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:
1 parent
1eb28314cf
commit
f140c2fd77
58 files changed
+1969
-1171
No files matched your search
+5
-12
@@ -4,6 +4,7 @@ import type { Asset } from '../core/model/Asset';
|
||||
import { isPlaceableType } from '../core/model/AssetTypes';
|
||||
import { instantiateContainer } from '../core/model/container';
|
||||
import { findObject } from '../core/model/hierarchy';
|
||||
import { descendantsBelow } from '../core/model/walk';
|
||||
import { findAsset, findScene, type Project } from '../core/model/Project';
|
||||
import { createSceneObject, type SceneObject } from '../core/model/SceneObject';
|
||||
import { footprintContains } from '../core/properties/bounds';
|
||||
@@ -71,7 +72,7 @@ export class World {
|
||||
const keep = new Set<Entity>();
|
||||
for (const object of scene.objects) {
|
||||
const asset = findAsset(this.project, object.assetId);
|
||||
if (!asset || asset.type === 'scene') continue;
|
||||
if (!asset || !isPlaceableType(asset.type)) continue;
|
||||
keep.add(this.materialize(object, asset));
|
||||
}
|
||||
for (let i = this.entities.length - 1; i >= 0; i--) if (!keep.has(this.entities[i]!)) this.entities.splice(i, 1);
|
||||
@@ -121,7 +122,7 @@ export class World {
|
||||
entity.parent = parentEntity;
|
||||
for (const child of created.slice(1)) {
|
||||
const childAsset = findAsset(this.project, child.assetId);
|
||||
if (!childAsset || childAsset.type === 'scene') continue;
|
||||
if (!childAsset || !isPlaceableType(childAsset.type)) continue;
|
||||
this.materialize(child, childAsset).parent = this.findByObjectId(child.parentId) ?? null;
|
||||
}
|
||||
this.structureChanged = true;
|
||||
@@ -144,7 +145,7 @@ export class World {
|
||||
for (let i = scene.objects.length - 1; i >= 0; i--) {
|
||||
const object = scene.objects[i]!;
|
||||
const asset = findAsset(this.project, object.assetId);
|
||||
if (asset && asset.type !== 'scene' && !alive.has(object.id)) scene.objects.splice(i, 1);
|
||||
if (asset && isPlaceableType(asset.type) && !alive.has(object.id)) scene.objects.splice(i, 1);
|
||||
}
|
||||
for (const entity of this.entities) {
|
||||
const object = findObject(scene, entity.objectId);
|
||||
@@ -219,15 +220,7 @@ export class World {
|
||||
|
||||
/** Everything parented below an entity, at any depth. */
|
||||
descendantsOf(entity: Entity): Entity[] {
|
||||
const result: Entity[] = [];
|
||||
const visit = (parent: Entity) => {
|
||||
for (const child of this.childrenOf(parent)) {
|
||||
result.push(child);
|
||||
visit(child);
|
||||
}
|
||||
};
|
||||
visit(entity);
|
||||
return result;
|
||||
return descendantsBelow(entity, (parent) => this.childrenOf(parent), (child) => child);
|
||||
}
|
||||
|
||||
findByObjectId(objectId: string): Entity | undefined {
|
||||
|
||||
Reference in new issue
Block a user