@loaders.gl/splats 5.0.0-alpha.1

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 (112) hide show
  1. package/LICENSE +41 -0
  2. package/README.md +3 -0
  3. package/dist/bundled.d.ts +2 -0
  4. package/dist/bundled.d.ts.map +1 -0
  5. package/dist/bundled.js +5 -0
  6. package/dist/bundled.js.map +1 -0
  7. package/dist/dist.dev.js +20876 -0
  8. package/dist/dist.min.js +18 -0
  9. package/dist/index.cjs +2046 -0
  10. package/dist/index.cjs.map +7 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +10 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/ksplat-loader-types.d.ts +42 -0
  16. package/dist/ksplat-loader-types.d.ts.map +1 -0
  17. package/dist/ksplat-loader-types.js +26 -0
  18. package/dist/ksplat-loader-types.js.map +1 -0
  19. package/dist/ksplat-loader.d.ts +22 -0
  20. package/dist/ksplat-loader.d.ts.map +1 -0
  21. package/dist/ksplat-loader.js +13 -0
  22. package/dist/ksplat-loader.js.map +1 -0
  23. package/dist/lib/parse-ksplat.d.ts +7 -0
  24. package/dist/lib/parse-ksplat.d.ts.map +1 -0
  25. package/dist/lib/parse-ksplat.js +312 -0
  26. package/dist/lib/parse-ksplat.js.map +1 -0
  27. package/dist/lib/parse-rad-chunk.d.ts +19 -0
  28. package/dist/lib/parse-rad-chunk.d.ts.map +1 -0
  29. package/dist/lib/parse-rad-chunk.js +514 -0
  30. package/dist/lib/parse-rad-chunk.js.map +1 -0
  31. package/dist/lib/parse-rad.d.ts +120 -0
  32. package/dist/lib/parse-rad.d.ts.map +1 -0
  33. package/dist/lib/parse-rad.js +235 -0
  34. package/dist/lib/parse-rad.js.map +1 -0
  35. package/dist/lib/parse-splat.d.ts +7 -0
  36. package/dist/lib/parse-splat.d.ts.map +1 -0
  37. package/dist/lib/parse-splat.js +58 -0
  38. package/dist/lib/parse-splat.js.map +1 -0
  39. package/dist/lib/parse-spz.d.ts +7 -0
  40. package/dist/lib/parse-spz.d.ts.map +1 -0
  41. package/dist/lib/parse-spz.js +268 -0
  42. package/dist/lib/parse-spz.js.map +1 -0
  43. package/dist/lib/splat-utils.d.ts +12 -0
  44. package/dist/lib/splat-utils.d.ts.map +1 -0
  45. package/dist/lib/splat-utils.js +38 -0
  46. package/dist/lib/splat-utils.js.map +1 -0
  47. package/dist/lib/splats-arrow-table.d.ts +5 -0
  48. package/dist/lib/splats-arrow-table.d.ts.map +1 -0
  49. package/dist/lib/splats-arrow-table.js +132 -0
  50. package/dist/lib/splats-arrow-table.js.map +1 -0
  51. package/dist/rad-loader-types.d.ts +36 -0
  52. package/dist/rad-loader-types.d.ts.map +1 -0
  53. package/dist/rad-loader-types.js +22 -0
  54. package/dist/rad-loader-types.js.map +1 -0
  55. package/dist/rad-loader.d.ts +21 -0
  56. package/dist/rad-loader.d.ts.map +1 -0
  57. package/dist/rad-loader.js +15 -0
  58. package/dist/rad-loader.js.map +1 -0
  59. package/dist/rad-source-loader.d.ts +115 -0
  60. package/dist/rad-source-loader.d.ts.map +1 -0
  61. package/dist/rad-source-loader.js +338 -0
  62. package/dist/rad-source-loader.js.map +1 -0
  63. package/dist/splat-loader-types.d.ts +42 -0
  64. package/dist/splat-loader-types.d.ts.map +1 -0
  65. package/dist/splat-loader-types.js +26 -0
  66. package/dist/splat-loader-types.js.map +1 -0
  67. package/dist/splat-loader.d.ts +22 -0
  68. package/dist/splat-loader.d.ts.map +1 -0
  69. package/dist/splat-loader.js +13 -0
  70. package/dist/splat-loader.js.map +1 -0
  71. package/dist/splats-format.d.ts +43 -0
  72. package/dist/splats-format.d.ts.map +1 -0
  73. package/dist/splats-format.js +46 -0
  74. package/dist/splats-format.js.map +1 -0
  75. package/dist/spz-loader-types.d.ts +44 -0
  76. package/dist/spz-loader-types.d.ts.map +1 -0
  77. package/dist/spz-loader-types.js +26 -0
  78. package/dist/spz-loader-types.js.map +1 -0
  79. package/dist/spz-loader.d.ts +23 -0
  80. package/dist/spz-loader.d.ts.map +1 -0
  81. package/dist/spz-loader.js +12 -0
  82. package/dist/spz-loader.js.map +1 -0
  83. package/dist/types.d.ts +34 -0
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/types.js +5 -0
  86. package/dist/types.js.map +1 -0
  87. package/dist/unbundled.d.ts +2 -0
  88. package/dist/unbundled.d.ts.map +1 -0
  89. package/dist/unbundled.js +5 -0
  90. package/dist/unbundled.js.map +1 -0
  91. package/package.json +85 -0
  92. package/src/bundled.ts +5 -0
  93. package/src/index.ts +26 -0
  94. package/src/ksplat-loader-types.ts +32 -0
  95. package/src/ksplat-loader.ts +18 -0
  96. package/src/lib/parse-ksplat.ts +538 -0
  97. package/src/lib/parse-rad-chunk.ts +721 -0
  98. package/src/lib/parse-rad.ts +439 -0
  99. package/src/lib/parse-splat.ts +77 -0
  100. package/src/lib/parse-spz.ts +368 -0
  101. package/src/lib/splat-utils.ts +49 -0
  102. package/src/lib/splats-arrow-table.ts +188 -0
  103. package/src/rad-loader-types.ts +27 -0
  104. package/src/rad-loader.ts +24 -0
  105. package/src/rad-source-loader.ts +504 -0
  106. package/src/splat-loader-types.ts +32 -0
  107. package/src/splat-loader.ts +18 -0
  108. package/src/splats-format.ts +51 -0
  109. package/src/spz-loader-types.ts +32 -0
  110. package/src/spz-loader.ts +18 -0
  111. package/src/types.ts +39 -0
  112. package/src/unbundled.ts +5 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/splats-format.ts", "../src/lib/splat-utils.ts", "../src/lib/splats-arrow-table.ts", "../src/lib/parse-splat.ts", "../src/splat-loader.ts", "../src/splat-loader-types.ts", "../src/lib/parse-ksplat.ts", "../src/ksplat-loader.ts", "../src/ksplat-loader-types.ts", "../src/lib/parse-spz.ts", "../src/spz-loader.ts", "../src/spz-loader-types.ts", "../src/lib/parse-rad.ts", "../src/lib/parse-rad-chunk.ts", "../src/rad-loader.ts", "../src/rad-loader-types.ts", "../src/index.ts", "../src/rad-source-loader.ts"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Format} from '@loaders.gl/loader-utils';\n\n/** SPLAT - raw binary Gaussian splat format. */\nexport const SPLATFormat = {\n name: 'SPLAT',\n id: 'splat',\n module: 'splats',\n format: 'splat',\n extensions: ['splat'],\n mimeTypes: ['application/octet-stream'],\n binary: true\n} as const satisfies Format;\n\n/** KSPLAT - GaussianSplats3D optimized Gaussian splat format. */\nexport const KSPLATFormat = {\n name: 'KSPLAT',\n id: 'ksplat',\n module: 'splats',\n format: 'ksplat',\n extensions: ['ksplat'],\n mimeTypes: ['application/octet-stream'],\n binary: true\n} as const satisfies Format;\n\n/** SPZ - Niantic Spatial compressed Gaussian splat format. */\nexport const SPZFormat = {\n name: 'SPZ',\n id: 'spz',\n module: 'splats',\n format: 'spz',\n extensions: ['spz'],\n mimeTypes: ['application/octet-stream'],\n binary: true,\n tests: [new Uint8Array([0x4e, 0x47, 0x53, 0x50]).buffer]\n} as const satisfies Format;\n\n/** RAD - Spark paged level-of-detail Gaussian splat container. */\nexport const RADFormat = {\n name: 'RAD',\n id: 'rad',\n module: 'splats',\n format: 'rad',\n extensions: ['rad'],\n mimeTypes: ['application/octet-stream'],\n binary: true,\n tests: [new Uint8Array([0x52, 0x41, 0x44, 0x30]).buffer]\n} as const satisfies Format;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport const SH_C0 = 0.28209479177387814;\n\n/** Converts a normalized RGB value to a spherical harmonic DC coefficient. */\nexport function convertColorByteToSphericalHarmonicDc(colorByte: number): number {\n return (colorByte / 255 - 0.5) / SH_C0;\n}\n\n/** Converts an unorm8 alpha byte to linear opacity. */\nexport function convertAlphaByteToLinearOpacity(alphaByte: number): number {\n return Math.min(Math.max(alphaByte / 255, 0), 1);\n}\n\n/** Returns a normalized quaternion, falling back to identity when invalid. */\nexport function normalizeQuaternion(\n w: number,\n x: number,\n y: number,\n z: number\n): [number, number, number, number] {\n const length = Math.hypot(w, x, y, z);\n if (!Number.isFinite(length) || length <= Number.EPSILON) {\n return [1, 0, 0, 0];\n }\n return [w / length, x / length, y / length, z / length];\n}\n\n/** Decodes the GaussianSplats3D uint8 quaternion component encoding. */\nexport function decodeQuaternionByte(byte: number): number {\n return (byte - 128) / 128;\n}\n\n/** Decodes an IEEE 754 binary16 value. */\nexport function decodeFloat16(value: number): number {\n const sign = value & 0x8000 ? -1 : 1;\n const exponent = (value >> 10) & 0x1f;\n const fraction = value & 0x03ff;\n\n if (exponent === 0) {\n return sign * Math.pow(2, -14) * (fraction / 1024);\n }\n if (exponent === 0x1f) {\n return fraction ? Number.NaN : sign * Number.POSITIVE_INFINITY;\n }\n return sign * Math.pow(2, exponent - 15) * (1 + fraction / 1024);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport type {Field, MeshArrowTable, Schema} from '@loaders.gl/schema';\nimport type {GaussianSplats} from '../types';\nimport {convertColorByteToSphericalHarmonicDc} from './splat-utils';\n\n/** Builds a Mesh Arrow table from decoded Gaussian splat values. */\nexport function makeGaussianSplatsArrowTable(splats: GaussianSplats): MeshArrowTable {\n const columns: Record<string, arrow.Vector> = {};\n const fields: arrow.Field[] = [];\n const schemaFields: Field[] = [];\n\n addColumn(\n columns,\n fields,\n schemaFields,\n 'POSITION',\n makeFixedSizeListVector(splats.positions, 3),\n {\n type: 'fixed-size-list',\n listSize: 3,\n children: [{name: 'value', type: 'float32'}]\n }\n );\n\n const colorCoefficients = getColorCoefficients(splats);\n addScalarColumn(columns, fields, schemaFields, 'f_dc_0', colorCoefficients[0], {\n 'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',\n 'loaders_gl.gaussian_splats.component': '0',\n 'loaders_gl.gaussian_splats.encoding': 'coefficient'\n });\n addScalarColumn(columns, fields, schemaFields, 'f_dc_1', colorCoefficients[1], {\n 'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',\n 'loaders_gl.gaussian_splats.component': '1',\n 'loaders_gl.gaussian_splats.encoding': 'coefficient'\n });\n addScalarColumn(columns, fields, schemaFields, 'f_dc_2', colorCoefficients[2], {\n 'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_dc',\n 'loaders_gl.gaussian_splats.component': '2',\n 'loaders_gl.gaussian_splats.encoding': 'coefficient'\n });\n\n addScalarColumn(columns, fields, schemaFields, 'opacity', splats.opacities, {\n 'loaders_gl.gaussian_splats.semantic': 'opacity',\n 'loaders_gl.gaussian_splats.encoding': 'linear'\n });\n addVectorComponents(columns, fields, schemaFields, 'scale', splats.scales, 3, {\n 'loaders_gl.gaussian_splats.semantic': 'scale',\n 'loaders_gl.gaussian_splats.encoding': 'linear'\n });\n addVectorComponents(columns, fields, schemaFields, 'rot', splats.rotations, 4, {\n 'loaders_gl.gaussian_splats.semantic': 'rotation',\n 'loaders_gl.gaussian_splats.encoding': 'quaternion'\n });\n\n if (splats.sphericalHarmonics && splats.sphericalHarmonicsComponentCount) {\n addSphericalHarmonicRestColumns(\n columns,\n fields,\n schemaFields,\n splats.sphericalHarmonics,\n splats.sphericalHarmonicsComponentCount\n );\n }\n\n const metadata = new Map<string, string>([\n ['loaders_gl.semantic_type', 'gaussian-splats'],\n ['loaders_gl.gaussian_splats.version', '1'],\n ['loaders_gl.gaussian_splats.source_format', splats.format],\n ['topology', 'point-list'],\n ['mode', '0']\n ]);\n const arrowSchema = new arrow.Schema(fields, metadata);\n const schema: Schema = {\n fields: schemaFields,\n metadata: Object.fromEntries(metadata)\n };\n\n return {\n shape: 'arrow-table',\n schema,\n data: new arrow.Table(arrowSchema, columns),\n topology: 'point-list',\n loaderData: splats.loaderData\n } as MeshArrowTable;\n}\n\n/** Adds one scalar Arrow column per component of an interleaved vector array. */\nfunction addVectorComponents(\n columns: Record<string, arrow.Vector>,\n fields: arrow.Field[],\n schemaFields: Field[],\n prefix: string,\n values: Float32Array,\n size: number,\n metadata: Record<string, string>\n): void {\n for (let component = 0; component < size; component++) {\n const componentValues = new Float32Array(values.length / size);\n for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {\n componentValues[rowIndex] = values[rowIndex * size + component];\n }\n addScalarColumn(columns, fields, schemaFields, `${prefix}_${component}`, componentValues, {\n ...metadata,\n 'loaders_gl.gaussian_splats.component': String(component)\n });\n }\n}\n\n/** Adds one scalar Arrow column per spherical harmonic rest component. */\nfunction addSphericalHarmonicRestColumns(\n columns: Record<string, arrow.Vector>,\n fields: arrow.Field[],\n schemaFields: Field[],\n sphericalHarmonics: Float32Array,\n componentCount: number\n): void {\n for (let component = 0; component < componentCount; component++) {\n const componentValues = new Float32Array(sphericalHarmonics.length / componentCount);\n for (let rowIndex = 0; rowIndex < componentValues.length; rowIndex++) {\n componentValues[rowIndex] = sphericalHarmonics[rowIndex * componentCount + component];\n }\n addScalarColumn(columns, fields, schemaFields, `f_rest_${component}`, componentValues, {\n 'loaders_gl.gaussian_splats.semantic': 'spherical_harmonic_rest',\n 'loaders_gl.gaussian_splats.component': String(component),\n 'loaders_gl.gaussian_splats.encoding': 'coefficient'\n });\n }\n}\n\n/** Adds a Float32 scalar Arrow column and matching loaders.gl schema field. */\nfunction addScalarColumn(\n columns: Record<string, arrow.Vector>,\n fields: arrow.Field[],\n schemaFields: Field[],\n name: string,\n values: Float32Array,\n metadata: Record<string, string>\n): void {\n addColumn(columns, fields, schemaFields, name, arrow.makeVector(values), 'float32', metadata);\n}\n\n/** Adds an Arrow column, Arrow field, and loaders.gl schema field. */\nfunction addColumn(\n columns: Record<string, arrow.Vector>,\n fields: arrow.Field[],\n schemaFields: Field[],\n name: string,\n column: arrow.Vector,\n schemaType: Field['type'],\n metadata: Record<string, string> = {}\n): void {\n columns[name] = column;\n fields.push(new arrow.Field(name, column.type, false, new Map(Object.entries(metadata))));\n schemaFields.push({name, type: schemaType, nullable: false, metadata});\n}\n\n/** Builds a FixedSizeList Arrow vector from an interleaved Float32 array. */\nfunction makeFixedSizeListVector(value: Float32Array, size: number): arrow.Vector {\n const values = arrow.makeVector(value);\n const child = values.data[0];\n const type = new arrow.FixedSizeList(size, new arrow.Field('value', child.type, false));\n const data = new arrow.Data(type, 0, value.length / size, 0, {}, [child]);\n return new arrow.Vector([data]);\n}\n\n/** Returns separate SH DC coefficient arrays from direct coefficients or RGB bytes. */\nfunction getColorCoefficients(splats: GaussianSplats): [Float32Array, Float32Array, Float32Array] {\n const rowCount = splats.splatCount;\n const fdc0 = new Float32Array(rowCount);\n const fdc1 = new Float32Array(rowCount);\n const fdc2 = new Float32Array(rowCount);\n for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n if (splats.sphericalHarmonicDcs) {\n fdc0[rowIndex] = splats.sphericalHarmonicDcs[rowIndex * 3 + 0];\n fdc1[rowIndex] = splats.sphericalHarmonicDcs[rowIndex * 3 + 1];\n fdc2[rowIndex] = splats.sphericalHarmonicDcs[rowIndex * 3 + 2];\n } else {\n fdc0[rowIndex] = convertColorByteToSphericalHarmonicDc(splats.colors[rowIndex * 3 + 0]);\n fdc1[rowIndex] = convertColorByteToSphericalHarmonicDc(splats.colors[rowIndex * 3 + 1]);\n fdc2[rowIndex] = convertColorByteToSphericalHarmonicDc(splats.colors[rowIndex * 3 + 2]);\n }\n }\n return [fdc0, fdc1, fdc2];\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {GaussianSplats} from '../types';\nimport {makeGaussianSplatsArrowTable} from './splats-arrow-table';\nimport {\n convertAlphaByteToLinearOpacity,\n decodeQuaternionByte,\n normalizeQuaternion\n} from './splat-utils';\n\nconst SPLAT_ROW_BYTE_LENGTH = 32;\n\n/** Parses a raw `.splat` ArrayBuffer into a Mesh Arrow table. */\nexport function parseSPLAT(data: ArrayBuffer): MeshArrowTable {\n return makeGaussianSplatsArrowTable(parseSPLATToGaussianSplats(data));\n}\n\n/** Parses a raw `.splat` ArrayBuffer into decoded Gaussian splat values. */\nexport function parseSPLATToGaussianSplats(data: ArrayBuffer): GaussianSplats {\n if (data.byteLength % SPLAT_ROW_BYTE_LENGTH !== 0) {\n throw new Error(`SPLATLoader: byte length must be a multiple of ${SPLAT_ROW_BYTE_LENGTH}.`);\n }\n\n const splatCount = data.byteLength / SPLAT_ROW_BYTE_LENGTH;\n const dataView = new DataView(data);\n const positions = new Float32Array(splatCount * 3);\n const scales = new Float32Array(splatCount * 3);\n const rotations = new Float32Array(splatCount * 4);\n const colors = new Uint8Array(splatCount * 3);\n const opacities = new Float32Array(splatCount);\n\n for (let splatIndex = 0; splatIndex < splatCount; splatIndex++) {\n const byteOffset = splatIndex * SPLAT_ROW_BYTE_LENGTH;\n const positionOffset = splatIndex * 3;\n const rotationOffset = splatIndex * 4;\n\n positions[positionOffset + 0] = dataView.getFloat32(byteOffset + 0, true);\n positions[positionOffset + 1] = dataView.getFloat32(byteOffset + 4, true);\n positions[positionOffset + 2] = dataView.getFloat32(byteOffset + 8, true);\n scales[positionOffset + 0] = dataView.getFloat32(byteOffset + 12, true);\n scales[positionOffset + 1] = dataView.getFloat32(byteOffset + 16, true);\n scales[positionOffset + 2] = dataView.getFloat32(byteOffset + 20, true);\n colors[positionOffset + 0] = dataView.getUint8(byteOffset + 24);\n colors[positionOffset + 1] = dataView.getUint8(byteOffset + 25);\n colors[positionOffset + 2] = dataView.getUint8(byteOffset + 26);\n opacities[splatIndex] = convertAlphaByteToLinearOpacity(dataView.getUint8(byteOffset + 27));\n\n const [w, x, y, z] = normalizeQuaternion(\n decodeQuaternionByte(dataView.getUint8(byteOffset + 28)),\n decodeQuaternionByte(dataView.getUint8(byteOffset + 29)),\n decodeQuaternionByte(dataView.getUint8(byteOffset + 30)),\n decodeQuaternionByte(dataView.getUint8(byteOffset + 31))\n );\n rotations[rotationOffset + 0] = w;\n rotations[rotationOffset + 1] = x;\n rotations[rotationOffset + 2] = y;\n rotations[rotationOffset + 3] = z;\n }\n\n return {\n format: 'splat',\n splatCount,\n positions,\n scales,\n rotations,\n colors,\n opacities,\n loaderData: {\n format: 'splat',\n splatCount,\n rowByteLength: SPLAT_ROW_BYTE_LENGTH\n }\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {parseSPLAT} from './lib/parse-splat';\nimport {SPLATLoader as SPLATLoaderMetadata} from './splat-loader-types';\n\nconst {preload: _SPLATLoaderPreload, ...SPLATLoaderMetadataWithoutPreload} = SPLATLoaderMetadata;\n\n/** Parser-bearing loader for raw `.splat` Gaussian splat files. */\nexport const SPLATLoaderWithParser = {\n ...SPLATLoaderMetadataWithoutPreload,\n parse: async (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer),\n parseSync: (arrayBuffer: ArrayBuffer) => parseSPLAT(arrayBuffer)\n} as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Loader} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {SPLATFormat} from './splats-format';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Preloads the parser-bearing SPLAT loader implementation. */\nasync function preload() {\n const {SPLATLoaderWithParser} = await import('./splat-loader');\n return SPLATLoaderWithParser;\n}\n\n/** Metadata-only loader for raw `.splat` Gaussian splat files. */\nexport const SPLATLoader = {\n dataType: null as unknown as MeshArrowTable,\n batchType: null as never,\n ...SPLATFormat,\n version: VERSION,\n options: {\n splats: {\n shape: 'arrow-table'\n }\n },\n preload\n} as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {GaussianSplats} from '../types';\nimport {makeGaussianSplatsArrowTable} from './splats-arrow-table';\nimport {convertAlphaByteToLinearOpacity, decodeFloat16, normalizeQuaternion} from './splat-utils';\n\nconst CURRENT_MAJOR_VERSION = 0;\nconst CURRENT_MINOR_VERSION = 1;\nconst HEADER_BYTE_LENGTH = 4096;\nconst SECTION_HEADER_BYTE_LENGTH = 1024;\nconst DEFAULT_SH_8BIT_COMPRESSION_RANGE = 3;\nconst DEFAULT_SH_8BIT_COMPRESSION_HALF_RANGE = DEFAULT_SH_8BIT_COMPRESSION_RANGE / 2;\n\ntype KSPLATHeader = {\n versionMajor: number;\n versionMinor: number;\n maxSectionCount: number;\n sectionCount: number;\n maxSplatCount: number;\n splatCount: number;\n compressionLevel: 0 | 1 | 2;\n minSphericalHarmonicsCoeff: number;\n maxSphericalHarmonicsCoeff: number;\n};\n\ntype KSPLATSection = {\n bytesPerSplat: number;\n splatCountOffset: number;\n splatCount: number;\n maxSplatCount: number;\n bucketSize: number;\n bucketCount: number;\n bucketStorageSizeBytes: number;\n bucketsStorageSizeBytes: number;\n compressionScaleRange: number;\n compressionScaleFactor: number;\n base: number;\n bucketsBase: number;\n dataBase: number;\n fullBucketCount: number;\n partiallyFilledBucketCount: number;\n sphericalHarmonicsDegree: number;\n};\n\ntype CompressionLayout = {\n bytesPerCenter: number;\n bytesPerScale: number;\n bytesPerRotation: number;\n bytesPerColor: number;\n scaleOffsetBytes: number;\n colorOffsetBytes: number;\n sphericalHarmonicsOffsetBytes: number;\n scaleRange: number;\n bytesPerSphericalHarmonicsComponent: number;\n};\n\nconst COMPRESSION_LAYOUTS: Record<0 | 1 | 2, CompressionLayout> = {\n 0: {\n bytesPerCenter: 12,\n bytesPerScale: 12,\n bytesPerRotation: 16,\n bytesPerColor: 4,\n scaleOffsetBytes: 12,\n colorOffsetBytes: 40,\n sphericalHarmonicsOffsetBytes: 44,\n scaleRange: 1,\n bytesPerSphericalHarmonicsComponent: 4\n },\n 1: {\n bytesPerCenter: 6,\n bytesPerScale: 6,\n bytesPerRotation: 8,\n bytesPerColor: 4,\n scaleOffsetBytes: 6,\n colorOffsetBytes: 20,\n sphericalHarmonicsOffsetBytes: 24,\n scaleRange: 32767,\n bytesPerSphericalHarmonicsComponent: 2\n },\n 2: {\n bytesPerCenter: 6,\n bytesPerScale: 6,\n bytesPerRotation: 8,\n bytesPerColor: 4,\n scaleOffsetBytes: 6,\n colorOffsetBytes: 20,\n sphericalHarmonicsOffsetBytes: 24,\n scaleRange: 32767,\n bytesPerSphericalHarmonicsComponent: 1\n }\n};\n\n/** Parses a `.ksplat` ArrayBuffer into a Mesh Arrow table. */\nexport function parseKSPLAT(data: ArrayBuffer): MeshArrowTable {\n return makeGaussianSplatsArrowTable(parseKSPLATToGaussianSplats(data));\n}\n\n/** Parses a `.ksplat` ArrayBuffer into decoded Gaussian splat values. */\nexport function parseKSPLATToGaussianSplats(data: ArrayBuffer): GaussianSplats {\n if (data.byteLength < HEADER_BYTE_LENGTH) {\n throw new Error(`KSPLATLoader: file must contain a ${HEADER_BYTE_LENGTH}-byte header.`);\n }\n\n const header = parseKSPLATHeader(data);\n checkKSPLATVersion(header);\n const sections = parseKSPLATSections(data, header);\n const splatCount = getTotalSplatCount(header, sections);\n const sphericalHarmonicsComponentCount = Math.max(\n 0,\n ...sections\n .slice(0, getActiveSectionCount(header))\n .map(section => getSphericalHarmonicsComponentCount(section.sphericalHarmonicsDegree))\n );\n\n const positions = new Float32Array(splatCount * 3);\n const scales = new Float32Array(splatCount * 3);\n const rotations = new Float32Array(splatCount * 4);\n const colors = new Uint8Array(splatCount * 3);\n const opacities = new Float32Array(splatCount);\n const sphericalHarmonics = sphericalHarmonicsComponentCount\n ? new Float32Array(splatCount * sphericalHarmonicsComponentCount)\n : undefined;\n\n let outputSplatIndex = 0;\n for (const section of sections.slice(0, getActiveSectionCount(header))) {\n validateSectionBounds(data, section);\n for (\n let localSplatIndex = 0;\n localSplatIndex < section.splatCount && outputSplatIndex < splatCount;\n localSplatIndex++\n ) {\n decodeKSPLATSplat(\n data,\n header,\n section,\n localSplatIndex,\n outputSplatIndex,\n positions,\n scales,\n rotations,\n colors,\n opacities,\n sphericalHarmonics,\n sphericalHarmonicsComponentCount\n );\n outputSplatIndex++;\n }\n }\n\n return {\n format: 'ksplat',\n splatCount,\n positions,\n scales,\n rotations,\n colors,\n opacities,\n sphericalHarmonics,\n sphericalHarmonicsComponentCount,\n loaderData: {\n format: 'ksplat',\n ...header,\n sections: sections.slice(0, getActiveSectionCount(header)).map(section => ({\n splatCount: section.splatCount,\n maxSplatCount: section.maxSplatCount,\n sphericalHarmonicsDegree: section.sphericalHarmonicsDegree\n }))\n }\n };\n}\n\n/** Decodes one KSPLAT record into the shared Gaussian splat arrays. */\nfunction decodeKSPLATSplat(\n data: ArrayBuffer,\n header: KSPLATHeader,\n section: KSPLATSection,\n localSplatIndex: number,\n outputSplatIndex: number,\n positions: Float32Array,\n scales: Float32Array,\n rotations: Float32Array,\n colors: Uint8Array,\n opacities: Float32Array,\n sphericalHarmonics: Float32Array | undefined,\n sphericalHarmonicsComponentCount: number\n): void {\n const layout = COMPRESSION_LAYOUTS[header.compressionLevel];\n const splatBase = section.dataBase + section.bytesPerSplat * localSplatIndex;\n const positionOffset = outputSplatIndex * 3;\n const rotationOffset = outputSplatIndex * 4;\n const bucketCenter = getBucketCenter(data, section, localSplatIndex);\n\n positions[positionOffset + 0] = decodeKSPLATCenterComponent(\n data,\n splatBase,\n 0,\n header,\n section,\n bucketCenter[0]\n );\n positions[positionOffset + 1] = decodeKSPLATCenterComponent(\n data,\n splatBase,\n 1,\n header,\n section,\n bucketCenter[1]\n );\n positions[positionOffset + 2] = decodeKSPLATCenterComponent(\n data,\n splatBase,\n 2,\n header,\n section,\n bucketCenter[2]\n );\n\n scales[positionOffset + 0] = readCompressedFloat(\n data,\n splatBase + layout.scaleOffsetBytes,\n 0,\n header.compressionLevel\n );\n scales[positionOffset + 1] = readCompressedFloat(\n data,\n splatBase + layout.scaleOffsetBytes,\n 1,\n header.compressionLevel\n );\n scales[positionOffset + 2] = readCompressedFloat(\n data,\n splatBase + layout.scaleOffsetBytes,\n 2,\n header.compressionLevel\n );\n\n const [w, x, y, z] = normalizeQuaternion(\n readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 3, header.compressionLevel),\n readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 4, header.compressionLevel),\n readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 5, header.compressionLevel),\n readCompressedFloat(data, splatBase + layout.scaleOffsetBytes, 6, header.compressionLevel)\n );\n rotations[rotationOffset + 0] = w;\n rotations[rotationOffset + 1] = x;\n rotations[rotationOffset + 2] = y;\n rotations[rotationOffset + 3] = z;\n\n const colorBase = splatBase + layout.colorOffsetBytes;\n const colorView = new Uint8Array(data, colorBase, 4);\n colors[positionOffset + 0] = colorView[0];\n colors[positionOffset + 1] = colorView[1];\n colors[positionOffset + 2] = colorView[2];\n opacities[outputSplatIndex] = convertAlphaByteToLinearOpacity(colorView[3]);\n\n if (sphericalHarmonics && sphericalHarmonicsComponentCount) {\n decodeSphericalHarmonics(\n data,\n splatBase + layout.sphericalHarmonicsOffsetBytes,\n header,\n section,\n outputSplatIndex,\n sphericalHarmonics,\n sphericalHarmonicsComponentCount\n );\n }\n}\n\n/** Reads and validates the fixed-size KSPLAT global header. */\nfunction parseKSPLATHeader(data: ArrayBuffer): KSPLATHeader {\n const dataView = new DataView(data, 0, HEADER_BYTE_LENGTH);\n const compressionLevel = dataView.getUint16(20, true);\n if (compressionLevel !== 0 && compressionLevel !== 1 && compressionLevel !== 2) {\n throw new Error(`KSPLATLoader: unsupported compression level ${compressionLevel}.`);\n }\n return {\n versionMajor: dataView.getUint8(0),\n versionMinor: dataView.getUint8(1),\n maxSectionCount: dataView.getUint32(4, true),\n sectionCount: dataView.getUint32(8, true),\n maxSplatCount: dataView.getUint32(12, true),\n splatCount: dataView.getUint32(16, true),\n compressionLevel,\n minSphericalHarmonicsCoeff:\n dataView.getFloat32(36, true) || -DEFAULT_SH_8BIT_COMPRESSION_HALF_RANGE,\n maxSphericalHarmonicsCoeff:\n dataView.getFloat32(40, true) || DEFAULT_SH_8BIT_COMPRESSION_HALF_RANGE\n };\n}\n\n/** Throws when the KSPLAT version is older than the supported SplatBuffer version. */\nfunction checkKSPLATVersion(header: KSPLATHeader): void {\n if (\n header.versionMajor === CURRENT_MAJOR_VERSION\n ? header.versionMinor >= CURRENT_MINOR_VERSION\n : header.versionMajor > CURRENT_MAJOR_VERSION\n ) {\n return;\n }\n throw new Error(\n `KSPLATLoader: version ${header.versionMajor}.${header.versionMinor} is not supported.`\n );\n}\n\n/** Reads all fixed-size KSPLAT section headers and derives their byte ranges. */\nfunction parseKSPLATSections(data: ArrayBuffer, header: KSPLATHeader): KSPLATSection[] {\n if (data.byteLength < HEADER_BYTE_LENGTH + header.maxSectionCount * SECTION_HEADER_BYTE_LENGTH) {\n throw new Error('KSPLATLoader: file does not contain all section headers.');\n }\n\n const sections: KSPLATSection[] = [];\n let sectionBase = HEADER_BYTE_LENGTH + header.maxSectionCount * SECTION_HEADER_BYTE_LENGTH;\n let splatCountOffset = 0;\n\n for (let sectionIndex = 0; sectionIndex < header.maxSectionCount; sectionIndex++) {\n const sectionHeaderBase = HEADER_BYTE_LENGTH + sectionIndex * SECTION_HEADER_BYTE_LENGTH;\n const dataView = new DataView(data, sectionHeaderBase, SECTION_HEADER_BYTE_LENGTH);\n const splatCount = dataView.getUint32(0, true);\n const maxSplatCount = dataView.getUint32(4, true);\n const bucketSize = dataView.getUint32(8, true);\n const bucketCount = dataView.getUint32(12, true);\n const bucketBlockSize = dataView.getFloat32(16, true);\n const bucketStorageSizeBytes = dataView.getUint16(20, true);\n const compressionScaleRange =\n dataView.getUint32(24, true) || COMPRESSION_LAYOUTS[header.compressionLevel].scaleRange;\n const fullBucketCount = dataView.getUint32(32, true);\n const partiallyFilledBucketCount = dataView.getUint32(36, true);\n const sphericalHarmonicsDegree = dataView.getUint16(40, true);\n const bytesPerSplat = getBytesPerSplat(header.compressionLevel, sphericalHarmonicsDegree);\n const bucketsMetaDataSizeBytes = partiallyFilledBucketCount * 4;\n const bucketsStorageSizeBytes = bucketStorageSizeBytes * bucketCount + bucketsMetaDataSizeBytes;\n const storageSizeBytes = bytesPerSplat * maxSplatCount + bucketsStorageSizeBytes;\n\n sections.push({\n bytesPerSplat,\n splatCountOffset,\n splatCount: splatCount || maxSplatCount,\n maxSplatCount,\n bucketSize,\n bucketCount,\n bucketStorageSizeBytes,\n bucketsStorageSizeBytes,\n compressionScaleRange,\n compressionScaleFactor: bucketBlockSize / 2 / compressionScaleRange,\n base: sectionBase,\n bucketsBase: sectionBase + bucketsMetaDataSizeBytes,\n dataBase: sectionBase + bucketsStorageSizeBytes,\n fullBucketCount,\n partiallyFilledBucketCount,\n sphericalHarmonicsDegree\n });\n\n sectionBase += storageSizeBytes;\n splatCountOffset += maxSplatCount;\n }\n\n return sections;\n}\n\n/** Decodes one center component, including bucket-relative decompression. */\nfunction decodeKSPLATCenterComponent(\n data: ArrayBuffer,\n splatBase: number,\n component: number,\n header: KSPLATHeader,\n section: KSPLATSection,\n bucketCenter: number\n): number {\n const value = readCompressedCenterValue(data, splatBase, component, header.compressionLevel);\n return header.compressionLevel >= 1\n ? (value - section.compressionScaleRange) * section.compressionScaleFactor + bucketCenter\n : value;\n}\n\n/** Reads one center component, preserving quantized uint16 values for compressed sections. */\nfunction readCompressedCenterValue(\n data: ArrayBuffer,\n byteOffset: number,\n component: number,\n compressionLevel: 0 | 1 | 2\n): number {\n const dataView = new DataView(data);\n return compressionLevel === 0\n ? dataView.getFloat32(byteOffset + component * 4, true)\n : dataView.getUint16(byteOffset + component * 2, true);\n}\n\n/** Returns the bucket center for a compressed splat section. */\nfunction getBucketCenter(\n data: ArrayBuffer,\n section: KSPLATSection,\n localSplatIndex: number\n): [number, number, number] {\n if (!section.bucketCount) {\n return [0, 0, 0];\n }\n const bucketIndex = getBucketIndex(data, section, localSplatIndex);\n const bucketBase = section.bucketsBase + bucketIndex * section.bucketStorageSizeBytes;\n const dataView = new DataView(data, bucketBase, 12);\n return [dataView.getFloat32(0, true), dataView.getFloat32(4, true), dataView.getFloat32(8, true)];\n}\n\n/** Returns the bucket index containing a local splat index. */\nfunction getBucketIndex(\n data: ArrayBuffer,\n section: KSPLATSection,\n localSplatIndex: number\n): number {\n const maxSplatIndexInFullBuckets = section.fullBucketCount * section.bucketSize;\n if (localSplatIndex < maxSplatIndexInFullBuckets) {\n return Math.floor(localSplatIndex / section.bucketSize);\n }\n\n let bucketSplatIndex = maxSplatIndexInFullBuckets;\n let bucketIndex = section.fullBucketCount;\n for (\n let partiallyFilledBucketIndex = 0;\n partiallyFilledBucketIndex < section.partiallyFilledBucketCount;\n partiallyFilledBucketIndex++\n ) {\n const bucketLength = new DataView(\n data,\n section.base + partiallyFilledBucketIndex * 4,\n 4\n ).getUint32(0, true);\n if (localSplatIndex < bucketSplatIndex + bucketLength) {\n return bucketIndex;\n }\n bucketSplatIndex += bucketLength;\n bucketIndex++;\n }\n return Math.max(bucketIndex - 1, 0);\n}\n\n/** Decodes all SH rest coefficients for one splat into the output array. */\nfunction decodeSphericalHarmonics(\n data: ArrayBuffer,\n byteOffset: number,\n header: KSPLATHeader,\n section: KSPLATSection,\n outputSplatIndex: number,\n output: Float32Array,\n outputComponentCount: number\n): void {\n const componentCount = getSphericalHarmonicsComponentCount(section.sphericalHarmonicsDegree);\n const componentBase = outputSplatIndex * outputComponentCount;\n for (let component = 0; component < componentCount; component++) {\n output[componentBase + component] = readCompressedFloat(\n data,\n byteOffset,\n component,\n header.compressionLevel,\n true,\n header.minSphericalHarmonicsCoeff,\n header.maxSphericalHarmonicsCoeff\n );\n }\n}\n\n/** Reads one compressed float or spherical harmonic coefficient. */\nfunction readCompressedFloat(\n data: ArrayBuffer,\n byteOffset: number,\n component: number,\n compressionLevel: 0 | 1 | 2,\n sphericalHarmonic: boolean = false,\n sphericalHarmonicRangeMin: number = 0,\n sphericalHarmonicRangeMax: number = 0\n): number {\n const dataView = new DataView(data);\n if (compressionLevel === 0) {\n return dataView.getFloat32(byteOffset + component * 4, true);\n }\n if (compressionLevel === 1 || !sphericalHarmonic) {\n return decodeFloat16(dataView.getUint16(byteOffset + component * 2, true));\n }\n const value = dataView.getUint8(byteOffset + component);\n return (\n (value / 255) * (sphericalHarmonicRangeMax - sphericalHarmonicRangeMin) +\n sphericalHarmonicRangeMin\n );\n}\n\n/** Returns the byte length of one splat record for a compression level and SH degree. */\nfunction getBytesPerSplat(compressionLevel: 0 | 1 | 2, sphericalHarmonicsDegree: number): number {\n const layout = COMPRESSION_LAYOUTS[compressionLevel];\n return (\n layout.bytesPerCenter +\n layout.bytesPerScale +\n layout.bytesPerRotation +\n layout.bytesPerColor +\n layout.bytesPerSphericalHarmonicsComponent *\n getSphericalHarmonicsComponentCount(sphericalHarmonicsDegree)\n );\n}\n\n/** Returns the number of SH rest coefficients for a GaussianSplats3D SH degree. */\nfunction getSphericalHarmonicsComponentCount(sphericalHarmonicsDegree: number): number {\n switch (sphericalHarmonicsDegree) {\n case 0:\n return 0;\n case 1:\n return 9;\n case 2:\n return 24;\n case 3:\n return 45;\n default:\n throw new Error(\n `KSPLATLoader: unsupported spherical harmonics degree ${sphericalHarmonicsDegree}.`\n );\n }\n}\n\n/** Returns the active section count in a complete KSPLAT file. */\nfunction getActiveSectionCount(header: KSPLATHeader): number {\n return header.sectionCount || header.maxSectionCount;\n}\n\n/** Returns the total number of splats that will be decoded. */\nfunction getTotalSplatCount(header: KSPLATHeader, sections: KSPLATSection[]): number {\n const sectionSplatCount = sections\n .slice(0, getActiveSectionCount(header))\n .reduce((splatCount, section) => splatCount + section.splatCount, 0);\n return header.splatCount\n ? Math.min(header.splatCount, sectionSplatCount || header.splatCount)\n : sectionSplatCount;\n}\n\n/** Throws when a section record range extends beyond the file buffer. */\nfunction validateSectionBounds(data: ArrayBuffer, section: KSPLATSection): void {\n const requiredByteLength = section.dataBase + section.bytesPerSplat * section.splatCount;\n if (requiredByteLength > data.byteLength) {\n throw new Error('KSPLATLoader: section data extends beyond the file length.');\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {parseKSPLAT} from './lib/parse-ksplat';\nimport {KSPLATLoader as KSPLATLoaderMetadata} from './ksplat-loader-types';\n\nconst {preload: _KSPLATLoaderPreload, ...KSPLATLoaderMetadataWithoutPreload} = KSPLATLoaderMetadata;\n\n/** Parser-bearing loader for `.ksplat` Gaussian splat files. */\nexport const KSPLATLoaderWithParser = {\n ...KSPLATLoaderMetadataWithoutPreload,\n parse: async (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer),\n parseSync: (arrayBuffer: ArrayBuffer) => parseKSPLAT(arrayBuffer)\n} as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Loader} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {KSPLATFormat} from './splats-format';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Preloads the parser-bearing KSPLAT loader implementation. */\nasync function preload() {\n const {KSPLATLoaderWithParser} = await import('./ksplat-loader');\n return KSPLATLoaderWithParser;\n}\n\n/** Metadata-only loader for `.ksplat` Gaussian splat files. */\nexport const KSPLATLoader = {\n dataType: null as unknown as MeshArrowTable,\n batchType: null as never,\n ...KSPLATFormat,\n version: VERSION,\n options: {\n splats: {\n shape: 'arrow-table'\n }\n },\n preload\n} as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ZstdCompression} from '@loaders.gl/compression';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {GaussianSplats, SplatsLoaderOptions} from '../types';\nimport {makeGaussianSplatsArrowTable} from './splats-arrow-table';\nimport {normalizeQuaternion} from './splat-utils';\n\nconst SPZ_HEADER_BYTE_LENGTH = 32;\nconst SPZ_MAGIC = 0x5053474e;\nconst SPZ_VERSION = 4;\nconst SPZ_EXTENSION_FLAG = 0x2;\nconst SPZ_COLOR_SCALE = 0.15;\nconst SPZ_ROTATION_COMPONENT_SCALE = Math.SQRT1_2;\nconst SPZ_ROTATION_COMPONENT_MASK = (1 << 9) - 1;\n\ntype SPZHeader = {\n magic: number;\n version: number;\n numPoints: number;\n shDegree: number;\n fractionalBits: number;\n flags: number;\n numStreams: number;\n tocByteOffset: number;\n};\n\ntype SPZStreamInfo = {\n compressedSize: number;\n uncompressedSize: number;\n compressedOffset: number;\n};\n\n/** Parses a Niantic Spatial `.spz` ArrayBuffer into a Mesh Arrow table. */\nexport async function parseSPZ(\n data: ArrayBuffer,\n options?: SplatsLoaderOptions\n): Promise<MeshArrowTable> {\n return makeGaussianSplatsArrowTable(await parseSPZToGaussianSplats(data, options));\n}\n\n/** Parses a Niantic Spatial `.spz` ArrayBuffer into decoded Gaussian splat values. */\nexport async function parseSPZToGaussianSplats(\n data: ArrayBuffer,\n options?: SplatsLoaderOptions\n): Promise<GaussianSplats> {\n const header = parseSPZHeader(data);\n const streamInfos = parseSPZStreamInfos(data, header, getSPZStreamByteLengths(header));\n const compressedStreams = streamInfos.map(streamInfo =>\n data.slice(streamInfo.compressedOffset, streamInfo.compressedOffset + streamInfo.compressedSize)\n );\n const compression = new ZstdCompression({modules: options?.modules});\n const streams = await Promise.all(\n compressedStreams.map((compressedStream, streamIndex) =>\n compression.decompress(compressedStream, streamInfos[streamIndex].uncompressedSize)\n )\n );\n\n validateSPZStreamLengths(streams, streamInfos);\n return decodeSPZStreams(header, streams, data);\n}\n\n/** Parses and validates the SPZ v4 plaintext header. */\nfunction parseSPZHeader(data: ArrayBuffer): SPZHeader {\n if (data.byteLength < SPZ_HEADER_BYTE_LENGTH) {\n throw new Error(`SPZLoader: file must contain a ${SPZ_HEADER_BYTE_LENGTH}-byte header.`);\n }\n\n const dataView = new DataView(data);\n const header: SPZHeader = {\n magic: dataView.getUint32(0, true),\n version: dataView.getUint32(4, true),\n numPoints: dataView.getUint32(8, true),\n shDegree: dataView.getUint8(12),\n fractionalBits: dataView.getUint8(13),\n flags: dataView.getUint8(14),\n numStreams: dataView.getUint8(15),\n tocByteOffset: dataView.getUint32(16, true)\n };\n\n if (header.magic !== SPZ_MAGIC) {\n throw new Error('SPZLoader: NGSP magic header not found.');\n }\n if (header.version !== SPZ_VERSION) {\n throw new Error(`SPZLoader: version ${header.version} is not supported.`);\n }\n if (header.shDegree > 4) {\n throw new Error(`SPZLoader: spherical harmonics degree ${header.shDegree} is not supported.`);\n }\n if (header.tocByteOffset < SPZ_HEADER_BYTE_LENGTH || header.tocByteOffset > data.byteLength) {\n throw new Error('SPZLoader: invalid table of contents byte offset.');\n }\n\n return header;\n}\n\n/** Parses the SPZ stream table of contents and validates expected stream sizes. */\nfunction parseSPZStreamInfos(\n data: ArrayBuffer,\n header: SPZHeader,\n expectedUncompressedSizes: number[]\n): SPZStreamInfo[] {\n if (header.numStreams !== expectedUncompressedSizes.length) {\n throw new Error(\n `SPZLoader: expected ${expectedUncompressedSizes.length} streams, found ${header.numStreams}.`\n );\n }\n\n const tocByteLength = header.numStreams * 16;\n const tocEnd = header.tocByteOffset + tocByteLength;\n if (tocEnd > data.byteLength) {\n throw new Error('SPZLoader: table of contents exceeds file byte length.');\n }\n\n const dataView = new DataView(data);\n let compressedOffset = tocEnd;\n const streamInfos: SPZStreamInfo[] = [];\n for (let streamIndex = 0; streamIndex < header.numStreams; streamIndex++) {\n const tocOffset = header.tocByteOffset + streamIndex * 16;\n const compressedSize = readSafeUint64(dataView, tocOffset);\n const uncompressedSize = readSafeUint64(dataView, tocOffset + 8);\n const expectedUncompressedSize = expectedUncompressedSizes[streamIndex];\n\n if (uncompressedSize !== expectedUncompressedSize) {\n throw new Error(\n `SPZLoader: stream ${streamIndex} has ${uncompressedSize} uncompressed bytes, expected ${expectedUncompressedSize}.`\n );\n }\n if (compressedOffset + compressedSize > data.byteLength) {\n throw new Error(`SPZLoader: stream ${streamIndex} exceeds file byte length.`);\n }\n\n streamInfos.push({compressedSize, uncompressedSize, compressedOffset});\n compressedOffset += compressedSize;\n }\n\n if (compressedOffset !== data.byteLength) {\n throw new Error('SPZLoader: compressed stream byte lengths do not match file byte length.');\n }\n\n return streamInfos;\n}\n\n/** Converts a little-endian uint64 to a safe JavaScript number. */\nfunction readSafeUint64(dataView: DataView, byteOffset: number): number {\n const value = dataView.getBigUint64(byteOffset, true);\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new Error('SPZLoader: stream byte length exceeds Number.MAX_SAFE_INTEGER.');\n }\n return Number(value);\n}\n\n/** Returns expected SPZ v4 stream byte lengths, skipping zero-length SH data. */\nfunction getSPZStreamByteLengths(header: SPZHeader): number[] {\n return [\n header.numPoints * 9,\n header.numPoints,\n header.numPoints * 3,\n header.numPoints * 3,\n header.numPoints * 4,\n header.numPoints * getSphericalHarmonicsComponentCount(header.shDegree)\n ].filter(byteLength => byteLength > 0);\n}\n\n/** Validates that decompressed stream lengths match the TOC. */\nfunction validateSPZStreamLengths(streams: ArrayBuffer[], streamInfos: SPZStreamInfo[]): void {\n for (let streamIndex = 0; streamIndex < streams.length; streamIndex++) {\n if (streams[streamIndex].byteLength !== streamInfos[streamIndex].uncompressedSize) {\n throw new Error(`SPZLoader: decompressed stream ${streamIndex} has unexpected byte length.`);\n }\n }\n}\n\n/** Decodes decompressed SPZ streams into shared Gaussian splat arrays. */\nfunction decodeSPZStreams(\n header: SPZHeader,\n streams: ArrayBuffer[],\n sourceData: ArrayBuffer\n): GaussianSplats {\n const splatCount = header.numPoints;\n const positions = new Float32Array(splatCount * 3);\n const scales = new Float32Array(splatCount * 3);\n const rotations = new Float32Array(splatCount * 4);\n const colors = new Uint8Array(splatCount * 3);\n const sphericalHarmonicDcs = new Float32Array(splatCount * 3);\n const opacities = new Float32Array(splatCount);\n const sphericalHarmonicsComponentCount = getSphericalHarmonicsComponentCount(header.shDegree);\n const sphericalHarmonics = sphericalHarmonicsComponentCount\n ? new Float32Array(splatCount * sphericalHarmonicsComponentCount)\n : undefined;\n const [\n positionStream,\n alphaStream,\n colorStream,\n scaleStream,\n rotationStream,\n sphericalHarmonicsStream\n ] = streams.map(stream => new Uint8Array(stream));\n\n decodeSPZPositions(positionStream, positions, header.fractionalBits);\n decodeSPZScales(scaleStream, scales);\n decodeSPZRotations(rotationStream, rotations);\n decodeSPZColors(colorStream, colors, sphericalHarmonicDcs);\n decodeSPZOpacities(alphaStream, opacities);\n if (sphericalHarmonics && sphericalHarmonicsStream) {\n decodeSPZSphericalHarmonics(sphericalHarmonicsStream, sphericalHarmonics);\n }\n\n return {\n format: 'spz',\n splatCount,\n positions,\n scales,\n rotations,\n colors,\n sphericalHarmonicDcs,\n opacities,\n sphericalHarmonics,\n sphericalHarmonicsComponentCount,\n loaderData: {\n format: 'spz',\n ...header,\n antialiased: Boolean(header.flags & 0x1),\n extensionByteLength: getSPZExtensionByteLength(header),\n extensionBytes: getSPZExtensionBytes(sourceData, header)\n }\n };\n}\n\n/** Decodes 24-bit signed fixed-point SPZ positions. */\nfunction decodeSPZPositions(\n positionStream: Uint8Array,\n positions: Float32Array,\n fractionalBits: number\n): void {\n const scale = 1 / 2 ** fractionalBits;\n for (let componentIndex = 0; componentIndex < positions.length; componentIndex++) {\n const byteOffset = componentIndex * 3;\n let fixed32 =\n positionStream[byteOffset] |\n (positionStream[byteOffset + 1] << 8) |\n (positionStream[byteOffset + 2] << 16);\n fixed32 |= fixed32 & 0x800000 ? 0xff000000 : 0;\n positions[componentIndex] = fixed32 * scale;\n }\n}\n\n/** Decodes SPZ log-encoded scales to linear standard deviations. */\nfunction decodeSPZScales(scaleStream: Uint8Array, scales: Float32Array): void {\n for (let componentIndex = 0; componentIndex < scales.length; componentIndex++) {\n scales[componentIndex] = Math.exp(scaleStream[componentIndex] / 16 - 10);\n }\n}\n\n/** Decodes SPZ smallest-three quaternion rotations into `[w, x, y, z]` order. */\nfunction decodeSPZRotations(rotationStream: Uint8Array, rotations: Float32Array): void {\n for (let splatIndex = 0; splatIndex < rotations.length / 4; splatIndex++) {\n const byteOffset = splatIndex * 4;\n const component =\n rotationStream[byteOffset] |\n (rotationStream[byteOffset + 1] << 8) |\n (rotationStream[byteOffset + 2] << 16) |\n (rotationStream[byteOffset + 3] << 24);\n const xyzw = decodeSPZQuaternion(component >>> 0);\n const [w, x, y, z] = normalizeQuaternion(xyzw[3], xyzw[0], xyzw[1], xyzw[2]);\n const rotationOffset = splatIndex * 4;\n rotations[rotationOffset + 0] = w;\n rotations[rotationOffset + 1] = x;\n rotations[rotationOffset + 2] = y;\n rotations[rotationOffset + 3] = z;\n }\n}\n\n/** Decodes one SPZ smallest-three quaternion into `[x, y, z, w]` order. */\nfunction decodeSPZQuaternion(component: number): [number, number, number, number] {\n const rotation: [number, number, number, number] = [0, 0, 0, 0];\n const largestComponent = component >>> 30;\n let remainingBits = component;\n let sumSquares = 0;\n\n for (let componentIndex = 3; componentIndex >= 0; componentIndex--) {\n if (componentIndex !== largestComponent) {\n const magnitude = remainingBits & SPZ_ROTATION_COMPONENT_MASK;\n const isNegative = (remainingBits >>> 9) & 0x1;\n remainingBits >>>= 10;\n let value = (SPZ_ROTATION_COMPONENT_SCALE * magnitude) / SPZ_ROTATION_COMPONENT_MASK;\n if (isNegative) {\n value = -value;\n }\n rotation[componentIndex] = value;\n sumSquares += value * value;\n }\n }\n\n rotation[largestComponent] = Math.sqrt(Math.max(0, 1 - sumSquares));\n return rotation;\n}\n\n/** Decodes SPZ color bytes into display RGB bytes and direct SH DC coefficients. */\nfunction decodeSPZColors(\n colorStream: Uint8Array,\n colors: Uint8Array,\n sphericalHarmonicDcs: Float32Array\n): void {\n for (let componentIndex = 0; componentIndex < colors.length; componentIndex++) {\n sphericalHarmonicDcs[componentIndex] =\n (colorStream[componentIndex] / 255 - 0.5) / SPZ_COLOR_SCALE;\n colors[componentIndex] = normalizeColorByte(sphericalHarmonicDcs[componentIndex]);\n }\n}\n\n/** Decodes SPZ alpha bytes into linear opacity. */\nfunction decodeSPZOpacities(alphaStream: Uint8Array, opacities: Float32Array): void {\n for (let splatIndex = 0; splatIndex < opacities.length; splatIndex++) {\n opacities[splatIndex] = alphaStream[splatIndex] / 255;\n }\n}\n\n/** Decodes SPZ quantized SH rest coefficients. */\nfunction decodeSPZSphericalHarmonics(\n sphericalHarmonicsStream: Uint8Array,\n sphericalHarmonics: Float32Array\n): void {\n for (let componentIndex = 0; componentIndex < sphericalHarmonics.length; componentIndex++) {\n sphericalHarmonics[componentIndex] = (sphericalHarmonicsStream[componentIndex] - 128) / 128;\n }\n}\n\n/** Converts an SH DC coefficient to a fallback RGB byte for preview paths. */\nfunction normalizeColorByte(sphericalHarmonicDc: number): number {\n return Math.min(\n Math.max(Math.round((sphericalHarmonicDc * SPZ_COLOR_SCALE + 0.5) * 255), 0),\n 255\n );\n}\n\n/** Returns the number of SH rest coefficients per splat for an SPZ degree. */\nfunction getSphericalHarmonicsComponentCount(shDegree: number): number {\n switch (shDegree) {\n case 0:\n return 0;\n case 1:\n return 9;\n case 2:\n return 24;\n case 3:\n return 45;\n case 4:\n return 72;\n default:\n throw new Error(`SPZLoader: spherical harmonics degree ${shDegree} is not supported.`);\n }\n}\n\n/** Returns the plaintext SPZ extension byte count. */\nfunction getSPZExtensionByteLength(header: SPZHeader): number {\n return header.flags & SPZ_EXTENSION_FLAG ? header.tocByteOffset - SPZ_HEADER_BYTE_LENGTH : 0;\n}\n\n/** Returns a copy of plaintext SPZ extension bytes when extension records are present. */\nfunction getSPZExtensionBytes(data: ArrayBuffer, header: SPZHeader): Uint8Array | undefined {\n const extensionByteLength = getSPZExtensionByteLength(header);\n return extensionByteLength\n ? new Uint8Array(data.slice(SPZ_HEADER_BYTE_LENGTH, header.tocByteOffset))\n : undefined;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {parseSPZ} from './lib/parse-spz';\nimport {SPZLoader as SPZLoaderMetadata} from './spz-loader-types';\n\nconst {preload: _SPZLoaderPreload, ...SPZLoaderMetadataWithoutPreload} = SPZLoaderMetadata;\n\n/** Parser-bearing loader for Niantic Spatial `.spz` Gaussian splat files. */\nexport const SPZLoaderWithParser = {\n ...SPZLoaderMetadataWithoutPreload,\n parse: async (arrayBuffer: ArrayBuffer, options?: SplatsLoaderOptions) =>\n parseSPZ(arrayBuffer, options)\n} as const satisfies LoaderWithParser<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Loader} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {SplatsLoaderOptions} from './types';\nimport {SPZFormat} from './splats-format';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Preloads the parser-bearing SPZ loader implementation. */\nasync function preload() {\n const {SPZLoaderWithParser} = await import('./spz-loader');\n return SPZLoaderWithParser;\n}\n\n/** Metadata-only loader for Niantic Spatial `.spz` Gaussian splat files. */\nexport const SPZLoader = {\n dataType: null as unknown as MeshArrowTable,\n batchType: null as never,\n ...SPZFormat,\n version: VERSION,\n options: {\n splats: {\n shape: 'arrow-table'\n }\n },\n preload\n} as const satisfies Loader<MeshArrowTable, never, SplatsLoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst RAD_MAGIC = 0x30444152;\nconst RAD_CHUNK_MAGIC = 0x43444152;\nconst RAD_HEADER_BYTE_LENGTH = 8;\nconst RAD_CHUNK_PAYLOAD_LENGTH_BYTE_LENGTH = 8;\nconst TEXT_DECODER = new TextDecoder();\n\n/** Spark RAD splat quantization and shader decode range metadata. */\nexport type RADSplatEncoding = {\n /** Minimum RGB value encoded into quantized color properties. */\n rgbMin?: number;\n /** Maximum RGB value encoded into quantized color properties. */\n rgbMax?: number;\n /** Minimum natural log scale encoded into quantized scale properties. */\n lnScaleMin?: number;\n /** Maximum natural log scale encoded into quantized scale properties. */\n lnScaleMax?: number;\n /** Maximum absolute SH degree-1 coefficient value. */\n sh1Max?: number;\n /** Maximum absolute SH degree-2 coefficient value. */\n sh2Max?: number;\n /** Maximum absolute SH degree-3 coefficient value. */\n sh3Max?: number;\n /** Whether opacity is encoded for LoD blending. */\n lodOpacity?: boolean;\n};\n\n/** One RAD chunk location in the top-level RAD chunk table. */\nexport type RADChunkRange = {\n /** Chunk byte offset relative to the top-level RAD chunk payload area. */\n offset: number;\n /** Chunk byte length. */\n bytes: number;\n /** Optional first splat index represented by this chunk. */\n base?: number;\n /** Optional number of splats represented by this chunk. */\n count?: number;\n /** Optional sidecar `.radc` filename relative to the RAD file URL. */\n filename?: string;\n};\n\n/** Parsed Spark RAD top-level metadata with loader-derived byte offsets. */\nexport type RADMetadata = {\n /** RAD container version. Version 1 is currently supported. */\n version: number;\n /** RAD payload type. Spark currently writes `gsplat`. */\n type: string;\n /** Total splat count represented by the RAD source. */\n count: number;\n /** Maximum spherical harmonics degree present in the chunks. */\n maxSh?: number;\n /** Whether the source includes LoD tree child-count and child-start properties. */\n lodTree?: boolean;\n /** Nominal number of splats per chunk. */\n chunkSize?: number;\n /** Total inline chunk byte length when present in the RAD metadata. */\n allChunkBytes?: number;\n /** RAD chunk table. */\n chunks: RADChunkRange[];\n /** Optional shared splat encoding metadata for chunk decoding. */\n splatEncoding?: RADSplatEncoding;\n /** Optional spherical harmonics codebook count. */\n shCodeCount?: number;\n /** Optional RAD writer comment. */\n comment?: string;\n /** Byte length of the JSON metadata block. */\n headerJsonByteLength: number;\n /** Byte offset where inline RAD chunks begin. */\n chunksByteOffset: number;\n};\n\n/** Known RAD chunk property names. */\nexport type RADChunkPropertyName =\n | 'center'\n | 'alpha'\n | 'rgb'\n | 'scales'\n | 'orientation'\n | 'sh1'\n | 'sh2'\n | 'sh3'\n | 'child_count'\n | 'child_start'\n | 'sh1_code'\n | 'sh2_code'\n | 'sh3_code'\n | 'sh_label';\n\n/** Known RAD chunk property encodings. */\nexport type RADChunkPropertyEncoding =\n | 'f32'\n | 'f16'\n | 'f32_lebytes'\n | 'f16_lebytes'\n | 'r8'\n | 'r8_delta'\n | 's8'\n | 's8_delta'\n | 'ln_0r8'\n | 'ln_f16'\n | 'oct88r8'\n | 'u16'\n | 'u32';\n\n/** Known RAD chunk property compression modes. */\nexport type RADChunkPropertyCompression = 'gz';\n\n/** One property payload entry inside a RAD chunk. */\nexport type RADChunkProperty = {\n /** Property byte offset relative to the chunk payload area. */\n offset: number;\n /** Property byte length before 8-byte payload padding. */\n bytes: number;\n /** Property semantic name. */\n property: RADChunkPropertyName | string;\n /** Property encoding name. */\n encoding: RADChunkPropertyEncoding | string;\n /** Optional property compression mode. */\n compression?: RADChunkPropertyCompression | string;\n /** Optional decode minimum for quantized properties. */\n min?: number;\n /** Optional decode maximum for quantized properties. */\n max?: number;\n};\n\n/** Parsed Spark RADC chunk metadata with loader-derived byte offsets. */\nexport type RADChunkMetadata = {\n /** RAD chunk version. Version 1 is currently supported. */\n version: number;\n /** First global splat index represented by this chunk. */\n base: number;\n /** Number of splats represented by this chunk. */\n count: number;\n /** Byte length of the padded property payload. */\n payloadBytes: number;\n /** Maximum spherical harmonics degree present in this chunk. */\n maxSh?: number;\n /** Whether this chunk contains LoD tree properties. */\n lodTree?: boolean;\n /** Optional chunk-local splat encoding metadata. */\n splatEncoding?: RADSplatEncoding;\n /** Property table for the chunk payload. */\n properties: RADChunkProperty[];\n /** Byte length of the chunk JSON metadata block. */\n headerJsonByteLength: number;\n /** Byte offset where the chunk payload begins. */\n payloadByteOffset: number;\n /** Byte length of the RADC header and payload. */\n chunkByteLength: number;\n};\n\n/** Returns true when the input begins with the Spark RAD magic bytes. */\nexport function isRAD(data: ArrayBuffer | ArrayBufferView): boolean {\n const bytes = getUint8Array(data);\n if (bytes.byteLength < 4) {\n return false;\n }\n return (\n new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(0, true) === RAD_MAGIC\n );\n}\n\n/** Parses a complete or header-prefix Spark `.rad` buffer. */\nexport function parseRADHeader(data: ArrayBuffer | ArrayBufferView): RADMetadata {\n const metadata = tryParseRADHeader(data);\n if (!metadata) {\n throw new Error('RADLoader: file must contain a complete RAD metadata header.');\n }\n return metadata;\n}\n\n/** Parses a Spark `.rad` header when enough bytes are available. */\nexport function tryParseRADHeader(data: ArrayBuffer | ArrayBufferView): RADMetadata | null {\n const bytes = getUint8Array(data);\n if (bytes.byteLength < RAD_HEADER_BYTE_LENGTH) {\n return null;\n }\n\n const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const magic = dataView.getUint32(0, true);\n if (magic !== RAD_MAGIC) {\n throw new Error(`RADLoader: RAD0 magic header not found, received 0x${magic.toString(16)}.`);\n }\n\n const headerJsonByteLength = dataView.getUint32(4, true);\n const headerJsonEnd = RAD_HEADER_BYTE_LENGTH + headerJsonByteLength;\n if (bytes.byteLength < headerJsonEnd) {\n return null;\n }\n\n const rawMetadata = parseJSONRecord(\n bytes.subarray(RAD_HEADER_BYTE_LENGTH, headerJsonEnd),\n 'RADLoader: failed to parse RAD metadata JSON.'\n );\n return normalizeRADMetadata(rawMetadata, headerJsonByteLength);\n}\n\n/** Parses the metadata header from one Spark `.radc` chunk buffer. */\nexport function parseRADChunkHeader(data: ArrayBuffer | ArrayBufferView): RADChunkMetadata {\n const bytes = getUint8Array(data);\n if (bytes.byteLength < RAD_HEADER_BYTE_LENGTH) {\n throw new Error('RADLoader: RADC chunk must contain an 8-byte metadata header.');\n }\n\n const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const magic = dataView.getUint32(0, true);\n if (magic !== RAD_CHUNK_MAGIC) {\n throw new Error(`RADLoader: RADC magic header not found, received 0x${magic.toString(16)}.`);\n }\n\n const headerJsonByteLength = dataView.getUint32(4, true);\n const headerJsonEnd = RAD_HEADER_BYTE_LENGTH + headerJsonByteLength;\n const payloadByteLengthOffset = RAD_HEADER_BYTE_LENGTH + roundUpToEight(headerJsonByteLength);\n const payloadByteOffset = payloadByteLengthOffset + RAD_CHUNK_PAYLOAD_LENGTH_BYTE_LENGTH;\n if (bytes.byteLength < payloadByteOffset) {\n throw new Error('RADLoader: RADC chunk must contain a complete metadata header.');\n }\n\n const rawMetadata = parseJSONRecord(\n bytes.subarray(RAD_HEADER_BYTE_LENGTH, headerJsonEnd),\n 'RADLoader: failed to parse RADC metadata JSON.'\n );\n const payloadBytes = readSafeUint64(\n dataView,\n payloadByteLengthOffset,\n 'RADC payload byte length'\n );\n return normalizeRADChunkMetadata(\n rawMetadata,\n headerJsonByteLength,\n payloadByteOffset,\n payloadBytes\n );\n}\n\n/** Rounds a byte length to Spark RAD's 8-byte alignment. */\nexport function roundUpToEight(byteLength: number): number {\n return (byteLength + 7) & ~7;\n}\n\nfunction normalizeRADMetadata(\n rawMetadata: Record<string, unknown>,\n headerJsonByteLength: number\n): RADMetadata {\n const version = requireSafeInteger(rawMetadata.version, 'RAD version');\n if (version !== 1) {\n throw new Error(`RADLoader: version ${version} is not supported.`);\n }\n\n const type = requireString(rawMetadata.type, 'RAD type');\n if (type !== 'gsplat') {\n throw new Error(`RADLoader: RAD type ${type} is not supported.`);\n }\n\n const chunks = requireArray(rawMetadata.chunks, 'RAD chunks').map((chunk, chunkIndex) =>\n normalizeRADChunkRange(chunk, chunkIndex)\n );\n const metadata: RADMetadata = {\n version,\n type,\n count: requireSafeInteger(rawMetadata.count, 'RAD count'),\n maxSh: optionalSafeInteger(rawMetadata.maxSh, 'RAD maxSh'),\n lodTree: optionalBoolean(rawMetadata.lodTree, 'RAD lodTree'),\n chunkSize: optionalSafeInteger(rawMetadata.chunkSize, 'RAD chunkSize'),\n allChunkBytes: optionalSafeInteger(rawMetadata.allChunkBytes, 'RAD allChunkBytes'),\n chunks,\n splatEncoding: optionalSplatEncoding(rawMetadata.splatEncoding, 'RAD splatEncoding'),\n shCodeCount: optionalSafeInteger(rawMetadata.shCodeCount, 'RAD shCodeCount'),\n comment: optionalString(rawMetadata.comment, 'RAD comment'),\n headerJsonByteLength,\n chunksByteOffset: RAD_HEADER_BYTE_LENGTH + roundUpToEight(headerJsonByteLength)\n };\n\n return metadata;\n}\n\nfunction normalizeRADChunkRange(rawChunk: unknown, chunkIndex: number): RADChunkRange {\n const chunk = requireRecord(rawChunk, `RAD chunk ${chunkIndex}`);\n return {\n offset: requireSafeInteger(chunk.offset, `RAD chunk ${chunkIndex} offset`),\n bytes: requireSafeInteger(chunk.bytes, `RAD chunk ${chunkIndex} bytes`),\n base: optionalSafeInteger(chunk.base, `RAD chunk ${chunkIndex} base`),\n count: optionalSafeInteger(chunk.count, `RAD chunk ${chunkIndex} count`),\n filename: optionalString(chunk.filename, `RAD chunk ${chunkIndex} filename`)\n };\n}\n\nfunction normalizeRADChunkMetadata(\n rawMetadata: Record<string, unknown>,\n headerJsonByteLength: number,\n payloadByteOffset: number,\n payloadBytes: number\n): RADChunkMetadata {\n const version = requireSafeInteger(rawMetadata.version, 'RADC version');\n if (version !== 1) {\n throw new Error(`RADLoader: RADC version ${version} is not supported.`);\n }\n\n const metadataPayloadBytes = requireSafeInteger(rawMetadata.payloadBytes, 'RADC payloadBytes');\n if (metadataPayloadBytes !== payloadBytes) {\n throw new Error('RADLoader: RADC metadata payload byte length does not match binary header.');\n }\n\n return {\n version,\n base: requireSafeInteger(rawMetadata.base, 'RADC base'),\n count: requireSafeInteger(rawMetadata.count, 'RADC count'),\n payloadBytes,\n maxSh: optionalSafeInteger(rawMetadata.maxSh, 'RADC maxSh'),\n lodTree: optionalBoolean(rawMetadata.lodTree, 'RADC lodTree'),\n splatEncoding: optionalSplatEncoding(rawMetadata.splatEncoding, 'RADC splatEncoding'),\n properties: requireArray(rawMetadata.properties, 'RADC properties').map((property, index) =>\n normalizeRADChunkProperty(property, index)\n ),\n headerJsonByteLength,\n payloadByteOffset,\n chunkByteLength: payloadByteOffset + payloadBytes\n };\n}\n\nfunction normalizeRADChunkProperty(rawProperty: unknown, propertyIndex: number): RADChunkProperty {\n const property = requireRecord(rawProperty, `RADC property ${propertyIndex}`);\n return {\n offset: requireSafeInteger(property.offset, `RADC property ${propertyIndex} offset`),\n bytes: requireSafeInteger(property.bytes, `RADC property ${propertyIndex} bytes`),\n property: requireString(property.property, `RADC property ${propertyIndex} name`),\n encoding: requireString(property.encoding, `RADC property ${propertyIndex} encoding`),\n compression: optionalString(property.compression, `RADC property ${propertyIndex} compression`),\n min: optionalFiniteNumber(property.min, `RADC property ${propertyIndex} min`),\n max: optionalFiniteNumber(property.max, `RADC property ${propertyIndex} max`)\n };\n}\n\nfunction optionalSplatEncoding(value: unknown, fieldName: string): RADSplatEncoding | undefined {\n if (value === undefined) {\n return undefined;\n }\n const encoding = requireRecord(value, fieldName);\n return {\n rgbMin: optionalFiniteNumber(encoding.rgbMin, `${fieldName}.rgbMin`),\n rgbMax: optionalFiniteNumber(encoding.rgbMax, `${fieldName}.rgbMax`),\n lnScaleMin: optionalFiniteNumber(encoding.lnScaleMin, `${fieldName}.lnScaleMin`),\n lnScaleMax: optionalFiniteNumber(encoding.lnScaleMax, `${fieldName}.lnScaleMax`),\n sh1Max: optionalFiniteNumber(encoding.sh1Max, `${fieldName}.sh1Max`),\n sh2Max: optionalFiniteNumber(encoding.sh2Max, `${fieldName}.sh2Max`),\n sh3Max: optionalFiniteNumber(encoding.sh3Max, `${fieldName}.sh3Max`),\n lodOpacity: optionalBoolean(encoding.lodOpacity, `${fieldName}.lodOpacity`)\n };\n}\n\nfunction parseJSONRecord(bytes: Uint8Array, message: string): Record<string, unknown> {\n try {\n return requireRecord(JSON.parse(TEXT_DECODER.decode(bytes)), message);\n } catch (error) {\n if (error instanceof Error && error.message.startsWith('RADLoader:')) {\n throw error;\n }\n throw new Error(message);\n }\n}\n\nfunction requireRecord(value: unknown, fieldName: string): Record<string, unknown> {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new Error(`RADLoader: ${fieldName} must be an object.`);\n }\n return value as Record<string, unknown>;\n}\n\nfunction requireArray(value: unknown, fieldName: string): unknown[] {\n if (!Array.isArray(value)) {\n throw new Error(`RADLoader: ${fieldName} must be an array.`);\n }\n return value;\n}\n\nfunction requireString(value: unknown, fieldName: string): string {\n if (typeof value !== 'string') {\n throw new Error(`RADLoader: ${fieldName} must be a string.`);\n }\n return value;\n}\n\nfunction optionalString(value: unknown, fieldName: string): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n return requireString(value, fieldName);\n}\n\nfunction optionalBoolean(value: unknown, fieldName: string): boolean | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'boolean') {\n throw new Error(`RADLoader: ${fieldName} must be a boolean.`);\n }\n return value;\n}\n\nfunction requireSafeInteger(value: unknown, fieldName: string): number {\n if (!Number.isSafeInteger(value) || Number(value) < 0) {\n throw new Error(`RADLoader: ${fieldName} must be a non-negative safe integer.`);\n }\n return Number(value);\n}\n\nfunction optionalSafeInteger(value: unknown, fieldName: string): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n return requireSafeInteger(value, fieldName);\n}\n\nfunction optionalFiniteNumber(value: unknown, fieldName: string): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new Error(`RADLoader: ${fieldName} must be a finite number.`);\n }\n return value;\n}\n\nfunction readSafeUint64(dataView: DataView, byteOffset: number, fieldName: string): number {\n const value = dataView.getBigUint64(byteOffset, true);\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) {\n throw new Error(`RADLoader: ${fieldName} exceeds Number.MAX_SAFE_INTEGER.`);\n }\n return Number(value);\n}\n\nfunction getUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n return data instanceof ArrayBuffer\n ? new Uint8Array(data)\n : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {DeflateCompression} from '@loaders.gl/compression';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport type {GaussianSplats, SplatsLoaderOptions} from '../types';\nimport {\n parseRADChunkHeader,\n roundUpToEight,\n type RADChunkMetadata,\n type RADChunkProperty,\n type RADSplatEncoding\n} from './parse-rad';\nimport {makeGaussianSplatsArrowTable} from './splats-arrow-table';\nimport {decodeFloat16, normalizeQuaternion, SH_C0} from './splat-utils';\n\nconst RAD_PROPERTY_DEFLATE = new DeflateCompression();\nconst RAD_PROPERTY_RAW_DEFLATE = new DeflateCompression({raw: true});\n\n/** Options for decoding one Spark RADC chunk payload. */\nexport type RADChunkDecodeOptions = SplatsLoaderOptions & {\n radChunk?: {\n /** Optional source-level splat encoding metadata used as a fallback for chunk-local metadata. */\n splatEncoding?: RADSplatEncoding;\n /** Whether decoded LoD child metadata is retained in `loaderData`. */\n includeLoDTree?: boolean;\n /** Whether decoded SH rest coefficients are included in Arrow table columns. */\n includeSphericalHarmonics?: boolean;\n };\n};\n\n/** Parses a Spark `.radc` chunk into a Mesh Arrow table. */\nexport function parseRADChunk(\n data: ArrayBuffer | ArrayBufferView,\n options?: RADChunkDecodeOptions\n): MeshArrowTable {\n return makeGaussianSplatsArrowTable(parseRADChunkToGaussianSplats(data, options));\n}\n\n/** Parses a Spark `.radc` chunk into decoded Gaussian splat values. */\nexport function parseRADChunkToGaussianSplats(\n data: ArrayBuffer | ArrayBufferView,\n options?: RADChunkDecodeOptions\n): GaussianSplats {\n const bytes = getUint8Array(data);\n const metadata = getRADChunkDecodeMetadata(parseRADChunkHeader(bytes), options);\n if (bytes.byteLength < metadata.chunkByteLength) {\n throw new Error('RADLoader: RADC chunk payload is incomplete.');\n }\n\n const splatCount = metadata.count;\n const positions = decodeRADFloatProperty(\n bytes,\n metadata,\n requireRADProperty(metadata, 'center'),\n 3\n );\n const opacities = decodeRADAlpha(bytes, metadata, splatCount);\n const rgb = decodeRADRgb(bytes, metadata, splatCount);\n const scales = decodeRADScales(bytes, metadata, splatCount);\n const rotations = decodeRADRotations(bytes, metadata, splatCount);\n const {colors, sphericalHarmonicDcs} = convertRgbToColorColumns(rgb);\n const includeLoDTree = options?.radChunk?.includeLoDTree ?? true;\n const childCounts = includeLoDTree\n ? decodeOptionalRADUint16(bytes, metadata, 'child_count')\n : null;\n const childStarts = includeLoDTree\n ? decodeOptionalRADUint32(bytes, metadata, 'child_start')\n : null;\n const includeSphericalHarmonics = options?.radChunk?.includeSphericalHarmonics ?? false;\n const sphericalHarmonics = includeSphericalHarmonics\n ? decodeRADSphericalHarmonics(bytes, metadata)\n : null;\n\n return {\n format: 'rad',\n splatCount,\n positions,\n scales,\n rotations,\n colors,\n sphericalHarmonicDcs,\n opacities,\n sphericalHarmonics: sphericalHarmonics?.values,\n sphericalHarmonicsComponentCount: sphericalHarmonics?.componentCount,\n loaderData: {\n format: 'rad',\n base: metadata.base,\n count: metadata.count,\n maxSh: metadata.maxSh ?? 0,\n lodTree: metadata.lodTree ?? false,\n splatEncoding: metadata.splatEncoding,\n childCounts: childCounts ?? undefined,\n childStarts: childStarts ?? undefined\n }\n };\n}\n\n/** Decodes the chunk alpha property, falling back to fully opaque splats. */\nfunction decodeRADAlpha(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n splatCount: number\n): Float32Array {\n const property = findRADProperty(metadata, 'alpha');\n if (!property) {\n return new Float32Array(splatCount).fill(1);\n }\n const opacities = decodeRADFloatProperty(bytes, metadata, property, 1);\n for (let splatIndex = 0; splatIndex < opacities.length; splatIndex++) {\n opacities[splatIndex] = decodeRADOpacity(opacities[splatIndex], metadata, property);\n }\n return opacities;\n}\n\n/** Decodes normal or Spark LoD opacity into the renderer opacity domain. */\nfunction decodeRADOpacity(\n opacity: number,\n metadata: RADChunkMetadata,\n property: RADChunkProperty\n): number {\n const normalizedOpacity = Math.max(opacity, 0);\n if (\n !metadata.splatEncoding?.lodOpacity ||\n (property.encoding !== 'r8' && property.encoding !== 'r8_delta')\n ) {\n return normalizedOpacity;\n }\n\n return normalizedOpacity * 2;\n}\n\n/** Decodes the chunk RGB property, falling back to white splats. */\nfunction decodeRADRgb(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n splatCount: number\n): Float32Array {\n const property = findRADProperty(metadata, 'rgb');\n if (!property) {\n return new Float32Array(splatCount * 3).fill(1);\n }\n return decodeRADFloatProperty(bytes, metadata, property, 3);\n}\n\n/** Decodes the chunk scale property, falling back to unit splats. */\nfunction decodeRADScales(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n splatCount: number\n): Float32Array {\n const property = findRADProperty(metadata, 'scales');\n if (!property) {\n return new Float32Array(splatCount * 3).fill(1);\n }\n return decodeRADFloatProperty(bytes, metadata, property, 3);\n}\n\n/** Decodes the chunk orientation property, falling back to identity rotations. */\nfunction decodeRADRotations(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n splatCount: number\n): Float32Array {\n const property = findRADProperty(metadata, 'orientation');\n if (!property) {\n return makeIdentityRotations(splatCount);\n }\n\n const propertyBytes = getRADPropertyBytes(bytes, metadata, property);\n switch (property.encoding) {\n case 'oct88r8':\n return decodeRADOct88R8Rotations(propertyBytes, splatCount);\n case 'f32':\n case 'f16': {\n const xyz = decodeRADFloatProperty(bytes, metadata, property, 3);\n const rotations = new Float32Array(splatCount * 4);\n for (let splatIndex = 0; splatIndex < splatCount; splatIndex++) {\n const xyzOffset = splatIndex * 3;\n const rotationOffset = splatIndex * 4;\n const x = xyz[xyzOffset + 0];\n const y = xyz[xyzOffset + 1];\n const z = xyz[xyzOffset + 2];\n const w = Math.sqrt(Math.max(0, 1 - x * x - y * y - z * z));\n const normalized = normalizeQuaternion(w, x, y, z);\n rotations.set(normalized, rotationOffset);\n }\n return rotations;\n }\n default:\n throw new Error(`RADLoader: unsupported orientation encoding ${property.encoding}.`);\n }\n}\n\n/** Decodes optional spherical harmonic rest properties from a chunk. */\nfunction decodeRADSphericalHarmonics(\n bytes: Uint8Array,\n metadata: RADChunkMetadata\n): {values: Float32Array; componentCount: number} | null {\n const shProperties = [\n {property: findRADProperty(metadata, 'sh1'), dimensions: 9},\n {property: findRADProperty(metadata, 'sh2'), dimensions: 15},\n {property: findRADProperty(metadata, 'sh3'), dimensions: 21}\n ].filter(\n (entry): entry is {property: RADChunkProperty; dimensions: number} =>\n entry.property !== undefined\n );\n if (shProperties.length === 0) {\n return null;\n }\n\n const decodedProperties = shProperties.map(entry => ({\n values: decodeRADFloatProperty(bytes, metadata, entry.property, entry.dimensions),\n dimensions: entry.dimensions\n }));\n const componentCount = decodedProperties.reduce((total, entry) => total + entry.dimensions, 0);\n const values = new Float32Array(metadata.count * componentCount);\n for (let splatIndex = 0; splatIndex < metadata.count; splatIndex++) {\n let outputOffset = splatIndex * componentCount;\n for (const decodedProperty of decodedProperties) {\n const inputOffset = splatIndex * decodedProperty.dimensions;\n values.set(\n decodedProperty.values.subarray(inputOffset, inputOffset + decodedProperty.dimensions),\n outputOffset\n );\n outputOffset += decodedProperty.dimensions;\n }\n }\n return {values, componentCount};\n}\n\n/** Decodes one numeric RADC property into row-major Float32 values. */\nfunction decodeRADFloatProperty(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n property: RADChunkProperty,\n dimensions: number\n): Float32Array {\n const propertyBytes = getRADPropertyBytes(bytes, metadata, property);\n switch (property.encoding) {\n case 'f32':\n return decodePlanarFloat32(propertyBytes, dimensions, metadata.count);\n case 'f16':\n return decodePlanarFloat16(propertyBytes, dimensions, metadata.count);\n case 'f32_lebytes':\n return decodeLeBytesFloat32(propertyBytes, dimensions, metadata.count);\n case 'f16_lebytes':\n return decodeLeBytesFloat16(propertyBytes, dimensions, metadata.count);\n case 'r8':\n return decodeR8(\n propertyBytes,\n dimensions,\n metadata.count,\n getPropertyMin(metadata, property),\n getPropertyMax(metadata, property)\n );\n case 'r8_delta':\n return decodeR8Delta(\n propertyBytes,\n dimensions,\n metadata.count,\n getPropertyMin(metadata, property),\n getPropertyMax(metadata, property)\n );\n case 's8':\n return decodeS8(\n propertyBytes,\n dimensions,\n metadata.count,\n getPropertyMax(metadata, property)\n );\n case 's8_delta':\n return decodeS8Delta(\n propertyBytes,\n dimensions,\n metadata.count,\n getPropertyMax(metadata, property)\n );\n case 'ln_0r8':\n return decodeScaleR8(\n propertyBytes,\n dimensions,\n metadata.count,\n getPropertyMin(metadata, property),\n getPropertyMax(metadata, property)\n );\n case 'ln_f16':\n return decodeLogFloat16(propertyBytes, dimensions, metadata.count);\n default:\n throw new Error(`RADLoader: unsupported ${property.property} encoding ${property.encoding}.`);\n }\n}\n\n/** Decodes one optional unsigned 16-bit RADC property. */\nfunction decodeOptionalRADUint16(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n propertyName: string\n): Uint16Array | null {\n const property = findRADProperty(metadata, propertyName);\n if (!property) {\n return null;\n }\n if (property.encoding !== 'u16') {\n throw new Error(`RADLoader: unsupported ${propertyName} encoding ${property.encoding}.`);\n }\n const propertyBytes = getRADPropertyBytes(bytes, metadata, property);\n const values = new Uint16Array(metadata.count);\n for (let splatIndex = 0; splatIndex < metadata.count; splatIndex++) {\n values[splatIndex] = propertyBytes[splatIndex * 2] | (propertyBytes[splatIndex * 2 + 1] << 8);\n }\n return values;\n}\n\n/** Decodes one optional unsigned 32-bit RADC property. */\nfunction decodeOptionalRADUint32(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n propertyName: string\n): Uint32Array | null {\n const property = findRADProperty(metadata, propertyName);\n if (!property) {\n return null;\n }\n if (property.encoding !== 'u32') {\n throw new Error(`RADLoader: unsupported ${propertyName} encoding ${property.encoding}.`);\n }\n const propertyBytes = getRADPropertyBytes(bytes, metadata, property);\n const dataView = new DataView(\n propertyBytes.buffer,\n propertyBytes.byteOffset,\n propertyBytes.byteLength\n );\n const values = new Uint32Array(metadata.count);\n for (let splatIndex = 0; splatIndex < metadata.count; splatIndex++) {\n values[splatIndex] = dataView.getUint32(splatIndex * 4, true);\n }\n return values;\n}\n\n/** Returns decompressed bytes for one RADC property. */\nfunction getRADPropertyBytes(\n bytes: Uint8Array,\n metadata: RADChunkMetadata,\n property: RADChunkProperty\n): Uint8Array {\n const paddedByteLength = roundUpToEight(property.bytes);\n const byteOffset = metadata.payloadByteOffset + property.offset;\n const byteEnd = byteOffset + paddedByteLength;\n if (byteEnd > bytes.byteLength || property.offset + paddedByteLength > metadata.payloadBytes) {\n throw new Error(`RADLoader: property ${property.property} exceeds RADC payload byte length.`);\n }\n\n const propertyBytes = bytes.subarray(byteOffset, byteOffset + property.bytes);\n if (!property.compression) {\n return propertyBytes;\n }\n if (property.compression !== 'gz') {\n throw new Error(`RADLoader: unsupported property compression ${property.compression}.`);\n }\n return decompressRADProperty(propertyBytes, property.property);\n}\n\n/** Inflates one Spark RADC property payload. */\nfunction decompressRADProperty(bytes: Uint8Array, propertyName: string): Uint8Array {\n const arrayBuffer = copyToArrayBuffer(bytes);\n try {\n return new Uint8Array(RAD_PROPERTY_DEFLATE.decompressSync(arrayBuffer));\n } catch {\n try {\n return new Uint8Array(RAD_PROPERTY_RAW_DEFLATE.decompressSync(arrayBuffer));\n } catch {\n throw new Error(`RADLoader: failed to decompress RADC property ${propertyName}.`);\n }\n }\n}\n\n/** Decodes planar Float32 values emitted by Spark RADC. */\nfunction decodePlanarFloat32(bytes: Uint8Array, dimensions: number, count: number): Float32Array {\n const dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const values = new Float32Array(count * dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n values[rowIndex * dimensions + dimension] = dataView.getFloat32(\n (dimension * count + rowIndex) * 4,\n true\n );\n }\n }\n return values;\n}\n\n/** Decodes planar Float16 values emitted by Spark RADC. */\nfunction decodePlanarFloat16(bytes: Uint8Array, dimensions: number, count: number): Float32Array {\n const values = new Float32Array(count * dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byteOffset = (dimension * count + rowIndex) * 2;\n values[rowIndex * dimensions + dimension] = decodeFloat16(\n bytes[byteOffset] | (bytes[byteOffset + 1] << 8)\n );\n }\n }\n return values;\n}\n\n/** Decodes Spark's byte-plane reordered Float32 values. */\nfunction decodeLeBytesFloat32(bytes: Uint8Array, dimensions: number, count: number): Float32Array {\n const values = new Float32Array(count * dimensions);\n const stride = count * dimensions;\n const scratch = new Uint8Array(4);\n const scratchView = new DataView(scratch.buffer);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byteOffset = dimension * count + rowIndex;\n for (let byteIndex = 0; byteIndex < 4; byteIndex++) {\n scratch[byteIndex] = bytes[byteOffset + stride * byteIndex];\n }\n values[rowIndex * dimensions + dimension] = scratchView.getFloat32(0, true);\n }\n }\n return values;\n}\n\n/** Decodes Spark's byte-plane reordered Float16 values. */\nfunction decodeLeBytesFloat16(bytes: Uint8Array, dimensions: number, count: number): Float32Array {\n const values = new Float32Array(count * dimensions);\n const stride = count * dimensions;\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byteOffset = dimension * count + rowIndex;\n values[rowIndex * dimensions + dimension] = decodeFloat16(\n bytes[byteOffset] | (bytes[byteOffset + stride] << 8)\n );\n }\n }\n return values;\n}\n\n/** Decodes R8 quantized planar float values. */\nfunction decodeR8(\n bytes: Uint8Array,\n dimensions: number,\n count: number,\n min: number,\n max: number\n): Float32Array {\n const values = new Float32Array(count * dimensions);\n const range = max - min;\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n values[rowIndex * dimensions + dimension] =\n (bytes[dimension * count + rowIndex] / 255) * range + min;\n }\n }\n return values;\n}\n\n/** Decodes delta-compressed R8 quantized planar float values. */\nfunction decodeR8Delta(\n bytes: Uint8Array,\n dimensions: number,\n count: number,\n min: number,\n max: number\n): Float32Array {\n const values = new Float32Array(count * dimensions);\n const range = max - min;\n const last = new Uint8Array(dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byteOffset = dimension * count + rowIndex;\n const value = (last[dimension] + bytes[byteOffset]) & 0xff;\n last[dimension] = value;\n values[rowIndex * dimensions + dimension] = (value / 255) * range + min;\n }\n }\n return values;\n}\n\n/** Decodes S8 quantized planar float values. */\nfunction decodeS8(bytes: Uint8Array, dimensions: number, count: number, max: number): Float32Array {\n const values = new Float32Array(count * dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byte = bytes[dimension * count + rowIndex];\n values[rowIndex * dimensions + dimension] = (((byte << 24) >> 24) / 127) * max;\n }\n }\n return values;\n}\n\n/** Decodes delta-compressed S8 quantized planar float values. */\nfunction decodeS8Delta(\n bytes: Uint8Array,\n dimensions: number,\n count: number,\n max: number\n): Float32Array {\n const values = new Float32Array(count * dimensions);\n const last = new Uint8Array(dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n const byteOffset = dimension * count + rowIndex;\n const value = (last[dimension] + bytes[byteOffset]) & 0xff;\n last[dimension] = value;\n values[rowIndex * dimensions + dimension] = (((value << 24) >> 24) / 127) * max;\n }\n }\n return values;\n}\n\n/** Decodes Spark scale8 values to linear Gaussian standard deviations. */\nfunction decodeScaleR8(\n bytes: Uint8Array,\n dimensions: number,\n count: number,\n min: number,\n max: number\n): Float32Array {\n const values = new Float32Array(count * dimensions);\n for (let rowIndex = 0; rowIndex < count; rowIndex++) {\n for (let dimension = 0; dimension < dimensions; dimension++) {\n values[rowIndex * dimensions + dimension] = decodeScale8(\n bytes[dimension * count + rowIndex],\n min,\n max\n );\n }\n }\n return values;\n}\n\n/** Decodes Spark log-Float16 scale values to linear Gaussian standard deviations. */\nfunction decodeLogFloat16(bytes: Uint8Array, dimensions: number, count: number): Float32Array {\n const logValues = decodePlanarFloat16(bytes, dimensions, count);\n for (let valueIndex = 0; valueIndex < logValues.length; valueIndex++) {\n logValues[valueIndex] = Math.exp(logValues[valueIndex]);\n }\n return logValues;\n}\n\n/** Decodes Spark oct88r8 quaternion values into `[w, x, y, z]` rotations. */\nfunction decodeRADOct88R8Rotations(bytes: Uint8Array, count: number): Float32Array {\n const rotations = new Float32Array(count * 4);\n for (let splatIndex = 0; splatIndex < count; splatIndex++) {\n const byteOffset = splatIndex * 3;\n const [x, y, z, w] = decodeQuatOct888(\n bytes[byteOffset],\n bytes[byteOffset + 1],\n bytes[byteOffset + 2]\n );\n rotations.set(normalizeQuaternion(w, x, y, z), splatIndex * 4);\n }\n return rotations;\n}\n\n/** Converts decoded RGB floats to loaders.gl color and SH DC columns. */\nfunction convertRgbToColorColumns(rgb: Float32Array): {\n colors: Uint8Array;\n sphericalHarmonicDcs: Float32Array;\n} {\n const colors = new Uint8Array(rgb.length);\n const sphericalHarmonicDcs = new Float32Array(rgb.length);\n for (let componentIndex = 0; componentIndex < rgb.length; componentIndex++) {\n const component = rgb[componentIndex];\n colors[componentIndex] = normalizeColorByte(component);\n sphericalHarmonicDcs[componentIndex] = (component - 0.5) / SH_C0;\n }\n return {colors, sphericalHarmonicDcs};\n}\n\n/** Returns an identity rotation array. */\nfunction makeIdentityRotations(count: number): Float32Array {\n const rotations = new Float32Array(count * 4);\n for (let splatIndex = 0; splatIndex < count; splatIndex++) {\n rotations[splatIndex * 4] = 1;\n }\n return rotations;\n}\n\n/** Decodes Spark's scale8 byte encoding. */\nfunction decodeScale8(scale: number, min: number, max: number): number {\n if (scale === 0) {\n return 0;\n }\n const logScaleStep = (max - min) / 254;\n return Math.exp(min + (scale - 1) * logScaleStep);\n}\n\n/** Decodes Spark's oct888 quaternion encoding into `[x, y, z, w]`. */\nfunction decodeQuatOct888(u: number, v: number, r: number): [number, number, number, number] {\n let x = (u / 255) * 2 - 1;\n let y = (v / 255) * 2 - 1;\n const z = 1 - Math.abs(x) - Math.abs(y);\n const t = Math.max(-z, 0);\n x = x >= 0 ? x - t : x + t;\n y = y >= 0 ? y - t : y + t;\n const length = Math.hypot(x, y, z);\n const axisX = length > Number.EPSILON ? x / length : 1;\n const axisY = length > Number.EPSILON ? y / length : 0;\n const axisZ = length > Number.EPSILON ? z / length : 0;\n const halfTheta = (r / 255) * 0.5 * Math.PI;\n const sinHalfTheta = Math.sin(halfTheta);\n return [axisX * sinHalfTheta, axisY * sinHalfTheta, axisZ * sinHalfTheta, Math.cos(halfTheta)];\n}\n\n/** Returns a named property or throws. */\nfunction requireRADProperty(metadata: RADChunkMetadata, propertyName: string): RADChunkProperty {\n const property = findRADProperty(metadata, propertyName);\n if (!property) {\n throw new Error(`RADLoader: RADC chunk is missing ${propertyName} property.`);\n }\n return property;\n}\n\n/** Returns a named property when present. */\nfunction findRADProperty(\n metadata: RADChunkMetadata,\n propertyName: string\n): RADChunkProperty | undefined {\n return metadata.properties.find(property => property.property === propertyName);\n}\n\n/** Merges source-level splat encoding with chunk-local encoding. */\nfunction getRADChunkDecodeMetadata(\n metadata: RADChunkMetadata,\n options?: RADChunkDecodeOptions\n): RADChunkMetadata {\n const splatEncoding = options?.radChunk?.splatEncoding;\n if (!splatEncoding) {\n return metadata;\n }\n return {\n ...metadata,\n splatEncoding: {\n ...splatEncoding,\n ...metadata.splatEncoding\n }\n };\n}\n\n/** Returns a required quantization minimum. */\nfunction getPropertyMin(metadata: RADChunkMetadata, property: RADChunkProperty): number {\n if (property.min === undefined) {\n const fallback = getSplatEncodingMinimum(metadata.splatEncoding, property.property);\n if (fallback !== undefined) {\n return fallback;\n }\n throw new Error(`RADLoader: RADC property ${property.property} is missing min.`);\n }\n return property.min;\n}\n\n/** Returns a required quantization maximum. */\nfunction getPropertyMax(metadata: RADChunkMetadata, property: RADChunkProperty): number {\n if (property.max === undefined) {\n const fallback = getSplatEncodingMaximum(metadata.splatEncoding, property.property);\n if (fallback !== undefined) {\n return fallback;\n }\n throw new Error(`RADLoader: RADC property ${property.property} is missing max.`);\n }\n return property.max;\n}\n\n/** Returns a source-level minimum value for a quantized RAD property. */\nfunction getSplatEncodingMinimum(\n splatEncoding: RADSplatEncoding | undefined,\n propertyName: string\n): number | undefined {\n switch (propertyName) {\n case 'rgb':\n return splatEncoding?.rgbMin;\n case 'scales':\n return splatEncoding?.lnScaleMin;\n default:\n return undefined;\n }\n}\n\n/** Returns a source-level maximum value for a quantized RAD property. */\nfunction getSplatEncodingMaximum(\n splatEncoding: RADSplatEncoding | undefined,\n propertyName: string\n): number | undefined {\n switch (propertyName) {\n case 'rgb':\n return splatEncoding?.rgbMax;\n case 'scales':\n return splatEncoding?.lnScaleMax;\n case 'sh1':\n return splatEncoding?.sh1Max;\n case 'sh2':\n return splatEncoding?.sh2Max;\n case 'sh3':\n return splatEncoding?.sh3Max;\n default:\n return undefined;\n }\n}\n\n/** Clamps a normalized color component into an unorm8 byte. */\nfunction normalizeColorByte(value: number): number {\n return Math.round(Math.min(Math.max(value, 0), 1) * 255);\n}\n\n/** Copies a byte view into a standalone ArrayBuffer. */\nfunction copyToArrayBuffer(bytes: Uint8Array): ArrayBuffer {\n const copy = new Uint8Array(bytes.byteLength);\n copy.set(bytes);\n return copy.buffer;\n}\n\n/** Converts an ArrayBuffer-like value into a Uint8Array view. */\nfunction getUint8Array(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n return data instanceof ArrayBuffer\n ? new Uint8Array(data)\n : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {parseRADHeader} from './lib/parse-rad';\nimport type {RADMetadata} from './lib/parse-rad';\nimport {RADLoader as RADLoaderMetadata} from './rad-loader-types';\n\nexport {parseRADChunkHeader, parseRADHeader, tryParseRADHeader} from './lib/parse-rad';\nexport {\n parseRADChunk,\n parseRADChunkToGaussianSplats,\n type RADChunkDecodeOptions\n} from './lib/parse-rad-chunk';\n\nconst {preload: _RADLoaderPreload, ...RADLoaderMetadataWithoutPreload} = RADLoaderMetadata;\n\n/** Parser-bearing loader for Spark `.rad` paged LoD Gaussian splat container metadata. */\nexport const RADLoaderWithParser = {\n ...RADLoaderMetadataWithoutPreload,\n parse: async (arrayBuffer: ArrayBuffer) => parseRADHeader(arrayBuffer),\n parseSync: (arrayBuffer: ArrayBuffer) => parseRADHeader(arrayBuffer)\n} as const satisfies LoaderWithParser<RADMetadata, never, LoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {RADFormat} from './splats-format';\nimport type {RADMetadata} from './lib/parse-rad';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Preloads the parser-bearing RAD loader implementation. */\nasync function preload() {\n const {RADLoaderWithParser} = await import('./rad-loader');\n return RADLoaderWithParser;\n}\n\n/** Metadata-only loader for Spark `.rad` paged LoD Gaussian splat containers. */\nexport const RADLoader = {\n dataType: null as unknown as RADMetadata,\n batchType: null as never,\n ...RADFormat,\n version: VERSION,\n options: {},\n preload\n} as const satisfies Loader<RADMetadata, never, LoaderOptions>;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {GaussianSplats, SplatsLoaderOptions} from './types';\nexport type {\n RADChunkMetadata,\n RADChunkProperty,\n RADChunkPropertyCompression,\n RADChunkPropertyEncoding,\n RADChunkPropertyName,\n RADChunkRange,\n RADMetadata,\n RADSplatEncoding\n} from './lib/parse-rad';\nexport {SPLATFormat, KSPLATFormat, SPZFormat, RADFormat} from './splats-format';\nexport {SPLATLoader} from './splat-loader-types';\nexport {KSPLATLoader} from './ksplat-loader-types';\nexport {SPZLoader} from './spz-loader-types';\nexport {RADLoader} from './rad-loader-types';\nexport type {\n RADChunkRequestOptions,\n RADChunkTableIteratorOptions,\n RADSourceLoaderOptions\n} from './rad-source-loader';\nexport {RADSource, RADSourceLoader, resolveRADChunkUrl} from './rad-source-loader';\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {CoreAPI, DataSourceOptions, SourceLoader} from '@loaders.gl/loader-utils';\nimport {DataSource} from '@loaders.gl/loader-utils';\nimport type {MeshArrowTable} from '@loaders.gl/schema';\nimport {RADFormat} from './splats-format';\nimport {\n parseRADChunkHeader,\n tryParseRADHeader,\n type RADChunkMetadata,\n type RADChunkRange,\n type RADMetadata\n} from './lib/parse-rad';\nimport {\n parseRADChunk,\n parseRADChunkToGaussianSplats,\n type RADChunkDecodeOptions\n} from './lib/parse-rad-chunk';\nimport {makeGaussianSplatsArrowTable} from './lib/splats-arrow-table';\nimport type {GaussianSplats} from './types';\n\nconst DEFAULT_RAD_HEADER_BYTE_LENGTHS = [64 * 1024, 256 * 1024, 1024 * 1024];\nconst DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS = 4;\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** Options for creating a Spark RAD source. */\nexport type RADSourceLoaderOptions = DataSourceOptions & {\n rad?: {\n /** Optional request headers forwarded to RAD and RADC fetches. */\n headers?: Record<string, string>;\n /** Whether remote RAD and RADC fetches should include credentials. */\n withCredentials?: boolean;\n /** Header byte lengths to try while probing remote RAD metadata. */\n headerByteLengths?: number[];\n };\n};\n\n/** Optional parameters for fetching RAD chunk bytes or metadata. */\nexport type RADChunkRequestOptions = {\n /** Abort signal forwarded to the underlying fetch. */\n signal?: AbortSignal;\n} & RADChunkDecodeOptions;\n\n/** Options for iterating decoded RAD chunk tables. */\nexport type RADChunkTableIteratorOptions = RADChunkRequestOptions & {\n /** First chunk index to decode. */\n startChunkIndex?: number;\n /** Maximum number of chunks to decode. */\n maxChunks?: number;\n /** Maximum number of splats to decode before stopping. */\n maxSplats?: number;\n /** Maximum number of RAD chunks to fetch and decode at once when the iterator must inspect a chunk window before yielding. */\n maxConcurrentChunkRequests?: number;\n /** Whether loaded child splats should replace parent LoD splats in returned tables. */\n pruneLoadedLoDParents?: boolean;\n};\n\n/** Source factory for Spark `.rad` paged LoD Gaussian splat containers. */\nexport const RADSourceLoader = {\n dataType: null as unknown as RADSource,\n batchType: null as never,\n ...RADFormat,\n name: 'RADSourceLoader',\n version: VERSION,\n type: 'rad',\n fromUrl: true,\n fromBlob: true,\n\n options: {\n rad: {\n headers: undefined!,\n withCredentials: false,\n headerByteLengths: undefined!\n }\n },\n\n defaultOptions: {\n rad: {\n headers: undefined!,\n withCredentials: false,\n headerByteLengths: undefined!\n }\n },\n\n testURL: (url: string): boolean => /\\.rad(?:$|[?#])/i.test(url),\n createDataSource: (\n data: string | Blob,\n options: RADSourceLoaderOptions,\n coreApi?: CoreAPI\n ): RADSource => new RADSource(data, options, coreApi)\n} as const satisfies SourceLoader<RADSource>;\n\n/** Runtime source for RAD metadata and chunk-byte access. */\nexport class RADSource extends DataSource<string | Blob, RADSourceLoaderOptions> {\n /** Shared metadata promise exposed for source-style integrations. */\n metadata: Promise<RADMetadata>;\n\n /** Lazily initialized RAD header promise. */\n private _metadataPromise: Promise<RADMetadata> | null = null;\n /** Lazily initialized per-chunk metadata promises. */\n private _chunkMetadataPromises: Map<number, Promise<RADChunkMetadata>> = new Map();\n\n constructor(data: string | Blob, options: RADSourceLoaderOptions, coreApi?: CoreAPI) {\n super(data, options, RADSourceLoader.defaultOptions, coreApi);\n this.metadata = this.getMetadata();\n }\n\n /** Ensures the RAD header metadata has been loaded. */\n async initialize(): Promise<void> {\n await this.getMetadata();\n }\n\n /** Returns parsed Spark RAD top-level metadata. */\n async getMetadata(): Promise<RADMetadata> {\n if (!this._metadataPromise) {\n this._metadataPromise = this._loadMetadata();\n }\n return await this._metadataPromise;\n }\n\n /** Returns the number of chunks declared by the RAD metadata. */\n async getChunkCount(): Promise<number> {\n const metadata = await this.getMetadata();\n return metadata.chunks.length;\n }\n\n /** Returns the URL used for a chunk, or `null` for Blob-backed inline chunks. */\n async getChunkUrl(chunkIndex: number): Promise<string | null> {\n const metadata = await this.getMetadata();\n const chunk = this._getChunkRange(metadata, chunkIndex);\n if (chunk.filename) {\n return resolveRADChunkUrl(this.url, chunk.filename);\n }\n return typeof this.data === 'string' ? this.url : null;\n }\n\n /** Fetches one raw RADC chunk by index. */\n async getChunk(chunkIndex: number, options: RADChunkRequestOptions = {}): Promise<ArrayBuffer> {\n const metadata = await this.getMetadata();\n const chunk = this._getChunkRange(metadata, chunkIndex);\n\n if (chunk.filename) {\n if (typeof this.data !== 'string') {\n throw new Error('RADSource: sidecar RADC chunks require a URL-backed RAD source.');\n }\n return await this._fetchArrayBuffer(resolveRADChunkUrl(this.url, chunk.filename), undefined, {\n signal: options.signal\n });\n }\n\n if (chunk.bytes === 0) {\n return new ArrayBuffer(0);\n }\n\n const byteOffset = metadata.chunksByteOffset + chunk.offset;\n if (typeof this.data !== 'string') {\n return await this.data.slice(byteOffset, byteOffset + chunk.bytes).arrayBuffer();\n }\n\n return await this._fetchArrayBuffer(\n this.url,\n {offset: byteOffset, bytes: chunk.bytes},\n {signal: options.signal}\n );\n }\n\n /** Fetches and parses metadata for one RADC chunk. */\n async getChunkMetadata(\n chunkIndex: number,\n options: RADChunkRequestOptions = {}\n ): Promise<RADChunkMetadata> {\n let chunkMetadataPromise = this._chunkMetadataPromises.get(chunkIndex);\n if (!chunkMetadataPromise) {\n chunkMetadataPromise = this.getChunk(chunkIndex, options).then(chunk =>\n parseRADChunkHeader(chunk)\n );\n this._chunkMetadataPromises.set(chunkIndex, chunkMetadataPromise);\n }\n return await chunkMetadataPromise;\n }\n\n /** Fetches and decodes one RADC chunk into raw Gaussian splat arrays. */\n async getChunkSplats(\n chunkIndex: number,\n options: RADChunkRequestOptions = {}\n ): Promise<GaussianSplats> {\n const metadata = await this.getMetadata();\n return parseRADChunkToGaussianSplats(\n await this.getChunk(chunkIndex, options),\n this._getChunkDecodeOptions(metadata, options)\n );\n }\n\n /** Fetches and decodes one RADC chunk into a Mesh Arrow table. */\n async getChunkTable(\n chunkIndex: number,\n options: RADChunkRequestOptions = {}\n ): Promise<MeshArrowTable> {\n const metadata = await this.getMetadata();\n return parseRADChunk(\n await this.getChunk(chunkIndex, options),\n this._getChunkDecodeOptions(metadata, options)\n );\n }\n\n /** Iterates decoded RADC chunks as Mesh Arrow tables. */\n async *getChunkTables(options: RADChunkTableIteratorOptions = {}): AsyncIterable<MeshArrowTable> {\n const metadata = await this.getMetadata();\n const startChunkIndex = options.startChunkIndex ?? 0;\n const maxChunks = options.maxChunks ?? Number.POSITIVE_INFINITY;\n const maxSplats = options.maxSplats ?? Number.POSITIVE_INFINITY;\n let chunkCount = 0;\n let splatCount = 0;\n\n if (options.pruneLoadedLoDParents) {\n const chunkIndices = getRADChunkTableIteratorIndices(\n metadata,\n startChunkIndex,\n maxChunks,\n maxSplats\n );\n const splatChunks = await this._getChunkSplatsConcurrently(chunkIndices, options);\n let loadedGlobalSplatEnd = 0;\n for (const splats of splatChunks) {\n chunkCount++;\n splatCount += splats.splatCount;\n const base = getRADChunkSplatBase(splats);\n loadedGlobalSplatEnd = Math.max(loadedGlobalSplatEnd, base + splats.splatCount);\n }\n for (const splats of splatChunks) {\n yield makeGaussianSplatsArrowTable(pruneLoadedLoDParents(splats, loadedGlobalSplatEnd));\n }\n return;\n }\n\n for (\n let chunkIndex = startChunkIndex;\n chunkIndex < metadata.chunks.length && chunkCount < maxChunks && splatCount < maxSplats;\n chunkIndex++\n ) {\n const table = await this.getChunkTable(chunkIndex, options);\n chunkCount++;\n splatCount += table.data.numRows;\n yield table;\n }\n }\n\n /** Fetches and decodes RAD chunks with bounded concurrency while preserving chunk order. */\n private async _getChunkSplatsConcurrently(\n chunkIndices: number[],\n options: RADChunkTableIteratorOptions\n ): Promise<GaussianSplats[]> {\n const splatChunks = new Array<GaussianSplats>(chunkIndices.length);\n const maxConcurrentChunkRequests = getRADMaxConcurrentChunkRequests(\n options.maxConcurrentChunkRequests\n );\n let nextResultIndex = 0;\n\n async function loadNextChunk(source: RADSource): Promise<void> {\n while (nextResultIndex < chunkIndices.length) {\n const resultIndex = nextResultIndex++;\n const chunkIndex = chunkIndices[resultIndex];\n splatChunks[resultIndex] = await source.getChunkSplats(chunkIndex, options);\n }\n }\n\n const workerCount = Math.min(maxConcurrentChunkRequests, chunkIndices.length);\n await Promise.all(Array.from({length: workerCount}, () => loadNextChunk(this)));\n return splatChunks;\n }\n\n /** Adds source-level RAD decode metadata to chunk decode options. */\n private _getChunkDecodeOptions(\n metadata: RADMetadata,\n options: RADChunkRequestOptions\n ): RADChunkRequestOptions {\n return {\n ...options,\n radChunk: {\n splatEncoding: metadata.splatEncoding,\n ...options.radChunk\n }\n };\n }\n\n /** Loads and parses the top-level RAD metadata. */\n private async _loadMetadata(): Promise<RADMetadata> {\n const headerByteLengths = this.options.rad?.headerByteLengths?.length\n ? this.options.rad.headerByteLengths\n : DEFAULT_RAD_HEADER_BYTE_LENGTHS;\n\n if (typeof this.data !== 'string') {\n const byteLength = Math.min(this.data.size, Math.max(...headerByteLengths));\n const metadata = tryParseRADHeader(await this.data.slice(0, byteLength).arrayBuffer());\n if (metadata) {\n return metadata;\n }\n throw new Error('RADSource: Blob does not contain a complete RAD metadata header.');\n }\n\n for (const byteLength of headerByteLengths) {\n const metadata = tryParseRADHeader(\n await this._fetchArrayBuffer(this.url, {offset: 0, bytes: byteLength})\n );\n if (metadata) {\n return metadata;\n }\n }\n\n throw new Error('RADSource: failed to load a complete RAD metadata header.');\n }\n\n /** Returns a validated chunk table entry. */\n private _getChunkRange(metadata: RADMetadata, chunkIndex: number): RADChunkRange {\n if (!Number.isInteger(chunkIndex) || chunkIndex < 0 || chunkIndex >= metadata.chunks.length) {\n throw new Error(\n `RADSource: chunk index ${chunkIndex} is outside 0-${metadata.chunks.length - 1}.`\n );\n }\n return metadata.chunks[chunkIndex];\n }\n\n /** Fetches a full or ranged ArrayBuffer while tolerating non-206 range fallbacks. */\n private async _fetchArrayBuffer(\n url: string,\n range?: {offset: number; bytes: number},\n options: RADChunkRequestOptions = {}\n ): Promise<ArrayBuffer> {\n const response = await this._fetchResponse(url, this._getRequestInit(range, options));\n if (!response.ok) {\n throw new Error(\n `RADSource: failed to fetch ${url}: ${response.status} ${response.statusText}`\n );\n }\n\n const arrayBuffer = await response.arrayBuffer();\n if (range && response.status !== 206 && arrayBuffer.byteLength >= range.offset + range.bytes) {\n return arrayBuffer.slice(range.offset, range.offset + range.bytes);\n }\n if (range && arrayBuffer.byteLength > range.bytes) {\n return arrayBuffer.slice(0, range.bytes);\n }\n return arrayBuffer;\n }\n\n /** Fetches through custom source fetch hooks or the injected core fetchFile helper. */\n private async _fetchResponse(url: string, requestInit: RequestInit): Promise<Response> {\n if (this._hasCustomFetch()) {\n return await this.fetch(url, requestInit);\n }\n return this.hasCoreApi\n ? await this.coreApi.fetchFile(url, requestInit)\n : await this.fetch(url, requestInit);\n }\n\n /** Returns true when source options supplied an explicit fetch override. */\n private _hasCustomFetch(): boolean {\n return Boolean(this.loadOptions?.core?.fetch || this.loadOptions?.fetch);\n }\n\n /** Builds request options for RAD fetches. */\n private _getRequestInit(\n range?: {offset: number; bytes: number},\n options: RADChunkRequestOptions = {}\n ): RequestInit {\n const headers = new Headers(this.options.rad?.headers);\n if (range && range.bytes > 0) {\n headers.set('Range', `bytes=${range.offset}-${range.offset + range.bytes - 1}`);\n }\n\n return {\n headers,\n credentials: this.options.rad?.withCredentials ? 'include' : 'same-origin',\n signal: options.signal\n };\n }\n}\n\n/** Returns the RAD chunk indices requested by a chunk-table iterator. */\nfunction getRADChunkTableIteratorIndices(\n metadata: RADMetadata,\n startChunkIndex: number,\n maxChunks: number,\n maxSplats: number\n): number[] {\n const chunkIndices: number[] = [];\n let estimatedSplatCount = 0;\n for (\n let chunkIndex = startChunkIndex;\n chunkIndex < metadata.chunks.length &&\n chunkIndices.length < maxChunks &&\n estimatedSplatCount < maxSplats;\n chunkIndex++\n ) {\n const chunk = metadata.chunks[chunkIndex];\n chunkIndices.push(chunkIndex);\n estimatedSplatCount += chunk?.count ?? metadata.chunkSize ?? 0;\n }\n return chunkIndices;\n}\n\n/** Returns a positive integer chunk request concurrency limit. */\nfunction getRADMaxConcurrentChunkRequests(maxConcurrentChunkRequests?: number): number {\n return Number.isFinite(maxConcurrentChunkRequests) && maxConcurrentChunkRequests! > 0\n ? Math.floor(maxConcurrentChunkRequests!)\n : DEFAULT_RAD_MAX_CONCURRENT_CHUNK_REQUESTS;\n}\n\n/** Returns the first global splat index represented by decoded RAD chunk data. */\nfunction getRADChunkSplatBase(splats: GaussianSplats): number {\n return typeof splats.loaderData?.base === 'number' ? splats.loaderData.base : 0;\n}\n\n/** Remove parent LoD rows when their children are present in the loaded chunk range. */\nfunction pruneLoadedLoDParents(\n splats: GaussianSplats,\n loadedGlobalSplatEnd: number\n): GaussianSplats {\n const childCounts = splats.loaderData?.childCounts;\n const childStarts = splats.loaderData?.childStarts;\n if (!(childCounts instanceof Uint16Array) || !(childStarts instanceof Uint32Array)) {\n return splats;\n }\n\n const keepRows = new Uint32Array(splats.splatCount);\n let keepCount = 0;\n for (let rowIndex = 0; rowIndex < splats.splatCount; rowIndex++) {\n const childCount = childCounts[rowIndex];\n const childStart = childStarts[rowIndex];\n if (childCount > 0 && childStart < loadedGlobalSplatEnd) {\n continue;\n }\n keepRows[keepCount++] = rowIndex;\n }\n if (keepCount === splats.splatCount) {\n return splats;\n }\n\n const keptRows = keepRows.subarray(0, keepCount);\n const sphericalHarmonicsComponentCount = splats.sphericalHarmonicsComponentCount ?? 0;\n return {\n ...splats,\n splatCount: keepCount,\n positions: copyInterleavedRows(splats.positions, 3, keptRows),\n scales: copyInterleavedRows(splats.scales, 3, keptRows),\n rotations: copyInterleavedRows(splats.rotations, 4, keptRows),\n colors: copyInterleavedRows(splats.colors, 3, keptRows),\n sphericalHarmonicDcs: splats.sphericalHarmonicDcs\n ? copyInterleavedRows(splats.sphericalHarmonicDcs, 3, keptRows)\n : undefined,\n opacities: copyInterleavedRows(splats.opacities, 1, keptRows),\n sphericalHarmonics:\n splats.sphericalHarmonics && sphericalHarmonicsComponentCount\n ? copyInterleavedRows(splats.sphericalHarmonics, sphericalHarmonicsComponentCount, keptRows)\n : undefined,\n loaderData: {\n ...splats.loaderData,\n count: keepCount,\n childCounts: copyInterleavedRows(childCounts, 1, keptRows),\n childStarts: copyInterleavedRows(childStarts, 1, keptRows)\n }\n };\n}\n\n/** Copy selected rows from an interleaved typed array. */\nfunction copyInterleavedRows<T extends Float32Array | Uint8Array | Uint16Array | Uint32Array>(\n values: T,\n itemSize: number,\n rows: Uint32Array\n): T {\n const copiedValues = new (values.constructor as {new (length: number): T})(\n rows.length * itemSize\n );\n for (let outputRowIndex = 0; outputRowIndex < rows.length; outputRowIndex++) {\n const inputOffset = rows[outputRowIndex] * itemSize;\n const outputOffset = outputRowIndex * itemSize;\n copiedValues.set(values.subarray(inputOffset, inputOffset + itemSize), outputOffset);\n }\n return copiedValues;\n}\n\n/** Resolves a sidecar RADC chunk filename relative to its parent RAD URL. */\nexport function resolveRADChunkUrl(rootUrl: string, chunkFilename: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(chunkFilename) || chunkFilename.startsWith('/')) {\n return chunkFilename;\n }\n if (!rootUrl) {\n throw new Error('RADSource: cannot resolve a sidecar RADC chunk without a RAD URL.');\n }\n\n try {\n return new URL(chunkFilename, rootUrl).toString();\n } catch {\n const [rootPath, suffix = ''] = rootUrl.split(/([?#].*)/, 2);\n const lastSlashIndex = Math.max(rootPath.lastIndexOf('/'), rootPath.lastIndexOf('\\\\'));\n const rootDirectory = lastSlashIndex >= 0 ? rootPath.slice(0, lastSlashIndex + 1) : '';\n return `${rootDirectory}${chunkFilename}${suffix}`;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAOa,aAWA,cAWA,WAYA;AAzCb;;;AAOO,IAAM,cAAc;MACzB,MAAM;MACN,IAAI;MACJ,QAAQ;MACR,QAAQ;MACR,YAAY,CAAC,OAAO;MACpB,WAAW,CAAC,0BAA0B;MACtC,QAAQ;;AAIH,IAAM,eAAe;MAC1B,MAAM;MACN,IAAI;MACJ,QAAQ;MACR,QAAQ;MACR,YAAY,CAAC,QAAQ;MACrB,WAAW,CAAC,0BAA0B;MACtC,QAAQ;;AAIH,IAAM,YAAY;MACvB,MAAM;MACN,IAAI;MACJ,QAAQ;MACR,QAAQ;MACR,YAAY,CAAC,KAAK;MAClB,WAAW,CAAC,0BAA0B;MACtC,QAAQ;MACR,OAAO,CAAC,IAAI,WAAW,CAAC,IAAM,IAAM,IAAM,EAAI,CAAC,EAAE,MAAM;;AAIlD,IAAM,YAAY;MACvB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O,SAAS,aAAa,cAAc,QAAQ,GAAG,YAAY;EACrF;AACA,SAAO;AACT;AAGM,SAAU,mBAAmB,SAAiB,eAAqB;AACvE,MAAI,uBAAuB,KAAK,aAAa,KAAK,cAAc,WAAW,GAAG,GAAG;AAC/E,WAAO;EACT;AACA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,mEAAmE;EACrF;AAEA,MAAI;AACF,WAAO,IAAI,IAAI,eAAe,OAAO,EAAE,SAAQ;EACjD,QAAE;AACA,UAAM,CAAC,UAAU,SAAS,EAAE,IAAI,QAAQ,MAAM,YAAY,CAAC;AAC3D,UAAM,iBAAiB,KAAK,IAAI,SAAS,YAAY,GAAG,GAAG,SAAS,YAAY,IAAI,CAAC;AACrF,UAAM,gBAAgB,kBAAkB,IAAI,SAAS,MAAM,GAAG,iBAAiB,CAAC,IAAI;AACpF,WAAO,GAAG,gBAAgB,gBAAgB;EAC5C;AACF;",
6
+ "names": ["SPLATLoaderWithParser", "preload", "KSPLATLoaderWithParser", "VERSION", "getSphericalHarmonicsComponentCount", "preload", "SPZLoaderWithParser", "VERSION", "readSafeUint64", "getUint8Array", "normalizeColorByte", "import_compression", "preload", "RADLoaderWithParser", "VERSION", "VERSION"]
7
+ }
@@ -0,0 +1,10 @@
1
+ export type { GaussianSplats, SplatsLoaderOptions } from "./types.js";
2
+ export type { RADChunkMetadata, RADChunkProperty, RADChunkPropertyCompression, RADChunkPropertyEncoding, RADChunkPropertyName, RADChunkRange, RADMetadata, RADSplatEncoding } from "./lib/parse-rad.js";
3
+ export { SPLATFormat, KSPLATFormat, SPZFormat, RADFormat } from "./splats-format.js";
4
+ export { SPLATLoader } from "./splat-loader-types.js";
5
+ export { KSPLATLoader } from "./ksplat-loader-types.js";
6
+ export { SPZLoader } from "./spz-loader-types.js";
7
+ export { RADLoader } from "./rad-loader-types.js";
8
+ export type { RADChunkRequestOptions, RADChunkTableIteratorOptions, RADSourceLoaderOptions } from "./rad-source-loader.js";
9
+ export { RADSource, RADSourceLoader, resolveRADChunkUrl } from "./rad-source-loader.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAC,cAAc,EAAE,mBAAmB,EAAC,mBAAgB;AACjE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,gBAAgB,EACjB,2BAAwB;AACzB,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAC,2BAAwB;AAChF,OAAO,EAAC,WAAW,EAAC,gCAA6B;AACjD,OAAO,EAAC,YAAY,EAAC,iCAA8B;AACnD,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,YAAY,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,sBAAsB,EACvB,+BAA4B;AAC7B,OAAO,EAAC,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAC,+BAA4B"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export { SPLATFormat, KSPLATFormat, SPZFormat, RADFormat } from "./splats-format.js";
5
+ export { SPLATLoader } from "./splat-loader-types.js";
6
+ export { KSPLATLoader } from "./ksplat-loader-types.js";
7
+ export { SPZLoader } from "./spz-loader-types.js";
8
+ export { RADLoader } from "./rad-loader-types.js";
9
+ export { RADSource, RADSourceLoader, resolveRADChunkUrl } from "./rad-source-loader.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAapC,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAC,2BAAwB;AAChF,OAAO,EAAC,WAAW,EAAC,gCAA6B;AACjD,OAAO,EAAC,YAAY,EAAC,iCAA8B;AACnD,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAC7C,OAAO,EAAC,SAAS,EAAC,8BAA2B;AAM7C,OAAO,EAAC,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAC,+BAA4B"}
@@ -0,0 +1,42 @@
1
+ import type { MeshArrowTable } from '@loaders.gl/schema';
2
+ /** Preloads the parser-bearing KSPLAT loader implementation. */
3
+ declare function preload(): Promise<{
4
+ readonly parse: (arrayBuffer: ArrayBuffer) => Promise<MeshArrowTable>;
5
+ readonly parseSync: (arrayBuffer: ArrayBuffer) => MeshArrowTable;
6
+ readonly version: any;
7
+ readonly options: {
8
+ readonly splats: {
9
+ readonly shape: "arrow-table";
10
+ };
11
+ };
12
+ readonly name: "KSPLAT";
13
+ readonly id: "ksplat";
14
+ readonly module: "splats";
15
+ readonly format: "ksplat";
16
+ readonly extensions: ["ksplat"];
17
+ readonly mimeTypes: ["application/octet-stream"];
18
+ readonly binary: true;
19
+ readonly dataType: MeshArrowTable;
20
+ readonly batchType: never;
21
+ }>;
22
+ /** Metadata-only loader for `.ksplat` Gaussian splat files. */
23
+ export declare const KSPLATLoader: {
24
+ readonly version: any;
25
+ readonly options: {
26
+ readonly splats: {
27
+ readonly shape: "arrow-table";
28
+ };
29
+ };
30
+ readonly preload: typeof preload;
31
+ readonly name: "KSPLAT";
32
+ readonly id: "ksplat";
33
+ readonly module: "splats";
34
+ readonly format: "ksplat";
35
+ readonly extensions: ["ksplat"];
36
+ readonly mimeTypes: ["application/octet-stream"];
37
+ readonly binary: true;
38
+ readonly dataType: MeshArrowTable;
39
+ readonly batchType: never;
40
+ };
41
+ export {};
42
+ //# sourceMappingURL=ksplat-loader-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksplat-loader-types.d.ts","sourceRoot":"","sources":["../src/ksplat-loader-types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAQvD,gEAAgE;AAChE,iBAAe,OAAO;;;;;;;;;;;;;;;;uBAOS,cAAc;wBACxB,KAAK;GALzB;AAED,+DAA+D;AAC/D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;uBACM,cAAc;wBACxB,KAAK;CAS6C,CAAC"}
@@ -0,0 +1,26 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { KSPLATFormat } from "./splats-format.js";
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof "5.0.0-alpha.1" !== 'undefined' ? "5.0.0-alpha.1" : 'latest';
8
+ /** Preloads the parser-bearing KSPLAT loader implementation. */
9
+ async function preload() {
10
+ const { KSPLATLoaderWithParser } = await import("./ksplat-loader.js");
11
+ return KSPLATLoaderWithParser;
12
+ }
13
+ /** Metadata-only loader for `.ksplat` Gaussian splat files. */
14
+ export const KSPLATLoader = {
15
+ dataType: null,
16
+ batchType: null,
17
+ ...KSPLATFormat,
18
+ version: VERSION,
19
+ options: {
20
+ splats: {
21
+ shape: 'arrow-table'
22
+ }
23
+ },
24
+ preload
25
+ };
26
+ //# sourceMappingURL=ksplat-loader-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksplat-loader-types.js","sourceRoot":"","sources":["../src/ksplat-loader-types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,yDAAyD;AACzD,qDAAqD;AACrD,MAAM,OAAO,GAAG,sBAAkB,KAAK,WAAW,CAAC,CAAC,iBAAa,CAAC,CAAC,QAAQ,CAAC;AAE5E,gEAAgE;AAChE,KAAK,UAAU,OAAO;IACpB,MAAM,EAAC,sBAAsB,EAAC,GAAG,MAAM,MAAM,sBAAmB,CAAC;IACjE,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,IAAiC;IAC3C,SAAS,EAAE,IAAa;IACxB,GAAG,YAAY;IACf,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;QACP,MAAM,EAAE;YACN,KAAK,EAAE,aAAa;SACrB;KACF;IACD,OAAO;CAC8D,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { MeshArrowTable } from '@loaders.gl/schema';
2
+ /** Parser-bearing loader for `.ksplat` Gaussian splat files. */
3
+ export declare const KSPLATLoaderWithParser: {
4
+ readonly parse: (arrayBuffer: ArrayBuffer) => Promise<MeshArrowTable>;
5
+ readonly parseSync: (arrayBuffer: ArrayBuffer) => MeshArrowTable;
6
+ readonly version: any;
7
+ readonly options: {
8
+ readonly splats: {
9
+ readonly shape: "arrow-table";
10
+ };
11
+ };
12
+ readonly name: "KSPLAT";
13
+ readonly id: "ksplat";
14
+ readonly module: "splats";
15
+ readonly format: "ksplat";
16
+ readonly extensions: ["ksplat"];
17
+ readonly mimeTypes: ["application/octet-stream"];
18
+ readonly binary: true;
19
+ readonly dataType: MeshArrowTable;
20
+ readonly batchType: never;
21
+ };
22
+ //# sourceMappingURL=ksplat-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksplat-loader.d.ts","sourceRoot":"","sources":["../src/ksplat-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAOvD,gEAAgE;AAChE,eAAO,MAAM,sBAAsB;kCAEN,WAAW;sCACb,WAAW;;;;;;;;;;;;;;;;CAC2C,CAAC"}
@@ -0,0 +1,13 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { parseKSPLAT } from "./lib/parse-ksplat.js";
5
+ import { KSPLATLoader as KSPLATLoaderMetadata } from "./ksplat-loader-types.js";
6
+ const { preload: _KSPLATLoaderPreload, ...KSPLATLoaderMetadataWithoutPreload } = KSPLATLoaderMetadata;
7
+ /** Parser-bearing loader for `.ksplat` Gaussian splat files. */
8
+ export const KSPLATLoaderWithParser = {
9
+ ...KSPLATLoaderMetadataWithoutPreload,
10
+ parse: async (arrayBuffer) => parseKSPLAT(arrayBuffer),
11
+ parseSync: (arrayBuffer) => parseKSPLAT(arrayBuffer)
12
+ };
13
+ //# sourceMappingURL=ksplat-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ksplat-loader.js","sourceRoot":"","sources":["../src/ksplat-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAC,WAAW,EAAC,8BAA2B;AAC/C,OAAO,EAAC,YAAY,IAAI,oBAAoB,EAAC,iCAA8B;AAE3E,MAAM,EAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,kCAAkC,EAAC,GAAG,oBAAoB,CAAC;AAEpG,gEAAgE;AAChE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,GAAG,kCAAkC;IACrC,KAAK,EAAE,KAAK,EAAE,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC;IACnE,SAAS,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC;CACc,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { MeshArrowTable } from '@loaders.gl/schema';
2
+ import type { GaussianSplats } from "../types.js";
3
+ /** Parses a `.ksplat` ArrayBuffer into a Mesh Arrow table. */
4
+ export declare function parseKSPLAT(data: ArrayBuffer): MeshArrowTable;
5
+ /** Parses a `.ksplat` ArrayBuffer into decoded Gaussian splat values. */
6
+ export declare function parseKSPLATToGaussianSplats(data: ArrayBuffer): GaussianSplats;
7
+ //# sourceMappingURL=parse-ksplat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-ksplat.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ksplat.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAC,cAAc,EAAC,oBAAiB;AA0F7C,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAE7D;AAED,yEAAyE;AACzE,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAuE7E"}