Multiselection and container assets: create container from selection, template instances
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
91ee2feadd
commit
0b78382bcc
26 files changed
+897
-114
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { worldPositionOf } from '../core/graph';
|
||||
import { instantiateContainer } from '../core/model/container';
|
||||
import { newId } from '../core/ids';
|
||||
import type { Asset } from '../core/model/Asset';
|
||||
import { isPlaceableType } from '../core/model/AssetTypes';
|
||||
@@ -96,9 +97,16 @@ export class World {
|
||||
if (!scene || !asset || !isPlaceableType(asset.type)) return null;
|
||||
const parentEntity = parent && this.entities.includes(parent) ? parent : null;
|
||||
const object = createSceneObject(newId(), asset.id, position, parentEntity?.objectId ?? '');
|
||||
scene.objects.push(object);
|
||||
// A container brings its content along (parented below it, in template order).
|
||||
const created = [object, ...(asset.type === 'container' ? instantiateContainer(this.project, asset, object.id) : [])];
|
||||
scene.objects.push(...created);
|
||||
const entity = this.materialize(object, asset);
|
||||
entity.parent = parentEntity;
|
||||
for (const child of created.slice(1)) {
|
||||
const childAsset = findAsset(this.project, child.assetId);
|
||||
if (!childAsset || childAsset.type === 'scene') continue;
|
||||
this.materialize(child, childAsset).parent = this.findByObjectId(child.parentId) ?? null;
|
||||
}
|
||||
this.structureChanged = true;
|
||||
return entity;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user