@voluma/vlam 0.2.4 → 0.3.2

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 (138) hide show
  1. package/README.md +3 -4
  2. package/dist/chunk-loader-DlNwggfG.js +1859 -0
  3. package/dist/chunk-loader-DlNwggfG.js.map +1 -0
  4. package/dist/{compute-sorter.d.ts → core/compute-sorter.d.ts} +1 -1
  5. package/dist/core/index.d.ts +45 -0
  6. package/dist/{splat-scene.d.ts → core/merged-splat-mesh.d.ts} +14 -15
  7. package/dist/{orientation.d.ts → core/orientation.d.ts} +7 -7
  8. package/dist/{relighting.d.ts → core/relighting.d.ts} +1 -1
  9. package/dist/{source-transform.d.ts → core/source-transform.d.ts} +4 -4
  10. package/dist/{splat-budget.d.ts → core/splat-budget.d.ts} +2 -2
  11. package/dist/{splat-data.d.ts → core/splat-data.d.ts} +4 -4
  12. package/dist/{splat-mesh-material.d.ts → core/splat-mesh-material.d.ts} +2 -2
  13. package/dist/{splat-mesh-types.d.ts → core/splat-mesh-types.d.ts} +19 -10
  14. package/dist/{splat-mesh.d.ts → core/splat-mesh.d.ts} +4 -4
  15. package/dist/{splat-modifier.d.ts → core/splat-modifier.d.ts} +5 -5
  16. package/dist/{webgpu-limits.d.ts → core/webgpu-limits.d.ts} +0 -59
  17. package/dist/{effects.d.ts → effects/index.d.ts} +14 -13
  18. package/dist/effects.js.map +1 -1
  19. package/dist/formats/ksplat/index.d.ts +1 -1
  20. package/dist/formats/ksplat/parse-ksplat.d.ts +1 -1
  21. package/dist/formats/ksplat.js.map +1 -1
  22. package/dist/formats/lcc/collision-mesh.d.ts +3 -3
  23. package/dist/formats/lcc/collision-partition.d.ts +1 -1
  24. package/dist/formats/lcc/lcc.d.ts +3 -3
  25. package/dist/formats/lcc/lcc2.d.ts +2 -2
  26. package/dist/formats/lcc/parse-lcc.d.ts +1 -1
  27. package/dist/formats/lcc.js +17 -16
  28. package/dist/formats/lcc.js.map +1 -1
  29. package/dist/formats/ply/index.d.ts +1 -1
  30. package/dist/formats/ply/parse-compressed-ply.d.ts +2 -2
  31. package/dist/formats/ply/parse-splat-ply.d.ts +4 -4
  32. package/dist/formats/ply.js +1 -1
  33. package/dist/formats/ply.js.map +1 -1
  34. package/dist/formats/rad/frontier-worker-protocol.d.ts +8 -1
  35. package/dist/formats/rad/index.d.ts +2 -2
  36. package/dist/formats/rad/parse-rad.d.ts +2 -2
  37. package/dist/formats/rad/rad-foveated-source.d.ts +3 -3
  38. package/dist/formats/rad/rad.d.ts +7 -7
  39. package/dist/formats/rad.js +3 -3
  40. package/dist/formats/rad.js.map +1 -1
  41. package/dist/formats/sog/index.d.ts +1 -1
  42. package/dist/formats/sog/parse-sog.d.ts +6 -6
  43. package/dist/formats/sog.js.map +1 -1
  44. package/dist/formats/splat/index.d.ts +1 -1
  45. package/dist/formats/splat/parse-splat.d.ts +1 -1
  46. package/dist/formats/splat.js.map +1 -1
  47. package/dist/formats/spz/index.d.ts +1 -1
  48. package/dist/formats/spz/parse-spz.d.ts +1 -1
  49. package/dist/formats/spz.js.map +1 -1
  50. package/dist/half-float-Cs4FDq8Q.js.map +1 -1
  51. package/dist/index.js +253 -9047
  52. package/dist/index.js.map +1 -1
  53. package/dist/{chunk-loader.d.ts → loaders/chunk-loader.d.ts} +4 -4
  54. package/dist/loaders/index.d.ts +15 -0
  55. package/dist/{load-scene.d.ts → loaders/load-splat-data.d.ts} +16 -14
  56. package/dist/{load-worker-protocol.d.ts → loaders/load-worker-protocol.d.ts} +2 -2
  57. package/dist/{loading.d.ts → loaders/loading.d.ts} +8 -8
  58. package/dist/loaders.js +26 -0
  59. package/dist/loaders.js.map +1 -0
  60. package/dist/loading-wLo8vRbA.js.map +1 -1
  61. package/dist/{splat-mesh-types-CTN_duw2.js → lod-scheduler-B0a_uBlv.js} +133 -140
  62. package/dist/lod-scheduler-B0a_uBlv.js.map +1 -0
  63. package/dist/logging-BfPdd7NJ.js.map +1 -1
  64. package/dist/{ply-header-BwgExCn-.js → ply-header-B9WllbPg.js} +3 -3
  65. package/dist/ply-header-B9WllbPg.js.map +1 -0
  66. package/dist/radix-sorter-BrbUg_CV.js +178 -0
  67. package/dist/radix-sorter-BrbUg_CV.js.map +1 -0
  68. package/dist/relighting-Tiwep8yd.js +977 -0
  69. package/dist/relighting-Tiwep8yd.js.map +1 -0
  70. package/dist/selection/index.d.ts +13 -0
  71. package/dist/{selection-volume.d.ts → selection/selection-volume.d.ts} +1 -1
  72. package/dist/{splat-partition.d.ts → selection/splat-partition.d.ts} +2 -2
  73. package/dist/selection.js +137 -0
  74. package/dist/selection.js.map +1 -0
  75. package/dist/sh-pack-D5wAe5gg.js.map +1 -1
  76. package/dist/{splat-budget-DXew_86c.js → splat-budget-DuVZspPQ.js} +7 -7
  77. package/dist/splat-budget-DuVZspPQ.js.map +1 -0
  78. package/dist/splat-data-BZM5dhhx.js.map +1 -1
  79. package/dist/splat-mesh-CsLOQb08.js +1942 -0
  80. package/dist/splat-mesh-CsLOQb08.js.map +1 -0
  81. package/dist/splat-mesh-types-BZIko-_9.js +18 -0
  82. package/dist/splat-mesh-types-BZIko-_9.js.map +1 -0
  83. package/dist/static-lod/index.d.ts +12 -0
  84. package/dist/{static-lod-splat-mesh.d.ts → static-lod/static-lod-splat-mesh.d.ts} +3 -3
  85. package/dist/{static-lod-worker-protocol.d.ts → static-lod/static-lod-worker-protocol.d.ts} +1 -1
  86. package/dist/{static-lod.d.ts → static-lod/static-lod.d.ts} +1 -1
  87. package/dist/{static-lod-worker-D2fyqQZO.js → static-lod-worker-DktKnJkR.js} +46 -46
  88. package/dist/{static-lod-worker-D2fyqQZO.js.map → static-lod-worker-DktKnJkR.js.map} +1 -1
  89. package/dist/static-lod.js +148 -0
  90. package/dist/static-lod.js.map +1 -0
  91. package/dist/{budget-governor.d.ts → streaming/budget-governor.d.ts} +4 -4
  92. package/dist/{camera-budget-governor.d.ts → streaming/camera-budget-governor.d.ts} +11 -11
  93. package/dist/{chunk-cache-budget.d.ts → streaming/chunk-cache-budget.d.ts} +5 -5
  94. package/dist/{chunk-fetch-scheduler.d.ts → streaming/chunk-fetch-scheduler.d.ts} +4 -4
  95. package/dist/{dataset-source.d.ts → streaming/dataset-source.d.ts} +1 -1
  96. package/dist/streaming/index.d.ts +23 -0
  97. package/dist/{lod-scheduler.d.ts → streaming/lod-scheduler.d.ts} +1 -1
  98. package/dist/{lod-source.d.ts → streaming/lod-source.d.ts} +9 -9
  99. package/dist/{streamed-splat-mesh-utils.d.ts → streaming/streamed-splat-mesh-utils.d.ts} +2 -2
  100. package/dist/{streamed-splat-mesh.d.ts → streaming/streamed-splat-mesh.d.ts} +66 -32
  101. package/dist/streaming.js +2911 -0
  102. package/dist/streaming.js.map +1 -0
  103. package/dist/unified/index.d.ts +11 -0
  104. package/dist/{unified-splat-renderer.d.ts → unified/unified-splat-mesh.d.ts} +23 -16
  105. package/dist/unified/unified-work-buffer.d.ts +66 -0
  106. package/dist/{work-buffer-gather.d.ts → unified/work-buffer-gather.d.ts} +6 -6
  107. package/dist/{work-buffer-material.d.ts → unified/work-buffer-material.d.ts} +1 -1
  108. package/dist/unified.js +746 -0
  109. package/dist/unified.js.map +1 -0
  110. package/dist/webgpu-limits-Y3CI_6_6.js +43 -0
  111. package/dist/webgpu-limits-Y3CI_6_6.js.map +1 -0
  112. package/package.json +27 -7
  113. package/dist/index.d.ts +0 -54
  114. package/dist/ply-header-BwgExCn-.js.map +0 -1
  115. package/dist/splat-budget-DXew_86c.js.map +0 -1
  116. package/dist/splat-mesh-types-CTN_duw2.js.map +0 -1
  117. /package/dist/{create-splat-renderer.d.ts → core/create-splat-renderer.d.ts} +0 -0
  118. /package/dist/{depth-of-field.d.ts → core/depth-of-field.d.ts} +0 -0
  119. /package/dist/{half-float.d.ts → core/half-float.d.ts} +0 -0
  120. /package/dist/{logging.d.ts → core/logging.d.ts} +0 -0
  121. /package/dist/{radix-sort.d.ts → core/radix-sort.d.ts} +0 -0
  122. /package/dist/{radix-sorter.d.ts → core/radix-sorter.d.ts} +0 -0
  123. /package/dist/{relighting-pass.d.ts → core/relighting-pass.d.ts} +0 -0
  124. /package/dist/{sh-pack.d.ts → core/sh-pack.d.ts} +0 -0
  125. /package/dist/{sort-scheduler.d.ts → core/sort-scheduler.d.ts} +0 -0
  126. /package/dist/{sort-worker-protocol.d.ts → core/sort-worker-protocol.d.ts} +0 -0
  127. /package/dist/{sorter.d.ts → core/sorter.d.ts} +0 -0
  128. /package/dist/{splat-depth-pack.d.ts → core/splat-depth-pack.d.ts} +0 -0
  129. /package/dist/{splat-mesh-picking.d.ts → core/splat-mesh-picking.d.ts} +0 -0
  130. /package/dist/{splat-mesh-pool.d.ts → core/splat-mesh-pool.d.ts} +0 -0
  131. /package/dist/{splat-modifier-stack.d.ts → core/splat-modifier-stack.d.ts} +0 -0
  132. /package/dist/{splat-query.d.ts → core/splat-query.d.ts} +0 -0
  133. /package/dist/{splat-sort-bounds.d.ts → core/splat-sort-bounds.d.ts} +0 -0
  134. /package/dist/{storage-attribute-mirror.d.ts → core/storage-attribute-mirror.d.ts} +0 -0
  135. /package/dist/{worker-sorter.d.ts → core/worker-sorter.d.ts} +0 -0
  136. /package/dist/{xr-view.d.ts → core/xr-view.d.ts} +0 -0
  137. /package/dist/{ply-header.d.ts → loaders/ply-header.d.ts} +0 -0
  138. /package/dist/{lod-manifest.d.ts → streaming/lod-manifest.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ksplat.js","sources":["../../src/lib/formats/ksplat/parse-ksplat.ts"],"sourcesContent":["import { halfToFloat } from '../../half-float';\nimport { packShCoefficients } from '../../sh-pack';\nimport { writeCovariance, type SplatData } from '../../splat-data';\n\nconst HEADER_BYTES = 4096;\nconst SECTION_HEADER_BYTES = 1024;\nconst BUCKET_CENTER_BYTES = 12;\n/** Default 8-bit SH dequant range half-width (GaussianSplats3D `Constants`). */\nconst DEFAULT_SH_RANGE_HALF = 1.5;\n\ninterface KsplatHeader {\n versionMajor: number;\n versionMinor: number;\n sectionCount: number;\n splatCount: number;\n compressionLevel: number;\n shCoeffMin: number;\n shCoeffMax: number;\n}\n\ninterface KsplatSection {\n count: number;\n maxCount: number;\n bucketSize: number;\n bucketCount: number;\n bucketBlockSize: number;\n bucketStorageBytes: number;\n compressionRange: number;\n fullBucketCount: number;\n partialBucketCount: number;\n shDegree: number;\n bytesPerSplat: number;\n base: number;\n bucketsBase: number;\n dataBase: number;\n}\n\n/**\n * Parses a GaussianSplats3D `.ksplat` file, including compression levels 0–2.\n * Base color, opacity, position, scale, rotation and optional higher-order\n * spherical harmonics (degrees 1–2) are retained.\n *\n * @throws {Error} if the header, section layout or record data is invalid.\n */\nexport function parseKsplat(buffer: ArrayBuffer): SplatData {\n const view = new DataView(buffer);\n const header = parseHeader(view);\n const sections = parseSections(view, header);\n const totalSectionSplats = sections.reduce((sum, section) => sum + section.count, 0);\n if (totalSectionSplats !== header.splatCount) {\n throw new Error(\n `Invalid KSPLAT counts: header declares ${header.splatCount}, sections contain ${totalSectionSplats}.`,\n );\n }\n\n const positions = new Float32Array(header.splatCount * 3);\n const colors = new Uint8Array(header.splatCount * 4);\n const covariances = new Float32Array(header.splatCount * 6);\n const maxShDegree = sections.reduce((max, section) => Math.max(max, section.shDegree), 0);\n const shComponents = shComponentsForDegree(maxShDegree);\n const coefficients = shComponents > 0 ? new Float32Array(header.splatCount * shComponents) : null;\n let outputIndex = 0;\n\n for (const section of sections) {\n const partialLengths = readPartialBucketLengths(view, section);\n const sectionShComponents = shComponentsForDegree(section.shDegree);\n const shOffset = header.compressionLevel === 0 ? 44 : 24;\n for (let localIndex = 0; localIndex < section.count; localIndex++, outputIndex++) {\n const source = section.dataBase + localIndex * section.bytesPerSplat;\n const position = outputIndex * 3;\n const color = outputIndex * 4;\n const scaleOffset = header.compressionLevel === 0 ? 12 : 6;\n const rotationOffset = header.compressionLevel === 0 ? 24 : 12;\n const colorOffset = header.compressionLevel === 0 ? 40 : 20;\n\n if (header.compressionLevel === 0) {\n positions[position + 0] = view.getFloat32(source + 0, true);\n positions[position + 1] = view.getFloat32(source + 4, true);\n positions[position + 2] = view.getFloat32(source + 8, true);\n } else {\n const bucket = bucketIndexForSplat(localIndex, section, partialLengths);\n const bucketBase = section.bucketsBase + bucket * section.bucketStorageBytes;\n const factor = (section.bucketBlockSize * 0.5) / section.compressionRange;\n positions[position + 0] =\n (view.getUint16(source + 0, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 0, true);\n positions[position + 1] =\n (view.getUint16(source + 2, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 4, true);\n positions[position + 2] =\n (view.getUint16(source + 4, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 8, true);\n }\n\n colors[color + 0] = view.getUint8(source + colorOffset + 0);\n colors[color + 1] = view.getUint8(source + colorOffset + 1);\n colors[color + 2] = view.getUint8(source + colorOffset + 2);\n colors[color + 3] = view.getUint8(source + colorOffset + 3);\n\n const readScalar = (offset: number): number =>\n header.compressionLevel === 0\n ? view.getFloat32(source + offset, true)\n : halfToFloat(view.getUint16(source + offset, true));\n const scalarBytes = header.compressionLevel === 0 ? 4 : 2;\n writeCovariance(\n covariances,\n outputIndex,\n readScalar(scaleOffset + 0 * scalarBytes),\n readScalar(scaleOffset + 1 * scalarBytes),\n readScalar(scaleOffset + 2 * scalarBytes),\n readScalar(rotationOffset + 0 * scalarBytes),\n readScalar(rotationOffset + 1 * scalarBytes),\n readScalar(rotationOffset + 2 * scalarBytes),\n readScalar(rotationOffset + 3 * scalarBytes),\n );\n\n if (coefficients && sectionShComponents > 0) {\n const dest = outputIndex * shComponents;\n for (let c = 0; c < sectionShComponents; c++) {\n const byteOffset = shOffset + c * shScalarBytes(header.compressionLevel);\n coefficients[dest + c] = readShScalar(\n view,\n source + byteOffset,\n header.compressionLevel,\n header.shCoeffMin,\n header.shCoeffMax,\n );\n }\n }\n }\n }\n\n const shPacked =\n coefficients && maxShDegree > 0\n ? packShCoefficients(coefficients, header.splatCount, maxShDegree as 1 | 2)\n : undefined;\n\n return {\n count: header.splatCount,\n positions,\n colors,\n covariances,\n ...(shPacked ? { shPacked } : {}),\n };\n}\n\nfunction shScalarBytes(compressionLevel: number): number {\n return compressionLevel === 0 ? 4 : compressionLevel === 1 ? 2 : 1;\n}\n\nfunction readShScalar(\n view: DataView,\n offset: number,\n compressionLevel: number,\n rangeMin: number,\n rangeMax: number,\n): number {\n if (compressionLevel === 0) return view.getFloat32(offset, true);\n if (compressionLevel === 1) return halfToFloat(view.getUint16(offset, true));\n const encoded = view.getUint8(offset);\n return (encoded / 255) * (rangeMax - rangeMin) + rangeMin;\n}\n\nfunction shComponentsForDegree(shDegree: number): number {\n if (shDegree === 0) return 0;\n if (shDegree === 1) return 9;\n if (shDegree === 2) return 24;\n throw new Error(`Unsupported KSPLAT SH degree ${shDegree}.`);\n}\n\nfunction parseHeader(view: DataView): KsplatHeader {\n if (view.byteLength < HEADER_BYTES) throw new Error('Truncated KSPLAT header.');\n const versionMajor = view.getUint8(0);\n const versionMinor = view.getUint8(1);\n const maxSectionCount = view.getUint32(4, true);\n const sectionCount = view.getUint32(8, true);\n const maxSplatCount = view.getUint32(12, true);\n const splatCount = view.getUint32(16, true);\n const compressionLevel = view.getUint16(20, true);\n const shCoeffMin = view.getFloat32(36, true) || -DEFAULT_SH_RANGE_HALF;\n const shCoeffMax = view.getFloat32(40, true) || DEFAULT_SH_RANGE_HALF;\n\n if (versionMajor !== 0 || versionMinor < 1) {\n throw new Error(\n `Unsupported KSPLAT version ${versionMajor}.${versionMinor}; expected 0.1 or newer.`,\n );\n }\n if (compressionLevel < 0 || compressionLevel > 2) {\n throw new Error(`Unsupported KSPLAT compression level ${compressionLevel}.`);\n }\n if (\n !Number.isSafeInteger(maxSectionCount) ||\n sectionCount > maxSectionCount ||\n sectionCount === 0\n ) {\n throw new Error(`Invalid KSPLAT section count ${sectionCount}/${maxSectionCount}.`);\n }\n if (splatCount > maxSplatCount) {\n throw new Error(`Invalid KSPLAT splat count ${splatCount}/${maxSplatCount}.`);\n }\n const headersEnd = HEADER_BYTES + maxSectionCount * SECTION_HEADER_BYTES;\n if (!Number.isSafeInteger(headersEnd) || headersEnd > view.byteLength) {\n throw new Error('Truncated KSPLAT section headers.');\n }\n\n return {\n versionMajor,\n versionMinor,\n sectionCount,\n splatCount,\n compressionLevel,\n shCoeffMin,\n shCoeffMax,\n };\n}\n\nfunction parseSections(view: DataView, header: KsplatHeader): KsplatSection[] {\n const maxSectionCount = view.getUint32(4, true);\n let sectionBase = HEADER_BYTES + maxSectionCount * SECTION_HEADER_BYTES;\n const sections: KsplatSection[] = [];\n\n for (let index = 0; index < maxSectionCount; index++) {\n const offset = HEADER_BYTES + index * SECTION_HEADER_BYTES;\n const count = view.getUint32(offset + 0, true);\n const maxCount = view.getUint32(offset + 4, true);\n const bucketSize = view.getUint32(offset + 8, true);\n const bucketCount = view.getUint32(offset + 12, true);\n const bucketBlockSize = view.getFloat32(offset + 16, true);\n const bucketStorageBytes = view.getUint16(offset + 20, true);\n const compressionRange = view.getUint32(offset + 24, true) || 32767;\n const fullBucketCount = view.getUint32(offset + 32, true);\n const partialBucketCount = view.getUint32(offset + 36, true);\n const shDegree = view.getUint16(offset + 40, true);\n const bytesPerSplat = bytesPerKsplat(header.compressionLevel, shDegree);\n const bucketMetadataBytes = partialBucketCount * 4;\n const bucketBytes = bucketCount * bucketStorageBytes;\n const storageBytes = bucketMetadataBytes + bucketBytes + maxCount * bytesPerSplat;\n\n if (index < header.sectionCount) {\n if (count > maxCount)\n throw new Error(`Invalid KSPLAT section ${index} count ${count}/${maxCount}.`);\n if (header.compressionLevel > 0) {\n if (bucketSize === 0 || bucketCount === 0 || bucketStorageBytes < BUCKET_CENTER_BYTES) {\n throw new Error(`Invalid KSPLAT bucket layout in section ${index}.`);\n }\n if (!Number.isFinite(bucketBlockSize) || bucketBlockSize <= 0 || compressionRange === 0) {\n throw new Error(`Invalid KSPLAT compression parameters in section ${index}.`);\n }\n if (fullBucketCount + partialBucketCount > bucketCount) {\n throw new Error(\n `Invalid KSPLAT section ${index}: ${fullBucketCount} full + ` +\n `${partialBucketCount} partial buckets exceed the ${bucketCount} declared.`,\n );\n }\n }\n if (sectionBase + storageBytes > view.byteLength) {\n throw new Error(`Truncated KSPLAT data in section ${index}.`);\n }\n sections.push({\n count,\n maxCount,\n bucketSize,\n bucketCount,\n bucketBlockSize,\n bucketStorageBytes,\n compressionRange,\n fullBucketCount,\n partialBucketCount,\n shDegree,\n bytesPerSplat,\n base: sectionBase,\n bucketsBase: sectionBase + bucketMetadataBytes,\n dataBase: sectionBase + bucketMetadataBytes + bucketBytes,\n });\n }\n sectionBase += storageBytes;\n }\n return sections;\n}\n\nfunction bytesPerKsplat(compressionLevel: number, shDegree: number): number {\n if (shDegree < 0 || shDegree > 2) throw new Error(`Unsupported KSPLAT SH degree ${shDegree}.`);\n const shComponents = shComponentsForDegree(shDegree);\n if (compressionLevel === 0) return 44 + shComponents * 4;\n return 24 + shComponents * shScalarBytes(compressionLevel);\n}\n\nfunction readPartialBucketLengths(view: DataView, section: KsplatSection): Uint32Array {\n const lengths = new Uint32Array(section.partialBucketCount);\n for (let i = 0; i < lengths.length; i++) lengths[i] = view.getUint32(section.base + i * 4, true);\n return lengths;\n}\n\nfunction bucketIndexForSplat(\n localIndex: number,\n section: KsplatSection,\n partialLengths: Uint32Array,\n): number {\n const fullSplats = section.fullBucketCount * section.bucketSize;\n const checked = (bucket: number): number => {\n // Belt-and-braces: a bucket index at or past bucketCount would read\n // bucket centers out of the section's storage (OOB DataView reads or\n // garbage positions from a hostile file).\n if (bucket >= section.bucketCount) {\n throw new Error(`KSPLAT splat ${localIndex} maps to out-of-range bucket ${bucket}.`);\n }\n return bucket;\n };\n if (localIndex < fullSplats) return checked(Math.floor(localIndex / section.bucketSize));\n let first = fullSplats;\n for (let i = 0; i < partialLengths.length; i++) {\n const length = partialLengths[i] as number;\n if (localIndex < first + length) return checked(section.fullBucketCount + i);\n first += length;\n }\n throw new Error(`KSPLAT splat ${localIndex} does not belong to a bucket.`);\n}\n"],"names":["HEADER_BYTES","SECTION_HEADER_BYTES","BUCKET_CENTER_BYTES","DEFAULT_SH_RANGE_HALF","parseKsplat","buffer","view","header","parseHeader","sections","parseSections","totalSectionSplats","sum","section","positions","colors","covariances","maxShDegree","max","shComponents","shComponentsForDegree","coefficients","outputIndex","partialLengths","readPartialBucketLengths","sectionShComponents","shOffset","localIndex","source","position","color","scaleOffset","rotationOffset","colorOffset","bucket","bucketIndexForSplat","bucketBase","factor","readScalar","offset","halfToFloat","scalarBytes","writeCovariance","dest","c","byteOffset","shScalarBytes","readShScalar","shPacked","packShCoefficients","compressionLevel","rangeMin","rangeMax","shDegree","versionMajor","versionMinor","maxSectionCount","sectionCount","maxSplatCount","splatCount","shCoeffMin","shCoeffMax","headersEnd","sectionBase","index","count","maxCount","bucketSize","bucketCount","bucketBlockSize","bucketStorageBytes","compressionRange","fullBucketCount","partialBucketCount","bytesPerSplat","bytesPerKsplat","bucketMetadataBytes","bucketBytes","storageBytes","lengths","i","fullSplats","checked","first","length"],"mappings":";;;AAIA,MAAMA,IAAe,MACfC,IAAuB,MACvBC,IAAsB,IAEtBC,IAAwB;AAoCvB,SAASC,EAAYC,GAAgC;AAC1D,QAAMC,IAAO,IAAI,SAASD,CAAM,GAC1BE,IAASC,EAAYF,CAAI,GACzBG,IAAWC,EAAcJ,GAAMC,CAAM,GACrCI,IAAqBF,EAAS,OAAO,CAACG,GAAKC,MAAYD,IAAMC,EAAQ,OAAO,CAAC;AACnF,MAAIF,MAAuBJ,EAAO;AAChC,UAAM,IAAI;AAAA,MACR,0CAA0CA,EAAO,UAAU,sBAAsBI,CAAkB;AAAA,IAAA;AAIvG,QAAMG,IAAY,IAAI,aAAaP,EAAO,aAAa,CAAC,GAClDQ,IAAS,IAAI,WAAWR,EAAO,aAAa,CAAC,GAC7CS,IAAc,IAAI,aAAaT,EAAO,aAAa,CAAC,GACpDU,IAAcR,EAAS,OAAO,CAACS,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AACA,QAAM,IAAI,MAAM,gBAAgBzD,CAAU,+BAA+B;AAC3E;"}
1
+ {"version":3,"file":"ksplat.js","sources":["../../src/lib/formats/ksplat/parse-ksplat.ts"],"sourcesContent":["import { halfToFloat } from '../../core/half-float';\nimport { packShCoefficients } from '../../core/sh-pack';\nimport { writeCovariance, type SplatData } from '../../core/splat-data';\n\nconst HEADER_BYTES = 4096;\nconst SECTION_HEADER_BYTES = 1024;\nconst BUCKET_CENTER_BYTES = 12;\n/** Default 8-bit SH dequant range half-width (GaussianSplats3D `Constants`). */\nconst DEFAULT_SH_RANGE_HALF = 1.5;\n\ninterface KsplatHeader {\n versionMajor: number;\n versionMinor: number;\n sectionCount: number;\n splatCount: number;\n compressionLevel: number;\n shCoeffMin: number;\n shCoeffMax: number;\n}\n\ninterface KsplatSection {\n count: number;\n maxCount: number;\n bucketSize: number;\n bucketCount: number;\n bucketBlockSize: number;\n bucketStorageBytes: number;\n compressionRange: number;\n fullBucketCount: number;\n partialBucketCount: number;\n shDegree: number;\n bytesPerSplat: number;\n base: number;\n bucketsBase: number;\n dataBase: number;\n}\n\n/**\n * Parses a GaussianSplats3D `.ksplat` file, including compression levels 0–2.\n * Base color, opacity, position, scale, rotation and optional higher-order\n * spherical harmonics (degrees 1–2) are retained.\n *\n * @throws {Error} if the header, section layout or record data is invalid.\n */\nexport function parseKsplat(buffer: ArrayBuffer): SplatData {\n const view = new DataView(buffer);\n const header = parseHeader(view);\n const sections = parseSections(view, header);\n const totalSectionSplats = sections.reduce((sum, section) => sum + section.count, 0);\n if (totalSectionSplats !== header.splatCount) {\n throw new Error(\n `Invalid KSPLAT counts: header declares ${header.splatCount}, sections contain ${totalSectionSplats}.`,\n );\n }\n\n const positions = new Float32Array(header.splatCount * 3);\n const colors = new Uint8Array(header.splatCount * 4);\n const covariances = new Float32Array(header.splatCount * 6);\n const maxShDegree = sections.reduce((max, section) => Math.max(max, section.shDegree), 0);\n const shComponents = shComponentsForDegree(maxShDegree);\n const coefficients = shComponents > 0 ? new Float32Array(header.splatCount * shComponents) : null;\n let outputIndex = 0;\n\n for (const section of sections) {\n const partialLengths = readPartialBucketLengths(view, section);\n const sectionShComponents = shComponentsForDegree(section.shDegree);\n const shOffset = header.compressionLevel === 0 ? 44 : 24;\n for (let localIndex = 0; localIndex < section.count; localIndex++, outputIndex++) {\n const source = section.dataBase + localIndex * section.bytesPerSplat;\n const position = outputIndex * 3;\n const color = outputIndex * 4;\n const scaleOffset = header.compressionLevel === 0 ? 12 : 6;\n const rotationOffset = header.compressionLevel === 0 ? 24 : 12;\n const colorOffset = header.compressionLevel === 0 ? 40 : 20;\n\n if (header.compressionLevel === 0) {\n positions[position + 0] = view.getFloat32(source + 0, true);\n positions[position + 1] = view.getFloat32(source + 4, true);\n positions[position + 2] = view.getFloat32(source + 8, true);\n } else {\n const bucket = bucketIndexForSplat(localIndex, section, partialLengths);\n const bucketBase = section.bucketsBase + bucket * section.bucketStorageBytes;\n const factor = (section.bucketBlockSize * 0.5) / section.compressionRange;\n positions[position + 0] =\n (view.getUint16(source + 0, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 0, true);\n positions[position + 1] =\n (view.getUint16(source + 2, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 4, true);\n positions[position + 2] =\n (view.getUint16(source + 4, true) - section.compressionRange) * factor +\n view.getFloat32(bucketBase + 8, true);\n }\n\n colors[color + 0] = view.getUint8(source + colorOffset + 0);\n colors[color + 1] = view.getUint8(source + colorOffset + 1);\n colors[color + 2] = view.getUint8(source + colorOffset + 2);\n colors[color + 3] = view.getUint8(source + colorOffset + 3);\n\n const readScalar = (offset: number): number =>\n header.compressionLevel === 0\n ? view.getFloat32(source + offset, true)\n : halfToFloat(view.getUint16(source + offset, true));\n const scalarBytes = header.compressionLevel === 0 ? 4 : 2;\n writeCovariance(\n covariances,\n outputIndex,\n readScalar(scaleOffset + 0 * scalarBytes),\n readScalar(scaleOffset + 1 * scalarBytes),\n readScalar(scaleOffset + 2 * scalarBytes),\n readScalar(rotationOffset + 0 * scalarBytes),\n readScalar(rotationOffset + 1 * scalarBytes),\n readScalar(rotationOffset + 2 * scalarBytes),\n readScalar(rotationOffset + 3 * scalarBytes),\n );\n\n if (coefficients && sectionShComponents > 0) {\n const dest = outputIndex * shComponents;\n for (let c = 0; c < sectionShComponents; c++) {\n const byteOffset = shOffset + c * shScalarBytes(header.compressionLevel);\n coefficients[dest + c] = readShScalar(\n view,\n source + byteOffset,\n header.compressionLevel,\n header.shCoeffMin,\n header.shCoeffMax,\n );\n }\n }\n }\n }\n\n const shPacked =\n coefficients && maxShDegree > 0\n ? packShCoefficients(coefficients, header.splatCount, maxShDegree as 1 | 2)\n : undefined;\n\n return {\n count: header.splatCount,\n positions,\n colors,\n covariances,\n ...(shPacked ? { shPacked } : {}),\n };\n}\n\nfunction shScalarBytes(compressionLevel: number): number {\n return compressionLevel === 0 ? 4 : compressionLevel === 1 ? 2 : 1;\n}\n\nfunction readShScalar(\n view: DataView,\n offset: number,\n compressionLevel: number,\n rangeMin: number,\n rangeMax: number,\n): number {\n if (compressionLevel === 0) return view.getFloat32(offset, true);\n if (compressionLevel === 1) return halfToFloat(view.getUint16(offset, true));\n const encoded = view.getUint8(offset);\n return (encoded / 255) * (rangeMax - rangeMin) + rangeMin;\n}\n\nfunction shComponentsForDegree(shDegree: number): number {\n if (shDegree === 0) return 0;\n if (shDegree === 1) return 9;\n if (shDegree === 2) return 24;\n throw new Error(`Unsupported KSPLAT SH degree ${shDegree}.`);\n}\n\nfunction parseHeader(view: DataView): KsplatHeader {\n if (view.byteLength < HEADER_BYTES) throw new Error('Truncated KSPLAT header.');\n const versionMajor = view.getUint8(0);\n const versionMinor = view.getUint8(1);\n const maxSectionCount = view.getUint32(4, true);\n const sectionCount = view.getUint32(8, true);\n const maxSplatCount = view.getUint32(12, true);\n const splatCount = view.getUint32(16, true);\n const compressionLevel = view.getUint16(20, true);\n const shCoeffMin = view.getFloat32(36, true) || -DEFAULT_SH_RANGE_HALF;\n const shCoeffMax = view.getFloat32(40, true) || DEFAULT_SH_RANGE_HALF;\n\n if (versionMajor !== 0 || versionMinor < 1) {\n throw new Error(\n `Unsupported KSPLAT version ${versionMajor}.${versionMinor}; expected 0.1 or newer.`,\n );\n }\n if (compressionLevel < 0 || compressionLevel > 2) {\n throw new Error(`Unsupported KSPLAT compression level ${compressionLevel}.`);\n }\n if (\n !Number.isSafeInteger(maxSectionCount) ||\n sectionCount > maxSectionCount ||\n sectionCount === 0\n ) {\n throw new Error(`Invalid KSPLAT section count ${sectionCount}/${maxSectionCount}.`);\n }\n if (splatCount > maxSplatCount) {\n throw new Error(`Invalid KSPLAT splat count ${splatCount}/${maxSplatCount}.`);\n }\n const headersEnd = HEADER_BYTES + maxSectionCount * SECTION_HEADER_BYTES;\n if (!Number.isSafeInteger(headersEnd) || headersEnd > view.byteLength) {\n throw new Error('Truncated KSPLAT section headers.');\n }\n\n return {\n versionMajor,\n versionMinor,\n sectionCount,\n splatCount,\n compressionLevel,\n shCoeffMin,\n shCoeffMax,\n };\n}\n\nfunction parseSections(view: DataView, header: KsplatHeader): KsplatSection[] {\n const maxSectionCount = view.getUint32(4, true);\n let sectionBase = HEADER_BYTES + maxSectionCount * SECTION_HEADER_BYTES;\n const sections: KsplatSection[] = [];\n\n for (let index = 0; index < maxSectionCount; index++) {\n const offset = HEADER_BYTES + index * SECTION_HEADER_BYTES;\n const count = view.getUint32(offset + 0, true);\n const maxCount = view.getUint32(offset + 4, true);\n const bucketSize = view.getUint32(offset + 8, true);\n const bucketCount = view.getUint32(offset + 12, true);\n const bucketBlockSize = view.getFloat32(offset + 16, true);\n const bucketStorageBytes = view.getUint16(offset + 20, true);\n const compressionRange = view.getUint32(offset + 24, true) || 32767;\n const fullBucketCount = view.getUint32(offset + 32, true);\n const partialBucketCount = view.getUint32(offset + 36, true);\n const shDegree = view.getUint16(offset + 40, true);\n const bytesPerSplat = bytesPerKsplat(header.compressionLevel, shDegree);\n const bucketMetadataBytes = partialBucketCount * 4;\n const bucketBytes = bucketCount * bucketStorageBytes;\n const storageBytes = bucketMetadataBytes + bucketBytes + maxCount * bytesPerSplat;\n\n if (index < header.sectionCount) {\n if (count > maxCount)\n throw new Error(`Invalid KSPLAT section ${index} count ${count}/${maxCount}.`);\n if (header.compressionLevel > 0) {\n if (bucketSize === 0 || bucketCount === 0 || bucketStorageBytes < BUCKET_CENTER_BYTES) {\n throw new Error(`Invalid KSPLAT bucket layout in section ${index}.`);\n }\n if (!Number.isFinite(bucketBlockSize) || bucketBlockSize <= 0 || compressionRange === 0) {\n throw new Error(`Invalid KSPLAT compression parameters in section ${index}.`);\n }\n if (fullBucketCount + partialBucketCount > bucketCount) {\n throw new Error(\n `Invalid KSPLAT section ${index}: ${fullBucketCount} full + ` +\n `${partialBucketCount} partial buckets exceed the ${bucketCount} declared.`,\n );\n }\n }\n if (sectionBase + storageBytes > view.byteLength) {\n throw new Error(`Truncated KSPLAT data in section ${index}.`);\n }\n sections.push({\n count,\n maxCount,\n bucketSize,\n bucketCount,\n bucketBlockSize,\n bucketStorageBytes,\n compressionRange,\n fullBucketCount,\n partialBucketCount,\n shDegree,\n bytesPerSplat,\n base: sectionBase,\n bucketsBase: sectionBase + bucketMetadataBytes,\n dataBase: sectionBase + bucketMetadataBytes + bucketBytes,\n });\n }\n sectionBase += storageBytes;\n }\n return sections;\n}\n\nfunction bytesPerKsplat(compressionLevel: number, shDegree: number): number {\n if (shDegree < 0 || shDegree > 2) throw new Error(`Unsupported KSPLAT SH degree ${shDegree}.`);\n const shComponents = shComponentsForDegree(shDegree);\n if (compressionLevel === 0) return 44 + shComponents * 4;\n return 24 + shComponents * shScalarBytes(compressionLevel);\n}\n\nfunction readPartialBucketLengths(view: DataView, section: KsplatSection): Uint32Array {\n const lengths = new Uint32Array(section.partialBucketCount);\n for (let i = 0; i < lengths.length; i++) lengths[i] = view.getUint32(section.base + i * 4, true);\n return lengths;\n}\n\nfunction bucketIndexForSplat(\n localIndex: number,\n section: KsplatSection,\n partialLengths: Uint32Array,\n): number {\n const fullSplats = section.fullBucketCount * section.bucketSize;\n const checked = (bucket: number): number => {\n // Belt-and-braces: a bucket index at or past bucketCount would read\n // bucket centers out of the section's storage (OOB DataView reads or\n // garbage positions from a hostile file).\n if (bucket >= section.bucketCount) {\n throw new Error(`KSPLAT splat ${localIndex} maps to out-of-range bucket ${bucket}.`);\n }\n return bucket;\n };\n if (localIndex < fullSplats) return checked(Math.floor(localIndex / section.bucketSize));\n let first = fullSplats;\n for (let i = 0; i < partialLengths.length; i++) {\n const length = partialLengths[i] as number;\n if (localIndex < first + length) return checked(section.fullBucketCount + i);\n first += length;\n }\n throw new Error(`KSPLAT splat ${localIndex} does not belong to a bucket.`);\n}\n"],"names":["HEADER_BYTES","SECTION_HEADER_BYTES","BUCKET_CENTER_BYTES","DEFAULT_SH_RANGE_HALF","parseKsplat","buffer","view","header","parseHeader","sections","parseSections","totalSectionSplats","sum","section","positions","colors","covariances","maxShDegree","max","shComponents","shComponentsForDegree","coefficients","outputIndex","partialLengths","readPartialBucketLengths","sectionShComponents","shOffset","localIndex","source","position","color","scaleOffset","rotationOffset","colorOffset","bucket","bucketIndexForSplat","bucketBase","factor","readScalar","offset","halfToFloat","scalarBytes","writeCovariance","dest","c","byteOffset","shScalarBytes","readShScalar","shPacked","packShCoefficients","compressionLevel","rangeMin","rangeMax","shDegree","versionMajor","versionMinor","maxSectionCount","sectionCount","maxSplatCount","splatCount","shCoeffMin","shCoeffMax","headersEnd","sectionBase","index","count","maxCount","bucketSize","bucketCount","bucketBlockSize","bucketStorageBytes","compressionRange","fullBucketCount","partialBucketCount","bytesPerSplat","bytesPerKsplat","bucketMetadataBytes","bucketBytes","storageBytes","lengths","i","fullSplats","checked","first","length"],"mappings":";;;AAIA,MAAMA,IAAe,MACfC,IAAuB,MACvBC,IAAsB,IAEtBC,IAAwB;AAoCvB,SAASC,EAAYC,GAAgC;AAC1D,QAAMC,IAAO,IAAI,SAASD,CAAM,GAC1BE,IAASC,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AI1C,QAAIA,KAAUrB,EAAQ;AACpB,YAAM,IAAI,MAAM,gBAAgBc,CAAU,gCAAgCO,CAAM,GAAG;AAErF,WAAOA;AAAA,EACT;AACA,MAAIP,IAAasD,EAAY,QAAOC,EAAQ,KAAK,MAAMvD,IAAad,EAAQ,UAAU,CAAC;AACvF,MAAIsE,IAAQF;AACZ,WAASD,IAAI,GAAGA,IAAIzD,EAAe,QAAQyD,KAAK;AAC9C,UAAMI,IAAS7D,EAAeyD,CAAC;AAC/B,QAAIrD,IAAawD,IAAQC,UAAeF,EAAQrE,EAAQ,kBAAkBmE,CAAC;AAC3E,IAAAG,KAASC;AAAA,EACX;AACA,QAAM,IAAI,MAAM,gBAAgBzD,CAAU,+BAA+B;AAC3E;"}
@@ -1,7 +1,7 @@
1
1
  import type * as THREE from 'three/webgpu';
2
- import { type SplatRequestOptions } from '../../loading';
2
+ import { type SplatRequestOptions } from '../../loaders/loading';
3
3
  import { type TriangleMeshData } from './parse-mesh-ply';
4
- import type { SceneCollision } from '../../lod-source';
4
+ import type { SplatCollisionData } from '../../streaming/lod-source';
5
5
  /**
6
6
  * Fetches the collision-mesh tiles a streamed scene declares.
7
7
  *
@@ -31,7 +31,7 @@ export interface CollisionMeshTile {
31
31
  *
32
32
  * @throws a `DOMException` named `AbortError` when cancelled.
33
33
  */
34
- export declare function loadCollisionMeshTiles(collision: SceneCollision, options?: {
34
+ export declare function loadCollisionMeshTiles(collision: SplatCollisionData, options?: {
35
35
  request?: SplatRequestOptions;
36
36
  signal?: AbortSignal;
37
37
  }): Promise<CollisionMeshTile[]>;
@@ -1,5 +1,5 @@
1
1
  import type { TriangleMeshData } from './parse-mesh-ply';
2
- import type { SelectionVolume } from '../../selection-volume';
2
+ import type { SelectionVolume } from '../../selection/selection-volume';
3
3
  /**
4
4
  * Splits a collision triangle mesh by the same {@link SelectionVolume} used to
5
5
  * separate a splat region, so the separated object keeps its collision
@@ -1,7 +1,7 @@
1
- import type { LodSourceOptions, StreamedScene } from '../../lod-source';
1
+ import type { LodSourceOptions, StreamedScene } from '../../streaming/lod-source';
2
2
  import { type LccManifest } from './parse-lcc';
3
- import { type SplatRequestOptions } from '../../loading';
4
- import type { SplatDatasetSource } from '../../dataset-source';
3
+ import { type SplatRequestOptions } from '../../loaders/loading';
4
+ import type { SplatDatasetSource } from '../../streaming/dataset-source';
5
5
  /** Options for {@link buildLccScene} beyond the shared LOD knobs. */
6
6
  export interface LccSceneOptions extends LodSourceOptions {
7
7
  /**
@@ -1,4 +1,4 @@
1
- import type { LodSourceOptions, StreamedScene } from '../../lod-source';
2
- import type { SplatDatasetSource } from '../../dataset-source';
1
+ import type { LodSourceOptions, StreamedScene } from '../../streaming/lod-source';
2
+ import type { SplatDatasetSource } from '../../streaming/dataset-source';
3
3
  /** Builds a scene from a parsed `.lcc2` manifest (JSON already fetched). */
4
4
  export declare function buildLcc2Scene(json: unknown, dataset: SplatDatasetSource, options: LodSourceOptions, shBands?: 0 | 1 | 2 | 3): StreamedScene;
@@ -1,4 +1,4 @@
1
- import { type SplatData } from '../../splat-data';
1
+ import { type SplatData } from '../../core/splat-data';
2
2
  /**
3
3
  * Decoder for XGRIDS' older LCC datasets (`.lcc` / `meta.lcc`; see
4
4
  * `docs/formats/lcc-notes.md`). Manifest versions **2.x** through **5.x** share the
@@ -4,10 +4,11 @@ var A = (e, t, n) => gt(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { w as wt } from "../splat-data-BZM5dhhx.js";
5
5
  import { a as mt, r as pt } from "../sh-pack-D5wAe5gg.js";
6
6
  import * as E from "three/webgpu";
7
- import { M as Ct, L as yt } from "../splat-mesh-types-CTN_duw2.js";
7
+ import { L as Ct } from "../lod-scheduler-B0a_uBlv.js";
8
8
  import { t as ct, a as W } from "../loading-wLo8vRbA.js";
9
+ import { M as yt } from "../splat-mesh-types-BZIko-_9.js";
9
10
  import { w as z } from "../logging-BfPdd7NJ.js";
10
- import { p as xt, a as vt, b as bt, c as k, d as j } from "../ply-header-BwgExCn-.js";
11
+ import { c as xt, a as vt, b as bt, p as k, d as j } from "../ply-header-B9WllbPg.js";
11
12
  const F = 32, O = 64, K = 1 << 24;
12
13
  function Lt(e) {
13
14
  return e === 1 ? 3 : e === 2 ? 8 : 15;
@@ -144,7 +145,7 @@ function Ft(e) {
144
145
  return n[t] = Math.sqrt(Math.max(0, 1 - s)), [n[3], n[0], n[1], n[2]];
145
146
  }
146
147
  const Tt = 1 / (511 * Math.SQRT2);
147
- async function re(e, t, n, o) {
148
+ async function le(e, t, n, o) {
148
149
  var v;
149
150
  const s = t.stride;
150
151
  if (s !== F && s !== F + O)
@@ -239,11 +240,11 @@ function P(e, t) {
239
240
  function H() {
240
241
  return new E.Matrix4().set(-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1);
241
242
  }
242
- function le(e) {
243
+ function ce(e) {
243
244
  e.matrix.copy(H()), e.matrix.decompose(e.position, e.quaternion, e.scale), e.matrixWorldNeedsUpdate = !0;
244
245
  }
245
246
  const Bt = 128e3;
246
- async function ce(e, t, n) {
247
+ async function ae(e, t, n) {
247
248
  const o = Et(e), s = (g) => {
248
249
  const x = t.resolve(g);
249
250
  if (x === null) throw new Error(`LCC dataset is missing "${g}".`);
@@ -253,7 +254,7 @@ async function ce(e, t, n) {
253
254
  o
254
255
  );
255
256
  Pt(c, o);
256
- const a = o.fileType === "Quality" ? Ct : 0, r = n.shBands ?? a, u = Math.min(r, a), f = u === 0 ? void 0 : u, h = f === void 0 ? null : s("shcoef.bin"), d = [], m = [], p = (g, x) => (d.push(g), m.push(x), d.length - 1), $ = [], b = /* @__PURE__ */ new Set();
257
+ const a = o.fileType === "Quality" ? yt : 0, r = n.shBands ?? a, u = Math.min(r, a), f = u === 0 ? void 0 : u, h = f === void 0 ? null : s("shcoef.bin"), d = [], m = [], p = (g, x) => (d.push(g), m.push(x), d.length - 1), $ = [], b = /* @__PURE__ */ new Set();
257
258
  let w = 0;
258
259
  const C = o.totalLevel;
259
260
  for (let g = 0; g < c.length; g++) {
@@ -346,7 +347,7 @@ async function ce(e, t, n) {
346
347
  // Classic LCC cells are broad XY tiles. Keep their priority independent of
347
348
  // frustum crossings so an orbit does not demote a sharp tile as it leaves
348
349
  // one edge, then rebuild it when the same tile re-enters the other edge.
349
- source: new yt(y, {
350
+ source: new Ct(y, {
350
351
  ...n,
351
352
  // Classic LCC cells are broad XY tiles. Keep their priority independent of
352
353
  // frustum crossings so an orbit does not demote a sharp tile as it leaves
@@ -451,7 +452,7 @@ async function _t(e, t, n) {
451
452
  return o.arrayBuffer();
452
453
  }
453
454
  const Dt = 3, zt = 0.1, tt = 0.1, Ot = 500;
454
- function ae(e, t, n, o = 0) {
455
+ function ue(e, t, n, o = 0) {
455
456
  var $, b;
456
457
  const s = e, i = s.root.splatFiles.map((w) => {
457
458
  const C = t.resolve(w);
@@ -889,7 +890,7 @@ function Wt(e, t, n, o, s) {
889
890
  )
890
891
  );
891
892
  }
892
- async function ue(e, t = {}) {
893
+ async function he(e, t = {}) {
893
894
  var s;
894
895
  const n = await Promise.allSettled(
895
896
  e.meshes.map((i) => jt(i, t))
@@ -927,7 +928,7 @@ function Kt(e) {
927
928
  return e.toLowerCase().includes(".lci");
928
929
  }
929
930
  }
930
- function he(e, t) {
931
+ function fe(e, t) {
931
932
  Zt(e);
932
933
  const { positions: n, indices: o, vertexCount: s, triangleCount: i } = e, l = new Uint8Array(s);
933
934
  for (let r = 0; r < s; r++)
@@ -982,16 +983,16 @@ function lt(e, t, n, o) {
982
983
  return { vertexCount: l, triangleCount: o, positions: a, indices: i };
983
984
  }
984
985
  export {
985
- le as applyLcc2ToThreeTransform,
986
- ae as buildLcc2Scene,
987
- ce as buildLccScene,
986
+ ce as applyLcc2ToThreeTransform,
987
+ ue as buildLcc2Scene,
988
+ ae as buildLccScene,
988
989
  H as createLcc2ToThreeMatrix,
989
- ue as loadCollisionMeshTiles,
990
+ he as loadCollisionMeshTiles,
990
991
  Qt as parseCollisionLci,
991
- re as parseLccChunk,
992
+ le as parseLccChunk,
992
993
  Mt as parseLccIndex,
993
994
  Et as parseLccManifest,
994
995
  Vt as parseMeshPly,
995
- he as partitionTriangleMesh
996
+ fe as partitionTriangleMesh
996
997
  };
997
998
  //# sourceMappingURL=lcc.js.map