@loaders.gl/splats 5.0.0-alpha.2 → 5.0.0-alpha.3

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.
@@ -4,7 +4,7 @@
4
4
  import { SPZFormat } from "./splats-format.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "5.0.0-alpha.2" !== 'undefined' ? "5.0.0-alpha.2" : 'latest';
7
+ const VERSION = typeof "5.0.0-alpha.3" !== 'undefined' ? "5.0.0-alpha.3" : 'latest';
8
8
  /** Preloads the parser-bearing SPZ loader implementation. */
9
9
  async function preload() {
10
10
  const { SPZLoaderWithParser } = await import("./spz-loader.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/splats",
3
- "version": "5.0.0-alpha.2",
3
+ "version": "5.0.0-alpha.3",
4
4
  "description": "Framework-independent loaders for Gaussian splat formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -78,9 +78,9 @@
78
78
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
79
79
  },
80
80
  "dependencies": {
81
- "@loaders.gl/compression": "5.0.0-alpha.2",
82
- "@loaders.gl/loader-utils": "5.0.0-alpha.2",
83
- "@loaders.gl/schema": "5.0.0-alpha.2",
81
+ "@loaders.gl/compression": "5.0.0-alpha.3",
82
+ "@loaders.gl/loader-utils": "5.0.0-alpha.3",
83
+ "@loaders.gl/schema": "5.0.0-alpha.3",
84
84
  "apache-arrow": ">= 17.0.0",
85
85
  "zod": "^4.1.12"
86
86
  },
@@ -90,5 +90,5 @@
90
90
  "peerDependencies": {
91
91
  "@loaders.gl/core": "~5.0.0-alpha.0"
92
92
  },
93
- "gitHead": "27bcc0db684abb66a83003263c9d1cafd9e5b2dd"
93
+ "gitHead": "6e6f532b04a2798191ee2d9a932ca73b7c7f3c8d"
94
94
  }
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {DeflateCompression} from '@loaders.gl/compression';
5
+ import {DeflateDecompressor} from '@loaders.gl/compression/deflate-decompressor';
6
6
  import type {MeshArrowTable} from '@loaders.gl/schema';
7
7
  import type {GaussianSplats, SplatsLoaderOptions} from '../types';
8
8
  import {
@@ -15,8 +15,8 @@ import {
15
15
  import {makeGaussianSplatsArrowTable} from './splats-arrow-table';
16
16
  import {decodeFloat16, normalizeQuaternion, SH_C0} from './splat-utils';
17
17
 
18
- const RAD_PROPERTY_DEFLATE = new DeflateCompression();
19
- const RAD_PROPERTY_RAW_DEFLATE = new DeflateCompression({raw: true});
18
+ const RAD_PROPERTY_DEFLATE = new DeflateDecompressor({useNative: false});
19
+ const RAD_PROPERTY_RAW_DEFLATE = new DeflateDecompressor({raw: true, useNative: false});
20
20
 
21
21
  /** Options for decoding one Spark RADC chunk payload. */
22
22
  export type RADChunkDecodeOptions = SplatsLoaderOptions & {
@@ -2,8 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {decompressWithNativeDecompressionStream} from '@loaders.gl/compression/native-decompression';
6
- import {getJSModuleOrNull, registerJSModules} from '@loaders.gl/loader-utils';
5
+ import {ZstdDecompressor} from '@loaders.gl/compression';
7
6
  import type {MeshArrowTable} from '@loaders.gl/schema';
8
7
  import type {GaussianSplats, SplatsLoaderOptions} from '../types';
9
8
  import {makeGaussianSplatsArrowTable} from './splats-arrow-table';
@@ -52,24 +51,10 @@ export async function parseSPZToGaussianSplats(
52
51
  const compressedStreams = streamInfos.map(streamInfo =>
53
52
  data.slice(streamInfo.compressedOffset, streamInfo.compressedOffset + streamInfo.compressedSize)
54
53
  );
55
- registerJSModules(options?.modules);
56
- const useNativeDecompressionStream = !getJSModuleOrNull('zstd-codec');
57
- let compressionPromise:
58
- | Promise<{
59
- decompress(input: ArrayBuffer, size?: number): Promise<ArrayBuffer>;
60
- }>
61
- | undefined;
54
+ const decompressor = new ZstdDecompressor({modules: options?.modules});
62
55
  const streams = await Promise.all(
63
56
  compressedStreams.map((compressedStream, streamIndex) =>
64
- decompressSPZStream(
65
- compressedStream,
66
- streamInfos[streamIndex].uncompressedSize,
67
- useNativeDecompressionStream,
68
- () => {
69
- compressionPromise ||= createZstdCompression(options?.modules);
70
- return compressionPromise;
71
- }
72
- )
57
+ decompressor.decompress(compressedStream, streamInfos[streamIndex].uncompressedSize)
73
58
  )
74
59
  );
75
60
 
@@ -77,45 +62,6 @@ export async function parseSPZToGaussianSplats(
77
62
  return decodeSPZStreams(header, streams, data);
78
63
  }
79
64
 
80
- /**
81
- * Decompresses one SPZ stream natively when available, then lazily loads the codec fallback.
82
- *
83
- * @param compressedStream Compressed Zstandard stream.
84
- * @param uncompressedSize Expected uncompressed byte length.
85
- * @param useNativeDecompressionStream Whether no provided codec should take precedence.
86
- * @param getCompression Lazily resolves the codec-backed Zstandard implementation.
87
- * @returns Decompressed stream bytes.
88
- */
89
- async function decompressSPZStream(
90
- compressedStream: ArrayBuffer,
91
- uncompressedSize: number,
92
- useNativeDecompressionStream: boolean,
93
- getCompression: () => Promise<{
94
- decompress(input: ArrayBuffer, size?: number): Promise<ArrayBuffer>;
95
- }>
96
- ): Promise<ArrayBuffer> {
97
- if (useNativeDecompressionStream) {
98
- const nativeOutput = await decompressWithNativeDecompressionStream(compressedStream, 'zstd');
99
- if (nativeOutput) {
100
- return nativeOutput;
101
- }
102
- }
103
-
104
- const compression = await getCompression();
105
- return await compression.decompress(compressedStream, uncompressedSize);
106
- }
107
-
108
- /**
109
- * Dynamically loads the codec-backed Zstandard class for unsupported native runtimes.
110
- *
111
- * @param modules Optional registered codec modules.
112
- * @returns Codec-backed Zstandard implementation.
113
- */
114
- async function createZstdCompression(modules?: {[key: string]: any}) {
115
- const {ZstdCompression} = await import('@loaders.gl/compression/zstd-compression');
116
- return new ZstdCompression({modules});
117
- }
118
-
119
65
  /** Parses and validates the SPZ v4 plaintext header. */
120
66
  function parseSPZHeader(data: ArrayBuffer): SPZHeader {
121
67
  if (data.byteLength < SPZ_HEADER_BYTE_LENGTH) {