@vgai/engine 0.5.10 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/adapter/authoring.d.ts +51 -28
- package/dist/adapter/authoring.d.ts.map +1 -1
- package/dist/adapter/body-marks.d.ts +59 -0
- package/dist/adapter/body-marks.d.ts.map +1 -0
- package/dist/adapter/body-marks.js +62 -0
- package/dist/adapter/constraint.d.ts +41 -0
- package/dist/adapter/constraint.d.ts.map +1 -0
- package/dist/adapter/constraint.js +27 -0
- package/dist/adapter/hierarchy-marks.d.ts +138 -0
- package/dist/adapter/hierarchy-marks.d.ts.map +1 -0
- package/dist/adapter/hierarchy-marks.js +148 -0
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/ingest/contract-system-adapters.d.ts +64 -0
- package/dist/adapter/ingest/contract-system-adapters.d.ts.map +1 -0
- package/dist/adapter/ingest/contract-system-adapters.js +134 -0
- package/dist/adapter/ingest/game-contract.d.ts +89 -5
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
- package/dist/adapter/ingest/game-contract.js +11 -3
- package/dist/adapter/ingest/scene-capture.d.ts +31 -4
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
- package/dist/adapter/ingest/scene-capture.js +29 -7
- package/dist/adapter/ingest/structural-ids.d.ts +1 -1
- package/dist/adapter/ingest/structural-ids.js +2 -2
- package/dist/adapter/reflection-probe.d.ts +53 -0
- package/dist/adapter/reflection-probe.d.ts.map +1 -0
- package/dist/adapter/reflection-probe.js +18 -0
- package/dist/asset-formats/index.d.ts +4 -10
- package/dist/asset-formats/index.d.ts.map +1 -1
- package/dist/asset-formats/index.js +3 -8
- package/dist/asset-formats/material.d.ts +0 -66
- package/dist/asset-formats/material.d.ts.map +1 -1
- package/dist/asset-formats/material.js +0 -8
- package/dist/asset-formats/mesh.d.ts +1 -2
- package/dist/asset-formats/mesh.d.ts.map +1 -1
- package/dist/asset-formats/mesh.js +3 -13
- package/dist/asset-formats/render-env.d.ts +2 -2
- package/dist/asset-parse-error.d.ts +4 -5
- package/dist/asset-parse-error.d.ts.map +1 -1
- package/dist/asset-parse-error.js +4 -5
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -0
- package/dist/data/curve.d.ts +116 -0
- package/dist/data/curve.d.ts.map +1 -0
- package/dist/data/curve.js +230 -0
- package/dist/data/vite-plugin-data.d.ts +2 -2
- package/dist/data/vite-plugin-data.d.ts.map +1 -1
- package/dist/data/vite-plugin-data.js +24 -15
- package/dist/dev/performance-profiler.d.ts +1 -0
- package/dist/dev/performance-profiler.d.ts.map +1 -1
- package/dist/dev/performance-profiler.js +25 -2
- package/dist/dev/register-render-vitals.d.ts +18 -7
- package/dist/dev/register-render-vitals.d.ts.map +1 -1
- package/dist/dev/register-render-vitals.js +35 -8
- package/dist/ecs/user-data.d.ts +49 -1
- package/dist/ecs/user-data.d.ts.map +1 -1
- package/dist/ecs/user-data.js +34 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/manifest/index.d.ts +3 -3
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/manifest/index.js +2 -2
- package/dist/manifest/load.d.ts +20 -63
- package/dist/manifest/load.d.ts.map +1 -1
- package/dist/manifest/load.js +12 -103
- package/dist/manifest/schema.d.ts +21 -103
- package/dist/manifest/schema.d.ts.map +1 -1
- package/dist/manifest/schema.js +66 -142
- package/dist/pixi/index.d.ts +2 -3
- package/dist/pixi/index.d.ts.map +1 -1
- package/dist/pixi/index.js +2 -3
- package/dist/pixi/ingest.d.ts +7 -75
- package/dist/pixi/ingest.d.ts.map +1 -1
- package/dist/pixi/ingest.js +6 -14
- package/dist/pixi/scene-capture.d.ts +2 -2
- package/dist/pixi/scene-capture.js +2 -2
- package/dist/react/use-data.d.ts +10 -5
- package/dist/react/use-data.d.ts.map +1 -1
- package/dist/react/use-data.js +15 -15
- package/dist/render/viewport-shading.d.ts +1 -1
- package/dist/render/viewport-shading.d.ts.map +1 -1
- package/dist/render/viewport-shading.js +14 -0
- package/dist/runtime/create-runtime.d.ts +12 -0
- package/dist/runtime/create-runtime.d.ts.map +1 -1
- package/dist/runtime/create-runtime.js +7 -2
- package/dist/runtime/mount-game.d.ts +1 -1
- package/dist/runtime/mount-game.d.ts.map +1 -1
- package/dist/runtime/mount-manifest.d.ts.map +1 -1
- package/dist/runtime/mount-manifest.js +5 -1
- package/dist/world3d-react/r3f-adapter.d.ts.map +1 -1
- package/dist/world3d-react/r3f-adapter.js +129 -6
- package/dist/world3d-react/renderer-config.d.ts +15 -0
- package/dist/world3d-react/renderer-config.d.ts.map +1 -1
- package/dist/world3d-react/renderer-config.js +15 -0
- package/dist/world3d-react/world-context.d.ts +11 -1
- package/dist/world3d-react/world-context.d.ts.map +1 -1
- package/dist/world3d-react/world-context.js +1 -0
- package/dist-config/config.js +140 -20
- package/dist-config/config.js.map +4 -4
- package/package.json +1 -1
- package/schemas/engine-capabilities.json +10 -10
- package/schemas/vgai-project.schema.json +22 -73
- package/src/adapter/authoring.ts +54 -31
- package/src/adapter/body-marks.ts +69 -0
- package/src/adapter/constraint.ts +71 -0
- package/src/adapter/hierarchy-marks.ts +155 -0
- package/src/adapter/index.ts +2 -3
- package/src/adapter/ingest/contract-system-adapters.ts +174 -0
- package/src/adapter/ingest/game-contract.ts +104 -6
- package/src/adapter/ingest/scene-capture.ts +61 -11
- package/src/adapter/ingest/structural-ids.ts +2 -2
- package/src/adapter/reflection-probe.ts +75 -0
- package/src/asset-formats/index.ts +4 -10
- package/src/asset-formats/material.ts +0 -11
- package/src/asset-formats/mesh.ts +3 -16
- package/src/asset-parse-error.ts +4 -5
- package/src/config.ts +13 -0
- package/src/data/curve.ts +263 -0
- package/src/data/vite-plugin-data.ts +48 -14
- package/src/dev/performance-profiler.ts +21 -2
- package/src/dev/register-render-vitals.ts +38 -8
- package/src/ecs/user-data.ts +50 -0
- package/src/index.ts +2 -3
- package/src/manifest/index.ts +3 -15
- package/src/manifest/load.ts +33 -139
- package/src/manifest/schema.ts +72 -181
- package/src/pixi/index.ts +2 -15
- package/src/pixi/ingest.ts +13 -87
- package/src/pixi/scene-capture.ts +2 -2
- package/src/react/use-data.ts +15 -20
- package/src/render/viewport-shading.ts +16 -1
- package/src/runtime/create-runtime.ts +30 -5
- package/src/runtime/mount-game.ts +1 -1
- package/src/runtime/mount-manifest.ts +5 -1
- package/src/world3d-react/r3f-adapter.tsx +142 -6
- package/src/world3d-react/renderer-config.ts +31 -0
- package/src/world3d-react/world-context.ts +11 -1
- package/dist/asset-formats/instances.d.ts +0 -17
- package/dist/asset-formats/instances.d.ts.map +0 -1
- package/dist/asset-formats/instances.js +0 -31
- package/dist/asset-formats/parse.d.ts +0 -20
- package/dist/asset-formats/parse.d.ts.map +0 -1
- package/dist/asset-formats/parse.js +0 -34
- package/dist/pixi/ingest-iframe.d.ts +0 -82
- package/dist/pixi/ingest-iframe.d.ts.map +0 -1
- package/dist/pixi/ingest-iframe.js +0 -166
- package/dist/render/instance-mesh.d.ts +0 -5
- package/dist/render/instance-mesh.d.ts.map +0 -1
- package/dist/render/instance-mesh.js +0 -19
- package/schemas/mat.schema.json +0 -255
- package/src/asset-formats/instances.ts +0 -38
- package/src/asset-formats/parse.ts +0 -39
- package/src/pixi/ingest-iframe.ts +0 -255
- package/src/render/instance-mesh.ts +0 -25
|
@@ -100,18 +100,12 @@
|
|
|
100
100
|
"ingest": {
|
|
101
101
|
"type": "object",
|
|
102
102
|
"properties": {
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"shared",
|
|
107
|
-
"deduped",
|
|
108
|
-
"iframe-reachable",
|
|
109
|
-
"opaque-embed"
|
|
110
|
-
],
|
|
111
|
-
"description": "Capture mechanics rung this ingested root uses (§4) — also the root`s natural local capability tier"
|
|
103
|
+
"contractShim": {
|
|
104
|
+
"description": "Project-relative path to a HOST-ADDED ES module that declares this game's `window.vgaiGame` contract (adapter/ingest/game-contract.ts) WITHOUT editing a vendored byte — the pristine-copy door. The host imports it immediately BEFORE the game's own entry module, in the editor's realm. TIMING CONTRACT, which a shim author must obey: because it runs before the game`s entry, it MUST assign `window.vgaiGame` SYNCHRONOUSLY at top level. Anything that needs the game`s own modules must be LAZY: a dynamic `import()` INSIDE each verb/provider closure, resolved at call time. Importing a game module eagerly from the shim would evaluate it ahead of the game`s own entry and reorder its module side effects. Every such `import()` MUST take a STRING LITERAL, never a variable/table lookup. A variable specifier is not statically analyzable, so the dev server leaves it alone and it resolves at runtime against the shim`s own `/@fs/` url — while the game`s entry has had ITS relative imports rewritten to whatever url the server considers canonical for those files. Module identity is per-url, so the shim silently binds a SECOND, freshly-evaluated copy of the whole game and every provider reports a game that never started. Measured on three-descent: 285 segments through the game`s graph, 0 through the shim`s, and no error anywhere.",
|
|
105
|
+
"type": "string"
|
|
112
106
|
},
|
|
113
|
-
"
|
|
114
|
-
"description": "
|
|
107
|
+
"dataWriter": {
|
|
108
|
+
"description": "Project-relative path to a HOST-ADDED ES module that writes this game's own DATA file back — the sibling of a source write for a game whose authorable truth is not source. Descent places its robots, powerups and hostages in binary records inside `descent.hog`, reaching no source literal, so an authored move of one is an edit to that file and nothing else can write it. The module declares two exports and the host knows nothing else about it: `dataFile` (a project-relative string — the ONE file this writer edits) and `planDataEdit(bytes, {record, property, baseline, next})`, which returns `{changed: true, bytes}` or `{changed: false, reason}` and may be async. It is loaded in the editor realm beside the game, so it may `import()` the game's own modules to resolve what only a running game knows (Descent's writer asks the game`s own `find_point_seg` which segment a moved object landed in, and refuses \"outside the mine\" rather than writing data the game would read back wrong). It NEVER fabricates: a record it cannot address, or a property it does not model, is a named refusal. An object is anchored to a record by carrying `userData.vgaiRecordIndex` — the game declares that identity itself (a recorded patch or a shim); the host never infers one.",
|
|
115
109
|
"type": "string"
|
|
116
110
|
},
|
|
117
111
|
"assets": {
|
|
@@ -132,40 +126,11 @@
|
|
|
132
126
|
}
|
|
133
127
|
},
|
|
134
128
|
"captureTimeoutMs": {
|
|
135
|
-
"description": "How long
|
|
129
|
+
"description": "How long the host waits for this game's first captured frame before the mount FAILS by name. A game that needs a long boot (streamed world assets, a menu the player must clear) raises it; the default is 10s.",
|
|
136
130
|
"type": "number"
|
|
137
|
-
},
|
|
138
|
-
"bundleUrl": {
|
|
139
|
-
"description": "Absolute URL of the externalized built game bundle — the WIRED iframe-reachable mount route (iframe-reachable only), for BOTH canvas (Track P, ingest-iframe-2d.ts's mountIngestGame2DIframeReachableMulti) and three (D-W1, ingest-iframe-reachable-adapter.ts's mountIngestGameIframeReachableBundle). PRECONDITION: the bundle must externalize its root`s own runtime as a bare, un-rewritten import (`pixi.js` for canvas, `three` for three — `vgai bundle` does this for you) so it resolves through the iframe importmap to the HOST instance the capture trap is installed on; a bundle with an inlined runtime is unreachable and degrades to the embed-only floor. Exactly one of bundleUrl/entryHtml is required when strategy is iframe-reachable.",
|
|
140
|
-
"type": "string"
|
|
141
|
-
},
|
|
142
|
-
"baseHref": {
|
|
143
|
-
"description": "Iframe <base href> so the game's relative asset URLs resolve (iframe-reachable only).",
|
|
144
|
-
"type": "string"
|
|
145
|
-
},
|
|
146
|
-
"assetBaseUrl": {
|
|
147
|
-
"description": "Host-side basePath forced onto the trapped runtime's own asset resolution — pixi's `Assets.init` for a canvas root, three's `DefaultLoadingManager.setURLModifier` for a three root (D-W1) — absolute, or root-relative (resolved against the editor page's own origin at mount time, ingest-mode.ts, so a static manifest never has to know the dev-server port) (iframe-reachable only — a document.write iframe keeps the parent window.location).",
|
|
148
|
-
"type": "string"
|
|
149
|
-
},
|
|
150
|
-
"extraDeps": {
|
|
151
|
-
"description": "Bare specifiers of this root's externalized deps beyond its own runtime (pixi.js/three — e.g. '@pixi/sound', 'gsap'). Resolved by the editor's host-namespace registry into module namespaces when known (D-P1 — the manifest carries data, not code); an unregistered specifier falls back to the open project's own node_modules (D-Z3), served as a verbatim iframe importmap URL. Throws a named error if neither resolves it (iframe-reachable only).",
|
|
152
|
-
"type": "array",
|
|
153
|
-
"items": {
|
|
154
|
-
"type": "string"
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
"pixiModuleUrl": {
|
|
158
|
-
"description": "PIXI-ONLY: standalone matching-major pixi ESM URL to trap instead of the host pixi, for version-skewed games (e.g. a v6 game on a v8 host); this field's PRESENCE is how the skew is expressed (D-P2 — no separate strategy/tier for version skew) (iframe-reachable only). Declaring this on a `kind: \"three\"` root is schema-legal (this field is kind-agnostic here) but throws a NAMED not-supported error at resolve — three has no version-skew mount this wave (D-W7: a hypothetical `threeModuleUrl` is explicitly parked, no consumer exists).",
|
|
159
|
-
"type": "string"
|
|
160
|
-
},
|
|
161
|
-
"bodyHtml": {
|
|
162
|
-
"description": "HTML injected into the iframe body before the game script boots (e.g. a `<div id=\"game-root\">` the game expects to find) (iframe-reachable only).",
|
|
163
|
-
"type": "string"
|
|
164
131
|
}
|
|
165
132
|
},
|
|
166
|
-
"
|
|
167
|
-
"strategy"
|
|
168
|
-
],
|
|
133
|
+
"additionalProperties": false,
|
|
169
134
|
"description": "Ingest adapter configuration for an unmodified game (a repo-vendored game or your own external folder)"
|
|
170
135
|
}
|
|
171
136
|
},
|
|
@@ -200,42 +165,12 @@
|
|
|
200
165
|
},
|
|
201
166
|
"loop": {
|
|
202
167
|
"default": "gated",
|
|
203
|
-
"description": "gated: host-driven loop (default). self-driven: this root drives its own loop (
|
|
168
|
+
"description": "gated: host-driven loop (default). self-driven: this root drives its own loop (composited, unsynchronized)",
|
|
204
169
|
"type": "string",
|
|
205
170
|
"enum": [
|
|
206
171
|
"gated",
|
|
207
172
|
"self-driven"
|
|
208
173
|
]
|
|
209
|
-
},
|
|
210
|
-
"capabilities": {
|
|
211
|
-
"description": "Per-delivery-context capability tier declarations (§4). Declaring above the adapter's ceiling for that context is an error; declaring at or below it (including `unsupported`) is legal.",
|
|
212
|
-
"type": "object",
|
|
213
|
-
"properties": {
|
|
214
|
-
"local": {
|
|
215
|
-
"description": "Declared capability tier when served via the local CLI (Vite pipeline); omitted -> derived (§4)",
|
|
216
|
-
"type": "string",
|
|
217
|
-
"enum": [
|
|
218
|
-
"first-party",
|
|
219
|
-
"shared",
|
|
220
|
-
"deduped",
|
|
221
|
-
"iframe-reachable",
|
|
222
|
-
"opaque-embed",
|
|
223
|
-
"unsupported"
|
|
224
|
-
]
|
|
225
|
-
},
|
|
226
|
-
"hosted": {
|
|
227
|
-
"description": "Declared capability tier when served hosted (no bundler: esbuild-wasm + externals only); omitted -> derived (§4)",
|
|
228
|
-
"type": "string",
|
|
229
|
-
"enum": [
|
|
230
|
-
"first-party",
|
|
231
|
-
"shared",
|
|
232
|
-
"deduped",
|
|
233
|
-
"iframe-reachable",
|
|
234
|
-
"opaque-embed",
|
|
235
|
-
"unsupported"
|
|
236
|
-
]
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
174
|
}
|
|
240
175
|
},
|
|
241
176
|
"required": [
|
|
@@ -356,6 +291,20 @@
|
|
|
356
291
|
"height"
|
|
357
292
|
]
|
|
358
293
|
},
|
|
294
|
+
"rendering": {
|
|
295
|
+
"description": "Construction-time renderer properties, which no world can declare after the fact. Everything a world CAN declare (tone mapping, output colour space, clear colour, shadow filter) lives on the world's own renderer config instead.",
|
|
296
|
+
"type": "object",
|
|
297
|
+
"properties": {
|
|
298
|
+
"antialias": {
|
|
299
|
+
"type": "boolean",
|
|
300
|
+
"description": "Whether every three root is built with a multisampled drawing buffer. This is the ONE render property a world cannot declare for itself (world3d-react/renderer-config.ts): a WebGL context fixes its sample count at CREATION from this boolean, long before a world mounts, so it belongs to the PROJECT. The runtime reader is mount-manifest.ts, which threads it into createHostRenderer for each three root. WebGL exposes no sample COUNT — the implementation picks one (4x on every desktop browser measured), so a source engine that authored 8x/16x gets multisampling but not its exact count."
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"required": [
|
|
304
|
+
"antialias"
|
|
305
|
+
],
|
|
306
|
+
"additionalProperties": false
|
|
307
|
+
},
|
|
359
308
|
"debug": {
|
|
360
309
|
"description": "Debug-bridge production gating (D18) — governs whether ?vgai-debug=1 installs window.__vgai outside dev builds.",
|
|
361
310
|
"type": "object",
|
package/src/adapter/authoring.ts
CHANGED
|
@@ -238,7 +238,7 @@ export interface InspectorProvider {
|
|
|
238
238
|
/** Schema-driven — NOT fixed to `SceneEntity`. */
|
|
239
239
|
properties(id: string): PropertyDescriptor[];
|
|
240
240
|
get(id: string, path: string): unknown;
|
|
241
|
-
set(id: string, path: string, value: unknown): void
|
|
241
|
+
set(id: string, path: string, value: unknown): void | Promise<void>;
|
|
242
242
|
/**
|
|
243
243
|
* Optional — REMOVE a property's authored override entirely (not "set to a
|
|
244
244
|
* value"), letting whatever governs it in its absence take over. The one
|
|
@@ -281,6 +281,19 @@ export interface AssetSubjectProvider {
|
|
|
281
281
|
entries?(): ReadonlyArray<{ id: string; subject: AuthoringAssetSubject }>;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
/** A semantic jump from one authored subject to another document/subject.
|
|
285
|
+
* The adapter owns resolution and opening; the inspector only presents the
|
|
286
|
+
* title and exposes the same verb to human and serialized projections. */
|
|
287
|
+
export interface RelatedSubjectLink {
|
|
288
|
+
readonly id: string;
|
|
289
|
+
readonly title: string;
|
|
290
|
+
open(): void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface RelatedSubjectsProvider {
|
|
294
|
+
links(id: string): readonly RelatedSubjectLink[];
|
|
295
|
+
}
|
|
296
|
+
|
|
284
297
|
export interface StructureProvider {
|
|
285
298
|
create(kind: string, parentId?: string): string;
|
|
286
299
|
/**
|
|
@@ -384,26 +397,6 @@ export interface PersistenceProvider {
|
|
|
384
397
|
applyExternal?(content: unknown, rawContent?: string): void;
|
|
385
398
|
}
|
|
386
399
|
|
|
387
|
-
/** D8 — mutually-exclusive root groups (radio roots): e.g. a "Scenes" group whose
|
|
388
|
-
* members are the game's scene roots, only one of which is loaded/active at a
|
|
389
|
-
* time (unlike ordinary sibling roots, which all coexist). */
|
|
390
|
-
export interface RootGroup {
|
|
391
|
-
id: string; // stable, e.g. 'scenes'
|
|
392
|
-
label: string; // 'Scenes'
|
|
393
|
-
memberRootIds: string[]; // EditorNode ids; each is a hierarchy root
|
|
394
|
-
activeRootId: string | null;
|
|
395
|
-
}
|
|
396
|
-
export interface RootGroupsProvider {
|
|
397
|
-
groups(): RootGroup[];
|
|
398
|
-
activate(groupId: string, rootId: string): Promise<void> | void;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/** D8 — data-file → root mapping ("opening a file" = activating its root). */
|
|
402
|
-
export interface FileMapProvider {
|
|
403
|
-
/** project-relative path → node id this adapter maps it to, else null. */
|
|
404
|
-
rootForFile(path: string): string | null;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
400
|
/** D12 — per-layer viewport picking. Coordinates are client (browser) px. */
|
|
408
401
|
export interface PickProvider {
|
|
409
402
|
pick(clientX: number, clientY: number): string | null;
|
|
@@ -510,9 +503,11 @@ export interface BoxEditProvider {
|
|
|
510
503
|
referencePoint?(id: string): BoxEditReferencePoint | null;
|
|
511
504
|
}
|
|
512
505
|
|
|
513
|
-
/** Text-content editing
|
|
514
|
-
*
|
|
515
|
-
*
|
|
506
|
+
/** Text-content editing, ON the contract: the react-world adapter implements this
|
|
507
|
+
* provider (`react-world-authoring-adapter.ts`'s `readonly text: TextProvider`),
|
|
508
|
+
* bringing its own `editText(id)` write path onto the seam, so the overlay's
|
|
509
|
+
* double-click-to-edit-text (D3) is contract-driven rather than reaching for a
|
|
510
|
+
* concrete adapter's method. */
|
|
516
511
|
export interface TextProvider {
|
|
517
512
|
/** the element's editable pure-text, or null if the body is dynamic/has child elements */
|
|
518
513
|
get(id: string): string | null;
|
|
@@ -539,15 +534,46 @@ export interface ColorSampleProvider {
|
|
|
539
534
|
}
|
|
540
535
|
|
|
541
536
|
/**
|
|
542
|
-
* WO-IDX1 — where a node's live object
|
|
537
|
+
* WO-IDX1 — where a node's live object CAME FROM in the game's own truth.
|
|
543
538
|
*
|
|
544
|
-
* `display` is the
|
|
539
|
+
* `display` is the string the editor shows verbatim. The unanchored shape
|
|
545
540
|
* carries a `reason` rather than a blank, because "we don't know" and "a
|
|
546
541
|
* library built it" are different facts and neither may present as silence
|
|
547
542
|
* (the honest-floor rule).
|
|
543
|
+
*
|
|
544
|
+
* TWO ANCHORED KINDS, because a game has two kinds of truth and only one of
|
|
545
|
+
* them is source.
|
|
546
|
+
*
|
|
547
|
+
* - `source` is the original: a `new` expression at a `file:line:col` in the
|
|
548
|
+
* game's own code, which is where an edit to a constructor literal has to be
|
|
549
|
+
* written.
|
|
550
|
+
* - `data` is the sibling a level-based game needs. Descent's placed cargo —
|
|
551
|
+
* the robots, the powerups, the hostages — reaches no source literal at all;
|
|
552
|
+
* it is binary records inside `descent.hog` that the game parses at load. An
|
|
553
|
+
* authored move of a robot is therefore an edit to THE GAME'S OWN DATA, and
|
|
554
|
+
* the honest anchor is the data file plus the index of the record that
|
|
555
|
+
* addresses the object inside it.
|
|
556
|
+
*
|
|
557
|
+
* `kind` is an explicit discriminant rather than an inferred one, so a consumer
|
|
558
|
+
* that only understands source anchors fails to compile against a data anchor
|
|
559
|
+
* instead of silently reading `line` off something that has none.
|
|
560
|
+
*
|
|
561
|
+
* A data record is EXACTLY ONE object by construction — an index addresses one
|
|
562
|
+
* record — so the "how many objects did this site construct?" question that
|
|
563
|
+
* governs a source write has no data-side analogue and must not be invented
|
|
564
|
+
* for one.
|
|
548
565
|
*/
|
|
549
566
|
export type NodeCreationSite =
|
|
550
|
-
| { anchored: true; file: string; line: number; col: number; display: string }
|
|
567
|
+
| { anchored: true; kind: 'source'; file: string; line: number; col: number; display: string }
|
|
568
|
+
| {
|
|
569
|
+
anchored: true;
|
|
570
|
+
kind: 'data';
|
|
571
|
+
/** Project-relative path of the game's own data file, POSIX separators. */
|
|
572
|
+
file: string;
|
|
573
|
+
/** Index of the record inside that file which addresses this object. */
|
|
574
|
+
record: number;
|
|
575
|
+
display: string;
|
|
576
|
+
}
|
|
551
577
|
| { anchored: false; reason: string };
|
|
552
578
|
|
|
553
579
|
/**
|
|
@@ -571,12 +597,9 @@ export interface AuthoringAdapter {
|
|
|
571
597
|
readonly inspector?: InspectorProvider;
|
|
572
598
|
/** The selected node is an atomic asset that can open in the Asset Editor. */
|
|
573
599
|
readonly assetSubject?: AssetSubjectProvider;
|
|
600
|
+
readonly related?: RelatedSubjectsProvider;
|
|
574
601
|
readonly structure?: StructureProvider;
|
|
575
602
|
readonly persistence?: PersistenceProvider;
|
|
576
|
-
/** D8 — mutually-exclusive root groups (radio roots). Absent ⇒ no grouped roots. */
|
|
577
|
-
readonly rootGroups?: RootGroupsProvider;
|
|
578
|
-
/** D8 — data-file → root mapping. Absent ⇒ this adapter maps no files to roots. */
|
|
579
|
-
readonly files?: FileMapProvider;
|
|
580
603
|
/** D12 — per-layer viewport picking. Absent ⇒ this adapter is not pickable. */
|
|
581
604
|
readonly pickable?: PickProvider;
|
|
582
605
|
/** T0 (spec 27 §2) — per-node screen geometry for a DOM visual editor's overlay/
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The transform-AUTHORITY convention: how a game tells the host which of its
|
|
3
|
+
* nodes have their pose written by a rigid body rather than by the node itself.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of `hierarchy-marks.ts`, and the same shape of idea. That module's
|
|
6
|
+
* marks answer "what IS this node" for the panel; this one answers "who WRITES
|
|
7
|
+
* this node's pose" for an edit. Both are written by GAME code at the seam that
|
|
8
|
+
* knows the answer, read generically by the host, and namespaced `vgai*` because
|
|
9
|
+
* they are the host's namespace on a node the game owns.
|
|
10
|
+
*
|
|
11
|
+
* ## Why it exists
|
|
12
|
+
*
|
|
13
|
+
* A world that simulates writes `node.position/quaternion` FROM its bodies every
|
|
14
|
+
* step. Setting the node is therefore not an edit — it is a value that survives
|
|
15
|
+
* until the next step and then vanishes, which is what "the gizmo does nothing"
|
|
16
|
+
* looks like from the outside. The edit has to reach the body.
|
|
17
|
+
*
|
|
18
|
+
* The host cannot find the body on its own. Three.js has no body concept, the
|
|
19
|
+
* body is usually not in the scene graph at all, and the mapping from node to
|
|
20
|
+
* body is private to whichever code built the pair. So the code that ATTACHES a
|
|
21
|
+
* body to a node draws the link in the same breath — one call, at the one place
|
|
22
|
+
* the answer is known — exactly as `markBuiltInternal` is called at the attach
|
|
23
|
+
* seam and never by a later sweep of the tree.
|
|
24
|
+
*
|
|
25
|
+
* ## Prefer the system adapter when you have one
|
|
26
|
+
*
|
|
27
|
+
* A game that already registers `SystemAdapters.physics` needs none of this: the
|
|
28
|
+
* adapter's `ownerOf`/`freeze`/`commit`/`unfreeze` is the richer answer, and the
|
|
29
|
+
* editor asks it first. This mark is for the case that seam cannot cover — a
|
|
30
|
+
* world whose bodies are built by ordinary per-scene code with no central
|
|
31
|
+
* registry to hand a `bodyFor(nodeId)` resolver (every translated import lane),
|
|
32
|
+
* where the only place node and body meet is the constructor that made both.
|
|
33
|
+
* Marked nodes reach the SAME four verbs through
|
|
34
|
+
* {@link createRapierBodyEditing}; this is a second SOURCE for one mechanism,
|
|
35
|
+
* not a second mechanism.
|
|
36
|
+
*
|
|
37
|
+
* ## What to mark
|
|
38
|
+
*
|
|
39
|
+
* The node whose pose the body writes — normally the body's own root node. Not
|
|
40
|
+
* subtree-scoped (unlike `vgaiBuiltInternal`): a child of a body-driven node
|
|
41
|
+
* inherits its parent's motion through the transform chain, and its own local
|
|
42
|
+
* pose is still the node's to keep. Mark exactly the node the sync writes.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
import type * as THREE from 'three';
|
|
46
|
+
import { getUserData, setUserData } from '../ecs/user-data';
|
|
47
|
+
import type { RapierEditableBody } from './rapier-physics-adapter';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Declare that `body` owns `node`'s pose: a transform edit on `node` is applied
|
|
51
|
+
* to `body`, and the next step is what puts the result back on the node.
|
|
52
|
+
*
|
|
53
|
+
* Call it where the pair is created. `body` is the game's OWN Rapier body,
|
|
54
|
+
* passed through unchanged — the parameter type names five of Rapier's own
|
|
55
|
+
* methods structurally (see {@link RapierEditableBody}) because this repo
|
|
56
|
+
* legitimately resolves two copies of `@dimforge/rapier3d-compat` whose
|
|
57
|
+
* `RigidBody` classes are unrelated nominal types.
|
|
58
|
+
*/
|
|
59
|
+
export function markBodyOwnedNode(node: THREE.Object3D, body: RapierEditableBody): void {
|
|
60
|
+
setUserData(node, 'vgaiBodyOwner', body);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The body that owns `node`'s pose, or `undefined` for a node that owns its own. */
|
|
64
|
+
export function bodyOwningNode(
|
|
65
|
+
node: THREE.Object3D | null | undefined,
|
|
66
|
+
): RapierEditableBody | undefined {
|
|
67
|
+
const body = getUserData(node, 'vgaiBodyOwner');
|
|
68
|
+
return body ?? undefined;
|
|
69
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format-neutral live mark for source-owned spatial constraints.
|
|
3
|
+
*
|
|
4
|
+
* The project capability that performs a solve attaches one or more marks to
|
|
5
|
+
* the Object3D that owns the constrained pose. The editor reads the marks to
|
|
6
|
+
* render an ordinary constraint stack and transient viewport handles. This is
|
|
7
|
+
* observation, not authored data: the owning TS/TSX and its ordinary target /
|
|
8
|
+
* pole Object3Ds remain the only source of truth.
|
|
9
|
+
*/
|
|
10
|
+
import type * as THREE from 'three';
|
|
11
|
+
import { deleteUserData, getUserData, setUserData } from '../ecs/user-data';
|
|
12
|
+
|
|
13
|
+
export type ConstraintStatus = 'ready' | 'disabled' | 'unresolved' | 'error';
|
|
14
|
+
|
|
15
|
+
export interface ConstraintConfig {
|
|
16
|
+
/** Stable only within this mounted owner. */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly type: 'two-bone-ik' | 'ccd-ik' | (string & {});
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly enabled: boolean;
|
|
21
|
+
readonly weight: number;
|
|
22
|
+
/** Evaluation order among constraints attached to this owner. */
|
|
23
|
+
readonly order: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ConstraintSnapshot {
|
|
27
|
+
readonly status: ConstraintStatus;
|
|
28
|
+
readonly message?: string;
|
|
29
|
+
/** Root → effector, using the real bones from the live skeleton. */
|
|
30
|
+
readonly chain: readonly THREE.Object3D[];
|
|
31
|
+
readonly target: THREE.Object3D | null;
|
|
32
|
+
readonly pole: THREE.Object3D | null;
|
|
33
|
+
/** Effector-to-target distance after the latest solve, in world units. */
|
|
34
|
+
readonly error: number | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ConstraintMark {
|
|
38
|
+
readonly config: ConstraintConfig;
|
|
39
|
+
getSnapshot(): ConstraintSnapshot;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function constraintsOf(
|
|
43
|
+
object: THREE.Object3D | null | undefined,
|
|
44
|
+
): readonly ConstraintMark[] {
|
|
45
|
+
const candidate = getUserData(object, 'constraints');
|
|
46
|
+
if (!Array.isArray(candidate)) return [];
|
|
47
|
+
return candidate.filter(
|
|
48
|
+
(entry): entry is ConstraintMark =>
|
|
49
|
+
Boolean(entry) &&
|
|
50
|
+
typeof entry === 'object' &&
|
|
51
|
+
typeof (entry as Partial<ConstraintMark>).getSnapshot === 'function' &&
|
|
52
|
+
Boolean((entry as Partial<ConstraintMark>).config),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Add or replace one constraint mark without disturbing sibling constraints. */
|
|
57
|
+
export function setConstraintMark(object: THREE.Object3D, mark: ConstraintMark): void {
|
|
58
|
+
const next = constraintsOf(object).filter((entry) => entry.config.id !== mark.config.id);
|
|
59
|
+
setUserData(object, 'constraints', [...next, mark]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Remove one mark, or the whole live projection when no id is supplied. */
|
|
63
|
+
export function clearConstraintMark(object: THREE.Object3D, id?: string): void {
|
|
64
|
+
if (id === undefined) {
|
|
65
|
+
deleteUserData(object, 'constraints');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const next = constraintsOf(object).filter((entry) => entry.config.id !== id);
|
|
69
|
+
if (next.length === 0) deleteUserData(object, 'constraints');
|
|
70
|
+
else setUserData(object, 'constraints', next);
|
|
71
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hierarchy-presentation convention: how a game tells the editor which
|
|
3
|
+
* parts of its LIVE scene graph are one component instance, and which parts are
|
|
4
|
+
* implementation rather than content.
|
|
5
|
+
*
|
|
6
|
+
* ## Why marks and not a second tree
|
|
7
|
+
*
|
|
8
|
+
* The live tree IS the display surface. A hierarchy derived from source would
|
|
9
|
+
* be a mirror layer — a second model of the world that drifts from the one on
|
|
10
|
+
* screen — so the boundaries a reader needs have to live ON the nodes. That is
|
|
11
|
+
* what these marks are, and it is the whole mechanism: a component WRAPS its
|
|
12
|
+
* functionality and MARKS its root; the editor supports the convention
|
|
13
|
+
* generically and never learns which library, importer or lane produced the
|
|
14
|
+
* node.
|
|
15
|
+
*
|
|
16
|
+
* ## STRUCTURE IS THE TREE'S JOB. MARKS ONLY CLASSIFY.
|
|
17
|
+
*
|
|
18
|
+
* There is deliberately no mark that says "show this row somewhere else". A
|
|
19
|
+
* group owns its children by CONTAINING them; a prefab owns its parts by
|
|
20
|
+
* CONTAINING them. If an object reads as belonging under something it is not
|
|
21
|
+
* parented to, the tree is wrong and the tree is what to fix — because the
|
|
22
|
+
* panel is not the only reader. `getWorldPosition`, raycasting, disposal,
|
|
23
|
+
* `traverse`, every physics or gameplay walk and every person reading the
|
|
24
|
+
* source all follow real parenthood, and a presentation-only "logical parent"
|
|
25
|
+
* would be true for exactly one of them.
|
|
26
|
+
*
|
|
27
|
+
* The usual reason a world gets this wrong is that three's parent chain is a
|
|
28
|
+
* TRANSFORM chain: `matrixWorld` is unconditionally `parent × local`, so an
|
|
29
|
+
* object that must not inherit its owner's pose — a physics-driven body writing
|
|
30
|
+
* a world transform every step, a world-space trail or decal, a follow camera
|
|
31
|
+
* that must escape its target's rotation — gets mounted at the scene root, and
|
|
32
|
+
* ownership is lost as a side effect. **That trade is not necessary.** Set
|
|
33
|
+
* `object.matrixWorldAutoUpdate = false` (three r144+) and the parent's
|
|
34
|
+
* propagation skips it: the object stays parented where it belongs and its
|
|
35
|
+
* `matrixWorld` becomes yours to write. Keep it parented, own the matrix, and
|
|
36
|
+
* the hierarchy needs no help.
|
|
37
|
+
*
|
|
38
|
+
* These two marks then have exactly one job left, which is CLASSIFICATION:
|
|
39
|
+
* which of the objects that really are here is the game, and which is the
|
|
40
|
+
* machinery underneath it.
|
|
41
|
+
*
|
|
42
|
+
* ## What the hierarchy is FOR
|
|
43
|
+
*
|
|
44
|
+
* It shows YOUR GAME: the structure you authored, plus the objects your game
|
|
45
|
+
* makes while it runs. Nothing else. Three consequences, and every rule below
|
|
46
|
+
* follows from them:
|
|
47
|
+
*
|
|
48
|
+
* - **A spawned object is content.** A bullet you fired, a wave of enemies, a
|
|
49
|
+
* prop pulled out of a pool and parented into the level — these are rows.
|
|
50
|
+
* They exist, you can select them, and they are usually the exact things you
|
|
51
|
+
* opened the panel to look at. An object your game frees stops being a row,
|
|
52
|
+
* because it stopped existing.
|
|
53
|
+
* - **An implementation artifact is not.** The bones behind a rig, the batched
|
|
54
|
+
* renderer behind a particle system, the instanced-mesh pools behind a tile
|
|
55
|
+
* field, the `target` object three needs in order to aim a directional
|
|
56
|
+
* light: machinery a library or a helper builds so one thing you DID author
|
|
57
|
+
* can work. It belongs UNDER that thing, folded, not beside it.
|
|
58
|
+
* - **"Not in the source file" is the wrong test for either.** Half of a
|
|
59
|
+
* running world is not in the source file — that is what running means.
|
|
60
|
+
* Folding spawned gameplay because a document does not name it is the same
|
|
61
|
+
* defect as listing bones, in the more damaging direction: the rows it loses
|
|
62
|
+
* are the ones you were looking for.
|
|
63
|
+
*
|
|
64
|
+
* ## The two marks
|
|
65
|
+
*
|
|
66
|
+
* - {@link markComponentRoot} — "this subtree is one instance of `<name>`."
|
|
67
|
+
* The editor renders it as ONE row, closed, expandable on demand. Put it on
|
|
68
|
+
* the EARLIEST point the node exists: the constructor that makes it, or the
|
|
69
|
+
* ref callback that receives it. A component whose root is a plain `<mesh>`
|
|
70
|
+
* marks that mesh.
|
|
71
|
+
* - {@link markBuiltInternal} — "this is IMPLEMENTATION, not content." It is
|
|
72
|
+
* **subtree-scoped**: marking the root of a built subtree marks everything
|
|
73
|
+
* under it, so a 60-bone rig costs one call and folding is transitive. The
|
|
74
|
+
* editor hides these rows and offers them behind the same "Reveal Internals"
|
|
75
|
+
* action a source-backed instance's internals already use — revealed rows
|
|
76
|
+
* are read-only, because there is no authored source for a rename or a
|
|
77
|
+
* reparent to write to.
|
|
78
|
+
*
|
|
79
|
+
* An instance therefore reads as the parent of everything meaningful beneath
|
|
80
|
+
* it: content nested inside an implementation node is listed under the instance
|
|
81
|
+
* rather than lost with it (the editor's `hierarchy-component-marks.ts` calls
|
|
82
|
+
* that promotion), so marking a rig does not hide the mesh skinned to it.
|
|
83
|
+
*
|
|
84
|
+
* ## Mark it where the subtree is ATTACHED, by whoever attaches it
|
|
85
|
+
*
|
|
86
|
+
* A mark belongs at the attach seam: the code that puts an implementation
|
|
87
|
+
* subtree into the world marks it in the same breath, because that code is the
|
|
88
|
+
* only thing that knows the subtree is implementation. Not a later sweep of the
|
|
89
|
+
* tree — "everything present at time T that the source did not name" is the
|
|
90
|
+
* wrong predicate twice over. It arrives too early for anything attached
|
|
91
|
+
* asynchronously (a model clone landing after its bytes resolve, a node gated
|
|
92
|
+
* on an audio decode) and too late in principle for anything attached
|
|
93
|
+
* afterwards (every spawn) — and were it re-run to catch those, it would
|
|
94
|
+
* classify each spawned object as implementation, which is the second bullet
|
|
95
|
+
* above inverted. Attach-seam marking has neither failure: it fires once, at
|
|
96
|
+
* the moment the answer is known, and an unmarked node is content by default.
|
|
97
|
+
*
|
|
98
|
+
* The subtree scope is what keeps this cheap — one call per attached root, not
|
|
99
|
+
* one per node, so a rig or a pool costs one line at the one place that builds
|
|
100
|
+
* it.
|
|
101
|
+
*
|
|
102
|
+
* ## What is NOT built-internal
|
|
103
|
+
*
|
|
104
|
+
* A node your game means as content — even one a class rather than JSX
|
|
105
|
+
* constructs — is content. `vgaiBuiltInternal` is not "the editor cannot write
|
|
106
|
+
* this"; that question is `TransformProvider.editability`'s, answered per
|
|
107
|
+
* channel with a sentence. This mark answers "is this implementation", and
|
|
108
|
+
* getting it wrong hides real content.
|
|
109
|
+
*
|
|
110
|
+
* Both keys live in the typed `userData` registry (`../ecs/user-data.ts`) so
|
|
111
|
+
* their literal strings are spelled exactly once; this module is the only
|
|
112
|
+
* reader/writer, which is why the helpers below exist at all rather than
|
|
113
|
+
* `setUserData` calls scattered through emitters and prefabs.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
import type * as THREE from 'three';
|
|
117
|
+
import { getUserData, setUserData } from '../ecs/user-data';
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Declare `node` the root of one component instance, displayed under `name`.
|
|
121
|
+
*
|
|
122
|
+
* `name` is the COMPONENT's name (`'Coin'`, `'HeroBox'`), not the instance's —
|
|
123
|
+
* the instance is already named by `node.name`, and the editor prints both.
|
|
124
|
+
*/
|
|
125
|
+
export function markComponentRoot(node: THREE.Object3D, name: string): void {
|
|
126
|
+
setUserData(node, 'vgaiComponentRoot', name);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The component name `node` is the root of, or `undefined` for an ordinary node. */
|
|
130
|
+
export function componentRootName(node: THREE.Object3D | null | undefined): string | undefined {
|
|
131
|
+
const name = getUserData(node, 'vgaiComponentRoot');
|
|
132
|
+
return typeof name === 'string' && name ? name : undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Whether `node` is a marked component-instance root. */
|
|
136
|
+
export function isComponentRoot(node: THREE.Object3D | null | undefined): boolean {
|
|
137
|
+
return componentRootName(node) !== undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Declare `node` (and everything under it) IMPLEMENTATION of whatever node it
|
|
142
|
+
* sits under, rather than content of its own. Call it on the ROOT of the built
|
|
143
|
+
* subtree only, at the seam that attaches it — see this module's header for why
|
|
144
|
+
* the seam and not a sweep.
|
|
145
|
+
*/
|
|
146
|
+
export function markBuiltInternal(node: THREE.Object3D): void {
|
|
147
|
+
setUserData(node, 'vgaiBuiltInternal', true);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Whether `node` itself carries the implementation mark. Ancestry is the
|
|
151
|
+
* CALLER's walk — see this module's header for why the mark is subtree-scoped
|
|
152
|
+
* but not restamped onto descendants. */
|
|
153
|
+
export function isBuiltInternal(node: THREE.Object3D | null | undefined): boolean {
|
|
154
|
+
return getUserData(node, 'vgaiBuiltInternal') === true;
|
|
155
|
+
}
|
package/src/adapter/index.ts
CHANGED
|
@@ -39,7 +39,6 @@ export type {
|
|
|
39
39
|
DOMRectLike,
|
|
40
40
|
EditorNode,
|
|
41
41
|
EditorNodeRole,
|
|
42
|
-
FileMapProvider,
|
|
43
42
|
HierarchyProvider,
|
|
44
43
|
InspectorProvider,
|
|
45
44
|
NodeCreationSite,
|
|
@@ -47,8 +46,8 @@ export type {
|
|
|
47
46
|
PickProvider,
|
|
48
47
|
PropertyDescriptor,
|
|
49
48
|
RectProvider,
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
RelatedSubjectLink,
|
|
50
|
+
RelatedSubjectsProvider,
|
|
52
51
|
SelectionProvider,
|
|
53
52
|
SelectionResolution,
|
|
54
53
|
StoriesProvider,
|