mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(render): a renderer can draw weather: the weather capability adds globe.weather (clouds, fog, haze, rain and snow, 0 to 1, and the wind they drift on); the view shows the conditions observed under the camera, and the Display panel's Weather group sets them by hand
This commit is contained in:
1 parent
639e92b4f7
commit
0b1dc325bc
29 files changed
+869
-27
No files matched your search
@@ -76,20 +76,26 @@ function nestedShape(type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** `[member, optional]` for every member, nested shapes dotted. */
|
||||
function members(type, prefix = '') {
|
||||
/**
|
||||
* `[member, optional]` for every member, nested shapes dotted; a member of
|
||||
* an optional shape is as optional as the shape.
|
||||
*/
|
||||
function members(type, prefix = '', inOptional = false) {
|
||||
const out = [];
|
||||
for (const property of checker.getPropertiesOfType(type)) {
|
||||
const name = `${prefix}${property.name}`;
|
||||
const optional = Boolean(property.flags & ts.SymbolFlags.Optional);
|
||||
const optional =
|
||||
inOptional || Boolean(property.flags & ts.SymbolFlags.Optional);
|
||||
out.push([name, optional]);
|
||||
const declaration = property.valueDeclaration ?? property.declarations?.[0];
|
||||
const propertyType = checker.getTypeOfSymbolAtLocation(
|
||||
property,
|
||||
declaration,
|
||||
);
|
||||
const declared = checker.getTypeOfSymbolAtLocation(property, declaration);
|
||||
// An optional member's shape, without the `undefined` its `?` adds.
|
||||
const propertyType =
|
||||
property.flags & ts.SymbolFlags.Optional
|
||||
? checker.getNonNullableType(declared)
|
||||
: declared;
|
||||
const nested = nestedShape(propertyType);
|
||||
if (nested) out.push(...members(nested, `${name}.`));
|
||||
if (nested) out.push(...members(nested, `${name}.`, optional));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user