@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,661 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Buffer,
|
|
7
|
+
Device,
|
|
8
|
+
type BufferLayout,
|
|
9
|
+
type CommandEncoder,
|
|
10
|
+
type RenderPass
|
|
11
|
+
} from '@luma.gl/core';
|
|
12
|
+
import {
|
|
13
|
+
type GPUVectorModelInputs,
|
|
14
|
+
type GPUVectorModelDrawBatchesOptions
|
|
15
|
+
} from '../../model/gpu-vector-model';
|
|
16
|
+
import {DynamicBuffer} from '@luma.gl/core/dynamic';
|
|
17
|
+
import {Model, type ModelProps} from '../../index';
|
|
18
|
+
import type {GPUInputSchema} from '@luma.gl/graph/gpu-tables';
|
|
19
|
+
import {GPUTableShaderBindings} from '@luma.gl/graph/gpu-tables';
|
|
20
|
+
import type {GPURecordBatch} from '@luma.gl/graph/gpu-tables';
|
|
21
|
+
import {GPU_TABLE_INDEX_COLUMN_NAME} from '@luma.gl/graph/gpu-tables';
|
|
22
|
+
import {GPUTable} from '@luma.gl/graph/gpu-tables';
|
|
23
|
+
import {getGPUDataBuffersForLayout, getGPUDataByteOffsetsForLayout} from '@luma.gl/gpgpu/gpu-data';
|
|
24
|
+
|
|
25
|
+
/** Controls which Model draw count mirrors the current GPU table row count. */
|
|
26
|
+
export type GPUTableModelCount = 'instance' | 'vertex' | 'none';
|
|
27
|
+
|
|
28
|
+
/** Props for rendering one GPU table through a luma.gl Model. */
|
|
29
|
+
export type GPUTableModelProps = ModelProps & {
|
|
30
|
+
/** GPU table supplying model-ready attributes, bindings, and preserved batches. */
|
|
31
|
+
table?: GPUTable;
|
|
32
|
+
/** Controls whether table rows infer `instanceCount`, `vertexCount`, or neither. */
|
|
33
|
+
tableCount?: GPUTableModelCount;
|
|
34
|
+
/** Optional logical-column contract used to resolve constants and renamed shader inputs. */
|
|
35
|
+
gpuInputSchema?: GPUInputSchema;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type GPUTableModelDrawBatchesOptions = {
|
|
39
|
+
/** Called immediately before drawing each non-empty preserved GPU record batch. */
|
|
40
|
+
onBatch?: (batch: GPURecordBatch, batchIndex: number) => void;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type GPUTableModelState = {
|
|
44
|
+
explicitAttributes: NonNullable<ModelProps['attributes']>;
|
|
45
|
+
explicitBindings: NonNullable<ModelProps['bindings']>;
|
|
46
|
+
tableBindingNames: string[];
|
|
47
|
+
explicitBufferLayout: BufferLayout[];
|
|
48
|
+
explicitIndexBuffer: Buffer | DynamicBuffer | null;
|
|
49
|
+
explicitIndexCount: number | undefined;
|
|
50
|
+
explicitFirstVertex: number;
|
|
51
|
+
explicitFirstIndex: number;
|
|
52
|
+
explicitVertexCount: number;
|
|
53
|
+
inferInstanceCount: boolean;
|
|
54
|
+
inferVertexCount: boolean;
|
|
55
|
+
gpuInputSchema?: GPUInputSchema;
|
|
56
|
+
shaderLayout?: ModelProps['shaderLayout'];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type GPUTableModelConstructorState = {
|
|
60
|
+
table?: GPUTable;
|
|
61
|
+
modelProps: ModelProps;
|
|
62
|
+
state: GPUTableModelState;
|
|
63
|
+
shaderBindings?: GPUTableShaderBindings;
|
|
64
|
+
tableAttributeByteOffsets?: Record<string, number>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type GPUTableDrawSource = GPUTable | GPURecordBatch;
|
|
68
|
+
|
|
69
|
+
type GPUTableIndexDrawState = {
|
|
70
|
+
indexBuffer: Buffer | DynamicBuffer;
|
|
71
|
+
indexCount: number;
|
|
72
|
+
firstVertex: number;
|
|
73
|
+
firstIndex: number;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A luma.gl Model whose GPU attributes and bindings are sourced from a `GPUTable`.
|
|
78
|
+
*
|
|
79
|
+
* The table stays caller-owned. The model rebinds preserved table batches on
|
|
80
|
+
* demand and mirrors table row counts into draw counts when requested.
|
|
81
|
+
*/
|
|
82
|
+
export class GPUTableModel extends Model {
|
|
83
|
+
/** Currently bound table, when table-backed rendering is active. */
|
|
84
|
+
table?: GPUTable;
|
|
85
|
+
private readonly tableState: GPUTableModelState;
|
|
86
|
+
private tableShaderBindings?: GPUTableShaderBindings;
|
|
87
|
+
private drawingTableBatches = false;
|
|
88
|
+
|
|
89
|
+
/** Bytes owned by table-to-shader binding preparation, excluding caller-owned table buffers. */
|
|
90
|
+
get tableBindingByteLength(): number {
|
|
91
|
+
return this.tableShaderBindings?.ownedByteLength ?? 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Creates a model whose table-backed attributes and bindings can be rebound by batch. */
|
|
95
|
+
constructor(device: Device, props: GPUTableModelProps) {
|
|
96
|
+
const {table, modelProps, state, shaderBindings, tableAttributeByteOffsets} =
|
|
97
|
+
getGPUTableModelConstructorState(device, props);
|
|
98
|
+
super(device, modelProps);
|
|
99
|
+
this.table = table;
|
|
100
|
+
this.tableState = state;
|
|
101
|
+
this.tableShaderBindings = shaderBindings;
|
|
102
|
+
if (
|
|
103
|
+
modelProps.attributes &&
|
|
104
|
+
Object.values(tableAttributeByteOffsets ?? {}).some(byteOffset => byteOffset !== 0)
|
|
105
|
+
) {
|
|
106
|
+
// Model binds constructor attributes at offset 0; rebind table chunks at their row offsets.
|
|
107
|
+
this.setAttributes(modelProps.attributes, {byteOffsets: tableAttributeByteOffsets});
|
|
108
|
+
}
|
|
109
|
+
this.captureExplicitDrawState();
|
|
110
|
+
if (table) {
|
|
111
|
+
this.setTableDrawState(table);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
override destroy(): void {
|
|
116
|
+
this.tableShaderBindings?.destroy();
|
|
117
|
+
this.tableShaderBindings = undefined;
|
|
118
|
+
super.destroy();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Skips a direct draw while an empty prepared storage range is still bound. */
|
|
122
|
+
override draw(renderPass: RenderPass): boolean {
|
|
123
|
+
const firstBatch = this.tableShaderBindings?.batches[0];
|
|
124
|
+
if (
|
|
125
|
+
firstBatch?.numRows === 0 &&
|
|
126
|
+
Object.entries(firstBatch.bindings).some(
|
|
127
|
+
([name, binding]) =>
|
|
128
|
+
this.bindings[name] === binding && 'size' in binding && binding.size === 0
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return super.draw(renderPass);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Replaces the bound GPU table when one is supplied. */
|
|
137
|
+
setProps(props: Partial<GPUTableModelProps>): void {
|
|
138
|
+
if (props.table) {
|
|
139
|
+
this.setTable(props.table);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Query redraw status after synchronizing inferred table draw state. */
|
|
144
|
+
override needsRedraw(): false | string {
|
|
145
|
+
this.syncTableDrawState();
|
|
146
|
+
return super.needsRedraw();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Synchronizes inferred table draw state before opening a render pass. */
|
|
150
|
+
override predraw(commandEncoder: CommandEncoder): void {
|
|
151
|
+
this.syncTableDrawState();
|
|
152
|
+
super.predraw(commandEncoder);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Draws each preserved GPU record batch by rebinding batch-local buffers.
|
|
157
|
+
*
|
|
158
|
+
* Batches with zero rows are skipped, because their empty storage chunks would produce
|
|
159
|
+
* zero-size bindings that WebGPU rejects. The table and its batches are not modified.
|
|
160
|
+
* The table-level attributes and bindings are restored before returning.
|
|
161
|
+
*/
|
|
162
|
+
override drawBatches<Inputs extends GPUVectorModelInputs = GPUVectorModelInputs>(
|
|
163
|
+
renderPass: RenderPass,
|
|
164
|
+
options: GPUVectorModelDrawBatchesOptions<Inputs>
|
|
165
|
+
): boolean;
|
|
166
|
+
override drawBatches(renderPass: RenderPass, options?: GPUTableModelDrawBatchesOptions): boolean;
|
|
167
|
+
override drawBatches<Inputs extends GPUVectorModelInputs = GPUVectorModelInputs>(
|
|
168
|
+
renderPass: RenderPass,
|
|
169
|
+
options: GPUTableModelDrawBatchesOptions | GPUVectorModelDrawBatchesOptions<Inputs> = {}
|
|
170
|
+
): boolean {
|
|
171
|
+
if ('vectors' in options) {
|
|
172
|
+
const drawingTableBatches = this.drawingTableBatches;
|
|
173
|
+
this.drawingTableBatches = true;
|
|
174
|
+
try {
|
|
175
|
+
return super.drawBatches(renderPass, options);
|
|
176
|
+
} finally {
|
|
177
|
+
this.drawingTableBatches = drawingTableBatches;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const table = this.table;
|
|
181
|
+
if (!(table instanceof GPUTable)) {
|
|
182
|
+
throw new Error('GPUTableModel.drawBatches() requires a GPUTable');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const tableBufferLayout = this.tableShaderBindings?.bufferLayout ?? table.bufferLayout;
|
|
186
|
+
assertMatchingBufferLayouts(
|
|
187
|
+
tableBufferLayout,
|
|
188
|
+
this.tableState.explicitBufferLayout,
|
|
189
|
+
this.bufferLayout,
|
|
190
|
+
'GPUTableModel.drawBatches() model buffer layout does not match its GPU table'
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
let drawSuccess = true;
|
|
194
|
+
this.drawingTableBatches = true;
|
|
195
|
+
try {
|
|
196
|
+
for (const [batchIndex, batch] of table.batches.entries()) {
|
|
197
|
+
if (batch.numRows === 0) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const preparedBatch = this.tableShaderBindings?.batches[batchIndex];
|
|
201
|
+
if (this.tableShaderBindings && !preparedBatch) {
|
|
202
|
+
throw new Error('GPUTableModel.drawBatches() is missing prepared batch bindings');
|
|
203
|
+
}
|
|
204
|
+
this.setAttributes(
|
|
205
|
+
{
|
|
206
|
+
...this.tableState.explicitAttributes,
|
|
207
|
+
...(preparedBatch?.attributes ?? getGPUTableDrawAttributes(batch))
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
byteOffsets:
|
|
211
|
+
preparedBatch?.attributeByteOffsets ?? getGPUTableDrawAttributeByteOffsets(batch)
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
this.setBindings({
|
|
215
|
+
...this.tableState.explicitBindings,
|
|
216
|
+
...(preparedBatch?.bindings ??
|
|
217
|
+
getGPUTableDrawBindings(batch, this.tableState.tableBindingNames))
|
|
218
|
+
});
|
|
219
|
+
if (this.tableShaderBindings) {
|
|
220
|
+
this.setConstantAttributes(this.tableShaderBindings.constantAttributes);
|
|
221
|
+
}
|
|
222
|
+
this.setTableDrawState(batch);
|
|
223
|
+
options.onBatch?.(batch, batchIndex);
|
|
224
|
+
drawSuccess = super.draw(renderPass) && drawSuccess;
|
|
225
|
+
}
|
|
226
|
+
} finally {
|
|
227
|
+
this.drawingTableBatches = false;
|
|
228
|
+
this.setAttributes(
|
|
229
|
+
{
|
|
230
|
+
...this.tableState.explicitAttributes,
|
|
231
|
+
...(this.tableShaderBindings?.batches[0]?.attributes ?? getGPUTableDrawAttributes(table))
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
byteOffsets:
|
|
235
|
+
this.tableShaderBindings?.batches[0]?.attributeByteOffsets ??
|
|
236
|
+
getGPUTableDrawAttributeByteOffsets(table)
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
this.setBindings({
|
|
240
|
+
...this.tableState.explicitBindings,
|
|
241
|
+
...(this.tableShaderBindings?.batches[0]?.bindings ??
|
|
242
|
+
getGPUTableDrawBindings(table, this.tableState.tableBindingNames))
|
|
243
|
+
});
|
|
244
|
+
this.setTableDrawState(table);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return drawSuccess;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Rebinds the model to a replacement table while preserving explicit model state. */
|
|
251
|
+
protected setTable(nextTable: GPUTable): void {
|
|
252
|
+
if (this.tableState.gpuInputSchema) {
|
|
253
|
+
if (!this.tableState.shaderLayout) {
|
|
254
|
+
throw new Error('GPUTableModel gpuInputSchema requires shaderLayout');
|
|
255
|
+
}
|
|
256
|
+
if (this.tableShaderBindings) {
|
|
257
|
+
this.tableShaderBindings.updateBindings(nextTable);
|
|
258
|
+
} else {
|
|
259
|
+
this.tableShaderBindings = new GPUTableShaderBindings(this.device, {
|
|
260
|
+
table: nextTable,
|
|
261
|
+
gpuInputSchema: this.tableState.gpuInputSchema,
|
|
262
|
+
shaderLayout: this.tableState.shaderLayout
|
|
263
|
+
});
|
|
264
|
+
if (this.tableShaderBindings.shaderModule) {
|
|
265
|
+
this.tableShaderBindings.destroy();
|
|
266
|
+
this.tableShaderBindings = undefined;
|
|
267
|
+
throw new Error(
|
|
268
|
+
'GPUTableModel storage gpuInputSchema requires a table during model construction'
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const tableBufferLayout = this.tableShaderBindings?.bufferLayout ?? nextTable.bufferLayout;
|
|
274
|
+
const tableAttributes =
|
|
275
|
+
this.tableShaderBindings?.batches[0]?.attributes ?? getGPUTableDrawAttributes(nextTable);
|
|
276
|
+
const tableAttributeByteOffsets =
|
|
277
|
+
this.tableShaderBindings?.batches[0]?.attributeByteOffsets ??
|
|
278
|
+
getGPUTableDrawAttributeByteOffsets(nextTable);
|
|
279
|
+
const tableBindings =
|
|
280
|
+
this.tableShaderBindings?.batches[0]?.bindings ??
|
|
281
|
+
getGPUTableDrawBindings(nextTable, this.tableState.tableBindingNames);
|
|
282
|
+
assertNoExplicitIndexBuffer(nextTable, this.tableState.explicitIndexBuffer);
|
|
283
|
+
validateGPUTableIndexBatches(nextTable);
|
|
284
|
+
assertNoDuplicateNames(
|
|
285
|
+
Object.keys(this.tableState.explicitAttributes),
|
|
286
|
+
getBufferLayoutNames(tableBufferLayout),
|
|
287
|
+
'attribute'
|
|
288
|
+
);
|
|
289
|
+
assertNoDuplicateNames(
|
|
290
|
+
getBufferLayoutNames(this.tableState.explicitBufferLayout),
|
|
291
|
+
getBufferLayoutNames(tableBufferLayout),
|
|
292
|
+
'buffer layout'
|
|
293
|
+
);
|
|
294
|
+
assertNoDuplicateNames(
|
|
295
|
+
Object.keys(this.tableState.explicitBindings),
|
|
296
|
+
Object.keys(tableBindings),
|
|
297
|
+
'binding'
|
|
298
|
+
);
|
|
299
|
+
this.setBufferLayout([...this.tableState.explicitBufferLayout, ...tableBufferLayout]);
|
|
300
|
+
this.setAttributes(
|
|
301
|
+
{
|
|
302
|
+
...this.tableState.explicitAttributes,
|
|
303
|
+
...tableAttributes
|
|
304
|
+
},
|
|
305
|
+
{byteOffsets: tableAttributeByteOffsets}
|
|
306
|
+
);
|
|
307
|
+
this.setBindings({
|
|
308
|
+
...this.tableState.explicitBindings,
|
|
309
|
+
...tableBindings
|
|
310
|
+
});
|
|
311
|
+
if (this.tableShaderBindings) {
|
|
312
|
+
this.setConstantAttributes(this.tableShaderBindings.constantAttributes);
|
|
313
|
+
}
|
|
314
|
+
this.setTableDrawState(nextTable);
|
|
315
|
+
this.table = nextTable;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** Disables table-backed draw state and restores any explicit index buffer. */
|
|
319
|
+
protected clearTable(): void {
|
|
320
|
+
this.table = undefined;
|
|
321
|
+
this.restoreExplicitIndexDrawState();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private syncTableDrawState(): void {
|
|
325
|
+
if (!this.table || this.drawingTableBatches) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
this.setTableDrawState(this.table);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private captureExplicitDrawState(): void {
|
|
332
|
+
if (!this.tableState.explicitIndexBuffer && this.indexBuffer) {
|
|
333
|
+
this.tableState.explicitIndexBuffer = this.indexBuffer;
|
|
334
|
+
}
|
|
335
|
+
if (this.tableState.explicitIndexCount === undefined && this.indexCount !== undefined) {
|
|
336
|
+
this.tableState.explicitIndexCount = this.indexCount;
|
|
337
|
+
}
|
|
338
|
+
if (this.tableState.explicitVertexCount === 0 && this.vertexCount > 0) {
|
|
339
|
+
this.tableState.explicitVertexCount = this.vertexCount;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private setTableDrawState(source: GPUTableDrawSource): void {
|
|
344
|
+
this.setTableRowCount(source.numRows);
|
|
345
|
+
const indexDrawState = getGPUTableIndexDrawState(source);
|
|
346
|
+
if (indexDrawState) {
|
|
347
|
+
this.setTableIndexDrawState(indexDrawState);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
this.restoreExplicitIndexDrawState();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private setTableRowCount(rowCount: number): void {
|
|
354
|
+
if (this.tableState.inferInstanceCount && this.instanceCount !== rowCount) {
|
|
355
|
+
this.setInstanceCount(rowCount);
|
|
356
|
+
}
|
|
357
|
+
if (this.tableState.inferVertexCount && this.vertexCount !== rowCount) {
|
|
358
|
+
this.setVertexCount(rowCount);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private setTableIndexDrawState({
|
|
363
|
+
indexBuffer,
|
|
364
|
+
indexCount,
|
|
365
|
+
firstVertex,
|
|
366
|
+
firstIndex
|
|
367
|
+
}: GPUTableIndexDrawState): void {
|
|
368
|
+
if (this.indexBuffer !== getConcreteIndexBuffer(indexBuffer)) {
|
|
369
|
+
this.setIndexBuffer(indexBuffer);
|
|
370
|
+
}
|
|
371
|
+
if (this.indexCount !== indexCount) {
|
|
372
|
+
this.setIndexCount(indexCount);
|
|
373
|
+
}
|
|
374
|
+
if (this.firstVertex !== firstVertex || this.firstIndex !== firstIndex) {
|
|
375
|
+
this.setDrawOffsets({firstVertex, firstIndex});
|
|
376
|
+
}
|
|
377
|
+
if (this.vertexCount !== indexCount) {
|
|
378
|
+
this.setVertexCount(indexCount);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private restoreExplicitIndexDrawState(): void {
|
|
383
|
+
if (this.indexBuffer !== getConcreteIndexBuffer(this.tableState.explicitIndexBuffer)) {
|
|
384
|
+
this.setIndexBuffer(this.tableState.explicitIndexBuffer);
|
|
385
|
+
}
|
|
386
|
+
if (this.indexCount !== this.tableState.explicitIndexCount) {
|
|
387
|
+
this.setIndexCount(this.tableState.explicitIndexCount);
|
|
388
|
+
}
|
|
389
|
+
if (
|
|
390
|
+
this.firstVertex !== this.tableState.explicitFirstVertex ||
|
|
391
|
+
this.firstIndex !== this.tableState.explicitFirstIndex
|
|
392
|
+
) {
|
|
393
|
+
this.setDrawOffsets({
|
|
394
|
+
firstVertex: this.tableState.explicitFirstVertex,
|
|
395
|
+
firstIndex: this.tableState.explicitFirstIndex
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
if (
|
|
399
|
+
!this.tableState.inferVertexCount &&
|
|
400
|
+
this.vertexCount !== this.tableState.explicitVertexCount
|
|
401
|
+
) {
|
|
402
|
+
this.setVertexCount(this.tableState.explicitVertexCount);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function getGPUTableModelConstructorState(
|
|
408
|
+
device: Device,
|
|
409
|
+
props: GPUTableModelProps
|
|
410
|
+
): GPUTableModelConstructorState {
|
|
411
|
+
const {table, tableCount = 'instance', gpuInputSchema, ...modelProps} = props;
|
|
412
|
+
const explicitAttributes = modelProps.attributes || {};
|
|
413
|
+
const explicitBindings = modelProps.bindings || {};
|
|
414
|
+
const tableBindingNames = (modelProps.shaderLayout?.bindings || [])
|
|
415
|
+
.filter(binding => binding.type === 'storage' || binding.type === 'read-only-storage')
|
|
416
|
+
.map(binding => binding.name);
|
|
417
|
+
const explicitBufferLayout = modelProps.bufferLayout || [];
|
|
418
|
+
const explicitIndexBuffer = modelProps.indexBuffer ?? null;
|
|
419
|
+
const explicitIndexCount = modelProps.indexCount;
|
|
420
|
+
const explicitFirstVertex = modelProps.firstVertex ?? 0;
|
|
421
|
+
const explicitFirstIndex = modelProps.firstIndex ?? 0;
|
|
422
|
+
const explicitVertexCount = modelProps.vertexCount ?? 0;
|
|
423
|
+
const inferInstanceCount =
|
|
424
|
+
Boolean(table) && tableCount === 'instance' && modelProps.instanceCount === undefined;
|
|
425
|
+
const inferVertexCount =
|
|
426
|
+
Boolean(table) && tableCount === 'vertex' && modelProps.vertexCount === undefined;
|
|
427
|
+
|
|
428
|
+
if (!table) {
|
|
429
|
+
return {
|
|
430
|
+
table,
|
|
431
|
+
modelProps,
|
|
432
|
+
state: {
|
|
433
|
+
explicitAttributes,
|
|
434
|
+
explicitBindings,
|
|
435
|
+
tableBindingNames,
|
|
436
|
+
explicitBufferLayout,
|
|
437
|
+
explicitIndexBuffer,
|
|
438
|
+
explicitIndexCount,
|
|
439
|
+
explicitFirstVertex,
|
|
440
|
+
explicitFirstIndex,
|
|
441
|
+
explicitVertexCount,
|
|
442
|
+
inferInstanceCount,
|
|
443
|
+
inferVertexCount,
|
|
444
|
+
gpuInputSchema,
|
|
445
|
+
shaderLayout: modelProps.shaderLayout
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
assertNoExplicitIndexBuffer(table, explicitIndexBuffer);
|
|
451
|
+
validateGPUTableIndexBatches(table);
|
|
452
|
+
|
|
453
|
+
let shaderBindings: GPUTableShaderBindings | undefined;
|
|
454
|
+
if (gpuInputSchema) {
|
|
455
|
+
if (!modelProps.shaderLayout) {
|
|
456
|
+
throw new Error('GPUTableModel gpuInputSchema requires shaderLayout');
|
|
457
|
+
}
|
|
458
|
+
shaderBindings = new GPUTableShaderBindings(device, {
|
|
459
|
+
table,
|
|
460
|
+
gpuInputSchema,
|
|
461
|
+
shaderLayout: modelProps.shaderLayout
|
|
462
|
+
});
|
|
463
|
+
} else if (Object.keys(table.gpuConstants).length > 0) {
|
|
464
|
+
throw new Error('GPUTableModel constant columns require gpuInputSchema');
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const tableBufferLayout = shaderBindings?.bufferLayout ?? table.bufferLayout;
|
|
468
|
+
const tableAttributes =
|
|
469
|
+
shaderBindings?.batches[0]?.attributes ?? getGPUTableDrawAttributes(table);
|
|
470
|
+
const tableAttributeByteOffsets =
|
|
471
|
+
shaderBindings?.batches[0]?.attributeByteOffsets ?? getGPUTableDrawAttributeByteOffsets(table);
|
|
472
|
+
const tableBindings =
|
|
473
|
+
shaderBindings?.batches[0]?.bindings ?? getGPUTableDrawBindings(table, tableBindingNames);
|
|
474
|
+
|
|
475
|
+
assertNoDuplicateNames(
|
|
476
|
+
Object.keys(explicitAttributes),
|
|
477
|
+
getBufferLayoutNames(tableBufferLayout),
|
|
478
|
+
'attribute'
|
|
479
|
+
);
|
|
480
|
+
assertNoDuplicateNames(
|
|
481
|
+
getBufferLayoutNames(explicitBufferLayout),
|
|
482
|
+
getBufferLayoutNames(tableBufferLayout),
|
|
483
|
+
'buffer layout'
|
|
484
|
+
);
|
|
485
|
+
assertNoDuplicateNames(Object.keys(explicitBindings), Object.keys(tableBindings), 'binding');
|
|
486
|
+
|
|
487
|
+
return {
|
|
488
|
+
table,
|
|
489
|
+
shaderBindings,
|
|
490
|
+
tableAttributeByteOffsets,
|
|
491
|
+
state: {
|
|
492
|
+
explicitAttributes,
|
|
493
|
+
explicitBindings,
|
|
494
|
+
tableBindingNames,
|
|
495
|
+
explicitBufferLayout,
|
|
496
|
+
explicitIndexBuffer,
|
|
497
|
+
explicitIndexCount,
|
|
498
|
+
explicitFirstVertex,
|
|
499
|
+
explicitFirstIndex,
|
|
500
|
+
explicitVertexCount,
|
|
501
|
+
inferInstanceCount,
|
|
502
|
+
inferVertexCount,
|
|
503
|
+
gpuInputSchema,
|
|
504
|
+
shaderLayout: modelProps.shaderLayout
|
|
505
|
+
},
|
|
506
|
+
modelProps: {
|
|
507
|
+
...modelProps,
|
|
508
|
+
modules: shaderBindings?.shaderModule
|
|
509
|
+
? [...(modelProps.modules ?? []), shaderBindings.shaderModule]
|
|
510
|
+
: modelProps.modules,
|
|
511
|
+
bufferLayout: [...explicitBufferLayout, ...tableBufferLayout],
|
|
512
|
+
attributes: {...explicitAttributes, ...tableAttributes},
|
|
513
|
+
constantAttributes: {
|
|
514
|
+
...(modelProps.constantAttributes || {}),
|
|
515
|
+
...(shaderBindings?.constantAttributes || {})
|
|
516
|
+
},
|
|
517
|
+
bindings: {
|
|
518
|
+
...explicitBindings,
|
|
519
|
+
...tableBindings
|
|
520
|
+
},
|
|
521
|
+
...(inferInstanceCount ? {instanceCount: table.numRows} : {}),
|
|
522
|
+
...(inferVertexCount ? {vertexCount: table.numRows} : {})
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function getGPUTableDrawBindings(
|
|
528
|
+
source: GPUTableDrawSource,
|
|
529
|
+
bindingNames: string[]
|
|
530
|
+
): Record<string, Buffer | DynamicBuffer> {
|
|
531
|
+
const batch = source instanceof GPUTable ? source.batches[0] : source;
|
|
532
|
+
if (!batch) {
|
|
533
|
+
return {};
|
|
534
|
+
}
|
|
535
|
+
const bindings: Record<string, Buffer | DynamicBuffer> = {};
|
|
536
|
+
for (const bindingName of bindingNames) {
|
|
537
|
+
const data = batch.gpuData[bindingName];
|
|
538
|
+
if (data) {
|
|
539
|
+
bindings[bindingName] = data.buffer;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return bindings;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function getGPUTableDrawAttributes(
|
|
546
|
+
source: GPUTableDrawSource
|
|
547
|
+
): Record<string, Buffer | DynamicBuffer> {
|
|
548
|
+
const attributeSource = source instanceof GPUTable ? source.batches[0] : source;
|
|
549
|
+
if (!attributeSource) {
|
|
550
|
+
return {};
|
|
551
|
+
}
|
|
552
|
+
return getGPUDataBuffersForLayout(attributeSource.bufferLayout, attributeSource.gpuData);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function getGPUTableDrawAttributeByteOffsets(source: GPUTableDrawSource): Record<string, number> {
|
|
556
|
+
const attributeSource = source instanceof GPUTable ? source.batches[0] : source;
|
|
557
|
+
if (!attributeSource) {
|
|
558
|
+
return {};
|
|
559
|
+
}
|
|
560
|
+
return getGPUDataByteOffsetsForLayout(attributeSource.bufferLayout, attributeSource.gpuData);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function getBufferLayoutNames(bufferLayout: BufferLayout[]): string[] {
|
|
564
|
+
return bufferLayout.map(layout => layout.name);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function assertNoDuplicateNames(
|
|
568
|
+
explicitNames: string[],
|
|
569
|
+
tableNames: string[],
|
|
570
|
+
nameType: string
|
|
571
|
+
): void {
|
|
572
|
+
const explicitNameSet = new Set(explicitNames);
|
|
573
|
+
for (const tableName of tableNames) {
|
|
574
|
+
if (explicitNameSet.has(tableName)) {
|
|
575
|
+
throw new Error(
|
|
576
|
+
`GPUTableModel ${nameType} "${tableName}" duplicates an explicit ${nameType}`
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function assertNoExplicitIndexBuffer(
|
|
583
|
+
table: Pick<GPUTable, 'gpuVectors'>,
|
|
584
|
+
explicitIndexBuffer: Buffer | DynamicBuffer | null
|
|
585
|
+
): void {
|
|
586
|
+
if (explicitIndexBuffer && table.gpuVectors[GPU_TABLE_INDEX_COLUMN_NAME]) {
|
|
587
|
+
throw new Error('GPUTableModel indices column duplicates an explicit indexBuffer');
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function validateGPUTableIndexBatches(table: GPUTable): void {
|
|
592
|
+
const tableHasIndices = Boolean(table.gpuVectors[GPU_TABLE_INDEX_COLUMN_NAME]);
|
|
593
|
+
for (const batch of table.batches) {
|
|
594
|
+
const batchHasIndices = Boolean(batch.gpuData[GPU_TABLE_INDEX_COLUMN_NAME]);
|
|
595
|
+
if (batchHasIndices !== tableHasIndices) {
|
|
596
|
+
throw new Error('GPUTableModel indexed tables require every batch to include indices');
|
|
597
|
+
}
|
|
598
|
+
getGPUTableIndexDrawState(batch);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function getGPUTableIndexDrawState(source: GPUTableDrawSource): GPUTableIndexDrawState | null {
|
|
603
|
+
const indexData =
|
|
604
|
+
source instanceof GPUTable
|
|
605
|
+
? source.gpuVectors[GPU_TABLE_INDEX_COLUMN_NAME]?.data[0]
|
|
606
|
+
: source.gpuData[GPU_TABLE_INDEX_COLUMN_NAME];
|
|
607
|
+
if (!indexData) {
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
if (source instanceof GPUTable && source.batches.length > 1) {
|
|
611
|
+
return null;
|
|
612
|
+
}
|
|
613
|
+
if (indexData.format !== 'vertex-list<uint32>') {
|
|
614
|
+
throw new Error('GPUTableModel indices column requires vertex-list<uint32> format');
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (
|
|
618
|
+
source instanceof GPUTable &&
|
|
619
|
+
source.gpuVectors[GPU_TABLE_INDEX_COLUMN_NAME].data.length !== 1
|
|
620
|
+
) {
|
|
621
|
+
throw new Error('GPUTableModel indices column requires exactly one GPUData chunk');
|
|
622
|
+
}
|
|
623
|
+
const indexBuffer = indexData.buffer;
|
|
624
|
+
const concreteIndexBuffer = getConcreteIndexBuffer(indexBuffer);
|
|
625
|
+
if (!concreteIndexBuffer || !(concreteIndexBuffer.usage & Buffer.INDEX)) {
|
|
626
|
+
throw new Error('GPUTableModel indices column requires Buffer.INDEX usage');
|
|
627
|
+
}
|
|
628
|
+
const indexByteStride = concreteIndexBuffer.indexType === 'uint32' ? 4 : 2;
|
|
629
|
+
if (indexData.byteOffset % indexByteStride !== 0) {
|
|
630
|
+
throw new Error('GPUTableModel indices column byteOffset must align with its index type');
|
|
631
|
+
}
|
|
632
|
+
return {
|
|
633
|
+
indexBuffer,
|
|
634
|
+
indexCount: indexData.valueLength,
|
|
635
|
+
firstVertex: indexData.byteOffset,
|
|
636
|
+
firstIndex: indexData.byteOffset / indexByteStride
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function getConcreteIndexBuffer(indexBuffer: Buffer | DynamicBuffer | null): Buffer | null {
|
|
641
|
+
return indexBuffer instanceof DynamicBuffer ? indexBuffer.buffer : indexBuffer;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function assertMatchingBufferLayouts(
|
|
645
|
+
tableBufferLayout: BufferLayout[],
|
|
646
|
+
explicitBufferLayout: BufferLayout[],
|
|
647
|
+
candidateBufferLayout: BufferLayout[],
|
|
648
|
+
errorMessage: string
|
|
649
|
+
): void {
|
|
650
|
+
const expectedBufferLayout = [...explicitBufferLayout, ...tableBufferLayout];
|
|
651
|
+
if (!deepEqualBufferLayouts(expectedBufferLayout, candidateBufferLayout)) {
|
|
652
|
+
throw new Error(errorMessage);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function deepEqualBufferLayouts(
|
|
657
|
+
expectedBufferLayout: BufferLayout[],
|
|
658
|
+
candidateBufferLayout: BufferLayout[]
|
|
659
|
+
): boolean {
|
|
660
|
+
return JSON.stringify(expectedBufferLayout) === JSON.stringify(candidateBufferLayout);
|
|
661
|
+
}
|