@luma.gl/engine 10.0.0-alpha.8 → 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/dist.dev.js +277 -291
- package/dist/dist.min.js +58 -58
- 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/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 +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -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/gpu-vector-bindings.cjs +10 -3
- 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 +12 -3
- package/dist/model/gpu-vector-bindings.js.map +1 -1
- package/dist/model/gpu-vector-draw-batches.cjs +4 -3
- 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 +4 -3
- package/dist/model/gpu-vector-draw-batches.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +22 -14
- package/dist/model/gpu-vector-model.d.ts +8 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +28 -14
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/model/model.d.ts +1 -1
- package/dist/model/model.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/package.json +6 -6
- 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/geometry/gpu-vector-geometry-adapter.ts +19 -1
- package/src/geometry/gpu-vector-geometry.ts +3 -0
- 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/index.ts +2 -0
- package/src/model/gpu-vector-bindings.ts +11 -3
- package/src/model/gpu-vector-draw-batches.ts +12 -10
- package/src/model/gpu-vector-model.ts +54 -16
- package/src/model/model.ts +1 -1
- package/src/splats/README.md +46 -0
- package/src/splats/splat-data.ts +53 -45
|
@@ -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. */
|
package/src/index.ts
CHANGED
|
@@ -354,3 +354,5 @@ export {makeAdapterAnimationBinding} from './animation/property-animation-bindin
|
|
|
354
354
|
export {deformPositions} from './animation/deform-positions';
|
|
355
355
|
|
|
356
356
|
export {createAreaLightLTCTextures} from './lighting/ltc-textures';
|
|
357
|
+
|
|
358
|
+
export {makeGPUVectorGeometry} from './geometry/gpu-vector-geometry-adapter';
|
|
@@ -51,9 +51,17 @@ export class GPUVectorBindings {
|
|
|
51
51
|
setInputs(
|
|
52
52
|
columns: GPUVectorModelAttributes,
|
|
53
53
|
explicitLayouts: BufferLayout[] | undefined,
|
|
54
|
-
stepMode: 'vertex' | 'instance'
|
|
54
|
+
stepMode: 'vertex' | 'instance',
|
|
55
|
+
enforceMatchingVectorLengths = true
|
|
55
56
|
): void {
|
|
56
|
-
|
|
57
|
+
if (enforceMatchingVectorLengths) {
|
|
58
|
+
validateGPUVectorBatchStructure(columns);
|
|
59
|
+
} else {
|
|
60
|
+
// Independent attributes currently require contiguous storage.
|
|
61
|
+
for (const column of Object.values(columns)) {
|
|
62
|
+
if (column && !isConstant(column)) assert(column.data.length === 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
57
65
|
this.claimedNames.clear();
|
|
58
66
|
this.inputs = columns;
|
|
59
67
|
this.sourceLayouts = explicitLayouts;
|
|
@@ -87,7 +95,7 @@ export class GPUVectorBindings {
|
|
|
87
95
|
// Inputs must describe a typed vector or a typed constant, never raw buffers or arrays.
|
|
88
96
|
if (!isConstant(column) && !Array.isArray(column.data))
|
|
89
97
|
throw new TypeError(`Expected a GPU vector or constant for ${name}`);
|
|
90
|
-
if (!isConstant(column)) {
|
|
98
|
+
if (!isConstant(column) && enforceMatchingVectorLengths) {
|
|
91
99
|
const layout = layouts.find(
|
|
92
100
|
layout =>
|
|
93
101
|
layout.name === name ||
|
|
@@ -19,7 +19,8 @@ export function drawGPUVectorGroups(
|
|
|
19
19
|
geometry: GPUVectorBindings,
|
|
20
20
|
attributes: GPUVectorBindings,
|
|
21
21
|
syncBindings: () => void,
|
|
22
|
-
draw: () => boolean
|
|
22
|
+
draw: () => boolean,
|
|
23
|
+
inferDrawCount?: 'instance' | 'vertex' | 'no'
|
|
23
24
|
): boolean {
|
|
24
25
|
const geometryInputs = geometry.inputs;
|
|
25
26
|
const attributeInputs = attributes.inputs;
|
|
@@ -68,16 +69,17 @@ export function drawGPUVectorGroups(
|
|
|
68
69
|
: attributes.vertexCount !== undefined
|
|
69
70
|
? attributeOffsets[attributeBatchIndex]
|
|
70
71
|
: 0;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
if (inferDrawCount === 'vertex')
|
|
73
|
+
model.setVertexCount(
|
|
74
|
+
Math.max(
|
|
75
|
+
0,
|
|
76
|
+
Math.min(
|
|
77
|
+
geometry.rowCount ?? attributes.vertexCount ?? vertexCount,
|
|
78
|
+
vertexCount - vertexOffset
|
|
79
|
+
)
|
|
77
80
|
)
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
if (attributes.instanceCount !== undefined)
|
|
81
|
+
);
|
|
82
|
+
if (inferDrawCount === 'instance' && attributes.instanceCount !== undefined)
|
|
81
83
|
model.setInstanceCount(
|
|
82
84
|
Math.max(
|
|
83
85
|
0,
|
|
@@ -115,8 +115,13 @@ export type GPUVectorModelProps = Omit<RenderPipelineProps, 'vs' | 'fs' | 'bindi
|
|
|
115
115
|
geometry?: GPUVectorGeometry | null;
|
|
116
116
|
/** Supplemental vertex or instance vectors and constants. */
|
|
117
117
|
attributeVectors?: GPUVectorModelAttributes;
|
|
118
|
-
/**
|
|
119
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Count inferred from vector rows or each explicit batch. `no` preserves both counts.
|
|
120
|
+
* @default 'no'
|
|
121
|
+
*/
|
|
122
|
+
inferDrawCount?: 'instance' | 'vertex' | 'no';
|
|
123
|
+
/** Require aligned lengths and chunks. False requires inferDrawCount: 'no' and single chunks. */
|
|
124
|
+
enforceMatchingVectorLengths?: boolean;
|
|
120
125
|
source?: string;
|
|
121
126
|
/** Input language compiled by the application-registered shader assembler transpiler. */
|
|
122
127
|
sourceLanguage?: string;
|
|
@@ -228,7 +233,8 @@ export class GPUVectorModel {
|
|
|
228
233
|
|
|
229
234
|
static defaultProps: Required<GPUVectorModelProps> = {
|
|
230
235
|
...RenderPipeline.defaultProps,
|
|
231
|
-
|
|
236
|
+
inferDrawCount: 'no',
|
|
237
|
+
enforceMatchingVectorLengths: true,
|
|
232
238
|
geometry: null,
|
|
233
239
|
attributeVectors: undefined!,
|
|
234
240
|
source: undefined!,
|
|
@@ -800,13 +806,22 @@ export class GPUVectorModel {
|
|
|
800
806
|
bufferLayouts ??=
|
|
801
807
|
this.getExplicitVectorLayouts(vectors) ??
|
|
802
808
|
this.getExplicitVectorLayouts(vectors, this.geometryVectorBindings.sourceLayouts);
|
|
803
|
-
|
|
804
|
-
if (
|
|
809
|
+
this.validateVectorLengthPolicy();
|
|
810
|
+
if (this.props.enforceMatchingVectorLengths) validateGPUVectorBatchStructure(vectors);
|
|
811
|
+
if (
|
|
812
|
+
this.props.enforceMatchingVectorLengths &&
|
|
813
|
+
(!this.isInstanced || this.attributeVectorBindings.vertexCount !== undefined)
|
|
814
|
+
)
|
|
805
815
|
validateGPUVectorBatchStructure([
|
|
806
816
|
...Object.values(vectors),
|
|
807
817
|
...Object.values(this.attributeVectorBindings.inputs)
|
|
808
818
|
]);
|
|
809
|
-
this.geometryVectorBindings.setInputs(
|
|
819
|
+
this.geometryVectorBindings.setInputs(
|
|
820
|
+
vectors,
|
|
821
|
+
bufferLayouts,
|
|
822
|
+
'vertex',
|
|
823
|
+
this.props.enforceMatchingVectorLengths
|
|
824
|
+
);
|
|
810
825
|
this.claimVectorLayouts(this.geometryVectorBindings);
|
|
811
826
|
this.syncVectorBindings();
|
|
812
827
|
const rowCount = this.geometryVectorBindings.rowCount;
|
|
@@ -815,7 +830,8 @@ export class GPUVectorModel {
|
|
|
815
830
|
this.attributeVectorBindings.vertexCount === undefined ||
|
|
816
831
|
rowCount === this.attributeVectorBindings.vertexCount
|
|
817
832
|
);
|
|
818
|
-
|
|
833
|
+
if (this.props.inferDrawCount === 'vertex')
|
|
834
|
+
this.setVertexCount(rowCount ?? this.attributeVectorBindings.vertexCount ?? 0);
|
|
819
835
|
}
|
|
820
836
|
|
|
821
837
|
/** Replaces supplemental vectors; instanced models default these inputs to instance step mode. */
|
|
@@ -843,7 +859,8 @@ export class GPUVectorModel {
|
|
|
843
859
|
layout.attributes?.some(attribute => attribute.attribute === name)
|
|
844
860
|
)?.stepMode ?? vector.bufferLayout?.stepMode) === 'vertex'
|
|
845
861
|
);
|
|
846
|
-
|
|
862
|
+
this.validateVectorLengthPolicy();
|
|
863
|
+
if (usesVertexRows && this.props.enforceMatchingVectorLengths)
|
|
847
864
|
validateGPUVectorBatchStructure([
|
|
848
865
|
...Object.values(this.geometryVectorBindings.inputs),
|
|
849
866
|
...Object.values(vectors)
|
|
@@ -851,14 +868,18 @@ export class GPUVectorModel {
|
|
|
851
868
|
this.attributeVectorBindings.setInputs(
|
|
852
869
|
vectors,
|
|
853
870
|
bufferLayouts,
|
|
854
|
-
this.isInstanced ? 'instance' : 'vertex'
|
|
871
|
+
this.isInstanced ? 'instance' : 'vertex',
|
|
872
|
+
this.props.enforceMatchingVectorLengths
|
|
855
873
|
);
|
|
856
874
|
this.claimVectorLayouts(this.attributeVectorBindings);
|
|
857
875
|
this.syncVectorBindings();
|
|
858
|
-
if (
|
|
876
|
+
if (
|
|
877
|
+
this.props.inferDrawCount === 'instance' &&
|
|
878
|
+
this.attributeVectorBindings.instanceCount !== undefined
|
|
879
|
+
)
|
|
859
880
|
this.setInstanceCount(this.attributeVectorBindings.instanceCount);
|
|
860
881
|
const vertexCount = this.attributeVectorBindings.vertexCount;
|
|
861
|
-
if (vertexCount !== undefined) {
|
|
882
|
+
if (vertexCount !== undefined && this.props.inferDrawCount === 'vertex') {
|
|
862
883
|
const geometryRowCount = this.geometryVectorBindings.rowCount;
|
|
863
884
|
// Supplemental vertex columns describe the same rows as the geometry columns.
|
|
864
885
|
assert(geometryRowCount === undefined || geometryRowCount === vertexCount);
|
|
@@ -999,7 +1020,8 @@ export class GPUVectorModel {
|
|
|
999
1020
|
this.geometryVectorBindings,
|
|
1000
1021
|
this.attributeVectorBindings,
|
|
1001
1022
|
() => this.syncVectorBindings(),
|
|
1002
|
-
() => GPUVectorModel.prototype.draw.call(this, renderPass)
|
|
1023
|
+
() => GPUVectorModel.prototype.draw.call(this, renderPass),
|
|
1024
|
+
this.props.inferDrawCount
|
|
1003
1025
|
);
|
|
1004
1026
|
if (success) {
|
|
1005
1027
|
this._lastDrawTimestamp = this.device.timestamp;
|
|
@@ -1112,9 +1134,16 @@ export class GPUVectorModel {
|
|
|
1112
1134
|
);
|
|
1113
1135
|
}
|
|
1114
1136
|
|
|
1137
|
+
private validateVectorLengthPolicy(): void {
|
|
1138
|
+
// Independent lengths cannot determine a common draw count.
|
|
1139
|
+
assert(this.props.enforceMatchingVectorLengths !== false || this.props.inferDrawCount === 'no');
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1115
1142
|
private setBatchDrawCount(
|
|
1116
1143
|
rowCount: number,
|
|
1117
|
-
count: GPUVectorModelCount = this.props.
|
|
1144
|
+
count: GPUVectorModelCount = this.props.inferDrawCount === 'no'
|
|
1145
|
+
? 'none'
|
|
1146
|
+
: this.props.inferDrawCount
|
|
1118
1147
|
): void {
|
|
1119
1148
|
if (count === 'instance') {
|
|
1120
1149
|
this.setInstanceCount(rowCount);
|
|
@@ -1148,13 +1177,22 @@ export class GPUVectorModel {
|
|
|
1148
1177
|
this.getExplicitVectorLayouts(geometry.inputs) ?? geometry.sourceLayouts;
|
|
1149
1178
|
const attributeLayouts =
|
|
1150
1179
|
this.getExplicitVectorLayouts(attributes.inputs) ?? attributes.sourceLayouts;
|
|
1151
|
-
geometry.setInputs(
|
|
1180
|
+
geometry.setInputs(
|
|
1181
|
+
geometry.inputs,
|
|
1182
|
+
geometryLayouts,
|
|
1183
|
+
'vertex',
|
|
1184
|
+
this.props.enforceMatchingVectorLengths
|
|
1185
|
+
);
|
|
1152
1186
|
attributes.setInputs(
|
|
1153
1187
|
attributes.inputs,
|
|
1154
1188
|
attributeLayouts,
|
|
1155
|
-
this.isInstanced ? 'instance' : 'vertex'
|
|
1189
|
+
this.isInstanced ? 'instance' : 'vertex',
|
|
1190
|
+
this.props.enforceMatchingVectorLengths
|
|
1156
1191
|
);
|
|
1157
|
-
if (
|
|
1192
|
+
if (
|
|
1193
|
+
this.props.enforceMatchingVectorLengths &&
|
|
1194
|
+
(!this.isInstanced || attributes.vertexCount !== undefined)
|
|
1195
|
+
)
|
|
1158
1196
|
validateGPUVectorBatchStructure([
|
|
1159
1197
|
...Object.values(geometry.inputs),
|
|
1160
1198
|
...Object.values(attributes.inputs)
|
package/src/model/model.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {makeGPUVectorGeometryFromGPUGeometry} from '../geometry/gpu-vector-geome
|
|
|
17
17
|
import {isTextureBindingSource} from '@luma.gl/core/dynamic';
|
|
18
18
|
|
|
19
19
|
/** Properties for the high-level rendering model. */
|
|
20
|
-
export type ModelProps = Omit<GPUVectorModelProps, '
|
|
20
|
+
export type ModelProps = Omit<GPUVectorModelProps, 'geometry'> & {
|
|
21
21
|
/** Geometry adapted into GPU attributes, buffer layouts, topology, and draw counts. */
|
|
22
22
|
geometry?: GPUVectorGeometry | GPUGeometry | Geometry | null;
|
|
23
23
|
/** Material-owned group-3 bindings and uniforms. */
|
package/src/splats/README.md
CHANGED
|
@@ -41,3 +41,49 @@ Renderers borrow source batches, preserve HDR colors, and must be destroyed befo
|
|
|
41
41
|
This package is public with experimental APIs. Install it with `yarn add @luma.gl/engine`.
|
|
42
42
|
|
|
43
43
|
See [luma.gl](https://luma.gl/docs/api-reference/splats) for documentation.
|
|
44
|
+
|
|
45
|
+
## Preparing glTF Gaussian primitives
|
|
46
|
+
|
|
47
|
+
When using loaders.gl, provide `SPZLoader` alongside `GLTFLoader` and request Arrow output. Pass
|
|
48
|
+
its result through `postProcessGLTF`, then use the optional Arrow entry to prepare both decoded SPZ
|
|
49
|
+
and uncompressed Gaussian primitives:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {load} from '@loaders.gl/core';
|
|
53
|
+
import {GLTFLoader} from '@loaders.gl/scene/gltf';
|
|
54
|
+
import {SPZLoader} from '@loaders.gl/splats';
|
|
55
|
+
import {createScenegraphsFromGLTF, postProcessGLTF} from '@luma.gl/engine/gltf';
|
|
56
|
+
import type {GLTFWithBuffers} from '@luma.gl/engine/gltf';
|
|
57
|
+
import {getGLTFSplatSceneInstances, makeGPUSplatDataFromGLTFScene} from '@luma.gl/engine/arrow';
|
|
58
|
+
|
|
59
|
+
const loaded = await load('scene.glb', [GLTFLoader, SPZLoader], {
|
|
60
|
+
splats: {shape: 'arrow-table', targetCoordinateSystem: 'LUF'}
|
|
61
|
+
});
|
|
62
|
+
const gltf = postProcessGLTF(loaded as GLTFWithBuffers);
|
|
63
|
+
const scenegraphs = createScenegraphsFromGLTF(device, gltf, {
|
|
64
|
+
excludeGaussianSplatPrimitives: true
|
|
65
|
+
});
|
|
66
|
+
const splatGroups = await makeGPUSplatDataFromGLTFScene(device, gltf);
|
|
67
|
+
const instances = getGLTFSplatSceneInstances(scenegraphs, splatGroups);
|
|
68
|
+
// Apply each instance's worldMatrix when drawing its batches in the host render pass.
|
|
69
|
+
// Recalculate instances after animation or visibility changes.
|
|
70
|
+
// Destroy the borrowing renderer first, then each batch and scenegraphs.destroy().
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The bridge preserves the Arrow record-batch boundaries and source mesh/primitive indices.
|
|
74
|
+
Instance discovery expands `EXT_mesh_gpu_instancing` matrices and reports each source instance index. The
|
|
75
|
+
splat upload is caller-owned, and decoded loader data remains borrowed. Quaternion conversion and
|
|
76
|
+
SH layout adaptation occur in the existing upload adapters; no coordinate-system conversion is
|
|
77
|
+
performed by the bridge. If decoding or preparation fails, previously prepared batches are
|
|
78
|
+
released. Cancellation is checked before each primitive and after preparation.
|
|
79
|
+
|
|
80
|
+
`excludeGaussianSplatPrimitives` leaves those primitives out of the mesh scenegraph; it does not
|
|
81
|
+
create or draw splat renderers. Applications must resolve scene-node instances, transforms,
|
|
82
|
+
visibility, and mixed-scene draw ordering. Decoded splats retain glTF feature-ID attributes when their row counts match the decoded table.
|
|
83
|
+
The decoded Arrow path currently accepts linear Rec. 709 display colors; sRGB display colors require
|
|
84
|
+
a separate conversion and are rejected. Strict required-extension
|
|
85
|
+
support remains unchanged until ordinary scene creation can render the extension end to end.
|
|
86
|
+
|
|
87
|
+
The Gaussian splat showcase includes a synthetic embedded-GLB scene. Select **Embedded glTF
|
|
88
|
+
Gaussian splats** in the scene control. The showcase currently accepts one visible Gaussian instance with an invertible node transform;
|
|
89
|
+
applications needing mixed meshes or multiple instances must compose their own render passes.
|
package/src/splats/splat-data.ts
CHANGED
|
@@ -143,54 +143,62 @@ export class GPUSplatData {
|
|
|
143
143
|
rowIndices[rowIndex] = this.sourceInfo.sourceRowIndexOffset + rowIndex;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.rotations = createSplatGPUVector(
|
|
155
|
-
device,
|
|
156
|
-
'rotations',
|
|
157
|
-
source.rotations,
|
|
158
|
-
'float32x4',
|
|
159
|
-
length
|
|
160
|
-
);
|
|
161
|
-
const colorFormat = source.colors instanceof Float32Array ? 'float32x4' : 'unorm8x4';
|
|
162
|
-
this.colors = createSplatGPUVector(device, 'colors', source.colors, colorFormat, length);
|
|
163
|
-
this.opacities = createSplatGPUVector(device, 'opacities', source.opacities, 'float32', length);
|
|
164
|
-
this.rowIndices = createSplatGPUVector(device, 'rowIndices', rowIndices, 'uint32', length);
|
|
165
|
-
if (source.semanticIds) {
|
|
166
|
-
this.semanticIds = createSplatGPUVector(
|
|
167
|
-
device,
|
|
168
|
-
'semanticIds',
|
|
169
|
-
source.semanticIds,
|
|
170
|
-
'uint32',
|
|
171
|
-
length
|
|
146
|
+
const allocatedVectors: GPUVector[] = [];
|
|
147
|
+
const track = <VectorT extends GPUVector>(vector: VectorT): VectorT => {
|
|
148
|
+
allocatedVectors.push(vector);
|
|
149
|
+
return vector;
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
this.positions = track(
|
|
153
|
+
createSplatGPUVector(device, 'positions', source.positions, 'float32x3', length)
|
|
172
154
|
);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
'
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
155
|
+
this.scales = track(
|
|
156
|
+
createSplatGPUVector(device, 'scales', source.scales, 'float32x3', length)
|
|
157
|
+
);
|
|
158
|
+
this.rotations = track(
|
|
159
|
+
createSplatGPUVector(device, 'rotations', source.rotations, 'float32x4', length)
|
|
160
|
+
);
|
|
161
|
+
const colorFormat = source.colors instanceof Float32Array ? 'float32x4' : 'unorm8x4';
|
|
162
|
+
this.colors = track(
|
|
163
|
+
createSplatGPUVector(device, 'colors', source.colors, colorFormat, length)
|
|
181
164
|
);
|
|
165
|
+
this.opacities = track(
|
|
166
|
+
createSplatGPUVector(device, 'opacities', source.opacities, 'float32', length)
|
|
167
|
+
);
|
|
168
|
+
this.rowIndices = track(
|
|
169
|
+
createSplatGPUVector(device, 'rowIndices', rowIndices, 'uint32', length)
|
|
170
|
+
);
|
|
171
|
+
if (source.semanticIds) {
|
|
172
|
+
this.semanticIds = track(
|
|
173
|
+
createSplatGPUVector(device, 'semanticIds', source.semanticIds, 'uint32', length)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (source.sphericalHarmonics) {
|
|
177
|
+
this.sphericalHarmonics = track(
|
|
178
|
+
createSplatGPUVector(
|
|
179
|
+
device,
|
|
180
|
+
'sphericalHarmonics',
|
|
181
|
+
source.sphericalHarmonics,
|
|
182
|
+
'float32',
|
|
183
|
+
source.sphericalHarmonics.length
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
this.table = new GPUTable({
|
|
188
|
+
vectors: {
|
|
189
|
+
positions: this.positions,
|
|
190
|
+
scales: this.scales,
|
|
191
|
+
rotations: this.rotations,
|
|
192
|
+
colors: this.colors,
|
|
193
|
+
opacities: this.opacities,
|
|
194
|
+
rowIndices: this.rowIndices
|
|
195
|
+
},
|
|
196
|
+
sourceInfo: this.sourceInfo
|
|
197
|
+
});
|
|
198
|
+
} catch (error) {
|
|
199
|
+
for (const vector of allocatedVectors) vector.destroy();
|
|
200
|
+
throw error;
|
|
182
201
|
}
|
|
183
|
-
this.table = new GPUTable({
|
|
184
|
-
vectors: {
|
|
185
|
-
positions: this.positions,
|
|
186
|
-
scales: this.scales,
|
|
187
|
-
rotations: this.rotations,
|
|
188
|
-
colors: this.colors,
|
|
189
|
-
opacities: this.opacities,
|
|
190
|
-
rowIndices: this.rowIndices
|
|
191
|
-
},
|
|
192
|
-
sourceInfo: this.sourceInfo
|
|
193
|
-
});
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
/** Number of logical source rows, matching {@link length}. */
|