@luma.gl/engine 10.0.0-alpha.7 → 10.0.0-alpha.9
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/dist/arrow/index.cjs +5 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -0
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -0
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +162 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts +34 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +159 -0
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -0
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-renderer.js.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +10 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.d.ts.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +10 -3
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
- package/dist/compute/computation.cjs +3 -0
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -0
- package/dist/compute/computation.js.map +1 -1
- package/dist/dist.dev.js +706 -501
- package/dist/dist.min.js +63 -63
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +14 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +7 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.js +17 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -1
- package/dist/geometry/gpu-vector-geometry.cjs +3 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +2 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry.js +2 -0
- package/dist/geometry/gpu-vector-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/index.cjs.map +1 -1
- package/dist/gltf/index.d.ts +1 -1
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.cjs +19 -13
- package/dist/gltf/parsers/parse-gltf.d.ts +2 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +18 -13
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.cjs +1 -0
- package/dist/gltf/parsers/post-process-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/post-process-gltf.js +1 -0
- package/dist/gltf/parsers/post-process-gltf.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts +2 -0
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-types.d.ts +19 -0
- package/dist/gltf/types/gltf-types.d.ts.map +1 -1
- package/dist/graph/models/index.cjs.map +3 -3
- 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/index.cjs.map +3 -3
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +67 -19
- package/dist/model/gpu-vector-bindings.d.ts +1 -1
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -1
- package/dist/model/gpu-vector-bindings.js +77 -18
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +8 -5
- package/dist/model/gpu-vector-draw-batches.d.ts +1 -1
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -1
- package/dist/model/gpu-vector-draw-batches.js +9 -5
- 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 +63 -17
- package/dist/model/gpu-vector-model.d.ts +16 -3
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +72 -16
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.cjs +8 -0
- package/dist/model/model.d.ts +4 -1
- 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 +34 -23
- package/dist/splats/splat-data.d.ts.map +1 -1
- package/dist/splats/splat-data.js +34 -22
- package/dist/splats/splat-data.js.map +1 -1
- package/dist/splats/splat-renderer.cjs +6 -1
- 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 +6 -1
- 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/package.json +8 -8
- package/src/arrow/index.ts +6 -0
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +220 -0
- package/src/arrow/renderers/text/renderers/arrow-text-renderer.ts +1 -0
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +12 -5
- package/src/compute/computation.ts +3 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +19 -1
- package/src/geometry/gpu-vector-geometry.ts +3 -0
- package/src/gltf/gltf/gltf-extension-support.ts +27 -5
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf.ts +21 -14
- package/src/gltf/parsers/post-process-gltf.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +2 -0
- package/src/gltf/types/gltf-types.ts +20 -0
- 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/index.ts +8 -0
- package/src/model/batch-uniform-buffer.ts +51 -0
- package/src/model/gpu-vector-bindings.ts +88 -22
- package/src/model/gpu-vector-draw-batches.ts +17 -12
- package/src/model/gpu-vector-model-batches.ts +5 -0
- package/src/model/gpu-vector-model.ts +101 -18
- package/src/model/model.ts +11 -1
- 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/README.md +46 -0
- package/src/splats/gpu-splat-graph-renderer.ts +1 -1
- package/src/splats/splat-data.ts +53 -45
- package/src/splats/splat-renderer.ts +9 -1
- package/src/splats/splat-sort.ts +1 -1
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Device} from '@luma.gl/core';
|
|
6
|
+
import {GroupNode} from '@luma.gl/engine';
|
|
7
|
+
import {Matrix4} from '@math.gl/core';
|
|
8
|
+
import {getGLTFNodeInstancing} from '../../../../gltf/gltf/gltf-instancing';
|
|
9
|
+
import {makeVector} from 'apache-arrow';
|
|
10
|
+
import type {GLTFPostprocessed} from '@luma.gl/engine/gltf';
|
|
11
|
+
import {
|
|
12
|
+
loadGPUSplatDataFromGLTF,
|
|
13
|
+
type GLTFSplatPrimitive,
|
|
14
|
+
type GPUSplatData,
|
|
15
|
+
type LoadGPUSplatDataFromGLTFOptions
|
|
16
|
+
} from '@luma.gl/engine/splats';
|
|
17
|
+
import {
|
|
18
|
+
makeGPUSplatDataFromArrow,
|
|
19
|
+
type GPUSplatArrowSource,
|
|
20
|
+
type GPUSplatArrowTableLike
|
|
21
|
+
} from './make-gpu-splat-data-from-arrow';
|
|
22
|
+
|
|
23
|
+
/** GPU batches prepared from one glTF mesh primitive. */
|
|
24
|
+
export type GLTFSplatBatchGroup = {
|
|
25
|
+
/** Source mesh index, shared by all node instances of this mesh. */
|
|
26
|
+
meshIndex: number;
|
|
27
|
+
/** Source primitive index within the mesh. */
|
|
28
|
+
primitiveIndex: number;
|
|
29
|
+
/** Ordered, independently owned batches; the caller must destroy them. */
|
|
30
|
+
batches: GPUSplatData[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Prepares loader-decoded Arrow splats and uncompressed glTF splat attributes.
|
|
35
|
+
* The returned identity refers to mesh primitives, not scene-node instances. The caller owns
|
|
36
|
+
* the returned GPU batches and must apply each node's transform when drawing them.
|
|
37
|
+
*/
|
|
38
|
+
export async function makeGPUSplatDataFromGLTFScene(
|
|
39
|
+
device: Device,
|
|
40
|
+
gltf: GLTFPostprocessed,
|
|
41
|
+
options: LoadGPUSplatDataFromGLTFOptions = {}
|
|
42
|
+
): Promise<GLTFSplatBatchGroup[]> {
|
|
43
|
+
const groups: GLTFSplatBatchGroup[] = [];
|
|
44
|
+
let sourceBatchIndex = options.sourceBatchIndex ?? 0;
|
|
45
|
+
let rowIndexBase = options.rowIndexBase ?? 0;
|
|
46
|
+
try {
|
|
47
|
+
for (const [meshIndex, mesh] of gltf.meshes.entries()) {
|
|
48
|
+
for (const [primitiveIndex, primitive] of mesh.primitives.entries()) {
|
|
49
|
+
if (!primitive.extensions?.KHR_gaussian_splatting) continue;
|
|
50
|
+
options.signal?.throwIfAborted();
|
|
51
|
+
const descriptor = gltf.gaussianSplatPrimitives?.find(
|
|
52
|
+
item => item.meshIndex === meshIndex && item.primitiveIndex === primitiveIndex
|
|
53
|
+
);
|
|
54
|
+
let batches: GPUSplatData[];
|
|
55
|
+
let consumedSourceBatches = 1;
|
|
56
|
+
const firstSourceBatchIndex = sourceBatchIndex;
|
|
57
|
+
if (descriptor?.decoded !== undefined) {
|
|
58
|
+
const extension = primitive.extensions.KHR_gaussian_splatting;
|
|
59
|
+
if (
|
|
60
|
+
primitive.mode !== 0 ||
|
|
61
|
+
extension.kernel !== 'ellipse' ||
|
|
62
|
+
extension.colorSpace !== 'lin_rec709_display' ||
|
|
63
|
+
(extension.projection !== undefined && extension.projection !== 'perspective') ||
|
|
64
|
+
(extension.sortingMethod !== undefined && extension.sortingMethod !== 'cameraDistance')
|
|
65
|
+
) {
|
|
66
|
+
throw new Error('Unsupported decoded glTF Gaussian splat primitive');
|
|
67
|
+
}
|
|
68
|
+
if (
|
|
69
|
+
typeof descriptor.decoded !== 'object' ||
|
|
70
|
+
descriptor.decoded === null ||
|
|
71
|
+
!('data' in descriptor.decoded) ||
|
|
72
|
+
!('shape' in descriptor.decoded) ||
|
|
73
|
+
descriptor.decoded.shape !== 'arrow-table'
|
|
74
|
+
) {
|
|
75
|
+
throw new Error('Decoded glTF splats require a Mesh Arrow table');
|
|
76
|
+
}
|
|
77
|
+
// Decoded data is a loader result, not a glTF accessor-bearing primitive.
|
|
78
|
+
const decoded = descriptor.decoded as GPUSplatArrowSource & {
|
|
79
|
+
data: GPUSplatArrowTableLike;
|
|
80
|
+
};
|
|
81
|
+
if (!decoded.data || !Array.isArray(decoded.data.batches)) {
|
|
82
|
+
throw new Error('Decoded glTF splats require a Mesh Arrow table');
|
|
83
|
+
}
|
|
84
|
+
consumedSourceBatches = decoded.data.batches.length;
|
|
85
|
+
const declaredFeature = primitive.extensions?.EXT_mesh_features?.featureIds?.find(
|
|
86
|
+
(feature: {attribute?: number}) => feature.attribute !== undefined
|
|
87
|
+
);
|
|
88
|
+
const featureName =
|
|
89
|
+
options.featureIdAttribute ??
|
|
90
|
+
(declaredFeature ? `_FEATURE_ID_${declaredFeature.attribute}` : undefined);
|
|
91
|
+
let source: GPUSplatArrowSource = decoded;
|
|
92
|
+
if (featureName) {
|
|
93
|
+
const accessor = primitive.attributes[featureName];
|
|
94
|
+
const values = accessor?.value;
|
|
95
|
+
if (
|
|
96
|
+
accessor?.normalized ||
|
|
97
|
+
!(
|
|
98
|
+
values instanceof Uint8Array ||
|
|
99
|
+
values instanceof Uint16Array ||
|
|
100
|
+
values instanceof Uint32Array
|
|
101
|
+
)
|
|
102
|
+
) {
|
|
103
|
+
throw new Error('glTF Gaussian splat feature IDs must be unsigned integers');
|
|
104
|
+
}
|
|
105
|
+
if (values.length !== decoded.data.numRows) {
|
|
106
|
+
throw new Error('glTF Gaussian splat feature-ID count does not match decoded splats');
|
|
107
|
+
}
|
|
108
|
+
let offset = 0;
|
|
109
|
+
const recordBatches = decoded.data.batches.map(recordBatch => {
|
|
110
|
+
const ids = values.subarray(offset, offset + recordBatch.numRows);
|
|
111
|
+
offset += recordBatch.numRows;
|
|
112
|
+
const vector = makeVector(ids);
|
|
113
|
+
return {
|
|
114
|
+
numRows: recordBatch.numRows,
|
|
115
|
+
schema: recordBatch.schema,
|
|
116
|
+
getChild: (name: string) =>
|
|
117
|
+
name === '__gltf_feature_id' ? vector : recordBatch.getChild(name)
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
const table = {
|
|
121
|
+
numRows: decoded.data.numRows,
|
|
122
|
+
schema: decoded.data.schema,
|
|
123
|
+
batches: recordBatches,
|
|
124
|
+
getChild: (name: string) => decoded.data.getChild(name)
|
|
125
|
+
};
|
|
126
|
+
source = {...decoded, data: table};
|
|
127
|
+
}
|
|
128
|
+
batches = makeGPUSplatDataFromArrow(device, source, {
|
|
129
|
+
sourceBatchIndex,
|
|
130
|
+
rowIndexBase,
|
|
131
|
+
maxSphericalHarmonicsDegree: options.maxSphericalHarmonicsDegree,
|
|
132
|
+
...(featureName ? {semanticColumn: '__gltf_feature_id'} : {})
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
const batch = await loadGPUSplatDataFromGLTF(
|
|
136
|
+
device,
|
|
137
|
+
primitive as unknown as GLTFSplatPrimitive,
|
|
138
|
+
{...options, sourceBatchIndex, rowIndexBase}
|
|
139
|
+
);
|
|
140
|
+
batches = [batch];
|
|
141
|
+
}
|
|
142
|
+
groups.push({meshIndex, primitiveIndex, batches});
|
|
143
|
+
options.signal?.throwIfAborted();
|
|
144
|
+
for (const batch of batches) {
|
|
145
|
+
sourceBatchIndex = batch.sourceBatchIndex + 1;
|
|
146
|
+
rowIndexBase = batch.rowIndexBase + batch.rowCount;
|
|
147
|
+
}
|
|
148
|
+
sourceBatchIndex = Math.max(
|
|
149
|
+
sourceBatchIndex,
|
|
150
|
+
firstSourceBatchIndex + consumedSourceBatches
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return groups;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
for (const group of groups) for (const batch of group.batches) batch.destroy();
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** A mesh primitive's splat batches placed by one visible glTF node in one scene. */
|
|
162
|
+
export type GLTFSplatInstance = {
|
|
163
|
+
/** Source scene index. */
|
|
164
|
+
sceneIndex: number;
|
|
165
|
+
/** Source node index. */
|
|
166
|
+
nodeIndex: number;
|
|
167
|
+
/** Index of the authored GPU instance, when the node uses GPU instancing. */
|
|
168
|
+
instanceIndex?: number;
|
|
169
|
+
/** Source mesh and primitive indices and their borrowed batches. */
|
|
170
|
+
group: GLTFSplatBatchGroup;
|
|
171
|
+
/** Current column-major world transform, including the complete ancestor hierarchy. */
|
|
172
|
+
worldMatrix: Float32Array;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** Resolves visible instances without baking node transforms into borrowed splat data. */
|
|
176
|
+
export function getGLTFSplatSceneInstances(
|
|
177
|
+
scenegraphs: import('@luma.gl/engine/gltf').GLTFScenegraphs,
|
|
178
|
+
groups: readonly GLTFSplatBatchGroup[]
|
|
179
|
+
): GLTFSplatInstance[] {
|
|
180
|
+
const instances: GLTFSplatInstance[] = [];
|
|
181
|
+
const nodeIndices = new Map(
|
|
182
|
+
Array.from(scenegraphs.gltfNodeIndexToNodeMap, ([index, node]) => [node, index])
|
|
183
|
+
);
|
|
184
|
+
for (const [sceneIndex, scene] of scenegraphs.scenes.entries()) {
|
|
185
|
+
const visit = (node: GroupNode, parent: Matrix4): void => {
|
|
186
|
+
if (!node.display) return;
|
|
187
|
+
const world = parent.clone().multiplyRight(node.matrix);
|
|
188
|
+
const nodeIndex = nodeIndices.get(node);
|
|
189
|
+
if (nodeIndex !== undefined) {
|
|
190
|
+
const sourceNode = scenegraphs.gltf.nodes[nodeIndex];
|
|
191
|
+
const mesh = sourceNode?.mesh;
|
|
192
|
+
const meshIndex = mesh ? scenegraphs.gltf.meshes.indexOf(mesh) : -1;
|
|
193
|
+
const instancing =
|
|
194
|
+
sourceNode && mesh ? getGLTFNodeInstancing(scenegraphs.gltf, sourceNode) : null;
|
|
195
|
+
for (const group of groups) {
|
|
196
|
+
if (group.meshIndex !== meshIndex) continue;
|
|
197
|
+
if (instancing) {
|
|
198
|
+
for (const [instanceIndex, localMatrix] of instancing.matrices.entries()) {
|
|
199
|
+
const worldMatrix = world.clone().multiplyRight(localMatrix);
|
|
200
|
+
instances.push({
|
|
201
|
+
sceneIndex,
|
|
202
|
+
nodeIndex,
|
|
203
|
+
instanceIndex,
|
|
204
|
+
group,
|
|
205
|
+
worldMatrix: Float32Array.from(worldMatrix)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
instances.push({sceneIndex, nodeIndex, group, worldMatrix: Float32Array.from(world)});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const child of node.children) {
|
|
214
|
+
if (child instanceof GroupNode) visit(child, world);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
visit(scene, new Matrix4());
|
|
218
|
+
}
|
|
219
|
+
return instances;
|
|
220
|
+
}
|
|
@@ -47,11 +47,18 @@ export function configureArrowTextShaderAssembler<ShaderAssemblerType extends Sh
|
|
|
47
47
|
return shaderAssembler;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
shaderAssembler.addShaderHook(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
shaderAssembler.addShaderHook({
|
|
51
|
+
name: 'TEXT_ATTRIBUTE_VERTEX_TRANSFORM',
|
|
52
|
+
stage: 'vertex',
|
|
53
|
+
glsl: {
|
|
54
|
+
parameters:
|
|
55
|
+
'inout vec4 position, inout vec2 textureCoordinate, inout vec4 textColor, vec2 worldPosition, vec4 glyphFrame, vec2 corner, vec2 glyphSize, vec2 atlasSize'
|
|
56
|
+
},
|
|
57
|
+
wgsl: {
|
|
58
|
+
parameters:
|
|
59
|
+
'outputs: ptr<function, FragmentInputs>, worldPosition: vec2<f32>, glyphFrame: vec4<f32>, corner: vec2<f32>, glyphSize: vec2<f32>, atlasSize: vec2<f32>'
|
|
60
|
+
}
|
|
61
|
+
});
|
|
55
62
|
configuredLanguages.add(shaderLanguage);
|
|
56
63
|
return shaderAssembler;
|
|
57
64
|
}
|
|
@@ -185,6 +185,9 @@ export class Computation {
|
|
|
185
185
|
|
|
186
186
|
const platformInfo = getPlatformInfo(device);
|
|
187
187
|
const resolvedPlugins = resolveShaderPlugins(this.props.plugins, platformInfo.shaderLanguage);
|
|
188
|
+
if (resolvedPlugins.hooks.length > 0) {
|
|
189
|
+
throw new Error('Computation does not support ShaderPlugin render hooks');
|
|
190
|
+
}
|
|
188
191
|
if (
|
|
189
192
|
Object.keys(resolvedPlugins.vertexInputs).length > 0 ||
|
|
190
193
|
Object.keys(resolvedPlugins.interStageVariables).length > 0
|
|
@@ -2,11 +2,29 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {Device} from '@luma.gl/core';
|
|
6
|
+
import type {Geometry} from '@math.gl/geometry';
|
|
5
7
|
import {vertexFormatDecoder} from '@luma.gl/core';
|
|
6
8
|
import type {GPUVectorModelInput} from '../model/gpu-vector-model-batches';
|
|
7
|
-
import {GPUGeometry} from './gpu-geometry';
|
|
9
|
+
import {GPUGeometry, makeGPUGeometry} from './gpu-geometry';
|
|
8
10
|
import {GPUVectorGeometry} from './gpu-vector-geometry';
|
|
9
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Interleaves and uploads CPU geometry for use with GPUVectorModel.
|
|
14
|
+
* The returned geometry owns its uploaded buffers; call destroy() after all models stop using it.
|
|
15
|
+
*/
|
|
16
|
+
export function makeGPUVectorGeometry(device: Device, geometry: Geometry): GPUVectorGeometry {
|
|
17
|
+
const gpuGeometry = makeGPUGeometry(device, geometry);
|
|
18
|
+
try {
|
|
19
|
+
const vectorGeometry = makeGPUVectorGeometryFromGPUGeometry(gpuGeometry);
|
|
20
|
+
vectorGeometry.destroy = () => gpuGeometry.destroy();
|
|
21
|
+
return vectorGeometry;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
gpuGeometry.destroy();
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
/** Borrows legacy geometry storage as typed vector views for Model's input adapter. */
|
|
11
29
|
export function makeGPUVectorGeometryFromGPUGeometry(geometry: GPUGeometry): GPUVectorGeometry {
|
|
12
30
|
const attributes: Record<string, GPUVectorModelInput> = {};
|
|
@@ -23,6 +23,9 @@ export class GPUVectorGeometry {
|
|
|
23
23
|
readonly vertexCount?: number;
|
|
24
24
|
readonly bufferLayout?: BufferLayout[];
|
|
25
25
|
|
|
26
|
+
/** Releases resources owned by uploaded geometry; borrowed vectors remain caller-owned. */
|
|
27
|
+
destroy(): void {}
|
|
28
|
+
|
|
26
29
|
constructor(props: GPUVectorGeometryProps) {
|
|
27
30
|
this.attributes = props.attributes;
|
|
28
31
|
this.indices = props.indices ?? null;
|
|
@@ -122,16 +122,36 @@ const GLTF_EXTENSION_SUPPORT_REGISTRY: Record<string, GLTFExtensionSupportDefini
|
|
|
122
122
|
},
|
|
123
123
|
EXT_mesh_features: {
|
|
124
124
|
supportLevel: 'loader-only',
|
|
125
|
-
standardStatus: '
|
|
125
|
+
standardStatus: 'unknown',
|
|
126
126
|
comment:
|
|
127
127
|
'Feature identifiers are decoded by loaders.gl; automatic rendering and picking are application-owned.'
|
|
128
128
|
},
|
|
129
129
|
EXT_structural_metadata: {
|
|
130
130
|
supportLevel: 'loader-only',
|
|
131
|
-
standardStatus: '
|
|
131
|
+
standardStatus: 'unknown',
|
|
132
132
|
comment:
|
|
133
133
|
'Structural metadata is decoded by loaders.gl; automatic rendering and querying are application-owned.'
|
|
134
134
|
},
|
|
135
|
+
KHR_gaussian_splatting: {
|
|
136
|
+
supportLevel: 'none',
|
|
137
|
+
standardStatus: 'ratified',
|
|
138
|
+
comment: 'A splat adapter exists, but ordinary glTF scene creation does not integrate it.'
|
|
139
|
+
},
|
|
140
|
+
KHR_interactivity: {
|
|
141
|
+
supportLevel: 'none',
|
|
142
|
+
standardStatus: 'ratified',
|
|
143
|
+
comment: 'The subset interpreter is not integrated into ordinary glTF scene creation.'
|
|
144
|
+
},
|
|
145
|
+
KHR_node_selectability: {
|
|
146
|
+
supportLevel: 'none',
|
|
147
|
+
standardStatus: 'ratified',
|
|
148
|
+
comment: 'Authored selection semantics are not wired into scene picking.'
|
|
149
|
+
},
|
|
150
|
+
KHR_node_hoverability: {
|
|
151
|
+
supportLevel: 'none',
|
|
152
|
+
standardStatus: 'ratified',
|
|
153
|
+
comment: 'Authored hover semantics are not wired into pointer dispatch.'
|
|
154
|
+
},
|
|
135
155
|
KHR_lights_punctual: {
|
|
136
156
|
supportLevel: 'built-in',
|
|
137
157
|
standardStatus: 'ratified',
|
|
@@ -166,9 +186,9 @@ const GLTF_EXTENSION_SUPPORT_REGISTRY: Record<string, GLTFExtensionSupportDefini
|
|
|
166
186
|
},
|
|
167
187
|
EXT_texture_avif: {
|
|
168
188
|
supportLevel: 'none',
|
|
169
|
-
standardStatus: '
|
|
189
|
+
standardStatus: 'unknown',
|
|
170
190
|
comment:
|
|
171
|
-
'
|
|
191
|
+
'Source selection depends on the loaders.gl version and decoder; luma.gl does not independently resolve AVIF sources.'
|
|
172
192
|
},
|
|
173
193
|
KHR_materials_specular: {
|
|
174
194
|
supportLevel: 'built-in',
|
|
@@ -389,7 +409,9 @@ export function assertSupportedGLTFExtensions(gltf: GLTFPostprocessed, device?:
|
|
|
389
409
|
throw new Error(
|
|
390
410
|
`Unsupported required glTF extensions: ${unsupportedExtensions
|
|
391
411
|
.map(extension => extension.extensionName)
|
|
392
|
-
.join(', ')}
|
|
412
|
+
.join(', ')}. ${unsupportedExtensions
|
|
413
|
+
.map(extension => `${extension.extensionName}: ${extension.comment}`)
|
|
414
|
+
.join(' ')}`
|
|
393
415
|
);
|
|
394
416
|
}
|
|
395
417
|
}
|
package/src/gltf/index.ts
CHANGED
|
@@ -59,6 +59,8 @@ export type ParseGLTFOptions = {
|
|
|
59
59
|
useTangents?: boolean;
|
|
60
60
|
/** When true, parsed semantic light colors are converted into luma.gl's legacy byte-style range. */
|
|
61
61
|
useByteColors?: boolean;
|
|
62
|
+
/** Leave Gaussian primitives for a caller-managed splat renderer instead of creating mesh models. */
|
|
63
|
+
excludeGaussianSplatPrimitives?: boolean;
|
|
62
64
|
/** Reject documents whose required extensions have no complete runtime implementation. */
|
|
63
65
|
strictExtensions?: boolean;
|
|
64
66
|
};
|
|
@@ -80,7 +82,8 @@ const defaultOptions: Required<ParseGLTFOptions> = {
|
|
|
80
82
|
lights: true,
|
|
81
83
|
useTangents: false,
|
|
82
84
|
useByteColors: true,
|
|
83
|
-
strictExtensions: false
|
|
85
|
+
strictExtensions: false,
|
|
86
|
+
excludeGaussianSplatPrimitives: false
|
|
84
87
|
};
|
|
85
88
|
|
|
86
89
|
/**
|
|
@@ -346,19 +349,23 @@ function createNodeForGLTFMesh(
|
|
|
346
349
|
)
|
|
347
350
|
});
|
|
348
351
|
}
|
|
349
|
-
const primitives = gltfPrimitives.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
352
|
+
const primitives = gltfPrimitives.flatMap((gltfPrimitive, i) =>
|
|
353
|
+
options.excludeGaussianSplatPrimitives && gltfPrimitive.extensions?.KHR_gaussian_splatting
|
|
354
|
+
? []
|
|
355
|
+
: [
|
|
356
|
+
createNodeForGLTFPrimitive({
|
|
357
|
+
device,
|
|
358
|
+
gltfPrimitive,
|
|
359
|
+
primitiveIndex: i,
|
|
360
|
+
gltfMesh,
|
|
361
|
+
gltf,
|
|
362
|
+
gltfMaterialIdToMaterialMap,
|
|
363
|
+
options,
|
|
364
|
+
instancing,
|
|
365
|
+
nodeLightmap,
|
|
366
|
+
lightmapInstance
|
|
367
|
+
})
|
|
368
|
+
]
|
|
362
369
|
);
|
|
363
370
|
const mesh = new GroupNode({
|
|
364
371
|
id: gltfMesh.name || gltfMesh.id,
|
|
@@ -746,6 +746,8 @@ export type GLTFTexturePostprocessed = {
|
|
|
746
746
|
*/
|
|
747
747
|
export type GLTFPostprocessed = {
|
|
748
748
|
id?: string;
|
|
749
|
+
/** Loader-supplied Gaussian descriptors, retaining source primitive identity. */
|
|
750
|
+
gaussianSplatPrimitives?: import('./gltf-types').GLTFGaussianSplatDescriptor[];
|
|
749
751
|
|
|
750
752
|
// GLTF attributes (possibly overridden)
|
|
751
753
|
/** Names of glTF extensions used somewhere in this asset. */
|
|
@@ -93,6 +93,26 @@ export type GLTFWithBuffers = {
|
|
|
93
93
|
images?: (GLTFImageData | null)[];
|
|
94
94
|
binary?: ArrayBuffer;
|
|
95
95
|
baseUri?: string;
|
|
96
|
+
/** Gaussian primitive descriptors supplied by the loader. */
|
|
97
|
+
gaussianSplatPrimitives?: GLTFGaussianSplatDescriptor[];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Loader-supplied Gaussian primitive identity and optional decoded payload. */
|
|
101
|
+
export type GLTFGaussianSplatDescriptor = {
|
|
102
|
+
/** Index of the source mesh. */
|
|
103
|
+
meshIndex: number;
|
|
104
|
+
/** Index of the source primitive within its mesh. */
|
|
105
|
+
primitiveIndex: number;
|
|
106
|
+
/** Source accessor indices for the primitive's Gaussian and feature attributes. */
|
|
107
|
+
attributes?: Readonly<Record<string, number>>;
|
|
108
|
+
/** Original Gaussian extension declaration, including its compression metadata. */
|
|
109
|
+
extension?: Readonly<Record<string, unknown>>;
|
|
110
|
+
/** Source buffer view containing the compressed payload. */
|
|
111
|
+
compressedBufferView?: number;
|
|
112
|
+
/** Decoder-specific result, such as a loaders.gl Mesh Arrow table. */
|
|
113
|
+
decoded?: unknown;
|
|
114
|
+
/** Copied compressed bytes retained by the loader, when available. */
|
|
115
|
+
compressedBytes?: Uint8Array;
|
|
96
116
|
};
|
|
97
117
|
|
|
98
118
|
/** Loader-derived index runs for KHR_mesh_primitive_restart. */
|
|
@@ -22,3 +22,13 @@ export {ScenegraphPhysicsPublication} from './scenegraph-publication';
|
|
|
22
22
|
export type {ScenegraphPhysicsRenderBinding} from './scenegraph-publication';
|
|
23
23
|
export {ScenegraphPhysicsSession} from './scenegraph-session';
|
|
24
24
|
export type {ScenegraphPhysicsScene, ScenegraphPhysicsSessionCapture} from './scenegraph-session';
|
|
25
|
+
export {PhysicsController} from './physics-controller';
|
|
26
|
+
export type {
|
|
27
|
+
PhysicsNodeReference,
|
|
28
|
+
PhysicsJointOptions,
|
|
29
|
+
PhysicsBodyOptions,
|
|
30
|
+
PhysicsControllerProps,
|
|
31
|
+
PhysicsBody,
|
|
32
|
+
PhysicsBodyPose,
|
|
33
|
+
PhysicsUpdateResult
|
|
34
|
+
} from './physics-controller';
|