Fix findUsages/undo/node-lookup bugs, split Viewport and Editor, share command and inspector helpers

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5 committed 2026-09-08 09:22:49 +02:00
1 parent 1eb28314cf
commit f140c2fd77
58 files changed
+1969 -1171

No files matched your search

+4 -12
View File
@@ -5,6 +5,7 @@ import { isAssetType } from '../model/AssetTypes';
import type { PropertyBag, PropertyValue } from '../model/Properties';
import { PROJECT_FORMAT_VERSION, type Project } from '../model/Project';
import type { SceneObject } from '../model/SceneObject';
import { hasParentCycle } from '../model/walk';
import { coerceValue, COMMON_PROPS, isCommonProp, type PropertyDef, type PropertySchema, schemaFor, VARIABLE_KINDS, variableDef, type VariableKind } from '../properties/PropertySchema';
/**
@@ -94,18 +95,9 @@ function normalizeObjects(raw: unknown, schemas: Map<string, PropertySchema>): S
// Parents must exist in the same scene, differ from the object itself and not form cycles.
const byId = new Map(objects.map((o) => [o.id, o]));
for (const o of objects) if (o.parentId && (o.parentId === o.id || !byId.has(o.parentId))) o.parentId = '';
for (const o of objects) {
const seen = new Set<string>([o.id]);
let current = o.parentId ? byId.get(o.parentId) : undefined;
while (current) {
if (seen.has(current.id)) {
o.parentId = '';
break;
}
seen.add(current.id);
current = current.parentId ? byId.get(current.parentId) : undefined;
}
}
// Cut one link per cycle: an object already unlinked here is a root for the objects checked after it.
const parentOf = (o: SceneObject) => (o.parentId ? byId.get(o.parentId) : undefined);
for (const o of objects) if (hasParentCycle(o, parentOf)) o.parentId = '';
return objects;
}