@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,221 @@
|
|
|
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
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Blend tree children
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
const AnimationBlendChildSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
clip: z.string().min(1).describe('Animation clip name this child plays'),
|
|
48
|
+
threshold: z.number().describe('1D/2D blend position on the primary parameter axis'),
|
|
49
|
+
thresholdY: z
|
|
50
|
+
.number()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe('2D blend position on the secondary parameter axis (2D blend trees only)'),
|
|
53
|
+
weight: z
|
|
54
|
+
.number()
|
|
55
|
+
.min(0)
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('Explicit weight for "direct" blend trees (ignored by 1D/2D)'),
|
|
58
|
+
})
|
|
59
|
+
.strict();
|
|
60
|
+
const AnimationBlendTree1DSchema = z
|
|
61
|
+
.object({
|
|
62
|
+
type: z.literal('1D').describe('Interpolates linearly between sorted children by threshold'),
|
|
63
|
+
parameter: z.string().min(1).describe('Context/selector value driving the blend'),
|
|
64
|
+
children: z
|
|
65
|
+
.array(AnimationBlendChildSchema)
|
|
66
|
+
.min(2, '1D blend tree needs at least 2 children to interpolate between'),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
const AnimationBlendTree2DSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
type: z
|
|
72
|
+
.literal('2D')
|
|
73
|
+
.describe('Inverse-distance-weights children by (parameter, parameterY) position'),
|
|
74
|
+
parameter: z.string().min(1).describe('Primary axis context/selector value'),
|
|
75
|
+
parameterY: z.string().min(1).describe('Secondary axis context/selector value'),
|
|
76
|
+
children: z
|
|
77
|
+
.array(AnimationBlendChildSchema.extend({ thresholdY: z.number() }))
|
|
78
|
+
.min(1, '2D blend tree needs at least 1 child'),
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
81
|
+
const AnimationBlendTreeDirectSchema = z
|
|
82
|
+
.object({
|
|
83
|
+
type: z.literal('direct').describe('Each child has an explicit weight, normalized to sum to 1'),
|
|
84
|
+
// `parameter` is unused by direct blending (evaluateBlendTree never reads
|
|
85
|
+
// it for `type: 'direct'`) but kept required+defaulted so the parsed
|
|
86
|
+
// value stays structurally assignable to `BlendTreeDef`
|
|
87
|
+
// (`anim-graph-types.ts`), which declares `parameter: string` for every
|
|
88
|
+
// blend mode — the same convention that type already uses.
|
|
89
|
+
parameter: z.string().default(''),
|
|
90
|
+
children: z
|
|
91
|
+
.array(AnimationBlendChildSchema.extend({ weight: z.number().min(0) }))
|
|
92
|
+
.min(1, 'direct blend tree needs at least 1 child'),
|
|
93
|
+
})
|
|
94
|
+
.strict();
|
|
95
|
+
export const AnimationBlendTreeSchema = z.discriminatedUnion('type', [
|
|
96
|
+
AnimationBlendTree1DSchema,
|
|
97
|
+
AnimationBlendTree2DSchema,
|
|
98
|
+
AnimationBlendTreeDirectSchema,
|
|
99
|
+
]);
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Crossfade / blend-in-out metadata (shared by clip and blend-tree states)
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
const AnimationCrossfadeMetaSchema = z
|
|
104
|
+
.object({
|
|
105
|
+
duration: z
|
|
106
|
+
.number()
|
|
107
|
+
.min(0)
|
|
108
|
+
.default(0)
|
|
109
|
+
.describe('Seconds to blend from the previously active clip into this state on entry, applied via ' +
|
|
110
|
+
'native `AnimationAction.crossFadeTo`/`fadeIn` (E2). 0 = instant activation, no fade.'),
|
|
111
|
+
warp: z
|
|
112
|
+
.boolean()
|
|
113
|
+
.default(false)
|
|
114
|
+
.describe("Passed through to AnimationAction.crossFadeTo's `warp` param — linearly warps timeScale " +
|
|
115
|
+
'across the two clips during the blend so differing clip lengths line up. Default false.'),
|
|
116
|
+
})
|
|
117
|
+
.strict()
|
|
118
|
+
.describe('Blend-in/out/crossfade timing for entering this state');
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Per-state animation metadata: single clip OR blend tree, plus crossfade
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
const ClipAnimationMetaSchema = z
|
|
123
|
+
.object({
|
|
124
|
+
clip: z.string().min(1).describe('Single clip to play while this XState state is active'),
|
|
125
|
+
loop: z
|
|
126
|
+
.boolean()
|
|
127
|
+
.default(true)
|
|
128
|
+
.describe('Loop the clip (THREE.LoopRepeat) vs play once (THREE.LoopOnce, clamped on last frame)'),
|
|
129
|
+
speed: z
|
|
130
|
+
.number()
|
|
131
|
+
.positive()
|
|
132
|
+
.default(1)
|
|
133
|
+
.describe('Playback speed multiplier (AnimationAction.timeScale)'),
|
|
134
|
+
crossfade: AnimationCrossfadeMetaSchema.optional(),
|
|
135
|
+
})
|
|
136
|
+
.strict();
|
|
137
|
+
const BlendTreeAnimationMetaSchema = z
|
|
138
|
+
.object({
|
|
139
|
+
blendTree: AnimationBlendTreeSchema.describe('Multiple clips blended by a live context/selector-driven parameter'),
|
|
140
|
+
crossfade: AnimationCrossfadeMetaSchema.optional(),
|
|
141
|
+
})
|
|
142
|
+
.strict();
|
|
143
|
+
/**
|
|
144
|
+
* The full shape of `state.meta.animation` for one XState state (spec §5.6):
|
|
145
|
+
* exactly one of a single clip or a blend tree, plus optional crossfade
|
|
146
|
+
* timing. `.strict()` on both branches is what makes authoring a transition
|
|
147
|
+
* keyword (`on`, `target`, `guard`, …) inside `meta.animation` a validation
|
|
148
|
+
* error instead of a silently-accepted second transition dialect.
|
|
149
|
+
*/
|
|
150
|
+
export const StateAnimationMetaSchema = z.union([
|
|
151
|
+
ClipAnimationMetaSchema,
|
|
152
|
+
BlendTreeAnimationMetaSchema,
|
|
153
|
+
]);
|
|
154
|
+
/** True iff a validated meta declares a single clip rather than a blend tree. */
|
|
155
|
+
export function isClipAnimationMeta(meta) {
|
|
156
|
+
return 'clip' in meta;
|
|
157
|
+
}
|
|
158
|
+
/** True iff a validated meta declares a blend tree rather than a single clip. */
|
|
159
|
+
export function isBlendTreeAnimationMeta(meta) {
|
|
160
|
+
return 'blendTree' in meta;
|
|
161
|
+
}
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// Validation entry point
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
/** Thrown by `parseStateAnimationMeta` — always names the offending state id. */
|
|
166
|
+
export class AnimationMetaValidationError extends Error {
|
|
167
|
+
stateId;
|
|
168
|
+
issues;
|
|
169
|
+
constructor(message, stateId, issues) {
|
|
170
|
+
super(message);
|
|
171
|
+
this.stateId = stateId;
|
|
172
|
+
this.issues = issues;
|
|
173
|
+
this.name = 'AnimationMetaValidationError';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Validate one state's `meta.animation` value. Called by the E2 binding for
|
|
178
|
+
* every state a machine declares (both at bind time, up front, and — for
|
|
179
|
+
* belt-and-suspenders — again whenever a state is entered).
|
|
180
|
+
*
|
|
181
|
+
* @throws {AnimationMetaValidationError} naming the state id and every Zod
|
|
182
|
+
* issue (path + message) — e.g. an unrecognized `on`/`target` key, a
|
|
183
|
+
* missing `clip`, or a 1D blend tree with only one child.
|
|
184
|
+
*/
|
|
185
|
+
export function parseStateAnimationMeta(stateId, raw) {
|
|
186
|
+
const result = StateAnimationMetaSchema.safeParse(raw);
|
|
187
|
+
if (!result.success) {
|
|
188
|
+
const detail = result.error.issues
|
|
189
|
+
.map((issue) => `${issue.path.length ? issue.path.join('.') : '(root)'}: ${issue.message}`)
|
|
190
|
+
.join('; ');
|
|
191
|
+
throw new AnimationMetaValidationError(`[xstate-animation] invalid meta.animation for state "${stateId}": ${detail}`, stateId, result.error.issues);
|
|
192
|
+
}
|
|
193
|
+
return result.data;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Walk every state node in a machine (from its root `StateNode`, e.g.
|
|
197
|
+
* `actor.logic.root`) and validate every `meta.animation` value found.
|
|
198
|
+
* States with no `meta.animation` are skipped (not every XState state needs
|
|
199
|
+
* to drive animation). Returns one entry per animated state, in document
|
|
200
|
+
* order.
|
|
201
|
+
*
|
|
202
|
+
* @throws {AnimationMetaValidationError} on the FIRST invalid meta found —
|
|
203
|
+
* naming the specific state id, so an agent authoring a machine gets an
|
|
204
|
+
* actionable pointer straight to the bad state instead of a generic error.
|
|
205
|
+
*/
|
|
206
|
+
export function collectMachineAnimationMeta(root) {
|
|
207
|
+
const out = [];
|
|
208
|
+
const visit = (node) => {
|
|
209
|
+
if (node.meta && 'animation' in node.meta && node.meta.animation !== undefined) {
|
|
210
|
+
out.push({ stateId: node.id, meta: parseStateAnimationMeta(node.id, node.meta.animation) });
|
|
211
|
+
}
|
|
212
|
+
for (const child of Object.values(node.states ?? {}))
|
|
213
|
+
visit(child);
|
|
214
|
+
};
|
|
215
|
+
visit(root);
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
/** Every clip name referenced anywhere in a validated meta (1 for clip states, N for blend trees). */
|
|
219
|
+
export function clipNamesOf(meta) {
|
|
220
|
+
return isClipAnimationMeta(meta) ? [meta.clip] : meta.blendTree.children.map((c) => c.clip);
|
|
221
|
+
}
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared asset cache — URL-keyed, deduplicating loader for GLTF and JSON.
|
|
3
|
+
*
|
|
4
|
+
* Inspired by Unity's Resources.Load / Godot's load():
|
|
5
|
+
* assets.load<T>(url) — async, returns Promise<T>, deduplicates concurrent loads
|
|
6
|
+
* assets.get<T>(url) — sync, returns T, throws if not yet loaded
|
|
7
|
+
*
|
|
8
|
+
* GLTF files (.glb/.gltf) resolve to GLTFResult.
|
|
9
|
+
* JSON files resolve to the parsed object (caller provides type via generic).
|
|
10
|
+
*
|
|
11
|
+
* Cache lives for the app lifetime — no dispose needed.
|
|
12
|
+
*/
|
|
13
|
+
import type * as THREE from 'three';
|
|
14
|
+
/** Result of loading a .glb/.gltf file. */
|
|
15
|
+
export interface GLTFResult {
|
|
16
|
+
scene: THREE.Group;
|
|
17
|
+
animations: THREE.AnimationClip[];
|
|
18
|
+
}
|
|
19
|
+
export interface AssetCache {
|
|
20
|
+
/** Load an asset by URL. Returns a cached promise if already loading/loaded. */
|
|
21
|
+
load<T = unknown>(url: string): Promise<T>;
|
|
22
|
+
/** Get a previously-loaded asset synchronously. Throws if not yet loaded. */
|
|
23
|
+
get<T = unknown>(url: string): T;
|
|
24
|
+
}
|
|
25
|
+
export declare function createAssetCache(): AssetCache;
|
|
26
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAGpC,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;IACnB,UAAU,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,gFAAgF;IAChF,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE3C,6EAA6E;IAC7E,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;CAClC;AAED,wBAAgB,gBAAgB,IAAI,UAAU,CAiD7C"}
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared asset cache — URL-keyed, deduplicating loader for GLTF and JSON.
|
|
3
|
+
*
|
|
4
|
+
* Inspired by Unity's Resources.Load / Godot's load():
|
|
5
|
+
* assets.load<T>(url) — async, returns Promise<T>, deduplicates concurrent loads
|
|
6
|
+
* assets.get<T>(url) — sync, returns T, throws if not yet loaded
|
|
7
|
+
*
|
|
8
|
+
* GLTF files (.glb/.gltf) resolve to GLTFResult.
|
|
9
|
+
* JSON files resolve to the parsed object (caller provides type via generic).
|
|
10
|
+
*
|
|
11
|
+
* Cache lives for the app lifetime — no dispose needed.
|
|
12
|
+
*/
|
|
13
|
+
import { gltfLoader, resolveUrl } from './loader';
|
|
14
|
+
export function createAssetCache() {
|
|
15
|
+
const cache = new Map();
|
|
16
|
+
const resolved = new Map();
|
|
17
|
+
// Use the shared, DRACO-wired GLTFLoader (A2 / CB2) — no second loader instance.
|
|
18
|
+
// This cache keeps the parsed source GLTFResult (load/get semantics for gameplay
|
|
19
|
+
// code); it does NOT clone. Callers that need disposal-safe clones use
|
|
20
|
+
// scene/asset-loaders `loadGLTF`, which clones + tags `__sharedGeometry`.
|
|
21
|
+
function load(url) {
|
|
22
|
+
const existing = cache.get(url);
|
|
23
|
+
if (existing)
|
|
24
|
+
return existing;
|
|
25
|
+
let promise;
|
|
26
|
+
if (url.endsWith('.glb') || url.endsWith('.gltf')) {
|
|
27
|
+
promise = new Promise((resolve, reject) => {
|
|
28
|
+
gltfLoader.load(url, (gltf) => resolve({ scene: gltf.scene, animations: gltf.animations }), undefined, reject);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else if (url.endsWith('.json')) {
|
|
32
|
+
promise = fetch(resolveUrl(url)).then((r) => {
|
|
33
|
+
if (!r.ok)
|
|
34
|
+
throw new Error(`Failed to fetch ${url}: ${r.status}`);
|
|
35
|
+
return r.json();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new Error(`AssetCache: unsupported file type for "${url}"`);
|
|
40
|
+
}
|
|
41
|
+
const tracked = promise.then((value) => {
|
|
42
|
+
resolved.set(url, value);
|
|
43
|
+
return value;
|
|
44
|
+
});
|
|
45
|
+
cache.set(url, tracked);
|
|
46
|
+
return tracked;
|
|
47
|
+
}
|
|
48
|
+
function get(url) {
|
|
49
|
+
if (!resolved.has(url)) {
|
|
50
|
+
throw new Error(`AssetCache: "${url}" not loaded. Call load() first and await it.`);
|
|
51
|
+
}
|
|
52
|
+
return resolved.get(url);
|
|
53
|
+
}
|
|
54
|
+
return { load, get };
|
|
55
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { bindClockToTone, type ToneClockBinding, type ToneClockBindingOptions, type ToneTransportLike, } from './tone-clock-binding';
|
|
2
|
+
export { bridgeToneToThreeAudio, connectToneBusToMasterGain, resumeSharedAudio, type ToneAudioBridge, } from './tone-context';
|
|
3
|
+
export { renderToneOffline, type ToneOfflineComposeFn, type ToneOfflineRenderRequest, type ToneOfflineRenderResult, } from './tone-offline-render';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audio/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Engine-core audio surface (spec §13 workstream G).
|
|
2
|
+
//
|
|
3
|
+
// G3 ("Replace or Relocate Procedural Audio Helpers") removed the former
|
|
4
|
+
// `musical.ts`/`weapons.ts`/`impacts.ts`/`vehicle.ts`/`ambient.ts`/
|
|
5
|
+
// `movement.ts`/`ui-sounds.ts` — raw-`AudioContext`/`Math.random`-driven
|
|
6
|
+
// oscillator and noise-buffer SFX generators that were engine-owned but
|
|
7
|
+
// non-spatial (they never touched `THREE.PositionalAudio`, so the "spatial
|
|
8
|
+
// one-shot helper" exception in the G3 acceptance criteria does not apply to
|
|
9
|
+
// them). Each was either relocated verbatim into the example project that
|
|
10
|
+
// used it (`examples/{third-person,fps,third-person-arena,rts,vehicle}/src/
|
|
11
|
+
// procedural-audio.ts`) or deleted as dead code with no shipped consumer
|
|
12
|
+
// (`bassPulse`/`arpeggio`/`gunshot`/`laser`/`bounce`/`crash`/`explosion`/
|
|
13
|
+
// `tireSkid`/`wind`/`rain`/`hum`/`nature`/`uiHover`/`uiError`). The canonical
|
|
14
|
+
// replacements — a procedural-music example built directly on Tone's own API
|
|
15
|
+
// and a spatial-audio example built directly on `THREE.PositionalAudio` — are
|
|
16
|
+
// `examples/audio-showcase`.
|
|
17
|
+
//
|
|
18
|
+
// What remains here is the genuine engine-core audio capability: the G1/G2
|
|
19
|
+
// Tone↔Three context bridge and offline render (`wav-encode.ts`, the G4
|
|
20
|
+
// PCM->WAV encoder, is consumed by its own module path, not this barrel — see
|
|
21
|
+
// `packages/engine/src/runtime/render-audio-control.ts`).
|
|
22
|
+
export { bindClockToTone, } from './tone-clock-binding';
|
|
23
|
+
export { bridgeToneToThreeAudio, connectToneBusToMasterGain, resumeSharedAudio, } from './tone-context';
|
|
24
|
+
export { renderToneOffline, } from './tone-offline-render';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { AnimationClock } from '../animation/animation-clock';
|
|
2
|
+
import type { SystemPhaseName } from '../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* G2 — Integrate Tone with the Canonical Clock, preview/real-time half
|
|
5
|
+
* (spec §13 G2, §10 D1). Mirrors `animation/theatre-clock-binding.ts`'s D2
|
|
6
|
+
* pattern exactly, on purpose: the canonical `AnimationClock` is the single
|
|
7
|
+
* source of truth for "what time is it", and every participating system
|
|
8
|
+
* (Theatre's sequence position, a registered GSAP timeline, and — here — a
|
|
9
|
+
* Tone transport) is seeked to match it on every clock crossing. Tone must
|
|
10
|
+
* never be left to free-run its own real-time clock while participating in
|
|
11
|
+
* a cinematic, for the exact same reason Theatre isn't: deterministic
|
|
12
|
+
* export, offline scrubbing, and no wall-clock dependency
|
|
13
|
+
* (`animation-clock.ts`'s module doc explains why in full).
|
|
14
|
+
*
|
|
15
|
+
* ## Why setting `transport.seconds` is enough
|
|
16
|
+
*
|
|
17
|
+
* Setting `Tone.getTransport().seconds` repositions the transport's
|
|
18
|
+
* playhead synchronously; it does not itself start real-time ticking (that
|
|
19
|
+
* still requires an explicit `transport.start()`, which this binding
|
|
20
|
+
* deliberately never calls — see the module doc on `animation-clock.ts` for
|
|
21
|
+
* why nothing in this codebase is allowed to drive its own
|
|
22
|
+
* `requestAnimationFrame`/wall-clock loop). A clock-seeked Tone transport is
|
|
23
|
+
* a pure function of `clock.time`, exactly like a Theatre sequence's
|
|
24
|
+
* `position` setter.
|
|
25
|
+
*
|
|
26
|
+
* ## Structural (not nominal) transport typing
|
|
27
|
+
*
|
|
28
|
+
* `ToneTransportLike` intentionally types only the ONE property this
|
|
29
|
+
* binding touches (`seconds`), the same narrowing discipline
|
|
30
|
+
* `runtime/render-control.ts`'s `SeekableClock` uses for the canonical
|
|
31
|
+
* clock. `Tone.getTransport()`'s real `TransportClass` satisfies this
|
|
32
|
+
* structurally with no adapter — pass it directly at the real call site.
|
|
33
|
+
* The narrow type is also what makes this binding's own unit tests real
|
|
34
|
+
* (not mocked-away): `packages/engine/test/audio/tone-clock-binding.test.ts`
|
|
35
|
+
* exercises the FULL seek/pause/loop/time-scale matrix against a real
|
|
36
|
+
* `AnimationClock` and a plain `{ seconds: number }` object — no Tone
|
|
37
|
+
* import, no `AudioContext`, and it still proves the exact behavior a real
|
|
38
|
+
* `Tone.Transport` will see, because `TransportClass` IS a
|
|
39
|
+
* `ToneTransportLike` at the type level.
|
|
40
|
+
*/
|
|
41
|
+
export interface ToneTransportLike {
|
|
42
|
+
seconds: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ToneClockBindingOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Which `AnimationClock` phase to seek the transport in. Defaults to
|
|
47
|
+
* `'animation'` — the same phase `theatre-clock-binding.ts` uses by
|
|
48
|
+
* default, so a Theatre sequence and a Tone transport bound to the same
|
|
49
|
+
* clock stay in lockstep with each other (`PHASE_ORDER`-then-registration-
|
|
50
|
+
* order — see `animation-clock.ts`'s `subscribe` doc comment).
|
|
51
|
+
*/
|
|
52
|
+
phase?: SystemPhaseName;
|
|
53
|
+
}
|
|
54
|
+
export interface ToneClockBinding {
|
|
55
|
+
/** Removes the clock evaluator. No further `transport.seconds` writes
|
|
56
|
+
* occur after this — the transport is left at whatever position it was
|
|
57
|
+
* last seeked to (matches `TheatreClockBinding.dispose`'s contract). */
|
|
58
|
+
dispose(): void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Subscribe `transport.seconds = clock.time` to every crossing of `clock`
|
|
62
|
+
* in the given phase (default `'animation'`). Returns a disposer; call it
|
|
63
|
+
* to stop driving the transport (e.g. on `GameCleanup.dispose()`, or before
|
|
64
|
+
* rebinding on hot reload — this is what keeps HMR from accumulating
|
|
65
|
+
* duplicate listeners).
|
|
66
|
+
*
|
|
67
|
+
* Only call this for a Tone composition that PARTICIPATES in a cinematic
|
|
68
|
+
* (spec G2 AC). Ordinary, non-cinematic game music should drive Tone's own
|
|
69
|
+
* real-time transport directly (`transport.start()`, `Tone.Transport.bpm`,
|
|
70
|
+
* etc. — see `tone-context.ts`'s "escape hatch" section) and must NEVER be
|
|
71
|
+
* bound here, since a bound transport's position is entirely clock-driven
|
|
72
|
+
* and `start()`/`stop()` calls on it would fight this binding's writes.
|
|
73
|
+
*/
|
|
74
|
+
export declare function bindClockToTone(clock: AnimationClock, transport: ToneTransportLike, options?: ToneClockBindingOptions): ToneClockBinding;
|
|
75
|
+
//# sourceMappingURL=tone-clock-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-clock-binding.d.ts","sourceRoot":"","sources":["../../src/audio/tone-clock-binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,8BAA8B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;6EAEyE;IACzE,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAelB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscribe `transport.seconds = clock.time` to every crossing of `clock`
|
|
3
|
+
* in the given phase (default `'animation'`). Returns a disposer; call it
|
|
4
|
+
* to stop driving the transport (e.g. on `GameCleanup.dispose()`, or before
|
|
5
|
+
* rebinding on hot reload — this is what keeps HMR from accumulating
|
|
6
|
+
* duplicate listeners).
|
|
7
|
+
*
|
|
8
|
+
* Only call this for a Tone composition that PARTICIPATES in a cinematic
|
|
9
|
+
* (spec G2 AC). Ordinary, non-cinematic game music should drive Tone's own
|
|
10
|
+
* real-time transport directly (`transport.start()`, `Tone.Transport.bpm`,
|
|
11
|
+
* etc. — see `tone-context.ts`'s "escape hatch" section) and must NEVER be
|
|
12
|
+
* bound here, since a bound transport's position is entirely clock-driven
|
|
13
|
+
* and `start()`/`stop()` calls on it would fight this binding's writes.
|
|
14
|
+
*/
|
|
15
|
+
export function bindClockToTone(clock, transport, options = {}) {
|
|
16
|
+
const phase = options.phase ?? 'animation';
|
|
17
|
+
const handle = clock.subscribe(phase, (crossing) => {
|
|
18
|
+
transport.seconds = crossing.currentTime;
|
|
19
|
+
});
|
|
20
|
+
let disposed = false;
|
|
21
|
+
return {
|
|
22
|
+
dispose() {
|
|
23
|
+
if (disposed)
|
|
24
|
+
return;
|
|
25
|
+
disposed = true;
|
|
26
|
+
handle.dispose();
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ToneAudioNode } from 'tone';
|
|
2
|
+
/**
|
|
3
|
+
* G1 — Establish Audio Ownership (spec §13 G1, §3.6, §4).
|
|
4
|
+
*
|
|
5
|
+
* ## The boundary
|
|
6
|
+
*
|
|
7
|
+
* Two independent, native-vocabulary audio systems coexist in every VGAI
|
|
8
|
+
* game, each with a genuinely different job. This module does not wrap
|
|
9
|
+
* either one — it only decides who owns which native `AudioContext` and how
|
|
10
|
+
* the two graphs meet:
|
|
11
|
+
*
|
|
12
|
+
* - **Three/Web Audio** (`setup/setup-audio.ts`) remains authoritative for
|
|
13
|
+
* SPATIAL audio: `THREE.AudioListener` (attached to the active camera)
|
|
14
|
+
* and `THREE.Audio`/`THREE.PositionalAudio` sources. (G3, a later unit,
|
|
15
|
+
* has since removed the non-spatial engine-owned one-shot procedural
|
|
16
|
+
* helpers this comment used to name here — `audio/impacts.ts`,
|
|
17
|
+
* `audio/weapons.ts`, `audio/ambient.ts`, and their siblings — relocating
|
|
18
|
+
* each into the example project that used it, or deleting it as dead code;
|
|
19
|
+
* see `packages/engine/src/audio/index.ts`'s header comment and
|
|
20
|
+
* `examples/audio-showcase` for the canonical native-Tone/native-Three
|
|
21
|
+
* replacements. This module's own boundary/bridge is unchanged by that
|
|
22
|
+
* unit.)
|
|
23
|
+
* - **Tone.js** owns musical transport, tempo, scheduling, synthesis, and
|
|
24
|
+
* procedural composition — imported and used with its OWN native API
|
|
25
|
+
* (`new Tone.Synth()`, `Tone.getTransport()`, `Tone.Offline(...)`,
|
|
26
|
+
* `Tone.getContext()`), never through a VGAI-renamed wrapper (spec §1's
|
|
27
|
+
* native-library rule). See `packages/engine/test/audio/tone-context.test.ts`
|
|
28
|
+
* for a direct, unwrapped usage example.
|
|
29
|
+
*
|
|
30
|
+
* ## Why they must share one native `AudioContext`
|
|
31
|
+
*
|
|
32
|
+
* Both systems ultimately talk to exactly one hardware output. If Tone ran
|
|
33
|
+
* its own independently-created `AudioContext` alongside
|
|
34
|
+
* `THREE.AudioListener`'s, they would: fight over autoplay-policy resume
|
|
35
|
+
* state (two contexts, two `state`s, two places a "click to start audio"
|
|
36
|
+
* gesture would need to unlock); produce TWO separate graphs that a single
|
|
37
|
+
* mute/volume control cannot coherently silence; and — fatally for G4/I6 —
|
|
38
|
+
* make deterministic offline capture impossible to align with the video's
|
|
39
|
+
* frame-addressed render range, since there would be no single graph whose
|
|
40
|
+
* lifecycle (suspend/resume/close) the render/capture harness can reason
|
|
41
|
+
* about.
|
|
42
|
+
*
|
|
43
|
+
* `bridgeToneToThreeAudio` fixes this: it points Tone's global context
|
|
44
|
+
* (`Tone.setContext`) at the SAME native `AudioContext` instance
|
|
45
|
+
* `THREE.AudioListener` already created (`setupAudio(camera).listener.context`,
|
|
46
|
+
* `setup/setup-audio.ts`). After bridging,
|
|
47
|
+
* `Tone.getContext().rawContext === threeListener.context` — there is
|
|
48
|
+
* exactly one native context. One `.resume()`/`.suspend()` call (or
|
|
49
|
+
* `Tone.start()`, which does both) affects both systems, and routing a Tone
|
|
50
|
+
* bus into `setupAudio()`'s `masterGain` (see `connectToneBusToMasterGain`
|
|
51
|
+
* below) puts Tone's output under the SAME mute/master-volume control as
|
|
52
|
+
* every `THREE.Audio` source.
|
|
53
|
+
*
|
|
54
|
+
* ## What this module does NOT do
|
|
55
|
+
*
|
|
56
|
+
* It does not create an `AudioContext` (that remains `setupAudio`'s job —
|
|
57
|
+
* call `bridgeToneToThreeAudio` AFTER `setupAudio(camera)`, before
|
|
58
|
+
* constructing any Tone node: Tone nodes built against the PREVIOUS global
|
|
59
|
+
* context are not retroactively migrated — Tone's own `setContext` contract,
|
|
60
|
+
* not a VGAI limitation). It does not wrap any Tone class, and it does not
|
|
61
|
+
* touch THREE's audio path at all. G3 (a later unit) is where engine-owned
|
|
62
|
+
* procedural helpers get rewritten directly on Tone or relocated to game
|
|
63
|
+
* code — this module only owns the context boundary + bridge.
|
|
64
|
+
*
|
|
65
|
+
* ## Escape hatch — ordinary (non-cinematic) game music
|
|
66
|
+
*
|
|
67
|
+
* None of the above requires participating in a cinematic. Once bridged,
|
|
68
|
+
* ordinary game music can drive Tone's REAL real-time transport exactly as
|
|
69
|
+
* Tone's own docs describe — `Tone.getTransport().bpm.value = 128`,
|
|
70
|
+
* `Tone.getTransport().start()`, `new Tone.Sequence(...).start(0)`, etc. —
|
|
71
|
+
* with no VGAI involvement at all. `tone-clock-binding.ts` (G2) is opt-in,
|
|
72
|
+
* only for the case where a Tone composition must stay in lockstep with the
|
|
73
|
+
* canonical `AnimationClock` because it participates in a cinematic.
|
|
74
|
+
*/
|
|
75
|
+
/** Result of {@link bridgeToneToThreeAudio} — the shared native context plus
|
|
76
|
+
* a re-checkable assertion, so a caller/test doesn't need to re-derive the
|
|
77
|
+
* bridging logic to confirm it still holds later. */
|
|
78
|
+
export interface ToneAudioBridge {
|
|
79
|
+
/** The native `AudioContext` Tone and `THREE.AudioListener` now share. */
|
|
80
|
+
readonly context: AudioContext;
|
|
81
|
+
/** True iff `Tone.getContext().rawContext` is still exactly `context`
|
|
82
|
+
* (identity, not equality — proves ONE shared native context, not two
|
|
83
|
+
* compatible-looking ones). */
|
|
84
|
+
isBridged(): boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Point Tone's global context at `context` (typically
|
|
88
|
+
* `setupAudio(camera).listener.context` from `setup/setup-audio.ts`). Call
|
|
89
|
+
* this once per game boot, after `setupAudio(camera)`, before constructing
|
|
90
|
+
* any Tone node.
|
|
91
|
+
*/
|
|
92
|
+
export declare function bridgeToneToThreeAudio(context: AudioContext): ToneAudioBridge;
|
|
93
|
+
/**
|
|
94
|
+
* Route a Tone output node (a bus, `Tone.getDestination()`, or any
|
|
95
|
+
* `Tone.Gain` used as a submix) into the SAME `masterGain`
|
|
96
|
+
* `setupAudio()` created, so Tone output is silenced/attenuated by the
|
|
97
|
+
* identical mute/volume control as every `THREE.Audio`/`THREE.PositionalAudio`
|
|
98
|
+
* source. `toneNode` is Tone's own `ToneAudioNode` type (no VGAI wrapper);
|
|
99
|
+
* `masterGain` is the plain native `GainNode` `setupAudio()` already
|
|
100
|
+
* returns — Tone's `.connect()` natively accepts a raw `AudioNode` as its
|
|
101
|
+
* destination, so no adapter node is needed on either side.
|
|
102
|
+
*/
|
|
103
|
+
export declare function connectToneBusToMasterGain(toneNode: ToneAudioNode, masterGain: GainNode): void;
|
|
104
|
+
/**
|
|
105
|
+
* Resume the shared context after a user gesture. Because
|
|
106
|
+
* {@link bridgeToneToThreeAudio} guarantees Tone and THREE share the
|
|
107
|
+
* identical native context, calling `Tone.start()` — which both resumes the
|
|
108
|
+
* context AND runs Tone's own autoplay-unlock bookkeeping (a silent-buffer
|
|
109
|
+
* trick required on some browsers) — is sufficient to unstick BOTH systems;
|
|
110
|
+
* a separate `context.resume()` call on the THREE side is redundant once
|
|
111
|
+
* bridged, not required.
|
|
112
|
+
*/
|
|
113
|
+
export declare function resumeSharedAudio(): Promise<void>;
|
|
114
|
+
//# sourceMappingURL=tone-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tone-context.d.ts","sourceRoot":"","sources":["../../src/audio/tone-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH;;sDAEsD;AACtD,MAAM,WAAW,eAAe;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B;;oCAEgC;IAChC,SAAS,IAAI,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,CAM7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,GAAG,IAAI,CAE9F;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as Tone from 'tone';
|
|
2
|
+
/**
|
|
3
|
+
* Point Tone's global context at `context` (typically
|
|
4
|
+
* `setupAudio(camera).listener.context` from `setup/setup-audio.ts`). Call
|
|
5
|
+
* this once per game boot, after `setupAudio(camera)`, before constructing
|
|
6
|
+
* any Tone node.
|
|
7
|
+
*/
|
|
8
|
+
export function bridgeToneToThreeAudio(context) {
|
|
9
|
+
Tone.setContext(context);
|
|
10
|
+
return {
|
|
11
|
+
context,
|
|
12
|
+
isBridged: () => Tone.getContext().rawContext === context,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Route a Tone output node (a bus, `Tone.getDestination()`, or any
|
|
17
|
+
* `Tone.Gain` used as a submix) into the SAME `masterGain`
|
|
18
|
+
* `setupAudio()` created, so Tone output is silenced/attenuated by the
|
|
19
|
+
* identical mute/volume control as every `THREE.Audio`/`THREE.PositionalAudio`
|
|
20
|
+
* source. `toneNode` is Tone's own `ToneAudioNode` type (no VGAI wrapper);
|
|
21
|
+
* `masterGain` is the plain native `GainNode` `setupAudio()` already
|
|
22
|
+
* returns — Tone's `.connect()` natively accepts a raw `AudioNode` as its
|
|
23
|
+
* destination, so no adapter node is needed on either side.
|
|
24
|
+
*/
|
|
25
|
+
export function connectToneBusToMasterGain(toneNode, masterGain) {
|
|
26
|
+
toneNode.connect(masterGain);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resume the shared context after a user gesture. Because
|
|
30
|
+
* {@link bridgeToneToThreeAudio} guarantees Tone and THREE share the
|
|
31
|
+
* identical native context, calling `Tone.start()` — which both resumes the
|
|
32
|
+
* context AND runs Tone's own autoplay-unlock bookkeeping (a silent-buffer
|
|
33
|
+
* trick required on some browsers) — is sufficient to unstick BOTH systems;
|
|
34
|
+
* a separate `context.resume()` call on the THREE side is redundant once
|
|
35
|
+
* bridged, not required.
|
|
36
|
+
*/
|
|
37
|
+
export async function resumeSharedAudio() {
|
|
38
|
+
await Tone.start();
|
|
39
|
+
}
|