Files
feuerwerk/tools/lib/builders.mjs
T
rootandClaude Opus 5 ead649eec3 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>
2026-09-08 21:09:53 +02:00

41 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Small factories for writing project documents by hand (the seed scripts). They produce the
* exact shape `src/core/store/serialize.ts` reads; optional fields get their defaults.
*/
/** A scene object (also a container template entry). Position defaults to the origin. */
export const sceneObject = (
id,
assetId,
{ name = '', x = 0, y = 0, z = 0, overrides = {}, parentId = '', instanceEdits, editorOffset } = {},
) => ({
id,
assetId,
name,
position: { x, y, z },
overrides,
parentId,
...(instanceEdits ? { instanceEdits } : {}),
...(editorOffset ? { editorOffset } : {}),
});
/**
* The id an object of a placed container resolves to: `<instance>~<template ids>`. A placed
* container stores nothing but itself, so this is how its content is addressed – in the editor,
* in a running game and in the check scripts alike (see `src/core/model/instance.ts`).
*/
export const instanceChild = (instanceId, ...templatePath) => `${instanceId}~${templatePath.join('/')}`;
/** A graph edge from `from.fromPort` to `to.toPort`. */
export const edge = (id, from, fromPort, to, toPort) => ({
id,
from: { node: from, port: fromPort },
to: { node: to, port: toPort },
});
/** A graph node; `params` holds settings and inline input values alike. */
export const node = (id, type, x, y, params = {}) => ({ id, type, x, y, params });
/** A behavior variable declaration. */
export const variable = (key, kind, value) => ({ key, label: key, kind, default: value });