@luma.gl/engine 10.0.0-alpha.6 → 10.0.0-alpha.8
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 +2 -2
- package/dist/arrow/arrow-geometry.cjs +1 -1
- package/dist/arrow/arrow-geometry.js +1 -1
- package/dist/arrow/arrow-picking.cjs +1 -1
- package/dist/arrow/arrow-picking.d.ts +1 -1
- package/dist/arrow/arrow-picking.js +1 -1
- package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.cjs +5 -5
- package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.d.ts +2 -2
- package/dist/arrow/renderers/path/conversion/arrow-path-gpu-vectors.js +5 -5
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.cjs +3 -3
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.js +3 -3
- package/dist/arrow/renderers/path/source/arrow-path-source-mapping.cjs +1 -1
- package/dist/arrow/renderers/path/source/arrow-path-source-mapping.js +1 -1
- package/dist/arrow/renderers/path/transforms/close-arrow-paths.cjs +5 -5
- package/dist/arrow/renderers/path/transforms/close-arrow-paths.d.ts +1 -1
- package/dist/arrow/renderers/path/transforms/close-arrow-paths.js +5 -5
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.cjs +3 -3
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.d.ts +1 -1
- package/dist/arrow/renderers/path/transforms/gpu-path-float64-deltas.js +3 -3
- package/dist/arrow/renderers/path/transforms/path-view-origins.cjs +1 -1
- package/dist/arrow/renderers/path/transforms/path-view-origins.d.ts +1 -1
- package/dist/arrow/renderers/path/transforms/path-view-origins.js +1 -1
- package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.cjs +1 -1
- package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.d.ts +1 -1
- package/dist/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.js +1 -1
- package/dist/arrow/renderers/polygon/renderers/arrow-polygon-renderer.cjs +4 -4
- package/dist/arrow/renderers/polygon/renderers/arrow-polygon-renderer.js +4 -4
- package/dist/arrow/renderers/polygon/source/arrow-polygon-source-mapping.cjs +1 -1
- package/dist/arrow/renderers/polygon/source/arrow-polygon-source-mapping.js +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.cjs +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.js +1 -1
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.cjs +1 -1
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.d.ts +1 -1
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.js +1 -1
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.cjs +5 -5
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.d.ts +1 -1
- package/dist/arrow/renderers/text/conversion/convert-arrow-text-vectors.js +5 -5
- package/dist/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.cjs +1 -1
- package/dist/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.js +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-picking.cjs +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-picking.js +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.cjs +5 -5
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.js +5 -5
- package/dist/arrow/renderers/text/source/arrow-text-source-mapping.cjs +1 -1
- package/dist/arrow/renderers/text/source/arrow-text-source-mapping.js +1 -1
- package/dist/compute/computation.cjs +5 -2
- package/dist/compute/computation.d.ts +1 -1
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +5 -2
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/texture-transform.d.ts +2 -2
- package/dist/compute/texture-transform.d.ts.map +1 -1
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/dist.dev.js +889 -597
- package/dist/dist.min.js +64 -59
- package/dist/experimental/materials/emissive-material.cjs +1 -1
- package/dist/experimental/materials/emissive-material.d.ts +1 -1
- package/dist/experimental/materials/emissive-material.d.ts.map +1 -1
- package/dist/experimental/materials/emissive-material.js +1 -1
- package/dist/experimental/materials/emissive-material.js.map +1 -1
- package/dist/experimental/materials/glass-material.cjs +1 -1
- package/dist/experimental/materials/glass-material.d.ts +1 -1
- package/dist/experimental/materials/glass-material.d.ts.map +1 -1
- package/dist/experimental/materials/glass-material.js +1 -1
- package/dist/experimental/materials/glass-material.js.map +1 -1
- package/dist/experimental/materials/glass-transmission.cjs +1 -1
- package/dist/experimental/materials/glass-transmission.d.ts +1 -1
- package/dist/experimental/materials/glass-transmission.d.ts.map +1 -1
- package/dist/experimental/materials/glass-transmission.js +1 -1
- package/dist/experimental/materials/glass-transmission.js.map +1 -1
- package/dist/experimental/materials/index.cjs.map +1 -1
- package/dist/experimental/materials/optical-caustics.cjs +1 -1
- package/dist/experimental/materials/optical-caustics.d.ts +1 -1
- package/dist/experimental/materials/optical-caustics.d.ts.map +1 -1
- package/dist/experimental/materials/optical-caustics.js +1 -1
- package/dist/experimental/materials/optical-caustics.js.map +1 -1
- package/dist/experimental/materials/optical-point-lights.cjs +1 -1
- package/dist/experimental/materials/optical-point-lights.d.ts +1 -1
- package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -1
- package/dist/experimental/materials/optical-point-lights.js +1 -1
- package/dist/experimental/materials/optical-point-lights.js.map +1 -1
- package/dist/experimental/materials/reflective-material.cjs +1 -1
- package/dist/experimental/materials/reflective-material.d.ts +1 -1
- package/dist/experimental/materials/reflective-material.d.ts.map +1 -1
- package/dist/experimental/materials/reflective-material.js +1 -1
- package/dist/experimental/materials/reflective-material.js.map +1 -1
- package/dist/geometry/gpu-geometry.cjs +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +1 -1
- package/dist/geometry/gpu-geometry.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +25 -5
- package/dist/gltf/gltf/gltf-extension-support.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.js +27 -5
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/gltf/gltf-lod.cjs +21 -6
- package/dist/gltf/gltf/gltf-lod.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-lod.js +20 -4
- package/dist/gltf/gltf/gltf-lod.js.map +1 -1
- package/dist/gltf/index.cjs.map +1 -1
- package/dist/gltf/types/gltf-json-schema.d.ts +37 -37
- package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts +28 -28
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/graph/models/index.cjs.map +3 -3
- package/dist/graph/models/path/path-attribute-model.cjs +2 -2
- package/dist/graph/models/path/path-attribute-model.d.ts +2 -2
- package/dist/graph/models/path/path-attribute-model.js +2 -2
- package/dist/graph/models/path/path-storage-model.cjs +1 -1
- package/dist/graph/models/path/path-storage-model.d.ts +1 -1
- package/dist/graph/models/path/path-storage-model.js +1 -1
- package/dist/graph/models/path/path-trips-storage-model.d.ts +2 -2
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +2 -2
- package/dist/graph/models/polygon/polygon-attribute-model.js +2 -2
- package/dist/graph/models/polygon/polygon-storage-model.cjs +2 -2
- package/dist/graph/models/polygon/polygon-storage-model.js +2 -2
- package/dist/graph/physics/index.cjs +3 -0
- package/dist/graph/physics/index.cjs.map +3 -3
- package/dist/graph/physics/index.d.ts +2 -0
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/index.js +1 -0
- package/dist/graph/physics/index.js.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +203 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts +6 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -0
- package/dist/graph/physics/physics-controller-geometry.js +205 -0
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -0
- package/dist/graph/physics/physics-controller.cjs +277 -0
- package/dist/graph/physics/physics-controller.d.ts +90 -0
- package/dist/graph/physics/physics-controller.d.ts.map +1 -0
- package/dist/graph/physics/physics-controller.js +266 -0
- package/dist/graph/physics/physics-controller.js.map +1 -0
- package/dist/graph/physics/scenegraph-instance.cjs +11 -2
- package/dist/graph/physics/scenegraph-instance.d.ts +3 -1
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +11 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/physics/scenegraph-motion.cjs +3 -3
- package/dist/graph/physics/scenegraph-motion.d.ts +5 -1
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-motion.js +3 -3
- package/dist/graph/physics/scenegraph-motion.js.map +1 -1
- package/dist/graph/physics/scenegraph-publication.cjs +13 -3
- package/dist/graph/physics/scenegraph-publication.d.ts +4 -2
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-publication.js +14 -3
- package/dist/graph/physics/scenegraph-publication.js.map +1 -1
- package/dist/graph/physics/scenegraph-session.cjs +11 -1
- package/dist/graph/physics/scenegraph-session.d.ts +11 -2
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-session.js +13 -1
- package/dist/graph/physics/scenegraph-session.js.map +1 -1
- package/dist/graph/tables/gpu-table-model.cjs +1 -1
- package/dist/graph/tables/gpu-table-model.js +1 -1
- package/dist/graph/tables/gpu-table-transform.cjs +2 -2
- package/dist/graph/tables/gpu-table-transform.d.ts +1 -1
- package/dist/graph/tables/gpu-table-transform.js +2 -2
- package/dist/graph/tables/index.cjs.map +3 -3
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/batch-uniform-buffer.cjs +70 -0
- package/dist/model/batch-uniform-buffer.d.ts +21 -0
- package/dist/model/batch-uniform-buffer.d.ts.map +1 -0
- package/dist/model/batch-uniform-buffer.js +48 -0
- package/dist/model/batch-uniform-buffer.js.map +1 -0
- package/dist/model/gpu-vector-bindings.cjs +57 -16
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
- package/dist/model/gpu-vector-bindings.js +65 -15
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +4 -2
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-draw-batches.js +5 -2
- package/dist/model/gpu-vector-draw-batches.js.map +1 -1
- package/dist/model/gpu-vector-model-batches.d.ts +5 -0
- package/dist/model/gpu-vector-model-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-model-batches.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +144 -81
- package/dist/model/gpu-vector-model.d.ts +9 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +173 -100
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.cjs +8 -0
- package/dist/model/model.d.ts +3 -0
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +8 -0
- package/dist/model/model.js.map +1 -1
- package/dist/scenegraph/geometry-node.cjs +47 -0
- package/dist/scenegraph/geometry-node.d.ts +13 -0
- package/dist/scenegraph/geometry-node.d.ts.map +1 -0
- package/dist/scenegraph/geometry-node.js +26 -0
- package/dist/scenegraph/geometry-node.js.map +1 -0
- package/dist/scenegraph/group-node.cjs +42 -0
- package/dist/scenegraph/group-node.d.ts +8 -0
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +47 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/transform-source.cjs +15 -0
- package/dist/scenegraph/transform-source.d.ts +24 -0
- package/dist/scenegraph/transform-source.d.ts.map +1 -0
- package/dist/scenegraph/transform-source.js +5 -0
- package/dist/scenegraph/transform-source.js.map +1 -0
- package/dist/splats/gpu-splat-graph-renderer.d.ts +1 -1
- package/dist/splats/gpu-splat-graph-renderer.d.ts.map +1 -1
- package/dist/splats/index.cjs.map +1 -1
- package/dist/splats/splat-data.cjs +1 -1
- package/dist/splats/splat-data.d.ts +1 -1
- package/dist/splats/splat-data.js +1 -1
- package/dist/splats/splat-renderer.cjs +7 -2
- package/dist/splats/splat-renderer.d.ts +3 -0
- package/dist/splats/splat-renderer.d.ts.map +1 -1
- package/dist/splats/splat-renderer.js +7 -2
- package/dist/splats/splat-renderer.js.map +1 -1
- package/dist/splats/splat-sort.d.ts +1 -1
- package/dist/splats/splat-sort.d.ts.map +1 -1
- package/dist/text/experimental.cjs +151 -3
- package/dist/text/experimental.d.ts +1 -1
- package/dist/text/experimental.d.ts.map +1 -1
- package/dist/text/experimental.js +1 -1
- package/dist/text/experimental.js.map +1 -1
- package/dist/text/index.cjs +41 -3
- package/dist/text/index.d.ts +1 -1
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +1 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/text-2d/experimental.cjs +128 -18
- package/dist/text/text-2d/experimental.d.ts +8 -8
- package/dist/text/text-2d/experimental.d.ts.map +1 -1
- package/dist/text/text-2d/experimental.js +7 -8
- package/dist/text/text-2d/experimental.js.map +1 -1
- package/dist/text/text-2d/model-utils/text-model-props.d.ts +1 -1
- package/dist/text/text-2d/models/text-attribute-model.cjs +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js +1 -1
- package/dist/utils/deep-equal.cjs +3 -1
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.d.ts.map +1 -1
- package/dist/utils/deep-equal.js +3 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/get-platform-info.cjs +9 -3
- package/dist/utils/get-platform-info.d.ts +1 -1
- package/dist/utils/get-platform-info.d.ts.map +1 -1
- package/dist/utils/get-platform-info.js +1 -1
- package/dist/utils/get-platform-info.js.map +1 -1
- package/package.json +8 -9
- package/src/arrow/arrow-geometry.ts +1 -1
- package/src/arrow/arrow-picking.ts +2 -2
- package/src/arrow/renderers/path/conversion/arrow-path-gpu-vectors.ts +9 -9
- package/src/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.ts +4 -4
- package/src/arrow/renderers/path/source/arrow-path-source-mapping.ts +1 -1
- package/src/arrow/renderers/path/transforms/close-arrow-paths.ts +5 -5
- package/src/arrow/renderers/path/transforms/gpu-path-float64-deltas.ts +3 -3
- package/src/arrow/renderers/path/transforms/path-view-origins.ts +2 -2
- package/src/arrow/renderers/polygon/conversion/arrow-polygon-gpu-vectors.ts +1 -1
- package/src/arrow/renderers/polygon/renderers/arrow-polygon-renderer.ts +4 -4
- package/src/arrow/renderers/polygon/source/arrow-polygon-source-mapping.ts +1 -1
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-arrow.ts +1 -1
- package/src/arrow/renderers/text/conversion/convert-arrow-text-to-attribute.ts +2 -2
- package/src/arrow/renderers/text/conversion/convert-arrow-text-to-storage.ts +1 -1
- package/src/arrow/renderers/text/conversion/convert-arrow-text-vectors.ts +6 -6
- package/src/arrow/renderers/text/conversion/make-gpu-text-data-from-arrow.ts +1 -1
- package/src/arrow/renderers/text/renderers/arrow-text-picking.ts +1 -1
- package/src/arrow/renderers/text/renderers/arrow-text-renderer.ts +5 -5
- package/src/arrow/renderers/text/source/arrow-text-source-mapping.ts +1 -1
- package/src/compute/computation.ts +8 -3
- package/src/compute/texture-transform.ts +2 -2
- package/src/experimental/materials/emissive-material.ts +1 -1
- package/src/experimental/materials/glass-material.ts +1 -1
- package/src/experimental/materials/glass-transmission.ts +1 -1
- package/src/experimental/materials/optical-caustics.ts +1 -1
- package/src/experimental/materials/optical-point-lights.ts +1 -1
- package/src/experimental/materials/reflective-material.ts +1 -1
- package/src/experimental/textures/rgba-decoder.ts +1 -1
- package/src/geometry/gpu-geometry.ts +1 -4
- package/src/gltf/gltf/gltf-extension-support.ts +27 -5
- package/src/gltf/gltf/gltf-lod.ts +22 -4
- package/src/gltf/physics/README.md +1 -1
- package/src/gltf/types/gltf-json-schema.ts +37 -37
- package/src/gltf/types/gltf-postprocessed-schema.ts +28 -28
- package/src/graph/models/path/path-attribute-model.ts +3 -3
- package/src/graph/models/path/path-storage-model.ts +2 -2
- package/src/graph/models/path/path-trips-storage-model.ts +2 -2
- package/src/graph/models/polygon/polygon-attribute-model.ts +2 -2
- package/src/graph/models/polygon/polygon-storage-model.ts +2 -2
- package/src/graph/physics/index.ts +10 -0
- package/src/graph/physics/physics-controller-geometry.ts +264 -0
- package/src/graph/physics/physics-controller.ts +348 -0
- package/src/graph/physics/scenegraph-instance.ts +12 -1
- package/src/graph/physics/scenegraph-motion.ts +14 -3
- package/src/graph/physics/scenegraph-publication.ts +24 -4
- package/src/graph/physics/scenegraph-session.ts +35 -3
- package/src/graph/tables/gpu-table-model.ts +1 -1
- package/src/graph/tables/gpu-table-transform.ts +3 -3
- package/src/index.ts +6 -0
- package/src/model/batch-uniform-buffer.ts +51 -0
- package/src/model/gpu-vector-bindings.ts +77 -19
- package/src/model/gpu-vector-draw-batches.ts +5 -2
- package/src/model/gpu-vector-model-batches.ts +5 -0
- package/src/model/gpu-vector-model.ts +194 -122
- package/src/model/model.ts +10 -0
- package/src/scenegraph/geometry-node.ts +31 -0
- package/src/scenegraph/group-node.ts +54 -1
- package/src/scenegraph/transform-source.ts +30 -0
- package/src/splats/gpu-splat-graph-renderer.ts +1 -1
- package/src/splats/splat-data.ts +1 -1
- package/src/splats/splat-renderer.ts +10 -2
- package/src/splats/splat-sort.ts +1 -1
- package/src/text/README.md +1 -1
- package/src/text/experimental.ts +122 -1
- package/src/text/index.ts +40 -1
- package/src/text/text-2d/experimental.ts +104 -8
- package/src/text/text-2d/model-utils/text-model-props.ts +1 -1
- package/src/text/text-2d/models/text-attribute-model.ts +1 -1
- package/src/utils/deep-equal.ts +4 -2
- package/src/utils/get-platform-info.ts +1 -1
|
@@ -42,6 +42,7 @@ import {mergeShaderPluginModules, resolveShaderPlugins, ShaderAssembler} from '@
|
|
|
42
42
|
import {GLSLShaderAssembler} from '@luma.gl/shaders/glsl';
|
|
43
43
|
import {WGSLShaderAssembler} from '@luma.gl/shaders/wgsl';
|
|
44
44
|
|
|
45
|
+
import {BatchUniformBuffer} from './batch-uniform-buffer';
|
|
45
46
|
import {getDebugTableForShaderLayout} from '../debug/debug-shader-layout';
|
|
46
47
|
import {debugFramebuffer} from '../debug/debug-framebuffer';
|
|
47
48
|
import {deepEqual} from '../utils/deep-equal';
|
|
@@ -282,7 +283,7 @@ export class GPUVectorModel {
|
|
|
282
283
|
/** Factory used to create shaders */
|
|
283
284
|
readonly shaderFactory: ShaderFactory;
|
|
284
285
|
/** User-supplied per-model data */
|
|
285
|
-
userData: {[key: string]:
|
|
286
|
+
userData: {[key: string]: unknown} = {};
|
|
286
287
|
|
|
287
288
|
// Fixed properties (change can trigger pipeline rebuild)
|
|
288
289
|
|
|
@@ -339,6 +340,7 @@ export class GPUVectorModel {
|
|
|
339
340
|
|
|
340
341
|
_attributeInfos: Record<string, AttributeInfo> = {};
|
|
341
342
|
protected props: Required<GPUVectorModelProps>;
|
|
343
|
+
private batchUniformBuffer?: BatchUniformBuffer;
|
|
342
344
|
private geometryVectorBindings!: GPUVectorBindings;
|
|
343
345
|
private attributeVectorBindings!: GPUVectorBindings;
|
|
344
346
|
private explicitBufferLayout: BufferLayout[] = [];
|
|
@@ -422,119 +424,132 @@ export class GPUVectorModel {
|
|
|
422
424
|
this.explicitBufferLayout = this.bufferLayout;
|
|
423
425
|
this.geometryVectorBindings = new GPUVectorBindings(device, `${this.id}-geometry`);
|
|
424
426
|
this.attributeVectorBindings = new GPUVectorBindings(device, `${this.id}-attributes`);
|
|
425
|
-
|
|
427
|
+
try {
|
|
428
|
+
this._initializeProps(props);
|
|
426
429
|
|
|
427
|
-
|
|
428
|
-
|
|
430
|
+
const platformInfo = getPlatformInfo(device);
|
|
431
|
+
const resolvedPlugins = resolveShaderPlugins(this.props.plugins, platformInfo.shaderLanguage);
|
|
429
432
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
433
|
+
// Setup shader module inputs
|
|
434
|
+
const shaderInputModules = mergeShaderPluginModules(
|
|
435
|
+
this.props.modules,
|
|
436
|
+
resolvedPlugins.modules
|
|
437
|
+
);
|
|
438
|
+
const moduleMap = Object.fromEntries(shaderInputModules.map(module => [module.name, module]));
|
|
436
439
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
440
|
+
const shaderInputs =
|
|
441
|
+
props.shaderInputs ||
|
|
442
|
+
new ShaderInputs(moduleMap, {disableWarnings: this.props.disableWarnings});
|
|
443
|
+
if (props.shaderInputs && resolvedPlugins.modules.length > 0) {
|
|
444
|
+
shaderInputs.addModules(resolvedPlugins.modules);
|
|
445
|
+
}
|
|
446
|
+
// @ts-ignore
|
|
447
|
+
this.setShaderInputs(shaderInputs);
|
|
445
448
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
+
// Setup shader assembler
|
|
450
|
+
const modules = mergeShaderModules(this.props.modules, shaderInputs.getModules());
|
|
451
|
+
const defines = {...resolvedPlugins.defines, ...this.props.defines};
|
|
449
452
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
+
if (this.device.type === 'webgl') {
|
|
454
|
+
this.props._uniformBlockLayouts = getShaderModuleUniformBlockLayouts(modules);
|
|
455
|
+
}
|
|
453
456
|
|
|
454
|
-
this.props.shaderLayout =
|
|
455
|
-
mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
456
|
-
|
|
457
|
-
const isWebGPU = this.device.type === 'webgpu';
|
|
458
|
-
|
|
459
|
-
// WebGPU
|
|
460
|
-
// TODO - hack to support unified WGSL shader
|
|
461
|
-
// TODO - this is wrong, compile a single shader
|
|
462
|
-
if (isWebGPU && this.props.source) {
|
|
463
|
-
// WGSL
|
|
464
|
-
const shaderAssembler = this.props.shaderAssembler;
|
|
465
|
-
// WGSL sources require an assembler with WGSL-specific hooks and binding state.
|
|
466
|
-
assert(isShaderAssemblerForLanguage(shaderAssembler, 'wgsl'));
|
|
467
|
-
const {
|
|
468
|
-
source,
|
|
469
|
-
getUniforms,
|
|
470
|
-
bindingTable,
|
|
471
|
-
entryPoints = {},
|
|
472
|
-
shaderLayout: assembledShaderLayout
|
|
473
|
-
} = shaderAssembler.assembleWGSLShader({
|
|
474
|
-
platformInfo,
|
|
475
|
-
...this.props,
|
|
476
|
-
modules,
|
|
477
|
-
defines,
|
|
478
|
-
pluginInjections: resolvedPlugins.injections,
|
|
479
|
-
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
480
|
-
pluginVaryings: resolvedPlugins.varyings
|
|
481
|
-
});
|
|
482
|
-
this.source = source;
|
|
483
|
-
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
484
|
-
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
485
|
-
// @ts-expect-error
|
|
486
|
-
this._getModuleUniforms = getUniforms;
|
|
487
|
-
this._bindingTable = bindingTable;
|
|
488
|
-
// Infer the layout after modules have been added so their bindings are included.
|
|
489
|
-
const scannedOrReflectedShaderLayout =
|
|
490
|
-
assembledShaderLayout ??
|
|
491
|
-
(device as Device & {getShaderLayout?: (source: string) => any}).getShaderLayout?.(
|
|
492
|
-
this.source
|
|
493
|
-
);
|
|
494
|
-
const inferredShaderLayout = normalizeShaderPluginAttributeNames(
|
|
495
|
-
scannedOrReflectedShaderLayout,
|
|
496
|
-
resolvedPlugins.vertexInputs
|
|
497
|
-
);
|
|
498
|
-
const shaderLayout = mergeInferredShaderLayout(
|
|
499
|
-
this.props.shaderLayout,
|
|
500
|
-
inferredShaderLayout,
|
|
501
|
-
Object.keys(resolvedPlugins.vertexInputs)
|
|
502
|
-
);
|
|
503
457
|
this.props.shaderLayout =
|
|
504
|
-
mergeShaderModuleBindingsIntoLayout(shaderLayout
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
//
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
458
|
+
mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
|
|
459
|
+
|
|
460
|
+
const isWebGPU = this.device.type === 'webgpu';
|
|
461
|
+
|
|
462
|
+
// WebGPU
|
|
463
|
+
// TODO - hack to support unified WGSL shader
|
|
464
|
+
// TODO - this is wrong, compile a single shader
|
|
465
|
+
if (isWebGPU && this.props.source) {
|
|
466
|
+
// WGSL
|
|
467
|
+
const shaderAssembler = this.props.shaderAssembler;
|
|
468
|
+
// WGSL sources require an assembler with WGSL-specific hooks and binding state.
|
|
469
|
+
assert(isShaderAssemblerForLanguage(shaderAssembler, 'wgsl'));
|
|
470
|
+
const {
|
|
471
|
+
source,
|
|
472
|
+
getUniforms,
|
|
473
|
+
bindingTable,
|
|
474
|
+
entryPoints = {},
|
|
475
|
+
shaderLayout: assembledShaderLayout
|
|
476
|
+
} = shaderAssembler.assembleWGSLShader({
|
|
477
|
+
platformInfo,
|
|
478
|
+
...this.props,
|
|
479
|
+
modules,
|
|
480
|
+
defines,
|
|
481
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
482
|
+
pluginInjections: resolvedPlugins.injections,
|
|
483
|
+
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
484
|
+
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
485
|
+
});
|
|
486
|
+
this.source = source;
|
|
487
|
+
this.props.vertexEntryPoint = entryPoints.vertex || this.props.vertexEntryPoint;
|
|
488
|
+
this.props.fragmentEntryPoint = entryPoints.fragment || this.props.fragmentEntryPoint;
|
|
489
|
+
// @ts-expect-error
|
|
490
|
+
this._getModuleUniforms = getUniforms;
|
|
491
|
+
this._bindingTable = bindingTable;
|
|
492
|
+
// Infer the layout after modules have been added so their bindings are included.
|
|
493
|
+
const scannedOrReflectedShaderLayout =
|
|
494
|
+
assembledShaderLayout ??
|
|
495
|
+
(device as Device & {getShaderLayout?: (source: string) => any}).getShaderLayout?.(
|
|
496
|
+
this.source
|
|
497
|
+
);
|
|
498
|
+
const inferredShaderLayout = normalizeShaderPluginAttributeNames(
|
|
499
|
+
scannedOrReflectedShaderLayout,
|
|
500
|
+
resolvedPlugins.vertexInputs
|
|
501
|
+
);
|
|
502
|
+
const shaderLayout = mergeInferredShaderLayout(
|
|
503
|
+
this.props.shaderLayout,
|
|
504
|
+
inferredShaderLayout,
|
|
505
|
+
Object.keys(resolvedPlugins.vertexInputs)
|
|
506
|
+
);
|
|
507
|
+
this.props.shaderLayout =
|
|
508
|
+
mergeShaderModuleBindingsIntoLayout(shaderLayout || null, modules) || null;
|
|
509
|
+
} else {
|
|
510
|
+
// GLSL
|
|
511
|
+
const shaderAssembler = this.props.shaderAssembler;
|
|
512
|
+
// GLSL shader pairs require an assembler with GLSL-specific hooks.
|
|
513
|
+
assert(isShaderAssemblerForLanguage(shaderAssembler, 'glsl'));
|
|
514
|
+
const {vs, fs, getUniforms} = shaderAssembler.assembleGLSLShaderPair({
|
|
515
|
+
platformInfo,
|
|
516
|
+
...this.props,
|
|
517
|
+
modules,
|
|
518
|
+
defines,
|
|
519
|
+
pluginHooks: resolvedPlugins.hooks,
|
|
520
|
+
pluginInjections: resolvedPlugins.injections,
|
|
521
|
+
pluginVertexInputs: resolvedPlugins.vertexInputs,
|
|
522
|
+
pluginInterStageVariables: resolvedPlugins.interStageVariables
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
this.vs = vs;
|
|
526
|
+
this.fs = fs;
|
|
527
|
+
// @ts-expect-error
|
|
528
|
+
this._getModuleUniforms = getUniforms;
|
|
529
|
+
this._bindingTable = [];
|
|
530
|
+
}
|
|
526
531
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
532
|
+
this.pipelineFactory =
|
|
533
|
+
props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
534
|
+
this.shaderFactory =
|
|
535
|
+
props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
530
536
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
537
|
+
const asyncCompilation = PipelineFactory.getAsyncCompilation(this.device);
|
|
538
|
+
if (asyncCompilation) {
|
|
539
|
+
this._pipelineInitialization = this._initializePipelineAsync(props);
|
|
540
|
+
asyncCompilation.push(this._pipelineInitialization);
|
|
541
|
+
} else {
|
|
542
|
+
this.pipeline = this._updatePipeline();
|
|
543
|
+
this._initializePipelineResources(props);
|
|
544
|
+
}
|
|
545
|
+
} catch (error) {
|
|
546
|
+
// Failed construction never returns a model for the caller to destroy.
|
|
547
|
+
// Subclass fields may not exist yet, so bypass virtual teardown.
|
|
548
|
+
try {
|
|
549
|
+
GPUVectorModel.prototype.destroy.call(this);
|
|
550
|
+
} finally {
|
|
551
|
+
throw error;
|
|
552
|
+
}
|
|
538
553
|
}
|
|
539
554
|
}
|
|
540
555
|
|
|
@@ -595,9 +610,11 @@ export class GPUVectorModel {
|
|
|
595
610
|
this.shaderFactory.release(this.pipeline.fs);
|
|
596
611
|
}
|
|
597
612
|
}
|
|
613
|
+
this.vertexArray?.destroy();
|
|
598
614
|
this.geometryVectorBindings.destroy();
|
|
599
615
|
this.attributeVectorBindings.destroy();
|
|
600
|
-
this._uniformStore
|
|
616
|
+
this._uniformStore?.destroy();
|
|
617
|
+
this.batchUniformBuffer?.destroy();
|
|
601
618
|
this._destroyed = true;
|
|
602
619
|
}
|
|
603
620
|
}
|
|
@@ -995,7 +1012,13 @@ export class GPUVectorModel {
|
|
|
995
1012
|
}
|
|
996
1013
|
}
|
|
997
1014
|
|
|
998
|
-
/**
|
|
1015
|
+
/**
|
|
1016
|
+
* Draws each aligned physical chunk without taking ownership of input vectors.
|
|
1017
|
+
* Each batch uses a separate aligned slot for managed shader-input uniforms set by
|
|
1018
|
+
* `onBatch`. Slots are reused on each call: submit previous draws before changing their
|
|
1019
|
+
* values or growing the allocation. Explicit buffers remain caller-managed. Vector
|
|
1020
|
+
* lengths and physical chunk boundaries must match.
|
|
1021
|
+
*/
|
|
999
1022
|
drawBatches<Inputs extends GPUVectorModelInputs = GPUVectorModelInputs>(
|
|
1000
1023
|
renderPass: RenderPass,
|
|
1001
1024
|
{vectors, onBatch}: GPUVectorModelDrawBatchesOptions<Inputs>
|
|
@@ -1014,6 +1037,20 @@ export class GPUVectorModel {
|
|
|
1014
1037
|
const previousIsInstanced = this.isInstanced;
|
|
1015
1038
|
const previousVertexCountSet = this._vertexCountSet;
|
|
1016
1039
|
const drawingVectorBatches = this.drawingVectorBatches;
|
|
1040
|
+
const batchUniformStore =
|
|
1041
|
+
this.device.type === 'webgpu' && batches.length
|
|
1042
|
+
? new UniformStore(this.device, this.shaderInputs.modules)
|
|
1043
|
+
: undefined;
|
|
1044
|
+
if (batchUniformStore && this._uniformStore.uniformBuffers.size) {
|
|
1045
|
+
this.batchUniformBuffer ??= new BatchUniformBuffer(this.device);
|
|
1046
|
+
let batchByteLength = 0;
|
|
1047
|
+
for (const moduleName of this._uniformStore.uniformBuffers.keys()) {
|
|
1048
|
+
batchByteLength += this.batchUniformBuffer.getAlignedByteLength(
|
|
1049
|
+
batchUniformStore.getUniformBufferData(moduleName).byteLength
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
this.batchUniformBuffer.prepare(batchByteLength * batches.length);
|
|
1053
|
+
}
|
|
1017
1054
|
this.drawingVectorBatches = true;
|
|
1018
1055
|
let drawSuccess = true;
|
|
1019
1056
|
try {
|
|
@@ -1021,9 +1058,29 @@ export class GPUVectorModel {
|
|
|
1021
1058
|
this.setGPUData(batch.data);
|
|
1022
1059
|
this.setBatchDrawCount(batch.rowCount);
|
|
1023
1060
|
onBatch?.(batch);
|
|
1024
|
-
|
|
1061
|
+
const managedBindings: Record<string, ModelBinding> = {};
|
|
1062
|
+
try {
|
|
1063
|
+
if (batchUniformStore) {
|
|
1064
|
+
batchUniformStore.setUniforms(this.shaderInputs.getUniformValues());
|
|
1065
|
+
for (const [moduleName, buffer] of this._uniformStore.uniformBuffers) {
|
|
1066
|
+
const bindingName = `${moduleName}Uniforms`;
|
|
1067
|
+
// Explicit bindings are caller-owned and must not be replaced.
|
|
1068
|
+
if (this.bindings[bindingName] !== buffer) continue;
|
|
1069
|
+
managedBindings[bindingName] = buffer;
|
|
1070
|
+
this.setBindings({
|
|
1071
|
+
[bindingName]: this.batchUniformBuffer!.write(
|
|
1072
|
+
batchUniformStore.getUniformBufferData(moduleName)
|
|
1073
|
+
)
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
drawSuccess = GPUVectorModel.prototype.draw.call(this, renderPass) && drawSuccess;
|
|
1078
|
+
} finally {
|
|
1079
|
+
this.setBindings(managedBindings);
|
|
1080
|
+
}
|
|
1025
1081
|
}
|
|
1026
1082
|
} finally {
|
|
1083
|
+
batchUniformStore?.destroy();
|
|
1027
1084
|
this.setAttributes(previousAttributes, {byteOffsets: previousAttributeByteOffsets});
|
|
1028
1085
|
for (const name of Object.keys(this.bindings)) {
|
|
1029
1086
|
if (!(name in previousBindings)) delete this.bindings[name];
|
|
@@ -1124,10 +1181,12 @@ export class GPUVectorModel {
|
|
|
1124
1181
|
|
|
1125
1182
|
// vertex array needs to be updated if we update buffer layout,
|
|
1126
1183
|
// but not if we update parameters
|
|
1184
|
+
const previousVertexArray = this.vertexArray;
|
|
1127
1185
|
this.vertexArray = this.device.createVertexArray({
|
|
1128
1186
|
shaderLayout: this.pipeline.shaderLayout,
|
|
1129
1187
|
bufferLayout: this.pipeline.bufferLayout
|
|
1130
1188
|
});
|
|
1189
|
+
previousVertexArray.destroy();
|
|
1131
1190
|
this._dynamicAttributeBufferSources = {};
|
|
1132
1191
|
this.applyVectorAttributes();
|
|
1133
1192
|
if (this.indexBuffer) this.vertexArray.setIndexBuffer(this.indexBuffer);
|
|
@@ -1467,7 +1526,13 @@ export class GPUVectorModel {
|
|
|
1467
1526
|
_updatePipeline(): RenderPipeline {
|
|
1468
1527
|
const update = this._preparePipelineUpdate();
|
|
1469
1528
|
if (update) {
|
|
1470
|
-
|
|
1529
|
+
try {
|
|
1530
|
+
this.pipeline = this.pipelineFactory.createRenderPipeline(update.props);
|
|
1531
|
+
} catch (error) {
|
|
1532
|
+
this._releasePipelineShaders(update.vertexShader, update.fragmentShader);
|
|
1533
|
+
this._pipelineNeedsUpdate = 'pipeline creation failed';
|
|
1534
|
+
throw error;
|
|
1535
|
+
}
|
|
1471
1536
|
this._finishPipelineUpdate(update);
|
|
1472
1537
|
}
|
|
1473
1538
|
return this.pipeline;
|
|
@@ -1507,22 +1572,29 @@ export class GPUVectorModel {
|
|
|
1507
1572
|
}
|
|
1508
1573
|
this._pipelineNeedsUpdate = false;
|
|
1509
1574
|
|
|
1510
|
-
|
|
1511
|
-
id: `${this.id}-vertex`,
|
|
1512
|
-
stage: 'vertex',
|
|
1513
|
-
source: this.source || this.vs,
|
|
1514
|
-
debugShaders: this.props.debugShaders
|
|
1515
|
-
});
|
|
1575
|
+
let vertexShader: Shader | null = null;
|
|
1516
1576
|
let fragmentShader: Shader | null = null;
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
stage: 'fragment',
|
|
1523
|
-
source: this.fs,
|
|
1577
|
+
try {
|
|
1578
|
+
vertexShader = this.shaderFactory.createShader({
|
|
1579
|
+
id: `${this.id}-vertex`,
|
|
1580
|
+
stage: 'vertex',
|
|
1581
|
+
source: this.source || this.vs,
|
|
1524
1582
|
debugShaders: this.props.debugShaders
|
|
1525
1583
|
});
|
|
1584
|
+
if (this.source) {
|
|
1585
|
+
fragmentShader = vertexShader;
|
|
1586
|
+
} else if (this.fs) {
|
|
1587
|
+
fragmentShader = this.shaderFactory.createShader({
|
|
1588
|
+
id: `${this.id}-fragment`,
|
|
1589
|
+
stage: 'fragment',
|
|
1590
|
+
source: this.fs,
|
|
1591
|
+
debugShaders: this.props.debugShaders
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
} catch (error) {
|
|
1595
|
+
this._releasePipelineShaders(vertexShader, fragmentShader);
|
|
1596
|
+
this._pipelineNeedsUpdate = 'shader creation failed';
|
|
1597
|
+
throw error;
|
|
1526
1598
|
}
|
|
1527
1599
|
return {
|
|
1528
1600
|
props: {
|
package/src/model/model.ts
CHANGED
|
@@ -34,6 +34,12 @@ export class Model extends GPUVectorModel {
|
|
|
34
34
|
declare material: Material | null;
|
|
35
35
|
declare _gpuGeometry: GPUGeometry | null;
|
|
36
36
|
private declare indexCountOverride: number | undefined;
|
|
37
|
+
private declare sourceGeometryValue: ModelProps['geometry'];
|
|
38
|
+
|
|
39
|
+
/** Borrowed source geometry, retained for scene adapters such as physics cooking. */
|
|
40
|
+
get sourceGeometry(): ModelProps['geometry'] {
|
|
41
|
+
return this.sourceGeometryValue;
|
|
42
|
+
}
|
|
37
43
|
|
|
38
44
|
constructor(device: Device, props: ModelProps) {
|
|
39
45
|
const sourceGeometry =
|
|
@@ -56,12 +62,14 @@ export class Model extends GPUVectorModel {
|
|
|
56
62
|
throw error;
|
|
57
63
|
}
|
|
58
64
|
this._gpuGeometry = gpuGeometry;
|
|
65
|
+
this.sourceGeometryValue = sourceGeometry;
|
|
59
66
|
if (gpuGeometry) this.setIndexCount(this.props.indexCount);
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
protected override _initializeProps(props: GPUVectorModelProps & {material?: Material}): void {
|
|
63
70
|
this.material = props.material || null;
|
|
64
71
|
this._gpuGeometry = null;
|
|
72
|
+
this.sourceGeometryValue = null;
|
|
65
73
|
super._initializeProps(props);
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -75,6 +83,7 @@ export class Model extends GPUVectorModel {
|
|
|
75
83
|
super.destroy();
|
|
76
84
|
this._gpuGeometry?.destroy();
|
|
77
85
|
this._gpuGeometry = null;
|
|
86
|
+
this.sourceGeometryValue = null;
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
/** Adapts CPU and legacy buffer geometry into the GPU vector geometry API. */
|
|
@@ -89,6 +98,7 @@ export class Model extends GPUVectorModel {
|
|
|
89
98
|
: geometry;
|
|
90
99
|
super.setGeometry(vectorGeometry instanceof GPUVectorGeometry ? vectorGeometry : null);
|
|
91
100
|
if (!(geometry instanceof GPUVectorGeometry)) super.setIndexCount(this.indexCountOverride);
|
|
101
|
+
this.sourceGeometryValue = geometry;
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
override setIndexCount(indexCount: number | undefined): void {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Geometry} from '../geometry/geometry';
|
|
6
|
+
import {ScenegraphNode, type ScenegraphNodeProps} from './scenegraph-node';
|
|
7
|
+
import type {ScenegraphBounds} from './scenegraph-bounds';
|
|
8
|
+
|
|
9
|
+
export type GeometryNodeProps = ScenegraphNodeProps & {geometry: Geometry};
|
|
10
|
+
|
|
11
|
+
/** Retained CPU geometry shared by render adapters and collider cooking. */
|
|
12
|
+
export class GeometryNode extends ScenegraphNode {
|
|
13
|
+
readonly geometry: Geometry;
|
|
14
|
+
constructor(props: GeometryNodeProps) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.geometry = props.geometry;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override getBounds(): ScenegraphBounds | null {
|
|
20
|
+
const positions = this.geometry.attributes['POSITION'];
|
|
21
|
+
if (!positions || positions.size !== 3 || !positions.value.length) return null;
|
|
22
|
+
const minimum: [number, number, number] = [Infinity, Infinity, Infinity];
|
|
23
|
+
const maximum: [number, number, number] = [-Infinity, -Infinity, -Infinity];
|
|
24
|
+
for (let index = 0; index < positions.value.length; index++) {
|
|
25
|
+
const axis = index % 3;
|
|
26
|
+
minimum[axis] = Math.min(minimum[axis], positions.value[index]);
|
|
27
|
+
maximum[axis] = Math.max(maximum[axis], positions.value[index]);
|
|
28
|
+
}
|
|
29
|
+
return [minimum, maximum];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {Matrix4, Vector3} from '@math.gl/core';
|
|
6
6
|
import type {NumericArray} from '@math.gl/core';
|
|
7
|
-
import {log} from '@luma.gl/core';
|
|
7
|
+
import {assert, log} from '@luma.gl/core';
|
|
8
8
|
import {ScenegraphNode, ScenegraphNodeProps} from './scenegraph-node';
|
|
9
9
|
import {
|
|
10
10
|
areScenegraphBoundsDefined,
|
|
@@ -12,9 +12,11 @@ import {
|
|
|
12
12
|
makeEmptyScenegraphBounds
|
|
13
13
|
} from './scenegraph-bounds';
|
|
14
14
|
import type {ScenegraphBounds} from './scenegraph-bounds';
|
|
15
|
+
import type {ScenegraphTransformSource} from './transform-source';
|
|
15
16
|
|
|
16
17
|
export type GroupNodeProps = ScenegraphNodeProps & {
|
|
17
18
|
children?: ScenegraphNode[];
|
|
19
|
+
transformSource?: ScenegraphTransformSource;
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
/** Camera-relative ordering options for a flattened scenegraph traversal. */
|
|
@@ -33,6 +35,8 @@ export type DepthSortedTraversalContext = {
|
|
|
33
35
|
|
|
34
36
|
export class GroupNode extends ScenegraphNode {
|
|
35
37
|
children: ScenegraphNode[];
|
|
38
|
+
/** Optional evaluated GPU poses; authored matrices remain unchanged. */
|
|
39
|
+
transformSource: ScenegraphTransformSource | null;
|
|
36
40
|
|
|
37
41
|
constructor(children: ScenegraphNode[]);
|
|
38
42
|
constructor(props?: GroupNodeProps);
|
|
@@ -46,6 +50,7 @@ export class GroupNode extends ScenegraphNode {
|
|
|
46
50
|
);
|
|
47
51
|
super(props);
|
|
48
52
|
this.children = children;
|
|
53
|
+
this.transformSource = props.transformSource ?? null;
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
override getBounds(): ScenegraphBounds | null {
|
|
@@ -94,6 +99,54 @@ export class GroupNode extends ScenegraphNode {
|
|
|
94
99
|
return this;
|
|
95
100
|
}
|
|
96
101
|
|
|
102
|
+
/** Resolve one exact ID or path. Missing nodes return undefined; ambiguous paths throw. */
|
|
103
|
+
findNode(path: string): ScenegraphNode | undefined {
|
|
104
|
+
const matches = this.findNodes(path);
|
|
105
|
+
if (matches.length > 1) {
|
|
106
|
+
throw new Error(`Ambiguous scenegraph path: ${path} (${matches.length} matches)`);
|
|
107
|
+
}
|
|
108
|
+
return matches[0];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Find structural matches in preorder, including hidden nodes and the search root. */
|
|
112
|
+
findNodes(path: string): ScenegraphNode[] {
|
|
113
|
+
const anchored = path.startsWith('/');
|
|
114
|
+
const segments =
|
|
115
|
+
path === '/'
|
|
116
|
+
? []
|
|
117
|
+
: (anchored ? path.slice(1) : path).split('/').map(segment => {
|
|
118
|
+
if (!segment || /~(?![01])/.test(segment)) {
|
|
119
|
+
throw new Error(`Invalid scenegraph path: ${path}`);
|
|
120
|
+
}
|
|
121
|
+
return segment.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
122
|
+
});
|
|
123
|
+
const matches: ScenegraphNode[] = [];
|
|
124
|
+
const ancestors: string[] = [];
|
|
125
|
+
const visited = new Set<ScenegraphNode>();
|
|
126
|
+
const pending: {node: ScenegraphNode; depth: number}[] = [{node: this, depth: 0}];
|
|
127
|
+
while (pending.length) {
|
|
128
|
+
const {node, depth} = pending.pop()!;
|
|
129
|
+
// Structural lookup requires a tree: cycles and shared node objects are invalid.
|
|
130
|
+
assert(!visited.has(node));
|
|
131
|
+
visited.add(node);
|
|
132
|
+
ancestors.length = depth;
|
|
133
|
+
ancestors.push(node.id);
|
|
134
|
+
const offset = ancestors.length - segments.length;
|
|
135
|
+
if (
|
|
136
|
+
(anchored ? offset === 1 : offset >= 0) &&
|
|
137
|
+
segments.every((segment, index) => segment === ancestors[offset + index])
|
|
138
|
+
) {
|
|
139
|
+
matches.push(node);
|
|
140
|
+
}
|
|
141
|
+
if (node instanceof GroupNode) {
|
|
142
|
+
for (let index = node.children.length - 1; index >= 0; index--) {
|
|
143
|
+
pending.push({node: node.children[index], depth: depth + 1});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return matches;
|
|
148
|
+
}
|
|
149
|
+
|
|
97
150
|
traverse(
|
|
98
151
|
visitor: (node: ScenegraphNode, context: {worldMatrix: Matrix4}) => void,
|
|
99
152
|
{worldMatrix = new Matrix4()} = {}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Buffer} from '@luma.gl/core';
|
|
6
|
+
import type {NumericArray} from '@math.gl/core';
|
|
7
|
+
import type {ScenegraphNode} from './scenegraph-node';
|
|
8
|
+
|
|
9
|
+
/** One visual node relative to a producer-owned world matrix. */
|
|
10
|
+
export type ScenegraphTransformBinding = {
|
|
11
|
+
matrixIndex: number;
|
|
12
|
+
localMatrix: Readonly<NumericArray>;
|
|
13
|
+
/** Optional producer visibility mask; authored display is evaluated live by traversal. */
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** An accepted GPU publication. Buffers are borrowed, never owned by a renderer. */
|
|
18
|
+
export type ScenegraphTransformFrame = {
|
|
19
|
+
/** Column-major float32 mat4 array, with STORAGE usage. */
|
|
20
|
+
matrices: Buffer;
|
|
21
|
+
matrixCount: number;
|
|
22
|
+
/** Changes when the producer replaces its buffers or index mapping. */
|
|
23
|
+
revision: number;
|
|
24
|
+
bindings: ReadonlyMap<ScenegraphNode, ScenegraphTransformBinding>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Generic GPU transform producer. Returning null selects authored scene transforms. */
|
|
28
|
+
export interface ScenegraphTransformSource {
|
|
29
|
+
getFrame(): ScenegraphTransformFrame | null;
|
|
30
|
+
}
|
|
@@ -39,7 +39,7 @@ import type {SplatSortMode} from './splat-sort';
|
|
|
39
39
|
/** Camera, styling, borrowed data, and canvas clearing for graph-native Gaussian rendering. */
|
|
40
40
|
export type GPUSplatGraphRendererProps = Omit<
|
|
41
41
|
SplatRendererProps,
|
|
42
|
-
'depthCompare' | 'depthWriteEnabled'
|
|
42
|
+
'depthCompare' | 'depthWriteEnabled' | 'depthConvention'
|
|
43
43
|
> & {
|
|
44
44
|
/** Color used when the graph opens its single default-framebuffer render pass. */
|
|
45
45
|
clearColor?: [number, number, number, number];
|
package/src/splats/splat-data.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Buffer, type Device} from '@luma.gl/core';
|
|
6
|
-
import {GPUVector} from '@luma.gl/
|
|
6
|
+
import {GPUVector} from '@luma.gl/graph/gpu-data';
|
|
7
7
|
import {GPUTable, type GPURecordBatchSourceInfo} from '@luma.gl/graph/gpu-tables';
|
|
8
8
|
import {
|
|
9
9
|
getSplatSphericalHarmonicCoefficientCount,
|