@luma.gl/engine 10.0.0-alpha.4 → 10.0.0-alpha.5
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 +9 -0
- package/dist/animation/animation-clip.cjs +36 -0
- package/dist/animation/animation-interpolation.cjs +115 -0
- package/dist/animation/animation-mixer.cjs +302 -0
- package/dist/animation/animation-track.cjs +55 -0
- package/dist/animation/animator.cjs +75 -0
- package/dist/animation/deform-positions.cjs +69 -0
- package/dist/animation/deform-positions.d.ts +13 -0
- package/dist/animation/deform-positions.d.ts.map +1 -0
- package/dist/animation/deform-positions.js +49 -0
- package/dist/animation/deform-positions.js.map +1 -0
- package/dist/animation/key-frames.cjs +81 -0
- package/dist/animation/morph-targets.cjs +162 -0
- package/dist/animation/node-animation-binding.cjs +67 -0
- package/dist/animation/node-animation-binding.d.ts +9 -0
- package/dist/animation/node-animation-binding.d.ts.map +1 -0
- package/dist/animation/node-animation-binding.js +45 -0
- package/dist/animation/node-animation-binding.js.map +1 -0
- package/dist/animation/property-animation-binding.cjs +159 -0
- package/dist/animation/property-animation-binding.d.ts +29 -0
- package/dist/animation/property-animation-binding.d.ts.map +1 -0
- package/dist/animation/property-animation-binding.js +138 -0
- package/dist/animation/property-animation-binding.js.map +1 -0
- package/dist/animation/scenegraph-animator.cjs +122 -0
- package/dist/animation/scenegraph-animator.d.ts +37 -0
- package/dist/animation/scenegraph-animator.d.ts.map +1 -0
- package/dist/animation/scenegraph-animator.js +99 -0
- package/dist/animation/scenegraph-animator.js.map +1 -0
- package/dist/animation/skin.cjs +49 -0
- package/dist/animation/texture-transform.cjs +41 -0
- package/dist/animation/texture-transform.d.ts +8 -0
- package/dist/animation/texture-transform.d.ts.map +1 -0
- package/dist/animation/texture-transform.js +17 -0
- package/dist/animation/texture-transform.js.map +1 -0
- package/dist/animation/timeline.cjs +129 -0
- package/dist/animation-loop/animation-loop-template.cjs +33 -0
- package/dist/animation-loop/animation-loop.cjs +498 -0
- package/dist/animation-loop/animation-loop.d.ts +2 -1
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +9 -3
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.cjs +15 -0
- package/dist/animation-loop/make-animation-loop.cjs +104 -0
- package/dist/animation-loop/request-animation-frame.cjs +43 -0
- package/dist/application-utils/load-file.cjs +77 -0
- package/dist/application-utils/random.cjs +38 -0
- package/dist/audio/audio-controller.cjs +429 -0
- package/dist/audio/audio-controller.d.ts +146 -0
- package/dist/audio/audio-controller.d.ts.map +1 -0
- package/dist/audio/audio-controller.js +445 -0
- package/dist/audio/audio-controller.js.map +1 -0
- package/dist/audio/audio-environment.cjs +157 -0
- package/dist/audio/audio-environment.d.ts +49 -0
- package/dist/audio/audio-environment.d.ts.map +1 -0
- package/dist/audio/audio-environment.js +148 -0
- package/dist/audio/audio-environment.js.map +1 -0
- package/dist/audio/audio-graph.cjs +182 -0
- package/dist/audio/audio-graph.d.ts +58 -0
- package/dist/audio/audio-graph.d.ts.map +1 -0
- package/dist/audio/audio-graph.js +181 -0
- package/dist/audio/audio-graph.js.map +1 -0
- package/dist/compute/buffer-transform.cjs +146 -0
- package/dist/compute/buffer-transform.d.ts +15 -5
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +56 -12
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.cjs +331 -0
- package/dist/compute/computation.d.ts +2 -4
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -14
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.cjs +132 -0
- package/dist/compute/texture-transform.cjs +142 -0
- package/dist/compute/texture-transform.d.ts +11 -7
- package/dist/compute/texture-transform.d.ts.map +1 -1
- package/dist/compute/texture-transform.js +16 -6
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/controls/orbit-controls.cjs +283 -0
- package/dist/controls/orbit-controls.d.ts +2 -0
- package/dist/controls/orbit-controls.d.ts.map +1 -1
- package/dist/controls/orbit-controls.js +2 -1
- package/dist/controls/orbit-controls.js.map +1 -1
- package/dist/debug/copy-texture-to-image.cjs +84 -0
- package/dist/debug/debug-framebuffer.cjs +113 -0
- package/dist/debug/debug-shader-layout.cjs +45 -0
- package/dist/debug/pixel-data-utils.cjs +54 -0
- package/dist/dist.dev.js +11756 -5632
- package/dist/dist.min.js +39 -35
- package/dist/dynamic-buffer/dynamic-buffer.cjs +39 -0
- package/dist/dynamic-buffer/dynamic-buffer.d.ts +1 -170
- package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -1
- package/dist/dynamic-buffer/dynamic-buffer.js +2 -312
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.cjs +27 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts +1 -114
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +2 -584
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.cjs +31 -0
- package/dist/dynamic-texture/texture-binding-source.d.ts +1 -54
- package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.js +2 -51
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
- package/dist/dynamic-texture/texture-data.cjs +53 -0
- package/dist/dynamic-texture/texture-data.d.ts +1 -145
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +2 -209
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.cjs +269 -0
- package/dist/dynamic-texture/video-texture.d.ts +1 -1
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
- package/dist/experimental/controls/comparison-splitter.cjs +231 -0
- package/dist/experimental/controls/comparison-splitter.d.ts +54 -0
- package/dist/experimental/controls/comparison-splitter.d.ts.map +1 -0
- package/dist/experimental/controls/comparison-splitter.js +215 -0
- package/dist/experimental/controls/comparison-splitter.js.map +1 -0
- package/dist/experimental/controls/flat-controller.cjs +301 -0
- package/dist/experimental/controls/flat-controller.d.ts +80 -0
- package/dist/experimental/controls/flat-controller.d.ts.map +1 -0
- package/dist/experimental/controls/flat-controller.js +295 -0
- package/dist/experimental/controls/flat-controller.js.map +1 -0
- package/dist/experimental/controls/index.cjs +35 -0
- package/dist/experimental/controls/index.cjs.map +6 -0
- package/dist/experimental/controls/index.d.ts +7 -0
- package/dist/experimental/controls/index.d.ts.map +1 -0
- package/dist/experimental/controls/index.js +7 -0
- package/dist/experimental/controls/index.js.map +1 -0
- package/dist/experimental/controls/orbit-controls.cjs +27 -0
- package/dist/experimental/controls/orbit-controls.d.ts +3 -0
- package/dist/experimental/controls/orbit-controls.d.ts.map +1 -0
- package/dist/experimental/controls/orbit-controls.js +5 -0
- package/dist/experimental/controls/orbit-controls.js.map +1 -0
- package/dist/experimental/materials/emissive-material.cjs +126 -0
- package/dist/experimental/materials/emissive-material.d.ts +38 -0
- package/dist/experimental/materials/emissive-material.d.ts.map +1 -0
- package/dist/experimental/materials/emissive-material.js +100 -0
- package/dist/experimental/materials/emissive-material.js.map +1 -0
- package/dist/experimental/materials/glass-material.cjs +570 -0
- package/dist/experimental/materials/glass-material.d.ts +107 -0
- package/dist/experimental/materials/glass-material.d.ts.map +1 -0
- package/dist/experimental/materials/glass-material.js +544 -0
- package/dist/experimental/materials/glass-material.js.map +1 -0
- package/dist/experimental/materials/glass-transmission.cjs +954 -0
- package/dist/experimental/materials/glass-transmission.d.ts +193 -0
- package/dist/experimental/materials/glass-transmission.d.ts.map +1 -0
- package/dist/experimental/materials/glass-transmission.js +928 -0
- package/dist/experimental/materials/glass-transmission.js.map +1 -0
- package/dist/experimental/materials/index.cjs +61 -0
- package/dist/experimental/materials/index.cjs.map +6 -0
- package/dist/experimental/materials/index.d.ts +14 -0
- package/dist/experimental/materials/index.d.ts.map +1 -0
- package/dist/experimental/materials/index.js +11 -0
- package/dist/experimental/materials/index.js.map +1 -0
- package/dist/experimental/materials/optical-caustics.cjs +201 -0
- package/dist/experimental/materials/optical-caustics.d.ts +69 -0
- package/dist/experimental/materials/optical-caustics.d.ts.map +1 -0
- package/dist/experimental/materials/optical-caustics.js +180 -0
- package/dist/experimental/materials/optical-caustics.js.map +1 -0
- package/dist/experimental/materials/optical-lighting.cjs +169 -0
- package/dist/experimental/materials/optical-lighting.d.ts +7 -0
- package/dist/experimental/materials/optical-lighting.d.ts.map +1 -0
- package/dist/experimental/materials/optical-lighting.js +144 -0
- package/dist/experimental/materials/optical-lighting.js.map +1 -0
- package/dist/experimental/materials/optical-point-lights.cjs +258 -0
- package/dist/experimental/materials/optical-point-lights.d.ts +68 -0
- package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -0
- package/dist/experimental/materials/optical-point-lights.js +237 -0
- package/dist/experimental/materials/optical-point-lights.js.map +1 -0
- package/dist/experimental/materials/reflective-material.cjs +216 -0
- package/dist/experimental/materials/reflective-material.d.ts +46 -0
- package/dist/experimental/materials/reflective-material.d.ts.map +1 -0
- package/dist/experimental/materials/reflective-material.js +190 -0
- package/dist/experimental/materials/reflective-material.js.map +1 -0
- package/dist/experimental/textures/html-texture.cjs +221 -0
- package/dist/experimental/textures/html-texture.d.ts +85 -0
- package/dist/experimental/textures/html-texture.d.ts.map +1 -0
- package/dist/experimental/textures/html-texture.js +206 -0
- package/dist/experimental/textures/html-texture.js.map +1 -0
- package/dist/experimental/textures/index.cjs +33 -0
- package/dist/experimental/textures/index.cjs.map +6 -0
- package/dist/experimental/textures/index.d.ts +5 -0
- package/dist/experimental/textures/index.d.ts.map +1 -0
- package/dist/experimental/textures/index.js +7 -0
- package/dist/experimental/textures/index.js.map +1 -0
- package/dist/experimental/textures/packed-pixels.cjs +248 -0
- package/dist/experimental/textures/packed-pixels.d.ts +17 -0
- package/dist/experimental/textures/packed-pixels.d.ts.map +1 -0
- package/dist/experimental/textures/packed-pixels.js +237 -0
- package/dist/experimental/textures/packed-pixels.js.map +1 -0
- package/dist/experimental/textures/rgba-decoder.cjs +60 -0
- package/dist/experimental/textures/rgba-decoder.d.ts +29 -0
- package/dist/experimental/textures/rgba-decoder.d.ts.map +1 -0
- package/dist/experimental/textures/rgba-decoder.js +43 -0
- package/dist/experimental/textures/rgba-decoder.js.map +1 -0
- package/dist/experimental/webxr/index.cjs +38 -0
- package/dist/experimental/webxr/index.cjs.map +6 -0
- package/dist/experimental/webxr/index.d.ts +9 -0
- package/dist/experimental/webxr/index.d.ts.map +1 -0
- package/dist/experimental/webxr/index.js +8 -0
- package/dist/experimental/webxr/index.js.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.cjs +38 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts +9 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js +17 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.cjs +157 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts +48 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.js +144 -0
- package/dist/experimental/webxr/webxr-camera-texture.js.map +1 -0
- package/dist/experimental/webxr/webxr-input.cjs +93 -0
- package/dist/experimental/webxr/webxr-input.d.ts +24 -0
- package/dist/experimental/webxr/webxr-input.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-input.js +70 -0
- package/dist/experimental/webxr/webxr-input.js.map +1 -0
- package/dist/experimental/webxr/webxr-manager.cjs +356 -0
- package/dist/experimental/webxr/webxr-manager.d.ts +91 -0
- package/dist/experimental/webxr/webxr-manager.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-manager.js +354 -0
- package/dist/experimental/webxr/webxr-manager.js.map +1 -0
- package/dist/experimental/webxr/webxr-types.cjs +15 -0
- package/dist/experimental/webxr/webxr-types.d.ts +152 -0
- package/dist/experimental/webxr/webxr-types.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-types.js +5 -0
- package/dist/experimental/webxr/webxr-types.js.map +1 -0
- package/dist/geometry/edge-geometry.cjs +171 -0
- package/dist/geometry/geometry-primitives.cjs +189 -0
- package/dist/geometry/geometry-primitives.d.ts +6 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.js +8 -0
- package/dist/geometry/geometry-primitives.js.map +1 -1
- package/dist/geometry/geometry-table.cjs +15 -0
- package/dist/geometry/geometry-utils.cjs +147 -0
- package/dist/geometry/geometry.cjs +90 -0
- package/dist/geometry/gpu-geometry.cjs +130 -0
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +88 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +5 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js +73 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -0
- package/dist/geometry/gpu-vector-geometry.cjs +40 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +21 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry.js +19 -0
- package/dist/geometry/gpu-vector-geometry.js.map +1 -0
- package/dist/geometry/mesh-simplification.cjs +385 -0
- package/dist/geometry/ring-geometry.cjs +104 -0
- package/dist/geometry/ring-geometry.d.ts +17 -0
- package/dist/geometry/ring-geometry.d.ts.map +1 -0
- package/dist/geometry/ring-geometry.js +94 -0
- package/dist/geometry/ring-geometry.js.map +1 -0
- package/dist/geometry/stroke-geometry.cjs +171 -0
- package/dist/graph/models/index.cjs +66 -0
- package/dist/graph/models/index.cjs.map +6 -0
- package/dist/graph/models/index.d.ts +7 -0
- package/dist/graph/models/index.d.ts.map +1 -0
- package/dist/graph/models/index.js +10 -0
- package/dist/graph/models/index.js.map +1 -0
- package/dist/graph/models/path/path-attribute-model.cjs +421 -0
- package/dist/graph/models/path/path-attribute-model.d.ts +142 -0
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-attribute-model.js +409 -0
- package/dist/graph/models/path/path-attribute-model.js.map +1 -0
- package/dist/graph/models/path/path-storage-model.cjs +711 -0
- package/dist/graph/models/path/path-storage-model.d.ts +174 -0
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-storage-model.js +720 -0
- package/dist/graph/models/path/path-storage-model.js.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.cjs +271 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts +58 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.js +248 -0
- package/dist/graph/models/path/path-trips-storage-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +117 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js +101 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.cjs +283 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts +77 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.js +242 -0
- package/dist/graph/models/polygon/polygon-shaders.js.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.cjs +111 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.js +92 -0
- package/dist/graph/models/polygon/polygon-storage-model.js.map +1 -0
- package/dist/graph/physics/index.cjs +50 -0
- package/dist/graph/physics/index.cjs.map +6 -0
- package/dist/graph/physics/index.d.ts +12 -0
- package/dist/graph/physics/index.d.ts.map +1 -0
- package/dist/graph/physics/index.js +12 -0
- package/dist/graph/physics/index.js.map +1 -0
- package/dist/graph/physics/physics-scenegraph.cjs +92 -0
- package/dist/graph/physics/physics-scenegraph.d.ts +35 -0
- package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -0
- package/dist/graph/physics/physics-scenegraph.js +80 -0
- package/dist/graph/physics/physics-scenegraph.js.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.cjs +164 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts +37 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.js +145 -0
- package/dist/graph/physics/scenegraph-behaviors.js.map +1 -0
- package/dist/graph/physics/scenegraph-instance.cjs +246 -0
- package/dist/graph/physics/scenegraph-instance.d.ts +59 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-instance.js +241 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -0
- package/dist/graph/physics/scenegraph-joints.cjs +51 -0
- package/dist/graph/physics/scenegraph-joints.d.ts +5 -0
- package/dist/graph/physics/scenegraph-joints.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-joints.js +31 -0
- package/dist/graph/physics/scenegraph-joints.js.map +1 -0
- package/dist/graph/physics/scenegraph-motion.cjs +177 -0
- package/dist/graph/physics/scenegraph-motion.d.ts +37 -0
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-motion.js +168 -0
- package/dist/graph/physics/scenegraph-motion.js.map +1 -0
- package/dist/graph/physics/scenegraph-properties.cjs +170 -0
- package/dist/graph/physics/scenegraph-properties.d.ts +37 -0
- package/dist/graph/physics/scenegraph-properties.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-properties.js +186 -0
- package/dist/graph/physics/scenegraph-properties.js.map +1 -0
- package/dist/graph/physics/scenegraph-publication.cjs +112 -0
- package/dist/graph/physics/scenegraph-publication.d.ts +23 -0
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-publication.js +99 -0
- package/dist/graph/physics/scenegraph-publication.js.map +1 -0
- package/dist/graph/physics/scenegraph-session.cjs +256 -0
- package/dist/graph/physics/scenegraph-session.d.ts +68 -0
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-session.js +249 -0
- package/dist/graph/physics/scenegraph-session.js.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.cjs +84 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts +32 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.js +67 -0
- package/dist/graph/tables/gpu-table-geometry.js.map +1 -0
- package/dist/graph/tables/gpu-table-model.cjs +459 -0
- package/dist/graph/tables/gpu-table-model.d.ts +67 -0
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-model.js +457 -0
- package/dist/graph/tables/gpu-table-model.js.map +1 -0
- package/dist/graph/tables/gpu-table-transform.cjs +341 -0
- package/dist/graph/tables/gpu-table-transform.d.ts +61 -0
- package/dist/graph/tables/gpu-table-transform.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-transform.js +333 -0
- package/dist/graph/tables/gpu-table-transform.js.map +1 -0
- package/dist/graph/tables/index.cjs +33 -0
- package/dist/graph/tables/index.cjs.map +6 -0
- package/dist/graph/tables/index.d.ts +4 -0
- package/dist/graph/tables/index.d.ts.map +1 -0
- package/dist/graph/tables/index.js +7 -0
- package/dist/graph/tables/index.js.map +1 -0
- package/dist/index.cjs +303 -9569
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +32 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/interactivity/interactivity.cjs +570 -0
- package/dist/interactivity/interactivity.d.ts +107 -0
- package/dist/interactivity/interactivity.d.ts.map +1 -0
- package/dist/interactivity/interactivity.js +575 -0
- package/dist/interactivity/interactivity.js.map +1 -0
- package/dist/interactivity/physics.cjs +15 -0
- package/dist/interactivity/physics.d.ts +12 -0
- package/dist/interactivity/physics.d.ts.map +1 -0
- package/dist/interactivity/physics.js +5 -0
- package/dist/interactivity/physics.js.map +1 -0
- package/dist/material/material-factory.cjs +99 -0
- package/dist/material/material-factory.d.ts +1 -1
- package/dist/material/material-factory.d.ts.map +1 -1
- package/dist/material/material.cjs +239 -0
- package/dist/material/material.d.ts +2 -2
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +2 -2
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-bindings.cjs +226 -0
- package/dist/model/gpu-vector-bindings.d.ts +36 -0
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -0
- package/dist/model/gpu-vector-bindings.js +217 -0
- package/dist/model/gpu-vector-bindings.js.map +1 -0
- package/dist/model/gpu-vector-draw-batches.cjs +82 -0
- package/dist/model/gpu-vector-draw-batches.d.ts +5 -0
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-draw-batches.js +73 -0
- package/dist/model/gpu-vector-draw-batches.js.map +1 -0
- package/dist/model/gpu-vector-model-batches.cjs +94 -0
- package/dist/model/gpu-vector-model-batches.d.ts +41 -0
- package/dist/model/gpu-vector-model-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-model-batches.js +77 -0
- package/dist/model/gpu-vector-model-batches.js.map +1 -0
- package/dist/model/gpu-vector-model.cjs +1264 -0
- package/dist/model/gpu-vector-model.d.ts +352 -0
- package/dist/model/gpu-vector-model.d.ts.map +1 -0
- package/dist/model/gpu-vector-model.js +1375 -0
- package/dist/model/gpu-vector-model.js.map +1 -0
- package/dist/model/model.cjs +134 -0
- package/dist/model/model.d.ts +21 -305
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +68 -1092
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.cjs +44 -0
- package/dist/model/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +5 -2
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.cjs +167 -0
- package/dist/models/billboard-texture-model.d.ts +1 -1
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +1 -1
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.cjs +61 -0
- package/dist/models/clip-space.cjs +103 -0
- package/dist/models/directional-light-model.cjs +45 -0
- package/dist/models/light-model-utils.cjs +426 -0
- package/dist/models/point-light-model.cjs +44 -0
- package/dist/models/spot-light-model.cjs +45 -0
- package/dist/modules/picking/color-picking.cjs +209 -0
- package/dist/modules/picking/color-picking.d.ts +1 -1
- package/dist/modules/picking/index-color-picking.cjs +230 -0
- package/dist/modules/picking/index-color-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.cjs +201 -0
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-color-picking.cjs +28 -0
- package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-picking-manager.cjs +92 -0
- package/dist/modules/picking/picking-manager.cjs +360 -0
- package/dist/modules/picking/picking-uniforms.cjs +140 -0
- package/dist/modules/picking/picking-uniforms.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking.cjs +43 -0
- package/dist/modules/picking/picking.d.ts +1 -1
- package/dist/passes/get-fragment-shader.cjs +119 -0
- package/dist/passes/shader-pass-renderer.cjs +722 -0
- package/dist/passes/shader-pass-renderer.d.ts +2 -2
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +1 -1
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.cjs +78 -0
- package/dist/scenegraph/controllers/area-light-controller.cjs +143 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/area-light-controller.js +130 -0
- package/dist/scenegraph/controllers/area-light-controller.js.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.cjs +156 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts +45 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.js +156 -0
- package/dist/scenegraph/controllers/billboard-controller.js.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.cjs +71 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts +30 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.js +53 -0
- package/dist/scenegraph/controllers/joint-controller.js.map +1 -0
- package/dist/scenegraph/controllers/material-variants.cjs +61 -0
- package/dist/scenegraph/controllers/material-variants.d.ts +42 -0
- package/dist/scenegraph/controllers/material-variants.d.ts.map +1 -0
- package/dist/scenegraph/controllers/material-variants.js +40 -0
- package/dist/scenegraph/controllers/material-variants.js.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.cjs +61 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts +19 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.js +41 -0
- package/dist/scenegraph/controllers/morph-controller.js.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.cjs +111 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts +36 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.js +90 -0
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -0
- package/dist/scenegraph/group-node.cjs +129 -0
- package/dist/scenegraph/model-node.cjs +68 -0
- package/dist/scenegraph/physics-transforms.cjs +95 -0
- package/dist/scenegraph/physics-transforms.d.ts +13 -0
- package/dist/scenegraph/physics-transforms.d.ts.map +1 -0
- package/dist/scenegraph/physics-transforms.js +72 -0
- package/dist/scenegraph/physics-transforms.js.map +1 -0
- package/dist/scenegraph/published-transforms.cjs +37 -0
- package/dist/scenegraph/published-transforms.d.ts +17 -0
- package/dist/scenegraph/published-transforms.d.ts.map +1 -0
- package/dist/scenegraph/published-transforms.js +16 -0
- package/dist/scenegraph/published-transforms.js.map +1 -0
- package/dist/scenegraph/scenegraph-bounds.cjs +51 -0
- package/dist/scenegraph/scenegraph-node.cjs +182 -0
- package/dist/shader-inputs.cjs +231 -0
- package/dist/shader-inputs.d.ts +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/utils/buffer-layout-helper.cjs +52 -0
- package/dist/utils/buffer-layout-order.cjs +37 -0
- package/dist/utils/deep-equal.cjs +65 -0
- package/dist/utils/get-platform-info.cjs +21 -0
- package/dist/utils/get-platform-info.d.ts +2 -0
- package/dist/utils/get-platform-info.d.ts.map +1 -0
- package/dist/utils/get-platform-info.js +5 -0
- package/dist/utils/get-platform-info.js.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.cjs +45 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts +12 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.js +27 -0
- package/dist/utils/gpu-vector-batch-structure.js.map +1 -0
- package/dist/utils/shader-module-utils.cjs +148 -0
- package/dist/utils/uid.cjs +32 -0
- package/package.json +45 -7
- package/src/animation/deform-positions.ts +62 -0
- package/src/animation/node-animation-binding.ts +54 -0
- package/src/animation/property-animation-binding.ts +212 -0
- package/src/animation/scenegraph-animator.ts +117 -0
- package/src/animation/texture-transform.ts +59 -0
- package/src/animation-loop/animation-loop.ts +10 -3
- package/src/audio/audio-controller.ts +583 -0
- package/src/audio/audio-environment.ts +202 -0
- package/src/audio/audio-graph.ts +253 -0
- package/src/compute/buffer-transform.ts +71 -16
- package/src/compute/computation.ts +4 -19
- package/src/compute/texture-transform.ts +25 -12
- package/src/controls/orbit-controls.ts +4 -1
- package/src/dynamic-buffer/dynamic-buffer.ts +15 -449
- package/src/dynamic-texture/dynamic-texture.ts +5 -760
- package/src/dynamic-texture/texture-binding-source.ts +8 -90
- package/src/dynamic-texture/texture-data.ts +31 -340
- package/src/dynamic-texture/video-texture.ts +1 -1
- package/src/experimental/controls/comparison-splitter.ts +269 -0
- package/src/experimental/controls/flat-controller.ts +403 -0
- package/src/experimental/controls/index.ts +16 -0
- package/src/experimental/controls/orbit-controls.ts +6 -0
- package/src/experimental/materials/emissive-material.ts +120 -0
- package/src/experimental/materials/glass-material.ts +607 -0
- package/src/experimental/materials/glass-transmission.ts +1023 -0
- package/src/experimental/materials/index.ts +49 -0
- package/src/experimental/materials/optical-caustics.ts +234 -0
- package/src/experimental/materials/optical-lighting.ts +148 -0
- package/src/experimental/materials/optical-point-lights.ts +288 -0
- package/src/experimental/materials/reflective-material.ts +214 -0
- package/src/experimental/textures/html-texture.ts +285 -0
- package/src/experimental/textures/index.ts +8 -0
- package/src/experimental/textures/packed-pixels.ts +351 -0
- package/src/experimental/textures/rgba-decoder.ts +79 -0
- package/src/experimental/webxr/index.ts +21 -0
- package/src/experimental/webxr/webxr-animation-frame-provider.ts +22 -0
- package/src/experimental/webxr/webxr-camera-texture.ts +195 -0
- package/src/experimental/webxr/webxr-input.ts +117 -0
- package/src/experimental/webxr/webxr-manager.ts +524 -0
- package/src/experimental/webxr/webxr-types.ts +192 -0
- package/src/geometry/geometry-primitives.ts +11 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +78 -0
- package/src/geometry/gpu-vector-geometry.ts +33 -0
- package/src/geometry/ring-geometry.ts +117 -0
- package/src/graph/models/index.ts +45 -0
- package/src/graph/models/path/path-attribute-model.ts +563 -0
- package/src/graph/models/path/path-storage-model.ts +996 -0
- package/src/graph/models/path/path-trips-storage-model.ts +286 -0
- package/src/graph/models/polygon/polygon-attribute-model.ts +165 -0
- package/src/graph/models/polygon/polygon-shaders.ts +279 -0
- package/src/graph/models/polygon/polygon-storage-model.ts +146 -0
- package/src/graph/physics/index.ts +24 -0
- package/src/graph/physics/physics-scenegraph.ts +112 -0
- package/src/graph/physics/scenegraph-behaviors.ts +169 -0
- package/src/graph/physics/scenegraph-instance.ts +296 -0
- package/src/graph/physics/scenegraph-joints.ts +37 -0
- package/src/graph/physics/scenegraph-motion.ts +175 -0
- package/src/graph/physics/scenegraph-properties.ts +241 -0
- package/src/graph/physics/scenegraph-publication.ts +116 -0
- package/src/graph/physics/scenegraph-session.ts +317 -0
- package/src/graph/tables/gpu-table-geometry.ts +88 -0
- package/src/graph/tables/gpu-table-model.ts +661 -0
- package/src/graph/tables/gpu-table-transform.ts +497 -0
- package/src/graph/tables/index.ts +18 -0
- package/src/index.ts +130 -13
- package/src/interactivity/interactivity.ts +670 -0
- package/src/interactivity/physics.ts +19 -0
- package/src/material/material-factory.ts +1 -1
- package/src/material/material.ts +2 -2
- package/src/model/gpu-vector-bindings.ts +276 -0
- package/src/model/gpu-vector-draw-batches.ts +116 -0
- package/src/model/gpu-vector-model-batches.ts +142 -0
- package/src/model/gpu-vector-model.ts +1819 -0
- package/src/model/model.ts +91 -1444
- package/src/model/split-uniforms-and-bindings.ts +6 -3
- package/src/models/billboard-texture-model.ts +1 -1
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +2 -2
- package/src/scenegraph/controllers/area-light-controller.ts +152 -0
- package/src/scenegraph/controllers/billboard-controller.ts +204 -0
- package/src/scenegraph/controllers/joint-controller.ts +81 -0
- package/src/scenegraph/controllers/material-variants.ts +70 -0
- package/src/scenegraph/controllers/morph-controller.ts +61 -0
- package/src/scenegraph/controllers/skin-controller.ts +125 -0
- package/src/scenegraph/physics-transforms.ts +82 -0
- package/src/scenegraph/published-transforms.ts +18 -0
- package/src/shader-inputs.ts +1 -1
- package/src/utils/get-platform-info.ts +5 -0
- package/src/utils/gpu-vector-batch-structure.ts +36 -0
- package/dist/compute/kernel.d.ts +0 -54
- package/dist/compute/kernel.d.ts.map +0 -1
- package/dist/compute/kernel.js +0 -103
- package/dist/compute/kernel.js.map +0 -1
- package/dist/compute/render-kernel.d.ts +0 -65
- package/dist/compute/render-kernel.d.ts.map +0 -1
- package/dist/compute/render-kernel.js +0 -129
- package/dist/compute/render-kernel.js.map +0 -1
- package/src/compute/kernel.ts +0 -146
- package/src/compute/render-kernel.ts +0 -192
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {InteractivityPhysics} from './physics';
|
|
6
|
+
|
|
7
|
+
// Typed operation graph input, independent of asset loading.
|
|
8
|
+
export type InteractivityValue = {
|
|
9
|
+
type?: number;
|
|
10
|
+
value?: unknown[];
|
|
11
|
+
node?: number;
|
|
12
|
+
socket?: string;
|
|
13
|
+
};
|
|
14
|
+
export type InteractivityNode = {
|
|
15
|
+
declaration: number;
|
|
16
|
+
configuration?: Record<string, {value: unknown[]}>;
|
|
17
|
+
values?: Record<string, InteractivityValue>;
|
|
18
|
+
flows?: Record<string, {node: number; socket?: string}>;
|
|
19
|
+
};
|
|
20
|
+
export type InteractivityGraph = {
|
|
21
|
+
types?: {signature: string}[];
|
|
22
|
+
events?: {id: string; values?: Record<string, {type: number; value?: unknown[]}>}[];
|
|
23
|
+
variables?: {type?: number; value?: unknown[]}[];
|
|
24
|
+
declarations?: {op: string; extension?: string}[];
|
|
25
|
+
nodes?: InteractivityNode[];
|
|
26
|
+
};
|
|
27
|
+
export type InteractivityDefinition = {
|
|
28
|
+
graph?: number;
|
|
29
|
+
graphs: InteractivityGraph[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type InteractivityValueType = unknown[];
|
|
33
|
+
export type InteractivityPropertyAdapter = {
|
|
34
|
+
get(pointer: string): InteractivityValueType | undefined;
|
|
35
|
+
set(pointer: string, value: InteractivityValueType): boolean;
|
|
36
|
+
};
|
|
37
|
+
export type InteractivityOptions = {
|
|
38
|
+
physics?: InteractivityPhysics;
|
|
39
|
+
graph?: number;
|
|
40
|
+
/** Receives custom events sent by the graph to its host. */
|
|
41
|
+
onEvent?: (eventId: string, values: Record<string, unknown[]>) => void;
|
|
42
|
+
/** Receives formatted graph diagnostics and their severity. */
|
|
43
|
+
onLog?: (message: string, severity: number) => void;
|
|
44
|
+
properties?: InteractivityPropertyAdapter;
|
|
45
|
+
/** Maximum flow activations per dispatch, protecting against unbounded cycles. */
|
|
46
|
+
maxSteps?: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const VALUE_OPS = new Set([
|
|
50
|
+
'variable/get',
|
|
51
|
+
'pointer/get',
|
|
52
|
+
'math/and',
|
|
53
|
+
'math/add',
|
|
54
|
+
'math/sub',
|
|
55
|
+
'math/mul',
|
|
56
|
+
'math/div',
|
|
57
|
+
'math/rem',
|
|
58
|
+
'math/min',
|
|
59
|
+
'math/max',
|
|
60
|
+
'math/eq',
|
|
61
|
+
'math/lt',
|
|
62
|
+
'math/le',
|
|
63
|
+
'math/gt',
|
|
64
|
+
'math/ge',
|
|
65
|
+
'math/select',
|
|
66
|
+
'math/switch',
|
|
67
|
+
'math/neg',
|
|
68
|
+
'math/abs',
|
|
69
|
+
'math/clamp',
|
|
70
|
+
'type/intToFloat',
|
|
71
|
+
'type/floatToInt'
|
|
72
|
+
]);
|
|
73
|
+
const PHYSICS_PREFIX = 'KHR_physics_rigid_bodies:';
|
|
74
|
+
const PHYSICS_OPS = new Set(
|
|
75
|
+
[
|
|
76
|
+
'rigid_body/applyImpulse',
|
|
77
|
+
'rigid_body/applyPointImpulse',
|
|
78
|
+
'rigid_body/rayCast',
|
|
79
|
+
'event/rigid_body_triggerEntered',
|
|
80
|
+
'event/rigid_body_triggerExited'
|
|
81
|
+
].map(operation => PHYSICS_PREFIX + operation)
|
|
82
|
+
);
|
|
83
|
+
const FLOW_OPS = new Set([
|
|
84
|
+
'event/onStart',
|
|
85
|
+
'event/onTick',
|
|
86
|
+
'event/send',
|
|
87
|
+
'debug/log',
|
|
88
|
+
'flow/sequence',
|
|
89
|
+
'flow/branch',
|
|
90
|
+
'flow/switch',
|
|
91
|
+
'variable/set',
|
|
92
|
+
'pointer/set',
|
|
93
|
+
'flow/setDelay',
|
|
94
|
+
'KHR_node_selectability:event/onSelect'
|
|
95
|
+
]);
|
|
96
|
+
function copy(value: unknown[]): unknown[] {
|
|
97
|
+
return value.slice();
|
|
98
|
+
}
|
|
99
|
+
function components(value: unknown): unknown[] {
|
|
100
|
+
if (!Array.isArray(value)) throw new Error('KHR_interactivity: expected component array');
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
function scalar(value: unknown[]): unknown {
|
|
104
|
+
return value[0];
|
|
105
|
+
}
|
|
106
|
+
function number(value: unknown[]): number {
|
|
107
|
+
const n = scalar(value);
|
|
108
|
+
if (typeof n !== 'number') throw new Error('KHR_interactivity: expected numeric value');
|
|
109
|
+
return n;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function getTypeDefaultValue(signature: string | undefined): unknown[] {
|
|
113
|
+
if (signature === 'bool') return [false];
|
|
114
|
+
if (signature === 'int') return [0];
|
|
115
|
+
if (signature === 'ref') return [null];
|
|
116
|
+
const dimensions = signature?.match(/^float(?:([234])(?:x([234]))?)?$/);
|
|
117
|
+
if (dimensions && (!dimensions[2] || dimensions[1] === dimensions[2])) {
|
|
118
|
+
return Array(Number(dimensions[1] ?? 1) * Number(dimensions[2] ?? 1)).fill(NaN);
|
|
119
|
+
}
|
|
120
|
+
throw new Error('KHR_interactivity: unsupported default value type');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Deterministic, GPU-independent interpreter for a defined subset of KHR_interactivity.
|
|
125
|
+
* Unsupported operations fail during construction; no graph is silently partially executed.
|
|
126
|
+
* A host supplies application properties through the property adapter.
|
|
127
|
+
*/
|
|
128
|
+
export class Interactivity {
|
|
129
|
+
private readonly physics?: InteractivityPhysics;
|
|
130
|
+
private readonly physicsPending = new Set<Promise<void>>();
|
|
131
|
+
private readonly physicsErrors: unknown[] = [];
|
|
132
|
+
readonly definition: InteractivityDefinition;
|
|
133
|
+
readonly graph: InteractivityGraph;
|
|
134
|
+
readonly variables: unknown[][];
|
|
135
|
+
readonly properties?: InteractivityPropertyAdapter;
|
|
136
|
+
readonly maxSteps: number;
|
|
137
|
+
private readonly onEvent: InteractivityOptions['onEvent'];
|
|
138
|
+
private readonly onLog: InteractivityOptions['onLog'];
|
|
139
|
+
private started = false;
|
|
140
|
+
private currentTimeSeconds = 0;
|
|
141
|
+
private nextDelayIdentifier = 0;
|
|
142
|
+
private pendingDelays: {
|
|
143
|
+
nodeIndex: number;
|
|
144
|
+
reference: string;
|
|
145
|
+
timeSeconds: number;
|
|
146
|
+
activate: () => void;
|
|
147
|
+
}[] = [];
|
|
148
|
+
private startTime = 0;
|
|
149
|
+
private lastTick: number | undefined;
|
|
150
|
+
private eventOutputs = new Map<number, Record<string, unknown[]>>();
|
|
151
|
+
|
|
152
|
+
constructor(definition: InteractivityDefinition, options: InteractivityOptions = {}) {
|
|
153
|
+
this.physics = options.physics;
|
|
154
|
+
this.definition = definition;
|
|
155
|
+
const graphIndex = options.graph ?? definition.graph ?? 0;
|
|
156
|
+
const graph = definition.graphs[graphIndex];
|
|
157
|
+
if (!graph) throw new Error(`KHR_interactivity: graph ${graphIndex} does not exist`);
|
|
158
|
+
this.graph = graph;
|
|
159
|
+
this.properties = options.properties;
|
|
160
|
+
this.onEvent = options.onEvent;
|
|
161
|
+
this.onLog = options.onLog;
|
|
162
|
+
this.maxSteps = options.maxSteps ?? 10000;
|
|
163
|
+
if (!Number.isSafeInteger(this.maxSteps) || this.maxSteps < 1) {
|
|
164
|
+
throw new Error('KHR_interactivity: maxSteps must be a positive safe integer');
|
|
165
|
+
}
|
|
166
|
+
this.variables = (graph.variables ?? []).map(variable => copy(variable.value ?? [0]));
|
|
167
|
+
for (const [index, node] of (graph.nodes ?? []).entries()) {
|
|
168
|
+
const op = this.getOperation(graphIndex, index);
|
|
169
|
+
if (!VALUE_OPS.has(op) && !FLOW_OPS.has(op) && !(this.physics && PHYSICS_OPS.has(op))) {
|
|
170
|
+
throw new Error(`KHR_interactivity: unsupported operation ${op}`);
|
|
171
|
+
}
|
|
172
|
+
if (op.startsWith(PHYSICS_PREFIX + 'event/')) {
|
|
173
|
+
const triggerNode = number(this.config(node, 'nodeIndex'));
|
|
174
|
+
if (
|
|
175
|
+
!this.physics?.isTriggerNode(triggerNode) ||
|
|
176
|
+
(graph.nodes ?? [])
|
|
177
|
+
.slice(0, index)
|
|
178
|
+
.some(
|
|
179
|
+
(other, previous) =>
|
|
180
|
+
this.getOperation(graphIndex, previous) === op &&
|
|
181
|
+
other.configuration?.['nodeIndex']?.value[0] === triggerNode
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
throw new Error('Invalid or duplicate physics trigger event');
|
|
185
|
+
}
|
|
186
|
+
if (op === 'event/send') {
|
|
187
|
+
const eventIndex = number(this.config(node, 'event'));
|
|
188
|
+
if (!Number.isInteger(eventIndex) || !graph.events?.[eventIndex]) {
|
|
189
|
+
throw new Error('KHR_interactivity: invalid custom event index');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const target of Object.values(node.flows ?? {})) {
|
|
193
|
+
if (!Number.isInteger(target.node) || !(graph.nodes ?? [])[target.node]) {
|
|
194
|
+
throw new Error(`KHR_interactivity: invalid flow target ${target.node}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
get graphCount(): number {
|
|
201
|
+
return this.definition.graphs.length;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
getGraph(index: number): InteractivityGraph {
|
|
205
|
+
const graph = this.definition.graphs[index];
|
|
206
|
+
if (!graph) throw new Error(`KHR_interactivity: graph index ${index} is out of range`);
|
|
207
|
+
return graph;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
getOperation(graphIndex: number, nodeIndex: number): string {
|
|
211
|
+
const graph = this.getGraph(graphIndex);
|
|
212
|
+
const node = graph.nodes?.[nodeIndex];
|
|
213
|
+
if (!node) throw new Error(`KHR_interactivity: node index ${nodeIndex} is out of range`);
|
|
214
|
+
const declaration = graph.declarations?.[node.declaration];
|
|
215
|
+
if (!declaration)
|
|
216
|
+
throw new Error(`KHR_interactivity: declaration index ${node.declaration} is out of range`);
|
|
217
|
+
return declaration.extension ? `${declaration.extension}:${declaration.op}` : declaration.op;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private op(index: number): string {
|
|
221
|
+
const node = this.graph.nodes?.[index];
|
|
222
|
+
const declaration = node && this.graph.declarations?.[node.declaration];
|
|
223
|
+
if (!declaration) throw new Error(`KHR_interactivity: invalid declaration for node ${index}`);
|
|
224
|
+
return declaration.extension ? `${declaration.extension}:${declaration.op}` : declaration.op;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private config(node: InteractivityNode, name: string): unknown[] {
|
|
228
|
+
const value = node.configuration?.[name]?.value;
|
|
229
|
+
if (!value) throw new Error(`KHR_interactivity: missing configuration ${name}`);
|
|
230
|
+
return components(value);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private getSwitchCases(node: InteractivityNode): unknown[] {
|
|
234
|
+
const cases = node.configuration?.['cases']?.value;
|
|
235
|
+
// Missing or invalid configuration uses the operation's default empty list.
|
|
236
|
+
return Array.isArray(cases) &&
|
|
237
|
+
cases.every(
|
|
238
|
+
value =>
|
|
239
|
+
typeof value === 'number' &&
|
|
240
|
+
Number.isInteger(value) &&
|
|
241
|
+
value >= -2147483648 &&
|
|
242
|
+
value <= 2147483647
|
|
243
|
+
)
|
|
244
|
+
? cases
|
|
245
|
+
: [];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
private input(index: number, name: string, visiting: Set<number>): unknown[] {
|
|
249
|
+
const value: InteractivityValue | undefined = this.graph.nodes?.[index]?.values?.[name];
|
|
250
|
+
if (!value) throw new Error(`KHR_interactivity: missing input ${name} on node ${index}`);
|
|
251
|
+
if (value.node !== undefined) {
|
|
252
|
+
if (!value.socket) throw new Error('KHR_interactivity: connected input missing socket');
|
|
253
|
+
return this.evaluate(value.node, value.socket, visiting);
|
|
254
|
+
}
|
|
255
|
+
if (!value.value) {
|
|
256
|
+
return getTypeDefaultValue(
|
|
257
|
+
value.type === undefined ? undefined : this.graph.types?.[value.type]?.signature
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
return copy(components(value.value));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private pointer(index: number, visiting: Set<number>): string {
|
|
264
|
+
const node = this.graph.nodes![index];
|
|
265
|
+
const template = scalar(this.config(node, 'pointer'));
|
|
266
|
+
if (typeof template !== 'string' || !template.startsWith('/')) {
|
|
267
|
+
throw new Error('KHR_interactivity: invalid pointer template');
|
|
268
|
+
}
|
|
269
|
+
return template.replace(/\[([^\]]+)\]|\{([^}]+)\}/g, (_match, integerName, refName) => {
|
|
270
|
+
const name = integerName ?? refName;
|
|
271
|
+
const value = scalar(this.input(index, name, visiting));
|
|
272
|
+
if (
|
|
273
|
+
refName &&
|
|
274
|
+
typeof value === 'string' &&
|
|
275
|
+
/^\/(?:[^/~]|~[01])+(?:\/(?:[^/~]|~[01])+)*$/.test(value)
|
|
276
|
+
)
|
|
277
|
+
return value.split('/').at(-1)!;
|
|
278
|
+
if (!Number.isSafeInteger(value) || (value as number) < 0) {
|
|
279
|
+
throw new Error('KHR_interactivity: invalid pointer parameter');
|
|
280
|
+
}
|
|
281
|
+
return String(value);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Evaluate a pure value socket. Values are component arrays as defined by the extension. */
|
|
286
|
+
evaluate(index: number, socket = 'value', visiting = new Set<number>()): unknown[] {
|
|
287
|
+
const node = this.graph.nodes?.[index];
|
|
288
|
+
if (!node) throw new Error(`KHR_interactivity: invalid node ${index}`);
|
|
289
|
+
if (visiting.has(index)) throw new Error('KHR_interactivity: cyclic value dependency');
|
|
290
|
+
visiting.add(index);
|
|
291
|
+
try {
|
|
292
|
+
const op = this.op(index);
|
|
293
|
+
const eventValue = this.eventOutputs.get(index)?.[socket];
|
|
294
|
+
if (eventValue) return copy(eventValue);
|
|
295
|
+
if (op === 'flow/setDelay' && socket === 'lastDelay') return [null];
|
|
296
|
+
if (op === 'variable/get') {
|
|
297
|
+
const id = number(this.config(node, 'variable'));
|
|
298
|
+
const value = this.variables[id];
|
|
299
|
+
if (!value) throw new Error('KHR_interactivity: invalid variable index');
|
|
300
|
+
return copy(value);
|
|
301
|
+
}
|
|
302
|
+
if (op === 'pointer/get') {
|
|
303
|
+
const value = this.properties?.get(this.pointer(index, visiting));
|
|
304
|
+
return socket === 'isValid' ? [value !== undefined] : copy(value ?? [0]);
|
|
305
|
+
}
|
|
306
|
+
if (socket !== 'value')
|
|
307
|
+
throw new Error(`KHR_interactivity: unsupported output socket ${socket}`);
|
|
308
|
+
const a = () => this.input(index, 'a', visiting);
|
|
309
|
+
const b = () => this.input(index, 'b', visiting);
|
|
310
|
+
const binary = (fn: (x: number, y: number) => number): unknown[] => {
|
|
311
|
+
const x = a().map(Number);
|
|
312
|
+
const y = b().map(Number);
|
|
313
|
+
if (x.length !== y.length)
|
|
314
|
+
throw new Error('KHR_interactivity: mismatched component lengths');
|
|
315
|
+
return x.map((v, i) => fn(v, y[i]));
|
|
316
|
+
};
|
|
317
|
+
switch (op) {
|
|
318
|
+
case 'type/intToFloat':
|
|
319
|
+
return a().map(Number);
|
|
320
|
+
case 'type/floatToInt':
|
|
321
|
+
return a().map(value => Number(value) | 0);
|
|
322
|
+
case 'math/clamp': {
|
|
323
|
+
const lower = b().map(Number);
|
|
324
|
+
const upper = this.input(index, 'c', visiting).map(Number);
|
|
325
|
+
return a().map((value, component) =>
|
|
326
|
+
Math.min(upper[component], Math.max(lower[component], Number(value)))
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
case 'math/and': {
|
|
330
|
+
const left = scalar(a());
|
|
331
|
+
const right = scalar(b());
|
|
332
|
+
if (typeof left === 'boolean' && typeof right === 'boolean') return [left && right];
|
|
333
|
+
if (typeof left === 'number' && typeof right === 'number') return [left & right];
|
|
334
|
+
throw new Error('KHR_interactivity: incompatible AND arguments');
|
|
335
|
+
}
|
|
336
|
+
case 'math/add':
|
|
337
|
+
return binary((x, y) => x + y);
|
|
338
|
+
case 'math/sub':
|
|
339
|
+
return binary((x, y) => x - y);
|
|
340
|
+
case 'math/mul':
|
|
341
|
+
return binary((x, y) => x * y);
|
|
342
|
+
case 'math/div':
|
|
343
|
+
return binary((x, y) => x / y);
|
|
344
|
+
case 'math/rem':
|
|
345
|
+
return binary((x, y) => x % y);
|
|
346
|
+
case 'math/min':
|
|
347
|
+
return binary(Math.min);
|
|
348
|
+
case 'math/max':
|
|
349
|
+
return binary(Math.max);
|
|
350
|
+
case 'math/neg':
|
|
351
|
+
return a().map(x => -Number(x));
|
|
352
|
+
case 'math/abs':
|
|
353
|
+
return a().map(x => Math.abs(Number(x)));
|
|
354
|
+
case 'math/eq':
|
|
355
|
+
return [JSON.stringify(a()) === JSON.stringify(b())];
|
|
356
|
+
case 'math/lt':
|
|
357
|
+
return [number(a()) < number(b())];
|
|
358
|
+
case 'math/le':
|
|
359
|
+
return [number(a()) <= number(b())];
|
|
360
|
+
case 'math/gt':
|
|
361
|
+
return [number(a()) > number(b())];
|
|
362
|
+
case 'math/ge':
|
|
363
|
+
return [number(a()) >= number(b())];
|
|
364
|
+
case 'math/select':
|
|
365
|
+
return this.input(
|
|
366
|
+
index,
|
|
367
|
+
Boolean(scalar(this.input(index, 'condition', visiting))) ? 'a' : 'b',
|
|
368
|
+
visiting
|
|
369
|
+
);
|
|
370
|
+
case 'math/switch': {
|
|
371
|
+
const selection = number(this.input(index, 'selection', visiting));
|
|
372
|
+
const cases = this.getSwitchCases(node);
|
|
373
|
+
return this.input(
|
|
374
|
+
index,
|
|
375
|
+
cases.includes(selection) ? String(selection) : 'default',
|
|
376
|
+
visiting
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
default:
|
|
380
|
+
throw new Error(`KHR_interactivity: ${op} is not a value operation`);
|
|
381
|
+
}
|
|
382
|
+
} finally {
|
|
383
|
+
visiting.delete(index);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Dispatch a lifecycle event, executing connected flows in deterministic depth-first order. */
|
|
388
|
+
private dispatch(
|
|
389
|
+
op: string,
|
|
390
|
+
outputs: Record<string, unknown[]>,
|
|
391
|
+
selectedNodeIndex?: number
|
|
392
|
+
): void {
|
|
393
|
+
let steps = 0;
|
|
394
|
+
const execute = (index: number, inputSocket: string): void => {
|
|
395
|
+
if (++steps > this.maxSteps) throw new Error('KHR_interactivity: flow step limit exceeded');
|
|
396
|
+
const node = this.graph.nodes![index];
|
|
397
|
+
const operation = this.op(index);
|
|
398
|
+
if (operation === 'flow/setDelay' && inputSocket === 'cancel') {
|
|
399
|
+
this.pendingDelays = this.pendingDelays.filter(delay => delay.nodeIndex !== index);
|
|
400
|
+
this.eventOutputs.set(index, {lastDelay: [null]});
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (inputSocket !== 'in')
|
|
404
|
+
throw new Error(`KHR_interactivity: unsupported input flow ${inputSocket}`);
|
|
405
|
+
const visiting = new Set<number>();
|
|
406
|
+
const follow = (socket: string): void => {
|
|
407
|
+
const target = node.flows?.[socket];
|
|
408
|
+
if (target) execute(target.node, target.socket ?? 'in');
|
|
409
|
+
};
|
|
410
|
+
if (PHYSICS_OPS.has(operation) && this.physics) {
|
|
411
|
+
const read = (socket: string, fallback?: unknown[]) =>
|
|
412
|
+
node.values?.[socket]
|
|
413
|
+
? this.input(index, socket, visiting)
|
|
414
|
+
: (fallback ?? this.input(index, socket, visiting));
|
|
415
|
+
const vector = (socket: string, fallback?: number[]) => {
|
|
416
|
+
const values = read(socket, fallback);
|
|
417
|
+
if (
|
|
418
|
+
values.length !== 3 ||
|
|
419
|
+
!values.every(value => typeof value === 'number' && Number.isFinite(value))
|
|
420
|
+
)
|
|
421
|
+
throw new Error('Invalid physics vector');
|
|
422
|
+
return values as number[];
|
|
423
|
+
};
|
|
424
|
+
if (operation === PHYSICS_PREFIX + 'rigid_body/applyImpulse') {
|
|
425
|
+
this.physics.applyImpulse(
|
|
426
|
+
number(read('nodeIndex')),
|
|
427
|
+
vector('linearImpulse', [0, 0, 0]),
|
|
428
|
+
vector('angularImpulse', [0, 0, 0])
|
|
429
|
+
);
|
|
430
|
+
follow('out');
|
|
431
|
+
} else if (operation === PHYSICS_PREFIX + 'rigid_body/applyPointImpulse') {
|
|
432
|
+
this.physics.applyPointImpulse(
|
|
433
|
+
number(read('nodeIndex')),
|
|
434
|
+
vector('impulse'),
|
|
435
|
+
vector('position')
|
|
436
|
+
);
|
|
437
|
+
follow('out');
|
|
438
|
+
} else if (operation === PHYSICS_PREFIX + 'rigid_body/rayCast') {
|
|
439
|
+
// Each continuation retains the event and query payloads that activated it.
|
|
440
|
+
const activationOutputs = new Map(this.eventOutputs);
|
|
441
|
+
const pending = this.physics
|
|
442
|
+
.rayCast(
|
|
443
|
+
vector('rayStart'),
|
|
444
|
+
vector('rayEnd'),
|
|
445
|
+
number(read('collisionFilterIndex', [-1]))
|
|
446
|
+
)
|
|
447
|
+
.then(hit => {
|
|
448
|
+
const previousOutputs = this.eventOutputs;
|
|
449
|
+
this.eventOutputs = activationOutputs;
|
|
450
|
+
try {
|
|
451
|
+
steps = 0;
|
|
452
|
+
this.eventOutputs.delete(index);
|
|
453
|
+
if (hit)
|
|
454
|
+
this.eventOutputs.set(index, {
|
|
455
|
+
hitNodeIndex: [hit.node],
|
|
456
|
+
hitFraction: [hit.fraction],
|
|
457
|
+
hitNormal: [...hit.normal]
|
|
458
|
+
});
|
|
459
|
+
follow(hit ? 'hit' : 'miss');
|
|
460
|
+
} finally {
|
|
461
|
+
this.eventOutputs = previousOutputs;
|
|
462
|
+
}
|
|
463
|
+
})
|
|
464
|
+
.catch(error => {
|
|
465
|
+
this.physicsErrors.push(error);
|
|
466
|
+
})
|
|
467
|
+
.finally(() => {
|
|
468
|
+
this.physicsPending.delete(pending);
|
|
469
|
+
});
|
|
470
|
+
this.physicsPending.add(pending);
|
|
471
|
+
} else throw new Error('Physics event is not an input flow');
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
switch (operation) {
|
|
475
|
+
case 'flow/setDelay': {
|
|
476
|
+
const duration = number(this.input(index, 'duration', visiting));
|
|
477
|
+
const activationTime = this.currentTimeSeconds + duration;
|
|
478
|
+
if (
|
|
479
|
+
!Number.isFinite(activationTime) ||
|
|
480
|
+
!Number.isFinite(duration) ||
|
|
481
|
+
duration < 0 ||
|
|
482
|
+
this.pendingDelays.length >= 1024
|
|
483
|
+
) {
|
|
484
|
+
follow('err');
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
const reference = `delay:${++this.nextDelayIdentifier}`;
|
|
488
|
+
this.eventOutputs.set(index, {lastDelay: [reference]});
|
|
489
|
+
this.pendingDelays.push({
|
|
490
|
+
nodeIndex: index,
|
|
491
|
+
reference,
|
|
492
|
+
timeSeconds: activationTime,
|
|
493
|
+
activate: () => {
|
|
494
|
+
steps = 0;
|
|
495
|
+
follow('done');
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
follow('out');
|
|
499
|
+
break;
|
|
500
|
+
}
|
|
501
|
+
case 'flow/sequence':
|
|
502
|
+
for (const key of Object.keys(node.flows ?? {}).sort()) follow(key);
|
|
503
|
+
break;
|
|
504
|
+
case 'flow/branch':
|
|
505
|
+
follow(Boolean(scalar(this.input(index, 'condition', visiting))) ? 'true' : 'false');
|
|
506
|
+
break;
|
|
507
|
+
case 'flow/switch': {
|
|
508
|
+
const selection = number(this.input(index, 'selection', visiting));
|
|
509
|
+
const cases = this.getSwitchCases(node);
|
|
510
|
+
follow(cases.includes(selection) ? String(selection) : 'default');
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
case 'variable/set': {
|
|
514
|
+
const ids = this.config(node, 'variables').map(Number);
|
|
515
|
+
const values = ids.map(id => this.input(index, String(id), visiting));
|
|
516
|
+
ids.forEach((id, i) => {
|
|
517
|
+
if (!this.variables[id]) throw new Error('KHR_interactivity: invalid variable index');
|
|
518
|
+
this.variables[id] = copy(values[i]);
|
|
519
|
+
});
|
|
520
|
+
follow('out');
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
case 'event/send': {
|
|
524
|
+
const eventIndex = number(this.config(node, 'event'));
|
|
525
|
+
const event = this.graph.events![eventIndex];
|
|
526
|
+
const values = Object.fromEntries(
|
|
527
|
+
Object.entries(event.values ?? {}).map(([name, declaration]) => [
|
|
528
|
+
name,
|
|
529
|
+
node.values?.[name]
|
|
530
|
+
? this.input(index, name, visiting)
|
|
531
|
+
: declaration.value
|
|
532
|
+
? copy(declaration.value)
|
|
533
|
+
: getTypeDefaultValue(this.graph.types?.[declaration.type]?.signature)
|
|
534
|
+
])
|
|
535
|
+
);
|
|
536
|
+
this.onEvent?.(event.id, values);
|
|
537
|
+
follow('out');
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
case 'debug/log': {
|
|
541
|
+
const severity = node.configuration?.['severity']?.value[0];
|
|
542
|
+
const template = node.configuration?.['message']?.value[0];
|
|
543
|
+
const tokens =
|
|
544
|
+
typeof template === 'string' ? template.match(/\{\{|\}\}|\{[^{}]+\}|[^{}]+/g) : null;
|
|
545
|
+
const validTemplate =
|
|
546
|
+
typeof template === 'string' && (tokens ?? []).join('') === template;
|
|
547
|
+
const message = validTemplate
|
|
548
|
+
? (tokens ?? [])
|
|
549
|
+
.map(token => {
|
|
550
|
+
if (token === '{{') return '{';
|
|
551
|
+
if (token === '}}') return '}';
|
|
552
|
+
if (token.startsWith('{'))
|
|
553
|
+
return JSON.stringify(this.input(index, token.slice(1, -1), visiting));
|
|
554
|
+
return token;
|
|
555
|
+
})
|
|
556
|
+
.join('')
|
|
557
|
+
: '';
|
|
558
|
+
this.onLog?.(
|
|
559
|
+
message,
|
|
560
|
+
typeof severity === 'number' && severity === (severity | 0) ? severity : 0
|
|
561
|
+
);
|
|
562
|
+
follow('out');
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
case 'pointer/set': {
|
|
566
|
+
const pointer = this.pointer(index, visiting);
|
|
567
|
+
const value = this.input(index, 'value', visiting);
|
|
568
|
+
follow(this.properties?.set(pointer, value) ? 'out' : 'err');
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
default:
|
|
572
|
+
throw new Error(`KHR_interactivity: ${operation} is not an executable flow operation`);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
const nodes = this.graph.nodes ?? [];
|
|
576
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
577
|
+
if (
|
|
578
|
+
this.op(index) === op &&
|
|
579
|
+
(selectedNodeIndex === undefined ||
|
|
580
|
+
nodes[index].configuration?.['nodeIndex']?.value[0] === selectedNodeIndex)
|
|
581
|
+
) {
|
|
582
|
+
this.eventOutputs.set(index, outputs);
|
|
583
|
+
const target = nodes[index].flows?.['out'];
|
|
584
|
+
if (target) execute(target.node, target.socket ?? 'in');
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** Await asynchronous physics query continuations before advancing the next simulation tick. */
|
|
590
|
+
async flushPhysics(): Promise<void> {
|
|
591
|
+
let rounds = 0;
|
|
592
|
+
while (this.physicsPending.size) {
|
|
593
|
+
if (++rounds > this.maxSteps) throw new Error('Physics continuation limit exceeded');
|
|
594
|
+
await Promise.all(this.physicsPending);
|
|
595
|
+
}
|
|
596
|
+
if (this.physicsErrors.length) throw this.physicsErrors.shift();
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** Deliver simulation-step sensor events, including multiple events between rendering ticks. */
|
|
600
|
+
notifyPhysicsTrigger(
|
|
601
|
+
phase: 'enter' | 'exit',
|
|
602
|
+
triggerNode: number,
|
|
603
|
+
colliderNode: number,
|
|
604
|
+
motionNode: number
|
|
605
|
+
): void {
|
|
606
|
+
if (!this.physics?.isTriggerNode(triggerNode)) throw new Error('Invalid physics trigger node');
|
|
607
|
+
this.dispatch(
|
|
608
|
+
PHYSICS_PREFIX +
|
|
609
|
+
(phase === 'enter' ? 'event/rigid_body_triggerEntered' : 'event/rigid_body_triggerExited'),
|
|
610
|
+
{
|
|
611
|
+
colliderNodeIndex: [colliderNode],
|
|
612
|
+
motionNodeIndex: [motionNode]
|
|
613
|
+
},
|
|
614
|
+
triggerNode
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Call once after host properties and scene objects are ready. */
|
|
619
|
+
start(): void {
|
|
620
|
+
if (this.started) return;
|
|
621
|
+
this.started = true;
|
|
622
|
+
this.dispatch('event/onStart', {event: [null]});
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** Dispatch selection of one source node; the host owns hit testing and selectability. */
|
|
626
|
+
selectNode(nodeIndex: number): void {
|
|
627
|
+
this.start();
|
|
628
|
+
this.dispatch(
|
|
629
|
+
'KHR_node_selectability:event/onSelect',
|
|
630
|
+
{
|
|
631
|
+
selectedNode: [`/nodes/${nodeIndex}`],
|
|
632
|
+
selectionRayOrigin: [0, 0, 0],
|
|
633
|
+
selectionPoint: [0, 0, 0],
|
|
634
|
+
controllerIndex: [0],
|
|
635
|
+
event: [null]
|
|
636
|
+
},
|
|
637
|
+
nodeIndex
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** Tick with elapsed seconds; the first tick has timeSinceStart=0 and delta=NaN. */
|
|
642
|
+
tick(timeSeconds: number): void {
|
|
643
|
+
if (!Number.isFinite(timeSeconds)) throw new Error('KHR_interactivity: invalid tick time');
|
|
644
|
+
if (this.lastTick !== undefined && timeSeconds < this.lastTick) {
|
|
645
|
+
throw new Error('KHR_interactivity: tick time must be monotonic');
|
|
646
|
+
}
|
|
647
|
+
if (this.lastTick === undefined) {
|
|
648
|
+
this.startTime = timeSeconds;
|
|
649
|
+
const clockOffset = timeSeconds - this.currentTimeSeconds;
|
|
650
|
+
for (const delay of this.pendingDelays) delay.timeSeconds += clockOffset;
|
|
651
|
+
}
|
|
652
|
+
const delta = this.lastTick === undefined ? NaN : timeSeconds - this.lastTick;
|
|
653
|
+
this.lastTick = timeSeconds;
|
|
654
|
+
this.currentTimeSeconds = timeSeconds;
|
|
655
|
+
this.start();
|
|
656
|
+
const ready = this.pendingDelays
|
|
657
|
+
.filter(delay => delay.timeSeconds <= timeSeconds)
|
|
658
|
+
.sort((first, second) => first.timeSeconds - second.timeSeconds);
|
|
659
|
+
for (const delay of ready) {
|
|
660
|
+
if (!this.pendingDelays.includes(delay)) continue;
|
|
661
|
+
this.pendingDelays = this.pendingDelays.filter(candidate => candidate !== delay);
|
|
662
|
+
delay.activate();
|
|
663
|
+
}
|
|
664
|
+
this.dispatch('event/onTick', {
|
|
665
|
+
timeSinceStart: [timeSeconds - this.startTime],
|
|
666
|
+
timeSinceLastTick: [delta],
|
|
667
|
+
event: [null]
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Host physics contract for behavior graphs; independent of asset format and GPU backend. */
|
|
6
|
+
export type InteractivityPhysics = {
|
|
7
|
+
applyImpulse(node: number, linear: readonly number[], angular: readonly number[]): void;
|
|
8
|
+
applyPointImpulse(node: number, impulse: readonly number[], position: readonly number[]): void;
|
|
9
|
+
rayCast(
|
|
10
|
+
start: readonly number[],
|
|
11
|
+
end: readonly number[],
|
|
12
|
+
filter: number
|
|
13
|
+
): Promise<{
|
|
14
|
+
node: number;
|
|
15
|
+
fraction: number;
|
|
16
|
+
normal: readonly number[];
|
|
17
|
+
} | null>;
|
|
18
|
+
isTriggerNode(node: number): boolean;
|
|
19
|
+
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Binding, BindingsByGroup, Device} from '@luma.gl/core';
|
|
6
6
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
7
|
-
import type {TextureBindingSource} from '
|
|
7
|
+
import type {TextureBindingSource} from '@luma.gl/core/dynamic';
|
|
8
8
|
import {ShaderInputs} from '../shader-inputs';
|
|
9
9
|
import type {Material, MaterialProps} from './material';
|
|
10
10
|
import {Material as MaterialClass} from './material';
|