@vgai/engine 0.5.21 → 0.5.23
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 -3
- package/dist/adapter/adapter-module.d.ts.map +1 -1
- package/dist/adapter/adapter-module.js +2 -4
- package/dist/adapter/adapter-surface.d.ts +1 -1
- package/dist/adapter/adapter-surface.js +1 -1
- package/dist/adapter/authoring.d.ts +19 -21
- package/dist/adapter/authoring.d.ts.map +1 -1
- package/dist/adapter/authoring.js +2 -2
- package/dist/adapter/binding.d.ts +341 -0
- package/dist/adapter/binding.d.ts.map +1 -0
- package/dist/adapter/binding.js +148 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -1
- package/dist/adapter/colyseus-networking-adapter.js +23 -4
- package/dist/adapter/entrypoint-selection-readers.d.ts +24 -0
- package/dist/adapter/entrypoint-selection-readers.d.ts.map +1 -0
- package/dist/adapter/entrypoint-selection-readers.js +63 -0
- package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -1
- package/dist/adapter/entrypoint-selection-source.js +1 -44
- package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
- package/dist/adapter/finders/scenes-from-entrypoint-selection.js +1 -52
- package/dist/adapter/host-context.d.ts +46 -15
- package/dist/adapter/host-context.d.ts.map +1 -1
- package/dist/adapter/host-context.js +2 -9
- package/dist/adapter/index.d.ts +11 -12
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +9 -10
- package/dist/adapter/ingest/game-contract.d.ts +0 -3
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
- package/dist/adapter/ingest/game-contract.js +0 -3
- package/dist/adapter/ingest/scene-capture.d.ts +19 -23
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
- package/dist/adapter/ingest/scene-capture.js +143 -17
- package/dist/adapter/ingest/visible-capture-window.d.ts +34 -0
- package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
- package/dist/adapter/manifest-interpreter.d.ts +59 -0
- package/dist/adapter/manifest-interpreter.d.ts.map +1 -0
- package/dist/adapter/manifest-interpreter.js +50 -0
- package/dist/adapter/native-debug-module.d.ts +71 -3
- package/dist/adapter/native-debug-module.d.ts.map +1 -1
- package/dist/adapter/native-debug-module.js +146 -10
- package/dist/adapter/rapier-physics-adapter.d.ts +31 -1
- package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -1
- package/dist/adapter/rapier-physics-adapter.js +50 -36
- package/dist/adapter/renderer-config.d.ts +3 -3
- package/dist/adapter/renderer-config.js +3 -3
- package/dist/adapter/root-adapter.d.ts +7 -7
- package/dist/adapter/root-adapter.js +4 -4
- package/dist/adapter/system-adapter.d.ts +45 -7
- package/dist/adapter/system-adapter.d.ts.map +1 -1
- package/dist/adapter/system-seam-contract.d.ts +3 -3
- package/dist/adapter/system-seam-contract.js +3 -3
- package/dist/adapter/system-slot.d.ts +168 -0
- package/dist/adapter/system-slot.d.ts.map +1 -0
- package/dist/adapter/system-slot.js +229 -0
- package/dist/adapter/transform.d.ts +11 -1
- package/dist/adapter/transform.d.ts.map +1 -1
- package/dist/ai/navigation.d.ts +17 -1
- package/dist/ai/navigation.d.ts.map +1 -1
- package/dist/ai/navigation.js +26 -5
- package/dist/animation/anim-graph-types.d.ts +11 -3
- package/dist/animation/anim-graph-types.d.ts.map +1 -1
- package/dist/animation/theatre-clock-binding.d.ts +4 -4
- package/dist/animation/theatre-clock-binding.js +4 -4
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
- package/dist/animation/xstate-animation-binding.js +2 -2
- package/dist/animation/xstate-animation-meta.d.ts +13 -0
- package/dist/animation/xstate-animation-meta.d.ts.map +1 -1
- package/dist/animation/xstate-animation-meta.js +14 -0
- package/dist/asset-formats/index.d.ts +4 -7
- package/dist/asset-formats/index.d.ts.map +1 -1
- package/dist/asset-formats/index.js +4 -7
- package/dist/asset-formats/render-env.d.ts +5 -8
- package/dist/asset-formats/render-env.d.ts.map +1 -1
- package/dist/asset-formats/render-env.js +3 -6
- package/dist/asset-parse-error.d.ts +2 -5
- package/dist/asset-parse-error.d.ts.map +1 -1
- package/dist/asset-parse-error.js +2 -5
- package/dist/audio/bus-mixer.d.ts +101 -0
- package/dist/audio/bus-mixer.d.ts.map +1 -0
- package/dist/audio/bus-mixer.js +115 -0
- package/dist/canvas-react/index.d.ts +5 -12
- package/dist/canvas-react/index.d.ts.map +1 -1
- package/dist/canvas-react/index.js +5 -12
- package/dist/canvas-react/pixi-react-root-factory.d.ts +34 -21
- package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
- package/dist/canvas-react/pixi-react-root-factory.js +274 -36
- package/dist/core/countdown-timer.d.ts +118 -0
- package/dist/core/countdown-timer.d.ts.map +1 -0
- package/dist/core/countdown-timer.js +137 -0
- package/dist/core/deferred-commands.d.ts +127 -0
- package/dist/core/deferred-commands.d.ts.map +1 -0
- package/dist/core/deferred-commands.js +132 -0
- package/dist/core/frame-pacing.d.ts +1 -1
- package/dist/core/frame-pacing.js +2 -2
- package/dist/core/game-loop.d.ts +1 -3
- package/dist/core/game-loop.d.ts.map +1 -1
- package/dist/core/game-loop.js +1 -3
- package/dist/core/seeded-random.d.ts +1 -1
- package/dist/core/sim-clock.d.ts +19 -8
- package/dist/core/sim-clock.d.ts.map +1 -1
- package/dist/core/sim-clock.js +18 -7
- package/dist/core/types.d.ts +1 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/defaults.d.ts +6 -14
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +6 -14
- package/dist/dev/instruments.d.ts +38 -11
- package/dist/dev/instruments.d.ts.map +1 -1
- package/dist/dev/instruments.js +81 -11
- package/dist/dev/register-render-vitals.d.ts +1 -4
- package/dist/dev/register-render-vitals.d.ts.map +1 -1
- package/dist/dev/register-render-vitals.js +1 -4
- package/dist/dev/render-debug-adapter.d.ts +2 -3
- package/dist/dev/render-debug-adapter.d.ts.map +1 -1
- package/dist/dev/render-debug-adapter.js +2 -3
- package/dist/dev/render-vitals.d.ts +3 -3
- package/dist/dev/render-vitals.js +3 -3
- package/dist/dev/webgl-frame-capture.d.ts +1 -1
- package/dist/dev/webgl-frame-capture.js +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/input/host-pointer.d.ts +122 -0
- package/dist/input/host-pointer.d.ts.map +1 -0
- package/dist/input/host-pointer.js +160 -0
- package/dist/input/input-manager.d.ts +33 -5
- package/dist/input/input-manager.d.ts.map +1 -1
- package/dist/input/input-manager.js +48 -13
- package/dist/input/rebind-controller.d.ts.map +1 -1
- package/dist/input/rebind-controller.js +6 -8
- package/dist/input/schema.d.ts.map +1 -1
- package/dist/input/schema.js +56 -28
- package/dist/manifest/filename.d.ts.map +1 -1
- package/dist/manifest/filename.js +8 -12
- package/dist/manifest/load.d.ts +10 -10
- package/dist/manifest/load.d.ts.map +1 -1
- package/dist/manifest/load.js +9 -6
- package/dist/manifest/schema.d.ts +17 -21
- package/dist/manifest/schema.d.ts.map +1 -1
- package/dist/manifest/schema.js +45 -35
- package/dist/physics/collider-dimensions.d.ts +8 -12
- package/dist/physics/collider-dimensions.d.ts.map +1 -1
- package/dist/physics/collider-dimensions.js +8 -12
- package/dist/pixi/scene-capture.d.ts +11 -13
- package/dist/pixi/scene-capture.d.ts.map +1 -1
- package/dist/react/world-state.d.ts +1 -1
- package/dist/react/world-state.d.ts.map +1 -1
- package/dist/render/directional-shadow-fit.d.ts +88 -0
- package/dist/render/directional-shadow-fit.d.ts.map +1 -0
- package/dist/render/directional-shadow-fit.js +133 -0
- package/dist/render/environment-capture.d.ts +68 -0
- package/dist/render/environment-capture.d.ts.map +1 -0
- package/dist/render/environment-capture.js +90 -0
- package/dist/render/ibl-override-material.d.ts +97 -0
- package/dist/render/ibl-override-material.d.ts.map +1 -0
- package/dist/render/ibl-override-material.js +114 -0
- package/dist/render/light-camera-factory.d.ts +5 -7
- package/dist/render/light-camera-factory.d.ts.map +1 -1
- package/dist/render/light-camera-factory.js +8 -11
- package/dist/render/material-factory.js +1 -1
- package/dist/render/render-batch-system.d.ts.map +1 -1
- package/dist/render/render-features.d.ts +17 -6
- package/dist/render/render-features.d.ts.map +1 -1
- package/dist/render/render-features.js +0 -28
- package/dist/runtime/create-runtime.d.ts +34 -25
- package/dist/runtime/create-runtime.d.ts.map +1 -1
- package/dist/runtime/create-runtime.js +218 -93
- package/dist/runtime/debug-registry.d.ts +77 -8
- package/dist/runtime/debug-registry.d.ts.map +1 -1
- package/dist/runtime/debug-registry.js +3 -3
- package/dist/runtime/dev-build.d.ts +2 -2
- package/dist/runtime/dev-build.js +2 -2
- package/dist/runtime/game-input-seams.d.ts +51 -0
- package/dist/runtime/game-input-seams.d.ts.map +1 -0
- package/dist/runtime/game-input-seams.js +86 -0
- package/dist/runtime/game.d.ts +104 -40
- package/dist/runtime/game.d.ts.map +1 -1
- package/dist/runtime/game.js +119 -61
- package/dist/runtime/mount-game.d.ts +0 -16
- package/dist/runtime/mount-game.d.ts.map +1 -1
- package/dist/runtime/mount-game.js +26 -41
- package/dist/runtime/mount-manifest.d.ts +22 -14
- package/dist/runtime/mount-manifest.d.ts.map +1 -1
- package/dist/runtime/mount-manifest.js +22 -20
- package/dist/runtime/playtest.d.ts +22 -0
- package/dist/runtime/playtest.d.ts.map +1 -0
- package/dist/runtime/playtest.js +12 -0
- package/dist/runtime/state-bridge.d.ts +2 -3
- package/dist/runtime/state-bridge.d.ts.map +1 -1
- package/dist/runtime/state-bridge.js +1 -0
- package/dist/setup/setup-audio.d.ts +12 -0
- package/dist/setup/setup-audio.d.ts.map +1 -1
- package/dist/setup/setup-audio.js +9 -10
- package/dist/setup/setup-renderer.d.ts +2 -25
- package/dist/setup/setup-renderer.d.ts.map +1 -1
- package/dist/setup/setup-renderer.js +2 -31
- package/dist/world3d-react/index.d.ts +15 -25
- package/dist/world3d-react/index.d.ts.map +1 -1
- package/dist/world3d-react/index.js +15 -25
- package/dist/world3d-react/r3f-root-factory.d.ts +28 -34
- package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
- package/dist/world3d-react/r3f-root-factory.js +403 -57
- package/dist/world3d-react/rapier-physics-bridge.d.ts +30 -17
- package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -1
- package/dist/world3d-react/rapier-physics-bridge.js +143 -58
- package/package.json +1 -1
- package/schemas/engine-capabilities.json +16 -14
- package/schemas/vgai-project.schema.json +35 -26
- package/src/adapter/adapter-module.ts +2 -4
- package/src/adapter/adapter-surface.ts +1 -1
- package/src/adapter/authoring.ts +19 -21
- package/src/adapter/binding.ts +468 -0
- package/src/adapter/colyseus-networking-adapter.ts +20 -5
- package/src/adapter/entrypoint-selection-readers.ts +66 -0
- package/src/adapter/entrypoint-selection-source.ts +1 -40
- package/src/adapter/finders/scenes-from-entrypoint-selection.ts +1 -48
- package/src/adapter/host-context.ts +45 -15
- package/src/adapter/index.ts +23 -11
- package/src/adapter/ingest/game-contract.ts +0 -3
- package/src/adapter/ingest/scene-capture.ts +190 -39
- package/src/adapter/ingest/visible-capture-window.ts +35 -0
- package/src/adapter/manifest-interpreter.ts +64 -0
- package/src/adapter/native-debug-module.ts +248 -15
- package/src/adapter/rapier-physics-adapter.ts +76 -20
- package/src/adapter/renderer-config.ts +3 -3
- package/src/adapter/root-adapter.ts +7 -7
- package/src/adapter/system-adapter.ts +43 -8
- package/src/adapter/system-seam-contract.ts +3 -3
- package/src/adapter/system-slot.ts +291 -0
- package/src/adapter/transform.ts +18 -1
- package/src/ai/navigation.ts +30 -3
- package/src/animation/anim-graph-types.ts +11 -3
- package/src/animation/theatre-clock-binding.ts +4 -4
- package/src/animation/xstate-animation-binding.ts +2 -2
- package/src/animation/xstate-animation-meta.ts +16 -0
- package/src/asset-formats/index.ts +4 -7
- package/src/asset-formats/render-env.ts +3 -6
- package/src/asset-parse-error.ts +2 -5
- package/src/audio/bus-mixer.ts +161 -0
- package/src/canvas-react/index.ts +5 -21
- package/src/canvas-react/pixi-react-root-factory.tsx +301 -39
- package/src/core/countdown-timer.ts +188 -0
- package/src/core/deferred-commands.ts +174 -0
- package/src/core/frame-pacing.ts +2 -2
- package/src/core/game-loop.ts +1 -3
- package/src/core/seeded-random.ts +1 -1
- package/src/core/sim-clock.ts +19 -8
- package/src/core/types.ts +1 -3
- package/src/defaults.ts +6 -14
- package/src/dev/instruments.ts +108 -11
- package/src/dev/register-render-vitals.ts +1 -4
- package/src/dev/render-debug-adapter.ts +2 -3
- package/src/dev/render-vitals.ts +3 -3
- package/src/dev/webgl-frame-capture.ts +1 -1
- package/src/index.ts +2 -5
- package/src/input/host-pointer.ts +230 -0
- package/src/input/input-manager.ts +49 -13
- package/src/input/input-types.ts +1 -1
- package/src/input/rebind-controller.ts +6 -8
- package/src/input/schema.ts +216 -188
- package/src/manifest/filename.ts +8 -12
- package/src/manifest/load.ts +17 -13
- package/src/manifest/schema.ts +55 -47
- package/src/physics/collider-dimensions.ts +8 -12
- package/src/pixi/scene-capture.ts +12 -15
- package/src/react/world-state.tsx +1 -1
- package/src/render/directional-shadow-fit.ts +156 -0
- package/src/render/environment-capture.ts +102 -0
- package/src/render/ibl-override-material.ts +170 -0
- package/src/render/light-camera-factory.ts +8 -11
- package/src/render/material-factory.ts +1 -1
- package/src/render/render-batch-system.ts +14 -6
- package/src/render/render-features.ts +17 -35
- package/src/runtime/create-runtime.ts +270 -108
- package/src/runtime/debug-registry.ts +84 -8
- package/src/runtime/dev-build.ts +2 -2
- package/src/runtime/game-input-seams.ts +108 -0
- package/src/runtime/game.ts +231 -85
- package/src/runtime/mount-game.ts +31 -57
- package/src/runtime/mount-manifest.ts +47 -36
- package/src/runtime/playtest.ts +22 -0
- package/src/runtime/state-bridge.ts +3 -3
- package/src/setup/setup-audio.ts +21 -11
- package/src/setup/setup-renderer.ts +2 -61
- package/src/world3d-react/index.ts +15 -31
- package/src/world3d-react/r3f-root-factory.tsx +451 -60
- package/src/world3d-react/rapier-physics-bridge.tsx +154 -58
- package/dist/adapter/setup-three-root-adapter.d.ts +0 -86
- package/dist/adapter/setup-three-root-adapter.d.ts.map +0 -1
- package/dist/adapter/setup-three-root-adapter.js +0 -908
- package/dist/animation/clip-map.d.ts +0 -12
- package/dist/animation/clip-map.d.ts.map +0 -1
- package/dist/animation/clip-map.js +0 -31
- package/dist/asset-registry.d.ts +0 -38
- package/dist/asset-registry.d.ts.map +0 -1
- package/dist/asset-registry.js +0 -66
- package/dist/canvas-react/engine-bridge.d.ts +0 -45
- package/dist/canvas-react/engine-bridge.d.ts.map +0 -1
- package/dist/canvas-react/engine-bridge.js +0 -45
- package/dist/canvas-react/pixi-react-adapter.d.ts +0 -77
- package/dist/canvas-react/pixi-react-adapter.d.ts.map +0 -1
- package/dist/canvas-react/pixi-react-adapter.js +0 -294
- package/dist/canvas-react/world-context.d.ts +0 -98
- package/dist/canvas-react/world-context.d.ts.map +0 -1
- package/dist/canvas-react/world-context.js +0 -173
- package/dist/dev/debug-draw.d.ts +0 -24
- package/dist/dev/debug-draw.d.ts.map +0 -1
- package/dist/dev/debug-draw.js +0 -73
- package/dist/render/auto-batcher.d.ts +0 -34
- package/dist/render/auto-batcher.d.ts.map +0 -1
- package/dist/render/auto-batcher.js +0 -140
- package/dist/render/lod.d.ts +0 -13
- package/dist/render/lod.d.ts.map +0 -1
- package/dist/render/lod.js +0 -16
- package/dist/runtime/types.d.ts +0 -303
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/types.js +0 -1
- package/dist/world3d-react/engine-bridge.d.ts +0 -47
- package/dist/world3d-react/engine-bridge.d.ts.map +0 -1
- package/dist/world3d-react/engine-bridge.js +0 -73
- package/dist/world3d-react/r3f-adapter.d.ts +0 -58
- package/dist/world3d-react/r3f-adapter.d.ts.map +0 -1
- package/dist/world3d-react/r3f-adapter.js +0 -634
- package/dist/world3d-react/world-context.d.ts +0 -182
- package/dist/world3d-react/world-context.d.ts.map +0 -1
- package/dist/world3d-react/world-context.js +0 -235
- package/src/adapter/setup-three-root-adapter.ts +0 -1032
- package/src/animation/clip-map.ts +0 -34
- package/src/asset-registry.ts +0 -89
- package/src/canvas-react/engine-bridge.ts +0 -59
- package/src/canvas-react/pixi-react-adapter.tsx +0 -356
- package/src/canvas-react/world-context.ts +0 -253
- package/src/dev/debug-draw.ts +0 -80
- package/src/render/auto-batcher.ts +0 -168
- package/src/render/lod.ts +0 -17
- package/src/runtime/types.ts +0 -328
- package/src/world3d-react/engine-bridge.ts +0 -86
- package/src/world3d-react/r3f-adapter.tsx +0 -717
- package/src/world3d-react/world-context.ts +0 -358
|
@@ -20,7 +20,19 @@ import type { Transform, TransformOwner } from './transform';
|
|
|
20
20
|
export type PhysicsColliderShape =
|
|
21
21
|
| { readonly type: 'cuboid'; readonly halfExtents: readonly [number, number, number] }
|
|
22
22
|
| { readonly type: 'ball'; readonly radius: number }
|
|
23
|
-
| { readonly type: 'capsule'; readonly halfHeight: number; readonly radius: number }
|
|
23
|
+
| { readonly type: 'capsule'; readonly halfHeight: number; readonly radius: number }
|
|
24
|
+
/**
|
|
25
|
+
* A collider this seam has no plain-data projection for — a trimesh,
|
|
26
|
+
* heightfield, convex hull, cylinder, cone, …
|
|
27
|
+
*
|
|
28
|
+
* IT IS STILL A COLLIDER, and the body still has it. Implementations used to
|
|
29
|
+
* drop these from `colliders()` entirely, so a body whose only collider was a
|
|
30
|
+
* trimesh inspected as a body with NO physics at all. `kind` is the native
|
|
31
|
+
* shape's own name, so the inspector can say WHICH shape it cannot draw
|
|
32
|
+
* rather than implying nothing is there. Nothing may synthesize dimensions
|
|
33
|
+
* for one, and `previewCollider` refuses it.
|
|
34
|
+
*/
|
|
35
|
+
| { readonly type: 'unsupported'; readonly kind: string };
|
|
24
36
|
|
|
25
37
|
/** Plain-data projection of one native 3D physics collider. The owning
|
|
26
38
|
* physics implementation keeps the actual collider; editor authoring only
|
|
@@ -249,12 +261,28 @@ export interface NetworkingAdapter {
|
|
|
249
261
|
authority(nodeId: string): 'local' | 'remote' | 'server';
|
|
250
262
|
/** Remote/server-authoritative nodes → inspect-only in the editor. */
|
|
251
263
|
editable(nodeId: string): boolean;
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Optional capability: current connection lifecycle state.
|
|
266
|
+
*
|
|
267
|
+
* OPTIONAL for the same reason every other member here is — `'disconnected'`
|
|
268
|
+
* is a POSITIVE CLAIM about the link, and an implementer that never taught
|
|
269
|
+
* this adapter to read connection state has not made it. Absent ⇒ the
|
|
270
|
+
* inspector marks the section unsupported; it does not report a game as
|
|
271
|
+
* disconnected on the strength of nobody having looked.
|
|
272
|
+
*/
|
|
273
|
+
getConnectionState?(): ConnectionState;
|
|
274
|
+
/**
|
|
275
|
+
* Optional capability: the active room's identity, or `null` when connected
|
|
276
|
+
* to no room. `null` is the ANSWER "there is no room", so absence of the
|
|
277
|
+
* accessor — "nothing here can tell you" — has to be a different thing.
|
|
278
|
+
*/
|
|
279
|
+
getRoomInfo?(): RoomInfo | null;
|
|
280
|
+
/**
|
|
281
|
+
* Optional capability: replication activity snapshot, for a live network
|
|
282
|
+
* inspector panel. Zeroes are a measurement, not a default; an adapter with
|
|
283
|
+
* no counters omits this rather than reporting a quiet link.
|
|
284
|
+
*/
|
|
285
|
+
getReplicationStats?(): ReplicationStats;
|
|
258
286
|
/** Subscribe to changes in connection state / room / replication stats. */
|
|
259
287
|
subscribe(cb: () => void): Unsubscribe;
|
|
260
288
|
/** Optional capability: one plain-data (JSON-safe) snapshot of the
|
|
@@ -281,7 +309,7 @@ export interface NetworkingAdapter {
|
|
|
281
309
|
* (e.g. read off its own room state). The editor consumes this for display —
|
|
282
310
|
* a seat label — ONLY when a real implementer provides it, falling back to a
|
|
283
311
|
* generic label otherwise. */
|
|
284
|
-
getPlayerIdentity?(): NetPlayerIdentity;
|
|
312
|
+
getPlayerIdentity?(): NetPlayerIdentity | undefined;
|
|
285
313
|
/** Optional capability, PAIRED with {@link getPlayerIdentity}: set the local
|
|
286
314
|
* player's identity through the game's OWN multiplayer mechanism. The editor
|
|
287
315
|
* renders an editable name field ONLY when a real implementer provides this
|
|
@@ -346,6 +374,13 @@ export interface NavCrowdAgentState {
|
|
|
346
374
|
*/
|
|
347
375
|
export interface NavigationAdapter {
|
|
348
376
|
hasNavMesh(): boolean;
|
|
377
|
+
/**
|
|
378
|
+
* `[]` means SEARCHED AND FOUND NO ROUTE — a fact about the level. An
|
|
379
|
+
* implementer with no navmesh to search, or whose query FAILED, THROWS
|
|
380
|
+
* instead; those are facts about the implementer, and collapsing all three
|
|
381
|
+
* into `[]` tells a caller the level is impassable when nobody looked.
|
|
382
|
+
* Gate on {@link hasNavMesh} where the first case is reachable.
|
|
383
|
+
*/
|
|
349
384
|
findPath(start: NavPoint, end: NavPoint): NavPoint[];
|
|
350
385
|
debugMesh(scene: THREE.Scene): THREE.Object3D | null;
|
|
351
386
|
/** (Re)build the navmesh from source meshes. Synchronous in the blessed
|
|
@@ -53,9 +53,9 @@ export const NETWORKING_ADAPTER_SHAPE = defineSeamShape<NetworkingAdapter>()({
|
|
|
53
53
|
networkId: { optional: false, kind: 'function', required: 'operation' },
|
|
54
54
|
authority: { optional: false, kind: 'function', required: 'operation' },
|
|
55
55
|
editable: { optional: false, kind: 'function', required: 'operation' },
|
|
56
|
-
getConnectionState: { optional:
|
|
57
|
-
getRoomInfo: { optional:
|
|
58
|
-
getReplicationStats: { optional:
|
|
56
|
+
getConnectionState: { optional: true, kind: 'function', required: 'operation' },
|
|
57
|
+
getRoomInfo: { optional: true, kind: 'function', required: 'operation' },
|
|
58
|
+
getReplicationStats: { optional: true, kind: 'function', required: 'operation' },
|
|
59
59
|
subscribe: { optional: false, kind: 'function', required: 'effect' },
|
|
60
60
|
getStateSnapshot: { optional: true, kind: 'function', required: 'operation' },
|
|
61
61
|
messageEvents: { optional: true, kind: 'function', required: 'operation' },
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createSystemSlot` — THE implementation of the declared-slot façade, the
|
|
3
|
+
* seam between a STATIC `systems` declaration and a LIVE adapter that only
|
|
4
|
+
* exists once the world tree is mounted.
|
|
5
|
+
*
|
|
6
|
+
* WHY IT EXISTS. An entry declares its systems statically
|
|
7
|
+
* (`export const systems = { networking: networkingSystem() }`), while the
|
|
8
|
+
* thing being declared — a joined Colyseus room, a baked navmesh, a mounted
|
|
9
|
+
* `<Physics>`, a cutscene's camera ownership — is built inside the world tree,
|
|
10
|
+
* later, and may be replaced (reconnect, remount, hot restart) or go away
|
|
11
|
+
* (stop). The slot is a stable object the host installs at mount and holds
|
|
12
|
+
* forever; every call forwards to whatever is attached right now.
|
|
13
|
+
*
|
|
14
|
+
* ── THE HONESTY RULE, STATED IN ONE PLACE ───────────────────────────────────
|
|
15
|
+
* This is why the pattern is centralized: five hand-rolled copies disagreed
|
|
16
|
+
* about it, and each disagreement was found by a separate review.
|
|
17
|
+
*
|
|
18
|
+
* - An **action** with no live target REFUSES BY NAME
|
|
19
|
+
* (`<name>: <unattachedMessage>`). Never a silent no-op — a caller that
|
|
20
|
+
* told the game to DO something must learn that it did not happen. An
|
|
21
|
+
* action against a live adapter that lacks the member refuses the same
|
|
22
|
+
* way, naming the member.
|
|
23
|
+
* - A **read** answers its declared HONEST EMPTY — `'disconnected'`, `[]`,
|
|
24
|
+
* `null`, `false`. That is not a fabrication: it is the truth of the
|
|
25
|
+
* not-attached state, in the same vocabulary the editor's own edit-mode
|
|
26
|
+
* adapters use. Reads are also the only kind safe to call from a per-frame
|
|
27
|
+
* debug draw, which is why a throw into a rAF loop is never the answer.
|
|
28
|
+
* - An **optional** member MIRRORS THE LIVE ADAPTER'S PRESENCE: absent while
|
|
29
|
+
* unattached, and absent afterwards when the live adapter itself does not
|
|
30
|
+
* provide it. Presence IS the consume-by-presence protocol's signal, so
|
|
31
|
+
* the slot may never invent it. Each presence read CAPTURES the adapter it
|
|
32
|
+
* saw and forwards to that same instance, so a detach between the read and
|
|
33
|
+
* the call answers as the adapter the caller was handed rather than a
|
|
34
|
+
* mid-flight swap.
|
|
35
|
+
* - A **subscribe** member SURVIVES REATTACHMENT: listeners live on the
|
|
36
|
+
* slot, never on the instance, and the slot re-binds its own single
|
|
37
|
+
* subscription on every attach/detach. A panel that subscribed once to the
|
|
38
|
+
* stable slot object is therefore never left holding a disposed system, and
|
|
39
|
+
* it is notified when the live half appears or disappears.
|
|
40
|
+
* - A member the config DOES NOT LIST does not exist on the slot at all.
|
|
41
|
+
* That is how the anti-shim rule spells omission — e.g. `PhysicsAdapter`'s
|
|
42
|
+
* `debugDraw`/`contactPoints` over `@react-three/rapier`, whose debug line
|
|
43
|
+
* segments live inside the fiber tree and expose no handle. Absence is a
|
|
44
|
+
* capability answer; a stub is a lie.
|
|
45
|
+
*
|
|
46
|
+
* ── RESOURCE OWNERSHIP ──────────────────────────────────────────────────────
|
|
47
|
+
* OWNER: whoever built the live adapter (the hook, the bridge component). The
|
|
48
|
+
* slot owns only the POINTER to it plus its own listener set and its own
|
|
49
|
+
* subscription to the live half. SHARERS: every reader of the declared
|
|
50
|
+
* system — editor inspectors, instruments. TEARDOWN: the function `attach`
|
|
51
|
+
* returns, and nothing else. It is IDENTITY-GUARDED — it clears only while
|
|
52
|
+
* the same instance is still attached, so a replace-then-teardown-the-old
|
|
53
|
+
* ordering cannot detach the new one — and detaching never disposes the
|
|
54
|
+
* adapter, because the slot did not create it.
|
|
55
|
+
*
|
|
56
|
+
* WHERE the slot module lives decides how many games share it. A slot in
|
|
57
|
+
* PROJECT-owned source (the four capability/example façades) is per Play
|
|
58
|
+
* instance, because the editor stamps mount ids onto project-owned import
|
|
59
|
+
* specifiers (`server/project-module-instance.ts`) — N instances get N module
|
|
60
|
+
* graphs and N slots. A slot in an ENGINE module is reached by bare
|
|
61
|
+
* specifier, which that stamping deliberately never touches, so it is ONE per
|
|
62
|
+
* page: every Play instance shares it, and concurrent instances' attaches
|
|
63
|
+
* contend (last attach wins; the loser's detach is dropped by the identity
|
|
64
|
+
* guard). `rapier-physics-bridge.tsx` is the one such slot today and warns
|
|
65
|
+
* loudly when contended — prefer project-owned slot modules for anything new.
|
|
66
|
+
*
|
|
67
|
+
* NOT A WRAPPER. The slot's members have the adapter interface's own exact
|
|
68
|
+
* signatures and hand back the implementation's own values; nothing stands
|
|
69
|
+
* between a caller and the live library object.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
import type { VgaiGameSystemEmpty } from './ingest/game-contract';
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `absent(reason)` — THE WHOLE-SLOT counterpart of the four per-member policies
|
|
76
|
+
* above, and the fifth line of the same honesty rule.
|
|
77
|
+
*
|
|
78
|
+
* The four policies answer "this slot exists but nothing is attached yet". This
|
|
79
|
+
* one answers a different question entirely: **this game will never have that
|
|
80
|
+
* subsystem, and here is what was searched.** A slot simply left out of the
|
|
81
|
+
* `systems` table cannot say that — an omitted key means "unsupported", which is
|
|
82
|
+
* the same shape as "nobody looked", and the coverage report has to file it as a
|
|
83
|
+
* work order forever. Declaring the absence turns an UNANSWERED row into a
|
|
84
|
+
* terminal one.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* export const systems = {
|
|
88
|
+
* audio: sfxAudioSystem(),
|
|
89
|
+
* physics: rapierPhysicsSystem(),
|
|
90
|
+
* networking: absent('single-player: no Colyseus client anywhere in `src/`'),
|
|
91
|
+
* };
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* ## It is a CONSTRUCTOR for the shape that already exists, not a second one
|
|
95
|
+
*
|
|
96
|
+
* The returned value IS `VgaiGameSystemEmpty` — the plain
|
|
97
|
+
* `{ present: false, evidence }` record an INGESTED game declares on
|
|
98
|
+
* `window.vgaiGame.systems.systemAdapters`, validated by the same single
|
|
99
|
+
* projection (`ingest/contract-system-adapters.ts`). There is one shape law, not
|
|
100
|
+
* two: a foreign game cannot import this helper and must stay able to write the
|
|
101
|
+
* record by hand, so nothing here may brand the runtime value. What the helper
|
|
102
|
+
* buys a FIRST-PARTY author is the reason-quality check moved to the call site —
|
|
103
|
+
* our own code failing its own contract fails fast, where an ingested game's
|
|
104
|
+
* same mistake is filed as a `malformed` verdict for its coverage report.
|
|
105
|
+
*
|
|
106
|
+
* ## It is a MARKER, never a stub adapter
|
|
107
|
+
*
|
|
108
|
+
* Do not answer an absent slot with an adapter whose methods return zeros. A
|
|
109
|
+
* `getConnectionState()` of `'disconnected'` on a game with no transport implies
|
|
110
|
+
* a connection that could exist; that is the fabrication the anti-shim rule
|
|
111
|
+
* forbids. The absence is STATED, and the host installs nothing for it.
|
|
112
|
+
*
|
|
113
|
+
* @param reason What was searched and what was found, in the game's own source
|
|
114
|
+
* terms. "no netcode anywhere in `src/`" is a finished answer a reviewer can
|
|
115
|
+
* re-run; "not implemented yet" is a plan, and is rejected here.
|
|
116
|
+
*/
|
|
117
|
+
export function absent(reason: string): VgaiGameSystemEmpty {
|
|
118
|
+
if (typeof reason !== 'string' || reason.trim() === '') {
|
|
119
|
+
throw new Error(
|
|
120
|
+
'absent(): an absence needs evidence — say what was searched and what was found ' +
|
|
121
|
+
'(e.g. "no Colyseus client anywhere in `src/`"), so a reviewer can re-run it. ' +
|
|
122
|
+
'An unevidenced absence asserts something nobody can re-check.',
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return { present: false, evidence: reason };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Any adapter member. `never[]` args make the conditional match contravariantly. */
|
|
129
|
+
type AnyFn = (...args: never[]) => unknown;
|
|
130
|
+
|
|
131
|
+
/** The declared member's return type, used to type a `read`'s honest empty. */
|
|
132
|
+
type MemberReturn<F> = NonNullable<F> extends (...args: never[]) => infer R ? R : never;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The per-member policy. There are exactly four, and every member of every
|
|
136
|
+
* declared slot in the repo is one of them — see the honesty rule above.
|
|
137
|
+
*/
|
|
138
|
+
export type SystemSlotMemberSpec<F> =
|
|
139
|
+
| { readonly kind: 'action' }
|
|
140
|
+
| { readonly kind: 'read'; readonly empty: MemberReturn<F> }
|
|
141
|
+
| { readonly kind: 'subscribe' }
|
|
142
|
+
| { readonly kind: 'optional' };
|
|
143
|
+
|
|
144
|
+
/** The keys of `T` whose values are callable (data properties are not slottable). */
|
|
145
|
+
type FunctionMemberKeys<T> = {
|
|
146
|
+
[K in keyof T]-?: NonNullable<T[K]> extends AnyFn ? K : never;
|
|
147
|
+
}[keyof T];
|
|
148
|
+
|
|
149
|
+
/** Per-member policies. A member left out is left OFF the slot entirely. */
|
|
150
|
+
export type SystemSlotMembers<T> = {
|
|
151
|
+
readonly [K in FunctionMemberKeys<T>]?: SystemSlotMemberSpec<T[K]>;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export interface SystemSlotConfig<T extends object> {
|
|
155
|
+
/**
|
|
156
|
+
* The slot's own name, used as the prefix of every refusal so a stack-less
|
|
157
|
+
* error still names the seam (`'networkingSystem'`, `'rapierPhysicsSystem'`).
|
|
158
|
+
*/
|
|
159
|
+
readonly name: string;
|
|
160
|
+
/**
|
|
161
|
+
* The rest of an action's refusal while nothing is attached — the DOMAIN
|
|
162
|
+
* half of the message, naming what has not happened yet ("the world is not
|
|
163
|
+
* playing, or the navmesh has not finished building").
|
|
164
|
+
*/
|
|
165
|
+
readonly unattachedMessage: string;
|
|
166
|
+
readonly members: SystemSlotMembers<T>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface SystemSlot<T extends object> {
|
|
170
|
+
/**
|
|
171
|
+
* Publish `live` as the slot's target. Returns the ONE detach path, which
|
|
172
|
+
* is identity-guarded: it clears only while `live` is still the attached
|
|
173
|
+
* instance, and never disposes it.
|
|
174
|
+
*/
|
|
175
|
+
attach(live: T): () => void;
|
|
176
|
+
/** The stable declared object. Hand THIS to the entry's `systems` map. */
|
|
177
|
+
readonly slot: T;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function createSystemSlot<T extends object>(config: SystemSlotConfig<T>): SystemSlot<T> {
|
|
181
|
+
const { name, unattachedMessage, members } = config;
|
|
182
|
+
|
|
183
|
+
let live: T | null = null;
|
|
184
|
+
/** Subscribers to the stable slot object; they outlive any one live instance. */
|
|
185
|
+
const listeners = new Set<() => void>();
|
|
186
|
+
/** The slot's own single subscription to whatever is attached. */
|
|
187
|
+
let liveUnsubscribe: (() => void) | null = null;
|
|
188
|
+
let subscribeMember: string | null = null;
|
|
189
|
+
|
|
190
|
+
const asRecord = (value: object): Record<string, unknown> =>
|
|
191
|
+
value as unknown as Record<string, unknown>;
|
|
192
|
+
|
|
193
|
+
const liveMember = (member: string): AnyFn | undefined => {
|
|
194
|
+
if (!live) return undefined;
|
|
195
|
+
const value = asRecord(live)[member];
|
|
196
|
+
return typeof value === 'function' ? (value as AnyFn) : undefined;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const notify = (): void => {
|
|
200
|
+
for (const listener of [...listeners]) listener();
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const bindLive = (): void => {
|
|
204
|
+
liveUnsubscribe?.();
|
|
205
|
+
liveUnsubscribe = null;
|
|
206
|
+
if (!live || subscribeMember === null || listeners.size === 0) return;
|
|
207
|
+
const subscribe = liveMember(subscribeMember);
|
|
208
|
+
if (!subscribe) return;
|
|
209
|
+
const result = subscribe.call(live, notify as never);
|
|
210
|
+
liveUnsubscribe = typeof result === 'function' ? (result as () => void) : null;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const target: Record<string, unknown> = {};
|
|
214
|
+
|
|
215
|
+
const declared = Object.entries(members) as [string, SystemSlotMemberSpec<unknown>][];
|
|
216
|
+
for (const [member, spec] of declared) {
|
|
217
|
+
switch (spec.kind) {
|
|
218
|
+
case 'action': {
|
|
219
|
+
// Refuse by name, twice over: no live adapter at all, or a live
|
|
220
|
+
// adapter that does not carry this member (only ever a foreign
|
|
221
|
+
// replacement — the blessed implementations carry all of theirs).
|
|
222
|
+
target[member] = (...args: never[]): unknown => {
|
|
223
|
+
if (!live) throw new Error(`${name}: ${unattachedMessage}`);
|
|
224
|
+
const fn = liveMember(member);
|
|
225
|
+
if (!fn) throw new Error(`${name}: the live adapter has no ${member}().`);
|
|
226
|
+
return fn.apply(live, args);
|
|
227
|
+
};
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
case 'read': {
|
|
231
|
+
const { empty } = spec;
|
|
232
|
+
target[member] = (...args: never[]): unknown => {
|
|
233
|
+
const current = live;
|
|
234
|
+
const fn = liveMember(member);
|
|
235
|
+
const value = fn ? fn.apply(current, args) : undefined;
|
|
236
|
+
return value ?? empty;
|
|
237
|
+
};
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
case 'subscribe': {
|
|
241
|
+
if (subscribeMember !== null) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`${name}: a slot declares at most one 'subscribe' member (${subscribeMember} and ${member}).`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
subscribeMember = member;
|
|
247
|
+
target[member] = (listener: () => void): (() => void) => {
|
|
248
|
+
listeners.add(listener);
|
|
249
|
+
bindLive();
|
|
250
|
+
return () => {
|
|
251
|
+
listeners.delete(listener);
|
|
252
|
+
bindLive();
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case 'optional': {
|
|
258
|
+
Object.defineProperty(target, member, {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
configurable: true,
|
|
261
|
+
get(): AnyFn | undefined {
|
|
262
|
+
const current = live;
|
|
263
|
+
const fn = liveMember(member);
|
|
264
|
+
if (!fn) return undefined;
|
|
265
|
+
return (...args: never[]): unknown => fn.apply(current, args);
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const attach = (next: T): (() => void) => {
|
|
274
|
+
live = next;
|
|
275
|
+
bindLive();
|
|
276
|
+
notify();
|
|
277
|
+
return () => {
|
|
278
|
+
if (live !== next) return;
|
|
279
|
+
live = null;
|
|
280
|
+
bindLive();
|
|
281
|
+
notify();
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// THE ONE CAST. `exactOptionalPropertyTypes` forbids an optional member
|
|
286
|
+
// whose getter can yield `undefined`, but that is precisely the honest
|
|
287
|
+
// shape here — the getter IS how presence mirrors the live adapter — and a
|
|
288
|
+
// reflectively built object cannot be typed structurally anyway. Callers
|
|
289
|
+
// see exactly the absent/present behavior the adapter interface documents.
|
|
290
|
+
return { attach, slot: target as T };
|
|
291
|
+
}
|
package/src/adapter/transform.ts
CHANGED
|
@@ -15,4 +15,21 @@ export interface Transform {
|
|
|
15
15
|
* needs simulation coordination (`physics`), or is best-effort/inspect-only
|
|
16
16
|
* (`script`/`network`/`external`).
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Who drives a node's transform right now.
|
|
20
|
+
*
|
|
21
|
+
* `'unresolved'` is the answer for a node THIS ADAPTER DOES NOT KNOW, and it is
|
|
22
|
+
* a distinct answer on purpose: every other member names a driver, so returning
|
|
23
|
+
* one of them for an unknown id is a positive claim about a node the
|
|
24
|
+
* implementer has never seen. A game-scoped physics adapter is asked about
|
|
25
|
+
* every node the editor touches, including nodes belonging to another root —
|
|
26
|
+
* "not mine" has to be sayable.
|
|
27
|
+
*/
|
|
28
|
+
export type TransformOwner =
|
|
29
|
+
| 'editor'
|
|
30
|
+
| 'physics'
|
|
31
|
+
| 'animation'
|
|
32
|
+
| 'script'
|
|
33
|
+
| 'network'
|
|
34
|
+
| 'external'
|
|
35
|
+
| 'unresolved';
|
package/src/ai/navigation.ts
CHANGED
|
@@ -119,11 +119,38 @@ export class NavMeshManager {
|
|
|
119
119
|
return this.navMesh !== null;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Find a straight path between two world positions.
|
|
124
|
+
*
|
|
125
|
+
* THREE OUTCOMES, and only one of them is an empty array:
|
|
126
|
+
*
|
|
127
|
+
* - **No pathfinder.** No navmesh has been built, so there is nothing to
|
|
128
|
+
* query. THROWS, the same way {@link createCrowd} does — `[]` here would
|
|
129
|
+
* say "I searched and there is no route between these points", which is a
|
|
130
|
+
* claim about the level rather than about this manager's state. Callers
|
|
131
|
+
* that can be in this position gate on {@link hasNavMesh} first.
|
|
132
|
+
* - **The query failed.** recast answered `success: false` WITH an error
|
|
133
|
+
* (bad half-extents, no polygon near an endpoint, a status code). THROWS,
|
|
134
|
+
* naming recast's own error — a failed search is not a searched-and-empty
|
|
135
|
+
* one, and the editor's probe already surfaces this separately from "no
|
|
136
|
+
* path found".
|
|
137
|
+
* - **Genuinely no route.** The query ran and found nothing. `[]`.
|
|
138
|
+
*/
|
|
123
139
|
findPath(start: Vector3Like, end: Vector3Like): Vector3Like[] {
|
|
124
|
-
if (!this.query)
|
|
140
|
+
if (!this.query) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
'NavMeshManager.findPath: no navmesh has been built, so no path can be queried. ' +
|
|
143
|
+
'Build one first (buildFromMeshes/importNavMesh) — gate on hasNavMesh() if the ' +
|
|
144
|
+
'caller can run before a bake.',
|
|
145
|
+
);
|
|
146
|
+
}
|
|
125
147
|
const result = this.query.computePath(start, end);
|
|
126
|
-
if (!result.success)
|
|
148
|
+
if (!result.success && result.error) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
`NavMeshManager.findPath: recast could not complete the query (${result.error.name}` +
|
|
151
|
+
`${result.error.status === undefined ? '' : `, status ${result.error.status}`}).`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
127
154
|
return result.path;
|
|
128
155
|
}
|
|
129
156
|
|
|
@@ -10,16 +10,24 @@
|
|
|
10
10
|
* the old `.animgraph.json` format) was deleted with the runtime that read
|
|
11
11
|
* them (`anim-graph.ts`).
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* The optional fields spell `| undefined` explicitly because the repo compiles
|
|
15
|
+
* with `exactOptionalPropertyTypes`, and the one producer of these values is
|
|
16
|
+
* `xstate-animation-meta.ts`'s Zod schema, whose `.optional()` infers
|
|
17
|
+
* `?: T | undefined`. Without the explicit union the parsed value is not
|
|
18
|
+
* assignable here and the call site needs a cast — which is exactly what used
|
|
19
|
+
* to hide field drift between the two declarations (see `asBlendTreeDef`).
|
|
20
|
+
*/
|
|
13
21
|
export interface BlendTreeDef {
|
|
14
22
|
type: '1D' | '2D' | 'direct';
|
|
15
23
|
parameter: string;
|
|
16
|
-
parameterY?: string; // for 2D
|
|
24
|
+
parameterY?: string | undefined; // for 2D
|
|
17
25
|
children: BlendChild[];
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
export interface BlendChild {
|
|
21
29
|
clip: string;
|
|
22
30
|
threshold: number;
|
|
23
|
-
thresholdY?: number; // for 2D
|
|
24
|
-
weight?: number; // for direct
|
|
31
|
+
thresholdY?: number | undefined; // for 2D
|
|
32
|
+
weight?: number | undefined; // for direct
|
|
25
33
|
}
|
|
@@ -78,10 +78,10 @@ export interface TheatreClockBinding {
|
|
|
78
78
|
/**
|
|
79
79
|
* Subscribe `sequence.position = clock.time` to every crossing of `clock` in
|
|
80
80
|
* the given phase (default `'animation'`). Returns a disposer; call it to
|
|
81
|
-
* stop driving the sequence (e.g.
|
|
82
|
-
* rebinding on hot reload — this is what keeps HMR from
|
|
83
|
-
* duplicate listeners
|
|
84
|
-
*
|
|
81
|
+
* stop driving the sequence (e.g. in the owning component's unmount cleanup,
|
|
82
|
+
* or before rebinding on hot reload — this is what keeps HMR from
|
|
83
|
+
* accumulating duplicate listeners: dispose the old binding before creating
|
|
84
|
+
* a new one).
|
|
85
85
|
*
|
|
86
86
|
* Multiple sheets/sequences can each get their own binding with no shared
|
|
87
87
|
* mutable state on VGAI's side — collision avoidance for the underlying
|
|
@@ -2,7 +2,6 @@ import * as THREE from 'three';
|
|
|
2
2
|
import type { AnyStateMachine } from 'xstate';
|
|
3
3
|
import type { createSystemRunner } from '../core/system-runner';
|
|
4
4
|
import { deleteUserData, getUserData, setUserData } from '../ecs/user-data';
|
|
5
|
-
import type { BlendTreeDef } from './anim-graph-types';
|
|
6
5
|
import { evaluateBlendTree } from './blend-node';
|
|
7
6
|
import {
|
|
8
7
|
type AnimationPreviewTransport,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
import {
|
|
12
11
|
type AnimationBoneMask,
|
|
13
12
|
type AnimationMetaStateNodeLike,
|
|
13
|
+
asBlendTreeDef,
|
|
14
14
|
clipNamesOf,
|
|
15
15
|
collectMachineAnimationMeta,
|
|
16
16
|
isBlendTreeAnimationMeta,
|
|
@@ -365,7 +365,7 @@ export function bindXStateAnimation(
|
|
|
365
365
|
|
|
366
366
|
function weightsOf(stateId: string, meta: StateAnimationMeta, context: unknown): WeightedClip[] {
|
|
367
367
|
const weights = isBlendTreeAnimationMeta(meta)
|
|
368
|
-
? evaluateBlendTree(meta.blendTree
|
|
368
|
+
? evaluateBlendTree(asBlendTreeDef(meta.blendTree), readParameters(context))
|
|
369
369
|
: [{ clip: meta.clip, weight: 1 }];
|
|
370
370
|
return weights.map(({ clip, weight }) => ({
|
|
371
371
|
clip,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { BlendTreeDef } from './anim-graph-types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* E1 — Zod/TypeScript metadata attached to XState state `meta.animation`
|
|
@@ -102,6 +103,21 @@ export const AnimationBlendTreeSchema = z.discriminatedUnion('type', [
|
|
|
102
103
|
|
|
103
104
|
export type AnimationBlendTree = z.infer<typeof AnimationBlendTreeSchema>;
|
|
104
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The structural-identity claim in this file's header, made COMPILER-CHECKED.
|
|
108
|
+
*
|
|
109
|
+
* `evaluateBlendTree` takes `anim-graph-types.ts`'s `BlendTreeDef`, and the
|
|
110
|
+
* whole reason this schema mirrors that shape field-for-field is so a parsed
|
|
111
|
+
* value can be handed over with zero conversion. The binding used to spell that
|
|
112
|
+
* hand-over `as unknown as BlendTreeDef` — a double cast that would have gone on
|
|
113
|
+
* compiling if either declaration drifted, silently feeding the blend math a
|
|
114
|
+
* shape it does not describe. This identity function is the assignability
|
|
115
|
+
* assertion instead: drift here is a type error at the seam that claims it.
|
|
116
|
+
*/
|
|
117
|
+
export function asBlendTreeDef(tree: AnimationBlendTree): BlendTreeDef {
|
|
118
|
+
return tree;
|
|
119
|
+
}
|
|
120
|
+
|
|
105
121
|
// ---------------------------------------------------------------------------
|
|
106
122
|
// Crossfade / blend-in-out metadata (shared by clip and blend-tree states)
|
|
107
123
|
// ---------------------------------------------------------------------------
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The engine's runtime descriptor schemas.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* real runtime reader still consumes it:
|
|
4
|
+
* Each module is here because a real runtime READER consumes it — nothing in
|
|
5
|
+
* this directory exists as documentation of a format:
|
|
7
6
|
*
|
|
8
7
|
* - `material.ts` — the inline material descriptor `render/material-factory.ts` reads
|
|
9
8
|
* - `mesh.ts` — the geometry descriptor `render/material-factory.ts`'s `createGeometry` reads
|
|
@@ -16,10 +15,8 @@
|
|
|
16
15
|
* - `tuples.ts` — the shared Vec3/Quat/Transform tuples the above build on
|
|
17
16
|
*
|
|
18
17
|
* These are DESCRIPTORS, not documents: each names a slice of authored data a
|
|
19
|
-
* render/physics factory reads, and none of them is a scene
|
|
20
|
-
*
|
|
21
|
-
* was a leftover of the deleted `.vscn.json` format, not a statement about what
|
|
22
|
-
* they describe.
|
|
18
|
+
* render/physics factory reads, and none of them is a scene — which is why
|
|
19
|
+
* every one of them is named `*Descriptor`.
|
|
23
20
|
*/
|
|
24
21
|
|
|
25
22
|
export type { CameraDescriptor } from './camera';
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
* Render settings — the tone-mapping / post-processing / render-feature scope
|
|
3
3
|
* the engine's renderer setup reads (`setup/setup-renderer.ts`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* postprocessing chain from them. Everything that was `.vscn`-only (`skybox`,
|
|
9
|
-
* `fog`, `ambient`, `background`, `envMapIntensity`, `navigation`, `physics`)
|
|
10
|
-
* went with the format.
|
|
5
|
+
* Exactly THREE scopes, and each is here because `setup-renderer.ts` reads
|
|
6
|
+
* every one of its fields to build the postprocessing chain. A setting with
|
|
7
|
+
* no such reader does not belong in this descriptor.
|
|
11
8
|
*/
|
|
12
9
|
import { z } from 'zod';
|
|
13
10
|
import { buildRenderingZod } from '../render/render-features';
|
package/src/asset-parse-error.ts
CHANGED
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* every caller (currently the input-map loader in `input/input-manager.ts`)
|
|
8
8
|
* does not have to reach into an unrelated subsystem for it.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* redesign"); with `.vscn` gone the old name described nothing — an
|
|
13
|
-
* `.inputmap.json` failure is not a scene failure — so the class and its
|
|
14
|
-
* message header now say `asset`.
|
|
10
|
+
* The name says ASSET, not scene: an `.inputmap.json` failure is not a scene
|
|
11
|
+
* failure, and the class covers every structured fetched asset.
|
|
15
12
|
*/
|
|
16
13
|
|
|
17
14
|
import type { ZodIssue } from 'zod';
|