@vgai/engine 0.2.0 → 0.3.0
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 +3 -1
- package/dist/adapter/authoring.d.ts +404 -0
- package/dist/adapter/authoring.d.ts.map +1 -0
- package/dist/adapter/authoring.js +22 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts +43 -0
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
- package/dist/adapter/colyseus-networking-adapter.js +38 -0
- package/dist/adapter/first-party-systems.d.ts +38 -0
- package/dist/adapter/first-party-systems.d.ts.map +1 -0
- package/dist/adapter/first-party-systems.js +77 -0
- package/dist/adapter/game-adapter.d.ts +133 -0
- package/dist/adapter/game-adapter.d.ts.map +1 -0
- package/dist/adapter/game-adapter.js +10 -0
- package/dist/adapter/host-context.d.ts +73 -0
- package/dist/adapter/host-context.d.ts.map +1 -0
- package/dist/adapter/host-context.js +16 -0
- package/dist/adapter/index.d.ts +22 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +15 -0
- package/dist/adapter/ingest/game-contract.d.ts +53 -0
- package/dist/adapter/ingest/game-contract.d.ts.map +1 -0
- package/dist/adapter/ingest/game-contract.js +30 -0
- package/dist/adapter/ingest/overlay-applier.d.ts +118 -0
- package/dist/adapter/ingest/overlay-applier.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-applier.js +132 -0
- package/dist/adapter/ingest/overlay-apply.d.ts +60 -0
- package/dist/adapter/ingest/overlay-apply.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-apply.js +101 -0
- package/dist/adapter/ingest/overlay-file.d.ts +79 -0
- package/dist/adapter/ingest/overlay-file.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-file.js +66 -0
- package/dist/adapter/ingest/overlay-report.d.ts +113 -0
- package/dist/adapter/ingest/overlay-report.d.ts.map +1 -0
- package/dist/adapter/ingest/overlay-report.js +103 -0
- package/dist/adapter/ingest/scene-capture.d.ts +97 -0
- package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
- package/dist/adapter/ingest/scene-capture.js +248 -0
- package/dist/adapter/ingest/upstream-pin.d.ts +47 -0
- package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
- package/dist/adapter/ingest/upstream-pin.js +50 -0
- package/dist/adapter/loop-gate-report.d.ts +34 -0
- package/dist/adapter/loop-gate-report.d.ts.map +1 -0
- package/dist/adapter/loop-gate-report.js +37 -0
- package/dist/adapter/rapier-physics-adapter.d.ts +12 -0
- package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
- package/dist/adapter/rapier-physics-adapter.js +46 -0
- package/dist/adapter/system-adapter.d.ts +133 -0
- package/dist/adapter/system-adapter.d.ts.map +1 -0
- package/dist/adapter/system-adapter.js +13 -0
- package/dist/adapter/transform.d.ts +18 -0
- package/dist/adapter/transform.d.ts.map +1 -0
- package/dist/adapter/transform.js +1 -0
- package/dist/adapter/vgai-scene-game-adapter.d.ts +116 -0
- package/dist/adapter/vgai-scene-game-adapter.d.ts.map +1 -0
- package/dist/adapter/vgai-scene-game-adapter.js +714 -0
- package/dist/adapter/world-kind.d.ts +30 -0
- package/dist/adapter/world-kind.d.ts.map +1 -0
- package/dist/adapter/world-kind.js +18 -0
- package/dist/ai/navigation.d.ts +64 -0
- package/dist/ai/navigation.d.ts.map +1 -0
- package/dist/ai/navigation.js +133 -0
- package/dist/animation/anim-graph-types.d.ts +25 -0
- package/dist/animation/anim-graph-types.d.ts.map +1 -0
- package/dist/animation/anim-graph-types.js +1 -0
- package/dist/animation/animation-clock.d.ts +213 -0
- package/dist/animation/animation-clock.d.ts.map +1 -0
- package/dist/animation/animation-clock.js +301 -0
- package/dist/animation/blend-node.d.ts +22 -0
- package/dist/animation/blend-node.d.ts.map +1 -0
- package/dist/animation/blend-node.js +97 -0
- package/dist/animation/camera-ownership.d.ts +250 -0
- package/dist/animation/camera-ownership.d.ts.map +1 -0
- package/dist/animation/camera-ownership.js +169 -0
- package/dist/animation/cinematic-cues.d.ts +200 -0
- package/dist/animation/cinematic-cues.d.ts.map +1 -0
- package/dist/animation/cinematic-cues.js +213 -0
- package/dist/animation/clip-map.d.ts +12 -0
- package/dist/animation/clip-map.d.ts.map +1 -0
- package/dist/animation/clip-map.js +37 -0
- package/dist/animation/gsap-registration.d.ts +119 -0
- package/dist/animation/gsap-registration.d.ts.map +1 -0
- package/dist/animation/gsap-registration.js +92 -0
- package/dist/animation/theatre-clock-binding.d.ts +89 -0
- package/dist/animation/theatre-clock-binding.d.ts.map +1 -0
- package/dist/animation/theatre-clock-binding.js +29 -0
- package/dist/animation/theatre-director.d.ts +242 -0
- package/dist/animation/theatre-director.d.ts.map +1 -0
- package/dist/animation/theatre-director.js +235 -0
- package/dist/animation/theatre-object-binding.d.ts +305 -0
- package/dist/animation/theatre-object-binding.d.ts.map +1 -0
- package/dist/animation/theatre-object-binding.js +351 -0
- package/dist/animation/xstate-animation-binding.d.ts +111 -0
- package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
- package/dist/animation/xstate-animation-binding.js +307 -0
- package/dist/animation/xstate-animation-meta.d.ts +228 -0
- package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
- package/dist/animation/xstate-animation-meta.js +221 -0
- package/dist/assets.d.ts +26 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +55 -0
- package/dist/audio/index.d.ts +4 -0
- package/dist/audio/index.d.ts.map +1 -0
- package/dist/audio/index.js +24 -0
- package/dist/audio/tone-clock-binding.d.ts +75 -0
- package/dist/audio/tone-clock-binding.d.ts.map +1 -0
- package/dist/audio/tone-clock-binding.js +29 -0
- package/dist/audio/tone-context.d.ts +114 -0
- package/dist/audio/tone-context.d.ts.map +1 -0
- package/dist/audio/tone-context.js +39 -0
- package/dist/audio/tone-offline-render.d.ts +90 -0
- package/dist/audio/tone-offline-render.d.ts.map +1 -0
- package/dist/audio/tone-offline-render.js +56 -0
- package/dist/audio/wav-encode.d.ts +38 -0
- package/dist/audio/wav-encode.d.ts.map +1 -0
- package/dist/audio/wav-encode.js +97 -0
- package/dist/core/game-loop.d.ts +21 -0
- package/dist/core/game-loop.d.ts.map +1 -0
- package/dist/core/game-loop.js +130 -0
- package/dist/core/system-runner.d.ts +120 -0
- package/dist/core/system-runner.d.ts.map +1 -0
- package/dist/core/system-runner.js +286 -0
- package/dist/core/types.d.ts +58 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +25 -0
- package/dist/data/data-asset.d.ts +101 -0
- package/dist/data/data-asset.d.ts.map +1 -0
- package/dist/data/data-asset.js +122 -0
- package/dist/data/data-check-core.d.ts +110 -0
- package/dist/data/data-check-core.d.ts.map +1 -0
- package/dist/data/data-check-core.js +178 -0
- package/dist/data/data-ref.d.ts +79 -0
- package/dist/data/data-ref.d.ts.map +1 -0
- package/dist/data/data-ref.js +130 -0
- package/dist/data/vite-plugin-data.d.ts +79 -0
- package/dist/data/vite-plugin-data.d.ts.map +1 -0
- package/dist/data/vite-plugin-data.js +217 -0
- package/dist/dev/console-bridge.d.ts +22 -0
- package/dist/dev/console-bridge.d.ts.map +1 -0
- package/dist/dev/console-bridge.js +71 -0
- package/dist/dev/debug-draw.d.ts +24 -0
- package/dist/dev/debug-draw.d.ts.map +1 -0
- package/dist/dev/debug-draw.js +73 -0
- package/dist/dev/logger.d.ts +30 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +90 -0
- package/dist/ecs/component-manager.d.ts +189 -0
- package/dist/ecs/component-manager.d.ts.map +1 -0
- package/dist/ecs/component-manager.js +676 -0
- package/dist/ecs/game-component.d.ts +97 -0
- package/dist/ecs/game-component.d.ts.map +1 -0
- package/dist/ecs/game-component.js +80 -0
- package/dist/ecs/hmr-swap-report.d.ts +53 -0
- package/dist/ecs/hmr-swap-report.d.ts.map +1 -0
- package/dist/ecs/hmr-swap-report.js +55 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/input/input-manager.d.ts +596 -0
- package/dist/input/input-manager.d.ts.map +1 -0
- package/dist/input/input-manager.js +1564 -0
- package/dist/input/input-types.d.ts +171 -0
- package/dist/input/input-types.d.ts.map +1 -0
- package/dist/input/input-types.js +1 -0
- package/dist/input/prompt-labels.d.ts +21 -0
- package/dist/input/prompt-labels.d.ts.map +1 -0
- package/dist/input/prompt-labels.js +121 -0
- package/dist/input/rebind-controller.d.ts +59 -0
- package/dist/input/rebind-controller.d.ts.map +1 -0
- package/dist/input/rebind-controller.js +85 -0
- package/dist/input/schema.d.ts +16 -0
- package/dist/input/schema.d.ts.map +1 -0
- package/dist/input/schema.js +228 -0
- package/dist/loader.d.ts +43 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +59 -0
- package/dist/manifest/index.d.ts +5 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +8 -0
- package/dist/manifest/load-file.d.ts +4 -0
- package/dist/manifest/load-file.d.ts.map +1 -0
- package/dist/manifest/load-file.js +14 -0
- package/dist/manifest/load.d.ts +117 -0
- package/dist/manifest/load.d.ts.map +1 -0
- package/dist/manifest/load.js +255 -0
- package/dist/manifest/schema.d.ts +173 -0
- package/dist/manifest/schema.d.ts.map +1 -0
- package/dist/manifest/schema.js +302 -0
- package/dist/physics/collision-system.d.ts +41 -0
- package/dist/physics/collision-system.d.ts.map +1 -0
- package/dist/physics/collision-system.js +64 -0
- package/dist/physics/physics-registry.d.ts +45 -0
- package/dist/physics/physics-registry.d.ts.map +1 -0
- package/dist/physics/physics-registry.js +65 -0
- package/dist/physics/transform-writer.d.ts +16 -0
- package/dist/physics/transform-writer.d.ts.map +1 -0
- package/dist/physics/transform-writer.js +38 -0
- package/dist/physics/trigger-dispatch.d.ts +24 -0
- package/dist/physics/trigger-dispatch.d.ts.map +1 -0
- package/dist/physics/trigger-dispatch.js +80 -0
- package/dist/react/game-state.d.ts +105 -0
- package/dist/react/game-state.d.ts.map +1 -0
- package/dist/react/game-state.js +144 -0
- package/dist/react/use-data.d.ts +60 -0
- package/dist/react/use-data.d.ts.map +1 -0
- package/dist/react/use-data.js +96 -0
- package/dist/react/use-selection.d.ts +75 -0
- package/dist/react/use-selection.d.ts.map +1 -0
- package/dist/react/use-selection.js +90 -0
- package/dist/render/auto-batcher.d.ts +34 -0
- package/dist/render/auto-batcher.d.ts.map +1 -0
- package/dist/render/auto-batcher.js +140 -0
- package/dist/render/render-batch-system.d.ts +33 -0
- package/dist/render/render-batch-system.d.ts.map +1 -0
- package/dist/render/render-batch-system.js +230 -0
- package/dist/render/render-features.d.ts +47 -0
- package/dist/render/render-features.d.ts.map +1 -0
- package/dist/render/render-features.js +105 -0
- package/dist/render/render-settings.d.ts +36 -0
- package/dist/render/render-settings.d.ts.map +1 -0
- package/dist/render/render-settings.js +51 -0
- package/dist/runtime/create-runtime.d.ts +280 -0
- package/dist/runtime/create-runtime.d.ts.map +1 -0
- package/dist/runtime/create-runtime.js +795 -0
- package/dist/runtime/frame-selector-cache.d.ts +41 -0
- package/dist/runtime/frame-selector-cache.d.ts.map +1 -0
- package/dist/runtime/frame-selector-cache.js +65 -0
- package/dist/runtime/game.d.ts +433 -0
- package/dist/runtime/game.d.ts.map +1 -0
- package/dist/runtime/game.js +569 -0
- package/dist/runtime/input-router.d.ts +78 -0
- package/dist/runtime/input-router.d.ts.map +1 -0
- package/dist/runtime/input-router.js +171 -0
- package/dist/runtime/mount-game.d.ts +129 -0
- package/dist/runtime/mount-game.d.ts.map +1 -0
- package/dist/runtime/mount-game.js +152 -0
- package/dist/runtime/mount-manifest.d.ts +119 -0
- package/dist/runtime/mount-manifest.d.ts.map +1 -0
- package/dist/runtime/mount-manifest.js +204 -0
- package/dist/runtime/render-audio-control.d.ts +110 -0
- package/dist/runtime/render-audio-control.d.ts.map +1 -0
- package/dist/runtime/render-audio-control.js +111 -0
- package/dist/runtime/render-control.d.ts +291 -0
- package/dist/runtime/render-control.d.ts.map +1 -0
- package/dist/runtime/render-control.js +264 -0
- package/dist/runtime/render-seed.d.ts +57 -0
- package/dist/runtime/render-seed.d.ts.map +1 -0
- package/dist/runtime/render-seed.js +74 -0
- package/dist/runtime/scene-ui-bridge.d.ts +69 -0
- package/dist/runtime/scene-ui-bridge.d.ts.map +1 -0
- package/dist/runtime/scene-ui-bridge.js +23 -0
- package/dist/runtime/scene-ui-data.d.ts +13 -0
- package/dist/runtime/scene-ui-data.d.ts.map +1 -0
- package/dist/runtime/scene-ui-data.js +92 -0
- package/dist/runtime/state-bridge.d.ts +47 -0
- package/dist/runtime/state-bridge.d.ts.map +1 -0
- package/dist/runtime/state-bridge.js +53 -0
- package/dist/runtime/types.d.ts +179 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/scene/asset-loaders.d.ts +79 -0
- package/dist/scene/asset-loaders.d.ts.map +1 -0
- package/dist/scene/asset-loaders.js +141 -0
- package/dist/scene/asset-paths.d.ts +11 -0
- package/dist/scene/asset-paths.d.ts.map +1 -0
- package/dist/scene/asset-paths.js +108 -0
- package/dist/scene/asset-ref-check.d.ts +88 -0
- package/dist/scene/asset-ref-check.d.ts.map +1 -0
- package/dist/scene/asset-ref-check.js +214 -0
- package/dist/scene/asset-registry.d.ts +30 -0
- package/dist/scene/asset-registry.d.ts.map +1 -0
- package/dist/scene/asset-registry.js +50 -0
- package/dist/scene/collider-dimensions.d.ts +63 -0
- package/dist/scene/collider-dimensions.d.ts.map +1 -0
- package/dist/scene/collider-dimensions.js +98 -0
- package/dist/scene/component-registry.d.ts +17 -0
- package/dist/scene/component-registry.d.ts.map +1 -0
- package/dist/scene/component-registry.js +28 -0
- package/dist/scene/defaults.d.ts +252 -0
- package/dist/scene/defaults.d.ts.map +1 -0
- package/dist/scene/defaults.js +151 -0
- package/dist/scene/geometries/index.d.ts +8 -0
- package/dist/scene/geometries/index.d.ts.map +1 -0
- package/dist/scene/geometries/index.js +7 -0
- package/dist/scene/geometries/terrain.d.ts +2 -0
- package/dist/scene/geometries/terrain.d.ts.map +1 -0
- package/dist/scene/geometries/terrain.js +37 -0
- package/dist/scene/geometry-registry.d.ts +24 -0
- package/dist/scene/geometry-registry.d.ts.map +1 -0
- package/dist/scene/geometry-registry.js +20 -0
- package/dist/scene/instance-registry.d.ts +36 -0
- package/dist/scene/instance-registry.d.ts.map +1 -0
- package/dist/scene/instance-registry.js +55 -0
- package/dist/scene/instancers/grid.d.ts +2 -0
- package/dist/scene/instancers/grid.d.ts.map +1 -0
- package/dist/scene/instancers/grid.js +36 -0
- package/dist/scene/instancers/index.d.ts +8 -0
- package/dist/scene/instancers/index.d.ts.map +1 -0
- package/dist/scene/instancers/index.js +7 -0
- package/dist/scene/light-camera-factory.d.ts +23 -0
- package/dist/scene/light-camera-factory.d.ts.map +1 -0
- package/dist/scene/light-camera-factory.js +68 -0
- package/dist/scene/material-factory.d.ts +17 -0
- package/dist/scene/material-factory.d.ts.map +1 -0
- package/dist/scene/material-factory.js +197 -0
- package/dist/scene/material-registry.d.ts +40 -0
- package/dist/scene/material-registry.d.ts.map +1 -0
- package/dist/scene/material-registry.js +44 -0
- package/dist/scene/materials/index.d.ts +8 -0
- package/dist/scene/materials/index.d.ts.map +1 -0
- package/dist/scene/materials/index.js +7 -0
- package/dist/scene/materials/water.d.ts +2 -0
- package/dist/scene/materials/water.d.ts.map +1 -0
- package/dist/scene/materials/water.js +54 -0
- package/dist/scene/parse.d.ts +23 -0
- package/dist/scene/parse.d.ts.map +1 -0
- package/dist/scene/parse.js +179 -0
- package/dist/scene/particles-factory.d.ts +33 -0
- package/dist/scene/particles-factory.d.ts.map +1 -0
- package/dist/scene/particles-factory.js +282 -0
- package/dist/scene/scene-apply.d.ts +109 -0
- package/dist/scene/scene-apply.d.ts.map +1 -0
- package/dist/scene/scene-apply.js +326 -0
- package/dist/scene/scene-diff-schema.d.ts +285 -0
- package/dist/scene/scene-diff-schema.d.ts.map +1 -0
- package/dist/scene/scene-diff-schema.js +92 -0
- package/dist/scene/scene-diff-types.d.ts +40 -0
- package/dist/scene/scene-diff-types.d.ts.map +1 -0
- package/dist/scene/scene-diff-types.js +14 -0
- package/dist/scene/scene-loader.d.ts +177 -0
- package/dist/scene/scene-loader.d.ts.map +1 -0
- package/dist/scene/scene-loader.js +1213 -0
- package/dist/scene/scene-query.d.ts +11 -0
- package/dist/scene/scene-query.d.ts.map +1 -0
- package/dist/scene/scene-query.js +63 -0
- package/dist/scene/scene-types.d.ts +10 -0
- package/dist/scene/scene-types.d.ts.map +1 -0
- package/dist/scene/scene-types.js +8 -0
- package/dist/scene/scene-version.d.ts +26 -0
- package/dist/scene/scene-version.d.ts.map +1 -0
- package/dist/scene/scene-version.js +34 -0
- package/dist/scene/schema/animation.d.ts +8 -0
- package/dist/scene/schema/animation.d.ts.map +1 -0
- package/dist/scene/schema/animation.js +42 -0
- package/dist/scene/schema/audio.d.ts +13 -0
- package/dist/scene/schema/audio.d.ts.map +1 -0
- package/dist/scene/schema/audio.js +22 -0
- package/dist/scene/schema/camera.d.ts +28 -0
- package/dist/scene/schema/camera.d.ts.map +1 -0
- package/dist/scene/schema/camera.js +17 -0
- package/dist/scene/schema/collider.d.ts +40 -0
- package/dist/scene/schema/collider.d.ts.map +1 -0
- package/dist/scene/schema/collider.js +55 -0
- package/dist/scene/schema/entity-ref.d.ts +31 -0
- package/dist/scene/schema/entity-ref.d.ts.map +1 -0
- package/dist/scene/schema/entity-ref.js +61 -0
- package/dist/scene/schema/entity.d.ts +1036 -0
- package/dist/scene/schema/entity.d.ts.map +1 -0
- package/dist/scene/schema/entity.js +153 -0
- package/dist/scene/schema/environment.d.ts +425 -0
- package/dist/scene/schema/environment.d.ts.map +1 -0
- package/dist/scene/schema/environment.js +357 -0
- package/dist/scene/schema/index.d.ts +39 -0
- package/dist/scene/schema/index.d.ts.map +1 -0
- package/dist/scene/schema/index.js +20 -0
- package/dist/scene/schema/instances.d.ts +14 -0
- package/dist/scene/schema/instances.d.ts.map +1 -0
- package/dist/scene/schema/instances.js +28 -0
- package/dist/scene/schema/joint.d.ts +23 -0
- package/dist/scene/schema/joint.d.ts.map +1 -0
- package/dist/scene/schema/joint.js +23 -0
- package/dist/scene/schema/light.d.ts +38 -0
- package/dist/scene/schema/light.d.ts.map +1 -0
- package/dist/scene/schema/light.js +26 -0
- package/dist/scene/schema/material.d.ts +199 -0
- package/dist/scene/schema/material.d.ts.map +1 -0
- package/dist/scene/schema/material.js +99 -0
- package/dist/scene/schema/mesh.d.ts +48 -0
- package/dist/scene/schema/mesh.d.ts.map +1 -0
- package/dist/scene/schema/mesh.js +82 -0
- package/dist/scene/schema/particles.d.ts +2178 -0
- package/dist/scene/schema/particles.d.ts.map +1 -0
- package/dist/scene/schema/particles.js +321 -0
- package/dist/scene/schema/physics.d.ts +56 -0
- package/dist/scene/schema/physics.d.ts.map +1 -0
- package/dist/scene/schema/physics.js +37 -0
- package/dist/scene/schema/scene-file.d.ts +304 -0
- package/dist/scene/schema/scene-file.d.ts.map +1 -0
- package/dist/scene/schema/scene-file.js +262 -0
- package/dist/scene/schema/shadow.d.ts +28 -0
- package/dist/scene/schema/shadow.d.ts.map +1 -0
- package/dist/scene/schema/shadow.js +20 -0
- package/dist/scene/schema/spline.d.ts +25 -0
- package/dist/scene/schema/spline.d.ts.map +1 -0
- package/dist/scene/schema/spline.js +15 -0
- package/dist/scene/schema/tuples.d.ts +12 -0
- package/dist/scene/schema/tuples.d.ts.map +1 -0
- package/dist/scene/schema/tuples.js +14 -0
- package/dist/scene/schema/ui.d.ts +880 -0
- package/dist/scene/schema/ui.d.ts.map +1 -0
- package/dist/scene/schema/ui.js +506 -0
- package/dist/scene/user-data.d.ts +171 -0
- package/dist/scene/user-data.d.ts.map +1 -0
- package/dist/scene/user-data.js +137 -0
- package/dist/setup/setup-audio.d.ts +20 -0
- package/dist/setup/setup-audio.d.ts.map +1 -0
- package/dist/setup/setup-audio.js +41 -0
- package/dist/setup/setup-particles.d.ts +17 -0
- package/dist/setup/setup-particles.d.ts.map +1 -0
- package/dist/setup/setup-particles.js +16 -0
- package/dist/setup/setup-physics.d.ts +25 -0
- package/dist/setup/setup-physics.d.ts.map +1 -0
- package/dist/setup/setup-physics.js +51 -0
- package/dist/setup/setup-renderer.d.ts +69 -0
- package/dist/setup/setup-renderer.d.ts.map +1 -0
- package/dist/setup/setup-renderer.js +363 -0
- package/dist/tools/define-tool.d.ts +105 -0
- package/dist/tools/define-tool.d.ts.map +1 -0
- package/dist/tools/define-tool.js +82 -0
- package/dist/world2d/authoring-2d.d.ts +76 -0
- package/dist/world2d/authoring-2d.d.ts.map +1 -0
- package/dist/world2d/authoring-2d.js +176 -0
- package/dist/world2d/capture-to-scene2d.d.ts +5 -0
- package/dist/world2d/capture-to-scene2d.d.ts.map +1 -0
- package/dist/world2d/capture-to-scene2d.js +49 -0
- package/dist/world2d/collision-2d.d.ts +52 -0
- package/dist/world2d/collision-2d.d.ts.map +1 -0
- package/dist/world2d/collision-2d.js +70 -0
- package/dist/world2d/components-2d.d.ts +47 -0
- package/dist/world2d/components-2d.d.ts.map +1 -0
- package/dist/world2d/components-2d.js +77 -0
- package/dist/world2d/index.d.ts +34 -0
- package/dist/world2d/index.d.ts.map +1 -0
- package/dist/world2d/index.js +32 -0
- package/dist/world2d/ingest-iframe-2d.d.ts +82 -0
- package/dist/world2d/ingest-iframe-2d.d.ts.map +1 -0
- package/dist/world2d/ingest-iframe-2d.js +166 -0
- package/dist/world2d/ingest2d.d.ts +97 -0
- package/dist/world2d/ingest2d.d.ts.map +1 -0
- package/dist/world2d/ingest2d.js +40 -0
- package/dist/world2d/physics2d-registry.d.ts +24 -0
- package/dist/world2d/physics2d-registry.d.ts.map +1 -0
- package/dist/world2d/physics2d-registry.js +38 -0
- package/dist/world2d/pixi-game-adapter.d.ts +107 -0
- package/dist/world2d/pixi-game-adapter.d.ts.map +1 -0
- package/dist/world2d/pixi-game-adapter.js +211 -0
- package/dist/world2d/pixi-surface.d.ts +39 -0
- package/dist/world2d/pixi-surface.d.ts.map +1 -0
- package/dist/world2d/pixi-surface.js +47 -0
- package/dist/world2d/scene-capture-2d.d.ts +43 -0
- package/dist/world2d/scene-capture-2d.d.ts.map +1 -0
- package/dist/world2d/scene-capture-2d.js +92 -0
- package/dist/world2d/scene2d-loader.d.ts +27 -0
- package/dist/world2d/scene2d-loader.d.ts.map +1 -0
- package/dist/world2d/scene2d-loader.js +274 -0
- package/dist/world2d/schema/entity2d.d.ts +102 -0
- package/dist/world2d/schema/entity2d.d.ts.map +1 -0
- package/dist/world2d/schema/entity2d.js +119 -0
- package/dist/world2d/schema/physics2d.d.ts +46 -0
- package/dist/world2d/schema/physics2d.d.ts.map +1 -0
- package/dist/world2d/schema/physics2d.js +45 -0
- package/dist/world2d/schema/sprite.d.ts +42 -0
- package/dist/world2d/schema/sprite.d.ts.map +1 -0
- package/dist/world2d/schema/sprite.js +63 -0
- package/dist/world2d/schema/tilemap.d.ts +15 -0
- package/dist/world2d/schema/tilemap.d.ts.map +1 -0
- package/dist/world2d/schema/tilemap.js +19 -0
- package/dist/world2d/schema/tuples2d.d.ts +20 -0
- package/dist/world2d/schema/tuples2d.d.ts.map +1 -0
- package/dist/world2d/schema/tuples2d.js +19 -0
- package/dist/world2d/system-adapters-2d.d.ts +16 -0
- package/dist/world2d/system-adapters-2d.d.ts.map +1 -0
- package/dist/world2d/system-adapters-2d.js +37 -0
- package/dist/world2d/transform-writer-2d.d.ts +16 -0
- package/dist/world2d/transform-writer-2d.d.ts.map +1 -0
- package/dist/world2d/transform-writer-2d.js +22 -0
- package/dist/world2d/types.d.ts +53 -0
- package/dist/world2d/types.d.ts.map +1 -0
- package/dist/world2d/types.js +1 -0
- package/package.json +18 -4
- package/src/adapter/authoring.ts +10 -0
- package/src/adapter/first-party-systems.ts +23 -34
- package/src/adapter/index.ts +1 -3
- package/src/adapter/system-adapter.ts +15 -22
- package/src/adapter/vgai-scene-game-adapter.ts +5 -14
- package/src/animation/anim-graph-types.ts +12 -43
- package/src/animation/animation-clock.ts +479 -0
- package/src/animation/camera-ownership.ts +467 -0
- package/src/animation/cinematic-cues.ts +451 -0
- package/src/animation/clip-map.ts +41 -0
- package/src/animation/gsap-registration.ts +184 -0
- package/src/animation/theatre-clock-binding.ts +111 -0
- package/src/animation/theatre-director.ts +347 -0
- package/src/animation/theatre-object-binding.ts +661 -0
- package/src/animation/xstate-animation-binding.ts +398 -0
- package/src/animation/xstate-animation-meta.ts +282 -0
- package/src/audio/index.ts +39 -7
- package/src/audio/tone-clock-binding.ts +98 -0
- package/src/audio/tone-context.ts +129 -0
- package/src/audio/tone-offline-render.ts +167 -0
- package/src/audio/wav-encode.ts +119 -0
- package/src/core/game-loop.ts +17 -0
- package/src/core/types.ts +13 -0
- package/src/data/data-asset.ts +167 -0
- package/src/data/data-check-core.ts +242 -0
- package/src/data/data-ref.ts +145 -0
- package/src/data/vite-plugin-data.ts +290 -0
- package/src/index.ts +48 -0
- package/src/input/input-manager.ts +1206 -32
- package/src/input/input-types.ts +155 -3
- package/src/input/prompt-labels.ts +122 -0
- package/src/input/rebind-controller.ts +105 -0
- package/src/input/schema.ts +206 -52
- package/src/react/use-data.ts +114 -0
- package/src/react/use-selection.tsx +135 -0
- package/src/runtime/create-runtime.ts +30 -9
- package/src/runtime/render-audio-control.ts +168 -0
- package/src/runtime/render-control.ts +522 -0
- package/src/runtime/render-seed.ts +79 -0
- package/src/runtime/types.ts +0 -5
- package/src/scene/asset-loaders.ts +10 -36
- package/src/scene/asset-paths.ts +0 -2
- package/src/scene/asset-ref-check.ts +248 -0
- package/src/scene/parse.ts +133 -0
- package/src/scene/scene-loader.ts +81 -96
- package/src/scene/schema/animation.ts +30 -79
- package/src/scene/schema/entity.ts +20 -0
- package/src/scene/schema/index.ts +2 -12
- package/src/scene/user-data.ts +8 -9
- package/src/setup/setup-renderer.ts +9 -2
- package/src/tools/define-tool.ts +152 -0
- package/src/animation/anim-graph.ts +0 -406
- package/src/animation/anim-system.ts +0 -28
- package/src/animation/property-track.ts +0 -178
- package/src/animation/schema.ts +0 -204
- package/src/audio/ambient.ts +0 -300
- package/src/audio/impacts.ts +0 -212
- package/src/audio/movement.ts +0 -140
- package/src/audio/musical.ts +0 -200
- package/src/audio/ui-sounds.ts +0 -171
- package/src/audio/vehicle.ts +0 -235
- package/src/audio/weapons.ts +0 -152
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { evaluateBlendTree } from './blend-node';
|
|
3
|
+
import { clipNamesOf, collectMachineAnimationMeta, isBlendTreeAnimationMeta, } from './xstate-animation-meta';
|
|
4
|
+
/**
|
|
5
|
+
* E2 — bind a native XState actor to a native `THREE.AnimationMixer` (spec
|
|
6
|
+
* §11 E2, §5.6, §3.3).
|
|
7
|
+
*
|
|
8
|
+
* A native XState actor drives native `THREE.AnimationAction`s: entering a
|
|
9
|
+
* state activates its `meta.animation` clip(s); leaving it deactivates them.
|
|
10
|
+
* There is no VGAI-specific trigger vocabulary — callers drive the machine
|
|
11
|
+
* with ordinary `actor.send(event)` (or the actor is externally owned and
|
|
12
|
+
* this binding merely observes it); XState alone decides which state is
|
|
13
|
+
* active.
|
|
14
|
+
*
|
|
15
|
+
* ## How enter/exit crossfades use NATIVE Three primitives (not a
|
|
16
|
+
* hand-rolled weight scheduler)
|
|
17
|
+
*
|
|
18
|
+
* The former `AnimGraph` runtime (removed by E5) pre-played every action at
|
|
19
|
+
* weight 0 and re-set every action's weight explicitly every frame,
|
|
20
|
+
* BYPASSING `AnimationAction.fadeIn`/`fadeOut`/`crossFadeTo` (to dodge
|
|
21
|
+
* multi-layer weight-summing bugs it hit historically).
|
|
22
|
+
* E2 deliberately does the opposite, per the spec AC ("use
|
|
23
|
+
* AnimationAction.crossFadeTo / fadeIn / fadeOut per the metadata"): the
|
|
24
|
+
* ENTER/EXIT edge of an XState state transition is represented by one real
|
|
25
|
+
* Three fade call, and `mixer.update(dt)` — the same call that advances clip
|
|
26
|
+
* time — is what advances the fade too. No parallel elapsed-time clock
|
|
27
|
+
* drives "is the fade done" for a plain (non-blend-tree) state; Three's own
|
|
28
|
+
* scheduler is authoritative end to end.
|
|
29
|
+
*
|
|
30
|
+
* A **blend-tree** state is, at the instant of entry, represented by ONE
|
|
31
|
+
* clip — its heaviest-weighted child at that instant (the same "representative"
|
|
32
|
+
* duration/action heuristic the removed `AnimGraph.LayerRuntime` used) — which
|
|
33
|
+
* receives the native crossFadeTo/fadeIn. Sibling
|
|
34
|
+
* children stay silent (weight 0) until the crossfade window elapses, at
|
|
35
|
+
* which point the FULL live blend-tree distribution (`evaluateBlendTree`,
|
|
36
|
+
* reused verbatim from `blend-node.ts` — no reimplementation) takes over via
|
|
37
|
+
* `setEffectiveWeight` every tick, recomputed from the actor's live
|
|
38
|
+
* context/selector value. This is a documented simplification (Three's
|
|
39
|
+
* `crossFadeTo` is strictly 1-to-1; there is no native N-ary blend-tree
|
|
40
|
+
* crossfade), the same spirit as `blend-node.ts`'s own documented 2D
|
|
41
|
+
* "smooth approximation, not Delaunay/barycentric" caveat. The crossfade
|
|
42
|
+
* window itself is tracked as a small elapsed-seconds counter, decremented
|
|
43
|
+
* by the SAME `dt` passed to `mixer.update(dt)` — it never drifts from
|
|
44
|
+
* Three's own fade schedule because both are driven by the identical `dt`
|
|
45
|
+
* stream, so it is bookkeeping for "when to hand off from native fade to
|
|
46
|
+
* live blend", not a second competing scheduler.
|
|
47
|
+
*
|
|
48
|
+
* ## Mixer advancement uses the canonical engine ANIMATION phase
|
|
49
|
+
*
|
|
50
|
+
* `tick(dt)` has exactly the engine's `SystemFn` shape (`core/types.ts`:
|
|
51
|
+
* `(dt: number) => void`) — a caller registers this binding on the engine's
|
|
52
|
+
* one real fixed-step scheduler at the ANIMATION phase, exactly as any other
|
|
53
|
+
* per-frame system: `ctx.systems.add(SystemPhase.ANIMATION, binding.tick)`
|
|
54
|
+
* (or, when the binding is owned by a `GameComponent` that also owns the
|
|
55
|
+
* actor — the §5.6 pattern the examples use — the component simply calls
|
|
56
|
+
* `binding.tick(dt)` from its own `update(dt)`). Either way mixer advancement
|
|
57
|
+
* rides that one scheduler; no second scheduler is invented here. (This is
|
|
58
|
+
* the same ANIMATION-phase slot the removed `AnimGraph` runtime's global
|
|
59
|
+
* `animationSystem` occupied before E5 — see
|
|
60
|
+
* docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md §3.3/§11 E5. The D1
|
|
61
|
+
* `AnimationClock` — `animation-clock.ts` — is a distinct, sibling concern: a
|
|
62
|
+
* per-cinematic/Theatre-timeline seek clock for scrubbing/export, not wired
|
|
63
|
+
* into ordinary gameplay ticking today.)
|
|
64
|
+
*/
|
|
65
|
+
/** Thrown for a binding-time problem: a missing clip, or a target-less bind. */
|
|
66
|
+
export class AnimationBindingError extends Error {
|
|
67
|
+
stateId;
|
|
68
|
+
constructor(message, stateId) {
|
|
69
|
+
super(message);
|
|
70
|
+
this.stateId = stateId;
|
|
71
|
+
this.name = 'AnimationBindingError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function dominantOf(weights) {
|
|
75
|
+
return weights.reduce((a, b) => (b.weight > a.weight ? b : a), weights[0]);
|
|
76
|
+
}
|
|
77
|
+
function naturalWeightsOf(meta) {
|
|
78
|
+
if (isBlendTreeAnimationMeta(meta)) {
|
|
79
|
+
// AnimationBlendTree (xstate-animation-meta.ts) is structurally
|
|
80
|
+
// identical to BlendTreeDef (anim-graph-types.ts) by design — reuse
|
|
81
|
+
// evaluateBlendTree verbatim, no conversion/reimplementation.
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
return [{ clip: meta.clip, weight: 1 }];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Bind an XState actor to a `THREE.AnimationMixer`.
|
|
88
|
+
*
|
|
89
|
+
* Validates EVERY state's `meta.animation` (via `collectMachineAnimationMeta`,
|
|
90
|
+
* E1) and resolves every referenced clip name against `clips` up front, at
|
|
91
|
+
* bind time — before the actor enters any of those states — so an agent
|
|
92
|
+
* authoring a machine with a typo'd clip name gets an actionable error
|
|
93
|
+
* immediately, not only once gameplay happens to reach that state.
|
|
94
|
+
*
|
|
95
|
+
* @throws {AnimationBindingError} if a state's meta references a clip name
|
|
96
|
+
* not present in `clips`, naming both the state and the clip.
|
|
97
|
+
*/
|
|
98
|
+
export function bindXStateAnimation(actor, mixer, clips, options = {}) {
|
|
99
|
+
const root = actor.logic.root;
|
|
100
|
+
const entries = collectMachineAnimationMeta(root);
|
|
101
|
+
const metaByStateId = new Map(entries.map((e) => [e.stateId, e.meta]));
|
|
102
|
+
// Resolve every referenced clip up front — actionable, named errors before
|
|
103
|
+
// any state is ever entered.
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
for (const clipName of clipNamesOf(entry.meta)) {
|
|
106
|
+
if (!clips.has(clipName)) {
|
|
107
|
+
throw new AnimationBindingError(`[bindXStateAnimation] state "${entry.stateId}" references clip "${clipName}", which is ` +
|
|
108
|
+
`not present in the supplied clips map. Known clips: ${[...clips.keys()].join(', ') || '(none)'}`, entry.stateId);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const actionCache = new Map();
|
|
113
|
+
function ensureAction(clipName, loop, speed) {
|
|
114
|
+
let action = actionCache.get(clipName);
|
|
115
|
+
if (!action) {
|
|
116
|
+
const clip = clips.get(clipName);
|
|
117
|
+
if (!clip) {
|
|
118
|
+
// Unreachable given the up-front resolution above; kept as a named,
|
|
119
|
+
// defensive error rather than a silent `mixer.clipAction(undefined)`.
|
|
120
|
+
throw new AnimationBindingError(`[bindXStateAnimation] clip "${clipName}" not found`);
|
|
121
|
+
}
|
|
122
|
+
action = mixer.clipAction(clip);
|
|
123
|
+
action.setEffectiveWeight(0);
|
|
124
|
+
action.play(); // must be "active" for mixer.update() to tick it at all (Three only advances active actions)
|
|
125
|
+
actionCache.set(clipName, action);
|
|
126
|
+
}
|
|
127
|
+
action.setLoop(loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity);
|
|
128
|
+
action.clampWhenFinished = !loop;
|
|
129
|
+
action.timeScale = speed;
|
|
130
|
+
return action;
|
|
131
|
+
}
|
|
132
|
+
function readParameters(context) {
|
|
133
|
+
const raw = options.selectParameters
|
|
134
|
+
? options.selectParameters(context)
|
|
135
|
+
: context;
|
|
136
|
+
return new Map(Object.entries(raw ?? {}));
|
|
137
|
+
}
|
|
138
|
+
let active = null;
|
|
139
|
+
let disposed = false;
|
|
140
|
+
// Known limitation (shared with plain Three.js `crossFadeTo` usage generally):
|
|
141
|
+
// `AnimationAction.fadeOut(duration)` always schedules a fixed 1→0 ramp, not
|
|
142
|
+
// "current weight → 0" — interrupting an action that is itself still
|
|
143
|
+
// mid-fade-in (e.g. a state transitions again before its own crossfade
|
|
144
|
+
// settles) can produce a brief visible pop back toward full weight before
|
|
145
|
+
// fading out. This is a native Three scheduling property, not something
|
|
146
|
+
// this binding's bookkeeping can smooth over without re-implementing
|
|
147
|
+
// Three's own weight scheduler; same accepted-approximation spirit as
|
|
148
|
+
// `blend-node.ts`'s documented 2D IDW caveat.
|
|
149
|
+
function silence(weights, except, duration) {
|
|
150
|
+
for (const { clip: clipName } of weights) {
|
|
151
|
+
if (clipName === except)
|
|
152
|
+
continue;
|
|
153
|
+
const action = actionCache.get(clipName);
|
|
154
|
+
if (!action)
|
|
155
|
+
continue;
|
|
156
|
+
if (duration > 0)
|
|
157
|
+
action.fadeOut(duration);
|
|
158
|
+
else
|
|
159
|
+
action.setEffectiveWeight(0);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Ensure every clip in `weights` has an action; reset the dominant one to weight 1 (base
|
|
163
|
+
* multiplier for the fade schedule about to be applied) and every sibling to silent (0). */
|
|
164
|
+
function prepareStateActions(weights, dominantClip, loop, speed) {
|
|
165
|
+
for (const { clip: clipName } of weights)
|
|
166
|
+
ensureAction(clipName, loop, speed);
|
|
167
|
+
const dominantAction = actionCache.get(dominantClip);
|
|
168
|
+
dominantAction.reset();
|
|
169
|
+
// `setEffectiveWeight(1)` (not just `.reset()`) is required here: reset() does not touch the
|
|
170
|
+
// base `.weight` multiplier a scheduled fade scales against, and this action may previously
|
|
171
|
+
// have been a silenced blend-tree sibling left at `.weight === 0` — left alone, that would mute
|
|
172
|
+
// the crossFadeTo/fadeIn schedule applied below to a permanent 0.
|
|
173
|
+
dominantAction.setEffectiveWeight(1);
|
|
174
|
+
// Non-dominant children of THIS state start silent; they pick up their
|
|
175
|
+
// live share once the crossfade window elapses (see `tick`).
|
|
176
|
+
for (const { clip: clipName } of weights) {
|
|
177
|
+
if (clipName === dominantClip)
|
|
178
|
+
continue;
|
|
179
|
+
const action = actionCache.get(clipName);
|
|
180
|
+
action.reset();
|
|
181
|
+
action.setEffectiveWeight(0);
|
|
182
|
+
}
|
|
183
|
+
return dominantAction;
|
|
184
|
+
}
|
|
185
|
+
/** Apply the enter-transition schedule: native crossFadeTo (from a previous dominant), a plain
|
|
186
|
+
* fadeIn (first-ever activation with a duration), or an immediate hard cut (duration 0). */
|
|
187
|
+
function activateTransition(dominantAction, outgoing, duration, warp) {
|
|
188
|
+
if (!outgoing) {
|
|
189
|
+
if (duration > 0)
|
|
190
|
+
dominantAction.fadeIn(duration);
|
|
191
|
+
else
|
|
192
|
+
dominantAction.setEffectiveWeight(1);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
// Fade out every non-dominant sibling of the OUTGOING state — a plain
|
|
196
|
+
// (non-blend) outgoing state has none.
|
|
197
|
+
silence(outgoing.natural, outgoing.dominantClip, duration);
|
|
198
|
+
const previousDominant = actionCache.get(outgoing.dominantClip);
|
|
199
|
+
if (previousDominant && duration > 0) {
|
|
200
|
+
previousDominant.crossFadeTo(dominantAction, duration, warp);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
previousDominant?.setEffectiveWeight(0);
|
|
204
|
+
dominantAction.setEffectiveWeight(1);
|
|
205
|
+
}
|
|
206
|
+
function enterState(stateId, meta, context) {
|
|
207
|
+
const isBlend = isBlendTreeAnimationMeta(meta);
|
|
208
|
+
const weights = isBlend
|
|
209
|
+
? evaluateBlendTree(meta.blendTree, readParameters(context))
|
|
210
|
+
: naturalWeightsOf(meta);
|
|
211
|
+
const dominant = dominantOf(weights);
|
|
212
|
+
const loop = isBlend ? true : meta.loop;
|
|
213
|
+
const speed = isBlend ? 1 : meta.speed;
|
|
214
|
+
const dominantAction = prepareStateActions(weights, dominant.clip, loop, speed);
|
|
215
|
+
const duration = meta.crossfade?.duration ?? 0;
|
|
216
|
+
const warp = meta.crossfade?.warp ?? false;
|
|
217
|
+
activateTransition(dominantAction, active, duration, warp);
|
|
218
|
+
active = {
|
|
219
|
+
stateId,
|
|
220
|
+
meta,
|
|
221
|
+
natural: weights,
|
|
222
|
+
dominantClip: dominant.clip,
|
|
223
|
+
crossfadeRemaining: duration,
|
|
224
|
+
};
|
|
225
|
+
// Zero-duration blend-tree entry: no crossfade window to wait out —
|
|
226
|
+
// apply the full live distribution immediately instead of leaving
|
|
227
|
+
// siblings silent for one extra tick.
|
|
228
|
+
if (isBlend && duration <= 0) {
|
|
229
|
+
applyLiveBlendWeights(active, context);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function applyLiveBlendWeights(state, context) {
|
|
233
|
+
if (!isBlendTreeAnimationMeta(state.meta))
|
|
234
|
+
return;
|
|
235
|
+
const params = readParameters(context);
|
|
236
|
+
const weights = evaluateBlendTree(state.meta.blendTree, params);
|
|
237
|
+
state.natural = weights;
|
|
238
|
+
for (const { clip: clipName, weight } of weights) {
|
|
239
|
+
actionCache.get(clipName)?.setEffectiveWeight(weight);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const initialSnapshot = actor.getSnapshot();
|
|
243
|
+
const initialStateId = leafStateIdOf(initialSnapshot, metaByStateId);
|
|
244
|
+
if (initialStateId) {
|
|
245
|
+
enterState(initialStateId, metaByStateId.get(initialStateId), initialSnapshot.context);
|
|
246
|
+
}
|
|
247
|
+
const subscription = actor.subscribe((snapshot) => {
|
|
248
|
+
if (disposed)
|
|
249
|
+
return;
|
|
250
|
+
const stateId = leafStateIdOf(snapshot, metaByStateId);
|
|
251
|
+
const meta = stateId ? metaByStateId.get(stateId) : undefined;
|
|
252
|
+
if (meta && stateId && stateId !== active?.stateId) {
|
|
253
|
+
enterState(stateId, meta, snapshot.context);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
function tick(dt) {
|
|
257
|
+
if (disposed)
|
|
258
|
+
return;
|
|
259
|
+
if (active && active.crossfadeRemaining > 0) {
|
|
260
|
+
active.crossfadeRemaining = Math.max(0, active.crossfadeRemaining - dt);
|
|
261
|
+
if (active.crossfadeRemaining <= 0 && isBlendTreeAnimationMeta(active.meta)) {
|
|
262
|
+
applyLiveBlendWeights(active, actor.getSnapshot().context);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (active && isBlendTreeAnimationMeta(active.meta)) {
|
|
266
|
+
applyLiveBlendWeights(active, actor.getSnapshot().context);
|
|
267
|
+
}
|
|
268
|
+
mixer.update(dt);
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
tick,
|
|
272
|
+
actor,
|
|
273
|
+
dispose() {
|
|
274
|
+
if (disposed)
|
|
275
|
+
return;
|
|
276
|
+
disposed = true;
|
|
277
|
+
subscription.unsubscribe();
|
|
278
|
+
for (const [clipName, action] of actionCache) {
|
|
279
|
+
action.stop();
|
|
280
|
+
mixer.uncacheAction(action.getClip(), action.getRoot());
|
|
281
|
+
actionCache.delete(clipName);
|
|
282
|
+
}
|
|
283
|
+
active = null;
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The full state id (e.g. `"character-animation.locomotion"`) of the single
|
|
289
|
+
* currently-active leaf that declares `meta.animation`, per `snapshot.value`.
|
|
290
|
+
* XState's `snapshot.getMeta()` is keyed by EVERY active state node's id
|
|
291
|
+
* (including ancestors with no meta of their own); this narrows to whichever
|
|
292
|
+
* one is actually described in `metaByStateId`. Machines with more than one
|
|
293
|
+
* simultaneously-active animated leaf (parallel regions each declaring
|
|
294
|
+
* `meta.animation`) are out of scope for this binding — v1 assumes exactly
|
|
295
|
+
* one active animation-bearing state at a time, matching the single-mixer
|
|
296
|
+
* §5.6 example; a machine that violates this throws rather than silently
|
|
297
|
+
* picking one.
|
|
298
|
+
*/
|
|
299
|
+
function leafStateIdOf(snapshot, metaByStateId) {
|
|
300
|
+
const activeIds = Object.keys(snapshot.getMeta()).filter((id) => metaByStateId.has(id));
|
|
301
|
+
if (activeIds.length > 1) {
|
|
302
|
+
throw new AnimationBindingError(`[bindXStateAnimation] more than one animated state is simultaneously active ` +
|
|
303
|
+
`(${activeIds.join(', ')}) — parallel-region animation composition is not supported by this ` +
|
|
304
|
+
'binding; exactly one active meta.animation state is required.');
|
|
305
|
+
}
|
|
306
|
+
return activeIds[0];
|
|
307
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* E1 — Zod/TypeScript metadata attached to XState state `meta.animation`
|
|
4
|
+
* (spec §11 E1, §5.6, §3.3).
|
|
5
|
+
*
|
|
6
|
+
* This module defines ONLY animation data: which clip(s) a state plays, how
|
|
7
|
+
* they loop/blend/crossfade, and (for locomotion-style states) how a 1D/2D/
|
|
8
|
+
* direct blend tree distributes weight across several clips from a live
|
|
9
|
+
* parameter. It intentionally contains **no transition vocabulary** — no
|
|
10
|
+
* `on`/`target`/`guard`/`always`/`after`/`entry`/`exit`. XState alone owns
|
|
11
|
+
* states, transitions, events, and guards (§3.3); this metadata is read-only
|
|
12
|
+
* data a binding (`xstate-animation-binding.ts`, E2) consumes to drive a
|
|
13
|
+
* `THREE.AnimationMixer` when XState enters/exits a state. Every schema below
|
|
14
|
+
* is `.strict()` specifically so that smuggling a transition-shaped key into
|
|
15
|
+
* `meta.animation` is a loud Zod "unrecognized key" error, not a silently
|
|
16
|
+
* ignored field (E1 AC: "Metadata contains no transition language").
|
|
17
|
+
*
|
|
18
|
+
* ## Deliberately out of scope: layers, additive blending, bone masks
|
|
19
|
+
*
|
|
20
|
+
* The spec asks for layer/weight/additive metadata "if retained" and bone
|
|
21
|
+
* masks "if supported by the Three implementation" (§11 E1). Neither is
|
|
22
|
+
* supported by the current Three-facing animation code: no bone-masking or
|
|
23
|
+
* blend-compositing across layers exists (the former `AnimGraph` layers, now
|
|
24
|
+
* removed by E5, never had it either, and rejected `blendMode`/`weight`/
|
|
25
|
+
* `boneMask` at parse for exactly this reason — those fields had no runtime
|
|
26
|
+
* reader anywhere in the engine). Per this repo's policy ("Do not author
|
|
27
|
+
* schema fields that have no runtime reader" — CLAUDE.md), this module does
|
|
28
|
+
* not declare fields for capabilities nothing reads. A single XState machine
|
|
29
|
+
* drives one mixer's weight budget; multi-machine/multi-layer composition
|
|
30
|
+
* (if ever added) is a distinct, future binding concern with its own reader,
|
|
31
|
+
* not a dead field here.
|
|
32
|
+
*
|
|
33
|
+
* ## Blend tree shape
|
|
34
|
+
*
|
|
35
|
+
* Deliberately structurally IDENTICAL to `anim-graph-types.ts`'s
|
|
36
|
+
* `BlendTreeDef` (same `type`/`parameter`/`parameterY`/`children[].clip`/
|
|
37
|
+
* `.threshold`/`.thresholdY`/`.weight` fields) so the binding can hand a
|
|
38
|
+
* parsed `AnimationBlendTree` straight to the existing, already-tested
|
|
39
|
+
* `evaluateBlendTree` (`blend-node.ts`) with zero conversion — E2 reuses that
|
|
40
|
+
* function verbatim rather than re-implementing 1D/2D/direct blend math.
|
|
41
|
+
*/
|
|
42
|
+
declare const AnimationBlendChildSchema: z.ZodObject<{
|
|
43
|
+
clip: z.ZodString;
|
|
44
|
+
threshold: z.ZodNumber;
|
|
45
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type AnimationBlendChild = z.infer<typeof AnimationBlendChildSchema>;
|
|
49
|
+
export declare const AnimationBlendTreeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"1D">;
|
|
51
|
+
parameter: z.ZodString;
|
|
52
|
+
children: z.ZodArray<z.ZodObject<{
|
|
53
|
+
clip: z.ZodString;
|
|
54
|
+
threshold: z.ZodNumber;
|
|
55
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strict>>;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<"2D">;
|
|
60
|
+
parameter: z.ZodString;
|
|
61
|
+
parameterY: z.ZodString;
|
|
62
|
+
children: z.ZodArray<z.ZodObject<{
|
|
63
|
+
clip: z.ZodString;
|
|
64
|
+
threshold: z.ZodNumber;
|
|
65
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
thresholdY: z.ZodNumber;
|
|
67
|
+
}, z.core.$strict>>;
|
|
68
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
69
|
+
type: z.ZodLiteral<"direct">;
|
|
70
|
+
parameter: z.ZodDefault<z.ZodString>;
|
|
71
|
+
children: z.ZodArray<z.ZodObject<{
|
|
72
|
+
clip: z.ZodString;
|
|
73
|
+
threshold: z.ZodNumber;
|
|
74
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
weight: z.ZodNumber;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
}, z.core.$strict>], "type">;
|
|
78
|
+
export type AnimationBlendTree = z.infer<typeof AnimationBlendTreeSchema>;
|
|
79
|
+
declare const AnimationCrossfadeMetaSchema: z.ZodObject<{
|
|
80
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
81
|
+
warp: z.ZodDefault<z.ZodBoolean>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
export type AnimationCrossfadeMeta = z.infer<typeof AnimationCrossfadeMetaSchema>;
|
|
84
|
+
declare const ClipAnimationMetaSchema: z.ZodObject<{
|
|
85
|
+
clip: z.ZodString;
|
|
86
|
+
loop: z.ZodDefault<z.ZodBoolean>;
|
|
87
|
+
speed: z.ZodDefault<z.ZodNumber>;
|
|
88
|
+
crossfade: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
warp: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
}, z.core.$strict>>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
export type ClipAnimationMeta = z.infer<typeof ClipAnimationMetaSchema>;
|
|
94
|
+
declare const BlendTreeAnimationMetaSchema: z.ZodObject<{
|
|
95
|
+
blendTree: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
96
|
+
type: z.ZodLiteral<"1D">;
|
|
97
|
+
parameter: z.ZodString;
|
|
98
|
+
children: z.ZodArray<z.ZodObject<{
|
|
99
|
+
clip: z.ZodString;
|
|
100
|
+
threshold: z.ZodNumber;
|
|
101
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strict>>;
|
|
104
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
105
|
+
type: z.ZodLiteral<"2D">;
|
|
106
|
+
parameter: z.ZodString;
|
|
107
|
+
parameterY: z.ZodString;
|
|
108
|
+
children: z.ZodArray<z.ZodObject<{
|
|
109
|
+
clip: z.ZodString;
|
|
110
|
+
threshold: z.ZodNumber;
|
|
111
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
thresholdY: z.ZodNumber;
|
|
113
|
+
}, z.core.$strict>>;
|
|
114
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
+
type: z.ZodLiteral<"direct">;
|
|
116
|
+
parameter: z.ZodDefault<z.ZodString>;
|
|
117
|
+
children: z.ZodArray<z.ZodObject<{
|
|
118
|
+
clip: z.ZodString;
|
|
119
|
+
threshold: z.ZodNumber;
|
|
120
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
weight: z.ZodNumber;
|
|
122
|
+
}, z.core.$strict>>;
|
|
123
|
+
}, z.core.$strict>], "type">;
|
|
124
|
+
crossfade: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
126
|
+
warp: z.ZodDefault<z.ZodBoolean>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
export type BlendTreeAnimationMeta = z.infer<typeof BlendTreeAnimationMetaSchema>;
|
|
130
|
+
/**
|
|
131
|
+
* The full shape of `state.meta.animation` for one XState state (spec §5.6):
|
|
132
|
+
* exactly one of a single clip or a blend tree, plus optional crossfade
|
|
133
|
+
* timing. `.strict()` on both branches is what makes authoring a transition
|
|
134
|
+
* keyword (`on`, `target`, `guard`, …) inside `meta.animation` a validation
|
|
135
|
+
* error instead of a silently-accepted second transition dialect.
|
|
136
|
+
*/
|
|
137
|
+
export declare const StateAnimationMetaSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
138
|
+
clip: z.ZodString;
|
|
139
|
+
loop: z.ZodDefault<z.ZodBoolean>;
|
|
140
|
+
speed: z.ZodDefault<z.ZodNumber>;
|
|
141
|
+
crossfade: z.ZodOptional<z.ZodObject<{
|
|
142
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
143
|
+
warp: z.ZodDefault<z.ZodBoolean>;
|
|
144
|
+
}, z.core.$strict>>;
|
|
145
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
146
|
+
blendTree: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
147
|
+
type: z.ZodLiteral<"1D">;
|
|
148
|
+
parameter: z.ZodString;
|
|
149
|
+
children: z.ZodArray<z.ZodObject<{
|
|
150
|
+
clip: z.ZodString;
|
|
151
|
+
threshold: z.ZodNumber;
|
|
152
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, z.core.$strict>>;
|
|
155
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
156
|
+
type: z.ZodLiteral<"2D">;
|
|
157
|
+
parameter: z.ZodString;
|
|
158
|
+
parameterY: z.ZodString;
|
|
159
|
+
children: z.ZodArray<z.ZodObject<{
|
|
160
|
+
clip: z.ZodString;
|
|
161
|
+
threshold: z.ZodNumber;
|
|
162
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
thresholdY: z.ZodNumber;
|
|
164
|
+
}, z.core.$strict>>;
|
|
165
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
166
|
+
type: z.ZodLiteral<"direct">;
|
|
167
|
+
parameter: z.ZodDefault<z.ZodString>;
|
|
168
|
+
children: z.ZodArray<z.ZodObject<{
|
|
169
|
+
clip: z.ZodString;
|
|
170
|
+
threshold: z.ZodNumber;
|
|
171
|
+
thresholdY: z.ZodOptional<z.ZodNumber>;
|
|
172
|
+
weight: z.ZodNumber;
|
|
173
|
+
}, z.core.$strict>>;
|
|
174
|
+
}, z.core.$strict>], "type">;
|
|
175
|
+
crossfade: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
duration: z.ZodDefault<z.ZodNumber>;
|
|
177
|
+
warp: z.ZodDefault<z.ZodBoolean>;
|
|
178
|
+
}, z.core.$strict>>;
|
|
179
|
+
}, z.core.$strict>]>;
|
|
180
|
+
export type StateAnimationMeta = z.infer<typeof StateAnimationMetaSchema>;
|
|
181
|
+
/** True iff a validated meta declares a single clip rather than a blend tree. */
|
|
182
|
+
export declare function isClipAnimationMeta(meta: StateAnimationMeta): meta is ClipAnimationMeta;
|
|
183
|
+
/** True iff a validated meta declares a blend tree rather than a single clip. */
|
|
184
|
+
export declare function isBlendTreeAnimationMeta(meta: StateAnimationMeta): meta is BlendTreeAnimationMeta;
|
|
185
|
+
/** Thrown by `parseStateAnimationMeta` — always names the offending state id. */
|
|
186
|
+
export declare class AnimationMetaValidationError extends Error {
|
|
187
|
+
readonly stateId: string;
|
|
188
|
+
readonly issues: z.ZodIssue[];
|
|
189
|
+
constructor(message: string, stateId: string, issues: z.ZodIssue[]);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Validate one state's `meta.animation` value. Called by the E2 binding for
|
|
193
|
+
* every state a machine declares (both at bind time, up front, and — for
|
|
194
|
+
* belt-and-suspenders — again whenever a state is entered).
|
|
195
|
+
*
|
|
196
|
+
* @throws {AnimationMetaValidationError} naming the state id and every Zod
|
|
197
|
+
* issue (path + message) — e.g. an unrecognized `on`/`target` key, a
|
|
198
|
+
* missing `clip`, or a 1D blend tree with only one child.
|
|
199
|
+
*/
|
|
200
|
+
export declare function parseStateAnimationMeta(stateId: string, raw: unknown): StateAnimationMeta;
|
|
201
|
+
/** The minimal shape of an XState `StateNode` this module needs to walk. */
|
|
202
|
+
export interface AnimationMetaStateNodeLike {
|
|
203
|
+
id: string;
|
|
204
|
+
meta?: {
|
|
205
|
+
animation?: unknown;
|
|
206
|
+
} & Record<string, unknown>;
|
|
207
|
+
states?: Record<string, AnimationMetaStateNodeLike>;
|
|
208
|
+
}
|
|
209
|
+
export interface MachineAnimationMetaEntry {
|
|
210
|
+
stateId: string;
|
|
211
|
+
meta: StateAnimationMeta;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Walk every state node in a machine (from its root `StateNode`, e.g.
|
|
215
|
+
* `actor.logic.root`) and validate every `meta.animation` value found.
|
|
216
|
+
* States with no `meta.animation` are skipped (not every XState state needs
|
|
217
|
+
* to drive animation). Returns one entry per animated state, in document
|
|
218
|
+
* order.
|
|
219
|
+
*
|
|
220
|
+
* @throws {AnimationMetaValidationError} on the FIRST invalid meta found —
|
|
221
|
+
* naming the specific state id, so an agent authoring a machine gets an
|
|
222
|
+
* actionable pointer straight to the bad state instead of a generic error.
|
|
223
|
+
*/
|
|
224
|
+
export declare function collectMachineAnimationMeta(root: AnimationMetaStateNodeLike): MachineAnimationMetaEntry[];
|
|
225
|
+
/** Every clip name referenced anywhere in a validated meta (1 for clip states, N for blend trees). */
|
|
226
|
+
export declare function clipNamesOf(meta: StateAnimationMeta): string[];
|
|
227
|
+
export {};
|
|
228
|
+
//# sourceMappingURL=xstate-animation-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xstate-animation-meta.d.ts","sourceRoot":"","sources":["../../src/animation/xstate-animation-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAMH,QAAA,MAAM,yBAAyB;;;;;kBAcpB,CAAC;AAEZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAwC5E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAInC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM1E,QAAA,MAAM,4BAA4B;;;kBAmBkC,CAAC;AAErE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAMlF,QAAA,MAAM,uBAAuB;;;;;;;;kBAgBlB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAOvB,CAAC;AAEZ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAGnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,IAAI,iBAAiB,CAEvF;AAED,iFAAiF;AACjF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,IAAI,sBAAsB,CAEjG;AAMD,iFAAiF;AACjF,qBAAa,4BAA6B,SAAQ,KAAK;IAGnD,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;gBAF7B,OAAO,EAAE,MAAM,EACN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAKhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAazF;AAMD,4EAA4E;AAC5E,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,0BAA0B,GAC/B,yBAAyB,EAAE,CAU7B;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAE9D"}
|