@luma.gl/engine 10.0.0-alpha.4 → 10.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/animation/animation-clip.cjs +36 -0
- package/dist/animation/animation-interpolation.cjs +115 -0
- package/dist/animation/animation-mixer.cjs +302 -0
- package/dist/animation/animation-track.cjs +55 -0
- package/dist/animation/animator.cjs +75 -0
- package/dist/animation/deform-positions.cjs +69 -0
- package/dist/animation/deform-positions.d.ts +13 -0
- package/dist/animation/deform-positions.d.ts.map +1 -0
- package/dist/animation/deform-positions.js +49 -0
- package/dist/animation/deform-positions.js.map +1 -0
- package/dist/animation/key-frames.cjs +81 -0
- package/dist/animation/morph-targets.cjs +162 -0
- package/dist/animation/node-animation-binding.cjs +67 -0
- package/dist/animation/node-animation-binding.d.ts +9 -0
- package/dist/animation/node-animation-binding.d.ts.map +1 -0
- package/dist/animation/node-animation-binding.js +45 -0
- package/dist/animation/node-animation-binding.js.map +1 -0
- package/dist/animation/property-animation-binding.cjs +159 -0
- package/dist/animation/property-animation-binding.d.ts +29 -0
- package/dist/animation/property-animation-binding.d.ts.map +1 -0
- package/dist/animation/property-animation-binding.js +138 -0
- package/dist/animation/property-animation-binding.js.map +1 -0
- package/dist/animation/scenegraph-animator.cjs +122 -0
- package/dist/animation/scenegraph-animator.d.ts +37 -0
- package/dist/animation/scenegraph-animator.d.ts.map +1 -0
- package/dist/animation/scenegraph-animator.js +99 -0
- package/dist/animation/scenegraph-animator.js.map +1 -0
- package/dist/animation/skin.cjs +49 -0
- package/dist/animation/texture-transform.cjs +41 -0
- package/dist/animation/texture-transform.d.ts +8 -0
- package/dist/animation/texture-transform.d.ts.map +1 -0
- package/dist/animation/texture-transform.js +17 -0
- package/dist/animation/texture-transform.js.map +1 -0
- package/dist/animation/timeline.cjs +129 -0
- package/dist/animation-loop/animation-loop-template.cjs +33 -0
- package/dist/animation-loop/animation-loop.cjs +498 -0
- package/dist/animation-loop/animation-loop.d.ts +2 -1
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +9 -3
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.cjs +15 -0
- package/dist/animation-loop/make-animation-loop.cjs +104 -0
- package/dist/animation-loop/request-animation-frame.cjs +43 -0
- package/dist/application-utils/load-file.cjs +77 -0
- package/dist/application-utils/random.cjs +38 -0
- package/dist/audio/audio-controller.cjs +429 -0
- package/dist/audio/audio-controller.d.ts +146 -0
- package/dist/audio/audio-controller.d.ts.map +1 -0
- package/dist/audio/audio-controller.js +445 -0
- package/dist/audio/audio-controller.js.map +1 -0
- package/dist/audio/audio-environment.cjs +157 -0
- package/dist/audio/audio-environment.d.ts +49 -0
- package/dist/audio/audio-environment.d.ts.map +1 -0
- package/dist/audio/audio-environment.js +148 -0
- package/dist/audio/audio-environment.js.map +1 -0
- package/dist/audio/audio-graph.cjs +182 -0
- package/dist/audio/audio-graph.d.ts +58 -0
- package/dist/audio/audio-graph.d.ts.map +1 -0
- package/dist/audio/audio-graph.js +181 -0
- package/dist/audio/audio-graph.js.map +1 -0
- package/dist/compute/buffer-transform.cjs +146 -0
- package/dist/compute/buffer-transform.d.ts +15 -5
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +56 -12
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.cjs +331 -0
- package/dist/compute/computation.d.ts +2 -4
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -14
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.cjs +132 -0
- package/dist/compute/texture-transform.cjs +142 -0
- package/dist/compute/texture-transform.d.ts +11 -7
- package/dist/compute/texture-transform.d.ts.map +1 -1
- package/dist/compute/texture-transform.js +16 -6
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/controls/orbit-controls.cjs +283 -0
- package/dist/controls/orbit-controls.d.ts +2 -0
- package/dist/controls/orbit-controls.d.ts.map +1 -1
- package/dist/controls/orbit-controls.js +2 -1
- package/dist/controls/orbit-controls.js.map +1 -1
- package/dist/debug/copy-texture-to-image.cjs +84 -0
- package/dist/debug/debug-framebuffer.cjs +113 -0
- package/dist/debug/debug-shader-layout.cjs +45 -0
- package/dist/debug/pixel-data-utils.cjs +54 -0
- package/dist/dist.dev.js +11756 -5632
- package/dist/dist.min.js +39 -35
- package/dist/dynamic-buffer/dynamic-buffer.cjs +39 -0
- package/dist/dynamic-buffer/dynamic-buffer.d.ts +1 -170
- package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -1
- package/dist/dynamic-buffer/dynamic-buffer.js +2 -312
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.cjs +27 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts +1 -114
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +2 -584
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.cjs +31 -0
- package/dist/dynamic-texture/texture-binding-source.d.ts +1 -54
- package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.js +2 -51
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
- package/dist/dynamic-texture/texture-data.cjs +53 -0
- package/dist/dynamic-texture/texture-data.d.ts +1 -145
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +2 -209
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.cjs +269 -0
- package/dist/dynamic-texture/video-texture.d.ts +1 -1
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
- package/dist/experimental/controls/comparison-splitter.cjs +231 -0
- package/dist/experimental/controls/comparison-splitter.d.ts +54 -0
- package/dist/experimental/controls/comparison-splitter.d.ts.map +1 -0
- package/dist/experimental/controls/comparison-splitter.js +215 -0
- package/dist/experimental/controls/comparison-splitter.js.map +1 -0
- package/dist/experimental/controls/flat-controller.cjs +301 -0
- package/dist/experimental/controls/flat-controller.d.ts +80 -0
- package/dist/experimental/controls/flat-controller.d.ts.map +1 -0
- package/dist/experimental/controls/flat-controller.js +295 -0
- package/dist/experimental/controls/flat-controller.js.map +1 -0
- package/dist/experimental/controls/index.cjs +35 -0
- package/dist/experimental/controls/index.cjs.map +6 -0
- package/dist/experimental/controls/index.d.ts +7 -0
- package/dist/experimental/controls/index.d.ts.map +1 -0
- package/dist/experimental/controls/index.js +7 -0
- package/dist/experimental/controls/index.js.map +1 -0
- package/dist/experimental/controls/orbit-controls.cjs +27 -0
- package/dist/experimental/controls/orbit-controls.d.ts +3 -0
- package/dist/experimental/controls/orbit-controls.d.ts.map +1 -0
- package/dist/experimental/controls/orbit-controls.js +5 -0
- package/dist/experimental/controls/orbit-controls.js.map +1 -0
- package/dist/experimental/materials/emissive-material.cjs +126 -0
- package/dist/experimental/materials/emissive-material.d.ts +38 -0
- package/dist/experimental/materials/emissive-material.d.ts.map +1 -0
- package/dist/experimental/materials/emissive-material.js +100 -0
- package/dist/experimental/materials/emissive-material.js.map +1 -0
- package/dist/experimental/materials/glass-material.cjs +570 -0
- package/dist/experimental/materials/glass-material.d.ts +107 -0
- package/dist/experimental/materials/glass-material.d.ts.map +1 -0
- package/dist/experimental/materials/glass-material.js +544 -0
- package/dist/experimental/materials/glass-material.js.map +1 -0
- package/dist/experimental/materials/glass-transmission.cjs +954 -0
- package/dist/experimental/materials/glass-transmission.d.ts +193 -0
- package/dist/experimental/materials/glass-transmission.d.ts.map +1 -0
- package/dist/experimental/materials/glass-transmission.js +928 -0
- package/dist/experimental/materials/glass-transmission.js.map +1 -0
- package/dist/experimental/materials/index.cjs +61 -0
- package/dist/experimental/materials/index.cjs.map +6 -0
- package/dist/experimental/materials/index.d.ts +14 -0
- package/dist/experimental/materials/index.d.ts.map +1 -0
- package/dist/experimental/materials/index.js +11 -0
- package/dist/experimental/materials/index.js.map +1 -0
- package/dist/experimental/materials/optical-caustics.cjs +201 -0
- package/dist/experimental/materials/optical-caustics.d.ts +69 -0
- package/dist/experimental/materials/optical-caustics.d.ts.map +1 -0
- package/dist/experimental/materials/optical-caustics.js +180 -0
- package/dist/experimental/materials/optical-caustics.js.map +1 -0
- package/dist/experimental/materials/optical-lighting.cjs +169 -0
- package/dist/experimental/materials/optical-lighting.d.ts +7 -0
- package/dist/experimental/materials/optical-lighting.d.ts.map +1 -0
- package/dist/experimental/materials/optical-lighting.js +144 -0
- package/dist/experimental/materials/optical-lighting.js.map +1 -0
- package/dist/experimental/materials/optical-point-lights.cjs +258 -0
- package/dist/experimental/materials/optical-point-lights.d.ts +68 -0
- package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -0
- package/dist/experimental/materials/optical-point-lights.js +237 -0
- package/dist/experimental/materials/optical-point-lights.js.map +1 -0
- package/dist/experimental/materials/reflective-material.cjs +216 -0
- package/dist/experimental/materials/reflective-material.d.ts +46 -0
- package/dist/experimental/materials/reflective-material.d.ts.map +1 -0
- package/dist/experimental/materials/reflective-material.js +190 -0
- package/dist/experimental/materials/reflective-material.js.map +1 -0
- package/dist/experimental/textures/html-texture.cjs +221 -0
- package/dist/experimental/textures/html-texture.d.ts +85 -0
- package/dist/experimental/textures/html-texture.d.ts.map +1 -0
- package/dist/experimental/textures/html-texture.js +206 -0
- package/dist/experimental/textures/html-texture.js.map +1 -0
- package/dist/experimental/textures/index.cjs +33 -0
- package/dist/experimental/textures/index.cjs.map +6 -0
- package/dist/experimental/textures/index.d.ts +5 -0
- package/dist/experimental/textures/index.d.ts.map +1 -0
- package/dist/experimental/textures/index.js +7 -0
- package/dist/experimental/textures/index.js.map +1 -0
- package/dist/experimental/textures/packed-pixels.cjs +248 -0
- package/dist/experimental/textures/packed-pixels.d.ts +17 -0
- package/dist/experimental/textures/packed-pixels.d.ts.map +1 -0
- package/dist/experimental/textures/packed-pixels.js +237 -0
- package/dist/experimental/textures/packed-pixels.js.map +1 -0
- package/dist/experimental/textures/rgba-decoder.cjs +60 -0
- package/dist/experimental/textures/rgba-decoder.d.ts +29 -0
- package/dist/experimental/textures/rgba-decoder.d.ts.map +1 -0
- package/dist/experimental/textures/rgba-decoder.js +43 -0
- package/dist/experimental/textures/rgba-decoder.js.map +1 -0
- package/dist/experimental/webxr/index.cjs +38 -0
- package/dist/experimental/webxr/index.cjs.map +6 -0
- package/dist/experimental/webxr/index.d.ts +9 -0
- package/dist/experimental/webxr/index.d.ts.map +1 -0
- package/dist/experimental/webxr/index.js +8 -0
- package/dist/experimental/webxr/index.js.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.cjs +38 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts +9 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js +17 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.cjs +157 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts +48 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.js +144 -0
- package/dist/experimental/webxr/webxr-camera-texture.js.map +1 -0
- package/dist/experimental/webxr/webxr-input.cjs +93 -0
- package/dist/experimental/webxr/webxr-input.d.ts +24 -0
- package/dist/experimental/webxr/webxr-input.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-input.js +70 -0
- package/dist/experimental/webxr/webxr-input.js.map +1 -0
- package/dist/experimental/webxr/webxr-manager.cjs +356 -0
- package/dist/experimental/webxr/webxr-manager.d.ts +91 -0
- package/dist/experimental/webxr/webxr-manager.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-manager.js +354 -0
- package/dist/experimental/webxr/webxr-manager.js.map +1 -0
- package/dist/experimental/webxr/webxr-types.cjs +15 -0
- package/dist/experimental/webxr/webxr-types.d.ts +152 -0
- package/dist/experimental/webxr/webxr-types.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-types.js +5 -0
- package/dist/experimental/webxr/webxr-types.js.map +1 -0
- package/dist/geometry/edge-geometry.cjs +171 -0
- package/dist/geometry/geometry-primitives.cjs +189 -0
- package/dist/geometry/geometry-primitives.d.ts +6 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.js +8 -0
- package/dist/geometry/geometry-primitives.js.map +1 -1
- package/dist/geometry/geometry-table.cjs +15 -0
- package/dist/geometry/geometry-utils.cjs +147 -0
- package/dist/geometry/geometry.cjs +90 -0
- package/dist/geometry/gpu-geometry.cjs +130 -0
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +88 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +5 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js +73 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -0
- package/dist/geometry/gpu-vector-geometry.cjs +40 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +21 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry.js +19 -0
- package/dist/geometry/gpu-vector-geometry.js.map +1 -0
- package/dist/geometry/mesh-simplification.cjs +385 -0
- package/dist/geometry/ring-geometry.cjs +104 -0
- package/dist/geometry/ring-geometry.d.ts +17 -0
- package/dist/geometry/ring-geometry.d.ts.map +1 -0
- package/dist/geometry/ring-geometry.js +94 -0
- package/dist/geometry/ring-geometry.js.map +1 -0
- package/dist/geometry/stroke-geometry.cjs +171 -0
- package/dist/graph/models/index.cjs +66 -0
- package/dist/graph/models/index.cjs.map +6 -0
- package/dist/graph/models/index.d.ts +7 -0
- package/dist/graph/models/index.d.ts.map +1 -0
- package/dist/graph/models/index.js +10 -0
- package/dist/graph/models/index.js.map +1 -0
- package/dist/graph/models/path/path-attribute-model.cjs +421 -0
- package/dist/graph/models/path/path-attribute-model.d.ts +142 -0
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-attribute-model.js +409 -0
- package/dist/graph/models/path/path-attribute-model.js.map +1 -0
- package/dist/graph/models/path/path-storage-model.cjs +711 -0
- package/dist/graph/models/path/path-storage-model.d.ts +174 -0
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-storage-model.js +720 -0
- package/dist/graph/models/path/path-storage-model.js.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.cjs +271 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts +58 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.js +248 -0
- package/dist/graph/models/path/path-trips-storage-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +117 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js +101 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.cjs +283 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts +77 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.js +242 -0
- package/dist/graph/models/polygon/polygon-shaders.js.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.cjs +111 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.js +92 -0
- package/dist/graph/models/polygon/polygon-storage-model.js.map +1 -0
- package/dist/graph/physics/index.cjs +50 -0
- package/dist/graph/physics/index.cjs.map +6 -0
- package/dist/graph/physics/index.d.ts +12 -0
- package/dist/graph/physics/index.d.ts.map +1 -0
- package/dist/graph/physics/index.js +12 -0
- package/dist/graph/physics/index.js.map +1 -0
- package/dist/graph/physics/physics-scenegraph.cjs +92 -0
- package/dist/graph/physics/physics-scenegraph.d.ts +35 -0
- package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -0
- package/dist/graph/physics/physics-scenegraph.js +80 -0
- package/dist/graph/physics/physics-scenegraph.js.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.cjs +164 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts +37 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.js +145 -0
- package/dist/graph/physics/scenegraph-behaviors.js.map +1 -0
- package/dist/graph/physics/scenegraph-instance.cjs +246 -0
- package/dist/graph/physics/scenegraph-instance.d.ts +59 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-instance.js +241 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -0
- package/dist/graph/physics/scenegraph-joints.cjs +51 -0
- package/dist/graph/physics/scenegraph-joints.d.ts +5 -0
- package/dist/graph/physics/scenegraph-joints.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-joints.js +31 -0
- package/dist/graph/physics/scenegraph-joints.js.map +1 -0
- package/dist/graph/physics/scenegraph-motion.cjs +177 -0
- package/dist/graph/physics/scenegraph-motion.d.ts +37 -0
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-motion.js +168 -0
- package/dist/graph/physics/scenegraph-motion.js.map +1 -0
- package/dist/graph/physics/scenegraph-properties.cjs +170 -0
- package/dist/graph/physics/scenegraph-properties.d.ts +37 -0
- package/dist/graph/physics/scenegraph-properties.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-properties.js +186 -0
- package/dist/graph/physics/scenegraph-properties.js.map +1 -0
- package/dist/graph/physics/scenegraph-publication.cjs +112 -0
- package/dist/graph/physics/scenegraph-publication.d.ts +23 -0
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-publication.js +99 -0
- package/dist/graph/physics/scenegraph-publication.js.map +1 -0
- package/dist/graph/physics/scenegraph-session.cjs +256 -0
- package/dist/graph/physics/scenegraph-session.d.ts +68 -0
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-session.js +249 -0
- package/dist/graph/physics/scenegraph-session.js.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.cjs +84 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts +32 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.js +67 -0
- package/dist/graph/tables/gpu-table-geometry.js.map +1 -0
- package/dist/graph/tables/gpu-table-model.cjs +459 -0
- package/dist/graph/tables/gpu-table-model.d.ts +67 -0
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-model.js +457 -0
- package/dist/graph/tables/gpu-table-model.js.map +1 -0
- package/dist/graph/tables/gpu-table-transform.cjs +341 -0
- package/dist/graph/tables/gpu-table-transform.d.ts +61 -0
- package/dist/graph/tables/gpu-table-transform.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-transform.js +333 -0
- package/dist/graph/tables/gpu-table-transform.js.map +1 -0
- package/dist/graph/tables/index.cjs +33 -0
- package/dist/graph/tables/index.cjs.map +6 -0
- package/dist/graph/tables/index.d.ts +4 -0
- package/dist/graph/tables/index.d.ts.map +1 -0
- package/dist/graph/tables/index.js +7 -0
- package/dist/graph/tables/index.js.map +1 -0
- package/dist/index.cjs +303 -9569
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +32 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/interactivity/interactivity.cjs +570 -0
- package/dist/interactivity/interactivity.d.ts +107 -0
- package/dist/interactivity/interactivity.d.ts.map +1 -0
- package/dist/interactivity/interactivity.js +575 -0
- package/dist/interactivity/interactivity.js.map +1 -0
- package/dist/interactivity/physics.cjs +15 -0
- package/dist/interactivity/physics.d.ts +12 -0
- package/dist/interactivity/physics.d.ts.map +1 -0
- package/dist/interactivity/physics.js +5 -0
- package/dist/interactivity/physics.js.map +1 -0
- package/dist/material/material-factory.cjs +99 -0
- package/dist/material/material-factory.d.ts +1 -1
- package/dist/material/material-factory.d.ts.map +1 -1
- package/dist/material/material.cjs +239 -0
- package/dist/material/material.d.ts +2 -2
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +2 -2
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-bindings.cjs +226 -0
- package/dist/model/gpu-vector-bindings.d.ts +36 -0
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -0
- package/dist/model/gpu-vector-bindings.js +217 -0
- package/dist/model/gpu-vector-bindings.js.map +1 -0
- package/dist/model/gpu-vector-draw-batches.cjs +82 -0
- package/dist/model/gpu-vector-draw-batches.d.ts +5 -0
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-draw-batches.js +73 -0
- package/dist/model/gpu-vector-draw-batches.js.map +1 -0
- package/dist/model/gpu-vector-model-batches.cjs +94 -0
- package/dist/model/gpu-vector-model-batches.d.ts +41 -0
- package/dist/model/gpu-vector-model-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-model-batches.js +77 -0
- package/dist/model/gpu-vector-model-batches.js.map +1 -0
- package/dist/model/gpu-vector-model.cjs +1264 -0
- package/dist/model/gpu-vector-model.d.ts +352 -0
- package/dist/model/gpu-vector-model.d.ts.map +1 -0
- package/dist/model/gpu-vector-model.js +1375 -0
- package/dist/model/gpu-vector-model.js.map +1 -0
- package/dist/model/model.cjs +134 -0
- package/dist/model/model.d.ts +21 -305
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +68 -1092
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.cjs +44 -0
- package/dist/model/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +5 -2
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.cjs +167 -0
- package/dist/models/billboard-texture-model.d.ts +1 -1
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +1 -1
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.cjs +61 -0
- package/dist/models/clip-space.cjs +103 -0
- package/dist/models/directional-light-model.cjs +45 -0
- package/dist/models/light-model-utils.cjs +426 -0
- package/dist/models/point-light-model.cjs +44 -0
- package/dist/models/spot-light-model.cjs +45 -0
- package/dist/modules/picking/color-picking.cjs +209 -0
- package/dist/modules/picking/color-picking.d.ts +1 -1
- package/dist/modules/picking/index-color-picking.cjs +230 -0
- package/dist/modules/picking/index-color-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.cjs +201 -0
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-color-picking.cjs +28 -0
- package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-picking-manager.cjs +92 -0
- package/dist/modules/picking/picking-manager.cjs +360 -0
- package/dist/modules/picking/picking-uniforms.cjs +140 -0
- package/dist/modules/picking/picking-uniforms.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking.cjs +43 -0
- package/dist/modules/picking/picking.d.ts +1 -1
- package/dist/passes/get-fragment-shader.cjs +119 -0
- package/dist/passes/shader-pass-renderer.cjs +722 -0
- package/dist/passes/shader-pass-renderer.d.ts +2 -2
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +1 -1
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.cjs +78 -0
- package/dist/scenegraph/controllers/area-light-controller.cjs +143 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/area-light-controller.js +130 -0
- package/dist/scenegraph/controllers/area-light-controller.js.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.cjs +156 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts +45 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.js +156 -0
- package/dist/scenegraph/controllers/billboard-controller.js.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.cjs +71 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts +30 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.js +53 -0
- package/dist/scenegraph/controllers/joint-controller.js.map +1 -0
- package/dist/scenegraph/controllers/material-variants.cjs +61 -0
- package/dist/scenegraph/controllers/material-variants.d.ts +42 -0
- package/dist/scenegraph/controllers/material-variants.d.ts.map +1 -0
- package/dist/scenegraph/controllers/material-variants.js +40 -0
- package/dist/scenegraph/controllers/material-variants.js.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.cjs +61 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts +19 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.js +41 -0
- package/dist/scenegraph/controllers/morph-controller.js.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.cjs +111 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts +36 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.js +90 -0
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -0
- package/dist/scenegraph/group-node.cjs +129 -0
- package/dist/scenegraph/model-node.cjs +68 -0
- package/dist/scenegraph/physics-transforms.cjs +95 -0
- package/dist/scenegraph/physics-transforms.d.ts +13 -0
- package/dist/scenegraph/physics-transforms.d.ts.map +1 -0
- package/dist/scenegraph/physics-transforms.js +72 -0
- package/dist/scenegraph/physics-transforms.js.map +1 -0
- package/dist/scenegraph/published-transforms.cjs +37 -0
- package/dist/scenegraph/published-transforms.d.ts +17 -0
- package/dist/scenegraph/published-transforms.d.ts.map +1 -0
- package/dist/scenegraph/published-transforms.js +16 -0
- package/dist/scenegraph/published-transforms.js.map +1 -0
- package/dist/scenegraph/scenegraph-bounds.cjs +51 -0
- package/dist/scenegraph/scenegraph-node.cjs +182 -0
- package/dist/shader-inputs.cjs +231 -0
- package/dist/shader-inputs.d.ts +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/utils/buffer-layout-helper.cjs +52 -0
- package/dist/utils/buffer-layout-order.cjs +37 -0
- package/dist/utils/deep-equal.cjs +65 -0
- package/dist/utils/get-platform-info.cjs +21 -0
- package/dist/utils/get-platform-info.d.ts +2 -0
- package/dist/utils/get-platform-info.d.ts.map +1 -0
- package/dist/utils/get-platform-info.js +5 -0
- package/dist/utils/get-platform-info.js.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.cjs +45 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts +12 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.js +27 -0
- package/dist/utils/gpu-vector-batch-structure.js.map +1 -0
- package/dist/utils/shader-module-utils.cjs +148 -0
- package/dist/utils/uid.cjs +32 -0
- package/package.json +45 -7
- package/src/animation/deform-positions.ts +62 -0
- package/src/animation/node-animation-binding.ts +54 -0
- package/src/animation/property-animation-binding.ts +212 -0
- package/src/animation/scenegraph-animator.ts +117 -0
- package/src/animation/texture-transform.ts +59 -0
- package/src/animation-loop/animation-loop.ts +10 -3
- package/src/audio/audio-controller.ts +583 -0
- package/src/audio/audio-environment.ts +202 -0
- package/src/audio/audio-graph.ts +253 -0
- package/src/compute/buffer-transform.ts +71 -16
- package/src/compute/computation.ts +4 -19
- package/src/compute/texture-transform.ts +25 -12
- package/src/controls/orbit-controls.ts +4 -1
- package/src/dynamic-buffer/dynamic-buffer.ts +15 -449
- package/src/dynamic-texture/dynamic-texture.ts +5 -760
- package/src/dynamic-texture/texture-binding-source.ts +8 -90
- package/src/dynamic-texture/texture-data.ts +31 -340
- package/src/dynamic-texture/video-texture.ts +1 -1
- package/src/experimental/controls/comparison-splitter.ts +269 -0
- package/src/experimental/controls/flat-controller.ts +403 -0
- package/src/experimental/controls/index.ts +16 -0
- package/src/experimental/controls/orbit-controls.ts +6 -0
- package/src/experimental/materials/emissive-material.ts +120 -0
- package/src/experimental/materials/glass-material.ts +607 -0
- package/src/experimental/materials/glass-transmission.ts +1023 -0
- package/src/experimental/materials/index.ts +49 -0
- package/src/experimental/materials/optical-caustics.ts +234 -0
- package/src/experimental/materials/optical-lighting.ts +148 -0
- package/src/experimental/materials/optical-point-lights.ts +288 -0
- package/src/experimental/materials/reflective-material.ts +214 -0
- package/src/experimental/textures/html-texture.ts +285 -0
- package/src/experimental/textures/index.ts +8 -0
- package/src/experimental/textures/packed-pixels.ts +351 -0
- package/src/experimental/textures/rgba-decoder.ts +79 -0
- package/src/experimental/webxr/index.ts +21 -0
- package/src/experimental/webxr/webxr-animation-frame-provider.ts +22 -0
- package/src/experimental/webxr/webxr-camera-texture.ts +195 -0
- package/src/experimental/webxr/webxr-input.ts +117 -0
- package/src/experimental/webxr/webxr-manager.ts +524 -0
- package/src/experimental/webxr/webxr-types.ts +192 -0
- package/src/geometry/geometry-primitives.ts +11 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +78 -0
- package/src/geometry/gpu-vector-geometry.ts +33 -0
- package/src/geometry/ring-geometry.ts +117 -0
- package/src/graph/models/index.ts +45 -0
- package/src/graph/models/path/path-attribute-model.ts +563 -0
- package/src/graph/models/path/path-storage-model.ts +996 -0
- package/src/graph/models/path/path-trips-storage-model.ts +286 -0
- package/src/graph/models/polygon/polygon-attribute-model.ts +165 -0
- package/src/graph/models/polygon/polygon-shaders.ts +279 -0
- package/src/graph/models/polygon/polygon-storage-model.ts +146 -0
- package/src/graph/physics/index.ts +24 -0
- package/src/graph/physics/physics-scenegraph.ts +112 -0
- package/src/graph/physics/scenegraph-behaviors.ts +169 -0
- package/src/graph/physics/scenegraph-instance.ts +296 -0
- package/src/graph/physics/scenegraph-joints.ts +37 -0
- package/src/graph/physics/scenegraph-motion.ts +175 -0
- package/src/graph/physics/scenegraph-properties.ts +241 -0
- package/src/graph/physics/scenegraph-publication.ts +116 -0
- package/src/graph/physics/scenegraph-session.ts +317 -0
- package/src/graph/tables/gpu-table-geometry.ts +88 -0
- package/src/graph/tables/gpu-table-model.ts +661 -0
- package/src/graph/tables/gpu-table-transform.ts +497 -0
- package/src/graph/tables/index.ts +18 -0
- package/src/index.ts +130 -13
- package/src/interactivity/interactivity.ts +670 -0
- package/src/interactivity/physics.ts +19 -0
- package/src/material/material-factory.ts +1 -1
- package/src/material/material.ts +2 -2
- package/src/model/gpu-vector-bindings.ts +276 -0
- package/src/model/gpu-vector-draw-batches.ts +116 -0
- package/src/model/gpu-vector-model-batches.ts +142 -0
- package/src/model/gpu-vector-model.ts +1819 -0
- package/src/model/model.ts +91 -1444
- package/src/model/split-uniforms-and-bindings.ts +6 -3
- package/src/models/billboard-texture-model.ts +1 -1
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +2 -2
- package/src/scenegraph/controllers/area-light-controller.ts +152 -0
- package/src/scenegraph/controllers/billboard-controller.ts +204 -0
- package/src/scenegraph/controllers/joint-controller.ts +81 -0
- package/src/scenegraph/controllers/material-variants.ts +70 -0
- package/src/scenegraph/controllers/morph-controller.ts +61 -0
- package/src/scenegraph/controllers/skin-controller.ts +125 -0
- package/src/scenegraph/physics-transforms.ts +82 -0
- package/src/scenegraph/published-transforms.ts +18 -0
- package/src/shader-inputs.ts +1 -1
- package/src/utils/get-platform-info.ts +5 -0
- package/src/utils/gpu-vector-batch-structure.ts +36 -0
- package/dist/compute/kernel.d.ts +0 -54
- package/dist/compute/kernel.d.ts.map +0 -1
- package/dist/compute/kernel.js +0 -103
- package/dist/compute/kernel.js.map +0 -1
- package/dist/compute/render-kernel.d.ts +0 -65
- package/dist/compute/render-kernel.d.ts.map +0 -1
- package/dist/compute/render-kernel.js +0 -129
- package/dist/compute/render-kernel.js.map +0 -1
- package/src/compute/kernel.ts +0 -146
- package/src/compute/render-kernel.ts +0 -192
package/dist/model/model.js
CHANGED
|
@@ -1,795 +1,107 @@
|
|
|
1
1
|
// luma.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
-
import {
|
|
5
|
-
import { mergeShaderPluginModules, resolveShaderPlugins, ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
|
+
import { GPUVectorModel } from "./gpu-vector-model.js";
|
|
6
5
|
import { makeGPUGeometry } from "../geometry/gpu-geometry.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { getShaderModuleUniformBlockLayouts, mergeInferredShaderLayout, mergeShaderModules, mergeShaderModuleBindingsIntoLayout, shaderModuleHasUniforms } from "../utils/shader-module-utils.js";
|
|
13
|
-
import { uid } from "../utils/uid.js";
|
|
14
|
-
import { ShaderInputs } from "../shader-inputs.js";
|
|
15
|
-
import { DynamicBuffer, isBufferRangeBinding, resolveBufferRangeBinding } from "../dynamic-buffer/dynamic-buffer.js";
|
|
16
|
-
import { getTextureBindingLayout, isTextureBindingSource } from "../dynamic-texture/texture-binding-source.js";
|
|
17
|
-
const LOG_DRAW_PRIORITY = 2;
|
|
18
|
-
const LOG_DRAW_TIMEOUT = 10000;
|
|
19
|
-
const PIPELINE_INITIALIZATION_FAILED = 'render pipeline initialization failed';
|
|
20
|
-
const DEPTH_STENCIL_ATTACHMENT_FORMATS = [
|
|
21
|
-
'stencil8',
|
|
22
|
-
'depth16unorm',
|
|
23
|
-
'depth24plus',
|
|
24
|
-
'depth24plus-stencil8',
|
|
25
|
-
'depth32float',
|
|
26
|
-
'depth32float-stencil8'
|
|
27
|
-
];
|
|
28
|
-
/**
|
|
29
|
-
* High level draw API for luma.gl.
|
|
30
|
-
*
|
|
31
|
-
* A `Model` encapsulates shaders, geometry attributes, bindings and render
|
|
32
|
-
* pipeline state into a single object. It automatically reuses and rebuilds
|
|
33
|
-
* pipelines as render parameters change and exposes convenient hooks for
|
|
34
|
-
* updating uniforms and attributes.
|
|
35
|
-
*
|
|
36
|
-
* Features:
|
|
37
|
-
* - Reuses and lazily recompiles {@link RenderPipeline | pipelines} as needed.
|
|
38
|
-
* - Integrates with `@luma.gl/shadertools` to assemble GLSL or WGSL from shader modules.
|
|
39
|
-
* - Manages geometry attributes and buffer bindings.
|
|
40
|
-
* - Accepts textures, samplers and uniform buffers as bindings, including texture binding sources.
|
|
41
|
-
* - Provides detailed debug logging and optional shader source inspection.
|
|
42
|
-
*/
|
|
43
|
-
export class Model {
|
|
44
|
-
/** Creates a model while allowing the backend to compile its render pipeline asynchronously. */
|
|
45
|
-
static async createAsync(device, props) {
|
|
46
|
-
const ownsCompilation = !PipelineFactory.getAsyncCompilation(device);
|
|
47
|
-
const asyncCompilation = ownsCompilation
|
|
48
|
-
? PipelineFactory.beginAsyncCompilation(device)
|
|
49
|
-
: PipelineFactory.getAsyncCompilation(device);
|
|
50
|
-
let model;
|
|
51
|
-
try {
|
|
52
|
-
model = new Model(device, props);
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
if (ownsCompilation)
|
|
56
|
-
PipelineFactory.endAsyncCompilation(device, asyncCompilation);
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
if (ownsCompilation) {
|
|
60
|
-
await Promise.all(asyncCompilation);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
await model._pipelineInitialization;
|
|
64
|
-
}
|
|
65
|
-
return model;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
model.destroy();
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
6
|
+
import { GPUVectorGeometry } from "../geometry/gpu-vector-geometry.js";
|
|
7
|
+
import { makeGPUVectorGeometryFromGPUGeometry } from "../geometry/gpu-vector-geometry-adapter.js";
|
|
8
|
+
import { isTextureBindingSource } from '@luma.gl/core/dynamic';
|
|
9
|
+
/** Rendering model with geometry adaptation and material bindings. */
|
|
10
|
+
export class Model extends GPUVectorModel {
|
|
72
11
|
static defaultProps = {
|
|
73
|
-
...
|
|
74
|
-
|
|
75
|
-
sourceLanguage: undefined,
|
|
76
|
-
vs: null,
|
|
77
|
-
fs: null,
|
|
78
|
-
id: 'unnamed',
|
|
79
|
-
handle: undefined,
|
|
80
|
-
userData: {},
|
|
81
|
-
defines: {},
|
|
82
|
-
modules: [],
|
|
83
|
-
plugins: [],
|
|
84
|
-
geometry: null,
|
|
85
|
-
indexBuffer: null,
|
|
86
|
-
indexCount: undefined,
|
|
87
|
-
firstVertex: 0,
|
|
88
|
-
firstIndex: 0,
|
|
89
|
-
attributes: {},
|
|
90
|
-
constantAttributes: {},
|
|
91
|
-
bindings: {},
|
|
92
|
-
uniforms: {},
|
|
93
|
-
varyings: [],
|
|
94
|
-
isInstanced: undefined,
|
|
95
|
-
instanceCount: 0,
|
|
96
|
-
vertexCount: 0,
|
|
97
|
-
shaderInputs: undefined,
|
|
98
|
-
material: undefined,
|
|
99
|
-
pipelineFactory: undefined,
|
|
100
|
-
shaderFactory: undefined,
|
|
101
|
-
transformFeedback: undefined,
|
|
102
|
-
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler('glsl'),
|
|
103
|
-
debugShaders: undefined,
|
|
104
|
-
disableWarnings: undefined
|
|
12
|
+
...GPUVectorModel.defaultProps,
|
|
13
|
+
material: undefined
|
|
105
14
|
};
|
|
106
|
-
/** Device that created this model */
|
|
107
|
-
device;
|
|
108
|
-
/** Application provided identifier */
|
|
109
|
-
id;
|
|
110
|
-
/** WGSL shader source when using unified shader */
|
|
111
|
-
// @ts-expect-error assigned in function called from constructor
|
|
112
|
-
source;
|
|
113
|
-
/** GLSL vertex shader source */
|
|
114
|
-
// @ts-expect-error assigned in function called from constructor
|
|
115
|
-
vs;
|
|
116
|
-
/** GLSL fragment shader source */
|
|
117
|
-
// @ts-expect-error assigned in function called from constructor
|
|
118
|
-
fs;
|
|
119
|
-
/** Factory used to create render pipelines */
|
|
120
|
-
pipelineFactory;
|
|
121
|
-
/** Factory used to create shaders */
|
|
122
|
-
shaderFactory;
|
|
123
|
-
/** User-supplied per-model data */
|
|
124
|
-
userData = {};
|
|
125
|
-
// Fixed properties (change can trigger pipeline rebuild)
|
|
126
|
-
/** The render pipeline GPU parameters, depth testing etc */
|
|
127
|
-
parameters;
|
|
128
|
-
/** The primitive topology */
|
|
129
|
-
topology;
|
|
130
|
-
/** Buffer layout */
|
|
131
|
-
bufferLayout;
|
|
132
|
-
// Dynamic properties
|
|
133
|
-
/** Use instanced rendering */
|
|
134
|
-
isInstanced = undefined;
|
|
135
|
-
/** instance count. `undefined` means not instanced */
|
|
136
|
-
instanceCount = 0;
|
|
137
|
-
/** Vertex count */
|
|
138
|
-
vertexCount;
|
|
139
|
-
/** Indexed draw count override. Undefined uses vertexCount, then the full bound index buffer. */
|
|
140
|
-
indexCount;
|
|
141
|
-
/** First vertex byte offset for WebGL indexed draws or first vertex for non-indexed draws. */
|
|
142
|
-
firstVertex;
|
|
143
|
-
/** First index element for WebGPU indexed draws. */
|
|
144
|
-
firstIndex;
|
|
145
|
-
/** Index buffer */
|
|
146
|
-
indexBuffer = null;
|
|
147
|
-
/** Buffer-valued attributes */
|
|
148
|
-
bufferAttributes = {};
|
|
149
|
-
/** Constant-valued attributes */
|
|
150
|
-
constantAttributes = {};
|
|
151
|
-
/** Bindings (textures, samplers, uniform buffers) */
|
|
152
|
-
bindings = {};
|
|
153
|
-
/**
|
|
154
|
-
* VertexArray
|
|
155
|
-
* @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!
|
|
156
|
-
* @todo - allow application to define multiple vertex arrays?
|
|
157
|
-
* */
|
|
158
|
-
vertexArray;
|
|
159
|
-
/** TransformFeedback, WebGL 2 only. */
|
|
160
|
-
transformFeedback = null;
|
|
161
|
-
/** The underlying GPU "program". @note May be recreated if parameters change */
|
|
162
|
-
pipeline;
|
|
163
|
-
/** ShaderInputs instance */
|
|
164
|
-
// @ts-expect-error Assigned in function called by constructor
|
|
165
|
-
shaderInputs;
|
|
166
|
-
material = null;
|
|
167
|
-
// @ts-expect-error Assigned in function called by constructor
|
|
168
|
-
_uniformStore;
|
|
169
|
-
_attributeInfos = {};
|
|
170
|
-
_gpuGeometry = null;
|
|
171
|
-
props;
|
|
172
|
-
_dynamicIndexBufferSource = null;
|
|
173
|
-
_dynamicAttributeBufferSources = {};
|
|
174
|
-
_colorAttachmentFormats;
|
|
175
|
-
_depthStencilAttachmentFormat;
|
|
176
|
-
_pipelineNeedsUpdate = 'newly created';
|
|
177
|
-
_needsRedraw = 'initializing';
|
|
178
|
-
_drawBlockedReason = false;
|
|
179
|
-
_destroyed = false;
|
|
180
|
-
_vertexCountSet = false;
|
|
181
|
-
/** "Time" of last draw. Monotonically increasing timestamp */
|
|
182
|
-
_lastDrawTimestamp = -1;
|
|
183
|
-
_bindingTable = [];
|
|
184
|
-
_pipelineInitialization;
|
|
185
|
-
get [Symbol.toStringTag]() {
|
|
186
|
-
return 'Model';
|
|
187
|
-
}
|
|
188
|
-
toString() {
|
|
189
|
-
return `Model(${this.id})`;
|
|
190
|
-
}
|
|
191
15
|
constructor(device, props) {
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
16
|
+
const sourceGeometry = props.geometry === undefined ? new.target.defaultProps.geometry : props.geometry;
|
|
17
|
+
const gpuGeometry = sourceGeometry && !(sourceGeometry instanceof GPUVectorGeometry)
|
|
18
|
+
? makeGPUGeometry(device, sourceGeometry)
|
|
19
|
+
: null;
|
|
20
|
+
const geometry = gpuGeometry
|
|
21
|
+
? makeGPUVectorGeometryFromGPUGeometry(gpuGeometry)
|
|
22
|
+
: sourceGeometry;
|
|
23
|
+
const modelProps = {
|
|
196
24
|
...props,
|
|
197
|
-
|
|
198
|
-
(isShaderAssemblerForLanguage(defaultShaderAssembler, device.info.shadingLanguage)
|
|
199
|
-
? defaultShaderAssembler
|
|
200
|
-
: ShaderAssembler.getDefaultShaderAssembler(device.info.shadingLanguage))
|
|
25
|
+
geometry: geometry instanceof GPUVectorGeometry ? geometry : null
|
|
201
26
|
};
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.id = props.id || uid('model');
|
|
205
|
-
this.device = device;
|
|
206
|
-
Object.assign(this.userData, props.userData);
|
|
207
|
-
this.material = props.material || null;
|
|
208
|
-
const platformInfo = getPlatformInfo(device);
|
|
209
|
-
const resolvedPlugins = resolveShaderPlugins(this.props.plugins, platformInfo.shaderLanguage);
|
|
210
|
-
// Setup shader module inputs
|
|
211
|
-
const shaderInputModules = mergeShaderPluginModules(this.props.modules, resolvedPlugins.modules);
|
|
212
|
-
const moduleMap = Object.fromEntries(shaderInputModules.map(module => [module.name, module]));
|
|
213
|
-
const shaderInputs = props.shaderInputs ||
|
|
214
|
-
new ShaderInputs(moduleMap, { disableWarnings: this.props.disableWarnings });
|
|
215
|
-
if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
|
|
216
|
-
shaderInputs.addModules(resolvedPlugins.modules);
|
|
217
|
-
}
|
|
218
|
-
// @ts-ignore
|
|
219
|
-
this.setShaderInputs(shaderInputs);
|
|
220
|
-
// Setup shader assembler
|
|
221
|
-
const modules = mergeShaderModules(this.props.modules, shaderInputs.getModules());
|
|
222
|
-
const defines = { ...resolvedPlugins.defines, ...this.props.defines };
|
|
223
|
-
if (this.device.type === 'webgl') {
|
|
224
|
-
this.props._uniformBlockLayouts = getShaderModuleUniformBlockLayouts(modules);
|
|
225
|
-
}
|
|
226
|
-
this.props.shaderLayout =
|
|
227
|
-
mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
228
|
-
const isWebGPU = this.device.type === 'webgpu';
|
|
229
|
-
// WebGPU
|
|
230
|
-
// TODO - hack to support unified WGSL shader
|
|
231
|
-
// TODO - this is wrong, compile a single shader
|
|
232
|
-
if (isWebGPU && this.props.source) {
|
|
233
|
-
// WGSL
|
|
234
|
-
const shaderAssembler = this.props.shaderAssembler;
|
|
235
|
-
// WGSL sources require an assembler with WGSL-specific hooks and binding state.
|
|
236
|
-
assert(isShaderAssemblerForLanguage(shaderAssembler, 'wgsl'));
|
|
237
|
-
const { source, getUniforms, bindingTable, entryPoints = {}, shaderLayout: assembledShaderLayout } = shaderAssembler.assembleWGSLShader({
|
|
238
|
-
platformInfo,
|
|
239
|
-
...this.props,
|
|
240
|
-
modules,
|
|
241
|
-
defines,
|
|
242
|
-
pluginInjections: resolvedPlugins.injections,
|
|
243
|
-
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
244
|
-
pluginVaryings: resolvedPlugins.varyings
|
|
245
|
-
});
|
|
246
|
-
this.source = source;
|
|
247
|
-
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
248
|
-
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
249
|
-
// @ts-expect-error
|
|
250
|
-
this._getModuleUniforms = getUniforms;
|
|
251
|
-
this._bindingTable = bindingTable;
|
|
252
|
-
// Infer the layout after modules have been added so their bindings are included.
|
|
253
|
-
const scannedOrReflectedShaderLayout = assembledShaderLayout ??
|
|
254
|
-
device.getShaderLayout?.(this.source);
|
|
255
|
-
const inferredShaderLayout = normalizeShaderPluginAttributeNames(scannedOrReflectedShaderLayout, resolvedPlugins.vertexInputs);
|
|
256
|
-
const shaderLayout = mergeInferredShaderLayout(this.props.shaderLayout, inferredShaderLayout, Object.keys(resolvedPlugins.vertexInputs));
|
|
257
|
-
this.props.shaderLayout =
|
|
258
|
-
mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
// GLSL
|
|
262
|
-
const shaderAssembler = this.props.shaderAssembler;
|
|
263
|
-
// GLSL shader pairs require an assembler with GLSL-specific hooks.
|
|
264
|
-
assert(isShaderAssemblerForLanguage(shaderAssembler, 'glsl'));
|
|
265
|
-
const { vs, fs, getUniforms } = shaderAssembler.assembleGLSLShaderPair({
|
|
266
|
-
platformInfo,
|
|
267
|
-
...this.props,
|
|
268
|
-
modules,
|
|
269
|
-
defines,
|
|
270
|
-
pluginInjections: resolvedPlugins.injections,
|
|
271
|
-
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
272
|
-
pluginVaryings: resolvedPlugins.varyings
|
|
273
|
-
});
|
|
274
|
-
this.vs = vs;
|
|
275
|
-
this.fs = fs;
|
|
276
|
-
// @ts-expect-error
|
|
277
|
-
this._getModuleUniforms = getUniforms;
|
|
278
|
-
this._bindingTable = [];
|
|
279
|
-
}
|
|
280
|
-
this.vertexCount = this.props.vertexCount;
|
|
281
|
-
this.indexCount = this.props.indexCount;
|
|
282
|
-
this.firstVertex = this.props.firstVertex;
|
|
283
|
-
this.firstIndex = this.props.firstIndex;
|
|
284
|
-
this.instanceCount = this.props.instanceCount;
|
|
285
|
-
this.topology = this.props.topology;
|
|
286
|
-
this.bufferLayout = this.props.bufferLayout;
|
|
287
|
-
this.parameters = this.props.parameters;
|
|
288
|
-
// Seed attachment formats before creating the initial WebGPU pipeline. This is required for
|
|
289
|
-
// depth-only models whose intentional empty color target list must not fall back to the canvas
|
|
290
|
-
// format before the first render pass can synchronize attachment state.
|
|
291
|
-
this._colorAttachmentFormats = this.props.colorAttachmentFormats;
|
|
292
|
-
this._depthStencilAttachmentFormat = this.props.depthStencilAttachmentFormat;
|
|
293
|
-
// Geometry, if provided, sets topology and vertex cound
|
|
294
|
-
if (props.geometry) {
|
|
295
|
-
this.setGeometry(props.geometry);
|
|
296
|
-
}
|
|
297
|
-
this.pipelineFactory =
|
|
298
|
-
props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
299
|
-
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
300
|
-
const asyncCompilation = PipelineFactory.getAsyncCompilation(this.device);
|
|
301
|
-
if (asyncCompilation) {
|
|
302
|
-
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
303
|
-
asyncCompilation.push(this._pipelineInitialization);
|
|
27
|
+
try {
|
|
28
|
+
super(device, modelProps);
|
|
304
29
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
30
|
+
catch (error) {
|
|
31
|
+
gpuGeometry?.destroy();
|
|
32
|
+
throw error;
|
|
308
33
|
}
|
|
34
|
+
this._gpuGeometry = gpuGeometry;
|
|
35
|
+
if (gpuGeometry)
|
|
36
|
+
this.setIndexCount(this.props.indexCount);
|
|
309
37
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.
|
|
38
|
+
_initializeProps(props) {
|
|
39
|
+
this.material = props.material || null;
|
|
40
|
+
this._gpuGeometry = null;
|
|
41
|
+
super._initializeProps(props);
|
|
313
42
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
318
|
-
});
|
|
43
|
+
_initializeAttributes() {
|
|
44
|
+
super._initializeAttributes();
|
|
45
|
+
// Legacy geometry selects indexed draw counts through vertexCount unless explicitly overridden.
|
|
319
46
|
if (this._gpuGeometry)
|
|
320
|
-
|
|
321
|
-
if ('isInstanced' in props)
|
|
322
|
-
this.isInstanced = props.isInstanced;
|
|
323
|
-
if (props.instanceCount)
|
|
324
|
-
this.setInstanceCount(props.instanceCount);
|
|
325
|
-
if (props.vertexCount)
|
|
326
|
-
this.setVertexCount(props.vertexCount);
|
|
327
|
-
if (props.indexBuffer)
|
|
328
|
-
this.setIndexBuffer(props.indexBuffer);
|
|
329
|
-
if (props.attributes)
|
|
330
|
-
this.setAttributes(props.attributes);
|
|
331
|
-
if (props.constantAttributes)
|
|
332
|
-
this.setConstantAttributes(props.constantAttributes);
|
|
333
|
-
if (props.bindings)
|
|
334
|
-
this.setBindings(props.bindings);
|
|
335
|
-
if (props.transformFeedback)
|
|
336
|
-
this.transformFeedback = props.transformFeedback;
|
|
47
|
+
super.setIndexCount(this.indexCountOverride);
|
|
337
48
|
}
|
|
338
49
|
destroy() {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
this.pipelineFactory.release(this.pipeline);
|
|
343
|
-
// Release the shaders
|
|
344
|
-
this.shaderFactory.release(this.pipeline.vs);
|
|
345
|
-
if (this.pipeline.fs && this.pipeline.fs !== this.pipeline.vs) {
|
|
346
|
-
this.shaderFactory.release(this.pipeline.fs);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
this._uniformStore.destroy();
|
|
350
|
-
// TODO - mark resource as managed and destroyIfManaged() ?
|
|
351
|
-
this._gpuGeometry?.destroy();
|
|
352
|
-
this._destroyed = true;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
// Draw call
|
|
356
|
-
/** Query redraw status. Clears the status. */
|
|
357
|
-
needsRedraw() {
|
|
358
|
-
// Catch any writes to already bound resources
|
|
359
|
-
if (this._getBindingsUpdateTimestamp() > this._lastDrawTimestamp) {
|
|
360
|
-
this.setNeedsRedraw('contents of bound textures or buffers updated');
|
|
361
|
-
}
|
|
362
|
-
const needsRedraw = this._needsRedraw;
|
|
363
|
-
this._needsRedraw = false;
|
|
364
|
-
return needsRedraw;
|
|
365
|
-
}
|
|
366
|
-
/** Mark the model as needing a redraw */
|
|
367
|
-
setNeedsRedraw(reason) {
|
|
368
|
-
this._needsRedraw ||= reason;
|
|
369
|
-
}
|
|
370
|
-
/** Returns WGSL binding debug rows for the assembled shader. Returns an empty array for GLSL models. */
|
|
371
|
-
getBindingDebugTable() {
|
|
372
|
-
return this._bindingTable;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Updates uniforms and pipeline state before opening a render pass.
|
|
376
|
-
*
|
|
377
|
-
* @param commandEncoder - Encoder that should own any GPU uploads emitted
|
|
378
|
-
* during draw preparation.
|
|
379
|
-
*/
|
|
380
|
-
predraw(commandEncoder) {
|
|
381
|
-
// Update uniform buffers if needed
|
|
382
|
-
this._syncDynamicBuffers();
|
|
383
|
-
this.updateShaderInputs(commandEncoder);
|
|
384
|
-
this.material?.updateShaderInputs(commandEncoder);
|
|
385
|
-
// Check if the pipeline is invalidated
|
|
386
|
-
this.pipeline = this._updatePipeline();
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Issue one draw call.
|
|
390
|
-
* @param renderPass - render pass to draw into
|
|
391
|
-
* @returns `true` if the draw call was executed, `false` if resources were not ready.
|
|
392
|
-
*/
|
|
393
|
-
draw(renderPass) {
|
|
394
|
-
if (this._drawBlockedReason && !this._pipelineNeedsUpdate) {
|
|
395
|
-
log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${this._drawBlockedReason}`)();
|
|
396
|
-
return false;
|
|
397
|
-
}
|
|
398
|
-
const loadingBinding = this._areBindingsLoading();
|
|
399
|
-
if (loadingBinding) {
|
|
400
|
-
log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${loadingBinding} not loaded`)();
|
|
401
|
-
return false;
|
|
402
|
-
}
|
|
403
|
-
this._syncAttachmentFormats(renderPass);
|
|
404
|
-
try {
|
|
405
|
-
renderPass.pushDebugGroup(`${this}.predraw(${renderPass})`);
|
|
406
|
-
if (this.device.type === 'webgpu') {
|
|
407
|
-
// WebGPU uploads cannot be encoded once the render pass is already open.
|
|
408
|
-
// Keep the implicit draw() path working for existing callers by falling
|
|
409
|
-
// back to immediate writes here; callers that need upload ordering
|
|
410
|
-
// across multiple draws/viewports must call predraw(commandEncoder)
|
|
411
|
-
// before beginRenderPass().
|
|
412
|
-
this.updateShaderInputs();
|
|
413
|
-
this.material?.updateShaderInputs();
|
|
414
|
-
this._syncDynamicBuffers();
|
|
415
|
-
this.pipeline = this._updatePipeline();
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
this.predraw(this.device.commandEncoder);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
finally {
|
|
422
|
-
renderPass.popDebugGroup();
|
|
423
|
-
}
|
|
424
|
-
let drawSuccess;
|
|
425
|
-
let pipelineErrored = this.pipeline.isErrored;
|
|
426
|
-
try {
|
|
427
|
-
renderPass.pushDebugGroup(`${this}.draw(${renderPass})`);
|
|
428
|
-
this._logDrawCallStart();
|
|
429
|
-
// Update the pipeline if invalidated
|
|
430
|
-
// TODO - inside RenderPass is likely the worst place to do this from performance perspective.
|
|
431
|
-
// Application can call Model.predraw() to avoid this.
|
|
432
|
-
this.pipeline = this._updatePipeline();
|
|
433
|
-
pipelineErrored = this.pipeline.isErrored;
|
|
434
|
-
if (pipelineErrored) {
|
|
435
|
-
log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${PIPELINE_INITIALIZATION_FAILED}`)();
|
|
436
|
-
drawSuccess = false;
|
|
437
|
-
}
|
|
438
|
-
else {
|
|
439
|
-
const drawValidationError = this.vertexArray.getDrawValidationError();
|
|
440
|
-
if (drawValidationError) {
|
|
441
|
-
log.info(LOG_DRAW_PRIORITY, `>>> DRAWING ABORTED ${this.id}: ${drawValidationError}`)();
|
|
442
|
-
this._drawBlockedReason = drawValidationError;
|
|
443
|
-
drawSuccess = false;
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
const shaderLayout = this._getCurrentShaderLayout();
|
|
447
|
-
const syncBindings = this._getBindings(shaderLayout);
|
|
448
|
-
const syncBindGroups = this._getBindGroups(shaderLayout, syncBindings);
|
|
449
|
-
const { indexBuffer } = this.vertexArray;
|
|
450
|
-
const indexCount = indexBuffer
|
|
451
|
-
? (this.indexCount ??
|
|
452
|
-
(this._vertexCountSet
|
|
453
|
-
? this.vertexCount
|
|
454
|
-
: indexBuffer.byteLength / (indexBuffer.indexType === 'uint32' ? 4 : 2)))
|
|
455
|
-
: undefined;
|
|
456
|
-
renderPass.setPipeline(this.pipeline);
|
|
457
|
-
renderPass.setBindings(syncBindGroups, {
|
|
458
|
-
_bindGroupCacheKeys: this._getBindGroupCacheKeys()
|
|
459
|
-
});
|
|
460
|
-
renderPass.setVertexArray(this.vertexArray);
|
|
461
|
-
const hasNoInstances = this.isInstanced === true && this.instanceCount === 0;
|
|
462
|
-
drawSuccess = hasNoInstances
|
|
463
|
-
? true
|
|
464
|
-
: renderPass.draw({
|
|
465
|
-
isInstanced: this.isInstanced,
|
|
466
|
-
vertexCount: this.vertexCount,
|
|
467
|
-
instanceCount: this.isInstanced ? this.instanceCount : undefined,
|
|
468
|
-
indexCount,
|
|
469
|
-
firstVertex: this.firstVertex,
|
|
470
|
-
firstIndex: this.firstIndex,
|
|
471
|
-
transformFeedback: this.transformFeedback || undefined,
|
|
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
|
-
}
|
|
481
|
-
finally {
|
|
482
|
-
renderPass.popDebugGroup();
|
|
483
|
-
this._logDrawCallEnd();
|
|
484
|
-
}
|
|
485
|
-
this._logFramebuffer(renderPass);
|
|
486
|
-
// Update needsRedraw flag
|
|
487
|
-
if (drawSuccess) {
|
|
488
|
-
this._lastDrawTimestamp = this.device.timestamp;
|
|
489
|
-
this._needsRedraw = false;
|
|
490
|
-
}
|
|
491
|
-
else if (pipelineErrored) {
|
|
492
|
-
this._needsRedraw = PIPELINE_INITIALIZATION_FAILED;
|
|
493
|
-
this._drawBlockedReason = PIPELINE_INITIALIZATION_FAILED;
|
|
494
|
-
}
|
|
495
|
-
else if (this._drawBlockedReason) {
|
|
496
|
-
this._needsRedraw = this._drawBlockedReason;
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
this._needsRedraw = 'waiting for resource initialization';
|
|
500
|
-
}
|
|
501
|
-
return drawSuccess;
|
|
50
|
+
super.destroy();
|
|
51
|
+
this._gpuGeometry?.destroy();
|
|
52
|
+
this._gpuGeometry = null;
|
|
502
53
|
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Updates the optional geometry
|
|
506
|
-
* Geometry, set topology and bufferLayout
|
|
507
|
-
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
508
|
-
*/
|
|
54
|
+
/** Adapts CPU and legacy buffer geometry into the GPU vector geometry API. */
|
|
509
55
|
setGeometry(geometry) {
|
|
510
56
|
this._gpuGeometry?.destroy();
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
524
|
-
* @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
525
|
-
*/
|
|
526
|
-
setTopology(topology) {
|
|
527
|
-
if (topology !== this.topology) {
|
|
528
|
-
this.topology = topology;
|
|
529
|
-
this._setPipelineNeedsUpdate('topology');
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Updates the buffer layout.
|
|
534
|
-
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
535
|
-
*/
|
|
536
|
-
setBufferLayout(bufferLayout) {
|
|
537
|
-
const bufferLayoutHelper = new BufferLayoutHelper(this.bufferLayout);
|
|
538
|
-
const nextBufferLayout = this._gpuGeometry
|
|
539
|
-
? bufferLayoutHelper.mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)
|
|
540
|
-
: bufferLayout;
|
|
541
|
-
if (deepEqual(nextBufferLayout, this.bufferLayout, -1)) {
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
this.bufferLayout = nextBufferLayout;
|
|
545
|
-
this._setPipelineNeedsUpdate('bufferLayout');
|
|
546
|
-
// Recreate the pipeline
|
|
547
|
-
this.pipeline = this._updatePipeline();
|
|
548
|
-
// vertex array needs to be updated if we update buffer layout,
|
|
549
|
-
// but not if we update parameters
|
|
550
|
-
this.vertexArray = this.device.createVertexArray({
|
|
551
|
-
shaderLayout: this.pipeline.shaderLayout,
|
|
552
|
-
bufferLayout: this.pipeline.bufferLayout
|
|
553
|
-
});
|
|
554
|
-
// Reapply geometry attributes to the new vertex array
|
|
555
|
-
if (this._gpuGeometry) {
|
|
556
|
-
this._setGeometryAttributes(this._gpuGeometry);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Set GPU parameters.
|
|
561
|
-
* @note Can trigger a pipeline rebuild / pipeline cache fetch.
|
|
562
|
-
* @param parameters
|
|
563
|
-
*/
|
|
564
|
-
setParameters(parameters) {
|
|
565
|
-
if (!deepEqual(parameters, this.parameters, 2)) {
|
|
566
|
-
this.parameters = parameters;
|
|
567
|
-
this._setPipelineNeedsUpdate('parameters');
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
// Update dynamic fields
|
|
571
|
-
/**
|
|
572
|
-
* Updates the instance count (used in draw calls)
|
|
573
|
-
* @note Any attributes with stepMode=instance need to be at least this big
|
|
574
|
-
*/
|
|
575
|
-
setInstanceCount(instanceCount) {
|
|
576
|
-
this.instanceCount = instanceCount;
|
|
577
|
-
// luma.gl examples don't set props.isInstanced and rely on auto-detection
|
|
578
|
-
// but deck.gl sets instanceCount even for models that are not instanced.
|
|
579
|
-
if (this.isInstanced === undefined && instanceCount > 0) {
|
|
580
|
-
this.isInstanced = true;
|
|
581
|
-
}
|
|
582
|
-
this.setNeedsRedraw('instanceCount');
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Updates the vertex count (used in draw calls)
|
|
586
|
-
* @note Any attributes with stepMode=vertex need to be at least this big
|
|
587
|
-
*/
|
|
588
|
-
setVertexCount(vertexCount) {
|
|
589
|
-
this.vertexCount = vertexCount;
|
|
590
|
-
this._vertexCountSet = true;
|
|
591
|
-
this.setNeedsRedraw('vertexCount');
|
|
57
|
+
this._gpuGeometry =
|
|
58
|
+
geometry && !(geometry instanceof GPUVectorGeometry)
|
|
59
|
+
? makeGPUGeometry(this.device, geometry)
|
|
60
|
+
: null;
|
|
61
|
+
const vectorGeometry = this._gpuGeometry
|
|
62
|
+
? makeGPUVectorGeometryFromGPUGeometry(this._gpuGeometry)
|
|
63
|
+
: geometry;
|
|
64
|
+
super.setGeometry(vectorGeometry instanceof GPUVectorGeometry ? vectorGeometry : null);
|
|
65
|
+
if (!(geometry instanceof GPUVectorGeometry))
|
|
66
|
+
super.setIndexCount(this.indexCountOverride);
|
|
592
67
|
}
|
|
593
|
-
/** Updates the indexed draw count override. */
|
|
594
68
|
setIndexCount(indexCount) {
|
|
595
|
-
this.
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
/** Updates the first indexed/non-indexed draw offsets. */
|
|
599
|
-
setDrawOffsets({ firstVertex, firstIndex }) {
|
|
600
|
-
this.firstVertex = firstVertex;
|
|
601
|
-
this.firstIndex = firstIndex;
|
|
602
|
-
this.setNeedsRedraw('drawOffsets');
|
|
603
|
-
}
|
|
604
|
-
/** Set the shader inputs */
|
|
605
|
-
setShaderInputs(shaderInputs) {
|
|
606
|
-
this.shaderInputs = shaderInputs;
|
|
607
|
-
this._uniformStore = new UniformStore(this.device, this.shaderInputs.modules);
|
|
608
|
-
// Create uniform buffer bindings for all modules that actually have uniforms
|
|
609
|
-
for (const [moduleName, module] of Object.entries(this.shaderInputs.modules)) {
|
|
610
|
-
if (shaderModuleHasUniforms(module) && !this.material?.ownsModule(moduleName)) {
|
|
611
|
-
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(moduleName);
|
|
612
|
-
this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
this.setNeedsRedraw('shaderInputs');
|
|
69
|
+
this.indexCountOverride = indexCount;
|
|
70
|
+
super.setIndexCount(indexCount);
|
|
616
71
|
}
|
|
617
72
|
setMaterial(material) {
|
|
618
73
|
this.material = material;
|
|
619
74
|
this.setNeedsRedraw('material');
|
|
620
75
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
* Flushes current shader-input values into managed uniform buffers and
|
|
624
|
-
* non-material bindings.
|
|
625
|
-
*
|
|
626
|
-
* @param commandEncoder - Optional encoder used to order uniform uploads with
|
|
627
|
-
* subsequent draw commands.
|
|
628
|
-
*/
|
|
629
|
-
updateShaderInputs(commandEncoder) {
|
|
630
|
-
this._uniformStore.setUniforms(this.shaderInputs.getUniformValues(), commandEncoder);
|
|
631
|
-
this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues()));
|
|
632
|
-
// TODO - this is already tracked through buffer/texture update times?
|
|
633
|
-
this.setNeedsRedraw('shaderInputs');
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Sets bindings (textures, samplers, uniform buffers)
|
|
637
|
-
*/
|
|
638
|
-
setBindings(bindings) {
|
|
639
|
-
Object.assign(this.bindings, bindings);
|
|
640
|
-
this.setNeedsRedraw('bindings');
|
|
76
|
+
_usesManagedUniformBuffer(moduleName) {
|
|
77
|
+
return !this.material?.ownsModule(moduleName);
|
|
641
78
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
setTransformFeedback(transformFeedback) {
|
|
646
|
-
this.transformFeedback = transformFeedback;
|
|
647
|
-
this.setNeedsRedraw('transformFeedback');
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Sets the index buffer
|
|
651
|
-
* @todo - how to unset it if we change geometry?
|
|
652
|
-
*/
|
|
653
|
-
setIndexBuffer(indexBuffer) {
|
|
654
|
-
const resolvedIndexBuffer = indexBuffer instanceof DynamicBuffer ? indexBuffer.buffer : indexBuffer;
|
|
655
|
-
this.indexBuffer = resolvedIndexBuffer;
|
|
656
|
-
this._dynamicIndexBufferSource =
|
|
657
|
-
indexBuffer instanceof DynamicBuffer
|
|
658
|
-
? { source: indexBuffer, generation: indexBuffer.generation }
|
|
659
|
-
: null;
|
|
660
|
-
this.vertexArray.setIndexBuffer(resolvedIndexBuffer);
|
|
661
|
-
this.setNeedsRedraw('indexBuffer');
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Sets attributes (buffers)
|
|
665
|
-
* @param options.byteOffsets Optional byte offsets, keyed by buffer name, where each buffer's
|
|
666
|
-
* vertex data starts. Buffers without an entry are bound at offset 0.
|
|
667
|
-
* @note Overrides any attributes previously set with the same name
|
|
668
|
-
*/
|
|
669
|
-
setAttributes(buffers, options) {
|
|
670
|
-
this._drawBlockedReason = false;
|
|
671
|
-
const disableWarnings = options?.disableWarnings ?? this.props.disableWarnings;
|
|
672
|
-
if (buffers['indices']) {
|
|
673
|
-
log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
|
|
674
|
-
}
|
|
675
|
-
// ensure bufferLayout order matches source layout so we bind
|
|
676
|
-
// the correct buffers to the correct indices in webgpu.
|
|
677
|
-
this.bufferLayout = sortedBufferLayoutByShaderSourceLocations(this.pipeline.shaderLayout, this.bufferLayout);
|
|
678
|
-
const bufferLayoutHelper = new BufferLayoutHelper(this.bufferLayout);
|
|
679
|
-
// Check if all buffers have a layout
|
|
680
|
-
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
681
|
-
const resolvedBuffer = buffer instanceof DynamicBuffer ? buffer.buffer : buffer;
|
|
682
|
-
const bufferLayout = bufferLayoutHelper.getBufferLayout(bufferName);
|
|
683
|
-
if (!bufferLayout) {
|
|
684
|
-
if (!disableWarnings) {
|
|
685
|
-
log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
686
|
-
}
|
|
687
|
-
continue; // eslint-disable-line no-continue
|
|
688
|
-
}
|
|
689
|
-
// In WebGL, for an interleaved attribute we may need to set multiple attributes
|
|
690
|
-
// but in WebGPU, we set it according to the buffer's position in the vertexArray
|
|
691
|
-
const attributeNames = bufferLayoutHelper.getAttributeNamesForBuffer(bufferLayout);
|
|
692
|
-
let set = false;
|
|
693
|
-
for (const attributeName of attributeNames) {
|
|
694
|
-
const attributeInfo = this._attributeInfos[attributeName];
|
|
695
|
-
if (attributeInfo) {
|
|
696
|
-
const bufferSlot = this.device.type === 'webgpu'
|
|
697
|
-
? this.vertexArray.getBufferSlot(attributeInfo.bufferName)
|
|
698
|
-
: attributeInfo.location;
|
|
699
|
-
if (bufferSlot === null) {
|
|
700
|
-
if (!disableWarnings) {
|
|
701
|
-
log.warn(`Model(${this.id}): Missing vertex array slot for buffer "${attributeInfo.bufferName}".`)();
|
|
702
|
-
}
|
|
703
|
-
continue; // eslint-disable-line no-continue
|
|
704
|
-
}
|
|
705
|
-
const byteOffset = options?.byteOffsets?.[bufferName] ?? 0;
|
|
706
|
-
this.vertexArray.setBuffer(bufferSlot, resolvedBuffer, byteOffset);
|
|
707
|
-
if (buffer instanceof DynamicBuffer) {
|
|
708
|
-
this._dynamicAttributeBufferSources[bufferSlot] = {
|
|
709
|
-
source: buffer,
|
|
710
|
-
generation: buffer.generation,
|
|
711
|
-
byteOffset
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
delete this._dynamicAttributeBufferSources[bufferSlot];
|
|
716
|
-
}
|
|
717
|
-
set = true;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
if (!set && !disableWarnings) {
|
|
721
|
-
log.warn(`Model(${this.id}): Ignoring buffer "${resolvedBuffer.id}" for unknown attribute "${bufferName}"`)();
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
this.setNeedsRedraw('attributes');
|
|
79
|
+
updateShaderInputs(commandEncoder) {
|
|
80
|
+
super.updateShaderInputs(commandEncoder);
|
|
81
|
+
this.material?.updateShaderInputs(commandEncoder);
|
|
725
82
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
* @param constantAttributes
|
|
733
|
-
*/
|
|
734
|
-
setConstantAttributes(attributes, options) {
|
|
735
|
-
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
736
|
-
const attributeInfo = this._attributeInfos[attributeName];
|
|
737
|
-
if (attributeInfo) {
|
|
738
|
-
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
739
|
-
}
|
|
740
|
-
else if (!(options?.disableWarnings ?? this.props.disableWarnings)) {
|
|
741
|
-
log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
this.setNeedsRedraw('constants');
|
|
83
|
+
_getShaderInputBindings() {
|
|
84
|
+
const bindings = super._getShaderInputBindings();
|
|
85
|
+
const material = this.material;
|
|
86
|
+
if (!material)
|
|
87
|
+
return bindings;
|
|
88
|
+
return Object.fromEntries(Object.entries(bindings).filter(([name]) => !material.ownsBinding(name)));
|
|
745
89
|
}
|
|
746
|
-
// INTERNAL METHODS
|
|
747
|
-
/** Check that bindings are loaded. Returns id of first binding that is still loading. */
|
|
748
90
|
_areBindingsLoading() {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
}
|
|
91
|
+
const loadingBinding = super._areBindingsLoading();
|
|
92
|
+
if (loadingBinding)
|
|
93
|
+
return loadingBinding;
|
|
754
94
|
for (const binding of Object.values(this.material?.bindings || {})) {
|
|
755
|
-
if (isTextureBindingSource(binding) && !binding.isReady)
|
|
95
|
+
if (isTextureBindingSource(binding) && !binding.isReady)
|
|
756
96
|
return binding.id;
|
|
757
|
-
}
|
|
758
97
|
}
|
|
759
98
|
return false;
|
|
760
99
|
}
|
|
761
|
-
/**
|
|
762
|
-
* Resolves ready model bindings for the current shader layout.
|
|
763
|
-
* @param shaderLayout Reflected bindings used to select copied or external texture resolution.
|
|
764
|
-
*/
|
|
765
|
-
_getBindings(shaderLayout = this._getCurrentShaderLayout()) {
|
|
766
|
-
const validBindings = {};
|
|
767
|
-
for (const [name, binding] of Object.entries(this.bindings)) {
|
|
768
|
-
const resolvedBinding = resolveModelBinding(name, binding, shaderLayout);
|
|
769
|
-
if (resolvedBinding) {
|
|
770
|
-
validBindings[name] = resolvedBinding;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
return validBindings;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Groups resolved model and material bindings for the current shader layout.
|
|
777
|
-
* @param shaderLayout Reflected bindings used to group logical binding names.
|
|
778
|
-
* @param bindings Model bindings already resolved for this draw preparation.
|
|
779
|
-
*/
|
|
780
100
|
_getBindGroups(shaderLayout = this._getCurrentShaderLayout(), bindings = this._getBindings(shaderLayout)) {
|
|
781
|
-
const bindGroups = shaderLayout
|
|
782
|
-
|
|
783
|
-
: { 0: bindings };
|
|
784
|
-
if (!this.material) {
|
|
785
|
-
return bindGroups;
|
|
786
|
-
}
|
|
787
|
-
for (const [groupKey, groupBindings] of Object.entries(this.material.getBindingsByGroup(shaderLayout))) {
|
|
101
|
+
const bindGroups = super._getBindGroups(shaderLayout, bindings);
|
|
102
|
+
for (const [groupKey, groupBindings] of Object.entries(this.material?.getBindingsByGroup(shaderLayout) || {})) {
|
|
788
103
|
const group = Number(groupKey);
|
|
789
|
-
bindGroups[group] = {
|
|
790
|
-
...(bindGroups[group] || {}),
|
|
791
|
-
...groupBindings
|
|
792
|
-
};
|
|
104
|
+
bindGroups[group] = { ...(bindGroups[group] || {}), ...groupBindings };
|
|
793
105
|
}
|
|
794
106
|
return bindGroups;
|
|
795
107
|
}
|
|
@@ -797,344 +109,8 @@ export class Model {
|
|
|
797
109
|
const bindGroupCacheKey = this.material?.getBindGroupCacheKey(3);
|
|
798
110
|
return bindGroupCacheKey ? { 3: bindGroupCacheKey } : {};
|
|
799
111
|
}
|
|
800
|
-
/** Get the timestamp of the latest updated bound GPU memory resource (buffer/texture). */
|
|
801
112
|
_getBindingsUpdateTimestamp() {
|
|
802
|
-
|
|
803
|
-
if (this._dynamicIndexBufferSource) {
|
|
804
|
-
timestamp = Math.max(timestamp, this._dynamicIndexBufferSource.source.updateTimestamp);
|
|
805
|
-
}
|
|
806
|
-
for (const entry of Object.values(this._dynamicAttributeBufferSources)) {
|
|
807
|
-
timestamp = Math.max(timestamp, entry.source.updateTimestamp);
|
|
808
|
-
}
|
|
809
|
-
for (const binding of Object.values(this.bindings)) {
|
|
810
|
-
if (binding instanceof TextureView) {
|
|
811
|
-
timestamp = Math.max(timestamp, binding.texture.updateTimestamp);
|
|
812
|
-
}
|
|
813
|
-
else if (binding instanceof Buffer ||
|
|
814
|
-
binding instanceof Texture ||
|
|
815
|
-
binding instanceof ExternalTexture) {
|
|
816
|
-
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
817
|
-
}
|
|
818
|
-
else if (binding instanceof DynamicBuffer) {
|
|
819
|
-
timestamp = Math.max(timestamp, binding.updateTimestamp);
|
|
820
|
-
}
|
|
821
|
-
else if (isTextureBindingSource(binding)) {
|
|
822
|
-
timestamp = binding.isReady
|
|
823
|
-
? Math.max(timestamp, binding.updateTimestamp)
|
|
824
|
-
: // The texture will become available in the future
|
|
825
|
-
Infinity;
|
|
826
|
-
}
|
|
827
|
-
else if (isBufferRangeBinding(binding)) {
|
|
828
|
-
timestamp = Math.max(timestamp, binding.buffer instanceof DynamicBuffer
|
|
829
|
-
? binding.buffer.updateTimestamp
|
|
830
|
-
: binding.buffer.updateTimestamp);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
return Math.max(timestamp, this.material?.getBindingsUpdateTimestamp() || 0);
|
|
113
|
+
return Math.max(super._getBindingsUpdateTimestamp(), this.material?.getBindingsUpdateTimestamp() || 0);
|
|
834
114
|
}
|
|
835
|
-
/**
|
|
836
|
-
* Updates the optional geometry attributes
|
|
837
|
-
* Geometry, sets several attributes, indexBuffer, and also vertex count
|
|
838
|
-
* @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU
|
|
839
|
-
*/
|
|
840
|
-
_setGeometryAttributes(gpuGeometry) {
|
|
841
|
-
// Filter geometry attribute so that we don't issue warnings for unused attributes
|
|
842
|
-
const attributes = { ...gpuGeometry.attributes };
|
|
843
|
-
for (const [attributeName] of Object.entries(attributes)) {
|
|
844
|
-
if (!this.pipeline.shaderLayout.attributes.find(layout => layout.name === attributeName) &&
|
|
845
|
-
attributeName !== 'positions') {
|
|
846
|
-
delete attributes[attributeName];
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
// TODO - delete previous geometry?
|
|
850
|
-
this.vertexCount = gpuGeometry.vertexCount;
|
|
851
|
-
this._vertexCountSet = true;
|
|
852
|
-
this.setIndexBuffer(gpuGeometry.indices || null);
|
|
853
|
-
this.setAttributes(gpuGeometry.attributes, { disableWarnings: true });
|
|
854
|
-
this.setAttributes(attributes, { disableWarnings: this.props.disableWarnings });
|
|
855
|
-
this.setNeedsRedraw('geometry attributes');
|
|
856
|
-
}
|
|
857
|
-
/** Mark pipeline as needing update */
|
|
858
|
-
_setPipelineNeedsUpdate(reason) {
|
|
859
|
-
this._pipelineNeedsUpdate ||= reason;
|
|
860
|
-
this._drawBlockedReason = false;
|
|
861
|
-
this.setNeedsRedraw(reason);
|
|
862
|
-
}
|
|
863
|
-
/** Update pipeline if needed */
|
|
864
|
-
_updatePipeline() {
|
|
865
|
-
const update = this._preparePipelineUpdate();
|
|
866
|
-
if (update) {
|
|
867
|
-
this.pipeline = this.pipelineFactory.createRenderPipeline(update.props);
|
|
868
|
-
this._finishPipelineUpdate(update);
|
|
869
|
-
}
|
|
870
|
-
return this.pipeline;
|
|
871
|
-
}
|
|
872
|
-
/** Creates or replaces the render pipeline through the backend's asynchronous compilation path. */
|
|
873
|
-
async _updatePipelineAsync() {
|
|
874
|
-
const update = this._preparePipelineUpdate();
|
|
875
|
-
if (update) {
|
|
876
|
-
try {
|
|
877
|
-
this.pipeline = await this.pipelineFactory.createRenderPipelineAsync(update.props);
|
|
878
|
-
}
|
|
879
|
-
catch (error) {
|
|
880
|
-
this._releasePipelineShaders(update.vertexShader, update.fragmentShader);
|
|
881
|
-
this._pipelineNeedsUpdate = 'asynchronous pipeline creation failed';
|
|
882
|
-
throw error;
|
|
883
|
-
}
|
|
884
|
-
this._finishPipelineUpdate(update);
|
|
885
|
-
}
|
|
886
|
-
return this.pipeline;
|
|
887
|
-
}
|
|
888
|
-
_preparePipelineUpdate() {
|
|
889
|
-
if (!this._pipelineNeedsUpdate)
|
|
890
|
-
return null;
|
|
891
|
-
const previousVertexShader = this.pipeline?.vs ?? null;
|
|
892
|
-
const previousFragmentShader = this.pipeline?.fs ?? null;
|
|
893
|
-
if (this.pipeline) {
|
|
894
|
-
log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
895
|
-
}
|
|
896
|
-
this._pipelineNeedsUpdate = false;
|
|
897
|
-
const vertexShader = this.shaderFactory.createShader({
|
|
898
|
-
id: `${this.id}-vertex`,
|
|
899
|
-
stage: 'vertex',
|
|
900
|
-
source: this.source || this.vs,
|
|
901
|
-
debugShaders: this.props.debugShaders
|
|
902
|
-
});
|
|
903
|
-
let fragmentShader = null;
|
|
904
|
-
if (this.source) {
|
|
905
|
-
fragmentShader = vertexShader;
|
|
906
|
-
}
|
|
907
|
-
else if (this.fs) {
|
|
908
|
-
fragmentShader = this.shaderFactory.createShader({
|
|
909
|
-
id: `${this.id}-fragment`,
|
|
910
|
-
stage: 'fragment',
|
|
911
|
-
source: this.fs,
|
|
912
|
-
debugShaders: this.props.debugShaders
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
return {
|
|
916
|
-
props: {
|
|
917
|
-
...this.props,
|
|
918
|
-
bindings: undefined,
|
|
919
|
-
bufferLayout: this.bufferLayout,
|
|
920
|
-
colorAttachmentFormats: this._colorAttachmentFormats,
|
|
921
|
-
depthStencilAttachmentFormat: this._depthStencilAttachmentFormat,
|
|
922
|
-
topology: this.topology,
|
|
923
|
-
parameters: this.parameters,
|
|
924
|
-
bindGroups: undefined,
|
|
925
|
-
vs: vertexShader,
|
|
926
|
-
fs: fragmentShader
|
|
927
|
-
},
|
|
928
|
-
vertexShader,
|
|
929
|
-
fragmentShader,
|
|
930
|
-
previousVertexShader,
|
|
931
|
-
previousFragmentShader
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
_finishPipelineUpdate(update) {
|
|
935
|
-
this._attributeInfos = getAttributeInfosFromLayouts(this.pipeline.shaderLayout, this.bufferLayout);
|
|
936
|
-
this._releasePipelineShaders(update.previousVertexShader, update.previousFragmentShader);
|
|
937
|
-
}
|
|
938
|
-
_releasePipelineShaders(vertexShader, fragmentShader) {
|
|
939
|
-
if (vertexShader)
|
|
940
|
-
this.shaderFactory.release(vertexShader);
|
|
941
|
-
if (fragmentShader && fragmentShader !== vertexShader) {
|
|
942
|
-
this.shaderFactory.release(fragmentShader);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
/** Throttle draw call logging */
|
|
946
|
-
_lastLogTime = 0;
|
|
947
|
-
_logOpen = false;
|
|
948
|
-
_logDrawCallStart() {
|
|
949
|
-
// IF level is 4 or higher, log every frame.
|
|
950
|
-
const logDrawTimeout = log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
951
|
-
if (log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
this._lastLogTime = Date.now();
|
|
955
|
-
this._logOpen = true;
|
|
956
|
-
log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: log.level <= 2 })();
|
|
957
|
-
}
|
|
958
|
-
_logDrawCallEnd() {
|
|
959
|
-
if (this._logOpen) {
|
|
960
|
-
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
961
|
-
// log.table(logLevel, attributeTable)();
|
|
962
|
-
// log.table(logLevel, uniformTable)();
|
|
963
|
-
log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
964
|
-
const uniformTable = this.shaderInputs.getDebugTable();
|
|
965
|
-
log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
966
|
-
const attributeTable = this._getAttributeDebugTable();
|
|
967
|
-
log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
968
|
-
log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
969
|
-
log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
970
|
-
this._logOpen = false;
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
_drawCount = 0;
|
|
974
|
-
_logFramebuffer(renderPass) {
|
|
975
|
-
const debugFramebuffers = this.device.props.debugFramebuffers;
|
|
976
|
-
this._drawCount++;
|
|
977
|
-
// Update first 3 frames and then every 60 frames
|
|
978
|
-
if (!debugFramebuffers) {
|
|
979
|
-
// } || (this._drawCount++ > 3 && this._drawCount % 60)) {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
const framebuffer = renderPass.props.framebuffer;
|
|
983
|
-
debugFramebuffer(renderPass, framebuffer, {
|
|
984
|
-
id: framebuffer?.id || `${this.id}-framebuffer`,
|
|
985
|
-
minimap: true
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
_getAttributeDebugTable() {
|
|
989
|
-
const table = {};
|
|
990
|
-
for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
|
|
991
|
-
const values = this.vertexArray.attributes[attributeInfo.location];
|
|
992
|
-
table[attributeInfo.location] = {
|
|
993
|
-
name,
|
|
994
|
-
type: attributeInfo.shaderType,
|
|
995
|
-
values: values
|
|
996
|
-
? this._getBufferOrConstantValues(values, attributeInfo.bufferDataType)
|
|
997
|
-
: 'null'
|
|
998
|
-
};
|
|
999
|
-
}
|
|
1000
|
-
if (this.vertexArray.indexBuffer) {
|
|
1001
|
-
const { indexBuffer } = this.vertexArray;
|
|
1002
|
-
const values = indexBuffer.indexType === 'uint32'
|
|
1003
|
-
? new Uint32Array(indexBuffer.debugData)
|
|
1004
|
-
: new Uint16Array(indexBuffer.debugData);
|
|
1005
|
-
table['indices'] = {
|
|
1006
|
-
name: 'indices',
|
|
1007
|
-
type: indexBuffer.indexType,
|
|
1008
|
-
values: values.toString()
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
return table;
|
|
1012
|
-
}
|
|
1013
|
-
// TODO - fix typing of luma data types
|
|
1014
|
-
_getBufferOrConstantValues(attribute, dataType) {
|
|
1015
|
-
const TypedArrayConstructor = dataTypeDecoder.getTypedArrayConstructor(dataType);
|
|
1016
|
-
const typedArray = attribute instanceof Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
1017
|
-
return typedArray.toString();
|
|
1018
|
-
}
|
|
1019
|
-
_getNonMaterialBindings(bindings) {
|
|
1020
|
-
if (!this.material) {
|
|
1021
|
-
return bindings;
|
|
1022
|
-
}
|
|
1023
|
-
const filteredBindings = {};
|
|
1024
|
-
for (const [name, binding] of Object.entries(bindings)) {
|
|
1025
|
-
if (!this.material.ownsBinding(name)) {
|
|
1026
|
-
filteredBindings[name] = binding;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
return filteredBindings;
|
|
1030
|
-
}
|
|
1031
|
-
/** Returns the current reflected shader layout or the pre-reflection empty layout. */
|
|
1032
|
-
_getCurrentShaderLayout() {
|
|
1033
|
-
return this.pipeline?.shaderLayout || this.props.shaderLayout || { bindings: [] };
|
|
1034
|
-
}
|
|
1035
|
-
_syncDynamicBuffers() {
|
|
1036
|
-
if (this._dynamicIndexBufferSource &&
|
|
1037
|
-
this._dynamicIndexBufferSource.generation !== this._dynamicIndexBufferSource.source.generation) {
|
|
1038
|
-
const resolvedIndexBuffer = this._dynamicIndexBufferSource.source.buffer;
|
|
1039
|
-
this.indexBuffer = resolvedIndexBuffer;
|
|
1040
|
-
this.vertexArray.setIndexBuffer(resolvedIndexBuffer);
|
|
1041
|
-
this._dynamicIndexBufferSource.generation = this._dynamicIndexBufferSource.source.generation;
|
|
1042
|
-
this.setNeedsRedraw('dynamic index buffer');
|
|
1043
|
-
}
|
|
1044
|
-
for (const [locationKey, entry] of Object.entries(this._dynamicAttributeBufferSources)) {
|
|
1045
|
-
if (entry.generation !== entry.source.generation) {
|
|
1046
|
-
this.vertexArray.setBuffer(Number(locationKey), entry.source.buffer, entry.byteOffset);
|
|
1047
|
-
entry.generation = entry.source.generation;
|
|
1048
|
-
this.setNeedsRedraw('dynamic attribute buffer');
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
_syncAttachmentFormats(renderPass) {
|
|
1053
|
-
if (this.device.type !== 'webgpu') {
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
const framebuffer = renderPass.framebuffer || renderPass.props.framebuffer;
|
|
1057
|
-
const renderBundleProps = renderPass.props;
|
|
1058
|
-
const nextColorAttachmentFormats = renderBundleProps.colorAttachmentFormats ??
|
|
1059
|
-
framebuffer?.colorAttachments?.map(colorAttachment => asColorAttachmentFormat(colorAttachment?.texture?.format));
|
|
1060
|
-
const nextDepthStencilAttachmentFormat = renderBundleProps.depthStencilAttachmentFormat === false
|
|
1061
|
-
? undefined
|
|
1062
|
-
: (renderBundleProps.depthStencilAttachmentFormat ??
|
|
1063
|
-
asDepthStencilAttachmentFormat(framebuffer?.depthStencilAttachment?.texture?.format));
|
|
1064
|
-
if (!deepEqual(this._colorAttachmentFormats, nextColorAttachmentFormats, 1) ||
|
|
1065
|
-
this._depthStencilAttachmentFormat !== nextDepthStencilAttachmentFormat) {
|
|
1066
|
-
this._colorAttachmentFormats = nextColorAttachmentFormats;
|
|
1067
|
-
this._depthStencilAttachmentFormat = nextDepthStencilAttachmentFormat;
|
|
1068
|
-
this._setPipelineNeedsUpdate('attachment formats');
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
function isShaderAssemblerForLanguage(shaderAssembler, shaderLanguage) {
|
|
1073
|
-
if (shaderAssembler.shaderLanguage !== undefined &&
|
|
1074
|
-
shaderAssembler.shaderLanguage !== shaderLanguage) {
|
|
1075
|
-
return false;
|
|
1076
|
-
}
|
|
1077
|
-
return shaderLanguage === 'glsl'
|
|
1078
|
-
? 'assembleGLSLShaderPair' in shaderAssembler &&
|
|
1079
|
-
typeof shaderAssembler.assembleGLSLShaderPair === 'function'
|
|
1080
|
-
: 'assembleWGSLShader' in shaderAssembler &&
|
|
1081
|
-
typeof shaderAssembler.assembleWGSLShader === 'function';
|
|
1082
|
-
}
|
|
1083
|
-
function normalizeShaderPluginAttributeNames(shaderLayout, vertexInputs) {
|
|
1084
|
-
if (!shaderLayout || Object.keys(vertexInputs).length === 0) {
|
|
1085
|
-
return shaderLayout;
|
|
1086
|
-
}
|
|
1087
|
-
return {
|
|
1088
|
-
...shaderLayout,
|
|
1089
|
-
attributes: shaderLayout.attributes.map(attribute => {
|
|
1090
|
-
const publicName = attribute.name.startsWith('_luma_')
|
|
1091
|
-
? attribute.name.slice('_luma_'.length)
|
|
1092
|
-
: null;
|
|
1093
|
-
return publicName && vertexInputs[publicName] ? { ...attribute, name: publicName } : attribute;
|
|
1094
|
-
})
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* Resolves one model binding against the current shader layout.
|
|
1099
|
-
* @param bindingName Logical model binding name.
|
|
1100
|
-
* @param binding Model binding or deferred engine binding source.
|
|
1101
|
-
* @param shaderLayout Reflected bindings used to select copied or external texture resolution.
|
|
1102
|
-
* @returns Concrete core binding, or `null` while a deferred source is unavailable.
|
|
1103
|
-
*/
|
|
1104
|
-
function resolveModelBinding(bindingName, binding, shaderLayout) {
|
|
1105
|
-
if (isTextureBindingSource(binding)) {
|
|
1106
|
-
const bindingLayout = getTextureBindingLayout(shaderLayout, bindingName, {
|
|
1107
|
-
fallbackGroup: 0
|
|
1108
|
-
});
|
|
1109
|
-
return bindingLayout ? binding.resolveTextureBinding(bindingLayout) : null;
|
|
1110
|
-
}
|
|
1111
|
-
if (binding instanceof DynamicBuffer) {
|
|
1112
|
-
return binding.buffer;
|
|
1113
|
-
}
|
|
1114
|
-
if (isBufferRangeBinding(binding)) {
|
|
1115
|
-
return resolveBufferRangeBinding(binding);
|
|
1116
|
-
}
|
|
1117
|
-
return binding;
|
|
1118
|
-
}
|
|
1119
|
-
function asColorAttachmentFormat(format) {
|
|
1120
|
-
return format && !isDepthStencilAttachmentFormat(format) ? format : null;
|
|
1121
|
-
}
|
|
1122
|
-
function asDepthStencilAttachmentFormat(format) {
|
|
1123
|
-
return format && isDepthStencilAttachmentFormat(format) ? format : undefined;
|
|
1124
|
-
}
|
|
1125
|
-
function isDepthStencilAttachmentFormat(format) {
|
|
1126
|
-
return DEPTH_STENCIL_ATTACHMENT_FORMATS.includes(format);
|
|
1127
|
-
}
|
|
1128
|
-
/** Create a shadertools platform info from the Device */
|
|
1129
|
-
export function getPlatformInfo(device) {
|
|
1130
|
-
return {
|
|
1131
|
-
type: device.type,
|
|
1132
|
-
shaderLanguage: device.info.shadingLanguage,
|
|
1133
|
-
shaderLanguageVersion: device.info.shadingLanguageVersion,
|
|
1134
|
-
gpu: device.info.gpu,
|
|
1135
|
-
limits: device.limits,
|
|
1136
|
-
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
|
|
1137
|
-
features: device.features
|
|
1138
|
-
};
|
|
1139
115
|
}
|
|
1140
116
|
//# sourceMappingURL=model.js.map
|