@loaders.gl/splats 5.0.0-beta.1 → 5.0.0-beta.11
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 +4 -2
- package/dist/bundled.d.ts +1 -1
- package/dist/bundled.d.ts.map +1 -1
- package/dist/bundled.js +1 -1
- package/dist/bundled.js.map +1 -1
- package/dist/dist.dev.js +550 -431
- package/dist/dist.min.js +20 -20
- package/dist/index.cjs +437 -365
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ksplat-loader-types.d.ts +11 -7
- package/dist/ksplat-loader-types.d.ts.map +1 -1
- package/dist/ksplat-loader-types.js +4 -2
- package/dist/ksplat-loader-types.js.map +1 -1
- package/dist/ksplat-loader.d.ts +7 -5
- package/dist/ksplat-loader.d.ts.map +1 -1
- package/dist/ksplat-loader.js.map +1 -1
- package/dist/lib/parse-ksplat.d.ts +2 -2
- package/dist/lib/parse-ksplat.d.ts.map +1 -1
- package/dist/lib/parse-rad-chunk.d.ts +2 -2
- package/dist/lib/parse-rad-chunk.d.ts.map +1 -1
- package/dist/lib/parse-splat.d.ts +2 -2
- package/dist/lib/parse-splat.d.ts.map +1 -1
- package/dist/lib/parse-spz.d.ts +2 -2
- package/dist/lib/parse-spz.d.ts.map +1 -1
- package/dist/lib/parse-spz.js.map +1 -1
- package/dist/lib/splats-arrow-table.d.ts +2 -2
- package/dist/lib/splats-arrow-table.d.ts.map +1 -1
- package/dist/lib/splats-arrow-table.js +30 -35
- package/dist/lib/splats-arrow-table.js.map +1 -1
- package/dist/rad-loader-types.d.ts +5 -0
- package/dist/rad-loader-types.d.ts.map +1 -1
- package/dist/rad-loader-types.js +3 -1
- package/dist/rad-loader-types.js.map +1 -1
- package/dist/rad-loader.d.ts +4 -0
- package/dist/rad-loader.d.ts.map +1 -1
- package/dist/rad-loader.js +2 -0
- package/dist/rad-loader.js.map +1 -1
- package/dist/rad-source-loader.d.ts +5 -36
- package/dist/rad-source-loader.d.ts.map +1 -1
- package/dist/rad-source-loader.js +10 -33
- package/dist/rad-source-loader.js.map +1 -1
- package/dist/splat-loader-types.d.ts +11 -7
- package/dist/splat-loader-types.d.ts.map +1 -1
- package/dist/splat-loader-types.js +4 -2
- package/dist/splat-loader-types.js.map +1 -1
- package/dist/splat-loader.d.ts +7 -5
- package/dist/splat-loader.d.ts.map +1 -1
- package/dist/splat-loader.js.map +1 -1
- package/dist/spz-loader-types.d.ts +10 -6
- package/dist/spz-loader-types.d.ts.map +1 -1
- package/dist/spz-loader-types.js +4 -2
- package/dist/spz-loader-types.js.map +1 -1
- package/dist/spz-loader.d.ts +6 -4
- package/dist/spz-loader.d.ts.map +1 -1
- package/dist/spz-loader.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/unbundled.d.ts +1 -1
- package/dist/unbundled.d.ts.map +1 -1
- package/dist/unbundled.js +1 -1
- package/dist/unbundled.js.map +1 -1
- package/package.json +8 -5
- package/src/bundled.ts +1 -1
- package/src/index.ts +1 -1
- package/src/ksplat-loader-types.ts +6 -4
- package/src/ksplat-loader.ts +2 -2
- package/src/lib/parse-ksplat.ts +2 -2
- package/src/lib/parse-rad-chunk.ts +2 -2
- package/src/lib/parse-splat.ts +2 -2
- package/src/lib/parse-spz.ts +2 -5
- package/src/lib/splats-arrow-table.ts +32 -46
- package/src/rad-loader-types.ts +2 -0
- package/src/rad-loader.ts +2 -0
- package/src/rad-source-loader.ts +19 -48
- package/src/splat-loader-types.ts +6 -4
- package/src/splat-loader.ts +2 -2
- package/src/spz-loader-types.ts +6 -4
- package/src/spz-loader.ts +2 -2
- package/src/types.ts +2 -2
- package/src/unbundled.ts +1 -1
|
@@ -3,55 +3,43 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import
|
|
6
|
+
import {encodeArrayBufferToBase64} from '@loaders.gl/core/loader-utils';
|
|
7
7
|
import type {GaussianSplats} from '../types';
|
|
8
8
|
import {convertColorByteToSphericalHarmonicDc} from './splat-utils';
|
|
9
9
|
|
|
10
10
|
/** Builds a Mesh Arrow table from decoded Gaussian splat values. */
|
|
11
|
-
export function makeGaussianSplatsArrowTable(splats: GaussianSplats):
|
|
11
|
+
export function makeGaussianSplatsArrowTable(splats: GaussianSplats): arrow.Table {
|
|
12
12
|
const columns: Record<string, arrow.Vector> = {};
|
|
13
13
|
const fields: arrow.Field[] = [];
|
|
14
|
-
const schemaFields: Field[] = [];
|
|
15
14
|
|
|
16
|
-
addColumn(
|
|
17
|
-
columns,
|
|
18
|
-
fields,
|
|
19
|
-
schemaFields,
|
|
20
|
-
'POSITION',
|
|
21
|
-
makeFixedSizeListVector(splats.positions, 3),
|
|
22
|
-
{
|
|
23
|
-
type: 'fixed-size-list',
|
|
24
|
-
listSize: 3,
|
|
25
|
-
children: [{name: 'value', type: 'float32'}]
|
|
26
|
-
}
|
|
27
|
-
);
|
|
15
|
+
addColumn(columns, fields, 'POSITION', makeFixedSizeListVector(splats.positions, 3));
|
|
28
16
|
|
|
29
17
|
const colorCoefficients = getColorCoefficients(splats);
|
|
30
|
-
addScalarColumn(columns, fields,
|
|
18
|
+
addScalarColumn(columns, fields, 'f_dc_0', colorCoefficients[0], {
|
|
31
19
|
'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',
|
|
32
20
|
'loaders_gl.gaussian_splats.component': '0',
|
|
33
21
|
'loaders_gl.gaussian_splats.encoding': 'coefficient'
|
|
34
22
|
});
|
|
35
|
-
addScalarColumn(columns, fields,
|
|
23
|
+
addScalarColumn(columns, fields, 'f_dc_1', colorCoefficients[1], {
|
|
36
24
|
'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',
|
|
37
25
|
'loaders_gl.gaussian_splats.component': '1',
|
|
38
26
|
'loaders_gl.gaussian_splats.encoding': 'coefficient'
|
|
39
27
|
});
|
|
40
|
-
addScalarColumn(columns, fields,
|
|
28
|
+
addScalarColumn(columns, fields, 'f_dc_2', colorCoefficients[2], {
|
|
41
29
|
'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',
|
|
42
30
|
'loaders_gl.gaussian_splats.component': '2',
|
|
43
31
|
'loaders_gl.gaussian_splats.encoding': 'coefficient'
|
|
44
32
|
});
|
|
45
33
|
|
|
46
|
-
addScalarColumn(columns, fields,
|
|
34
|
+
addScalarColumn(columns, fields, 'opacity', splats.opacities, {
|
|
47
35
|
'loaders_gl.gaussian_splats.semantic': 'opacity',
|
|
48
36
|
'loaders_gl.gaussian_splats.encoding': 'linear'
|
|
49
37
|
});
|
|
50
|
-
addVectorComponents(columns, fields,
|
|
38
|
+
addVectorComponents(columns, fields, 'scale', splats.scales, 3, {
|
|
51
39
|
'loaders_gl.gaussian_splats.semantic': 'scale',
|
|
52
40
|
'loaders_gl.gaussian_splats.encoding': 'linear'
|
|
53
41
|
});
|
|
54
|
-
addVectorComponents(columns, fields,
|
|
42
|
+
addVectorComponents(columns, fields, 'rot', splats.rotations, 4, {
|
|
55
43
|
'loaders_gl.gaussian_splats.semantic': 'rotation',
|
|
56
44
|
'loaders_gl.gaussian_splats.encoding': 'quaternion'
|
|
57
45
|
});
|
|
@@ -60,7 +48,6 @@ export function makeGaussianSplatsArrowTable(splats: GaussianSplats): MeshArrowT
|
|
|
60
48
|
addSphericalHarmonicRestColumns(
|
|
61
49
|
columns,
|
|
62
50
|
fields,
|
|
63
|
-
schemaFields,
|
|
64
51
|
splats.sphericalHarmonics,
|
|
65
52
|
splats.sphericalHarmonicsComponentCount
|
|
66
53
|
);
|
|
@@ -73,26 +60,30 @@ export function makeGaussianSplatsArrowTable(splats: GaussianSplats): MeshArrowT
|
|
|
73
60
|
['topology', 'point-list'],
|
|
74
61
|
['mode', '0']
|
|
75
62
|
]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
63
|
+
if (splats.loaderData) {
|
|
64
|
+
const {extensionBytes, childCounts, childStarts, ...header} = splats.loaderData;
|
|
65
|
+
metadata.set(
|
|
66
|
+
'loaders_gl.gaussian_splats.loader_data',
|
|
67
|
+
JSON.stringify({
|
|
68
|
+
...header,
|
|
69
|
+
childCounts: childCounts instanceof Uint16Array ? Array.from(childCounts) : childCounts,
|
|
70
|
+
childStarts: childStarts instanceof Uint32Array ? Array.from(childStarts) : childStarts
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
if (extensionBytes instanceof Uint8Array) {
|
|
74
|
+
metadata.set(
|
|
75
|
+
'loaders_gl.gaussian_splats.extension_bytes',
|
|
76
|
+
encodeArrayBufferToBase64(extensionBytes.slice().buffer)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return new arrow.Table(new arrow.Schema(fields, metadata), columns);
|
|
89
81
|
}
|
|
90
82
|
|
|
91
83
|
/** Adds one scalar Arrow column per component of an interleaved vector array. */
|
|
92
84
|
function addVectorComponents(
|
|
93
85
|
columns: Record<string, arrow.Vector>,
|
|
94
86
|
fields: arrow.Field[],
|
|
95
|
-
schemaFields: Field[],
|
|
96
87
|
prefix: string,
|
|
97
88
|
values: Float32Array,
|
|
98
89
|
size: number,
|
|
@@ -103,7 +94,7 @@ function addVectorComponents(
|
|
|
103
94
|
for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {
|
|
104
95
|
componentValues[rowIndex] = values[rowIndex * size + component];
|
|
105
96
|
}
|
|
106
|
-
addScalarColumn(columns, fields,
|
|
97
|
+
addScalarColumn(columns, fields, `${prefix}_${component}`, componentValues, {
|
|
107
98
|
...metadata,
|
|
108
99
|
'loaders_gl.gaussian_splats.component': String(component)
|
|
109
100
|
});
|
|
@@ -114,7 +105,6 @@ function addVectorComponents(
|
|
|
114
105
|
function addSphericalHarmonicRestColumns(
|
|
115
106
|
columns: Record<string, arrow.Vector>,
|
|
116
107
|
fields: arrow.Field[],
|
|
117
|
-
schemaFields: Field[],
|
|
118
108
|
sphericalHarmonics: Float32Array,
|
|
119
109
|
componentCount: number
|
|
120
110
|
): void {
|
|
@@ -123,7 +113,7 @@ function addSphericalHarmonicRestColumns(
|
|
|
123
113
|
for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {
|
|
124
114
|
componentValues[rowIndex] = sphericalHarmonics[rowIndex * componentCount + component];
|
|
125
115
|
}
|
|
126
|
-
addScalarColumn(columns, fields,
|
|
116
|
+
addScalarColumn(columns, fields, `f_rest_${component}`, componentValues, {
|
|
127
117
|
'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_rest',
|
|
128
118
|
'loaders_gl.gaussian_splats.component': String(component),
|
|
129
119
|
'loaders_gl.gaussian_splats.encoding': 'coefficient'
|
|
@@ -131,31 +121,27 @@ function addSphericalHarmonicRestColumns(
|
|
|
131
121
|
}
|
|
132
122
|
}
|
|
133
123
|
|
|
134
|
-
/** Adds a Float32 scalar Arrow column
|
|
124
|
+
/** Adds a Float32 scalar Arrow column. */
|
|
135
125
|
function addScalarColumn(
|
|
136
126
|
columns: Record<string, arrow.Vector>,
|
|
137
127
|
fields: arrow.Field[],
|
|
138
|
-
schemaFields: Field[],
|
|
139
128
|
name: string,
|
|
140
129
|
values: Float32Array,
|
|
141
130
|
metadata: Record<string, string>
|
|
142
131
|
): void {
|
|
143
|
-
addColumn(columns, fields,
|
|
132
|
+
addColumn(columns, fields, name, arrow.makeVector(values), metadata);
|
|
144
133
|
}
|
|
145
134
|
|
|
146
|
-
/** Adds an Arrow column
|
|
135
|
+
/** Adds an Arrow column and its field metadata. */
|
|
147
136
|
function addColumn(
|
|
148
137
|
columns: Record<string, arrow.Vector>,
|
|
149
138
|
fields: arrow.Field[],
|
|
150
|
-
schemaFields: Field[],
|
|
151
139
|
name: string,
|
|
152
140
|
column: arrow.Vector,
|
|
153
|
-
schemaType: Field['type'],
|
|
154
141
|
metadata: Record<string, string> = {}
|
|
155
142
|
): void {
|
|
156
143
|
columns[name] = column;
|
|
157
144
|
fields.push(new arrow.Field(name, column.type, false, new Map(Object.entries(metadata))));
|
|
158
|
-
schemaFields.push({name, type: schemaType, nullable: false, metadata});
|
|
159
145
|
}
|
|
160
146
|
|
|
161
147
|
/** Builds a FixedSizeList Arrow vector from an interleaved Float32 array. */
|
package/src/rad-loader-types.ts
CHANGED
package/src/rad-loader.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import {createRADSource} from './rad-source-loader';
|
|
5
6
|
import type {LoaderOptions, LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
6
7
|
import {parseRADHeader} from './lib/parse-rad';
|
|
7
8
|
import type {RADMetadata} from './lib/parse-rad';
|
|
@@ -19,6 +20,7 @@ const {preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload} = RADLoad
|
|
|
19
20
|
|
|
20
21
|
/** Parser-bearing loader for Spark `.rad` paged LoD Gaussian splat container metadata. */
|
|
21
22
|
export const RADLoaderWithParser = {
|
|
23
|
+
createDataSourceSync: createRADSource,
|
|
22
24
|
...RADLoaderMetadataWithoutPreload,
|
|
23
25
|
parse: async (arrayBuffer: ArrayBuffer) => parseRADHeader(arrayBuffer),
|
|
24
26
|
parseSync: (arrayBuffer: ArrayBuffer) => parseRADHeader(arrayBuffer)
|
package/src/rad-source-loader.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {CoreAPI, DataSourceOptions
|
|
5
|
+
import type {CoreAPI, DataSourceOptions} from '@loaders.gl/core/loader-utils';
|
|
6
6
|
import {DataSource} from '@loaders.gl/core/loader-utils';
|
|
7
|
-
import type {
|
|
8
|
-
import {RADFormat} from './splats-format';
|
|
7
|
+
import type {Table} from 'apache-arrow';
|
|
9
8
|
import {
|
|
10
9
|
parseRADChunkHeader,
|
|
11
10
|
tryParseRADHeader,
|
|
@@ -25,10 +24,6 @@ import type {GaussianSplats} from './types';
|
|
|
25
24
|
const DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];
|
|
26
25
|
const DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;
|
|
27
26
|
|
|
28
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
29
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
30
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
31
|
-
|
|
32
27
|
/** Options for creating a Spark RAD source. */
|
|
33
28
|
export type RADSourceLoaderOptions = DataSourceOptions & {
|
|
34
29
|
rad?: {
|
|
@@ -61,40 +56,19 @@ export type RADChunkTableIteratorOptions = RADChunkRequestOptions & {
|
|
|
61
56
|
pruneLoadedLoDParents?: boolean;
|
|
62
57
|
};
|
|
63
58
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...RADFormat,
|
|
69
|
-
name: 'RADSourceLoader',
|
|
70
|
-
version: VERSION,
|
|
71
|
-
type: 'rad',
|
|
72
|
-
fromUrl: true,
|
|
73
|
-
fromBlob: true,
|
|
74
|
-
|
|
75
|
-
options: {
|
|
76
|
-
rad: {
|
|
77
|
-
headers: undefined!,
|
|
78
|
-
withCredentials: false,
|
|
79
|
-
headerByteLengths: undefined!
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
defaultOptions: {
|
|
84
|
-
rad: {
|
|
85
|
-
headers: undefined!,
|
|
86
|
-
withCredentials: false,
|
|
87
|
-
headerByteLengths: undefined!
|
|
88
|
-
}
|
|
89
|
-
},
|
|
59
|
+
/** Default request options for a RAD source. */
|
|
60
|
+
const RAD_SOURCE_DEFAULT_OPTIONS = {
|
|
61
|
+
rad: {headers: undefined!, withCredentials: false, headerByteLengths: undefined!}
|
|
62
|
+
};
|
|
90
63
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
64
|
+
/** Opens a RAD source over a URL or Blob. */
|
|
65
|
+
export function createRADSource(
|
|
66
|
+
data: string | Blob,
|
|
67
|
+
options: RADSourceLoaderOptions,
|
|
68
|
+
coreApi?: CoreAPI
|
|
69
|
+
): RADSource {
|
|
70
|
+
return new RADSource(data, options, coreApi);
|
|
71
|
+
}
|
|
98
72
|
|
|
99
73
|
/** Runtime source for RAD metadata and chunk-byte access. */
|
|
100
74
|
export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions> {
|
|
@@ -107,7 +81,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
|
|
|
107
81
|
private _chunkMetadataPromises: Map<number, Promise<RADChunkMetadata>> = new Map();
|
|
108
82
|
|
|
109
83
|
constructor(data: string | Blob, options: RADSourceLoaderOptions, coreApi?: CoreAPI) {
|
|
110
|
-
super(data, options,
|
|
84
|
+
super(data, options, RAD_SOURCE_DEFAULT_OPTIONS, coreApi);
|
|
111
85
|
this.metadata = this.getMetadata();
|
|
112
86
|
}
|
|
113
87
|
|
|
@@ -199,10 +173,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
|
|
|
199
173
|
}
|
|
200
174
|
|
|
201
175
|
/** Fetches and decodes one RADC chunk into a Mesh Arrow table. */
|
|
202
|
-
async getChunkTable(
|
|
203
|
-
chunkIndex: number,
|
|
204
|
-
options: RADChunkRequestOptions = {}
|
|
205
|
-
): Promise<MeshArrowTable> {
|
|
176
|
+
async getChunkTable(chunkIndex: number, options: RADChunkRequestOptions = {}): Promise<Table> {
|
|
206
177
|
const metadata = await this.getMetadata();
|
|
207
178
|
await preloadRADCompression();
|
|
208
179
|
return parseRADChunk(
|
|
@@ -212,7 +183,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
|
|
|
212
183
|
}
|
|
213
184
|
|
|
214
185
|
/** Iterates decoded RADC chunks as Mesh Arrow tables. */
|
|
215
|
-
async *getChunkTables(options: RADChunkTableIteratorOptions = {}): AsyncIterable<
|
|
186
|
+
async *getChunkTables(options: RADChunkTableIteratorOptions = {}): AsyncIterable<Table> {
|
|
216
187
|
const metadata = await this.getMetadata();
|
|
217
188
|
const startChunkIndex = options.startChunkIndex ?? 0;
|
|
218
189
|
const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;
|
|
@@ -248,7 +219,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
|
|
|
248
219
|
) {
|
|
249
220
|
const table = await this.getChunkTable(chunkIndex, options);
|
|
250
221
|
chunkCount++;
|
|
251
|
-
splatCount += table.
|
|
222
|
+
splatCount += table.numRows;
|
|
252
223
|
yield table;
|
|
253
224
|
}
|
|
254
225
|
}
|
|
@@ -363,7 +334,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
|
|
|
363
334
|
|
|
364
335
|
/** Returns true when source options supplied an explicit fetch override. */
|
|
365
336
|
private _hasCustomFetch(): boolean {
|
|
366
|
-
return Boolean(this.loadOptions?.core?.fetch
|
|
337
|
+
return Boolean(this.loadOptions?.core?.fetch);
|
|
367
338
|
}
|
|
368
339
|
|
|
369
340
|
/** Builds request options for RAD fetches. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Loader} from '@loaders.gl/core/loader-utils';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Table} from 'apache-arrow';
|
|
7
7
|
import type {SplatsLoaderOptions} from './types';
|
|
8
8
|
import {SPLATFormat} from './splats-format';
|
|
9
9
|
|
|
@@ -19,14 +19,16 @@ async function preload() {
|
|
|
19
19
|
|
|
20
20
|
/** Metadata-only loader for raw `.splat` Gaussian splat files. */
|
|
21
21
|
export const SPLATLoader = {
|
|
22
|
-
|
|
22
|
+
defaultShape: 'arrow',
|
|
23
|
+
supportsNativeArrow: true,
|
|
24
|
+
dataType: null as unknown as Table,
|
|
23
25
|
batchType: null as never,
|
|
24
26
|
...SPLATFormat,
|
|
25
27
|
version: VERSION,
|
|
26
28
|
options: {
|
|
27
29
|
splats: {
|
|
28
|
-
shape: 'arrow
|
|
30
|
+
shape: 'arrow'
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
preload
|
|
32
|
-
} as const satisfies Loader<
|
|
34
|
+
} as const satisfies Loader<Table, never, SplatsLoaderOptions>;
|
package/src/splat-loader.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Table} from 'apache-arrow';
|
|
7
7
|
import type {SplatsLoaderOptions} from './types';
|
|
8
8
|
import {parseSPLAT} from './lib/parse-splat';
|
|
9
9
|
import {SPLATLoader as SPLATLoaderMetadata} from './splat-loader-types';
|
|
@@ -15,4 +15,4 @@ export const SPLATLoaderWithParser = {
|
|
|
15
15
|
...SPLATLoaderMetadataWithoutPreload,
|
|
16
16
|
parse: async (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer),
|
|
17
17
|
parseSync: (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer)
|
|
18
|
-
} as const satisfies LoaderWithParser<
|
|
18
|
+
} as const satisfies LoaderWithParser<Table, never, SplatsLoaderOptions>;
|
package/src/spz-loader-types.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Loader} from '@loaders.gl/core/loader-utils';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Table} from 'apache-arrow';
|
|
7
7
|
import type {SplatsLoaderOptions} from './types';
|
|
8
8
|
import {SPZFormat} from './splats-format';
|
|
9
9
|
|
|
@@ -19,14 +19,16 @@ async function preload() {
|
|
|
19
19
|
|
|
20
20
|
/** Metadata-only loader for Niantic Spatial `.spz` Gaussian splat files. */
|
|
21
21
|
export const SPZLoader = {
|
|
22
|
-
|
|
22
|
+
defaultShape: 'arrow',
|
|
23
|
+
supportsNativeArrow: true,
|
|
24
|
+
dataType: null as unknown as Table,
|
|
23
25
|
batchType: null as never,
|
|
24
26
|
...SPZFormat,
|
|
25
27
|
version: VERSION,
|
|
26
28
|
options: {
|
|
27
29
|
splats: {
|
|
28
|
-
shape: 'arrow
|
|
30
|
+
shape: 'arrow'
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
preload
|
|
32
|
-
} as const satisfies Loader<
|
|
34
|
+
} as const satisfies Loader<Table, never, SplatsLoaderOptions>;
|
package/src/spz-loader.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Table} from 'apache-arrow';
|
|
7
7
|
import type {SplatsLoaderOptions} from './types';
|
|
8
8
|
import {parseSPZ} from './lib/parse-spz';
|
|
9
9
|
import {SPZLoader as SPZLoaderMetadata} from './spz-loader-types';
|
|
@@ -15,4 +15,4 @@ export const SPZLoaderWithParser = {
|
|
|
15
15
|
...SPZLoaderMetadataWithoutPreload,
|
|
16
16
|
parse: async (arrayBuffer: ArrayBuffer, options?: SplatsLoaderOptions) =>
|
|
17
17
|
parseSPZ(arrayBuffer, options)
|
|
18
|
-
} as const satisfies LoaderWithParser<
|
|
18
|
+
} as const satisfies LoaderWithParser<Table, never, SplatsLoaderOptions>;
|
package/src/types.ts
CHANGED
|
@@ -7,8 +7,8 @@ import type {LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
|
7
7
|
/** Options shared by Gaussian splat loaders. */
|
|
8
8
|
export type SplatsLoaderOptions = LoaderOptions & {
|
|
9
9
|
splats?: {
|
|
10
|
-
/** Output shape.
|
|
11
|
-
shape?: 'arrow
|
|
10
|
+
/** Output shape. Returns a native Apache Arrow table. */
|
|
11
|
+
shape?: 'arrow';
|
|
12
12
|
/** Coordinate frame stored in the source SPZ payload. */
|
|
13
13
|
sourceCoordinateSystem?: SPZCoordinateSystem;
|
|
14
14
|
/** Coordinate frame expected by the caller. Defaults to the source frame. */
|
package/src/unbundled.ts
CHANGED