@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,1264 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var gpu_vector_model_exports = {};
|
|
19
|
+
__export(gpu_vector_model_exports, {
|
|
20
|
+
GPUVectorModel: () => GPUVectorModel,
|
|
21
|
+
getGPUVectorModelBatches: () => import_gpu_vector_model_batches2.getGPUVectorModelBatches
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(gpu_vector_model_exports);
|
|
24
|
+
var import_core = require("@luma.gl/core");
|
|
25
|
+
var import_shadertools = require("@luma.gl/shadertools");
|
|
26
|
+
var import_debug_shader_layout = require("../debug/debug-shader-layout.cjs");
|
|
27
|
+
var import_debug_framebuffer = require("../debug/debug-framebuffer.cjs");
|
|
28
|
+
var import_deep_equal = require("../utils/deep-equal.cjs");
|
|
29
|
+
var import_buffer_layout_helper = require("../utils/buffer-layout-helper.cjs");
|
|
30
|
+
var import_buffer_layout_order = require("../utils/buffer-layout-order.cjs");
|
|
31
|
+
var import_shader_module_utils = require("../utils/shader-module-utils.cjs");
|
|
32
|
+
var import_get_platform_info = require("../utils/get-platform-info.cjs");
|
|
33
|
+
var import_uid = require("../utils/uid.cjs");
|
|
34
|
+
var import_gpu_vector_model_batches = require("./gpu-vector-model-batches.cjs");
|
|
35
|
+
var import_gpu_vector_model_batches2 = require("./gpu-vector-model-batches.cjs");
|
|
36
|
+
var import_gpu_vector_batch_structure = require("../utils/gpu-vector-batch-structure.cjs");
|
|
37
|
+
var import_gpu_vector_draw_batches = require("./gpu-vector-draw-batches.cjs");
|
|
38
|
+
var import_gpu_vector_bindings = require("./gpu-vector-bindings.cjs");
|
|
39
|
+
var import_shader_inputs = require("../shader-inputs.cjs");
|
|
40
|
+
var import_dynamic = require("@luma.gl/core/dynamic");
|
|
41
|
+
var import_dynamic2 = require("@luma.gl/core/dynamic");
|
|
42
|
+
const LOG_DRAW_PRIORITY = 2;
|
|
43
|
+
const LOG_DRAW_TIMEOUT = 1e4;
|
|
44
|
+
const PIPELINE_INITIALIZATION_FAILED = "render pipeline initialization failed";
|
|
45
|
+
const DEPTH_STENCIL_ATTACHMENT_FORMATS = [
|
|
46
|
+
"stencil8",
|
|
47
|
+
"depth16unorm",
|
|
48
|
+
"depth24plus",
|
|
49
|
+
"depth24plus-stencil8",
|
|
50
|
+
"depth32float",
|
|
51
|
+
"depth32float-stencil8"
|
|
52
|
+
];
|
|
53
|
+
class GPUVectorModel {
|
|
54
|
+
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
55
|
+
static async createAsync(device, props) {
|
|
56
|
+
const ownsCompilation = !import_core.PipelineFactory.getAsyncCompilation(device);
|
|
57
|
+
const asyncCompilation = ownsCompilation ? import_core.PipelineFactory.beginAsyncCompilation(device) : import_core.PipelineFactory.getAsyncCompilation(device);
|
|
58
|
+
let model;
|
|
59
|
+
try {
|
|
60
|
+
model = new this(device, props);
|
|
61
|
+
} finally {
|
|
62
|
+
if (ownsCompilation)
|
|
63
|
+
import_core.PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
if (ownsCompilation) {
|
|
67
|
+
await Promise.all(asyncCompilation);
|
|
68
|
+
} else {
|
|
69
|
+
await model._pipelineInitialization;
|
|
70
|
+
}
|
|
71
|
+
return model;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
model.destroy();
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
static defaultProps = {
|
|
78
|
+
...import_core.RenderPipeline.defaultProps,
|
|
79
|
+
gpuVectorCount: "instance",
|
|
80
|
+
geometry: null,
|
|
81
|
+
attributeVectors: void 0,
|
|
82
|
+
source: void 0,
|
|
83
|
+
sourceLanguage: void 0,
|
|
84
|
+
vs: null,
|
|
85
|
+
fs: null,
|
|
86
|
+
id: "unnamed",
|
|
87
|
+
handle: void 0,
|
|
88
|
+
userData: {},
|
|
89
|
+
defines: {},
|
|
90
|
+
modules: [],
|
|
91
|
+
plugins: [],
|
|
92
|
+
indexBuffer: null,
|
|
93
|
+
indexCount: void 0,
|
|
94
|
+
firstVertex: 0,
|
|
95
|
+
firstIndex: 0,
|
|
96
|
+
attributes: {},
|
|
97
|
+
constantAttributes: {},
|
|
98
|
+
bindings: {},
|
|
99
|
+
uniforms: {},
|
|
100
|
+
varyings: [],
|
|
101
|
+
isInstanced: void 0,
|
|
102
|
+
instanceCount: 0,
|
|
103
|
+
vertexCount: 0,
|
|
104
|
+
shaderInputs: void 0,
|
|
105
|
+
pipelineFactory: void 0,
|
|
106
|
+
shaderFactory: void 0,
|
|
107
|
+
transformFeedback: void 0,
|
|
108
|
+
shaderAssembler: import_shadertools.ShaderAssembler.getDefaultShaderAssembler("glsl"),
|
|
109
|
+
debugShaders: void 0,
|
|
110
|
+
disableWarnings: void 0
|
|
111
|
+
};
|
|
112
|
+
/** Device that created this model */
|
|
113
|
+
device;
|
|
114
|
+
/** Application provided identifier */
|
|
115
|
+
id;
|
|
116
|
+
/** WGSL shader source when using unified shader */
|
|
117
|
+
// @ts-expect-error assigned in function called from constructor
|
|
118
|
+
source;
|
|
119
|
+
/** GLSL vertex shader source */
|
|
120
|
+
// @ts-expect-error assigned in function called from constructor
|
|
121
|
+
vs;
|
|
122
|
+
/** GLSL fragment shader source */
|
|
123
|
+
// @ts-expect-error assigned in function called from constructor
|
|
124
|
+
fs;
|
|
125
|
+
/** Factory used to create render pipelines */
|
|
126
|
+
pipelineFactory;
|
|
127
|
+
/** Factory used to create shaders */
|
|
128
|
+
shaderFactory;
|
|
129
|
+
/** User-supplied per-model data */
|
|
130
|
+
userData = {};
|
|
131
|
+
// Fixed properties (change can trigger pipeline rebuild)
|
|
132
|
+
/** The render pipeline GPU parameters, depth testing etc */
|
|
133
|
+
parameters;
|
|
134
|
+
/** The primitive topology */
|
|
135
|
+
topology;
|
|
136
|
+
/** Buffer layout */
|
|
137
|
+
bufferLayout;
|
|
138
|
+
// Dynamic properties
|
|
139
|
+
/** Use instanced rendering */
|
|
140
|
+
isInstanced = void 0;
|
|
141
|
+
/** instance count. `undefined` means not instanced */
|
|
142
|
+
instanceCount = 0;
|
|
143
|
+
/** Vertex count */
|
|
144
|
+
vertexCount;
|
|
145
|
+
/** Indexed draw count override. Undefined uses vertexCount, then the full bound index buffer. */
|
|
146
|
+
indexCount;
|
|
147
|
+
/** First vertex byte offset for WebGL indexed draws or first vertex for non-indexed draws. */
|
|
148
|
+
firstVertex;
|
|
149
|
+
/** First index element for WebGPU indexed draws. */
|
|
150
|
+
firstIndex;
|
|
151
|
+
/** Index buffer */
|
|
152
|
+
indexBuffer = null;
|
|
153
|
+
/** Buffer-valued attributes */
|
|
154
|
+
bufferAttributes = {};
|
|
155
|
+
/** Constant-valued attributes */
|
|
156
|
+
constantAttributes = {};
|
|
157
|
+
/** Bindings (textures, samplers, uniform buffers) */
|
|
158
|
+
bindings = {};
|
|
159
|
+
/**
|
|
160
|
+
* VertexArray
|
|
161
|
+
* @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
|
|
162
|
+
* @todo - allow application to define multiple vertex arrays?
|
|
163
|
+
* */
|
|
164
|
+
vertexArray;
|
|
165
|
+
/** TransformFeedback, WebGL 2 only. */
|
|
166
|
+
transformFeedback = null;
|
|
167
|
+
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
168
|
+
pipeline;
|
|
169
|
+
/** ShaderInputs instance */
|
|
170
|
+
// @ts-expect-error Assigned in function called by constructor
|
|
171
|
+
shaderInputs;
|
|
172
|
+
// @ts-expect-error Assigned in function called by constructor
|
|
173
|
+
_uniformStore;
|
|
174
|
+
_attributeInfos = {};
|
|
175
|
+
props;
|
|
176
|
+
geometryVectorBindings;
|
|
177
|
+
attributeVectorBindings;
|
|
178
|
+
explicitBufferLayout = [];
|
|
179
|
+
constructorDrawCounts;
|
|
180
|
+
constructorDrawOffsets;
|
|
181
|
+
drawingVectorBatches = false;
|
|
182
|
+
indexVector = null;
|
|
183
|
+
currentAttributes = {};
|
|
184
|
+
currentAttributeByteOffsets = {};
|
|
185
|
+
_dynamicIndexBufferSource = null;
|
|
186
|
+
_dynamicAttributeBufferSources = {};
|
|
187
|
+
_colorAttachmentFormats;
|
|
188
|
+
_depthStencilAttachmentFormat;
|
|
189
|
+
_pipelineNeedsUpdate = "newly created";
|
|
190
|
+
_needsRedraw = "initializing";
|
|
191
|
+
_drawBlockedReason = false;
|
|
192
|
+
_destroyed = false;
|
|
193
|
+
_vertexCountSet = false;
|
|
194
|
+
/** "Time" of last draw. Monotonically increasing timestamp */
|
|
195
|
+
_lastDrawTimestamp = -1;
|
|
196
|
+
_bindingTable = [];
|
|
197
|
+
_pipelineInitialization;
|
|
198
|
+
get [Symbol.toStringTag]() {
|
|
199
|
+
return "Model";
|
|
200
|
+
}
|
|
201
|
+
toString() {
|
|
202
|
+
return `Model(${this.id})`;
|
|
203
|
+
}
|
|
204
|
+
constructor(device, props) {
|
|
205
|
+
var _a;
|
|
206
|
+
this.constructorDrawOffsets = { firstVertex: props.firstVertex, firstIndex: props.firstIndex };
|
|
207
|
+
const defaultProps = this.constructor.defaultProps;
|
|
208
|
+
this.constructorDrawCounts = {
|
|
209
|
+
vertexCount: props.vertexCount ?? (defaultProps.vertexCount || void 0),
|
|
210
|
+
instanceCount: props.instanceCount ?? (defaultProps.instanceCount || void 0)
|
|
211
|
+
};
|
|
212
|
+
const defaultShaderAssembler = defaultProps.shaderAssembler;
|
|
213
|
+
const vertexCountSet = Object.hasOwn(props, "vertexCount");
|
|
214
|
+
this.props = {
|
|
215
|
+
...defaultProps,
|
|
216
|
+
...props,
|
|
217
|
+
shaderAssembler: props.shaderAssembler ?? (isShaderAssemblerForLanguage(defaultShaderAssembler, device.info.shadingLanguage) ? defaultShaderAssembler : import_shadertools.ShaderAssembler.getDefaultShaderAssembler(device.info.shadingLanguage))
|
|
218
|
+
};
|
|
219
|
+
this._vertexCountSet = vertexCountSet;
|
|
220
|
+
props = this.props;
|
|
221
|
+
this.id = props.id || (0, import_uid.uid)("model");
|
|
222
|
+
this.device = device;
|
|
223
|
+
Object.assign(this.userData, props.userData);
|
|
224
|
+
this.vertexCount = this.props.vertexCount;
|
|
225
|
+
this.indexCount = this.props.indexCount;
|
|
226
|
+
this.firstVertex = this.props.firstVertex;
|
|
227
|
+
this.firstIndex = this.props.firstIndex;
|
|
228
|
+
this.instanceCount = this.props.instanceCount;
|
|
229
|
+
this.topology = this.props.topology;
|
|
230
|
+
this.bufferLayout = this.props.bufferLayout;
|
|
231
|
+
this.parameters = this.props.parameters;
|
|
232
|
+
this._colorAttachmentFormats = this.props.colorAttachmentFormats;
|
|
233
|
+
this._depthStencilAttachmentFormat = this.props.depthStencilAttachmentFormat;
|
|
234
|
+
this.isInstanced = props.isInstanced ?? (props.instanceCount ? true : void 0);
|
|
235
|
+
this.explicitBufferLayout = this.bufferLayout;
|
|
236
|
+
this.geometryVectorBindings = new import_gpu_vector_bindings.GPUVectorBindings(device, `${this.id}-geometry`);
|
|
237
|
+
this.attributeVectorBindings = new import_gpu_vector_bindings.GPUVectorBindings(device, `${this.id}-attributes`);
|
|
238
|
+
this._initializeProps(props);
|
|
239
|
+
const platformInfo = (0, import_get_platform_info.getPlatformInfo)(device);
|
|
240
|
+
const resolvedPlugins = (0, import_shadertools.resolveShaderPlugins)(this.props.plugins, platformInfo.shaderLanguage);
|
|
241
|
+
const shaderInputModules = (0, import_shadertools.mergeShaderPluginModules)(this.props.modules, resolvedPlugins.modules);
|
|
242
|
+
const moduleMap = Object.fromEntries(shaderInputModules.map((module2) => [module2.name, module2]));
|
|
243
|
+
const shaderInputs = props.shaderInputs || new import_shader_inputs.ShaderInputs(moduleMap, { disableWarnings: this.props.disableWarnings });
|
|
244
|
+
if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
|
|
245
|
+
shaderInputs.addModules(resolvedPlugins.modules);
|
|
246
|
+
}
|
|
247
|
+
this.setShaderInputs(shaderInputs);
|
|
248
|
+
const modules = (0, import_shader_module_utils.mergeShaderModules)(this.props.modules, shaderInputs.getModules());
|
|
249
|
+
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
250
|
+
if (this.device.type === "webgl") {
|
|
251
|
+
this.props._uniformBlockLayouts = (0, import_shader_module_utils.getShaderModuleUniformBlockLayouts)(modules);
|
|
252
|
+
}
|
|
253
|
+
this.props.shaderLayout = (0, import_shader_module_utils.mergeShaderModuleBindingsIntoLayout)(this.props.shaderLayout, modules) || null;
|
|
254
|
+
const isWebGPU = this.device.type === "webgpu";
|
|
255
|
+
if (isWebGPU && this.props.source) {
|
|
256
|
+
const shaderAssembler = this.props.shaderAssembler;
|
|
257
|
+
(0, import_core.assert)(isShaderAssemblerForLanguage(shaderAssembler, "wgsl"));
|
|
258
|
+
const { source, getUniforms, bindingTable, entryPoints = {}, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
259
|
+
platformInfo,
|
|
260
|
+
...this.props,
|
|
261
|
+
modules,
|
|
262
|
+
defines,
|
|
263
|
+
pluginInjections: resolvedPlugins.injections,
|
|
264
|
+
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
265
|
+
pluginVaryings: resolvedPlugins.varyings
|
|
266
|
+
});
|
|
267
|
+
this.source = source;
|
|
268
|
+
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
269
|
+
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
270
|
+
this._getModuleUniforms = getUniforms;
|
|
271
|
+
this._bindingTable = bindingTable;
|
|
272
|
+
const scannedOrReflectedShaderLayout = assembledShaderLayout ?? ((_a = device.getShaderLayout) == null ? void 0 : _a.call(device, this.source));
|
|
273
|
+
const inferredShaderLayout = normalizeShaderPluginAttributeNames(scannedOrReflectedShaderLayout, resolvedPlugins.vertexInputs);
|
|
274
|
+
const shaderLayout = (0, import_shader_module_utils.mergeInferredShaderLayout)(this.props.shaderLayout, inferredShaderLayout, Object.keys(resolvedPlugins.vertexInputs));
|
|
275
|
+
this.props.shaderLayout = (0, import_shader_module_utils.mergeShaderModuleBindingsIntoLayout)(shaderLayout || null, modules) || null;
|
|
276
|
+
} else {
|
|
277
|
+
const shaderAssembler = this.props.shaderAssembler;
|
|
278
|
+
(0, import_core.assert)(isShaderAssemblerForLanguage(shaderAssembler, "glsl"));
|
|
279
|
+
const { vs, fs, getUniforms } = shaderAssembler.assembleGLSLShaderPair({
|
|
280
|
+
platformInfo,
|
|
281
|
+
...this.props,
|
|
282
|
+
modules,
|
|
283
|
+
defines,
|
|
284
|
+
pluginInjections: resolvedPlugins.injections,
|
|
285
|
+
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
286
|
+
pluginVaryings: resolvedPlugins.varyings
|
|
287
|
+
});
|
|
288
|
+
this.vs = vs;
|
|
289
|
+
this.fs = fs;
|
|
290
|
+
this._getModuleUniforms = getUniforms;
|
|
291
|
+
this._bindingTable = [];
|
|
292
|
+
}
|
|
293
|
+
this.pipelineFactory = props.pipelineFactory || import_core.PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
294
|
+
this.shaderFactory = props.shaderFactory || import_core.ShaderFactory.getDefaultShaderFactory(this.device);
|
|
295
|
+
const asyncCompilation = import_core.PipelineFactory.getAsyncCompilation(this.device);
|
|
296
|
+
if (asyncCompilation) {
|
|
297
|
+
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
298
|
+
asyncCompilation.push(this._pipelineInitialization);
|
|
299
|
+
} else {
|
|
300
|
+
this.pipeline = this._updatePipeline();
|
|
301
|
+
this._initializePipelineResources(props);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/** Initializes subclass input policies before shader and pipeline creation. */
|
|
305
|
+
_initializeProps(props) {
|
|
306
|
+
if (props.geometry)
|
|
307
|
+
this.setGeometry(props.geometry);
|
|
308
|
+
if (props.attributeVectors)
|
|
309
|
+
this.setAttributeVectors(props.attributeVectors);
|
|
310
|
+
}
|
|
311
|
+
/** Whether this model manages the uniform buffer for a shader-input module. */
|
|
312
|
+
_usesManagedUniformBuffer(moduleName) {
|
|
313
|
+
void moduleName;
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
async _initializePipelineAsync(props) {
|
|
317
|
+
await this._updatePipelineAsync();
|
|
318
|
+
this._initializePipelineResources(props);
|
|
319
|
+
}
|
|
320
|
+
/** Initializes subclass attributes before explicit constructor bindings are applied. */
|
|
321
|
+
_initializeAttributes() {
|
|
322
|
+
this.applyVectorAttributes();
|
|
323
|
+
if (this.indexVector)
|
|
324
|
+
this.bindIndexVector();
|
|
325
|
+
}
|
|
326
|
+
_initializePipelineResources(props) {
|
|
327
|
+
this.vertexArray = this.device.createVertexArray({
|
|
328
|
+
shaderLayout: this.pipeline.shaderLayout,
|
|
329
|
+
bufferLayout: this.pipeline.bufferLayout
|
|
330
|
+
});
|
|
331
|
+
this._initializeAttributes();
|
|
332
|
+
if (props.indexBuffer)
|
|
333
|
+
this.setIndexBuffer(props.indexBuffer);
|
|
334
|
+
if (props.indexCount !== void 0)
|
|
335
|
+
this.setIndexCount(props.indexCount);
|
|
336
|
+
if (this.constructorDrawOffsets.firstVertex !== void 0)
|
|
337
|
+
this.firstVertex = this.constructorDrawOffsets.firstVertex;
|
|
338
|
+
if (this.constructorDrawOffsets.firstIndex !== void 0)
|
|
339
|
+
this.firstIndex = this.constructorDrawOffsets.firstIndex;
|
|
340
|
+
if (props.isInstanced !== void 0)
|
|
341
|
+
this.isInstanced = props.isInstanced;
|
|
342
|
+
if (this.constructorDrawCounts.instanceCount !== void 0)
|
|
343
|
+
this.setInstanceCount(this.constructorDrawCounts.instanceCount);
|
|
344
|
+
if (this.constructorDrawCounts.vertexCount !== void 0)
|
|
345
|
+
this.setVertexCount(this.constructorDrawCounts.vertexCount);
|
|
346
|
+
if (props.attributes)
|
|
347
|
+
this.setAttributes(props.attributes);
|
|
348
|
+
if (props.constantAttributes)
|
|
349
|
+
this.setConstantAttributes(props.constantAttributes);
|
|
350
|
+
if (props.bindings)
|
|
351
|
+
this.setBindings(props.bindings);
|
|
352
|
+
if (props.transformFeedback)
|
|
353
|
+
this.transformFeedback = props.transformFeedback;
|
|
354
|
+
}
|
|
355
|
+
destroy() {
|
|
356
|
+
if (!this._destroyed) {
|
|
357
|
+
if (this.pipeline) {
|
|
358
|
+
this.pipelineFactory.release(this.pipeline);
|
|
359
|
+
this.shaderFactory.release(this.pipeline.vs);
|
|
360
|
+
if (this.pipeline.fs && this.pipeline.fs !== this.pipeline.vs) {
|
|
361
|
+
this.shaderFactory.release(this.pipeline.fs);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
this.geometryVectorBindings.destroy();
|
|
365
|
+
this.attributeVectorBindings.destroy();
|
|
366
|
+
this._uniformStore.destroy();
|
|
367
|
+
this._destroyed = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
// Draw call
|
|
371
|
+
/** Query redraw status. Clears the status. */
|
|
372
|
+
needsRedraw() {
|
|
373
|
+
if (this._getBindingsUpdateTimestamp() > this._lastDrawTimestamp) {
|
|
374
|
+
this.setNeedsRedraw("contents of bound textures or buffers updated");
|
|
375
|
+
}
|
|
376
|
+
const needsRedraw = this._needsRedraw;
|
|
377
|
+
this._needsRedraw = false;
|
|
378
|
+
return needsRedraw;
|
|
379
|
+
}
|
|
380
|
+
/** Mark the model as needing a redraw */
|
|
381
|
+
setNeedsRedraw(reason) {
|
|
382
|
+
this._needsRedraw ||= reason;
|
|
383
|
+
}
|
|
384
|
+
/** Returns WGSL binding debug rows for the assembled shader. Returns an empty array for GLSL models. */
|
|
385
|
+
getBindingDebugTable() {
|
|
386
|
+
return this._bindingTable;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Updates uniforms and pipeline state before opening a render pass.
|
|
390
|
+
*
|
|
391
|
+
* @param commandEncoder - Encoder that should own any GPU uploads emitted
|
|
392
|
+
* during draw preparation.
|
|
393
|
+
*/
|
|
394
|
+
predraw(commandEncoder) {
|
|
395
|
+
this._syncDynamicBuffers();
|
|
396
|
+
this.updateShaderInputs(commandEncoder);
|
|
397
|
+
this.pipeline = this._updatePipeline();
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Issue one draw call.
|
|
401
|
+
* @param renderPass - render pass to draw into
|
|
402
|
+
* @returns `true` if the draw call was executed, `false` if resources were not ready.
|
|
403
|
+
*/
|
|
404
|
+
draw(renderPass) {
|
|
405
|
+
var _a;
|
|
406
|
+
if (((_a = this.indexVector) == null ? void 0 : _a.length) === 0) {
|
|
407
|
+
this._lastDrawTimestamp = this.device.timestamp;
|
|
408
|
+
this._needsRedraw = false;
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
if (!this.drawingVectorBatches && (this.geometryVectorBindings.batchCount !== 1 || this.attributeVectorBindings.batchCount !== 1)) {
|
|
412
|
+
return this.drawVectorGroups(renderPass);
|
|
413
|
+
}
|
|
414
|
+
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
415
|
+
import_core.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
const loadingBinding = this._areBindingsLoading();
|
|
419
|
+
if (loadingBinding) {
|
|
420
|
+
import_core.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
this._syncAttachmentFormats(renderPass);
|
|
424
|
+
try {
|
|
425
|
+
renderPass.pushDebugGroup(`${this}.predraw(${renderPass})`);
|
|
426
|
+
if (this.device.type === "webgpu") {
|
|
427
|
+
this.updateShaderInputs();
|
|
428
|
+
this._syncDynamicBuffers();
|
|
429
|
+
this.pipeline = this._updatePipeline();
|
|
430
|
+
} else {
|
|
431
|
+
this.predraw(this.device.commandEncoder);
|
|
432
|
+
}
|
|
433
|
+
} finally {
|
|
434
|
+
renderPass.popDebugGroup();
|
|
435
|
+
}
|
|
436
|
+
let drawSuccess;
|
|
437
|
+
let pipelineErrored = this.pipeline.isErrored;
|
|
438
|
+
try {
|
|
439
|
+
renderPass.pushDebugGroup(`${this}.draw(${renderPass})`);
|
|
440
|
+
this._logDrawCallStart();
|
|
441
|
+
this.pipeline = this._updatePipeline();
|
|
442
|
+
pipelineErrored = this.pipeline.isErrored;
|
|
443
|
+
if (pipelineErrored) {
|
|
444
|
+
import_core.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`)();
|
|
445
|
+
drawSuccess = false;
|
|
446
|
+
} else {
|
|
447
|
+
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
448
|
+
if (drawValidationError) {
|
|
449
|
+
import_core.log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
450
|
+
this._drawBlockedReason = drawValidationError;
|
|
451
|
+
drawSuccess = false;
|
|
452
|
+
} else {
|
|
453
|
+
const shaderLayout = this._getCurrentShaderLayout();
|
|
454
|
+
const syncBindings = this._getBindings(shaderLayout);
|
|
455
|
+
const syncBindGroups = this._getBindGroups(shaderLayout, syncBindings);
|
|
456
|
+
const { indexBuffer } = this.vertexArray;
|
|
457
|
+
const indexCount = indexBuffer ? this.indexCount ?? (this._vertexCountSet ? this.vertexCount : indexBuffer.byteLength / (indexBuffer.indexType === "uint32" ? 4 : 2)) : void 0;
|
|
458
|
+
renderPass.setPipeline(this.pipeline);
|
|
459
|
+
renderPass.setBindings(syncBindGroups, {
|
|
460
|
+
_bindGroupCacheKeys: this._getBindGroupCacheKeys()
|
|
461
|
+
});
|
|
462
|
+
renderPass.setVertexArray(this.vertexArray);
|
|
463
|
+
const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
|
|
464
|
+
drawSuccess = hasNoInstances ? true : renderPass.draw({
|
|
465
|
+
isInstanced: this.isInstanced,
|
|
466
|
+
vertexCount: this.vertexCount,
|
|
467
|
+
instanceCount: this.isInstanced ? this.instanceCount : void 0,
|
|
468
|
+
indexCount,
|
|
469
|
+
firstVertex: this.firstVertex,
|
|
470
|
+
firstIndex: this.firstIndex,
|
|
471
|
+
transformFeedback: this.transformFeedback || void 0,
|
|
472
|
+
uniforms: this.props.uniforms,
|
|
473
|
+
// WebGL shares underlying cached programs even for models that have different
|
|
474
|
+
// parameters and topology, so those compatibility overrides remain per draw.
|
|
475
|
+
parameters: this.parameters,
|
|
476
|
+
topology: this.topology
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
} finally {
|
|
481
|
+
renderPass.popDebugGroup();
|
|
482
|
+
this._logDrawCallEnd();
|
|
483
|
+
}
|
|
484
|
+
this._logFramebuffer(renderPass);
|
|
485
|
+
if (drawSuccess) {
|
|
486
|
+
this._lastDrawTimestamp = this.device.timestamp;
|
|
487
|
+
this._needsRedraw = false;
|
|
488
|
+
} else if (pipelineErrored) {
|
|
489
|
+
this._needsRedraw = PIPELINE_INITIALIZATION_FAILED;
|
|
490
|
+
this._drawBlockedReason = PIPELINE_INITIALIZATION_FAILED;
|
|
491
|
+
} else if (this._drawBlockedReason) {
|
|
492
|
+
this._needsRedraw = this._drawBlockedReason;
|
|
493
|
+
} else {
|
|
494
|
+
this._needsRedraw = "waiting for resource initialization";
|
|
495
|
+
}
|
|
496
|
+
return drawSuccess;
|
|
497
|
+
}
|
|
498
|
+
/** Binds a GPU-only mesh. CPU geometry adaptation belongs in Model. */
|
|
499
|
+
setGeometry(geometry) {
|
|
500
|
+
if (geometry)
|
|
501
|
+
this.setTopology(geometry.topology);
|
|
502
|
+
this.setGeometryVectors((geometry == null ? void 0 : geometry.attributes) ?? {}, geometry == null ? void 0 : geometry.bufferLayout);
|
|
503
|
+
this.setIndexVector((geometry == null ? void 0 : geometry.indices) ?? null);
|
|
504
|
+
if ((geometry == null ? void 0 : geometry.vertexCount) !== void 0)
|
|
505
|
+
this.setVertexCount(geometry.vertexCount);
|
|
506
|
+
}
|
|
507
|
+
/** Replaces per-vertex mesh vectors while preserving supplemental attributes. */
|
|
508
|
+
setGeometryVectors(vectors, bufferLayouts) {
|
|
509
|
+
bufferLayouts ??= this.getExplicitVectorLayouts(vectors) ?? this.getExplicitVectorLayouts(vectors, this.geometryVectorBindings.sourceLayouts);
|
|
510
|
+
(0, import_gpu_vector_batch_structure.validateGPUVectorBatchStructure)(vectors);
|
|
511
|
+
if (!this.isInstanced || this.attributeVectorBindings.vertexCount !== void 0)
|
|
512
|
+
(0, import_gpu_vector_batch_structure.validateGPUVectorBatchStructure)([
|
|
513
|
+
...Object.values(vectors),
|
|
514
|
+
...Object.values(this.attributeVectorBindings.inputs)
|
|
515
|
+
]);
|
|
516
|
+
this.geometryVectorBindings.setInputs(vectors, bufferLayouts, "vertex");
|
|
517
|
+
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
518
|
+
this.syncVectorBindings();
|
|
519
|
+
const rowCount = this.geometryVectorBindings.rowCount;
|
|
520
|
+
(0, import_core.assert)(rowCount === void 0 || this.attributeVectorBindings.vertexCount === void 0 || rowCount === this.attributeVectorBindings.vertexCount);
|
|
521
|
+
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
522
|
+
}
|
|
523
|
+
/** Replaces supplemental vectors; instanced models default these inputs to instance step mode. */
|
|
524
|
+
setAttributeVectors(vectors, bufferLayouts) {
|
|
525
|
+
bufferLayouts ??= this.getExplicitVectorLayouts(vectors) ?? this.getExplicitVectorLayouts(vectors, this.attributeVectorBindings.sourceLayouts);
|
|
526
|
+
if (this.isInstanced === void 0 && ((bufferLayouts == null ? void 0 : bufferLayouts.some((layout) => layout.stepMode === "instance")) || Object.values(vectors).some((vector) => {
|
|
527
|
+
var _a;
|
|
528
|
+
return vector && "data" in vector && ((_a = vector.bufferLayout) == null ? void 0 : _a.stepMode) === "instance";
|
|
529
|
+
})))
|
|
530
|
+
this.isInstanced = true;
|
|
531
|
+
const usesVertexRows = !this.isInstanced || Object.entries(vectors).some(([name, vector]) => {
|
|
532
|
+
var _a, _b;
|
|
533
|
+
return vector && "data" in vector && (((_a = bufferLayouts == null ? void 0 : bufferLayouts.find((layout) => {
|
|
534
|
+
var _a2;
|
|
535
|
+
return layout.name === name || ((_a2 = layout.attributes) == null ? void 0 : _a2.some((attribute) => attribute.attribute === name));
|
|
536
|
+
})) == null ? void 0 : _a.stepMode) ?? ((_b = vector.bufferLayout) == null ? void 0 : _b.stepMode)) === "vertex";
|
|
537
|
+
});
|
|
538
|
+
if (usesVertexRows)
|
|
539
|
+
(0, import_gpu_vector_batch_structure.validateGPUVectorBatchStructure)([
|
|
540
|
+
...Object.values(this.geometryVectorBindings.inputs),
|
|
541
|
+
...Object.values(vectors)
|
|
542
|
+
]);
|
|
543
|
+
this.attributeVectorBindings.setInputs(vectors, bufferLayouts, this.isInstanced ? "instance" : "vertex");
|
|
544
|
+
this.claimVectorLayouts(this.attributeVectorBindings);
|
|
545
|
+
this.syncVectorBindings();
|
|
546
|
+
if (this.attributeVectorBindings.instanceCount !== void 0)
|
|
547
|
+
this.setInstanceCount(this.attributeVectorBindings.instanceCount);
|
|
548
|
+
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
549
|
+
if (vertexCount !== void 0) {
|
|
550
|
+
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
551
|
+
(0, import_core.assert)(geometryRowCount === void 0 || geometryRowCount === vertexCount);
|
|
552
|
+
if (geometryRowCount === void 0)
|
|
553
|
+
this.setVertexCount(vertexCount);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/** Binds typed columns using caller-resolved layouts, including packed groups. */
|
|
557
|
+
setGPUAttributes(vectors, bufferLayouts) {
|
|
558
|
+
this.setAttributeVectors(vectors, bufferLayouts);
|
|
559
|
+
}
|
|
560
|
+
/** Replaces the borrowed contiguous uint16/uint32 index vector. */
|
|
561
|
+
setIndexVector(vector) {
|
|
562
|
+
if (vector) {
|
|
563
|
+
(0, import_core.assert)(vector.format === "uint8" || vector.format === "uint16" || vector.format === "uint32");
|
|
564
|
+
(0, import_core.assert)(vector.data.length <= 1);
|
|
565
|
+
(0, import_core.assert)(vector.byteStride === (vector.format === "uint32" ? 4 : vector.format === "uint16" ? 2 : 1));
|
|
566
|
+
}
|
|
567
|
+
this.indexVector = vector;
|
|
568
|
+
if (this.vertexArray)
|
|
569
|
+
this.bindIndexVector();
|
|
570
|
+
}
|
|
571
|
+
bindIndexVector() {
|
|
572
|
+
const vector = this.indexVector;
|
|
573
|
+
const chunk = vector == null ? void 0 : vector.data[0];
|
|
574
|
+
if (chunk && this.indexVector) {
|
|
575
|
+
const buffer = chunk.buffer instanceof import_dynamic.DynamicBuffer ? chunk.buffer.buffer : chunk.buffer;
|
|
576
|
+
(0, import_core.assert)(buffer.indexType === this.indexVector.format && chunk.byteOffset % this.indexVector.byteStride === 0);
|
|
577
|
+
}
|
|
578
|
+
this.indexVector = null;
|
|
579
|
+
this.setIndexBuffer((chunk == null ? void 0 : chunk.buffer) ?? null);
|
|
580
|
+
this.indexVector = vector;
|
|
581
|
+
this.indexCount = vector == null ? void 0 : vector.length;
|
|
582
|
+
this.setDrawOffsets({
|
|
583
|
+
firstVertex: (chunk == null ? void 0 : chunk.byteOffset) ?? 0,
|
|
584
|
+
firstIndex: chunk ? chunk.byteOffset / this.indexVector.byteStride : 0
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
claimVectorLayouts(group) {
|
|
588
|
+
this.explicitBufferLayout = this.explicitBufferLayout.filter((layout) => {
|
|
589
|
+
var _a;
|
|
590
|
+
return !group.claimedNames.has(layout.name) && !((_a = layout.attributes) == null ? void 0 : _a.some((attribute) => group.claimedNames.has(attribute.attribute)));
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
getExplicitVectorLayouts(vectors, sourceLayouts = this.explicitBufferLayout) {
|
|
594
|
+
const names = new Set(Object.keys(vectors));
|
|
595
|
+
const layouts = sourceLayouts.filter((layout) => {
|
|
596
|
+
var _a;
|
|
597
|
+
return names.has(layout.name) || ((_a = layout.attributes) == null ? void 0 : _a.some((attribute) => names.has(attribute.attribute)));
|
|
598
|
+
});
|
|
599
|
+
return layouts.length ? layouts : void 0;
|
|
600
|
+
}
|
|
601
|
+
getVectorBufferLayout() {
|
|
602
|
+
const groups = [this.geometryVectorBindings, this.attributeVectorBindings];
|
|
603
|
+
const explicitLayouts = this.explicitBufferLayout.filter((layout) => !groups.some((group) => {
|
|
604
|
+
var _a;
|
|
605
|
+
return group.claimedNames.has(layout.name) || ((_a = layout.attributes) == null ? void 0 : _a.some((attribute) => group.claimedNames.has(attribute.attribute)));
|
|
606
|
+
}));
|
|
607
|
+
return [
|
|
608
|
+
...explicitLayouts,
|
|
609
|
+
...this.geometryVectorBindings.layouts,
|
|
610
|
+
...this.attributeVectorBindings.layouts
|
|
611
|
+
];
|
|
612
|
+
}
|
|
613
|
+
syncVectorBindings() {
|
|
614
|
+
const layouts = this.getVectorBufferLayout();
|
|
615
|
+
if (this.vertexArray) {
|
|
616
|
+
this.applyBufferLayout(layouts);
|
|
617
|
+
this.applyVectorAttributes();
|
|
618
|
+
} else
|
|
619
|
+
this.bufferLayout = layouts;
|
|
620
|
+
}
|
|
621
|
+
applyVectorAttributes() {
|
|
622
|
+
const activeNames = new Set(this.bufferLayout.map((layout) => layout.name));
|
|
623
|
+
for (const name of Object.keys(this.currentAttributes)) {
|
|
624
|
+
if (!activeNames.has(name))
|
|
625
|
+
delete this.currentAttributes[name];
|
|
626
|
+
}
|
|
627
|
+
this.setAttributes({
|
|
628
|
+
...this.currentAttributes,
|
|
629
|
+
...this.geometryVectorBindings.buffers,
|
|
630
|
+
...this.attributeVectorBindings.buffers
|
|
631
|
+
}, {
|
|
632
|
+
byteOffsets: {
|
|
633
|
+
...this.currentAttributeByteOffsets,
|
|
634
|
+
...this.geometryVectorBindings.byteOffsets,
|
|
635
|
+
...this.attributeVectorBindings.byteOffsets
|
|
636
|
+
},
|
|
637
|
+
disableWarnings: true
|
|
638
|
+
});
|
|
639
|
+
if (this.device.type === "webgl")
|
|
640
|
+
this.setConstantAttributes({
|
|
641
|
+
...this.geometryVectorBindings.constants,
|
|
642
|
+
...this.attributeVectorBindings.constants
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
/** Binds contiguous borrowed vectors; use drawBatches() for multi-chunk inputs. */
|
|
646
|
+
setGPUVectors(vectors, options) {
|
|
647
|
+
var _a;
|
|
648
|
+
const batches = (0, import_gpu_vector_model_batches.getGPUVectorModelBatches)(this.id, vectors);
|
|
649
|
+
(0, import_core.assert)(batches.length <= 1);
|
|
650
|
+
(0, import_gpu_vector_model_batches.validateGPUVectorModelLayouts)(this.id, vectors, this.bufferLayout);
|
|
651
|
+
if (batches[0])
|
|
652
|
+
this.setGPUData(batches[0].data);
|
|
653
|
+
this.setBatchDrawCount(((_a = batches[0]) == null ? void 0 : _a.rowCount) ?? 0, options == null ? void 0 : options.count);
|
|
654
|
+
}
|
|
655
|
+
drawVectorGroups(renderPass) {
|
|
656
|
+
const drawingVectorBatches = this.drawingVectorBatches;
|
|
657
|
+
const vertexCountSet = this._vertexCountSet;
|
|
658
|
+
this.drawingVectorBatches = true;
|
|
659
|
+
try {
|
|
660
|
+
const success = (0, import_gpu_vector_draw_batches.drawGPUVectorGroups)(this, this.geometryVectorBindings, this.attributeVectorBindings, () => this.syncVectorBindings(), () => GPUVectorModel.prototype.draw.call(this, renderPass));
|
|
661
|
+
if (success) {
|
|
662
|
+
this._lastDrawTimestamp = this.device.timestamp;
|
|
663
|
+
this._needsRedraw = false;
|
|
664
|
+
}
|
|
665
|
+
return success;
|
|
666
|
+
} finally {
|
|
667
|
+
this._vertexCountSet = vertexCountSet;
|
|
668
|
+
this.drawingVectorBatches = drawingVectorBatches;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
/** Draws each aligned physical chunk without retaining or taking ownership of input vectors. */
|
|
672
|
+
drawBatches(renderPass, { vectors, onBatch }) {
|
|
673
|
+
const batches = (0, import_gpu_vector_model_batches.getGPUVectorModelBatches)(this.id, vectors);
|
|
674
|
+
(0, import_gpu_vector_model_batches.validateGPUVectorModelLayouts)(this.id, vectors, this.bufferLayout);
|
|
675
|
+
for (const name of Object.keys(vectors)) {
|
|
676
|
+
(0, import_core.assert)(!vectors[name] || this.currentAttributes[name]);
|
|
677
|
+
}
|
|
678
|
+
const previousAttributes = { ...this.currentAttributes };
|
|
679
|
+
const previousAttributeByteOffsets = { ...this.currentAttributeByteOffsets };
|
|
680
|
+
const previousBindings = { ...this.bindings };
|
|
681
|
+
const previousInstanceCount = this.instanceCount;
|
|
682
|
+
const previousVertexCount = this.vertexCount;
|
|
683
|
+
const previousIsInstanced = this.isInstanced;
|
|
684
|
+
const previousVertexCountSet = this._vertexCountSet;
|
|
685
|
+
const drawingVectorBatches = this.drawingVectorBatches;
|
|
686
|
+
this.drawingVectorBatches = true;
|
|
687
|
+
let drawSuccess = true;
|
|
688
|
+
try {
|
|
689
|
+
for (const batch of batches) {
|
|
690
|
+
this.setGPUData(batch.data);
|
|
691
|
+
this.setBatchDrawCount(batch.rowCount);
|
|
692
|
+
onBatch == null ? void 0 : onBatch(batch);
|
|
693
|
+
drawSuccess = GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
|
|
694
|
+
}
|
|
695
|
+
} finally {
|
|
696
|
+
this.setAttributes(previousAttributes, { byteOffsets: previousAttributeByteOffsets });
|
|
697
|
+
for (const name of Object.keys(this.bindings)) {
|
|
698
|
+
if (!(name in previousBindings))
|
|
699
|
+
delete this.bindings[name];
|
|
700
|
+
}
|
|
701
|
+
this.setBindings(previousBindings);
|
|
702
|
+
this.setInstanceCount(previousInstanceCount);
|
|
703
|
+
this.setVertexCount(previousVertexCount);
|
|
704
|
+
this.isInstanced = previousIsInstanced;
|
|
705
|
+
this._vertexCountSet = previousVertexCountSet;
|
|
706
|
+
this.drawingVectorBatches = drawingVectorBatches;
|
|
707
|
+
}
|
|
708
|
+
return drawSuccess;
|
|
709
|
+
}
|
|
710
|
+
setGPUData(data) {
|
|
711
|
+
this.setAttributes(Object.fromEntries(Object.entries(data).map(([name, chunk]) => [name, chunk.buffer])), {
|
|
712
|
+
byteOffsets: Object.fromEntries(Object.entries(data).map(([name, chunk]) => {
|
|
713
|
+
var _a, _b;
|
|
714
|
+
const layout = this.bufferLayout.find((layout2) => layout2.name === name);
|
|
715
|
+
const byteOffset = chunk.byteOffset - (((_b = (_a = layout == null ? void 0 : layout.attributes) == null ? void 0 : _a[0]) == null ? void 0 : _b.byteOffset) ?? 0);
|
|
716
|
+
(0, import_core.assert)(byteOffset >= 0);
|
|
717
|
+
return [name, byteOffset];
|
|
718
|
+
}))
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
setBatchDrawCount(rowCount, count = this.props.gpuVectorCount) {
|
|
722
|
+
if (count === "instance") {
|
|
723
|
+
this.setInstanceCount(rowCount);
|
|
724
|
+
} else if (count === "vertex") {
|
|
725
|
+
this.setVertexCount(rowCount);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
// Update fixed fields (can trigger pipeline rebuild)
|
|
729
|
+
/**
|
|
730
|
+
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
731
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
732
|
+
*/
|
|
733
|
+
setTopology(topology) {
|
|
734
|
+
if (topology !== this.topology) {
|
|
735
|
+
this.topology = topology;
|
|
736
|
+
this._setPipelineNeedsUpdate("topology");
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Updates the buffer layout.
|
|
741
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
742
|
+
*/
|
|
743
|
+
setBufferLayout(bufferLayout) {
|
|
744
|
+
this.explicitBufferLayout = bufferLayout;
|
|
745
|
+
const geometry = this.geometryVectorBindings;
|
|
746
|
+
const attributes = this.attributeVectorBindings;
|
|
747
|
+
const geometryLayouts = this.getExplicitVectorLayouts(geometry.inputs) ?? geometry.sourceLayouts;
|
|
748
|
+
const attributeLayouts = this.getExplicitVectorLayouts(attributes.inputs) ?? attributes.sourceLayouts;
|
|
749
|
+
geometry.setInputs(geometry.inputs, geometryLayouts, "vertex");
|
|
750
|
+
attributes.setInputs(attributes.inputs, attributeLayouts, this.isInstanced ? "instance" : "vertex");
|
|
751
|
+
if (!this.isInstanced || attributes.vertexCount !== void 0)
|
|
752
|
+
(0, import_gpu_vector_batch_structure.validateGPUVectorBatchStructure)([
|
|
753
|
+
...Object.values(geometry.inputs),
|
|
754
|
+
...Object.values(attributes.inputs)
|
|
755
|
+
]);
|
|
756
|
+
this.claimVectorLayouts(geometry);
|
|
757
|
+
this.claimVectorLayouts(attributes);
|
|
758
|
+
this.applyBufferLayout(this.getVectorBufferLayout());
|
|
759
|
+
}
|
|
760
|
+
applyBufferLayout(nextBufferLayout) {
|
|
761
|
+
nextBufferLayout = (0, import_buffer_layout_order.sortedBufferLayoutByShaderSourceLocations)(this.pipeline.shaderLayout, nextBufferLayout);
|
|
762
|
+
if ((0, import_deep_equal.deepEqual)(nextBufferLayout, this.bufferLayout, -1)) {
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
this.bufferLayout = nextBufferLayout;
|
|
766
|
+
this._setPipelineNeedsUpdate("bufferLayout");
|
|
767
|
+
this.pipeline = this._updatePipeline();
|
|
768
|
+
this.vertexArray = this.device.createVertexArray({
|
|
769
|
+
shaderLayout: this.pipeline.shaderLayout,
|
|
770
|
+
bufferLayout: this.pipeline.bufferLayout
|
|
771
|
+
});
|
|
772
|
+
this._dynamicAttributeBufferSources = {};
|
|
773
|
+
this.applyVectorAttributes();
|
|
774
|
+
if (this.indexBuffer)
|
|
775
|
+
this.vertexArray.setIndexBuffer(this.indexBuffer);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Set GPU parameters.
|
|
779
|
+
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU.
|
|
780
|
+
* On WebGL, parameters are applied at each draw call, so the pipeline is kept.
|
|
781
|
+
* @param parameters
|
|
782
|
+
*/
|
|
783
|
+
setParameters(parameters) {
|
|
784
|
+
if (!(0, import_deep_equal.deepEqual)(parameters, this.parameters, 2)) {
|
|
785
|
+
this.parameters = parameters;
|
|
786
|
+
if (this.device.type === "webgl") {
|
|
787
|
+
this.setNeedsRedraw("parameters");
|
|
788
|
+
} else {
|
|
789
|
+
this._setPipelineNeedsUpdate("parameters");
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
// Update dynamic fields
|
|
794
|
+
/**
|
|
795
|
+
* Updates the instance count (used in draw calls)
|
|
796
|
+
* @note Any attributes with stepMode=instance need to be at least this big
|
|
797
|
+
*/
|
|
798
|
+
setInstanceCount(instanceCount) {
|
|
799
|
+
this.instanceCount = instanceCount;
|
|
800
|
+
if (this.isInstanced === void 0 && instanceCount > 0) {
|
|
801
|
+
this.isInstanced = true;
|
|
802
|
+
}
|
|
803
|
+
this.setNeedsRedraw("instanceCount");
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Updates the vertex count (used in draw calls)
|
|
807
|
+
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
808
|
+
*/
|
|
809
|
+
setVertexCount(vertexCount) {
|
|
810
|
+
this.vertexCount = vertexCount;
|
|
811
|
+
this._vertexCountSet = true;
|
|
812
|
+
this.setNeedsRedraw("vertexCount");
|
|
813
|
+
}
|
|
814
|
+
/** Updates the indexed draw count override. */
|
|
815
|
+
setIndexCount(indexCount) {
|
|
816
|
+
this.indexCount = indexCount;
|
|
817
|
+
this.setNeedsRedraw("indexCount");
|
|
818
|
+
}
|
|
819
|
+
/** Updates the first indexed/non-indexed draw offsets. */
|
|
820
|
+
setDrawOffsets({ firstVertex, firstIndex }) {
|
|
821
|
+
this.firstVertex = firstVertex;
|
|
822
|
+
this.firstIndex = firstIndex;
|
|
823
|
+
this.setNeedsRedraw("drawOffsets");
|
|
824
|
+
}
|
|
825
|
+
/** Set the shader inputs */
|
|
826
|
+
setShaderInputs(shaderInputs) {
|
|
827
|
+
this.shaderInputs = shaderInputs;
|
|
828
|
+
this._uniformStore = new import_core.UniformStore(this.device, this.shaderInputs.modules);
|
|
829
|
+
for (const [moduleName, module2] of Object.entries(this.shaderInputs.modules)) {
|
|
830
|
+
if ((0, import_shader_module_utils.shaderModuleHasUniforms)(module2) && this._usesManagedUniformBuffer(moduleName)) {
|
|
831
|
+
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
832
|
+
this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
this.setNeedsRedraw("shaderInputs");
|
|
836
|
+
}
|
|
837
|
+
/** Update uniform buffers from the model's shader inputs */
|
|
838
|
+
/**
|
|
839
|
+
* Flushes current shader-input values into managed uniform buffers and
|
|
840
|
+
* resource bindings.
|
|
841
|
+
*
|
|
842
|
+
* @param commandEncoder - Optional encoder used to order uniform uploads with
|
|
843
|
+
* subsequent draw commands.
|
|
844
|
+
*/
|
|
845
|
+
updateShaderInputs(commandEncoder) {
|
|
846
|
+
this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(), commandEncoder);
|
|
847
|
+
this.setBindings(this._getShaderInputBindings());
|
|
848
|
+
this.setNeedsRedraw("shaderInputs");
|
|
849
|
+
}
|
|
850
|
+
/** Resolves resource bindings supplied by shader inputs. */
|
|
851
|
+
_getShaderInputBindings() {
|
|
852
|
+
return this.shaderInputs.getBindingValues();
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Sets bindings (textures, samplers, uniform buffers)
|
|
856
|
+
*/
|
|
857
|
+
setBindings(bindings) {
|
|
858
|
+
Object.assign(this.bindings, bindings);
|
|
859
|
+
this.setNeedsRedraw("bindings");
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Updates optional transform feedback. WebGL only.
|
|
863
|
+
*/
|
|
864
|
+
setTransformFeedback(transformFeedback) {
|
|
865
|
+
this.transformFeedback = transformFeedback;
|
|
866
|
+
this.setNeedsRedraw("transformFeedback");
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Sets the index buffer
|
|
870
|
+
* @todo - how to unset it if we change geometry?
|
|
871
|
+
*/
|
|
872
|
+
setIndexBuffer(indexBuffer) {
|
|
873
|
+
if (this.indexVector) {
|
|
874
|
+
this.indexCount = void 0;
|
|
875
|
+
this.firstVertex = 0;
|
|
876
|
+
this.firstIndex = 0;
|
|
877
|
+
}
|
|
878
|
+
this.indexVector = null;
|
|
879
|
+
const resolvedIndexBuffer = indexBuffer instanceof import_dynamic.DynamicBuffer ? indexBuffer.buffer : indexBuffer;
|
|
880
|
+
this.indexBuffer = resolvedIndexBuffer;
|
|
881
|
+
this._dynamicIndexBufferSource = indexBuffer instanceof import_dynamic.DynamicBuffer ? { source: indexBuffer, generation: indexBuffer.generation } : null;
|
|
882
|
+
this.vertexArray.setIndexBuffer(resolvedIndexBuffer);
|
|
883
|
+
this.setNeedsRedraw("indexBuffer");
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Sets attributes (buffers)
|
|
887
|
+
* @param options.byteOffsets Optional byte offsets, keyed by buffer name, where each buffer's
|
|
888
|
+
* vertex data starts. Buffers without an entry are bound at offset 0.
|
|
889
|
+
* @note Overrides any attributes previously set with the same name
|
|
890
|
+
*/
|
|
891
|
+
setAttributes(buffers, options) {
|
|
892
|
+
var _a, _b;
|
|
893
|
+
Object.assign(this.currentAttributes, buffers);
|
|
894
|
+
for (const name of Object.keys(buffers)) {
|
|
895
|
+
this.currentAttributeByteOffsets[name] = ((_a = options == null ? void 0 : options.byteOffsets) == null ? void 0 : _a[name]) ?? 0;
|
|
896
|
+
}
|
|
897
|
+
this._drawBlockedReason = false;
|
|
898
|
+
const disableWarnings = (options == null ? void 0 : options.disableWarnings) ?? this.props.disableWarnings;
|
|
899
|
+
if (buffers["indices"]) {
|
|
900
|
+
import_core.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
|
|
901
|
+
}
|
|
902
|
+
this.bufferLayout = (0, import_buffer_layout_order.sortedBufferLayoutByShaderSourceLocations)(this.pipeline.shaderLayout, this.bufferLayout);
|
|
903
|
+
const bufferLayoutHelper = new import_buffer_layout_helper.BufferLayoutHelper(this.bufferLayout);
|
|
904
|
+
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
905
|
+
const resolvedBuffer = buffer instanceof import_dynamic.DynamicBuffer ? buffer.buffer : buffer;
|
|
906
|
+
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
907
|
+
if (!bufferLayout) {
|
|
908
|
+
if (!disableWarnings) {
|
|
909
|
+
import_core.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
910
|
+
}
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
913
|
+
const attributeNames = bufferLayoutHelper.getAttributeNamesForBuffer(bufferLayout);
|
|
914
|
+
let set = false;
|
|
915
|
+
for (const attributeName of attributeNames) {
|
|
916
|
+
const attributeInfo = this._attributeInfos[attributeName];
|
|
917
|
+
if (attributeInfo) {
|
|
918
|
+
const bufferSlot = this.device.type === "webgpu" ? this.vertexArray.getBufferSlot(attributeInfo.bufferName) : attributeInfo.location;
|
|
919
|
+
if (bufferSlot === null) {
|
|
920
|
+
if (!disableWarnings) {
|
|
921
|
+
import_core.log.warn(`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`)();
|
|
922
|
+
}
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
const byteOffset = ((_b = options == null ? void 0 : options.byteOffsets) == null ? void 0 : _b[bufferName]) ?? 0;
|
|
926
|
+
this.vertexArray.setBuffer(bufferSlot, resolvedBuffer, byteOffset);
|
|
927
|
+
if (buffer instanceof import_dynamic.DynamicBuffer) {
|
|
928
|
+
this._dynamicAttributeBufferSources[bufferSlot] = {
|
|
929
|
+
source: buffer,
|
|
930
|
+
generation: buffer.generation,
|
|
931
|
+
byteOffset
|
|
932
|
+
};
|
|
933
|
+
} else {
|
|
934
|
+
delete this._dynamicAttributeBufferSources[bufferSlot];
|
|
935
|
+
}
|
|
936
|
+
set = true;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (!set && !disableWarnings) {
|
|
940
|
+
import_core.log.warn(`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`)();
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
this.setNeedsRedraw("attributes");
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Sets constant attributes
|
|
947
|
+
* @note Overrides any attributes previously set with the same name
|
|
948
|
+
* Constant attributes are only supported in WebGL, not in WebGPU
|
|
949
|
+
* Any attribute that is disabled in the current vertex array object
|
|
950
|
+
* is read from the context's global constant value for that attribute location.
|
|
951
|
+
* @param constantAttributes
|
|
952
|
+
*/
|
|
953
|
+
setConstantAttributes(attributes, options) {
|
|
954
|
+
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
955
|
+
const attributeInfo = this._attributeInfos[attributeName];
|
|
956
|
+
if (attributeInfo) {
|
|
957
|
+
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
958
|
+
} else if (!((options == null ? void 0 : options.disableWarnings) ?? this.props.disableWarnings)) {
|
|
959
|
+
import_core.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
this.setNeedsRedraw("constants");
|
|
963
|
+
}
|
|
964
|
+
// INTERNAL METHODS
|
|
965
|
+
/** Check that bindings are loaded. Returns id of first binding that is still loading. */
|
|
966
|
+
_areBindingsLoading() {
|
|
967
|
+
for (const binding of Object.values(this.bindings)) {
|
|
968
|
+
if ((0, import_dynamic2.isTextureBindingSource)(binding) && !binding.isReady) {
|
|
969
|
+
return binding.id;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
return false;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Resolves ready model bindings for the current shader layout.
|
|
976
|
+
* @param shaderLayout Reflected bindings used to select copied or external texture resolution.
|
|
977
|
+
*/
|
|
978
|
+
_getBindings(shaderLayout = this._getCurrentShaderLayout()) {
|
|
979
|
+
const validBindings = {};
|
|
980
|
+
for (const [name, binding] of Object.entries(this.bindings)) {
|
|
981
|
+
const resolvedBinding = resolveModelBinding(name, binding, shaderLayout);
|
|
982
|
+
if (resolvedBinding) {
|
|
983
|
+
validBindings[name] = resolvedBinding;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return validBindings;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Groups resolved resource bindings for the current shader layout.
|
|
990
|
+
* @param shaderLayout Reflected bindings used to group logical binding names.
|
|
991
|
+
* @param bindings GPUVectorModel bindings already resolved for this draw preparation.
|
|
992
|
+
*/
|
|
993
|
+
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
994
|
+
return shaderLayout.bindings.length ? (0, import_core.normalizeBindingsByGroup)(shaderLayout, bindings) : { 0: bindings };
|
|
995
|
+
}
|
|
996
|
+
_getBindGroupCacheKeys() {
|
|
997
|
+
return {};
|
|
998
|
+
}
|
|
999
|
+
/** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
|
|
1000
|
+
_getBindingsUpdateTimestamp() {
|
|
1001
|
+
let timestamp = 0;
|
|
1002
|
+
if (this._dynamicIndexBufferSource) {
|
|
1003
|
+
timestamp = Math.max(timestamp, this._dynamicIndexBufferSource.source.updateTimestamp);
|
|
1004
|
+
}
|
|
1005
|
+
for (const entry of Object.values(this._dynamicAttributeBufferSources)) {
|
|
1006
|
+
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
1007
|
+
}
|
|
1008
|
+
for (const binding of Object.values(this.bindings)) {
|
|
1009
|
+
if (binding instanceof import_core.TextureView) {
|
|
1010
|
+
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
1011
|
+
} else if (binding instanceof import_core.Buffer || binding instanceof import_core.Texture || binding instanceof import_core.ExternalTexture) {
|
|
1012
|
+
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
1013
|
+
} else if (binding instanceof import_dynamic.DynamicBuffer) {
|
|
1014
|
+
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
1015
|
+
} else if ((0, import_dynamic2.isTextureBindingSource)(binding)) {
|
|
1016
|
+
timestamp = binding.isReady ? Math.max(timestamp, binding.updateTimestamp) : (
|
|
1017
|
+
// The texture will become available in the future
|
|
1018
|
+
Infinity
|
|
1019
|
+
);
|
|
1020
|
+
} else if ((0, import_dynamic.isBufferRangeBinding)(binding)) {
|
|
1021
|
+
timestamp = Math.max(timestamp, binding.buffer instanceof import_dynamic.DynamicBuffer ? binding.buffer.updateTimestamp : binding.buffer.updateTimestamp);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
return timestamp;
|
|
1025
|
+
}
|
|
1026
|
+
/** Mark pipeline as needing update */
|
|
1027
|
+
_setPipelineNeedsUpdate(reason) {
|
|
1028
|
+
this._pipelineNeedsUpdate ||= reason;
|
|
1029
|
+
this._drawBlockedReason = false;
|
|
1030
|
+
this.setNeedsRedraw(reason);
|
|
1031
|
+
}
|
|
1032
|
+
/** Update pipeline if needed */
|
|
1033
|
+
_updatePipeline() {
|
|
1034
|
+
const update = this._preparePipelineUpdate();
|
|
1035
|
+
if (update) {
|
|
1036
|
+
this.pipeline = this.pipelineFactory.createRenderPipeline(update.props);
|
|
1037
|
+
this._finishPipelineUpdate(update);
|
|
1038
|
+
}
|
|
1039
|
+
return this.pipeline;
|
|
1040
|
+
}
|
|
1041
|
+
/** Creates or replaces the render pipeline through the backend's asynchronous compilation path. */
|
|
1042
|
+
async _updatePipelineAsync() {
|
|
1043
|
+
const update = this._preparePipelineUpdate();
|
|
1044
|
+
if (update) {
|
|
1045
|
+
try {
|
|
1046
|
+
this.pipeline = await this.pipelineFactory.createRenderPipelineAsync(update.props);
|
|
1047
|
+
} catch (error) {
|
|
1048
|
+
this._releasePipelineShaders(update.vertexShader, update.fragmentShader);
|
|
1049
|
+
this._pipelineNeedsUpdate = "asynchronous pipeline creation failed";
|
|
1050
|
+
throw error;
|
|
1051
|
+
}
|
|
1052
|
+
this._finishPipelineUpdate(update);
|
|
1053
|
+
}
|
|
1054
|
+
return this.pipeline;
|
|
1055
|
+
}
|
|
1056
|
+
_preparePipelineUpdate() {
|
|
1057
|
+
var _a, _b;
|
|
1058
|
+
if (!this._pipelineNeedsUpdate)
|
|
1059
|
+
return null;
|
|
1060
|
+
const previousVertexShader = ((_a = this.pipeline) == null ? void 0 : _a.vs) ?? null;
|
|
1061
|
+
const previousFragmentShader = ((_b = this.pipeline) == null ? void 0 : _b.fs) ?? null;
|
|
1062
|
+
if (this.pipeline) {
|
|
1063
|
+
import_core.log.log(1, `GPUVectorModel ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
1064
|
+
}
|
|
1065
|
+
this._pipelineNeedsUpdate = false;
|
|
1066
|
+
const vertexShader = this.shaderFactory.createShader({
|
|
1067
|
+
id: `${this.id}-vertex`,
|
|
1068
|
+
stage: "vertex",
|
|
1069
|
+
source: this.source || this.vs,
|
|
1070
|
+
debugShaders: this.props.debugShaders
|
|
1071
|
+
});
|
|
1072
|
+
let fragmentShader = null;
|
|
1073
|
+
if (this.source) {
|
|
1074
|
+
fragmentShader = vertexShader;
|
|
1075
|
+
} else if (this.fs) {
|
|
1076
|
+
fragmentShader = this.shaderFactory.createShader({
|
|
1077
|
+
id: `${this.id}-fragment`,
|
|
1078
|
+
stage: "fragment",
|
|
1079
|
+
source: this.fs,
|
|
1080
|
+
debugShaders: this.props.debugShaders
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
return {
|
|
1084
|
+
props: {
|
|
1085
|
+
...this.props,
|
|
1086
|
+
bindings: void 0,
|
|
1087
|
+
bufferLayout: this.bufferLayout,
|
|
1088
|
+
colorAttachmentFormats: this._colorAttachmentFormats,
|
|
1089
|
+
depthStencilAttachmentFormat: this._depthStencilAttachmentFormat,
|
|
1090
|
+
topology: this.topology,
|
|
1091
|
+
parameters: this.parameters,
|
|
1092
|
+
bindGroups: void 0,
|
|
1093
|
+
vs: vertexShader,
|
|
1094
|
+
fs: fragmentShader
|
|
1095
|
+
},
|
|
1096
|
+
vertexShader,
|
|
1097
|
+
fragmentShader,
|
|
1098
|
+
previousVertexShader,
|
|
1099
|
+
previousFragmentShader
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
_finishPipelineUpdate(update) {
|
|
1103
|
+
this._attributeInfos = (0, import_core.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout, this.bufferLayout);
|
|
1104
|
+
this._releasePipelineShaders(update.previousVertexShader, update.previousFragmentShader);
|
|
1105
|
+
}
|
|
1106
|
+
_releasePipelineShaders(vertexShader, fragmentShader) {
|
|
1107
|
+
if (vertexShader)
|
|
1108
|
+
this.shaderFactory.release(vertexShader);
|
|
1109
|
+
if (fragmentShader && fragmentShader !== vertexShader) {
|
|
1110
|
+
this.shaderFactory.release(fragmentShader);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
/** Throttle draw call logging */
|
|
1114
|
+
_lastLogTime = 0;
|
|
1115
|
+
_logOpen = false;
|
|
1116
|
+
_logDrawCallStart() {
|
|
1117
|
+
const logDrawTimeout = import_core.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
1118
|
+
if (import_core.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
this._lastLogTime = Date.now();
|
|
1122
|
+
this._logOpen = true;
|
|
1123
|
+
import_core.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core.log.level <= 2 })();
|
|
1124
|
+
}
|
|
1125
|
+
_logDrawCallEnd() {
|
|
1126
|
+
if (this._logOpen) {
|
|
1127
|
+
const shaderLayoutTable = (0, import_debug_shader_layout.getDebugTableForShaderLayout)(this.pipeline.shaderLayout, this.id);
|
|
1128
|
+
import_core.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
1129
|
+
const uniformTable = this.shaderInputs.getDebugTable();
|
|
1130
|
+
import_core.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
1131
|
+
const attributeTable = this._getAttributeDebugTable();
|
|
1132
|
+
import_core.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
1133
|
+
import_core.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
1134
|
+
import_core.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
1135
|
+
this._logOpen = false;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
_drawCount = 0;
|
|
1139
|
+
_logFramebuffer(renderPass) {
|
|
1140
|
+
const debugFramebuffers = this.device.props.debugFramebuffers;
|
|
1141
|
+
this._drawCount++;
|
|
1142
|
+
if (!debugFramebuffers) {
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const framebuffer = renderPass.props.framebuffer;
|
|
1146
|
+
(0, import_debug_framebuffer.debugFramebuffer)(renderPass, framebuffer, {
|
|
1147
|
+
id: (framebuffer == null ? void 0 : framebuffer.id) || `${this.id}-framebuffer`,
|
|
1148
|
+
minimap: true
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
_getAttributeDebugTable() {
|
|
1152
|
+
const table = {};
|
|
1153
|
+
for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
|
|
1154
|
+
const values = this.vertexArray.attributes[attributeInfo.location];
|
|
1155
|
+
table[attributeInfo.location] = {
|
|
1156
|
+
name,
|
|
1157
|
+
type: attributeInfo.shaderType,
|
|
1158
|
+
values: values ? this._getBufferOrConstantValues(values, attributeInfo.bufferDataType) : "null"
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
if (this.vertexArray.indexBuffer) {
|
|
1162
|
+
const { indexBuffer } = this.vertexArray;
|
|
1163
|
+
const values = indexBuffer.indexType === "uint32" ? new Uint32Array(indexBuffer.debugData) : new Uint16Array(indexBuffer.debugData);
|
|
1164
|
+
table["indices"] = {
|
|
1165
|
+
name: "indices",
|
|
1166
|
+
type: indexBuffer.indexType,
|
|
1167
|
+
values: values.toString()
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
return table;
|
|
1171
|
+
}
|
|
1172
|
+
// TODO - fix typing of luma data types
|
|
1173
|
+
_getBufferOrConstantValues(attribute, dataType) {
|
|
1174
|
+
const TypedArrayConstructor = import_core.dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
1175
|
+
const typedArray = attribute instanceof import_core.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
1176
|
+
return typedArray.toString();
|
|
1177
|
+
}
|
|
1178
|
+
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
1179
|
+
_getCurrentShaderLayout() {
|
|
1180
|
+
var _a;
|
|
1181
|
+
return ((_a = this.pipeline) == null ? void 0 : _a.shaderLayout) || this.props.shaderLayout || { bindings: [] };
|
|
1182
|
+
}
|
|
1183
|
+
_syncDynamicBuffers() {
|
|
1184
|
+
if (this._dynamicIndexBufferSource && this._dynamicIndexBufferSource.generation !== this._dynamicIndexBufferSource.source.generation) {
|
|
1185
|
+
const resolvedIndexBuffer = this._dynamicIndexBufferSource.source.buffer;
|
|
1186
|
+
this.indexBuffer = resolvedIndexBuffer;
|
|
1187
|
+
this.vertexArray.setIndexBuffer(resolvedIndexBuffer);
|
|
1188
|
+
this._dynamicIndexBufferSource.generation = this._dynamicIndexBufferSource.source.generation;
|
|
1189
|
+
this.setNeedsRedraw("dynamic index buffer");
|
|
1190
|
+
}
|
|
1191
|
+
for (const [locationKey, entry] of Object.entries(this._dynamicAttributeBufferSources)) {
|
|
1192
|
+
if (entry.generation !== entry.source.generation) {
|
|
1193
|
+
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer, entry.byteOffset);
|
|
1194
|
+
entry.generation = entry.source.generation;
|
|
1195
|
+
this.setNeedsRedraw("dynamic attribute buffer");
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
_syncAttachmentFormats(renderPass) {
|
|
1200
|
+
var _a, _b, _c;
|
|
1201
|
+
if (this.device.type !== "webgpu") {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
const framebuffer = renderPass.framebuffer || renderPass.props.framebuffer;
|
|
1205
|
+
const renderBundleProps = renderPass.props;
|
|
1206
|
+
const nextColorAttachmentFormats = renderBundleProps.colorAttachmentFormats ?? ((_a = framebuffer == null ? void 0 : framebuffer.colorAttachments) == null ? void 0 : _a.map((colorAttachment) => {
|
|
1207
|
+
var _a2;
|
|
1208
|
+
return asColorAttachmentFormat((_a2 = colorAttachment == null ? void 0 : colorAttachment.texture) == null ? void 0 : _a2.format);
|
|
1209
|
+
}));
|
|
1210
|
+
const nextDepthStencilAttachmentFormat = renderBundleProps.depthStencilAttachmentFormat === false ? void 0 : renderBundleProps.depthStencilAttachmentFormat ?? asDepthStencilAttachmentFormat((_c = (_b = framebuffer == null ? void 0 : framebuffer.depthStencilAttachment) == null ? void 0 : _b.texture) == null ? void 0 : _c.format);
|
|
1211
|
+
if (!(0, import_deep_equal.deepEqual)(this._colorAttachmentFormats, nextColorAttachmentFormats, 1) || this._depthStencilAttachmentFormat !== nextDepthStencilAttachmentFormat) {
|
|
1212
|
+
this._colorAttachmentFormats = nextColorAttachmentFormats;
|
|
1213
|
+
this._depthStencilAttachmentFormat = nextDepthStencilAttachmentFormat;
|
|
1214
|
+
this._setPipelineNeedsUpdate("attachment formats");
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function isShaderAssemblerForLanguage(shaderAssembler, shaderLanguage) {
|
|
1219
|
+
if (shaderAssembler.shaderLanguage !== void 0 && shaderAssembler.shaderLanguage !== shaderLanguage) {
|
|
1220
|
+
return false;
|
|
1221
|
+
}
|
|
1222
|
+
return shaderLanguage === "glsl" ? "assembleGLSLShaderPair" in shaderAssembler && typeof shaderAssembler.assembleGLSLShaderPair === "function" : "assembleWGSLShader" in shaderAssembler && typeof shaderAssembler.assembleWGSLShader === "function";
|
|
1223
|
+
}
|
|
1224
|
+
function normalizeShaderPluginAttributeNames(shaderLayout, vertexInputs) {
|
|
1225
|
+
if (!shaderLayout || Object.keys(vertexInputs).length === 0) {
|
|
1226
|
+
return shaderLayout;
|
|
1227
|
+
}
|
|
1228
|
+
return {
|
|
1229
|
+
...shaderLayout,
|
|
1230
|
+
attributes: shaderLayout.attributes.map((attribute) => {
|
|
1231
|
+
const publicName = attribute.name.startsWith("_luma_") ? attribute.name.slice("_luma_".length) : null;
|
|
1232
|
+
return publicName && vertexInputs[publicName] ? { ...attribute, name: publicName } : attribute;
|
|
1233
|
+
})
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
function resolveModelBinding(bindingName, binding, shaderLayout) {
|
|
1237
|
+
if ((0, import_dynamic2.isTextureBindingSource)(binding)) {
|
|
1238
|
+
const bindingLayout = (0, import_dynamic2.getTextureBindingLayout)(shaderLayout, bindingName, {
|
|
1239
|
+
fallbackGroup: 0
|
|
1240
|
+
});
|
|
1241
|
+
return bindingLayout ? binding.resolveTextureBinding(bindingLayout) : null;
|
|
1242
|
+
}
|
|
1243
|
+
if (binding instanceof import_dynamic.DynamicBuffer) {
|
|
1244
|
+
return binding.buffer;
|
|
1245
|
+
}
|
|
1246
|
+
if ((0, import_dynamic.isBufferRangeBinding)(binding)) {
|
|
1247
|
+
return (0, import_dynamic.resolveBufferRangeBinding)(binding);
|
|
1248
|
+
}
|
|
1249
|
+
return binding;
|
|
1250
|
+
}
|
|
1251
|
+
function asColorAttachmentFormat(format) {
|
|
1252
|
+
return format && !isDepthStencilAttachmentFormat(format) ? format : null;
|
|
1253
|
+
}
|
|
1254
|
+
function asDepthStencilAttachmentFormat(format) {
|
|
1255
|
+
return format && isDepthStencilAttachmentFormat(format) ? format : void 0;
|
|
1256
|
+
}
|
|
1257
|
+
function isDepthStencilAttachmentFormat(format) {
|
|
1258
|
+
return DEPTH_STENCIL_ATTACHMENT_FORMATS.includes(format);
|
|
1259
|
+
}
|
|
1260
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1261
|
+
0 && (module.exports = {
|
|
1262
|
+
GPUVectorModel,
|
|
1263
|
+
getGPUVectorModelBatches
|
|
1264
|
+
});
|