@loaders.gl/splats 5.0.0-beta.1 → 5.0.0-beta.10

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.
Files changed (73) hide show
  1. package/README.md +4 -2
  2. package/dist/bundled.d.ts +1 -1
  3. package/dist/bundled.d.ts.map +1 -1
  4. package/dist/bundled.js +1 -1
  5. package/dist/bundled.js.map +1 -1
  6. package/dist/dist.dev.js +532 -396
  7. package/dist/dist.min.js +20 -20
  8. package/dist/index.cjs +422 -337
  9. package/dist/index.cjs.map +3 -3
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/ksplat-loader-types.d.ts +11 -7
  15. package/dist/ksplat-loader-types.d.ts.map +1 -1
  16. package/dist/ksplat-loader-types.js +4 -2
  17. package/dist/ksplat-loader-types.js.map +1 -1
  18. package/dist/ksplat-loader.d.ts +7 -5
  19. package/dist/ksplat-loader.d.ts.map +1 -1
  20. package/dist/ksplat-loader.js +2 -2
  21. package/dist/ksplat-loader.js.map +1 -1
  22. package/dist/lib/splats-arrow-table.d.ts.map +1 -1
  23. package/dist/lib/splats-arrow-table.js +8 -0
  24. package/dist/lib/splats-arrow-table.js.map +1 -1
  25. package/dist/rad-loader-types.d.ts +5 -0
  26. package/dist/rad-loader-types.d.ts.map +1 -1
  27. package/dist/rad-loader-types.js +3 -1
  28. package/dist/rad-loader-types.js.map +1 -1
  29. package/dist/rad-loader.d.ts +4 -0
  30. package/dist/rad-loader.d.ts.map +1 -1
  31. package/dist/rad-loader.js +2 -0
  32. package/dist/rad-loader.js.map +1 -1
  33. package/dist/rad-source-loader.d.ts +2 -33
  34. package/dist/rad-source-loader.d.ts.map +1 -1
  35. package/dist/rad-source-loader.js +9 -32
  36. package/dist/rad-source-loader.js.map +1 -1
  37. package/dist/splat-loader-types.d.ts +11 -7
  38. package/dist/splat-loader-types.d.ts.map +1 -1
  39. package/dist/splat-loader-types.js +4 -2
  40. package/dist/splat-loader-types.js.map +1 -1
  41. package/dist/splat-loader.d.ts +7 -5
  42. package/dist/splat-loader.d.ts.map +1 -1
  43. package/dist/splat-loader.js +2 -2
  44. package/dist/splat-loader.js.map +1 -1
  45. package/dist/spz-loader-types.d.ts +10 -6
  46. package/dist/spz-loader-types.d.ts.map +1 -1
  47. package/dist/spz-loader-types.js +4 -2
  48. package/dist/spz-loader-types.js.map +1 -1
  49. package/dist/spz-loader.d.ts +6 -4
  50. package/dist/spz-loader.d.ts.map +1 -1
  51. package/dist/spz-loader.js +1 -1
  52. package/dist/spz-loader.js.map +1 -1
  53. package/dist/types.d.ts +2 -2
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/unbundled.d.ts +1 -1
  56. package/dist/unbundled.d.ts.map +1 -1
  57. package/dist/unbundled.js +1 -1
  58. package/dist/unbundled.js.map +1 -1
  59. package/package.json +8 -5
  60. package/src/bundled.ts +1 -1
  61. package/src/index.ts +1 -1
  62. package/src/ksplat-loader-types.ts +6 -4
  63. package/src/ksplat-loader.ts +4 -4
  64. package/src/lib/splats-arrow-table.ts +11 -0
  65. package/src/rad-loader-types.ts +2 -0
  66. package/src/rad-loader.ts +2 -0
  67. package/src/rad-source-loader.ts +15 -41
  68. package/src/splat-loader-types.ts +6 -4
  69. package/src/splat-loader.ts +4 -4
  70. package/src/spz-loader-types.ts +6 -4
  71. package/src/spz-loader.ts +3 -3
  72. package/src/types.ts +2 -2
  73. package/src/unbundled.ts +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/splats",
3
- "version": "5.0.0-beta.1",
4
- "description": "Framework-independent loaders for Gaussian splat formats",
3
+ "version": "5.0.0-beta.10",
4
+ "description": "Gaussian splat loaders for SPLAT, KSPLAT, SPZ, and RAD",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -18,7 +18,10 @@
18
18
  "point cloud",
19
19
  "gaussian splats",
20
20
  "splat",
21
- "ksplat"
21
+ "ksplat",
22
+ "loaders.gl",
23
+ "SPZ",
24
+ "RAD"
22
25
  ],
23
26
  "types": "dist/index.d.ts",
24
27
  "main": "dist/index.cjs",
@@ -80,7 +83,7 @@
80
83
  "build-bundle-dev": "node ../../scripts/build-codec-bundle.mjs ./bundle.ts --env=dev --output=dist/dist.dev.js"
81
84
  },
82
85
  "dependencies": {
83
- "@loaders.gl/compression": "5.0.0-beta.1",
86
+ "@loaders.gl/compression": "5.0.0-beta.10",
84
87
  "apache-arrow": ">= 17.0.0",
85
88
  "zod": "^4.1.12"
86
89
  },
@@ -90,5 +93,5 @@
90
93
  "peerDependencies": {
91
94
  "@loaders.gl/core": "~5.0.0-alpha.0"
92
95
  },
93
- "gitHead": "89312301ed9e8ec89a58501c052a38284d1570c1"
96
+ "gitHead": "efdd84034c25e2e5dbb41bc88b75af56cb2176da"
94
97
  }
package/src/bundled.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export {SPLATLoader, KSPLATLoader, SPZLoader, RADLoader, RADSourceLoader} from './index';
5
+ export {SPLATLoader, KSPLATLoader, SPZLoader, RADLoader} from './index';
package/src/index.ts CHANGED
@@ -26,4 +26,4 @@ export type {
26
26
  RADChunkTableIteratorOptions,
27
27
  RADSourceLoaderOptions
28
28
  } from './rad-source-loader';
29
- export {RADSource, RADSourceLoader, resolveRADChunkUrl} from './rad-source-loader';
29
+ export {RADSource, resolveRADChunkUrl} from './rad-source-loader';
@@ -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 {MeshArrowTable} from '@loaders.gl/core/schema';
6
+ import type {Table} from 'apache-arrow';
7
7
  import type {SplatsLoaderOptions} from './types';
8
8
  import {KSPLATFormat} from './splats-format';
9
9
 
@@ -19,14 +19,16 @@ async function preload() {
19
19
 
20
20
  /** Metadata-only loader for `.ksplat` Gaussian splat files. */
21
21
  export const KSPLATLoader = {
22
- dataType: null as unknown as MeshArrowTable,
22
+ defaultShape: 'arrow',
23
+ supportsNativeArrow: true,
24
+ dataType: null as unknown as Table,
23
25
  batchType: null as never,
24
26
  ...KSPLATFormat,
25
27
  version: VERSION,
26
28
  options: {
27
29
  splats: {
28
- shape: 'arrow-table'
30
+ shape: 'arrow'
29
31
  }
30
32
  },
31
33
  preload
32
- } as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;
34
+ } as const satisfies Loader<Table, never, SplatsLoaderOptions>;
@@ -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 {MeshArrowTable} from '@loaders.gl/core/schema';
6
+ import type {Table} from 'apache-arrow';
7
7
  import type {SplatsLoaderOptions} from './types';
8
8
  import {parseKSPLAT} from './lib/parse-ksplat';
9
9
  import {KSPLATLoader as KSPLATLoaderMetadata} from './ksplat-loader-types';
@@ -13,6 +13,6 @@ const {preload: _KSPLATLoaderPreload, ...KSPLATLoaderMetadataWithoutPreload} = K
13
13
  /** Parser-bearing loader for `.ksplat` Gaussian splat files. */
14
14
  export const KSPLATLoaderWithParser = {
15
15
  ...KSPLATLoaderMetadataWithoutPreload,
16
- parse: async (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer),
17
- parseSync: (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer)
18
- } as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;
16
+ parse: async (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer).data,
17
+ parseSync: (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer).data
18
+ } as const satisfies LoaderWithParser<Table, never, SplatsLoaderOptions>;
@@ -3,6 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import * as arrow from 'apache-arrow';
6
+ import {encodeArrayBufferToBase64} from '@loaders.gl/core/loader-utils';
6
7
  import type {Field, MeshArrowTable, Schema} from '@loaders.gl/core/schema';
7
8
  import type {GaussianSplats} from '../types';
8
9
  import {convertColorByteToSphericalHarmonicDc} from './splat-utils';
@@ -73,6 +74,16 @@ export function makeGaussianSplatsArrowTable(splats: GaussianSplats): MeshArrowT
73
74
  ['topology', 'point-list'],
74
75
  ['mode', '0']
75
76
  ]);
77
+ if (splats.format !== 'rad' && splats.loaderData) {
78
+ const {extensionBytes, ...header} = splats.loaderData;
79
+ metadata.set('loaders_gl.gaussian_splats.loader_data', JSON.stringify(header));
80
+ if (extensionBytes instanceof Uint8Array) {
81
+ metadata.set(
82
+ 'loaders_gl.gaussian_splats.extension_bytes',
83
+ encodeArrayBufferToBase64(extensionBytes.slice().buffer)
84
+ );
85
+ }
86
+ }
76
87
  const arrowSchema = new arrow.Schema(fields, metadata);
77
88
  const schema: Schema = {
78
89
  fields: schemaFields,
@@ -23,5 +23,7 @@ export const RADLoader = {
23
23
  ...RADFormat,
24
24
  version: VERSION,
25
25
  options: {},
26
+ fromUrl: true,
27
+ fromBlob: true,
26
28
  preload
27
29
  } as const satisfies Loader<RADMetadata, never, LoaderOptions>;
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)
@@ -2,10 +2,9 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import type {CoreAPI, DataSourceOptions, SourceLoader} from '@loaders.gl/core/loader-utils';
5
+ import type {CoreAPI, DataSourceOptions} from '@loaders.gl/core/loader-utils';
6
6
  import {DataSource} from '@loaders.gl/core/loader-utils';
7
7
  import type {MeshArrowTable} from '@loaders.gl/core/schema';
8
- import {RADFormat} from './splats-format';
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
- /** Source factory for Spark `.rad` paged LoD Gaussian splat containers. */
65
- export const RADSourceLoader = {
66
- dataType: null as unknown as RADSource,
67
- batchType: null as never,
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
- testURL: (url: string): boolean => /\.rad(?:$|[?#])/i.test(url),
92
- createDataSource: (
93
- data: string | Blob,
94
- options: RADSourceLoaderOptions,
95
- coreApi?: CoreAPI
96
- ): RADSource => new RADSource(data, options, coreApi)
97
- } as const satisfies SourceLoader<RADSource>;
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, RADSourceLoader.defaultOptions, coreApi);
84
+ super(data, options, RAD_SOURCE_DEFAULT_OPTIONS, coreApi);
111
85
  this.metadata = this.getMetadata();
112
86
  }
113
87
 
@@ -363,7 +337,7 @@ export class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions>
363
337
 
364
338
  /** Returns true when source options supplied an explicit fetch override. */
365
339
  private _hasCustomFetch(): boolean {
366
- return Boolean(this.loadOptions?.core?.fetch || this.loadOptions?.fetch);
340
+ return Boolean(this.loadOptions?.core?.fetch);
367
341
  }
368
342
 
369
343
  /** 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 {MeshArrowTable} from '@loaders.gl/core/schema';
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
- dataType: null as unknown as MeshArrowTable,
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-table'
30
+ shape: 'arrow'
29
31
  }
30
32
  },
31
33
  preload
32
- } as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;
34
+ } as const satisfies Loader<Table, never, SplatsLoaderOptions>;
@@ -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 {MeshArrowTable} from '@loaders.gl/core/schema';
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';
@@ -13,6 +13,6 @@ const {preload: _SPLATLoaderPreload, ...SPLATLoaderMetadataWithoutPreload} = SPL
13
13
  /** Parser-bearing loader for raw `.splat` Gaussian splat files. */
14
14
  export const SPLATLoaderWithParser = {
15
15
  ...SPLATLoaderMetadataWithoutPreload,
16
- parse: async (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer),
17
- parseSync: (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer)
18
- } as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;
16
+ parse: async (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer).data,
17
+ parseSync: (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer).data
18
+ } as const satisfies LoaderWithParser<Table, never, SplatsLoaderOptions>;
@@ -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 {MeshArrowTable} from '@loaders.gl/core/schema';
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
- dataType: null as unknown as MeshArrowTable,
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-table'
30
+ shape: 'arrow'
29
31
  }
30
32
  },
31
33
  preload
32
- } as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;
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 {MeshArrowTable} from '@loaders.gl/core/schema';
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';
@@ -14,5 +14,5 @@ const {preload: _SPZLoaderPreload, ...SPZLoaderMetadataWithoutPreload} = SPZLoad
14
14
  export const SPZLoaderWithParser = {
15
15
  ...SPZLoaderMetadataWithoutPreload,
16
16
  parse: async (arrayBuffer: ArrayBuffer, options?: SplatsLoaderOptions) =>
17
- parseSPZ(arrayBuffer, options)
18
- } as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;
17
+ (await parseSPZ(arrayBuffer, options)).data
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. V1 supports loaders.gl Mesh Arrow tables. */
11
- shape?: 'arrow-table';
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
@@ -2,4 +2,4 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export {SPLATLoader, KSPLATLoader, SPZLoader, RADLoader, RADSourceLoader} from './index';
5
+ export {SPLATLoader, KSPLATLoader, SPZLoader, RADLoader} from './index';