@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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {assert} from '@luma.gl/core';
|
|
6
6
|
import type {TypedArray} from '@math.gl/core';
|
|
7
|
+
import type {Geometry as MathGeometry} from '@math.gl/geometry';
|
|
7
8
|
import {Geometry, type GeometryAttribute} from './geometry';
|
|
8
9
|
|
|
9
10
|
export type MakeEdgeGeometryOptions = {
|
|
@@ -22,7 +23,7 @@ type Edge = {start: number; end: number; normal: Position; faceCount: number; cr
|
|
|
22
23
|
|
|
23
24
|
/** Extracts boundary, crease, and non-manifold edges from a triangle-list CPU geometry. */
|
|
24
25
|
export function makeEdgeGeometry(
|
|
25
|
-
geometry:
|
|
26
|
+
geometry: MathGeometry,
|
|
26
27
|
options: MakeEdgeGeometryOptions = {}
|
|
27
28
|
): Geometry {
|
|
28
29
|
const {angleThreshold = 30, weldTolerance = 0, positionAttribute = 'POSITION'} = options;
|
|
@@ -141,7 +142,7 @@ export function makeEdgeGeometry(
|
|
|
141
142
|
|
|
142
143
|
/** Classifies adjacent meshes together to suppress coplanar tile seams and duplicate edges. */
|
|
143
144
|
export function makeEdgeGeometryFromGeometries(
|
|
144
|
-
geometries: readonly
|
|
145
|
+
geometries: readonly MathGeometry[],
|
|
145
146
|
options: MakeEdgeGeometryOptions = {}
|
|
146
147
|
): Geometry {
|
|
147
148
|
// A batch needs at least one source to define its position storage type.
|
|
@@ -188,7 +189,10 @@ export function makeEdgeGeometryFromGeometries(
|
|
|
188
189
|
);
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
function getTrianglePositions(
|
|
192
|
+
function getTrianglePositions(
|
|
193
|
+
geometry: MathGeometry,
|
|
194
|
+
positionAttribute: string
|
|
195
|
+
): GeometryAttribute {
|
|
192
196
|
const positions = geometry.attributes[positionAttribute];
|
|
193
197
|
// Edge extraction requires packed xyz positions and complete triangle-list primitives.
|
|
194
198
|
assert(geometry.topology === 'triangle-list' && positions?.size === 3);
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
CubeGeometry as MathCubeGeometry,
|
|
7
|
+
SphereGeometry as MathSphereGeometry,
|
|
8
|
+
IcoSphereGeometry as MathIcoSphereGeometry,
|
|
9
|
+
PlaneGeometry as MathPlaneGeometry,
|
|
10
|
+
TruncatedConeGeometry as MathTruncatedConeGeometry,
|
|
11
|
+
unpackIndexedGeometry,
|
|
12
|
+
type Geometry as MathGeometry,
|
|
13
|
+
type GeometryAttributeInput,
|
|
14
|
+
type SphereGeometryProps,
|
|
15
|
+
type IcoSphereGeometryProps,
|
|
16
|
+
type TruncatedConeGeometryProps
|
|
17
|
+
} from '@math.gl/geometry';
|
|
18
|
+
import {TorusGeometry as MathTorusGeometry, type TorusGeometryProps} from '@math.gl/geometry';
|
|
19
|
+
import {Geometry} from './geometry';
|
|
20
|
+
|
|
21
|
+
export type {TorusGeometryProps};
|
|
22
|
+
|
|
23
|
+
/** Shared math.gl tessellation, including open partial sweeps around the Y axis. */
|
|
24
|
+
export class TorusGeometry extends Geometry {
|
|
25
|
+
constructor(props: TorusGeometryProps = {}) {
|
|
26
|
+
const source = new MathTorusGeometry(props);
|
|
27
|
+
super({...source, attributes: source.attributes});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type {SphereGeometryProps, IcoSphereGeometryProps, TruncatedConeGeometryProps};
|
|
32
|
+
|
|
33
|
+
export type CubeGeometryProps = {
|
|
34
|
+
id?: string;
|
|
35
|
+
indices?: boolean;
|
|
36
|
+
attributes?: Record<string, GeometryAttributeInput>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Compatibility defaults and face metadata over the math.gl box tessellator. */
|
|
40
|
+
export class CubeGeometry extends Geometry {
|
|
41
|
+
constructor(props: CubeGeometryProps = {}) {
|
|
42
|
+
const source = new MathCubeGeometry({size: 2});
|
|
43
|
+
const faceIndices = new Uint32Array(24);
|
|
44
|
+
// The renderer's semantic face order is +Z, -Z, +Y, -Y, +X, -X.
|
|
45
|
+
const faceOrder = [4, 5, 2, 3, 0, 1];
|
|
46
|
+
for (let vertexIndex = 0; vertexIndex < faceIndices.length; vertexIndex++) {
|
|
47
|
+
faceIndices[vertexIndex] = faceOrder[Math.floor(vertexIndex / 4)];
|
|
48
|
+
}
|
|
49
|
+
source.attributes['faceIndex'] = {size: 1, value: faceIndices};
|
|
50
|
+
if (props.indices === false) {
|
|
51
|
+
source.attributes['COLOR_0'] = {
|
|
52
|
+
size: 3,
|
|
53
|
+
value: new Float32Array(
|
|
54
|
+
Array.from(source.attributes['POSITION'].value, value => (value + 1) / 2)
|
|
55
|
+
)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const data = props.indices === false ? unpackIndexedGeometry(source) : source;
|
|
59
|
+
super({
|
|
60
|
+
id: props.id,
|
|
61
|
+
topology: source.topology,
|
|
62
|
+
indices: props.indices === false ? undefined : source.indices,
|
|
63
|
+
attributes: mergeAttributes(data.attributes, props.attributes)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class SphereGeometry extends Geometry {
|
|
69
|
+
constructor(props: SphereGeometryProps = {}) {
|
|
70
|
+
const source = new MathSphereGeometry({
|
|
71
|
+
...props,
|
|
72
|
+
attributes: undefined,
|
|
73
|
+
radius: props.radius ?? 1
|
|
74
|
+
});
|
|
75
|
+
// Retain the legacy longitude-to-UV mapping while math.gl tessellates the sphere.
|
|
76
|
+
for (const name of ['POSITION', 'NORMAL']) {
|
|
77
|
+
const values = source.attributes[name].value;
|
|
78
|
+
for (let index = 0; index < values.length; index += 3) {
|
|
79
|
+
const horizontal = values[index];
|
|
80
|
+
values[index] = values[index + 2];
|
|
81
|
+
values[index + 2] = horizontal;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const indices = source.indices?.value;
|
|
85
|
+
if (indices) {
|
|
86
|
+
for (let index = 0; index < indices.length; index += 3) {
|
|
87
|
+
const second = indices[index + 1];
|
|
88
|
+
indices[index + 1] = indices[index + 2];
|
|
89
|
+
indices[index + 2] = second;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
super({...source, attributes: {...source.attributes, ...props.attributes}});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export class IcoSphereGeometry extends Geometry {
|
|
97
|
+
constructor(props: IcoSphereGeometryProps = {}) {
|
|
98
|
+
const source = new MathIcoSphereGeometry({...props, radius: props.radius ?? 1});
|
|
99
|
+
super({...source, attributes: source.attributes});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class TruncatedConeGeometry extends Geometry {
|
|
104
|
+
constructor(props: TruncatedConeGeometryProps = {}) {
|
|
105
|
+
const source = new MathTruncatedConeGeometry({...props, bottomRadius: props.bottomRadius ?? 1});
|
|
106
|
+
super({...source, attributes: source.attributes});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type CylinderGeometryProps = Omit<
|
|
111
|
+
TruncatedConeGeometryProps,
|
|
112
|
+
'topRadius' | 'bottomRadius'
|
|
113
|
+
> & {
|
|
114
|
+
radius?: number;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export class CylinderGeometry extends TruncatedConeGeometry {
|
|
118
|
+
constructor(props: CylinderGeometryProps = {}) {
|
|
119
|
+
const radius = props.radius ?? 1;
|
|
120
|
+
super({...props, topRadius: radius, bottomRadius: radius});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type ConeGeometryProps = Omit<
|
|
125
|
+
TruncatedConeGeometryProps,
|
|
126
|
+
'topRadius' | 'bottomRadius' | 'topCap' | 'bottomCap'
|
|
127
|
+
> & {radius?: number; cap?: boolean};
|
|
128
|
+
|
|
129
|
+
export class ConeGeometry extends TruncatedConeGeometry {
|
|
130
|
+
constructor(props: ConeGeometryProps = {}) {
|
|
131
|
+
const cap = props.cap ?? true;
|
|
132
|
+
super({...props, topRadius: 0, bottomRadius: props.radius ?? 1, topCap: cap, bottomCap: cap});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type PlaneGeometryProps = {
|
|
137
|
+
id?: string;
|
|
138
|
+
radius?: number;
|
|
139
|
+
attributes?: Record<string, GeometryAttributeInput>;
|
|
140
|
+
type?: 'x,y' | 'x,z' | 'y,z';
|
|
141
|
+
offset?: number;
|
|
142
|
+
flipCull?: boolean;
|
|
143
|
+
unpack?: boolean;
|
|
144
|
+
xlen?: number;
|
|
145
|
+
ylen?: number;
|
|
146
|
+
zlen?: number;
|
|
147
|
+
nx?: number;
|
|
148
|
+
ny?: number;
|
|
149
|
+
nz?: number;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Adapts legacy plane axes and facing to math.gl's XZ plane. */
|
|
153
|
+
export class PlaneGeometry extends Geometry {
|
|
154
|
+
constructor(props: PlaneGeometryProps = {}) {
|
|
155
|
+
const {type = 'x,y', offset = 0, flipCull = false} = props;
|
|
156
|
+
const planeAxes = {
|
|
157
|
+
'x,y': {sizeX: props.xlen, sizeZ: props.ylen, nx: props.nx, nz: props.ny},
|
|
158
|
+
'x,z': {sizeX: props.xlen, sizeZ: props.zlen, nx: props.nx, nz: props.nz},
|
|
159
|
+
'y,z': {sizeX: props.ylen, sizeZ: props.zlen, nx: props.ny, nz: props.nz}
|
|
160
|
+
}[type];
|
|
161
|
+
// Only the three legacy axis pairs are supported.
|
|
162
|
+
if (!planeAxes) throw new Error('Invalid plane axes');
|
|
163
|
+
const source = new MathPlaneGeometry({
|
|
164
|
+
sizeX: planeAxes.sizeX || 1,
|
|
165
|
+
sizeZ: planeAxes.sizeZ || 1,
|
|
166
|
+
nx: planeAxes.nx || 1,
|
|
167
|
+
nz: planeAxes.nz || 1
|
|
168
|
+
});
|
|
169
|
+
orientPlane(source, type, offset, flipCull);
|
|
170
|
+
const data = props.unpack ? unpackIndexedGeometry(source) : source;
|
|
171
|
+
super({
|
|
172
|
+
id: props.id,
|
|
173
|
+
topology: source.topology,
|
|
174
|
+
indices: props.unpack ? undefined : source.indices,
|
|
175
|
+
attributes: mergeAttributes(data.attributes, props.attributes)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function orientPlane(
|
|
181
|
+
geometry: MathGeometry,
|
|
182
|
+
type: NonNullable<PlaneGeometryProps['type']>,
|
|
183
|
+
offset: number,
|
|
184
|
+
flipCull: boolean
|
|
185
|
+
): void {
|
|
186
|
+
const positions = geometry.attributes['POSITION'].value;
|
|
187
|
+
const normals = geometry.attributes['NORMAL'].value;
|
|
188
|
+
const texCoords = geometry.attributes['TEXCOORD_0'].value;
|
|
189
|
+
for (let vertexIndex = 0; vertexIndex < positions.length / 3; vertexIndex++) {
|
|
190
|
+
const positionIndex = vertexIndex * 3;
|
|
191
|
+
const horizontal = Number(positions[positionIndex]) * (flipCull ? -1 : 1);
|
|
192
|
+
const vertical = -Number(positions[positionIndex + 2]);
|
|
193
|
+
const normal = flipCull ? 1 : -1;
|
|
194
|
+
if (type === 'x,y') {
|
|
195
|
+
positions.set([horizontal, vertical, offset], positionIndex);
|
|
196
|
+
normals.set([0, 0, normal], positionIndex);
|
|
197
|
+
} else if (type === 'x,z') {
|
|
198
|
+
positions.set([horizontal, offset, vertical], positionIndex);
|
|
199
|
+
normals.set([0, normal, 0], positionIndex);
|
|
200
|
+
} else {
|
|
201
|
+
positions.set([offset, horizontal, vertical], positionIndex);
|
|
202
|
+
normals.set([normal, 0, 0], positionIndex);
|
|
203
|
+
}
|
|
204
|
+
if (flipCull) texCoords[vertexIndex * 2] = 1 - Number(texCoords[vertexIndex * 2]);
|
|
205
|
+
}
|
|
206
|
+
// The legacy XY and YZ planes face the negative perpendicular axis.
|
|
207
|
+
if (type !== 'x,z' && geometry.indices) {
|
|
208
|
+
const indices = geometry.indices.value;
|
|
209
|
+
for (let index = 0; index < indices.length; index += 3) {
|
|
210
|
+
const second = indices[index + 1];
|
|
211
|
+
indices[index + 1] = indices[index + 2];
|
|
212
|
+
indices[index + 2] = second;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function mergeAttributes(
|
|
218
|
+
source: Record<string, GeometryAttributeInput | undefined>,
|
|
219
|
+
overrides: Record<string, GeometryAttributeInput> = {}
|
|
220
|
+
): Record<string, GeometryAttributeInput> {
|
|
221
|
+
const attributes: Record<string, GeometryAttributeInput> = {};
|
|
222
|
+
for (const [name, attribute] of Object.entries(source)) {
|
|
223
|
+
if (attribute) attributes[name] = attribute;
|
|
224
|
+
}
|
|
225
|
+
return {...attributes, ...overrides};
|
|
226
|
+
}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {VertexFormat} from '@luma.gl/core';
|
|
5
|
+
import type {BufferLayout, VertexFormat} from '@luma.gl/core';
|
|
6
6
|
import {vertexFormatDecoder} from '@luma.gl/core';
|
|
7
7
|
import type {TypedArray} from '@math.gl/core';
|
|
8
|
+
import type {Geometry as MathGeometry} from '@math.gl/geometry';
|
|
9
|
+
export {unpackIndexedGeometry} from '@math.gl/geometry';
|
|
8
10
|
import {Geometry, getGeometryShaderAttributeName, type GeometryAttribute} from './geometry';
|
|
9
11
|
|
|
10
12
|
type TypedArrayConstructor = {
|
|
@@ -13,11 +15,6 @@ type TypedArrayConstructor = {
|
|
|
13
15
|
readonly BYTES_PER_ELEMENT: number;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
|
-
type GeometryLike = {
|
|
17
|
-
indices?: GeometryAttribute;
|
|
18
|
-
attributes: Record<string, GeometryAttribute | undefined>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
18
|
/** Options for {@link makeInterleavedGeometry}. */
|
|
22
19
|
export type MakeInterleavedGeometryOptions = {
|
|
23
20
|
/** Name of the packed geometry buffer. Defaults to `geometry`. */
|
|
@@ -44,48 +41,6 @@ type InterleavedAttribute = {
|
|
|
44
41
|
byteLength: number;
|
|
45
42
|
};
|
|
46
43
|
|
|
47
|
-
/**
|
|
48
|
-
* Expands indexed geometry attributes into non-indexed attributes.
|
|
49
|
-
*
|
|
50
|
-
* The returned object keeps the original attribute keys and replaces each non-constant attribute
|
|
51
|
-
* with data expanded through the index buffer. The `indices` field is intentionally omitted from
|
|
52
|
-
* the returned geometry-like object.
|
|
53
|
-
*/
|
|
54
|
-
export function unpackIndexedGeometry<T extends GeometryLike>(geometry: T): GeometryLike {
|
|
55
|
-
const {indices, attributes} = geometry;
|
|
56
|
-
if (!indices) {
|
|
57
|
-
return geometry;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const vertexCount = indices.value.length;
|
|
61
|
-
const unpackedAttributes: Record<string, GeometryAttribute> = {};
|
|
62
|
-
|
|
63
|
-
for (const attributeName in attributes) {
|
|
64
|
-
const attribute = attributes[attributeName];
|
|
65
|
-
if (!attribute) {
|
|
66
|
-
continue; // eslint-disable-line
|
|
67
|
-
}
|
|
68
|
-
const {value, size} = attribute;
|
|
69
|
-
const constant = attribute['constant'];
|
|
70
|
-
if (constant || !size) {
|
|
71
|
-
continue; // eslint-disable-line
|
|
72
|
-
}
|
|
73
|
-
const ArrayType = value.constructor as TypedArrayConstructor;
|
|
74
|
-
const unpackedValue = new ArrayType(vertexCount * size);
|
|
75
|
-
for (let x = 0; x < vertexCount; ++x) {
|
|
76
|
-
const index = indices.value[x];
|
|
77
|
-
for (let i = 0; i < size; i++) {
|
|
78
|
-
unpackedValue[x * size + i] = value[index * size + i];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
unpackedAttributes[attributeName] = {size, value: unpackedValue};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
attributes: Object.assign({}, attributes, unpackedAttributes)
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
44
|
/**
|
|
90
45
|
* Packs a CPU {@link Geometry} into one interleaved vertex buffer.
|
|
91
46
|
*
|
|
@@ -95,7 +50,7 @@ export function unpackIndexedGeometry<T extends GeometryLike>(geometry: T): Geom
|
|
|
95
50
|
* idempotent and returns the original instance.
|
|
96
51
|
*/
|
|
97
52
|
export function makeInterleavedGeometry(
|
|
98
|
-
geometry:
|
|
53
|
+
geometry: MathGeometry & {bufferLayout?: BufferLayout[]},
|
|
99
54
|
options: MakeInterleavedGeometryOptions = {}
|
|
100
55
|
): Geometry {
|
|
101
56
|
const bufferName = options.bufferName || 'geometry';
|
|
@@ -183,8 +138,11 @@ export function makeInterleavedGeometry(
|
|
|
183
138
|
});
|
|
184
139
|
}
|
|
185
140
|
|
|
186
|
-
function isInterleavedGeometry(
|
|
187
|
-
|
|
141
|
+
function isInterleavedGeometry(
|
|
142
|
+
geometry: MathGeometry & {bufferLayout?: BufferLayout[]},
|
|
143
|
+
bufferName: string
|
|
144
|
+
): geometry is Geometry {
|
|
145
|
+
if (geometry.bufferLayout?.length !== 1) {
|
|
188
146
|
return false;
|
|
189
147
|
}
|
|
190
148
|
|
|
@@ -197,13 +155,16 @@ function isInterleavedGeometry(geometry: Geometry, bufferName: string): boolean
|
|
|
197
155
|
}
|
|
198
156
|
|
|
199
157
|
function getInterleavedSourceAttributes(
|
|
200
|
-
geometry:
|
|
158
|
+
geometry: MathGeometry,
|
|
201
159
|
attributeNames?: string[]
|
|
202
160
|
): Array<[string, GeometryAttribute | undefined]> {
|
|
203
|
-
|
|
204
|
-
|
|
161
|
+
const attributes = new Map<string, [string, GeometryAttribute]>();
|
|
162
|
+
const sourceNames = attributeNames || Object.keys(geometry.attributes);
|
|
163
|
+
for (const name of sourceNames) {
|
|
164
|
+
const attribute = geometry.attributes[name];
|
|
165
|
+
if (attribute) attributes.set(getGeometryShaderAttributeName(name), [name, attribute]);
|
|
205
166
|
}
|
|
206
|
-
return
|
|
167
|
+
return Array.from(attributes.values());
|
|
207
168
|
}
|
|
208
169
|
|
|
209
170
|
function writeInterleavedAttribute(
|
|
@@ -236,19 +197,3 @@ function writeInterleavedAttribute(
|
|
|
236
197
|
function alignTo(byteOffset: number, alignment: number): number {
|
|
237
198
|
return Math.ceil(byteOffset / alignment) * alignment;
|
|
238
199
|
}
|
|
239
|
-
|
|
240
|
-
// export function calculateVertexNormals(positions: Float32Array): Uint8Array {
|
|
241
|
-
// let normals = new Uint8Array(positions.length / 3);
|
|
242
|
-
|
|
243
|
-
// for (let i = 0; i < positions.length; i++) {
|
|
244
|
-
// const vec1 = new Vector3(positions.subarray(i * 3, i + 0, i + 3));
|
|
245
|
-
// const vec2 = new Vector3(positions.subarray(i + 3, i + 6));
|
|
246
|
-
// const vec3 = new Vector3(positions.subarray(i + 6, i + 9));
|
|
247
|
-
|
|
248
|
-
// const normal = new Vector3(vec1).cross(vec2).normalize();
|
|
249
|
-
// normals.set(normal[0], i + 4);
|
|
250
|
-
// normals.set(normal[1], i + 4 + 1);
|
|
251
|
-
// normals.set(normal[2], i + 2);
|
|
252
|
-
// }
|
|
253
|
-
// const normal = new Vector3(vec1).cross(vec2).normalize();
|
|
254
|
-
// }
|
package/src/geometry/geometry.ts
CHANGED
|
@@ -2,181 +2,54 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type
|
|
6
|
-
import type {BufferLayout
|
|
5
|
+
import {Geometry as MathGeometry, type GeometryProps as MathGeometryProps} from '@math.gl/geometry';
|
|
6
|
+
import type {BufferLayout} from '@luma.gl/core';
|
|
7
7
|
import {vertexFormatDecoder} from '@luma.gl/core';
|
|
8
|
-
import {
|
|
8
|
+
import type {GeometryAttribute} from '@math.gl/geometry';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export type {
|
|
11
|
+
GeometryAttribute,
|
|
12
|
+
GeometryAttributeInput,
|
|
13
|
+
GeometryAttributes
|
|
14
|
+
} from '@math.gl/geometry';
|
|
12
15
|
|
|
13
|
-
/**
|
|
14
|
-
export type GeometryProps = {
|
|
15
|
-
/** Application-provided identifier. */
|
|
16
|
-
id?: string;
|
|
17
|
-
/** Determines how vertices are assembled into primitives. */
|
|
18
|
-
topology: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
|
|
19
|
-
/** Draw vertex count. Auto-calculated from attributes or indices when omitted. */
|
|
20
|
-
vertexCount?: number;
|
|
21
|
-
/** CPU attributes, keyed by caller-provided names such as glTF mesh attribute semantics. */
|
|
22
|
-
attributes: Record<string, GeometryAttributeInput>;
|
|
23
|
-
/**
|
|
24
|
-
* Maps geometry buffers to shader attributes.
|
|
25
|
-
*
|
|
26
|
-
* If omitted, the constructor creates one shader-facing buffer layout entry for each attribute.
|
|
27
|
-
* Explicit buffer layouts are preserved unchanged.
|
|
28
|
-
*/
|
|
29
|
-
bufferLayout?: BufferLayout[];
|
|
30
|
-
/** Optional index data. Indices are always stored separately from vertex attributes. */
|
|
31
|
-
indices?: GeometryAttribute | TypedArray;
|
|
32
|
-
};
|
|
16
|
+
/** Legacy engine geometry properties, including caller-owned shader layout metadata. */
|
|
17
|
+
export type GeometryProps = MathGeometryProps & {bufferLayout?: BufferLayout[]};
|
|
33
18
|
|
|
34
|
-
/**
|
|
35
|
-
export
|
|
36
|
-
/** Optional index attribute, included when the geometry is indexed. */
|
|
37
|
-
indices?: GeometryAttribute & {size: 1; value: Uint32Array | Uint16Array};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/** Typed-array backed CPU geometry attribute. */
|
|
41
|
-
export type GeometryAttribute = {
|
|
42
|
-
/** Number of typed-array elements per vertex. */
|
|
43
|
-
size?: number;
|
|
44
|
-
/** Attribute data. */
|
|
45
|
-
value: TypedArray;
|
|
46
|
-
/** Additional attribute metadata consumed by geometry utilities. */
|
|
47
|
-
[key: string]: any;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* CPU-side geometry container.
|
|
52
|
-
*
|
|
53
|
-
* `Geometry` stores typed-array vertex data, optional index data, and an always-populated
|
|
54
|
-
* `bufferLayout` that describes how its attributes map to shader inputs. CPU attribute names are
|
|
55
|
-
* preserved as supplied; synthesized buffer layouts map supported glTF-style names such as
|
|
56
|
-
* `POSITION` and `TEXCOORD_0` to default shader names such as `positions` and `texCoords`.
|
|
57
|
-
*/
|
|
58
|
-
export class Geometry {
|
|
59
|
-
/** Application-provided or generated identifier. */
|
|
60
|
-
readonly id: string;
|
|
61
|
-
|
|
62
|
-
/** Determines how vertices are assembled into primitives. */
|
|
63
|
-
readonly topology?: PrimitiveTopology;
|
|
64
|
-
|
|
65
|
-
/** Resolved draw vertex count. */
|
|
66
|
-
readonly vertexCount: number;
|
|
67
|
-
|
|
68
|
-
/** Optional index attribute. */
|
|
69
|
-
readonly indices?: GeometryAttribute;
|
|
70
|
-
|
|
71
|
-
/** CPU attributes, keyed by caller-provided source attribute name. */
|
|
72
|
-
readonly attributes: Record<string, GeometryAttribute | undefined>;
|
|
73
|
-
|
|
74
|
-
/** Buffer layout matching the geometry attributes. Always populated. */
|
|
19
|
+
/** Compatibility adapter for math.gl CPU geometry with engine shader layout metadata. */
|
|
20
|
+
export class Geometry extends MathGeometry {
|
|
75
21
|
readonly bufferLayout: BufferLayout[];
|
|
76
22
|
|
|
77
|
-
/** Application-owned metadata. */
|
|
78
|
-
userData: Record<string, unknown> = {};
|
|
79
|
-
|
|
80
|
-
/** Creates a CPU geometry and wraps raw typed arrays into attribute records. */
|
|
81
23
|
constructor(props: GeometryProps) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
24
|
+
const attributes: MathGeometryProps['attributes'] = {};
|
|
25
|
+
const sourceNames = new Map<string, string>();
|
|
26
|
+
for (const [name, attribute] of Object.entries(props.attributes)) {
|
|
27
|
+
const shaderName = getGeometryShaderAttributeName(name);
|
|
28
|
+
const previousName = sourceNames.get(shaderName);
|
|
29
|
+
if (previousName) delete attributes[previousName];
|
|
30
|
+
sourceNames.set(shaderName, name);
|
|
31
|
+
attributes[name] = attribute;
|
|
89
32
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
|
|
106
|
-
attribute.size = 3;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Move indices to separate field
|
|
110
|
-
if (attributeName === 'indices') {
|
|
111
|
-
if (this.indices) {
|
|
112
|
-
throw new Error('Multiple indices detected');
|
|
113
|
-
}
|
|
114
|
-
this.indices = attribute;
|
|
115
|
-
} else {
|
|
116
|
-
const shaderAttributeName = getGeometryShaderAttributeName(attributeName);
|
|
117
|
-
const storedAttributeName = Object.keys(this.attributes).find(
|
|
118
|
-
name => getGeometryShaderAttributeName(name) === shaderAttributeName
|
|
119
|
-
);
|
|
120
|
-
if (storedAttributeName) {
|
|
121
|
-
delete this.attributes[storedAttributeName];
|
|
122
|
-
}
|
|
123
|
-
this.attributes[attributeName] = attribute;
|
|
33
|
+
const sourceIndices = props.indices;
|
|
34
|
+
const indices =
|
|
35
|
+
sourceIndices instanceof Uint8Array
|
|
36
|
+
? new Uint16Array(sourceIndices)
|
|
37
|
+
: sourceIndices &&
|
|
38
|
+
!ArrayBuffer.isView(sourceIndices) &&
|
|
39
|
+
sourceIndices.value instanceof Uint8Array
|
|
40
|
+
? {...sourceIndices, value: new Uint16Array(sourceIndices.value)}
|
|
41
|
+
: sourceIndices;
|
|
42
|
+
super({...props, attributes, indices});
|
|
43
|
+
// Preserve legacy descriptor identity while math.gl owns normalization and validation.
|
|
44
|
+
for (const [name, input] of Object.entries(attributes)) {
|
|
45
|
+
if (!ArrayBuffer.isView(input) && Object.isExtensible(input) && name !== 'indices') {
|
|
46
|
+
Object.assign(input, this.attributes[name]);
|
|
47
|
+
this.attributes[name] = input;
|
|
124
48
|
}
|
|
125
49
|
}
|
|
126
|
-
|
|
127
|
-
if (this.indices && this.indices['isIndexed'] !== undefined) {
|
|
128
|
-
this.indices = Object.assign({}, this.indices);
|
|
129
|
-
delete this.indices['isIndexed'];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
|
|
133
50
|
this.bufferLayout =
|
|
134
51
|
props.bufferLayout || getBufferLayoutFromGeometryAttributes(this.attributes);
|
|
135
52
|
}
|
|
136
|
-
|
|
137
|
-
/** Returns the resolved draw vertex count. */
|
|
138
|
-
getVertexCount(): number {
|
|
139
|
-
return this.vertexCount;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Returns all attributes, including `indices` when index data is present. */
|
|
143
|
-
getAttributes(): GeometryAttributes {
|
|
144
|
-
return (
|
|
145
|
-
this.indices ? {indices: this.indices, ...this.attributes} : this.attributes
|
|
146
|
-
) as GeometryAttributes;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// PRIVATE
|
|
150
|
-
|
|
151
|
-
_print(attributeName: string): string {
|
|
152
|
-
return `Geometry ${this.id} attribute ${attributeName}`;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
_setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this {
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
_calculateVertexCount(
|
|
160
|
-
attributes: Record<string, GeometryAttribute | undefined>,
|
|
161
|
-
indices?: GeometryAttribute
|
|
162
|
-
): number {
|
|
163
|
-
if (indices) {
|
|
164
|
-
return indices.value.length;
|
|
165
|
-
}
|
|
166
|
-
let vertexCount = Infinity;
|
|
167
|
-
for (const attribute of Object.values(attributes)) {
|
|
168
|
-
if (!attribute) {
|
|
169
|
-
continue; // eslint-disable-line no-continue
|
|
170
|
-
}
|
|
171
|
-
const {value, size, constant} = attribute;
|
|
172
|
-
if (!constant && value && size !== undefined && size >= 1) {
|
|
173
|
-
vertexCount = Math.min(vertexCount, value.length / size);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// assert(Number.isFinite(vertexCount));
|
|
178
|
-
return vertexCount;
|
|
179
|
-
}
|
|
180
53
|
}
|
|
181
54
|
|
|
182
55
|
/**
|
|
@@ -202,7 +75,7 @@ export function getGeometryShaderAttributeName(attributeName: string): string {
|
|
|
202
75
|
}
|
|
203
76
|
}
|
|
204
77
|
|
|
205
|
-
function getBufferLayoutFromGeometryAttributes(
|
|
78
|
+
export function getBufferLayoutFromGeometryAttributes(
|
|
206
79
|
attributes: Record<string, GeometryAttribute | undefined>
|
|
207
80
|
): BufferLayout[] {
|
|
208
81
|
const bufferLayout: BufferLayout[] = [];
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import type {PrimitiveTopology, BufferLayout} from '@luma.gl/core';
|
|
6
6
|
import {Device, Buffer} from '@luma.gl/core';
|
|
7
|
-
import
|
|
7
|
+
import type {Geometry} from '@math.gl/geometry';
|
|
8
|
+
import {
|
|
9
|
+
getBufferLayoutFromGeometryAttributes,
|
|
10
|
+
getGeometryShaderAttributeName
|
|
11
|
+
} from '../geometry/geometry';
|
|
8
12
|
import {makeInterleavedGeometry} from './geometry-utils';
|
|
9
13
|
import {uid} from '../utils/uid';
|
|
10
14
|
|
|
@@ -143,12 +147,12 @@ export function getIndexBufferFromGeometry(device: Device, geometry: Geometry):
|
|
|
143
147
|
*/
|
|
144
148
|
export function getAttributeBuffersFromGeometry(
|
|
145
149
|
device: Device,
|
|
146
|
-
geometry: Geometry
|
|
150
|
+
geometry: Geometry & {bufferLayout?: BufferLayout[]}
|
|
147
151
|
): {attributes: Record<string, Buffer>; bufferLayout: BufferLayout[]; vertexCount: number} {
|
|
148
152
|
const attributes: Record<string, Buffer> = {};
|
|
149
153
|
for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
|
|
150
154
|
const name =
|
|
151
|
-
geometry.bufferLayout
|
|
155
|
+
geometry.bufferLayout?.find(bufferLayout => bufferLayout.name === attributeName)?.name ||
|
|
152
156
|
getGeometryShaderAttributeName(attributeName);
|
|
153
157
|
if (attribute) {
|
|
154
158
|
attributes[name] = device.createBuffer({
|
|
@@ -160,7 +164,8 @@ export function getAttributeBuffersFromGeometry(
|
|
|
160
164
|
|
|
161
165
|
return {
|
|
162
166
|
attributes,
|
|
163
|
-
bufferLayout:
|
|
167
|
+
bufferLayout:
|
|
168
|
+
geometry.bufferLayout || getBufferLayoutFromGeometryAttributes(geometry.attributes),
|
|
164
169
|
vertexCount: geometry.vertexCount
|
|
165
170
|
};
|
|
166
171
|
}
|