Resolve container content from the template instead of copying it
A scene now stores only the container object; its content is resolved from the template on every read, with deviations kept as sparse instanceEdits on the container object. This drops the propagation bookkeeping entirely -- templateSync.ts is gone and the three structural gaps (add, remove, reparent) cannot diverge any more. Values stay editable on an instance, structure does not; Unpack writes the content into the scene, keeping ids. Play mode bakes containers into the throwaway copy before entities are built. No migration: formatVersion is 2 and the seeders write the new format. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d93020bd8
commit
ead649eec3
37 files changed
+1878
-1006
No files matched your search
+11
-2
@@ -27,6 +27,7 @@ const KEYS = {
|
||||
ArrowRight: { key: 'ArrowRight', code: 'ArrowRight', windowsVirtualKeyCode: 39 },
|
||||
Delete: { key: 'Delete', code: 'Delete', windowsVirtualKeyCode: 46 },
|
||||
a: { key: 'a', code: 'KeyA', windowsVirtualKeyCode: 65 },
|
||||
g: { key: 'g', code: 'KeyG', windowsVirtualKeyCode: 71 },
|
||||
z: { key: 'z', code: 'KeyZ', windowsVirtualKeyCode: 90 },
|
||||
};
|
||||
|
||||
@@ -164,8 +165,15 @@ function makeTools({ cdp, projectId, baseUrl, consoleLog, check, shotPrefix }) {
|
||||
json(
|
||||
'{ selection: __gm.state.selection, mode: __gm.state.mode, save: __gm.state.saveStatus, notice: __gm.state.notice }',
|
||||
);
|
||||
const objects = () => json('__gm.state.activeScene.objects');
|
||||
const object = (id) => json(`__gm.state.activeScene.objects.find((o) => o.id === ${JSON.stringify(id)})`);
|
||||
/**
|
||||
* The scene's objects the way the editor lists them: the content of a placed container is
|
||||
* resolved from its template and stored nowhere (see `src/core/model/instance.ts`), so it is in
|
||||
* here but not in `state.activeScene.objects`. Use `storedObjects()` for the latter.
|
||||
*/
|
||||
const objects = () => json('__gm.sceneObjects()');
|
||||
const object = (id) => json(`__gm.sceneObjects().find((o) => o.id === ${JSON.stringify(id)})`);
|
||||
/** Only what the scene really holds – a placed container counts as one object, not as its content. */
|
||||
const storedObjects = () => json('__gm.state.activeScene.objects');
|
||||
const asset = (id) => json(`__gm.state.project.assets.find((a) => a.id === ${JSON.stringify(id)})`);
|
||||
const world = () => json('__gm.world()');
|
||||
const entity = async (objectId) => (await world()).entities.find((e) => e.objectId === objectId);
|
||||
@@ -224,6 +232,7 @@ function makeTools({ cdp, projectId, baseUrl, consoleLog, check, shotPrefix }) {
|
||||
state,
|
||||
objects,
|
||||
object,
|
||||
storedObjects,
|
||||
asset,
|
||||
world,
|
||||
entity,
|
||||
|
||||
Reference in new issue
Block a user