@luma.gl/engine 10.0.0-alpha.3 → 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 +11517 -6015
- 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/edge-geometry.d.ts +3 -2
- package/dist/geometry/edge-geometry.d.ts.map +1 -1
- package/dist/geometry/edge-geometry.js.map +1 -1
- package/dist/geometry/geometry-primitives.cjs +189 -0
- package/dist/geometry/geometry-primitives.d.ts +60 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -0
- package/dist/geometry/geometry-primitives.js +161 -0
- package/dist/geometry/geometry-primitives.js.map +1 -0
- package/dist/geometry/geometry-table.cjs +15 -0
- package/dist/geometry/geometry-utils.cjs +147 -0
- package/dist/geometry/geometry-utils.d.ts +7 -15
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +9 -55
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.cjs +90 -0
- package/dist/geometry/geometry.d.ts +9 -69
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +27 -93
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.cjs +130 -0
- package/dist/geometry/gpu-geometry.d.ts +4 -2
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +3 -3
- package/dist/geometry/gpu-geometry.js.map +1 -1
- 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 -10629
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +46 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -10
- 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 +22 -306
- 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/clip-space.d.ts +4 -1
- package/dist/models/clip-space.d.ts.map +1 -1
- package/dist/models/clip-space.js +16 -13
- package/dist/models/clip-space.js.map +1 -1
- package/dist/models/directional-light-model.cjs +45 -0
- package/dist/models/directional-light-model.js +1 -1
- package/dist/models/directional-light-model.js.map +1 -1
- package/dist/models/light-model-utils.cjs +426 -0
- package/dist/models/point-light-model.cjs +44 -0
- package/dist/models/point-light-model.js +1 -1
- package/dist/models/point-light-model.js.map +1 -1
- package/dist/models/spot-light-model.cjs +45 -0
- package/dist/models/spot-light-model.js +1 -1
- package/dist/models/spot-light-model.js.map +1 -1
- 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 +47 -8
- 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/edge-geometry.ts +7 -3
- package/src/geometry/geometry-primitives.ts +226 -0
- package/src/geometry/geometry-utils.ts +16 -71
- package/src/geometry/geometry.ts +36 -163
- package/src/geometry/gpu-geometry.ts +9 -4
- 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 +144 -27
- 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/models/clip-space.ts +21 -14
- package/src/models/directional-light-model.ts +1 -1
- package/src/models/point-light-model.ts +1 -1
- package/src/models/spot-light-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/dist/geometries/cone-geometry.d.ts +0 -12
- package/dist/geometries/cone-geometry.d.ts.map +0 -1
- package/dist/geometries/cone-geometry.js +0 -19
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.d.ts +0 -14
- package/dist/geometries/cube-geometry.d.ts.map +0 -1
- package/dist/geometries/cube-geometry.js +0 -222
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.d.ts +0 -11
- package/dist/geometries/cylinder-geometry.d.ts.map +0 -1
- package/dist/geometries/cylinder-geometry.js +0 -17
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +0 -11
- package/dist/geometries/ico-sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js +0 -158
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.d.ts +0 -20
- package/dist/geometries/plane-geometry.d.ts.map +0 -1
- package/dist/geometries/plane-geometry.js +0 -106
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.d.ts +0 -12
- package/dist/geometries/sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/sphere-geometry.js +0 -88
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +0 -23
- package/dist/geometries/truncated-cone-geometry.d.ts.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js +0 -112
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/src/compute/kernel.ts +0 -146
- package/src/compute/render-kernel.ts +0 -192
- package/src/geometries/cone-geometry.ts +0 -31
- package/src/geometries/cube-geometry.ts +0 -258
- package/src/geometries/cylinder-geometry.ts +0 -28
- package/src/geometries/ico-sphere-geometry.ts +0 -193
- package/src/geometries/plane-geometry.ts +0 -142
- package/src/geometries/sphere-geometry.ts +0 -113
- package/src/geometries/truncated-cone-geometry.ts +0 -145
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {GPUPathStorageInputProps} from '@luma.gl/graph/experimental/models';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Buffer,
|
|
9
|
+
type Binding,
|
|
10
|
+
type BufferLayout,
|
|
11
|
+
type Device,
|
|
12
|
+
type RenderPass,
|
|
13
|
+
type ShaderLayout
|
|
14
|
+
} from '@luma.gl/core';
|
|
15
|
+
import {DynamicBuffer} from '@luma.gl/core/dynamic';
|
|
16
|
+
import {Model, type ModelProps} from '../../../index';
|
|
17
|
+
import {GPUVector} from '@luma.gl/gpgpu/gpu-data';
|
|
18
|
+
import {type GPUVectorFormat} from '@luma.gl/gpgpu/gpu-data';
|
|
19
|
+
import {planGeneratedBufferBatches} from '@luma.gl/graph/gpu-tables';
|
|
20
|
+
import {
|
|
21
|
+
createGpuPathExpansionInput,
|
|
22
|
+
createGpuPathGeneratedState,
|
|
23
|
+
createGpuPathRangeState,
|
|
24
|
+
dispatchGpuPathExpansionCompute
|
|
25
|
+
} from '@luma.gl/graph/experimental/models';
|
|
26
|
+
import {
|
|
27
|
+
resolvePathStorageInputs,
|
|
28
|
+
type PathStorageBatchInputs
|
|
29
|
+
} from '@luma.gl/graph/experimental/models';
|
|
30
|
+
import type {GPUInputSchema} from '@luma.gl/graph/gpu-tables';
|
|
31
|
+
|
|
32
|
+
const SEGMENT_START_POINT_INDICES_COLUMN = 'segmentStartPointIndices';
|
|
33
|
+
const SEGMENT_END_POINT_INDICES_COLUMN = 'segmentEndPointIndices';
|
|
34
|
+
const SEGMENT_PREVIOUS_POINT_INDICES_COLUMN = 'segmentPreviousPointIndices';
|
|
35
|
+
const SEGMENT_NEXT_POINT_INDICES_COLUMN = 'segmentNextPointIndices';
|
|
36
|
+
const SEGMENT_FLAGS_COLUMN = 'segmentFlags';
|
|
37
|
+
const ROW_INDICES_COLUMN = 'rowIndices';
|
|
38
|
+
const COMPACT_PATH_VERTEX_DATA = 'compactPathVertexData';
|
|
39
|
+
const PATH_RANGES_COLUMN = 'pathRanges';
|
|
40
|
+
const PATH_VIEW_ORIGINS_COLUMN = 'pathViewOrigins';
|
|
41
|
+
|
|
42
|
+
const COMPACT_PATH_VERTEX_BYTE_STRIDE = Uint32Array.BYTES_PER_ELEMENT * 3;
|
|
43
|
+
const LEGACY_PATH_VERTEX_BYTE_STRIDE = Uint32Array.BYTES_PER_ELEMENT * 6;
|
|
44
|
+
const LEGACY_SEGMENT_END_POINT_INDICES_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT;
|
|
45
|
+
const LEGACY_SEGMENT_PREVIOUS_POINT_INDICES_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT * 2;
|
|
46
|
+
const LEGACY_SEGMENT_NEXT_POINT_INDICES_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT * 3;
|
|
47
|
+
const LEGACY_SEGMENT_FLAGS_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT * 4;
|
|
48
|
+
const LEGACY_ROW_INDICES_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT * 5;
|
|
49
|
+
const COMPACT_SEGMENT_FLAGS_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT;
|
|
50
|
+
const COMPACT_ROW_INDICES_BYTE_OFFSET = Uint32Array.BYTES_PER_ELEMENT * 2;
|
|
51
|
+
|
|
52
|
+
const DEFAULT_PATH_STORAGE_COLOR: [number, number, number, number] = [255, 255, 255, 255];
|
|
53
|
+
const DEFAULT_PATH_STORAGE_WIDTH = 1;
|
|
54
|
+
|
|
55
|
+
/** Prepared GPU inputs consumed by the storage-backed path model. */
|
|
56
|
+
export const PATH_STORAGE_GPU_INPUT_SCHEMA = [
|
|
57
|
+
{
|
|
58
|
+
columnName: 'paths',
|
|
59
|
+
kind: 'positions',
|
|
60
|
+
required: true,
|
|
61
|
+
formats: ['vertex-list<float32x2>', 'vertex-list<float32x3>', 'vertex-list<float32x4>']
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
columnName: 'colors',
|
|
65
|
+
kind: 'colors',
|
|
66
|
+
required: false,
|
|
67
|
+
formats: ['unorm8x4', 'vertex-list<unorm8x4>']
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
columnName: 'widths',
|
|
71
|
+
kind: 'scalars',
|
|
72
|
+
required: false,
|
|
73
|
+
formats: ['float32']
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
columnName: 'timestamps',
|
|
77
|
+
kind: 'time',
|
|
78
|
+
required: false,
|
|
79
|
+
formats: ['vertex-list<float32>']
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
columnName: 'viewOrigins',
|
|
83
|
+
kind: 'positions',
|
|
84
|
+
required: false,
|
|
85
|
+
formats: ['float32x4'],
|
|
86
|
+
internal: true
|
|
87
|
+
}
|
|
88
|
+
] as const satisfies GPUInputSchema;
|
|
89
|
+
|
|
90
|
+
type PathStorageOwnedResource =
|
|
91
|
+
| Pick<GPUVector, 'destroy'>
|
|
92
|
+
| Pick<DynamicBuffer, 'destroy'>
|
|
93
|
+
| Pick<Buffer, 'destroy'>;
|
|
94
|
+
type PathStorageRecordMode = 'compact' | 'legacy';
|
|
95
|
+
|
|
96
|
+
const DEFAULT_PATH_STORAGE_SHADER_LAYOUT: ShaderLayout = {
|
|
97
|
+
attributes: [
|
|
98
|
+
{name: SEGMENT_START_POINT_INDICES_COLUMN, location: 0, type: 'u32', stepMode: 'instance'},
|
|
99
|
+
{name: SEGMENT_FLAGS_COLUMN, location: 1, type: 'u32', stepMode: 'instance'},
|
|
100
|
+
{name: ROW_INDICES_COLUMN, location: 2, type: 'u32', stepMode: 'instance'}
|
|
101
|
+
],
|
|
102
|
+
bindings: []
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const DEFAULT_PATH_STORAGE_SOURCE = /* wgsl */ `
|
|
106
|
+
@group(0) @binding(auto) var<storage, read> pathValues : array<f32>;
|
|
107
|
+
@group(0) @binding(auto) var<storage, read> pathRanges : array<vec4<u32>>;
|
|
108
|
+
@group(0) @binding(auto) var<storage, read> pathViewOrigins : array<vec4<f32>>;
|
|
109
|
+
@group(0) @binding(auto) var<storage, read> pathRowColors : array<u32>;
|
|
110
|
+
@group(0) @binding(auto) var<storage, read> pathVertexColors : array<u32>;
|
|
111
|
+
@group(0) @binding(auto) var<storage, read> pathRowWidths : array<f32>;
|
|
112
|
+
|
|
113
|
+
struct PathStorageStyleConfig {
|
|
114
|
+
constantColor : vec4<f32>,
|
|
115
|
+
constantWidth : f32,
|
|
116
|
+
useRowColors : u32,
|
|
117
|
+
useRowWidths : u32,
|
|
118
|
+
batchRowIndexBase : u32,
|
|
119
|
+
pathComponentCount : u32,
|
|
120
|
+
useViewOrigins : u32,
|
|
121
|
+
useVertexColors : u32,
|
|
122
|
+
_padding1 : u32,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
@group(0) @binding(auto) var<uniform> pathStorageStyleConfig : PathStorageStyleConfig;
|
|
126
|
+
|
|
127
|
+
struct VertexInputs {
|
|
128
|
+
@builtin(vertex_index) vertexIndex : u32,
|
|
129
|
+
@location(0) segmentStartPointIndices : u32,
|
|
130
|
+
@location(1) segmentFlags : u32,
|
|
131
|
+
@location(2) rowIndices : u32,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
struct FragmentInputs {
|
|
135
|
+
@builtin(position) position : vec4<f32>,
|
|
136
|
+
@location(0) color : vec4<f32>,
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
fn unpackPathColor(colorWord: u32) -> vec4<f32> {
|
|
140
|
+
return vec4<f32>(
|
|
141
|
+
f32(colorWord & 0xffu),
|
|
142
|
+
f32((colorWord >> 8u) & 0xffu),
|
|
143
|
+
f32((colorWord >> 16u) & 0xffu),
|
|
144
|
+
f32((colorWord >> 24u) & 0xffu)
|
|
145
|
+
) / 255.0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fn readPathComponent(pointIndex: u32, componentIndex: u32) -> f32 {
|
|
149
|
+
if (componentIndex >= pathStorageStyleConfig.pathComponentCount) {
|
|
150
|
+
return 0.0;
|
|
151
|
+
}
|
|
152
|
+
return pathValues[pointIndex * pathStorageStyleConfig.pathComponentCount + componentIndex];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
fn readPathPoint(pointIndex: u32) -> vec4<f32> {
|
|
156
|
+
return vec4<f32>(
|
|
157
|
+
readPathComponent(pointIndex, 0u),
|
|
158
|
+
readPathComponent(pointIndex, 1u),
|
|
159
|
+
readPathComponent(pointIndex, 2u),
|
|
160
|
+
readPathComponent(pointIndex, 3u)
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn readPathRange(globalRowIndex: u32) -> vec4<u32> {
|
|
165
|
+
return pathRanges[globalRowIndex - pathStorageStyleConfig.batchRowIndexBase];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fn readPathViewOrigin(rowIndex: u32) -> vec4<f32> {
|
|
169
|
+
if (pathStorageStyleConfig.useViewOrigins == 0u) {
|
|
170
|
+
return vec4<f32>(0.0);
|
|
171
|
+
}
|
|
172
|
+
return pathViewOrigins[rowIndex];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@vertex
|
|
176
|
+
fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
177
|
+
let rowIndex = inputs.rowIndices - pathStorageStyleConfig.batchRowIndexBase;
|
|
178
|
+
let pathRange = readPathRange(inputs.rowIndices);
|
|
179
|
+
let segmentEndPointIndex = min(inputs.segmentStartPointIndices + 1u, pathRange.y - 1u);
|
|
180
|
+
let pathWidth = select(
|
|
181
|
+
pathStorageStyleConfig.constantWidth,
|
|
182
|
+
pathRowWidths[rowIndex],
|
|
183
|
+
pathStorageStyleConfig.useRowWidths != 0u
|
|
184
|
+
);
|
|
185
|
+
let pathPosition = select(
|
|
186
|
+
readPathPoint(inputs.segmentStartPointIndices),
|
|
187
|
+
readPathPoint(segmentEndPointIndex),
|
|
188
|
+
(inputs.vertexIndex & 1u) == 1u
|
|
189
|
+
) + readPathViewOrigin(rowIndex);
|
|
190
|
+
var outputs : FragmentInputs;
|
|
191
|
+
outputs.position = vec4<f32>(
|
|
192
|
+
pathPosition.xyz + vec3<f32>(0.0, 0.0, pathWidth * 0.0),
|
|
193
|
+
1.0
|
|
194
|
+
);
|
|
195
|
+
outputs.color = pathStorageStyleConfig.constantColor;
|
|
196
|
+
if (pathStorageStyleConfig.useVertexColors != 0u) {
|
|
197
|
+
outputs.color = mix(
|
|
198
|
+
unpackPathColor(pathVertexColors[inputs.segmentStartPointIndices]),
|
|
199
|
+
unpackPathColor(pathVertexColors[segmentEndPointIndex]),
|
|
200
|
+
f32(inputs.vertexIndex & 1u)
|
|
201
|
+
);
|
|
202
|
+
} else if (pathStorageStyleConfig.useRowColors != 0u) {
|
|
203
|
+
outputs.color = unpackPathColor(pathRowColors[rowIndex]);
|
|
204
|
+
}
|
|
205
|
+
return outputs;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@fragment
|
|
209
|
+
fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4<f32> {
|
|
210
|
+
return inputs.color;
|
|
211
|
+
}
|
|
212
|
+
`;
|
|
213
|
+
|
|
214
|
+
/** GPU vectors used by the storage-backed path model. */
|
|
215
|
+
export type PathStorageInputProps = Omit<ModelProps, 'instanceCount'> & GPUPathStorageInputProps;
|
|
216
|
+
|
|
217
|
+
type PathStorageRenderProps = Omit<
|
|
218
|
+
PathStorageInputProps,
|
|
219
|
+
'paths' | 'colors' | 'widths' | 'viewOrigins' | 'color' | 'width'
|
|
220
|
+
>;
|
|
221
|
+
|
|
222
|
+
/** Per-source-batch storage bindings retained by {@link PathStorageState}. */
|
|
223
|
+
export type PathStorageBatchState = {
|
|
224
|
+
/** Global source path row index assigned to local row zero. */
|
|
225
|
+
batchRowIndexBase: number;
|
|
226
|
+
/** Source path rows included in this storage batch. */
|
|
227
|
+
rowCount: number;
|
|
228
|
+
/** Generated segment records drawn from this storage batch. */
|
|
229
|
+
segmentCount: number;
|
|
230
|
+
/** Read-only storage binding for flattened prepared path values. */
|
|
231
|
+
pathValuesBinding: Binding;
|
|
232
|
+
/** Read-only storage binding for persistent per-path ranges. */
|
|
233
|
+
pathRangesBinding: Binding;
|
|
234
|
+
/** Read-only storage binding for Float32 path view origins. */
|
|
235
|
+
pathViewOriginsBinding: Binding;
|
|
236
|
+
/** Read-only storage binding for packed per-row RGBA8 path colors. */
|
|
237
|
+
rowColorsBinding: Binding;
|
|
238
|
+
/** Read-only storage binding for packed per-vertex RGBA8 path colors. */
|
|
239
|
+
vertexColorsBinding: Binding;
|
|
240
|
+
/** Read-only storage binding for Float32 path widths. */
|
|
241
|
+
rowWidthsBinding: Binding;
|
|
242
|
+
/** Optional read-only storage binding for prepared Float32 path timestamps. */
|
|
243
|
+
pathTimestampsBinding?: Binding;
|
|
244
|
+
/** Uniform buffer selecting row style bindings and path component count. */
|
|
245
|
+
styleConfigBuffer: DynamicBuffer;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/** Generated storage path render-batch state. */
|
|
249
|
+
export type PathStorageRenderBatchState = {
|
|
250
|
+
/** Source storage batch whose row bindings feed this generated render batch. */
|
|
251
|
+
rowBindingBatchIndex: number;
|
|
252
|
+
/** First source path row included in this generated render batch. */
|
|
253
|
+
rowStart: number;
|
|
254
|
+
/** Source path row after the last row included in this generated render batch. */
|
|
255
|
+
rowEnd: number;
|
|
256
|
+
/** Generated segment records drawn by this render batch. */
|
|
257
|
+
segmentCount: number;
|
|
258
|
+
/** Generated compact or legacy path segment vertex buffer. */
|
|
259
|
+
compactPathVertexData: Buffer;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/** Reusable WebGPU storage path expansion and row-binding state. */
|
|
263
|
+
export type PathStorageState = {
|
|
264
|
+
/** Generated segment records across all preserved render batches. */
|
|
265
|
+
segmentCount: number;
|
|
266
|
+
/** CPU time spent constructing persistent path range metadata. */
|
|
267
|
+
pathRangeBuildTimeMs: number;
|
|
268
|
+
/** Bytes occupied by persistent per-path range buffers. */
|
|
269
|
+
pathRangeByteLength: number;
|
|
270
|
+
/** Bytes occupied by one generated path segment record. */
|
|
271
|
+
pathRecordByteStride: number;
|
|
272
|
+
/** Logical bytes occupied by the first generated path segment buffer. */
|
|
273
|
+
compactPathVertexByteLength: number;
|
|
274
|
+
/** Logical bytes occupied by all generated path segment buffers. */
|
|
275
|
+
generatedRenderBufferByteLength: number;
|
|
276
|
+
/** Bytes occupied by retained row style/default binding resources. */
|
|
277
|
+
rowStorageByteLength: number;
|
|
278
|
+
/** Bytes occupied by transient compute input buffers released after expansion. */
|
|
279
|
+
transientComputeInputByteLength: number;
|
|
280
|
+
/** Per-source-batch storage bindings and persistent range state. */
|
|
281
|
+
batches: PathStorageBatchState[];
|
|
282
|
+
/** Generated render batches preserved for device buffer-size limits. */
|
|
283
|
+
renderBatches: PathStorageRenderBatchState[];
|
|
284
|
+
/** Row/default binding resources owned by this storage state. */
|
|
285
|
+
ownedRowBindingResources: PathStorageOwnedResource[];
|
|
286
|
+
/** First batch packed per-row RGBA8 color binding. */
|
|
287
|
+
rowColorsBinding: Binding;
|
|
288
|
+
/** First batch packed per-vertex RGBA8 color binding. */
|
|
289
|
+
vertexColorsBinding: Binding;
|
|
290
|
+
/** First batch Float32 path width binding. */
|
|
291
|
+
rowWidthsBinding: Binding;
|
|
292
|
+
/** First batch path style config uniform buffer. */
|
|
293
|
+
styleConfigBuffer: DynamicBuffer;
|
|
294
|
+
/** First generated compact or legacy path segment vertex buffer. */
|
|
295
|
+
compactPathVertexData: Buffer;
|
|
296
|
+
/** Releases owned generated path, range, and row-binding resources. */
|
|
297
|
+
destroy: () => void;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/** Props for constructing or rebinding a WebGPU storage-backed path model. */
|
|
301
|
+
export type PathStorageModelProps =
|
|
302
|
+
| (PathStorageInputProps & {storageState?: never})
|
|
303
|
+
| (PathStorageRenderProps & {storageState: PathStorageState});
|
|
304
|
+
|
|
305
|
+
type PathStorageDefaultBindings = {
|
|
306
|
+
colorsBinding: Binding;
|
|
307
|
+
vertexColorsBinding: Binding;
|
|
308
|
+
widthsBinding: Binding;
|
|
309
|
+
viewOriginsBinding: Binding;
|
|
310
|
+
byteLength: number;
|
|
311
|
+
ownedResources: PathStorageOwnedResource[];
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
type PathStorageBatchRowState = {
|
|
315
|
+
pathViewOriginsBinding: Binding;
|
|
316
|
+
rowColorsBinding: Binding;
|
|
317
|
+
vertexColorsBinding: Binding;
|
|
318
|
+
rowWidthsBinding: Binding;
|
|
319
|
+
styleConfigBuffer: DynamicBuffer;
|
|
320
|
+
ownedResources: PathStorageOwnedResource[];
|
|
321
|
+
ownedByteLength: number;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* WebGPU-only path model that expands variable-length GPU path rows through compute,
|
|
326
|
+
* while keeping per-row style values as storage-buffer reads during rendering.
|
|
327
|
+
*/
|
|
328
|
+
export class PathStorageModel extends Model {
|
|
329
|
+
/** Prepared GPU vectors consumed by the storage-backed path model. */
|
|
330
|
+
static readonly gpuInputSchema: GPUInputSchema = PATH_STORAGE_GPU_INPUT_SCHEMA;
|
|
331
|
+
|
|
332
|
+
/** Generated segment records across all preserved render batches. */
|
|
333
|
+
segmentCount!: number;
|
|
334
|
+
/** CPU time spent constructing persistent path range metadata. */
|
|
335
|
+
pathRangeBuildTimeMs!: number;
|
|
336
|
+
/** Bytes occupied by persistent per-path range buffers. */
|
|
337
|
+
pathRangeByteLength!: number;
|
|
338
|
+
/** Bytes occupied by one generated path segment record. */
|
|
339
|
+
pathRecordByteStride!: number;
|
|
340
|
+
/** Logical bytes occupied by the first generated path segment buffer. */
|
|
341
|
+
compactPathVertexByteLength!: number;
|
|
342
|
+
/** Logical bytes occupied by all generated path segment buffers. */
|
|
343
|
+
generatedRenderBufferByteLength!: number;
|
|
344
|
+
/** Bytes occupied by retained row style/default binding resources. */
|
|
345
|
+
rowStorageByteLength!: number;
|
|
346
|
+
/** Bytes occupied by transient compute input buffers released after expansion. */
|
|
347
|
+
transientComputeInputByteLength!: number;
|
|
348
|
+
/** Per-source-batch storage bindings and persistent range state. */
|
|
349
|
+
batches!: PathStorageBatchState[];
|
|
350
|
+
/** Generated render batches preserved for device buffer-size limits. */
|
|
351
|
+
renderBatches!: PathStorageRenderBatchState[];
|
|
352
|
+
/** First batch packed per-row RGBA8 color binding. */
|
|
353
|
+
rowColorsBinding!: Binding;
|
|
354
|
+
/** First batch packed per-vertex RGBA8 color binding. */
|
|
355
|
+
vertexColorsBinding!: Binding;
|
|
356
|
+
/** First batch Float32 path width binding. */
|
|
357
|
+
rowWidthsBinding!: Binding;
|
|
358
|
+
/** First batch path style config uniform buffer. */
|
|
359
|
+
styleConfigBuffer!: DynamicBuffer;
|
|
360
|
+
/** First generated compact or legacy path segment vertex buffer. */
|
|
361
|
+
compactPathVertexData!: Buffer;
|
|
362
|
+
/** Reusable storage path expansion and row-binding state currently bound by the model. */
|
|
363
|
+
storageState: PathStorageState;
|
|
364
|
+
private pathProps: PathStorageModelProps;
|
|
365
|
+
private ownsStorageState: boolean;
|
|
366
|
+
|
|
367
|
+
/** Creates a WebGPU storage-backed path model. */
|
|
368
|
+
constructor(device: Device, props: PathStorageModelProps) {
|
|
369
|
+
if (device.type !== 'webgpu') {
|
|
370
|
+
throw new Error('PathStorageModel is WebGPU-only');
|
|
371
|
+
}
|
|
372
|
+
const ownsStorageState = !hasPathStorageState(props);
|
|
373
|
+
const storageState = ownsStorageState
|
|
374
|
+
? createPathStorageState(device, props)
|
|
375
|
+
: props.storageState;
|
|
376
|
+
super(device, createPathStorageModelProps(props, storageState));
|
|
377
|
+
this.pathProps = props;
|
|
378
|
+
this.storageState = storageState;
|
|
379
|
+
this.ownsStorageState = ownsStorageState;
|
|
380
|
+
this.applyStorageState(storageState);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** Updates storage path props, rebuilding state only when path/layout inputs change. */
|
|
384
|
+
setProps(props: Partial<PathStorageModelProps>): void {
|
|
385
|
+
const nextProps = {...this.pathProps, ...props} as PathStorageModelProps;
|
|
386
|
+
const nextUsesExternalState = hasPathStorageState(nextProps);
|
|
387
|
+
const pathProps = props as Partial<PathStorageInputProps>;
|
|
388
|
+
const shouldReplaceExternalState = 'storageState' in props && props.storageState !== undefined;
|
|
389
|
+
const shouldReplaceState =
|
|
390
|
+
shouldReplaceExternalState ||
|
|
391
|
+
pathProps.paths !== undefined ||
|
|
392
|
+
pathProps.shaderLayout !== undefined ||
|
|
393
|
+
pathProps.rowIndexBase !== undefined;
|
|
394
|
+
const shouldRefreshRowBindings =
|
|
395
|
+
!nextUsesExternalState &&
|
|
396
|
+
(pathProps.colors !== undefined ||
|
|
397
|
+
pathProps.widths !== undefined ||
|
|
398
|
+
pathProps.timestamps !== undefined ||
|
|
399
|
+
pathProps.viewOrigins !== undefined ||
|
|
400
|
+
pathProps.color !== undefined ||
|
|
401
|
+
pathProps.width !== undefined);
|
|
402
|
+
|
|
403
|
+
this.pathProps = nextProps;
|
|
404
|
+
if (!shouldReplaceState) {
|
|
405
|
+
if (shouldRefreshRowBindings) {
|
|
406
|
+
refreshPathStorageRowBindings(this.device, nextProps, this.storageState);
|
|
407
|
+
this.applyStorageState(this.storageState);
|
|
408
|
+
const firstBatch = getFirstPathStorageBatch(this.storageState);
|
|
409
|
+
this.setBindings(createPathStorageBindings(nextProps, firstBatch));
|
|
410
|
+
this.setNeedsRedraw('Storage path row bindings updated');
|
|
411
|
+
}
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const nextStorageState = nextUsesExternalState
|
|
416
|
+
? nextProps.storageState
|
|
417
|
+
: createPathStorageState(this.device, nextProps);
|
|
418
|
+
if (this.ownsStorageState) {
|
|
419
|
+
this.storageState.destroy();
|
|
420
|
+
}
|
|
421
|
+
this.storageState = nextStorageState;
|
|
422
|
+
this.ownsStorageState = !nextUsesExternalState;
|
|
423
|
+
this.applyStorageState(nextStorageState);
|
|
424
|
+
const firstBatch = getFirstPathStorageBatch(nextStorageState);
|
|
425
|
+
const firstRenderBatch = getFirstPathStorageRenderBatch(nextStorageState);
|
|
426
|
+
this.setAttributes({
|
|
427
|
+
[COMPACT_PATH_VERTEX_DATA]: firstRenderBatch.compactPathVertexData
|
|
428
|
+
});
|
|
429
|
+
this.setBindings(createPathStorageBindings(nextProps, firstBatch));
|
|
430
|
+
this.setInstanceCount(firstRenderBatch.segmentCount);
|
|
431
|
+
this.setNeedsRedraw('Storage path state updated');
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** Draws each generated storage path render batch against the supplied render pass. */
|
|
435
|
+
override draw(renderPass: RenderPass): boolean {
|
|
436
|
+
let drawSuccess = true;
|
|
437
|
+
for (const renderBatch of this.storageState.renderBatches) {
|
|
438
|
+
if (renderBatch.segmentCount === 0) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const batch = this.storageState.batches[renderBatch.rowBindingBatchIndex];
|
|
442
|
+
if (!batch) {
|
|
443
|
+
throw new Error('PathStorageModel render batch is missing its row-binding batch');
|
|
444
|
+
}
|
|
445
|
+
this.setAttributes({
|
|
446
|
+
[COMPACT_PATH_VERTEX_DATA]: renderBatch.compactPathVertexData
|
|
447
|
+
});
|
|
448
|
+
this.setBindings(createPathStorageBindings(this.pathProps, batch));
|
|
449
|
+
this.setInstanceCount(renderBatch.segmentCount);
|
|
450
|
+
drawSuccess = super.draw(renderPass) && drawSuccess;
|
|
451
|
+
}
|
|
452
|
+
const firstBatch = getFirstPathStorageBatch(this.storageState);
|
|
453
|
+
const firstRenderBatch = getFirstPathStorageRenderBatch(this.storageState);
|
|
454
|
+
this.setAttributes({
|
|
455
|
+
[COMPACT_PATH_VERTEX_DATA]: firstRenderBatch.compactPathVertexData
|
|
456
|
+
});
|
|
457
|
+
this.setBindings(createPathStorageBindings(this.pathProps, firstBatch));
|
|
458
|
+
this.setInstanceCount(this.storageState.segmentCount);
|
|
459
|
+
return drawSuccess;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** Releases owned storage path state plus inherited model resources. */
|
|
463
|
+
override destroy(): void {
|
|
464
|
+
if (this.ownsStorageState) {
|
|
465
|
+
this.storageState.destroy();
|
|
466
|
+
}
|
|
467
|
+
super.destroy();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
private applyStorageState(storageState: PathStorageState): void {
|
|
471
|
+
this.segmentCount = storageState.segmentCount;
|
|
472
|
+
this.pathRangeBuildTimeMs = storageState.pathRangeBuildTimeMs;
|
|
473
|
+
this.pathRangeByteLength = storageState.pathRangeByteLength;
|
|
474
|
+
this.pathRecordByteStride = storageState.pathRecordByteStride;
|
|
475
|
+
this.compactPathVertexByteLength = storageState.compactPathVertexByteLength;
|
|
476
|
+
this.generatedRenderBufferByteLength = storageState.generatedRenderBufferByteLength;
|
|
477
|
+
this.rowStorageByteLength = storageState.rowStorageByteLength;
|
|
478
|
+
this.transientComputeInputByteLength = storageState.transientComputeInputByteLength;
|
|
479
|
+
this.batches = storageState.batches;
|
|
480
|
+
this.renderBatches = storageState.renderBatches;
|
|
481
|
+
this.rowColorsBinding = storageState.rowColorsBinding;
|
|
482
|
+
this.vertexColorsBinding = storageState.vertexColorsBinding;
|
|
483
|
+
this.rowWidthsBinding = storageState.rowWidthsBinding;
|
|
484
|
+
this.styleConfigBuffer = storageState.styleConfigBuffer;
|
|
485
|
+
this.compactPathVertexData = storageState.compactPathVertexData;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function getPathStorageRecordMode(shaderLayout: ShaderLayout): PathStorageRecordMode {
|
|
490
|
+
const shaderAttributeNames = new Set(shaderLayout.attributes.map(attribute => attribute.name));
|
|
491
|
+
return shaderRequestsLegacySegmentAttributes(shaderAttributeNames) ? 'legacy' : 'compact';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function shaderRequestsLegacySegmentAttributes(shaderAttributeNames: Set<string>): boolean {
|
|
495
|
+
return (
|
|
496
|
+
shaderAttributeNames.has(SEGMENT_END_POINT_INDICES_COLUMN) ||
|
|
497
|
+
shaderAttributeNames.has(SEGMENT_PREVIOUS_POINT_INDICES_COLUMN) ||
|
|
498
|
+
shaderAttributeNames.has(SEGMENT_NEXT_POINT_INDICES_COLUMN)
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function getPathStorageRecordByteStride(recordMode: PathStorageRecordMode): number {
|
|
503
|
+
return recordMode === 'legacy' ? LEGACY_PATH_VERTEX_BYTE_STRIDE : COMPACT_PATH_VERTEX_BYTE_STRIDE;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Builds reusable WebGPU storage path expansion and row-binding state. */
|
|
507
|
+
export function createPathStorageState(
|
|
508
|
+
device: Device,
|
|
509
|
+
props: PathStorageInputProps
|
|
510
|
+
): PathStorageState {
|
|
511
|
+
if (device.type !== 'webgpu') {
|
|
512
|
+
throw new Error('createPathStorageState requires a WebGPU device');
|
|
513
|
+
}
|
|
514
|
+
const pathRangeBuildStartTime = getNow();
|
|
515
|
+
const shaderLayout = props.shaderLayout ?? DEFAULT_PATH_STORAGE_SHADER_LAYOUT;
|
|
516
|
+
const pathRecordMode = getPathStorageRecordMode(shaderLayout);
|
|
517
|
+
const pathRecordByteStride = getPathStorageRecordByteStride(pathRecordMode);
|
|
518
|
+
const pathRecordWordCount = pathRecordByteStride / Uint32Array.BYTES_PER_ELEMENT;
|
|
519
|
+
const pathInputs = resolvePathStorageInputs(props, PathStorageModel.gpuInputSchema);
|
|
520
|
+
const defaultBindings = createPathStorageDefaultBindings(device, props);
|
|
521
|
+
const ownedRowBindingResources: PathStorageOwnedResource[] = [...defaultBindings.ownedResources];
|
|
522
|
+
const ownedPathRangeResources: PathStorageOwnedResource[] = [];
|
|
523
|
+
const batches: PathStorageBatchState[] = [];
|
|
524
|
+
const renderBatches: PathStorageRenderBatchState[] = [];
|
|
525
|
+
let segmentCount = 0;
|
|
526
|
+
let pathRangeByteLength = 0;
|
|
527
|
+
let generatedRenderBufferByteLength = 0;
|
|
528
|
+
let rowStorageByteLength = defaultBindings.byteLength;
|
|
529
|
+
let transientComputeInputByteLength = 0;
|
|
530
|
+
|
|
531
|
+
for (const [rowBindingBatchIndex, batchInput] of pathInputs.batches.entries()) {
|
|
532
|
+
const pathRangeState = createGpuPathRangeState(
|
|
533
|
+
device,
|
|
534
|
+
{id: props.id},
|
|
535
|
+
{
|
|
536
|
+
valueOffsets: batchInput.valueOffsets,
|
|
537
|
+
recordOffsets: batchInput.recordOffsets,
|
|
538
|
+
batchRowIndexBase: batchInput.batchRowIndexBase,
|
|
539
|
+
rowCount: batchInput.rowCount
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
ownedPathRangeResources.push(pathRangeState);
|
|
543
|
+
pathRangeByteLength += pathRangeState.byteLength;
|
|
544
|
+
const rowState = createPathStorageBatchRowState(device, props, batchInput, defaultBindings);
|
|
545
|
+
const generatedBufferBatches = planGeneratedBufferBatches({
|
|
546
|
+
device,
|
|
547
|
+
recordOffsets: batchInput.recordOffsets,
|
|
548
|
+
recordByteStride: pathRecordByteStride,
|
|
549
|
+
maxBatchByteLength: device.limits.maxStorageBufferBindingSize,
|
|
550
|
+
resourceLabel: 'PathStorageModel indexed generated path vertex data'
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
for (const generatedBufferBatch of generatedBufferBatches) {
|
|
554
|
+
const expansionInput = createGpuPathExpansionInput(
|
|
555
|
+
device,
|
|
556
|
+
{id: props.id},
|
|
557
|
+
{
|
|
558
|
+
generatedBufferBatch,
|
|
559
|
+
componentCount: batchInput.componentCount,
|
|
560
|
+
recordWordCount: pathRecordWordCount
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
const generated = createGpuPathGeneratedState(
|
|
564
|
+
device,
|
|
565
|
+
{id: props.id},
|
|
566
|
+
generatedBufferBatch.recordCount,
|
|
567
|
+
pathRecordWordCount
|
|
568
|
+
);
|
|
569
|
+
dispatchGpuPathExpansionCompute(
|
|
570
|
+
device,
|
|
571
|
+
{id: props.id},
|
|
572
|
+
{
|
|
573
|
+
pathValues: batchInput.pathValuesBinding,
|
|
574
|
+
pathRanges: pathRangeState.pathRangesBuffer,
|
|
575
|
+
expansionInput,
|
|
576
|
+
generated,
|
|
577
|
+
rowCount: generatedBufferBatch.rowEnd - generatedBufferBatch.rowStart,
|
|
578
|
+
segmentCount: generatedBufferBatch.recordCount
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
renderBatches.push({
|
|
582
|
+
rowBindingBatchIndex,
|
|
583
|
+
rowStart: generatedBufferBatch.rowStart,
|
|
584
|
+
rowEnd: generatedBufferBatch.rowEnd,
|
|
585
|
+
segmentCount: generatedBufferBatch.recordCount,
|
|
586
|
+
compactPathVertexData: generated.compactPathVertexData
|
|
587
|
+
});
|
|
588
|
+
generatedRenderBufferByteLength += generated.byteLength;
|
|
589
|
+
transientComputeInputByteLength += expansionInput.byteLength;
|
|
590
|
+
expansionInput.expansionConfigBuffer.destroy();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
batches.push({
|
|
594
|
+
...rowState,
|
|
595
|
+
batchRowIndexBase: batchInput.batchRowIndexBase,
|
|
596
|
+
rowCount: batchInput.rowCount,
|
|
597
|
+
segmentCount: batchInput.segmentCount,
|
|
598
|
+
pathValuesBinding: batchInput.pathValuesBinding,
|
|
599
|
+
pathRangesBinding: pathRangeState.pathRangesBuffer,
|
|
600
|
+
...(batchInput.timestampsBinding
|
|
601
|
+
? {pathTimestampsBinding: batchInput.timestampsBinding}
|
|
602
|
+
: {}),
|
|
603
|
+
pathViewOriginsBinding: rowState.pathViewOriginsBinding
|
|
604
|
+
});
|
|
605
|
+
ownedRowBindingResources.push(...rowState.ownedResources);
|
|
606
|
+
rowStorageByteLength += rowState.ownedByteLength;
|
|
607
|
+
segmentCount += batchInput.segmentCount;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const firstBatch = getFirstPathStorageBatch({batches});
|
|
611
|
+
const firstRenderBatch = getFirstPathStorageRenderBatch({renderBatches});
|
|
612
|
+
let destroyed = false;
|
|
613
|
+
return {
|
|
614
|
+
segmentCount,
|
|
615
|
+
pathRangeBuildTimeMs: getNow() - pathRangeBuildStartTime,
|
|
616
|
+
pathRangeByteLength,
|
|
617
|
+
pathRecordByteStride,
|
|
618
|
+
compactPathVertexByteLength: generatedRenderBufferByteLength,
|
|
619
|
+
generatedRenderBufferByteLength,
|
|
620
|
+
rowStorageByteLength,
|
|
621
|
+
transientComputeInputByteLength,
|
|
622
|
+
batches,
|
|
623
|
+
renderBatches,
|
|
624
|
+
ownedRowBindingResources,
|
|
625
|
+
rowColorsBinding: firstBatch.rowColorsBinding,
|
|
626
|
+
vertexColorsBinding: firstBatch.vertexColorsBinding,
|
|
627
|
+
rowWidthsBinding: firstBatch.rowWidthsBinding,
|
|
628
|
+
styleConfigBuffer: firstBatch.styleConfigBuffer,
|
|
629
|
+
compactPathVertexData: firstRenderBatch.compactPathVertexData,
|
|
630
|
+
destroy: () => {
|
|
631
|
+
if (destroyed) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
destroyed = true;
|
|
635
|
+
destroyPathStorageResources(ownedRowBindingResources);
|
|
636
|
+
destroyPathStorageResources(ownedPathRangeResources);
|
|
637
|
+
for (const renderBatch of renderBatches) {
|
|
638
|
+
renderBatch.compactPathVertexData.destroy();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function createPathStorageModelProps(
|
|
645
|
+
props: PathStorageModelProps,
|
|
646
|
+
storageState: PathStorageState
|
|
647
|
+
): ModelProps {
|
|
648
|
+
const shaderLayout = props.shaderLayout ?? DEFAULT_PATH_STORAGE_SHADER_LAYOUT;
|
|
649
|
+
const firstBatch = getFirstPathStorageBatch(storageState);
|
|
650
|
+
const firstRenderBatch = getFirstPathStorageRenderBatch(storageState);
|
|
651
|
+
return {
|
|
652
|
+
...props,
|
|
653
|
+
source: props.source ?? DEFAULT_PATH_STORAGE_SOURCE,
|
|
654
|
+
shaderLayout,
|
|
655
|
+
bindings: createPathStorageBindings(props, firstBatch),
|
|
656
|
+
attributes: {
|
|
657
|
+
...(props.attributes || {}),
|
|
658
|
+
[COMPACT_PATH_VERTEX_DATA]: firstRenderBatch.compactPathVertexData
|
|
659
|
+
},
|
|
660
|
+
bufferLayout: [
|
|
661
|
+
...(props.bufferLayout || []),
|
|
662
|
+
createCompactPathBufferLayout(shaderLayout, storageState.pathRecordByteStride)
|
|
663
|
+
],
|
|
664
|
+
topology: props.topology ?? 'line-list',
|
|
665
|
+
vertexCount: props.vertexCount ?? 2,
|
|
666
|
+
instanceCount: firstRenderBatch.segmentCount
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
function createPathStorageBindings(
|
|
671
|
+
props: PathStorageModelProps,
|
|
672
|
+
batch: PathStorageBatchState
|
|
673
|
+
): NonNullable<ModelProps['bindings']> {
|
|
674
|
+
return {
|
|
675
|
+
...(props.bindings || {}),
|
|
676
|
+
pathValues: batch.pathValuesBinding,
|
|
677
|
+
[PATH_RANGES_COLUMN]: batch.pathRangesBinding,
|
|
678
|
+
[PATH_VIEW_ORIGINS_COLUMN]: batch.pathViewOriginsBinding,
|
|
679
|
+
pathRowColors: batch.rowColorsBinding,
|
|
680
|
+
pathVertexColors: batch.vertexColorsBinding,
|
|
681
|
+
pathRowWidths: batch.rowWidthsBinding,
|
|
682
|
+
...(batch.pathTimestampsBinding ? {pathTimestamps: batch.pathTimestampsBinding} : {}),
|
|
683
|
+
pathStorageStyleConfig: batch.styleConfigBuffer
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function createCompactPathBufferLayout(
|
|
688
|
+
shaderLayout: ShaderLayout,
|
|
689
|
+
pathRecordByteStride: number
|
|
690
|
+
): BufferLayout {
|
|
691
|
+
const shaderAttributeNames = new Set(shaderLayout.attributes.map(attribute => attribute.name));
|
|
692
|
+
const useLegacyRecordLayout = pathRecordByteStride === LEGACY_PATH_VERTEX_BYTE_STRIDE;
|
|
693
|
+
const attributes: NonNullable<BufferLayout['attributes']> = [];
|
|
694
|
+
if (shaderAttributeNames.has(SEGMENT_START_POINT_INDICES_COLUMN)) {
|
|
695
|
+
attributes.push({
|
|
696
|
+
attribute: SEGMENT_START_POINT_INDICES_COLUMN,
|
|
697
|
+
format: 'uint32',
|
|
698
|
+
byteOffset: 0
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
if (!useLegacyRecordLayout && shaderRequestsLegacySegmentAttributes(shaderAttributeNames)) {
|
|
702
|
+
throw new Error(
|
|
703
|
+
'PathStorageModel storageState uses compact path records, but the shader layout requests legacy segment neighbor attributes'
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
if (useLegacyRecordLayout && shaderAttributeNames.has(SEGMENT_END_POINT_INDICES_COLUMN)) {
|
|
707
|
+
attributes.push({
|
|
708
|
+
attribute: SEGMENT_END_POINT_INDICES_COLUMN,
|
|
709
|
+
format: 'uint32',
|
|
710
|
+
byteOffset: LEGACY_SEGMENT_END_POINT_INDICES_BYTE_OFFSET
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
if (useLegacyRecordLayout && shaderAttributeNames.has(SEGMENT_PREVIOUS_POINT_INDICES_COLUMN)) {
|
|
714
|
+
attributes.push({
|
|
715
|
+
attribute: SEGMENT_PREVIOUS_POINT_INDICES_COLUMN,
|
|
716
|
+
format: 'uint32',
|
|
717
|
+
byteOffset: LEGACY_SEGMENT_PREVIOUS_POINT_INDICES_BYTE_OFFSET
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
if (useLegacyRecordLayout && shaderAttributeNames.has(SEGMENT_NEXT_POINT_INDICES_COLUMN)) {
|
|
721
|
+
attributes.push({
|
|
722
|
+
attribute: SEGMENT_NEXT_POINT_INDICES_COLUMN,
|
|
723
|
+
format: 'uint32',
|
|
724
|
+
byteOffset: LEGACY_SEGMENT_NEXT_POINT_INDICES_BYTE_OFFSET
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
if (shaderAttributeNames.has(SEGMENT_FLAGS_COLUMN)) {
|
|
728
|
+
attributes.push({
|
|
729
|
+
attribute: SEGMENT_FLAGS_COLUMN,
|
|
730
|
+
format: 'uint32',
|
|
731
|
+
byteOffset: useLegacyRecordLayout
|
|
732
|
+
? LEGACY_SEGMENT_FLAGS_BYTE_OFFSET
|
|
733
|
+
: COMPACT_SEGMENT_FLAGS_BYTE_OFFSET
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
if (shaderAttributeNames.has(ROW_INDICES_COLUMN)) {
|
|
737
|
+
attributes.push({
|
|
738
|
+
attribute: ROW_INDICES_COLUMN,
|
|
739
|
+
format: 'uint32',
|
|
740
|
+
byteOffset: useLegacyRecordLayout
|
|
741
|
+
? LEGACY_ROW_INDICES_BYTE_OFFSET
|
|
742
|
+
: COMPACT_ROW_INDICES_BYTE_OFFSET
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
name: COMPACT_PATH_VERTEX_DATA,
|
|
747
|
+
stepMode: 'instance',
|
|
748
|
+
byteStride: pathRecordByteStride,
|
|
749
|
+
attributes
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function createPathStorageDefaultBindings(
|
|
754
|
+
device: Device,
|
|
755
|
+
props: PathStorageInputProps
|
|
756
|
+
): PathStorageDefaultBindings {
|
|
757
|
+
const id = props.id || 'path-storage-model';
|
|
758
|
+
const colorsVector = createPathStorageOwnedGpuVector(
|
|
759
|
+
device,
|
|
760
|
+
`${id}-default-row-colors`,
|
|
761
|
+
'unorm8x4',
|
|
762
|
+
new Uint8Array(props.color ?? DEFAULT_PATH_STORAGE_COLOR)
|
|
763
|
+
);
|
|
764
|
+
const widthsVector = createPathStorageOwnedGpuVector(
|
|
765
|
+
device,
|
|
766
|
+
`${id}-default-row-widths`,
|
|
767
|
+
'float32',
|
|
768
|
+
new Float32Array([props.width ?? DEFAULT_PATH_STORAGE_WIDTH])
|
|
769
|
+
);
|
|
770
|
+
const viewOriginsVector = createPathStorageOwnedGpuVector(
|
|
771
|
+
device,
|
|
772
|
+
`${id}-default-view-origins`,
|
|
773
|
+
'float32x4',
|
|
774
|
+
new Float32Array(4)
|
|
775
|
+
);
|
|
776
|
+
return {
|
|
777
|
+
colorsBinding: getPathStorageGpuVectorBinding(colorsVector),
|
|
778
|
+
vertexColorsBinding: getPathStorageGpuVectorBinding(colorsVector),
|
|
779
|
+
widthsBinding: getPathStorageGpuVectorBinding(widthsVector),
|
|
780
|
+
viewOriginsBinding: getPathStorageGpuVectorBinding(viewOriginsVector),
|
|
781
|
+
byteLength:
|
|
782
|
+
Uint8Array.BYTES_PER_ELEMENT * 4 +
|
|
783
|
+
Float32Array.BYTES_PER_ELEMENT +
|
|
784
|
+
Float32Array.BYTES_PER_ELEMENT * 4,
|
|
785
|
+
ownedResources: [colorsVector, widthsVector, viewOriginsVector]
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function createPathStorageBatchRowState(
|
|
790
|
+
device: Device,
|
|
791
|
+
props: PathStorageInputProps,
|
|
792
|
+
batchInput: PathStorageBatchInputs,
|
|
793
|
+
defaultBindings: PathStorageDefaultBindings
|
|
794
|
+
): PathStorageBatchRowState {
|
|
795
|
+
const styleConfigData = createPathStorageStyleConfigData(
|
|
796
|
+
props,
|
|
797
|
+
batchInput.batchRowIndexBase,
|
|
798
|
+
batchInput.componentCount
|
|
799
|
+
);
|
|
800
|
+
const styleConfigBuffer = new DynamicBuffer(device, {
|
|
801
|
+
id: `${props.id || 'path-storage-model'}-style-config-${batchInput.batchRowIndexBase}`,
|
|
802
|
+
usage: Buffer.UNIFORM | Buffer.COPY_DST | Buffer.COPY_SRC,
|
|
803
|
+
data: styleConfigData
|
|
804
|
+
});
|
|
805
|
+
return {
|
|
806
|
+
pathViewOriginsBinding: batchInput.viewOriginsBinding ?? defaultBindings.viewOriginsBinding,
|
|
807
|
+
rowColorsBinding:
|
|
808
|
+
props.colors && isArrowPathRowColorGPUVector(props.colors) && batchInput.colorsBinding
|
|
809
|
+
? batchInput.colorsBinding
|
|
810
|
+
: defaultBindings.colorsBinding,
|
|
811
|
+
vertexColorsBinding:
|
|
812
|
+
props.colors && isPathVertexColorGPUVector(props.colors) && batchInput.colorsBinding
|
|
813
|
+
? batchInput.colorsBinding
|
|
814
|
+
: defaultBindings.vertexColorsBinding,
|
|
815
|
+
rowWidthsBinding: batchInput.widthsBinding ?? defaultBindings.widthsBinding,
|
|
816
|
+
styleConfigBuffer,
|
|
817
|
+
ownedResources: [styleConfigBuffer],
|
|
818
|
+
ownedByteLength: styleConfigData.byteLength
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function createPathStorageOwnedGpuVector<FormatT extends GPUVectorFormat>(
|
|
823
|
+
device: Device,
|
|
824
|
+
name: string,
|
|
825
|
+
format: FormatT,
|
|
826
|
+
data: Uint8Array | Float32Array
|
|
827
|
+
): GPUVector<FormatT> {
|
|
828
|
+
return new GPUVector({
|
|
829
|
+
type: 'buffer',
|
|
830
|
+
name,
|
|
831
|
+
buffer: device.createBuffer({
|
|
832
|
+
id: name,
|
|
833
|
+
usage: Buffer.STORAGE | Buffer.COPY_DST | Buffer.COPY_SRC,
|
|
834
|
+
data
|
|
835
|
+
}),
|
|
836
|
+
format,
|
|
837
|
+
length: 1,
|
|
838
|
+
ownsBuffer: true
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function getPathStorageGpuVectorBinding(vector: GPUVector): Binding {
|
|
843
|
+
const [data, ...remainingData] = vector.data;
|
|
844
|
+
if (!data || remainingData.length > 0) {
|
|
845
|
+
throw new Error(`Storage path vector "${vector.name}" requires exactly one GPUData chunk`);
|
|
846
|
+
}
|
|
847
|
+
const buffer = data.buffer;
|
|
848
|
+
return buffer instanceof DynamicBuffer ? buffer.buffer : buffer;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function isArrowPathRowColorGPUVector(
|
|
852
|
+
colors: NonNullable<PathStorageInputProps['colors']>
|
|
853
|
+
): boolean {
|
|
854
|
+
return colors.format === 'unorm8x4';
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function isPathVertexColorGPUVector(colors: NonNullable<PathStorageInputProps['colors']>): boolean {
|
|
858
|
+
return colors.format === 'vertex-list<unorm8x4>';
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function createPathStorageStyleConfigData(
|
|
862
|
+
props: PathStorageInputProps,
|
|
863
|
+
batchRowIndexBase: number,
|
|
864
|
+
pathComponentCount: number
|
|
865
|
+
): Uint32Array {
|
|
866
|
+
const arrayBuffer = new ArrayBuffer(48);
|
|
867
|
+
const floatValues = new Float32Array(arrayBuffer);
|
|
868
|
+
const uintValues = new Uint32Array(arrayBuffer);
|
|
869
|
+
const color = props.color ?? DEFAULT_PATH_STORAGE_COLOR;
|
|
870
|
+
floatValues[0] = color[0] / 255;
|
|
871
|
+
floatValues[1] = color[1] / 255;
|
|
872
|
+
floatValues[2] = color[2] / 255;
|
|
873
|
+
floatValues[3] = color[3] / 255;
|
|
874
|
+
floatValues[4] = props.width ?? DEFAULT_PATH_STORAGE_WIDTH;
|
|
875
|
+
uintValues[5] = props.colors && isArrowPathRowColorGPUVector(props.colors) ? 1 : 0;
|
|
876
|
+
uintValues[6] = props.widths ? 1 : 0;
|
|
877
|
+
uintValues[7] = batchRowIndexBase;
|
|
878
|
+
uintValues[8] = pathComponentCount;
|
|
879
|
+
uintValues[9] = props.viewOrigins ? 1 : 0;
|
|
880
|
+
uintValues[10] = props.colors && isPathVertexColorGPUVector(props.colors) ? 1 : 0;
|
|
881
|
+
return uintValues;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function refreshPathStorageRowBindings(
|
|
885
|
+
device: Device,
|
|
886
|
+
props: PathStorageInputProps,
|
|
887
|
+
storageState: PathStorageState
|
|
888
|
+
): void {
|
|
889
|
+
const pathInputs = resolvePathStorageInputs(props, PathStorageModel.gpuInputSchema);
|
|
890
|
+
assertPathStorageRowBindingRefreshCompatible(storageState, pathInputs.batches);
|
|
891
|
+
const nextOwnedRowBindingResources: PathStorageOwnedResource[] = [];
|
|
892
|
+
const defaultBindings = createPathStorageDefaultBindings(device, props);
|
|
893
|
+
nextOwnedRowBindingResources.push(...defaultBindings.ownedResources);
|
|
894
|
+
let rowStorageByteLength = defaultBindings.byteLength;
|
|
895
|
+
|
|
896
|
+
const nextBatches = pathInputs.batches.map((batchInput, batchIndex) => {
|
|
897
|
+
const previousBatch = storageState.batches[batchIndex];
|
|
898
|
+
const rowState = createPathStorageBatchRowState(device, props, batchInput, defaultBindings);
|
|
899
|
+
nextOwnedRowBindingResources.push(...rowState.ownedResources);
|
|
900
|
+
rowStorageByteLength += rowState.ownedByteLength;
|
|
901
|
+
return {
|
|
902
|
+
...rowState,
|
|
903
|
+
batchRowIndexBase: previousBatch.batchRowIndexBase,
|
|
904
|
+
rowCount: previousBatch.rowCount,
|
|
905
|
+
segmentCount: previousBatch.segmentCount,
|
|
906
|
+
pathValuesBinding: previousBatch.pathValuesBinding,
|
|
907
|
+
pathRangesBinding: previousBatch.pathRangesBinding,
|
|
908
|
+
...(batchInput.timestampsBinding
|
|
909
|
+
? {pathTimestampsBinding: batchInput.timestampsBinding}
|
|
910
|
+
: {}),
|
|
911
|
+
pathViewOriginsBinding: rowState.pathViewOriginsBinding
|
|
912
|
+
};
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
replaceOwnedPathStorageResources(
|
|
916
|
+
storageState.ownedRowBindingResources,
|
|
917
|
+
nextOwnedRowBindingResources
|
|
918
|
+
);
|
|
919
|
+
storageState.batches = nextBatches;
|
|
920
|
+
storageState.rowStorageByteLength = rowStorageByteLength;
|
|
921
|
+
syncPathStorageStateFirstBatch(storageState);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function assertPathStorageRowBindingRefreshCompatible(
|
|
925
|
+
storageState: PathStorageState,
|
|
926
|
+
batches: PathStorageBatchInputs[]
|
|
927
|
+
): void {
|
|
928
|
+
if (batches.length !== storageState.batches.length) {
|
|
929
|
+
throw new Error('PathStorageModel row-binding updates must preserve path batch count');
|
|
930
|
+
}
|
|
931
|
+
for (const [batchIndex, batchInput] of batches.entries()) {
|
|
932
|
+
const existingBatch = storageState.batches[batchIndex];
|
|
933
|
+
if (
|
|
934
|
+
!existingBatch ||
|
|
935
|
+
existingBatch.batchRowIndexBase !== batchInput.batchRowIndexBase ||
|
|
936
|
+
existingBatch.rowCount !== batchInput.rowCount ||
|
|
937
|
+
existingBatch.segmentCount !== batchInput.segmentCount
|
|
938
|
+
) {
|
|
939
|
+
throw new Error('PathStorageModel row-binding updates must preserve path batch rows');
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function syncPathStorageStateFirstBatch(storageState: PathStorageState): void {
|
|
945
|
+
const firstBatch = getFirstPathStorageBatch(storageState);
|
|
946
|
+
const firstRenderBatch = getFirstPathStorageRenderBatch(storageState);
|
|
947
|
+
storageState.rowColorsBinding = firstBatch.rowColorsBinding;
|
|
948
|
+
storageState.vertexColorsBinding = firstBatch.vertexColorsBinding;
|
|
949
|
+
storageState.rowWidthsBinding = firstBatch.rowWidthsBinding;
|
|
950
|
+
storageState.styleConfigBuffer = firstBatch.styleConfigBuffer;
|
|
951
|
+
storageState.compactPathVertexData = firstRenderBatch.compactPathVertexData;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
function destroyPathStorageResources(resources: PathStorageOwnedResource[]): void {
|
|
955
|
+
for (const resource of resources) {
|
|
956
|
+
resource.destroy();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
function replaceOwnedPathStorageResources(
|
|
961
|
+
currentResources: PathStorageOwnedResource[],
|
|
962
|
+
nextResources: PathStorageOwnedResource[]
|
|
963
|
+
): void {
|
|
964
|
+
destroyPathStorageResources(currentResources);
|
|
965
|
+
currentResources.splice(0, currentResources.length, ...nextResources);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function getFirstPathStorageBatch(
|
|
969
|
+
storageState: Pick<PathStorageState, 'batches'>
|
|
970
|
+
): PathStorageBatchState {
|
|
971
|
+
const firstBatch = storageState.batches[0];
|
|
972
|
+
if (!firstBatch) {
|
|
973
|
+
throw new Error('PathStorageState requires at least one row-binding batch');
|
|
974
|
+
}
|
|
975
|
+
return firstBatch;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function getFirstPathStorageRenderBatch(
|
|
979
|
+
storageState: Pick<PathStorageState, 'renderBatches'>
|
|
980
|
+
): PathStorageRenderBatchState {
|
|
981
|
+
const firstRenderBatch = storageState.renderBatches[0];
|
|
982
|
+
if (!firstRenderBatch) {
|
|
983
|
+
throw new Error('PathStorageState requires at least one render batch');
|
|
984
|
+
}
|
|
985
|
+
return firstRenderBatch;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function hasPathStorageState(
|
|
989
|
+
props: PathStorageModelProps
|
|
990
|
+
): props is PathStorageRenderProps & {storageState: PathStorageState} {
|
|
991
|
+
return 'storageState' in props && props.storageState !== undefined;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function getNow(): number {
|
|
995
|
+
return typeof performance === 'undefined' ? Date.now() : performance.now();
|
|
996
|
+
}
|