Consolidate duplicated editor code, trim comments, refresh README
Split GraphCanvas (1076 -> 831 lines) into EdgeLayer and graphMenus; the port and marker menus were the same list and are now one function. Value specs of the inspector and the list tab share valueSpecs.ts, and the remaining copies (compound commands, type glyphs, typed asset lookup, name rule, play/editor world setup, marquee) are merged. Four copies had already drifted apart; merging them fixes: - "Disconnect N links" in the port menu is one undo step, not N - "+ Add collider" is hidden on a placed container instance, as in the hierarchy menu, instead of always failing - a bool property coerced from the text "false" becomes false - a port command on an unknown node type reports instead of crashing Comment-only edits leave the bundle byte-identical. README corrected in 35 places (step limit, jump-run clock, suite duration, 409 body, ...). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9212e61c4c
commit
8f92a06c84
96 files changed
+999
-1261
No files matched your search
@@ -1,14 +1,8 @@
|
||||
/**
|
||||
* A container placed in a scene is not copied into it. The scene stores the container object
|
||||
* alone; its content is resolved from the template on every read, so a template edit reaches
|
||||
* every instance at once. What the user changes on one of those resolved objects is kept as a
|
||||
* sparse `InstanceEdit` on the instance, keyed by the path of template ids leading to it – and
|
||||
* only where it actually deviates, which is what makes an untouched value keep following.
|
||||
*
|
||||
* Ids of resolved content are derived (`<instance id>~<path>`), never stored, and stable as long
|
||||
* as the template is: the selection, the hierarchy and the viewport address them like any other.
|
||||
* A placed container's content is resolved from its template on every read. Per-instance changes live
|
||||
* in sparse `instanceEdits` keyed by template-id path; derived ids `<instance>~<path>` are never stored.
|
||||
*/
|
||||
import type { Asset, ContainerAsset } from './Asset';
|
||||
import type { ContainerAsset } from './Asset';
|
||||
import type { ObjectTree } from './hierarchy';
|
||||
import {
|
||||
type Axis,
|
||||
@@ -19,7 +13,7 @@ import {
|
||||
setBagValue,
|
||||
type Vec2,
|
||||
} from './Properties';
|
||||
import { findAsset, type ObjectHolder, objectHolders, type Project } from './Project';
|
||||
import { findAssetOf, type ObjectHolder, objectHolders, type Project } from './Project';
|
||||
import type { SceneObject } from './SceneObject';
|
||||
|
||||
/** Neither character can occur inside an id (see `newId`), so a derived id parses back uniquely. */
|
||||
@@ -77,8 +71,7 @@ function mergeEdits(
|
||||
}
|
||||
|
||||
export function containerAssetOf(project: Project, object: SceneObject): ContainerAsset | undefined {
|
||||
const asset: Asset | undefined = findAsset(project, object.assetId);
|
||||
return asset?.type === 'container' ? asset : undefined;
|
||||
return findAssetOf(project, object.assetId, 'container');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,12 +196,8 @@ export interface InstanceTarget {
|
||||
asset: ContainerAsset;
|
||||
template: SceneObject;
|
||||
/**
|
||||
* What the object would show without this instance's edit: the template with the edits of every
|
||||
* container in between already woven in. Only this is a base a value can fall back to, so it –
|
||||
* not `template` – decides whether an edit deviates. The two differ once containers nest.
|
||||
*
|
||||
* Built fresh on every read, because "apply" writes into `template` and then asks whether the
|
||||
* edit still deviates – a base captured beforehand would answer for the old template.
|
||||
* The template with the edits of every container in between woven in – this, not `template`, decides
|
||||
* whether an edit deviates. Built fresh on every read, since "apply" writes into `template` first.
|
||||
*/
|
||||
readonly base: SceneObject;
|
||||
}
|
||||
@@ -219,8 +208,6 @@ export function instanceTargetOf(
|
||||
holder: ObjectTree,
|
||||
objectId: string,
|
||||
): InstanceTarget | undefined {
|
||||
// Unpacking keeps the derived ids, so the shape of the id alone still looks like content of a
|
||||
// template afterwards. What decides is whether the object is spelled out in the holder.
|
||||
if (!isTemplateContent(holder, objectId)) return undefined;
|
||||
const split = splitInstanceId(objectId);
|
||||
const instance = split && holder.objects.find((o) => o.id === split.instanceId);
|
||||
@@ -388,10 +375,8 @@ export function restoreObject(memo: ObjectMemo): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* One sparse bag of property overrides in the project, with the asset whose schema governs it:
|
||||
* a placed object's own, or the deviations a container instance keeps for its content. Anything
|
||||
* rewriting overrides across the project (removing or renaming a behavior variable, counting the
|
||||
* uses of a texture) has to cover both, or it silently misses everything inside a container.
|
||||
* One sparse override bag with the asset whose schema governs it: a placed object's own, or a container
|
||||
* instance's edits for its content. Project-wide rewrites must cover both or they miss container content.
|
||||
*/
|
||||
export interface OverrideSite {
|
||||
holder: ObjectHolder;
|
||||
|
||||
Reference in new issue
Block a user