@babylonjs/loaders 9.12.0 → 9.12.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 (77) hide show
  1. package/FBX/fbxFileLoader.d.ts +194 -0
  2. package/FBX/fbxFileLoader.js +2440 -0
  3. package/FBX/fbxFileLoader.js.map +1 -0
  4. package/FBX/fbxFileLoader.metadata.d.ts +11 -0
  5. package/FBX/fbxFileLoader.metadata.js +11 -0
  6. package/FBX/fbxFileLoader.metadata.js.map +1 -0
  7. package/FBX/index.d.ts +3 -0
  8. package/FBX/index.js +3 -0
  9. package/FBX/index.js.map +1 -0
  10. package/FBX/interpreter/animation.d.ts +122 -0
  11. package/FBX/interpreter/animation.js +648 -0
  12. package/FBX/interpreter/animation.js.map +1 -0
  13. package/FBX/interpreter/blendShapes.d.ts +44 -0
  14. package/FBX/interpreter/blendShapes.js +192 -0
  15. package/FBX/interpreter/blendShapes.js.map +1 -0
  16. package/FBX/interpreter/connections.d.ts +95 -0
  17. package/FBX/interpreter/connections.js +233 -0
  18. package/FBX/interpreter/connections.js.map +1 -0
  19. package/FBX/interpreter/fbxInterpreter.d.ts +149 -0
  20. package/FBX/interpreter/fbxInterpreter.js +496 -0
  21. package/FBX/interpreter/fbxInterpreter.js.map +1 -0
  22. package/FBX/interpreter/geometry.d.ts +55 -0
  23. package/FBX/interpreter/geometry.js +573 -0
  24. package/FBX/interpreter/geometry.js.map +1 -0
  25. package/FBX/interpreter/materials.d.ts +50 -0
  26. package/FBX/interpreter/materials.js +144 -0
  27. package/FBX/interpreter/materials.js.map +1 -0
  28. package/FBX/interpreter/propertyTemplates.d.ts +22 -0
  29. package/FBX/interpreter/propertyTemplates.js +125 -0
  30. package/FBX/interpreter/propertyTemplates.js.map +1 -0
  31. package/FBX/interpreter/rig.d.ts +20 -0
  32. package/FBX/interpreter/rig.js +259 -0
  33. package/FBX/interpreter/rig.js.map +1 -0
  34. package/FBX/interpreter/sceneDiagnostics.d.ts +14 -0
  35. package/FBX/interpreter/sceneDiagnostics.js +55 -0
  36. package/FBX/interpreter/sceneDiagnostics.js.map +1 -0
  37. package/FBX/interpreter/skeleton.d.ts +93 -0
  38. package/FBX/interpreter/skeleton.js +515 -0
  39. package/FBX/interpreter/skeleton.js.map +1 -0
  40. package/FBX/interpreter/transform.d.ts +21 -0
  41. package/FBX/interpreter/transform.js +92 -0
  42. package/FBX/interpreter/transform.js.map +1 -0
  43. package/FBX/parsers/fbxAsciiParser.d.ts +5 -0
  44. package/FBX/parsers/fbxAsciiParser.js +330 -0
  45. package/FBX/parsers/fbxAsciiParser.js.map +1 -0
  46. package/FBX/parsers/fbxBinaryParser.d.ts +6 -0
  47. package/FBX/parsers/fbxBinaryParser.js +255 -0
  48. package/FBX/parsers/fbxBinaryParser.js.map +1 -0
  49. package/FBX/parsers/zlibInflate.d.ts +7 -0
  50. package/FBX/parsers/zlibInflate.js +350 -0
  51. package/FBX/parsers/zlibInflate.js.map +1 -0
  52. package/FBX/types/fbxTypes.d.ts +54 -0
  53. package/FBX/types/fbxTypes.js +66 -0
  54. package/FBX/types/fbxTypes.js.map +1 -0
  55. package/SPLAT/gaussianSplattingStream.d.ts +341 -0
  56. package/SPLAT/gaussianSplattingStream.js +976 -0
  57. package/SPLAT/gaussianSplattingStream.js.map +1 -0
  58. package/SPLAT/gaussianSplattingWorkBuffer.d.ts +51 -0
  59. package/SPLAT/gaussianSplattingWorkBuffer.js +159 -0
  60. package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -0
  61. package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +25 -0
  62. package/SPLAT/gaussianSplattingWorkBufferShaders.js +255 -0
  63. package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -0
  64. package/SPLAT/index.d.ts +1 -0
  65. package/SPLAT/index.js +1 -0
  66. package/SPLAT/index.js.map +1 -1
  67. package/SPLAT/sog.js +18 -16
  68. package/SPLAT/sog.js.map +1 -1
  69. package/SPLAT/splatFileLoader.d.ts +8 -0
  70. package/SPLAT/splatFileLoader.js +49 -0
  71. package/SPLAT/splatFileLoader.js.map +1 -1
  72. package/dynamic.js +9 -0
  73. package/dynamic.js.map +1 -1
  74. package/index.d.ts +1 -0
  75. package/index.js +1 -0
  76. package/index.js.map +1 -1
  77. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gaussianSplattingStream.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/gaussianSplattingStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAI5F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAoB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AA4F5E,iHAAiH;AACjH,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;AAEvD,gGAAgG;AAChG,MAAM,WAAW,GAAG,IAAI,MAAM,EAAE,CAAC;AACjC,MAAM,cAAc,GAAG,IAAI,OAAO,EAAE,CAAC;AACrC,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE,CAAC;AACtC,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE,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Splatting/gaussianSplattingMesh\";\r\nimport { type IGaussianSplattingSplatRange } from \"core/Meshes/GaussianSplatting/gaussianSplattingMeshBase\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Vector3, Matrix } from \"core/Maths/math.vector\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Camera } from \"core/Cameras/camera\";\r\nimport { type Observer } from \"core/Misc/observable\";\r\nimport { BoundingInfo } from \"core/Culling/boundingInfo\";\r\nimport { CreateLineSystem } from \"core/Meshes/Builders/linesBuilder\";\r\nimport { type LinesMesh } from \"core/Meshes/linesMesh\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { ParseSogMetaAsTextures, type SOGRootData } from \"./sog\";\r\nimport { GaussianSplattingWorkBuffer } from \"./gaussianSplattingWorkBuffer\";\r\nimport { type ISogTexturePack } from \"./splatDefs\";\r\n\r\n/**\r\n * A single LOD variant of a tree node: a contiguous splat range inside one streamed SOG file.\r\n */\r\ninterface ISOGLODEntry {\r\n /** Index into {@link ISOGLODMetadata.filenames}. */\r\n file: number;\r\n /** First splat index inside that file. */\r\n offset: number;\r\n /** Number of splats. */\r\n count: number;\r\n}\r\n\r\n/**\r\n * A node of the PlayCanvas-style SOG LOD octree. Internal nodes have `children`; leaves have `lods`.\r\n */\r\ninterface ISOGLODNode {\r\n bound: { min: number[]; max: number[] };\r\n children?: ISOGLODNode[];\r\n lods?: { [level: string]: ISOGLODEntry };\r\n /** LOD level currently streamed/rendered for this node, or undefined until its base LOD is ready. */\r\n activeLod?: number;\r\n /** Distance-based ideal LOD level for this node, recomputed per frame. */\r\n optimalLod?: number;\r\n /** Available LOD levels for this leaf, sorted ascending (0 = finest). Set during the tree walk. */\r\n availableLevels?: number[];\r\n /** Coarsest available level (= max key), always streamed as the permanent base layer. */\r\n baseLod?: number;\r\n /** Final LOD level the node should stream/render (distance optimal, capped by maxDetailLod). */\r\n targetLevel?: number;\r\n /** Frames remaining before this node may switch LOD again (oscillation damping). */\r\n lodCooldown?: number;\r\n}\r\n\r\n/**\r\n * Parsed contents of a PlayCanvas-style `lod-meta.json` file.\r\n */\r\nexport interface ISOGLODMetadata {\r\n /** Number of LOD levels (0 = highest detail). */\r\n lodLevels: number;\r\n /** SOG `meta.json` paths, relative to the metadata file, indexed by `ISOGLODEntry.file`. */\r\n filenames: string[];\r\n /** Optional always-on environment `.sog` bundle, relative to the metadata file. */\r\n environment?: string;\r\n /** Root of the LOD octree. */\r\n tree: ISOGLODNode;\r\n}\r\n\r\n/**\r\n * Selects which LOD value drives the {@link GaussianSplattingStream} debug wireframe colors.\r\n */\r\nexport type GaussianSplattingStreamDebugLodSource = \"optimal\" | \"current\";\r\n\r\n/**\r\n * Options for {@link GaussianSplattingStream}.\r\n */\r\nexport interface IGaussianSplattingStreamOptions {\r\n /** URL of the fflate UMD module used to unzip `.sog` environment bundles. */\r\n deflateURL?: string;\r\n /** Pre-loaded fflate module. */\r\n fflate?: any;\r\n /** When true, renders a wireframe box per LOD node, colored by the node's LOD level. */\r\n debugDisplay?: boolean;\r\n /** Which LOD value drives the debug wireframe colors. Defaults to `\"optimal\"`. */\r\n debugLodSource?: GaussianSplattingStreamDebugLodSource;\r\n /** Distance (in local units) of the first LOD transition. PlayCanvas default `5`. */\r\n lodBaseDistance?: number;\r\n /** Geometric ratio between successive LOD transition distances. PlayCanvas default `3`. */\r\n lodMultiplier?: number;\r\n /** Distance multiplier applied to nodes behind the camera (`1` = no penalty). PlayCanvas default `1`. */\r\n lodBehindPenalty?: number;\r\n /** Lowest LOD index the optimal-LOD heuristic may select. Defaults to `0`. */\r\n lodRangeMin?: number;\r\n /** Highest LOD index the optimal-LOD heuristic may select. Defaults to `lodLevels - 1`. */\r\n lodRangeMax?: number;\r\n /** Maximum number of LOD source files to GPU-decode per frame (spreads work to avoid hitches). Defaults to `1`. */\r\n maxDecodesPerFrame?: number;\r\n /** Frames a node must wait after switching LOD before it may switch again (oscillation damping). Defaults to `10`. */\r\n lodCooldownFrames?: number;\r\n /** Minimum number of frames between LOD re-evaluations (throttles per-frame work during motion). Defaults to `4`. */\r\n lodUpdateInterval?: number;\r\n /** Minimum camera movement (world units) required to re-evaluate LODs. Defaults to `0.5`. */\r\n lodUpdateDistance?: number;\r\n /**\r\n * Finest (most detailed) LOD level any node is allowed to render. `0` allows full detail (level 0);\r\n * `1` caps detail at the next-coarser level, and so on. Higher values force a coarser maximum detail.\r\n */\r\n maxDetailLod?: number;\r\n}\r\n\r\n// tan(22.5deg): reference half-FOV for a 45-degree vertical FOV, used for FOV compensation (matches PlayCanvas).\r\nconst RefTanHalfFov = Math.tan((22.5 * Math.PI) / 180);\r\n\r\n// Scratch objects reused by the per-frame optimal-LOD evaluation (avoids per-call allocations).\r\nconst TmpInvWorld = new Matrix();\r\nconst TmpLocalCamera = new Vector3();\r\nconst TmpLocalForward = new Vector3();\r\nconst TmpWorldForward = new Vector3();\r\n// Camera-local forward axis (+Z) used to derive the world-space view direction.\r\nconst LocalForwardAxis = new Vector3(0, 0, 1);\r\n\r\n// The 12 edges of a box, as index pairs into its 8 corners. 12 edges x 2 endpoints = 24 vertices per box.\r\nconst BoxEdges = [\r\n [0, 1],\r\n [1, 2],\r\n [2, 3],\r\n [3, 0],\r\n [4, 5],\r\n [5, 6],\r\n [6, 7],\r\n [7, 4],\r\n [0, 4],\r\n [1, 5],\r\n [2, 6],\r\n [3, 7],\r\n];\r\n// Vertices generated per leaf box (BoxEdges.length * 2).\r\nconst VerticesPerBox = BoxEdges.length * 2;\r\n\r\n/**\r\n * Wireframe colors per LOD level (cycled by `node.activeLod`).\r\n */\r\nconst GsLodDebugColors = [\r\n new Color4(1.0, 0.2, 0.2, 1.0), // LOD 0 - red\r\n new Color4(1.0, 0.6, 0.1, 1.0), // LOD 1 - orange\r\n new Color4(1.0, 1.0, 0.2, 1.0), // LOD 2 - yellow\r\n new Color4(0.3, 1.0, 0.3, 1.0), // LOD 3 - green\r\n new Color4(0.2, 1.0, 1.0, 1.0), // LOD 4 - cyan\r\n new Color4(0.4, 0.5, 1.0, 1.0), // LOD 5 - blue\r\n new Color4(0.9, 0.4, 1.0, 1.0), // LOD 6 - magenta\r\n new Color4(1.0, 1.0, 1.0, 1.0), // LOD 7 - white\r\n];\r\n\r\n/**\r\n * Streams a PlayCanvas-style SOG LOD scene (`lod-meta.json`) into a single Gaussian Splatting mesh.\r\n *\r\n * Each selected SOG file (plus the environment) is loaded directly as GPU textures and decoded on the\r\n * GPU into one unified, PlayCanvas-style square work buffer (no CPU splat decode or `updateData`). Only\r\n * the splats of each node's currently-selected LOD are rendered/sorted via the mesh's interval filter.\r\n *\r\n * The coarsest (least-detail) LOD of every node is streamed first as a permanent base layer so the whole\r\n * scene is visible quickly with no holes. A distance-based \"optimal\" LOD is then computed per node (see\r\n * {@link evaluateOptimalLods}); finer LOD source files are streamed on demand and a node only switches to\r\n * a finer LOD once that file is decoded, so transitions never flash or leave gaps.\r\n *\r\n * @experimental\r\n */\r\nexport class GaussianSplattingStream extends GaussianSplattingMesh {\r\n private readonly _metadata: ISOGLODMetadata;\r\n private readonly _rootUrl: string;\r\n private readonly _streamOptions: IGaussianSplattingStreamOptions;\r\n\r\n // Flat list of leaf nodes that carry renderable LOD entries (used by the LOD heuristic and debug).\r\n private readonly _leafNodes: ISOGLODNode[] = [];\r\n\r\n // LOD heuristic parameters (PlayCanvas-aligned defaults).\r\n private _lodBaseDistance = 5;\r\n private _lodMultiplier = 3;\r\n private _lodBehindPenalty = 1;\r\n private _lodRangeMin = 0;\r\n private _lodRangeMax: number;\r\n private _maxDecodesPerFrame = 1;\r\n private _lodCooldownFrames = 10;\r\n // Minimum frames between LOD re-evaluations, and minimum camera movement (world units) to re-evaluate.\r\n private _lodUpdateInterval = 4;\r\n private _lodUpdateDistance = 0.5;\r\n private _maxDetailLod = 0;\r\n\r\n // GPU work buffer holding all decoded splats; created once the total capacity is known.\r\n private _workBuffer: Nullable<GaussianSplattingWorkBuffer> = null;\r\n\r\n // Global splat offset where each source file begins in the work buffer (fixed for all files up front).\r\n private readonly _fileBaseSplat = new Map<number, number>();\r\n // Splat count of each source file (learned from its metadata before allocation).\r\n private readonly _fileCounts = new Map<number, number>();\r\n // Cached SOG metadata per file so on-demand decodes don't refetch the meta.json.\r\n private readonly _fileMeta = new Map<number, { sogData: SOGRootData; subRootUrl: string }>();\r\n // Files whose splats have been GPU-decoded into the work buffer.\r\n private readonly _decodedFiles = new Set<number>();\r\n // Files whose decode is currently in flight (dedupes concurrent requests).\r\n private readonly _loadingFiles = new Set<number>();\r\n // FIFO of file ids waiting to be decoded (drained under a per-frame budget).\r\n private readonly _decodeQueue: number[] = [];\r\n\r\n // Global range covered by the environment file (always rendered), or null until it loads.\r\n private _environmentRange: Nullable<{ offset: number; count: number }> = null;\r\n // Unzipped environment bundle contents, retained between count-gathering and decode.\r\n private _environmentFiles: Nullable<Map<string, Uint8Array>> = null;\r\n\r\n // Per-frame LOD streaming loop; installed once the base layer is ready.\r\n private _lodObserver: Nullable<Observer<Scene>> = null;\r\n private _baseLayerReady = false;\r\n // Throttling state for the per-frame LOD loop.\r\n private _framesSinceLodUpdate = 0;\r\n private readonly _lastLodCamPos = new Vector3(Infinity, Infinity, Infinity);\r\n // Forces the next LOD update to run regardless of the throttle (e.g. after a budget change).\r\n private _forceLodUpdate = false;\r\n\r\n // Running local-space bounds of all decoded splat centers (for frustum culling / picking).\r\n private readonly _boundsMin = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n private readonly _boundsMax = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n // Debug LOD-node wireframe display.\r\n private _debugDisplay = false;\r\n private _debugLodSource: GaussianSplattingStreamDebugLodSource = \"optimal\";\r\n private _debugMesh: Nullable<LinesMesh> = null;\r\n private _debugObserver: Nullable<Observer<Scene>> = null;\r\n // Per-vertex RGBA color buffer mirror, updated in place when LOD colors change (avoids mesh rebuild flicker).\r\n private _debugColorData: Nullable<Float32Array> = null;\r\n // Signature of the per-leaf displayed LOD levels, used to skip rebuilding unchanged debug geometry.\r\n private _debugSignature = 0;\r\n\r\n private _disposed = false;\r\n\r\n /**\r\n * Returns true when the parsed JSON looks like a PlayCanvas-style `lod-meta.json` payload.\r\n * @param data parsed JSON\r\n * @returns whether the data is SOG LOD metadata\r\n */\r\n public static IsLODMetadata(data: unknown): data is ISOGLODMetadata {\r\n if (typeof data !== \"object\" || data === null) {\r\n return false;\r\n }\r\n const meta = data as Partial<ISOGLODMetadata>;\r\n return typeof meta.lodLevels === \"number\" && Array.isArray(meta.filenames) && typeof meta.tree === \"object\" && meta.tree !== null;\r\n }\r\n\r\n /**\r\n * Creates a new SOG LOD streaming mesh and immediately starts streaming (non-blocking).\r\n * @param name mesh name\r\n * @param metadata parsed `lod-meta.json`\r\n * @param rootUrl base URL the metadata's relative paths resolve against\r\n * @param scene hosting scene\r\n * @param options streaming options\r\n */\r\n constructor(name: string, metadata: ISOGLODMetadata, rootUrl: string, scene: Scene, options: IGaussianSplattingStreamOptions = {}) {\r\n super(name, null, scene, false);\r\n this._metadata = metadata;\r\n this._rootUrl = rootUrl;\r\n this._streamOptions = options;\r\n\r\n // LOD heuristic parameters: take the provided values, otherwise keep the PlayCanvas-aligned defaults.\r\n const maxLod = Math.max(0, metadata.lodLevels - 1);\r\n this._lodRangeMax = maxLod;\r\n if (options.lodBaseDistance !== undefined) {\r\n this._lodBaseDistance = Math.max(0.1, options.lodBaseDistance);\r\n }\r\n if (options.lodMultiplier !== undefined) {\r\n this._lodMultiplier = Math.max(1.2, options.lodMultiplier);\r\n }\r\n if (options.lodBehindPenalty !== undefined) {\r\n this._lodBehindPenalty = Math.max(1, options.lodBehindPenalty);\r\n }\r\n if (options.lodRangeMin !== undefined) {\r\n this._lodRangeMin = Math.max(0, Math.min(options.lodRangeMin, maxLod));\r\n }\r\n if (options.lodRangeMax !== undefined) {\r\n this._lodRangeMax = Math.max(this._lodRangeMin, Math.min(options.lodRangeMax, maxLod));\r\n }\r\n if (options.maxDecodesPerFrame !== undefined) {\r\n this._maxDecodesPerFrame = Math.max(1, options.maxDecodesPerFrame);\r\n }\r\n if (options.lodCooldownFrames !== undefined) {\r\n this._lodCooldownFrames = Math.max(0, options.lodCooldownFrames);\r\n }\r\n if (options.lodUpdateInterval !== undefined) {\r\n this._lodUpdateInterval = Math.max(1, options.lodUpdateInterval);\r\n }\r\n if (options.lodUpdateDistance !== undefined) {\r\n this._lodUpdateDistance = Math.max(0, options.lodUpdateDistance);\r\n }\r\n if (options.maxDetailLod !== undefined) {\r\n this._maxDetailLod = Math.max(0, Math.floor(options.maxDetailLod));\r\n }\r\n if (options.debugLodSource) {\r\n this._debugLodSource = options.debugLodSource;\r\n }\r\n\r\n // PlayCanvas SOG data is authored with a flipped Y; match the standard SOG loader.\r\n this.scaling.y *= -1;\r\n // PlayCanvas SOG LOD scenes are authored Z-up; rotate into Babylon's Y-up convention.\r\n this.rotation.x = -Math.PI / 2;\r\n\r\n this._collectLodEntries(metadata.tree);\r\n\r\n if (options.debugDisplay) {\r\n this.debugDisplay = true;\r\n }\r\n\r\n // Kick off streaming without blocking the caller or the render loop.\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n this._streamAllAsync().catch((e) => {\r\n Logger.Error(\"GaussianSplattingStream: streaming failed: \" + (e?.message ?? e));\r\n });\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"GaussianSplattingStream\";\r\n }\r\n\r\n /**\r\n * Finest (most detailed) LOD level any node is allowed to render. `0` allows full detail (level 0);\r\n * `1` caps detail at the next-coarser level, and so on. Nodes already coarser than this cap (by\r\n * distance) are unaffected. Changes take effect in real time.\r\n */\r\n public get maxDetailLod(): number {\r\n return this._maxDetailLod;\r\n }\r\n\r\n public set maxDetailLod(value: number) {\r\n const level = Math.max(0, Math.floor(value));\r\n if (this._maxDetailLod === level) {\r\n return;\r\n }\r\n this._maxDetailLod = level;\r\n // Re-evaluate LODs on the next frame regardless of the movement throttle so the change is immediate.\r\n this._forceLodUpdate = true;\r\n }\r\n\r\n /**\r\n * Coarsest LOD level index in the scene (number of LOD levels minus one). Useful as the upper bound\r\n * for {@link maxDetailLod}.\r\n */\r\n public get maxLodLevel(): number {\r\n return Math.max(0, this._metadata.lodLevels - 1);\r\n }\r\n\r\n /**\r\n * When true, renders a wireframe box per LOD node, colored by the LOD level selected by {@link debugLodSource}.\r\n */\r\n public get debugDisplay(): boolean {\r\n return this._debugDisplay;\r\n }\r\n\r\n public set debugDisplay(value: boolean) {\r\n if (this._debugDisplay === value) {\r\n return;\r\n }\r\n this._debugDisplay = value;\r\n if (value) {\r\n this._refreshDebugDisplay();\r\n } else {\r\n this._clearDebugDisplay();\r\n }\r\n }\r\n\r\n /**\r\n * Selects which LOD value drives the debug wireframe colors: the distance-based `\"optimal\"` LOD\r\n * (default, recomputed as the camera moves) or the `\"current\"` streamed/rendered LOD.\r\n */\r\n public get debugLodSource(): GaussianSplattingStreamDebugLodSource {\r\n return this._debugLodSource;\r\n }\r\n\r\n public set debugLodSource(value: GaussianSplattingStreamDebugLodSource) {\r\n if (this._debugLodSource === value) {\r\n return;\r\n }\r\n this._debugLodSource = value;\r\n if (this._debugDisplay) {\r\n this._refreshDebugDisplay();\r\n }\r\n }\r\n\r\n public override dispose(doNotRecurse?: boolean): void {\r\n this._disposed = true;\r\n if (this._lodObserver) {\r\n this._scene.onBeforeRenderObservable.remove(this._lodObserver);\r\n this._lodObserver = null;\r\n }\r\n this._clearDebugDisplay();\r\n this._workBuffer?.dispose();\r\n this._workBuffer = null;\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n /**\r\n * Re-evaluates the optimal LOD for every node based on the camera position. The result is stored in\r\n * each node's `optimalLod`. Rendering is unaffected; this currently drives only diagnostics and the\r\n * debug wireframe display.\r\n * @param camera camera to evaluate against (defaults to the scene's active camera)\r\n */\r\n public evaluateOptimalLods(camera: Nullable<Camera> = this._scene.activeCamera): void {\r\n if (!camera || this._leafNodes.length === 0) {\r\n return;\r\n }\r\n\r\n const maxLod = Math.max(0, this._metadata.lodLevels - 1);\r\n const base = this._lodBaseDistance;\r\n const mult = this._lodMultiplier;\r\n const behindPenalty = this._lodBehindPenalty;\r\n const rangeMin = this._lodRangeMin;\r\n const rangeMax = this._lodRangeMax;\r\n\r\n // FOV compensation: use min(tanHalfV, tanHalfH) so transitions stay perceptually uniform (matches PlayCanvas).\r\n const aspect = this._scene.getEngine().getAspectRatio(camera) || 1;\r\n let tanHalfV = Math.tan(camera.fov * 0.5);\r\n if (camera.fovMode === Camera.FOVMODE_HORIZONTAL_FIXED) {\r\n tanHalfV /= aspect;\r\n }\r\n const tanHalfH = tanHalfV * aspect;\r\n const fovScale = Math.min(tanHalfV, tanHalfH) / RefTanHalfFov;\r\n\r\n // Transform the camera into the mesh's local space (where the node bounds live).\r\n this.computeWorldMatrix(true).invertToRef(TmpInvWorld);\r\n const localCamera = Vector3.TransformCoordinatesToRef(camera.globalPosition, TmpInvWorld, TmpLocalCamera);\r\n const px = localCamera.x;\r\n const py = localCamera.y;\r\n const pz = localCamera.z;\r\n\r\n let fwx = 0;\r\n let fwy = 0;\r\n let fwz = 0;\r\n if (behindPenalty > 1) {\r\n camera.getDirectionToRef(LocalForwardAxis, TmpWorldForward);\r\n const localForward = Vector3.TransformNormalToRef(TmpWorldForward, TmpInvWorld, TmpLocalForward);\r\n localForward.normalize();\r\n fwx = localForward.x;\r\n fwy = localForward.y;\r\n fwz = localForward.z;\r\n }\r\n\r\n for (const node of this._leafNodes) {\r\n const mn = node.bound.min;\r\n const mx = node.bound.max;\r\n\r\n // Distance from the camera to the closest point on this node's AABB (local space).\r\n const qx = px < mn[0] ? mn[0] : px > mx[0] ? mx[0] : px;\r\n const qy = py < mn[1] ? mn[1] : py > mx[1] ? mx[1] : py;\r\n const qz = pz < mn[2] ? mn[2] : pz > mx[2] ? mx[2] : pz;\r\n const dx = qx - px;\r\n const dy = qy - py;\r\n const dz = qz - pz;\r\n const actualDistance = Math.sqrt(dx * dx + dy * dy + dz * dz);\r\n\r\n // Push nodes behind the camera toward coarser LODs when a penalty is configured.\r\n let penalizedDistance = actualDistance;\r\n if (behindPenalty > 1 && actualDistance > 0.01) {\r\n const dotOverDistance = (fwx * dx + fwy * dy + fwz * dz) / actualDistance;\r\n if (dotOverDistance < 0) {\r\n penalizedDistance = actualDistance * (1 + -dotOverDistance * (behindPenalty - 1));\r\n }\r\n }\r\n\r\n // Geometric LOD bands: threshold[k] = base * mult^(k-1).\r\n const fovAdjustedDistance = penalizedDistance * fovScale;\r\n let optimalLod: number;\r\n if (maxLod === 0 || fovAdjustedDistance < base) {\r\n optimalLod = 0;\r\n } else {\r\n optimalLod = maxLod;\r\n while (optimalLod > 1 && fovAdjustedDistance < base * Math.pow(mult, optimalLod - 1)) {\r\n optimalLod--;\r\n }\r\n }\r\n\r\n if (optimalLod < rangeMin) {\r\n optimalLod = rangeMin;\r\n } else if (optimalLod > rangeMax) {\r\n optimalLod = rangeMax;\r\n }\r\n node.optimalLod = optimalLod;\r\n }\r\n }\r\n\r\n /**\r\n * The LOD level used to color a node's debug box, per {@link debugLodSource}.\r\n * @param node leaf node\r\n * @returns the displayed LOD level\r\n */\r\n private _displayedLodLevel(node: ISOGLODNode): number {\r\n if (this._debugLodSource === \"optimal\") {\r\n return node.optimalLod ?? node.activeLod ?? 0;\r\n }\r\n return node.activeLod ?? 0;\r\n }\r\n\r\n /**\r\n * Rebuilds the debug wireframe (evaluating the optimal LOD first when needed) and wires up the per-frame\r\n * recolor observer. The observer runs for both LOD sources: \"optimal\" colors track the camera, and\r\n * \"current\" colors track LOD levels as they stream in/out.\r\n */\r\n private _refreshDebugDisplay(): void {\r\n if (this._debugLodSource === \"optimal\") {\r\n this.evaluateOptimalLods();\r\n }\r\n this._buildDebugMesh();\r\n\r\n const needsObserver = this._debugDisplay;\r\n if (needsObserver && !this._debugObserver) {\r\n this._debugObserver = this._scene.onBeforeRenderObservable.add(() => this._onDebugFrame());\r\n } else if (!needsObserver && this._debugObserver) {\r\n this._scene.onBeforeRenderObservable.remove(this._debugObserver);\r\n this._debugObserver = null;\r\n }\r\n }\r\n\r\n /**\r\n * Per-frame debug update: recolors the existing wireframe in place whenever the displayed LOD levels\r\n * change. For the \"optimal\" source the optimal LOD is recomputed first (it tracks the camera); for the\r\n * \"current\" source the levels are driven by the streaming loop, so no recomputation is needed here. The\r\n * geometry is never rebuilt, which avoids the dispose/recreate flicker while the camera moves.\r\n */\r\n private _onDebugFrame(): void {\r\n if (this._debugLodSource === \"optimal\") {\r\n this.evaluateOptimalLods();\r\n }\r\n if (this._computeDebugSignature() !== this._debugSignature) {\r\n this._updateDebugColors();\r\n }\r\n }\r\n\r\n /**\r\n * Builds the LOD-node wireframe boxes once (one box per leaf node), colored by the displayed LOD level.\r\n * The color vertex buffer is created updatable so subsequent recolors can happen in place.\r\n */\r\n private _buildDebugMesh(): void {\r\n if (this._debugMesh) {\r\n this._debugMesh.dispose();\r\n this._debugMesh = null;\r\n }\r\n this._debugColorData = null;\r\n\r\n const lines: Vector3[][] = [];\r\n const colors: Color4[][] = [];\r\n for (const node of this._leafNodes) {\r\n const color = GsLodDebugColors[this._displayedLodLevel(node) % GsLodDebugColors.length];\r\n const mn = node.bound.min;\r\n const mx = node.bound.max;\r\n const corners = [\r\n new Vector3(mn[0], mn[1], mn[2]),\r\n new Vector3(mx[0], mn[1], mn[2]),\r\n new Vector3(mx[0], mx[1], mn[2]),\r\n new Vector3(mn[0], mx[1], mn[2]),\r\n new Vector3(mn[0], mn[1], mx[2]),\r\n new Vector3(mx[0], mn[1], mx[2]),\r\n new Vector3(mx[0], mx[1], mx[2]),\r\n new Vector3(mn[0], mx[1], mx[2]),\r\n ];\r\n for (const edge of BoxEdges) {\r\n lines.push([corners[edge[0]], corners[edge[1]]]);\r\n colors.push([color, color]);\r\n }\r\n }\r\n\r\n this._debugSignature = this._computeDebugSignature();\r\n if (lines.length === 0) {\r\n return;\r\n }\r\n\r\n const mesh = CreateLineSystem(this.name + \"_lodDebug\", { lines, colors, updatable: true, useVertexAlpha: false }, this._scene);\r\n mesh.parent = this;\r\n mesh.isPickable = false;\r\n mesh.doNotSerialize = true;\r\n mesh.reservedDataStore = { hidden: true };\r\n this._debugMesh = mesh;\r\n this._debugColorData = new Float32Array(this._leafNodes.length * VerticesPerBox * 4);\r\n }\r\n\r\n /**\r\n * Recolors the existing wireframe in place from the current displayed LOD levels, without rebuilding geometry.\r\n */\r\n private _updateDebugColors(): void {\r\n if (!this._debugMesh || !this._debugColorData) {\r\n return;\r\n }\r\n const data = this._debugColorData;\r\n let offset = 0;\r\n for (const node of this._leafNodes) {\r\n const color = GsLodDebugColors[this._displayedLodLevel(node) % GsLodDebugColors.length];\r\n for (let v = 0; v < VerticesPerBox; v++) {\r\n data[offset++] = color.r;\r\n data[offset++] = color.g;\r\n data[offset++] = color.b;\r\n data[offset++] = color.a;\r\n }\r\n }\r\n this._debugMesh.updateVerticesData(VertexBuffer.ColorKind, data);\r\n this._debugSignature = this._computeDebugSignature();\r\n }\r\n\r\n /**\r\n * Computes a cheap 32-bit rolling hash of every leaf's displayed LOD level, used to detect when the\r\n * debug wireframe needs recoloring. Avoids per-frame string allocation in the render loop.\r\n * @returns a numeric signature of the current displayed LOD levels\r\n */\r\n private _computeDebugSignature(): number {\r\n let hash = 0;\r\n for (const node of this._leafNodes) {\r\n hash = (hash * 31 + this._displayedLodLevel(node)) | 0;\r\n }\r\n return hash;\r\n }\r\n\r\n /**\r\n * Disposes the LOD-node wireframe boxes and stops live debug updates.\r\n */\r\n private _clearDebugDisplay(): void {\r\n if (this._debugObserver) {\r\n this._scene.onBeforeRenderObservable.remove(this._debugObserver);\r\n this._debugObserver = null;\r\n }\r\n if (this._debugMesh) {\r\n this._debugMesh.dispose();\r\n this._debugMesh = null;\r\n }\r\n this._debugColorData = null;\r\n this._debugSignature = 0;\r\n }\r\n\r\n /**\r\n * Walks the LOD tree and records every leaf that carries renderable LOD entries, capturing the set of\r\n * available levels and the coarsest (base) level for each.\r\n * @param node current tree node\r\n */\r\n private _collectLodEntries(node: ISOGLODNode): void {\r\n if (node.children) {\r\n for (const child of node.children) {\r\n this._collectLodEntries(child);\r\n }\r\n return;\r\n }\r\n\r\n if (!node.lods) {\r\n return;\r\n }\r\n\r\n // Collect all levels that hold splats (PlayCanvas convention: level 0 is the finest, higher = coarser).\r\n const levels: number[] = [];\r\n for (const key of Object.keys(node.lods)) {\r\n const level = Number(key);\r\n const entry = node.lods[key];\r\n if (Number.isFinite(level) && entry && entry.count > 0) {\r\n levels.push(level);\r\n }\r\n }\r\n if (levels.length === 0) {\r\n return;\r\n }\r\n levels.sort((a, b) => a - b);\r\n\r\n node.availableLevels = levels;\r\n node.baseLod = levels[levels.length - 1];\r\n node.activeLod = undefined;\r\n node.lodCooldown = 0;\r\n this._leafNodes.push(node);\r\n }\r\n\r\n /**\r\n * Streams the scene: learns every source file's splat count, allocates one unified GPU work buffer\r\n * sized for all LOD files, decodes the environment and the coarsest LOD of every node as a permanent\r\n * base layer, then installs the per-frame loop that streams finer LODs on demand.\r\n */\r\n private async _streamAllAsync(): Promise<void> {\r\n // Phase 1: learn splat counts for the environment and every referenced LOD file (cheap meta only).\r\n const fileIds = this._collectAllFileIds();\r\n const envCount = await this._gatherCountsAsync(fileIds);\r\n if (this._disposed) {\r\n return;\r\n }\r\n\r\n // Phase 2: assign fixed work-buffer offsets (environment first, then every file) and allocate.\r\n // Index 0 is reserved as a never-decoded padding splat: the sort worker and index buffer pad unused\r\n // slots with index 0, and leaving that slot zeroed (center.w = 0 => zero covariance, alpha 0) makes\r\n // the padding invisible instead of ghosting a copy of the first real splat.\r\n let capacity = 1;\r\n if (envCount > 0) {\r\n this._environmentRange = { offset: capacity, count: envCount };\r\n capacity += envCount;\r\n }\r\n for (const fileId of fileIds) {\r\n const count = this._fileCounts.get(fileId);\r\n if (count === undefined || count <= 0) {\r\n continue;\r\n }\r\n this._fileBaseSplat.set(fileId, capacity);\r\n capacity += count;\r\n }\r\n if (capacity <= 1) {\r\n return;\r\n }\r\n\r\n this._workBuffer = new GaussianSplattingWorkBuffer(this._scene, capacity);\r\n const splatPositions = new Float32Array(capacity * 4);\r\n const textures = this._workBuffer.textures;\r\n this._setExternalWorkBuffer(textures[0], textures[1], textures[2], textures[3], splatPositions, capacity);\r\n // Nothing is active until at least one resource has been decoded.\r\n this.setSplatIndexRanges([]);\r\n this.setEnabled(true);\r\n\r\n // Phase 3: decode the environment, then every node's coarsest LOD as the permanent base layer.\r\n if (this._environmentRange && this._environmentFiles) {\r\n await this._decodeEnvironmentAsync();\r\n }\r\n this._environmentFiles = null;\r\n\r\n const baseFiles = new Set<number>();\r\n for (const node of this._leafNodes) {\r\n const entry = node.lods![String(node.baseLod)];\r\n if (entry && this._fileBaseSplat.has(entry.file)) {\r\n baseFiles.add(entry.file);\r\n }\r\n }\r\n for (const fileId of Array.from(baseFiles)) {\r\n if (this._disposed) {\r\n return;\r\n }\r\n // eslint-disable-next-line no-await-in-loop\r\n await this._decodeFileAsync(fileId);\r\n }\r\n\r\n if (this._disposed) {\r\n return;\r\n }\r\n // Phase 4: hand off to the per-frame LOD streaming loop.\r\n this._baseLayerReady = true;\r\n if (!this._lodObserver) {\r\n this._lodObserver = this._scene.onBeforeRenderObservable.add(() => this._onLodFrame());\r\n }\r\n }\r\n\r\n /**\r\n * Collects the unique set of source file indices referenced by any LOD of any leaf, sorted ascending.\r\n * @returns sorted unique file indices\r\n */\r\n private _collectAllFileIds(): number[] {\r\n const ids = new Set<number>();\r\n for (const node of this._leafNodes) {\r\n for (const level of node.availableLevels!) {\r\n const entry = node.lods![String(level)];\r\n if (entry) {\r\n ids.add(entry.file);\r\n }\r\n }\r\n }\r\n return Array.from(ids).sort((a, b) => a - b);\r\n }\r\n\r\n /**\r\n * Fetches the environment bundle and every referenced file's metadata to learn splat counts, caching\r\n * each file's parsed metadata for the later on-demand decode. Metadata fetches run in parallel.\r\n * @param fileIds file indices to fetch metadata for\r\n * @returns the environment splat count (0 when there is no environment)\r\n */\r\n private async _gatherCountsAsync(fileIds: number[]): Promise<number> {\r\n let envCount = 0;\r\n if (this._metadata.environment) {\r\n try {\r\n const url = this._rootUrl + this._metadata.environment;\r\n const buffer = (await Tools.LoadFileAsync(url, true)) as ArrayBuffer;\r\n const files = await this._unzipAsync(new Uint8Array(buffer));\r\n const metaBytes = files.get(\"meta.json\");\r\n if (metaBytes) {\r\n const meta = JSON.parse(new TextDecoder().decode(metaBytes)) as SOGRootData;\r\n envCount = GaussianSplattingStream._GetSplatCount(meta);\r\n this._environmentFiles = files;\r\n }\r\n } catch (e: any) {\r\n // The environment is non-essential — keep streaming the LOD tree even if it fails.\r\n Logger.Warn(\"GaussianSplattingStream: failed to load environment: \" + (e?.message ?? e));\r\n }\r\n }\r\n\r\n await Promise.all(\r\n fileIds.map(async (fileId) => {\r\n const relativePath = this._metadata.filenames[fileId];\r\n if (!relativePath) {\r\n Logger.Warn(`GaussianSplattingStream: missing filename for file index ${fileId}.`);\r\n return;\r\n }\r\n try {\r\n const metaUrl = this._rootUrl + relativePath;\r\n const subRootUrl = metaUrl.substring(0, metaUrl.lastIndexOf(\"/\") + 1);\r\n const metaText = (await Tools.LoadFileAsync(metaUrl, false)) as string;\r\n const sogData = JSON.parse(metaText) as SOGRootData;\r\n this._fileCounts.set(fileId, GaussianSplattingStream._GetSplatCount(sogData));\r\n this._fileMeta.set(fileId, { sogData, subRootUrl });\r\n } catch (e: any) {\r\n Logger.Warn(`GaussianSplattingStream: failed to load metadata for ${relativePath}: ${e?.message ?? e}`);\r\n }\r\n })\r\n );\r\n\r\n return envCount;\r\n }\r\n\r\n /**\r\n * Queues a file for on-demand decode if it isn't already decoded, in flight, or already queued.\r\n * @param fileId file index to decode\r\n */\r\n private _enqueueDecode(fileId: number): void {\r\n if (this._decodedFiles.has(fileId) || this._loadingFiles.has(fileId) || !this._fileMeta.has(fileId)) {\r\n return;\r\n }\r\n if (this._decodeQueue.indexOf(fileId) === -1) {\r\n this._decodeQueue.push(fileId);\r\n }\r\n }\r\n\r\n /**\r\n * Starts up to {@link _maxDecodesPerFrame} queued decodes for this frame. Decodes run asynchronously\r\n * and promote any waiting nodes once they complete.\r\n */\r\n private _pumpDecodeQueue(): void {\r\n let started = 0;\r\n while (this._decodeQueue.length > 0 && started < this._maxDecodesPerFrame) {\r\n const fileId = this._decodeQueue.shift()!;\r\n if (this._decodedFiles.has(fileId) || this._loadingFiles.has(fileId)) {\r\n continue;\r\n }\r\n started++;\r\n // eslint-disable-next-line github/no-then\r\n this._decodeFileAsync(fileId).catch((e) => {\r\n Logger.Warn(\"GaussianSplattingStream: decode failed: \" + (e?.message ?? e));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Decodes the always-on environment bundle into its work-buffer block and activates its range.\r\n */\r\n private async _decodeEnvironmentAsync(): Promise<void> {\r\n if (!this._environmentRange || !this._environmentFiles || !this._workBuffer) {\r\n return;\r\n }\r\n const range = this._environmentRange;\r\n try {\r\n const parsed = await ParseSogMetaAsTextures(this._environmentFiles, \"\", this._scene);\r\n const pack = parsed.sogTextures;\r\n if (!pack) {\r\n return;\r\n }\r\n try {\r\n if (this._disposed || !this._workBuffer) {\r\n return;\r\n }\r\n await this._workBuffer.decodeAsync(pack, range.offset);\r\n if (this._disposed) {\r\n return;\r\n }\r\n this._splatPositions!.set(pack.positions.subarray(0, range.count * 4), range.offset * 4);\r\n this._updateBounds(pack.positions, range.count);\r\n this._notifyWorkerNewData();\r\n this._refreshActiveRanges();\r\n } finally {\r\n // Always release the GPU source textures (the decode pass is the only consumer).\r\n GaussianSplattingStream._DisposePack(pack);\r\n }\r\n } catch (e: any) {\r\n Logger.Warn(\"GaussianSplattingStream: failed to decode environment: \" + (e?.message ?? e));\r\n }\r\n }\r\n\r\n /**\r\n * Loads one LOD source file as GPU textures, decodes it into its fixed work-buffer block, records its\r\n * CPU centers for sorting, frees the source textures, then promotes any nodes that were waiting for it.\r\n * Concurrent or repeat requests for the same file are ignored.\r\n * @param fileId file index to decode\r\n */\r\n private async _decodeFileAsync(fileId: number): Promise<void> {\r\n if (this._decodedFiles.has(fileId) || this._loadingFiles.has(fileId)) {\r\n return;\r\n }\r\n const meta = this._fileMeta.get(fileId);\r\n const base = this._fileBaseSplat.get(fileId);\r\n const count = this._fileCounts.get(fileId);\r\n if (!meta || base === undefined || count === undefined) {\r\n return;\r\n }\r\n this._loadingFiles.add(fileId);\r\n try {\r\n const parsed = await ParseSogMetaAsTextures(meta.sogData, meta.subRootUrl, this._scene);\r\n const pack = parsed.sogTextures;\r\n if (!pack) {\r\n return;\r\n }\r\n try {\r\n if (this._disposed || !this._workBuffer) {\r\n return;\r\n }\r\n await this._workBuffer.decodeAsync(pack, base);\r\n if (this._disposed) {\r\n return;\r\n }\r\n this._splatPositions!.set(pack.positions.subarray(0, count * 4), base * 4);\r\n this._updateBounds(pack.positions, count);\r\n this._decodedFiles.add(fileId);\r\n this._notifyWorkerNewData();\r\n // Promote any nodes that can now reach their desired LOD via this newly decoded file.\r\n if (this._applyDesiredLods()) {\r\n this._refreshActiveRanges();\r\n }\r\n } finally {\r\n // Always release the GPU source textures (the decode pass is the only consumer).\r\n GaussianSplattingStream._DisposePack(pack);\r\n }\r\n } finally {\r\n this._loadingFiles.delete(fileId);\r\n }\r\n }\r\n\r\n /**\r\n * Snaps a desired LOD level to the nearest level the node provides, while never selecting a level finer\r\n * than {@link maxDetailLod} (i.e. with an index below the cap). Ties prefer the finer allowed level. If\r\n * the node has no level at or coarser than the cap, its coarsest available level is used.\r\n * @param node leaf node\r\n * @param desired desired LOD level\r\n * @returns the chosen available level\r\n */\r\n private _cappedLevelForNode(node: ISOGLODNode, desired: number): number {\r\n const levels = node.availableLevels!;\r\n const floor = this._maxDetailLod;\r\n let best = -1;\r\n let bestDiff = Number.POSITIVE_INFINITY;\r\n for (const level of levels) {\r\n if (level < floor) {\r\n continue;\r\n }\r\n const diff = Math.abs(level - desired);\r\n if (diff < bestDiff) {\r\n best = level;\r\n bestDiff = diff;\r\n }\r\n }\r\n // No level is coarse enough to satisfy the cap: fall back to the coarsest the node has.\r\n return best < 0 ? node.baseLod! : best;\r\n }\r\n\r\n /**\r\n * Computes each node's {@link ISOGLODNode.targetLevel}: the distance-based optimal level snapped to an\r\n * available level, capped so no node renders finer (more detailed) than {@link maxDetailLod}.\r\n */\r\n private _computeTargetLevels(): void {\r\n for (const node of this._leafNodes) {\r\n const desired = node.optimalLod ?? node.baseLod!;\r\n node.targetLevel = this._cappedLevelForNode(node, desired);\r\n }\r\n }\r\n\r\n /**\r\n * Applies each node's {@link ISOGLODNode.targetLevel}: switches a node to its target level when that\r\n * level's file is already decoded, otherwise queues the file and leaves the node on its current LOD (so\r\n * nothing ever disappears). Nodes within their post-switch cooldown are left untouched to damp oscillation.\r\n * @returns true when at least one node changed LOD (callers should refresh the active ranges)\r\n */\r\n private _applyDesiredLods(): boolean {\r\n let dirty = false;\r\n for (const node of this._leafNodes) {\r\n if (node.lodCooldown && node.lodCooldown > 0) {\r\n continue;\r\n }\r\n const desired = node.targetLevel ?? node.baseLod!;\r\n if (desired === node.activeLod) {\r\n continue;\r\n }\r\n const entry = node.lods![String(desired)];\r\n if (!entry) {\r\n continue;\r\n }\r\n if (this._decodedFiles.has(entry.file)) {\r\n node.activeLod = desired;\r\n node.lodCooldown = this._lodCooldownFrames;\r\n dirty = true;\r\n } else {\r\n this._enqueueDecode(entry.file);\r\n }\r\n }\r\n return dirty;\r\n }\r\n\r\n /**\r\n * Per-frame LOD streaming loop. Ticks cooldowns and pumps the decode queue every frame, but throttles\r\n * the expensive LOD re-evaluation (optimal-LOD computation, budget balancing, desired-LOD application\r\n * and interval rebuild) to run at most every {@link _lodUpdateInterval} frames and only after the camera\r\n * has moved far enough, so continuous camera motion no longer rebuilds the interval set every frame. A\r\n * budget change forces a single immediate update regardless of the throttle.\r\n */\r\n private _onLodFrame(): void {\r\n if (this._disposed || !this._baseLayerReady) {\r\n return;\r\n }\r\n for (const node of this._leafNodes) {\r\n if (node.lodCooldown && node.lodCooldown > 0) {\r\n node.lodCooldown--;\r\n }\r\n }\r\n // In-flight/queued decodes still progress every frame.\r\n this._pumpDecodeQueue();\r\n\r\n const forced = this._forceLodUpdate;\r\n if (!forced) {\r\n if (++this._framesSinceLodUpdate < this._lodUpdateInterval) {\r\n return;\r\n }\r\n const camera = this._scene.activeCamera;\r\n if (camera) {\r\n const threshold = this._lodUpdateDistance;\r\n if (Vector3.DistanceSquared(camera.globalPosition, this._lastLodCamPos) < threshold * threshold) {\r\n return;\r\n }\r\n this._lastLodCamPos.copyFrom(camera.globalPosition);\r\n }\r\n }\r\n this._forceLodUpdate = false;\r\n this._framesSinceLodUpdate = 0;\r\n\r\n this.evaluateOptimalLods(this._scene.activeCamera);\r\n this._computeTargetLevels();\r\n if (this._applyDesiredLods()) {\r\n this._refreshActiveRanges();\r\n }\r\n }\r\n\r\n /**\r\n * Reads the splat count from SOG metadata.\r\n * @param data SOG metadata\r\n * @returns the splat count\r\n */\r\n private static _GetSplatCount(data: SOGRootData): number {\r\n return data.count ?? (Array.isArray(data.means.shape) ? data.means.shape[0] : 0);\r\n }\r\n\r\n /**\r\n * Disposes all GPU source textures of a SOG pack (they are only needed for the one decode pass).\r\n * @param pack the SOG texture pack\r\n */\r\n private static _DisposePack(pack: ISogTexturePack): void {\r\n pack.meansTextureL.dispose();\r\n pack.meansTextureU.dispose();\r\n pack.scalesTexture.dispose();\r\n pack.quatsTexture.dispose();\r\n pack.sh0Texture.dispose();\r\n pack.shCentroidsTexture?.dispose();\r\n pack.shLabelsTexture?.dispose();\r\n pack.codebookTexture?.dispose();\r\n }\r\n\r\n /**\r\n * Expands the running splat-center bounds with a newly decoded file's centers and updates the\r\n * mesh bounding info so the GS is correctly frustum-culled and pickable.\r\n * @param positions stride-4 splat centers for the new file\r\n * @param count number of splats\r\n */\r\n private _updateBounds(positions: Float32Array, count: number): void {\r\n const min = this._boundsMin;\r\n const max = this._boundsMax;\r\n for (let i = 0; i < count; i++) {\r\n const x = positions[i * 4 + 0];\r\n const y = positions[i * 4 + 1];\r\n const z = positions[i * 4 + 2];\r\n min.minimizeInPlaceFromFloats(x, y, z);\r\n max.maximizeInPlaceFromFloats(x, y, z);\r\n }\r\n this.setBoundingInfo(new BoundingInfo(min, max));\r\n }\r\n\r\n /**\r\n * Rebuilds the active interval set from the environment plus each node's currently-selected LOD entry,\r\n * coalesces adjacent ranges, and pushes the result to the sort worker.\r\n */\r\n private _refreshActiveRanges(): void {\r\n const ranges: IGaussianSplattingSplatRange[] = [];\r\n\r\n if (this._environmentRange) {\r\n ranges.push({ offset: this._environmentRange.offset, count: this._environmentRange.count });\r\n }\r\n\r\n for (const node of this._leafNodes) {\r\n if (node.activeLod === undefined) {\r\n continue;\r\n }\r\n const entry = node.lods![String(node.activeLod)];\r\n if (!entry) {\r\n continue;\r\n }\r\n const base = this._fileBaseSplat.get(entry.file);\r\n if (base === undefined) {\r\n continue;\r\n }\r\n ranges.push({ offset: base + entry.offset, count: entry.count });\r\n }\r\n\r\n this.setSplatIndexRanges(GaussianSplattingStream._CoalesceRanges(ranges));\r\n }\r\n\r\n /**\r\n * Sorts and merges adjacent/overlapping ranges to keep the interval list compact.\r\n * @param ranges raw ranges\r\n * @returns coalesced ranges\r\n */\r\n private static _CoalesceRanges(ranges: IGaussianSplattingSplatRange[]): IGaussianSplattingSplatRange[] {\r\n if (ranges.length <= 1) {\r\n return ranges;\r\n }\r\n const sorted = ranges.slice().sort((a, b) => a.offset - b.offset);\r\n const merged: IGaussianSplattingSplatRange[] = [{ offset: sorted[0].offset, count: sorted[0].count }];\r\n for (let i = 1; i < sorted.length; i++) {\r\n const last = merged[merged.length - 1];\r\n const range = sorted[i];\r\n const lastEnd = last.offset + last.count;\r\n if (range.offset <= lastEnd) {\r\n const end = Math.max(lastEnd, range.offset + range.count);\r\n last.count = end - last.offset;\r\n } else {\r\n merged.push({ offset: range.offset, count: range.count });\r\n }\r\n }\r\n return merged;\r\n }\r\n\r\n /**\r\n * Unzips a `.sog` bundle into a name -> bytes map, loading fflate on demand.\r\n * @param data zipped bytes\r\n * @returns map of entry name to bytes\r\n */\r\n private async _unzipAsync(data: Uint8Array): Promise<Map<string, Uint8Array>> {\r\n let fflateModule = this._streamOptions.fflate;\r\n if (!fflateModule) {\r\n if (typeof (window as any).fflate === \"undefined\") {\r\n await Tools.LoadScriptAsync(this._streamOptions.deflateURL ?? \"https://unpkg.com/fflate/umd/index.js\");\r\n }\r\n fflateModule = (window as any).fflate;\r\n }\r\n\r\n const unzipped = fflateModule.unzipSync(data) as Record<string, Uint8Array>;\r\n const files = new Map<string, Uint8Array>();\r\n for (const [name, content] of Object.entries(unzipped)) {\r\n files.set(name, content);\r\n }\r\n return files;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,51 @@
1
+ import { type Texture } from "@babylonjs/core/Materials/Textures/texture.js";
2
+ import { type Scene } from "@babylonjs/core/scene.js";
3
+ import { type ISogTexturePack } from "./splatDefs.js";
4
+ /**
5
+ * A unified, GPU-decoded Gaussian Splatting work buffer.
6
+ *
7
+ * Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity
8
+ * (PlayCanvas-style: `ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU
9
+ * (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the
10
+ * standard (non-SOG) Gaussian Splatting draw path.
11
+ *
12
+ * @experimental
13
+ */
14
+ export declare class GaussianSplattingWorkBuffer {
15
+ private readonly _scene;
16
+ private readonly _mrt;
17
+ private readonly _textureSize;
18
+ private readonly _shaderLanguage;
19
+ private readonly _material;
20
+ private readonly _quad;
21
+ private _disposed;
22
+ /**
23
+ * Square edge length (in pixels) of the work-buffer textures.
24
+ */
25
+ get textureSize(): number;
26
+ /**
27
+ * The decoded work-buffer textures: [centers, covA, covB, colors].
28
+ */
29
+ get textures(): Texture[];
30
+ /**
31
+ * Creates a work buffer sized to hold `capacity` splats.
32
+ * @param scene hosting scene
33
+ * @param capacity total number of splats the work buffer must address
34
+ */
35
+ constructor(scene: Scene, capacity: number);
36
+ /**
37
+ * Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously
38
+ * decoded files are preserved). Resolves once the GPU decode has been issued. The caller may
39
+ * dispose the source pack textures after this resolves.
40
+ * @param pack the SOG texture pack (GPU source textures + per-file decode parameters)
41
+ * @param offset first splat index (pixel offset) for this file in the work buffer
42
+ */
43
+ decodeAsync(pack: ISogTexturePack, offset: number): Promise<void>;
44
+ /**
45
+ * Disposes the work buffer and its decode resources.
46
+ */
47
+ dispose(): void;
48
+ private _createQuad;
49
+ private _createMaterial;
50
+ private _applyPack;
51
+ }
@@ -0,0 +1,159 @@
1
+ import { MultiRenderTarget } from "@babylonjs/core/Materials/Textures/multiRenderTarget.js";
2
+ import { ShaderMaterial } from "@babylonjs/core/Materials/shaderMaterial.js";
3
+ import { Constants } from "@babylonjs/core/Engines/constants.js";
4
+ import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
5
+ import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
6
+ import { Color4 } from "@babylonjs/core/Maths/math.color.js";
7
+ import { Vector3, Vector4 } from "@babylonjs/core/Maths/math.vector.js";
8
+ import { GaussianSplattingWorkBufferVertexShaderGLSL, GaussianSplattingWorkBufferFragmentShaderGLSL, GaussianSplattingWorkBufferVertexShaderWGSL, GaussianSplattingWorkBufferFragmentShaderWGSL, } from "./gaussianSplattingWorkBufferShaders.js";
9
+ /**
10
+ * A unified, GPU-decoded Gaussian Splatting work buffer.
11
+ *
12
+ * Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity
13
+ * (PlayCanvas-style: `ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU
14
+ * (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the
15
+ * standard (non-SOG) Gaussian Splatting draw path.
16
+ *
17
+ * @experimental
18
+ */
19
+ export class GaussianSplattingWorkBuffer {
20
+ /**
21
+ * Square edge length (in pixels) of the work-buffer textures.
22
+ */
23
+ get textureSize() {
24
+ return this._textureSize;
25
+ }
26
+ /**
27
+ * The decoded work-buffer textures: [centers, covA, covB, colors].
28
+ */
29
+ get textures() {
30
+ return this._mrt.textures;
31
+ }
32
+ /**
33
+ * Creates a work buffer sized to hold `capacity` splats.
34
+ * @param scene hosting scene
35
+ * @param capacity total number of splats the work buffer must address
36
+ */
37
+ constructor(scene, capacity) {
38
+ this._disposed = false;
39
+ this._scene = scene;
40
+ this._shaderLanguage = scene.getEngine().isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */;
41
+ this._textureSize = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, capacity))));
42
+ this._mrt = new MultiRenderTarget("gsWorkBuffer", { width: this._textureSize, height: this._textureSize }, 4, scene, {
43
+ types: [Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_UNSIGNED_BYTE],
44
+ samplingModes: [
45
+ Constants.TEXTURE_NEAREST_SAMPLINGMODE,
46
+ Constants.TEXTURE_NEAREST_SAMPLINGMODE,
47
+ Constants.TEXTURE_NEAREST_SAMPLINGMODE,
48
+ Constants.TEXTURE_NEAREST_SAMPLINGMODE,
49
+ ],
50
+ formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],
51
+ generateDepthBuffer: false,
52
+ generateDepthTexture: false,
53
+ generateMipMaps: false,
54
+ }, ["gsWorkCenters", "gsWorkCovA", "gsWorkCovB", "gsWorkColors"]);
55
+ this._mrt.clearColor = new Color4(0, 0, 0, 0);
56
+ this._mrt.renderList = [];
57
+ // Take over clearing (no-op) so each decode accumulates into the buffer instead of wiping
58
+ // previously-decoded files. Undecoded regions are never sampled (only active intervals render).
59
+ this._mrt.onClearObservable.add(() => { });
60
+ // One persistent decode material + fullscreen-triangle quad, reused (with per-file uniforms)
61
+ // for every decode so the shader is compiled only once.
62
+ this._material = this._createMaterial();
63
+ this._quad = this._createQuad();
64
+ this._quad.material = this._material;
65
+ }
66
+ /**
67
+ * Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously
68
+ * decoded files are preserved). Resolves once the GPU decode has been issued. The caller may
69
+ * dispose the source pack textures after this resolves.
70
+ * @param pack the SOG texture pack (GPU source textures + per-file decode parameters)
71
+ * @param offset first splat index (pixel offset) for this file in the work buffer
72
+ */
73
+ async decodeAsync(pack, offset) {
74
+ if (this._disposed) {
75
+ return;
76
+ }
77
+ this._applyPack(pack, offset);
78
+ // Render the decode pass at the start of a frame (the safe point for custom render targets),
79
+ // once the shader is compiled — never re-entrantly from a promise/observable continuation.
80
+ await new Promise((resolve) => {
81
+ const attempt = () => {
82
+ if (this._disposed) {
83
+ resolve();
84
+ return;
85
+ }
86
+ if (!this._material.isReady(this._quad)) {
87
+ this._scene.onBeforeRenderObservable.addOnce(attempt);
88
+ return;
89
+ }
90
+ this._mrt.renderList = [this._quad];
91
+ this._mrt.render();
92
+ resolve();
93
+ };
94
+ this._scene.onBeforeRenderObservable.addOnce(attempt);
95
+ });
96
+ }
97
+ /**
98
+ * Disposes the work buffer and its decode resources.
99
+ */
100
+ dispose() {
101
+ this._disposed = true;
102
+ this._quad.dispose();
103
+ this._material.dispose(true, false);
104
+ this._mrt.dispose();
105
+ }
106
+ _createQuad() {
107
+ const quad = new Mesh("gsWorkBufferQuad", this._scene);
108
+ const vertexData = new VertexData();
109
+ // Fullscreen triangle in clip space (the vertex shader passes positions straight through).
110
+ vertexData.positions = [-1, -1, 0, 3, -1, 0, -1, 3, 0];
111
+ vertexData.indices = [0, 1, 2];
112
+ vertexData.applyToMesh(quad);
113
+ // Render only inside the work-buffer MRT, never in the main scene pass.
114
+ this._scene.removeMesh(quad);
115
+ return quad;
116
+ }
117
+ _createMaterial() {
118
+ const isWGSL = this._shaderLanguage === 1 /* ShaderLanguage.WGSL */;
119
+ const material = new ShaderMaterial("gsSogDecode", this._scene, {
120
+ vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,
121
+ fragmentSource: isWGSL ? GaussianSplattingWorkBufferFragmentShaderWGSL : GaussianSplattingWorkBufferFragmentShaderGLSL,
122
+ }, {
123
+ attributes: ["position"],
124
+ uniforms: ["sogMeansMin", "sogMeansMax", "sogScalesMin", "sogScalesMax", "sogSh0Min", "sogSh0Max", "uVersion", "uOffset", "uCount", "uDestWidth", "uSrcWidth"],
125
+ samplers: ["sogMeansLTex", "sogMeansUTex", "sogScalesTex", "sogQuatsTex", "sogSh0Tex", "sogCodebookTex"],
126
+ shaderLanguage: this._shaderLanguage,
127
+ });
128
+ material.backFaceCulling = false;
129
+ material.disableDepthWrite = true;
130
+ return material;
131
+ }
132
+ _applyPack(pack, offset) {
133
+ const material = this._material;
134
+ const srcWidth = pack.meansTextureL.getSize().width;
135
+ material.setTexture("sogMeansLTex", pack.meansTextureL);
136
+ material.setTexture("sogMeansUTex", pack.meansTextureU);
137
+ material.setTexture("sogScalesTex", pack.scalesTexture);
138
+ material.setTexture("sogQuatsTex", pack.quatsTexture);
139
+ material.setTexture("sogSh0Tex", pack.sh0Texture);
140
+ // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.
141
+ material.setTexture("sogCodebookTex", pack.codebookTexture ?? pack.sh0Texture);
142
+ material.setVector3("sogMeansMin", new Vector3(pack.meansMin[0], pack.meansMin[1], pack.meansMin[2]));
143
+ material.setVector3("sogMeansMax", new Vector3(pack.meansMax[0], pack.meansMax[1], pack.meansMax[2]));
144
+ const sMin = pack.scalesMin ?? [0, 0, 0];
145
+ const sMax = pack.scalesMax ?? [0, 0, 0];
146
+ material.setVector3("sogScalesMin", new Vector3(sMin[0], sMin[1], sMin[2]));
147
+ material.setVector3("sogScalesMax", new Vector3(sMax[0], sMax[1], sMax[2]));
148
+ const c0Min = pack.sh0Min ?? [0, 0, 0, 0];
149
+ const c0Max = pack.sh0Max ?? [0, 0, 0, 0];
150
+ material.setVector4("sogSh0Min", new Vector4(c0Min[0], c0Min[1], c0Min[2], c0Min[3]));
151
+ material.setVector4("sogSh0Max", new Vector4(c0Max[0], c0Max[1], c0Max[2], c0Max[3]));
152
+ material.setInt("uVersion", pack.version);
153
+ material.setInt("uOffset", offset);
154
+ material.setInt("uCount", pack.splatCount);
155
+ material.setInt("uDestWidth", this._textureSize);
156
+ material.setInt("uSrcWidth", srcWidth);
157
+ }
158
+ }
159
+ //# sourceMappingURL=gaussianSplattingWorkBuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gaussianSplattingWorkBuffer.js","sourceRoot":"","sources":["../../../../dev/loaders/src/SPLAT/gaussianSplattingWorkBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EACH,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,6CAA6C,GAChD,MAAM,sCAAsC,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA2B;IASpC;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC9B,CAAC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AAC,WAAW,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACJ","sourcesContent":["import { MultiRenderTarget } from \"core/Materials/Textures/multiRenderTarget\";\r\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { type Texture } from \"core/Materials/Textures/texture\";\r\nimport { type Scene } from \"core/scene\";\r\nimport { type ISogTexturePack } from \"./splatDefs\";\r\nimport {\r\n GaussianSplattingWorkBufferVertexShaderGLSL,\r\n GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n GaussianSplattingWorkBufferVertexShaderWGSL,\r\n GaussianSplattingWorkBufferFragmentShaderWGSL,\r\n} from \"./gaussianSplattingWorkBufferShaders\";\r\n\r\n/**\r\n * A unified, GPU-decoded Gaussian Splatting work buffer.\r\n *\r\n * Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity\r\n * (PlayCanvas-style: `ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU\r\n * (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the\r\n * standard (non-SOG) Gaussian Splatting draw path.\r\n *\r\n * @experimental\r\n */\r\nexport class GaussianSplattingWorkBuffer {\r\n private readonly _scene: Scene;\r\n private readonly _mrt: MultiRenderTarget;\r\n private readonly _textureSize: number;\r\n private readonly _shaderLanguage: ShaderLanguage;\r\n private readonly _material: ShaderMaterial;\r\n private readonly _quad: Mesh;\r\n private _disposed = false;\r\n\r\n /**\r\n * Square edge length (in pixels) of the work-buffer textures.\r\n */\r\n public get textureSize(): number {\r\n return this._textureSize;\r\n }\r\n\r\n /**\r\n * The decoded work-buffer textures: [centers, covA, covB, colors].\r\n */\r\n public get textures(): Texture[] {\r\n return this._mrt.textures;\r\n }\r\n\r\n /**\r\n * Creates a work buffer sized to hold `capacity` splats.\r\n * @param scene hosting scene\r\n * @param capacity total number of splats the work buffer must address\r\n */\r\n constructor(scene: Scene, capacity: number) {\r\n this._scene = scene;\r\n this._shaderLanguage = scene.getEngine().isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL;\r\n this._textureSize = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, capacity))));\r\n\r\n this._mrt = new MultiRenderTarget(\r\n \"gsWorkBuffer\",\r\n { width: this._textureSize, height: this._textureSize },\r\n 4,\r\n scene,\r\n {\r\n types: [Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_UNSIGNED_BYTE],\r\n samplingModes: [\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n ],\r\n formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],\r\n generateDepthBuffer: false,\r\n generateDepthTexture: false,\r\n generateMipMaps: false,\r\n },\r\n [\"gsWorkCenters\", \"gsWorkCovA\", \"gsWorkCovB\", \"gsWorkColors\"]\r\n );\r\n this._mrt.clearColor = new Color4(0, 0, 0, 0);\r\n this._mrt.renderList = [];\r\n // Take over clearing (no-op) so each decode accumulates into the buffer instead of wiping\r\n // previously-decoded files. Undecoded regions are never sampled (only active intervals render).\r\n this._mrt.onClearObservable.add(() => {});\r\n\r\n // One persistent decode material + fullscreen-triangle quad, reused (with per-file uniforms)\r\n // for every decode so the shader is compiled only once.\r\n this._material = this._createMaterial();\r\n this._quad = this._createQuad();\r\n this._quad.material = this._material;\r\n }\r\n\r\n /**\r\n * Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously\r\n * decoded files are preserved). Resolves once the GPU decode has been issued. The caller may\r\n * dispose the source pack textures after this resolves.\r\n * @param pack the SOG texture pack (GPU source textures + per-file decode parameters)\r\n * @param offset first splat index (pixel offset) for this file in the work buffer\r\n */\r\n public async decodeAsync(pack: ISogTexturePack, offset: number): Promise<void> {\r\n if (this._disposed) {\r\n return;\r\n }\r\n this._applyPack(pack, offset);\r\n // Render the decode pass at the start of a frame (the safe point for custom render targets),\r\n // once the shader is compiled — never re-entrantly from a promise/observable continuation.\r\n await new Promise<void>((resolve) => {\r\n const attempt = () => {\r\n if (this._disposed) {\r\n resolve();\r\n return;\r\n }\r\n if (!this._material.isReady(this._quad)) {\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n return;\r\n }\r\n this._mrt.renderList = [this._quad];\r\n this._mrt.render();\r\n resolve();\r\n };\r\n this._scene.onBeforeRenderObservable.addOnce(attempt);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes the work buffer and its decode resources.\r\n */\r\n public dispose(): void {\r\n this._disposed = true;\r\n this._quad.dispose();\r\n this._material.dispose(true, false);\r\n this._mrt.dispose();\r\n }\r\n\r\n private _createQuad(): Mesh {\r\n const quad = new Mesh(\"gsWorkBufferQuad\", this._scene);\r\n const vertexData = new VertexData();\r\n // Fullscreen triangle in clip space (the vertex shader passes positions straight through).\r\n vertexData.positions = [-1, -1, 0, 3, -1, 0, -1, 3, 0];\r\n vertexData.indices = [0, 1, 2];\r\n vertexData.applyToMesh(quad);\r\n // Render only inside the work-buffer MRT, never in the main scene pass.\r\n this._scene.removeMesh(quad);\r\n return quad;\r\n }\r\n\r\n private _createMaterial(): ShaderMaterial {\r\n const isWGSL = this._shaderLanguage === ShaderLanguage.WGSL;\r\n const material = new ShaderMaterial(\r\n \"gsSogDecode\",\r\n this._scene,\r\n {\r\n vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,\r\n fragmentSource: isWGSL ? GaussianSplattingWorkBufferFragmentShaderWGSL : GaussianSplattingWorkBufferFragmentShaderGLSL,\r\n },\r\n {\r\n attributes: [\"position\"],\r\n uniforms: [\"sogMeansMin\", \"sogMeansMax\", \"sogScalesMin\", \"sogScalesMax\", \"sogSh0Min\", \"sogSh0Max\", \"uVersion\", \"uOffset\", \"uCount\", \"uDestWidth\", \"uSrcWidth\"],\r\n samplers: [\"sogMeansLTex\", \"sogMeansUTex\", \"sogScalesTex\", \"sogQuatsTex\", \"sogSh0Tex\", \"sogCodebookTex\"],\r\n shaderLanguage: this._shaderLanguage,\r\n }\r\n );\r\n material.backFaceCulling = false;\r\n material.disableDepthWrite = true;\r\n return material;\r\n }\r\n\r\n private _applyPack(pack: ISogTexturePack, offset: number): void {\r\n const material = this._material;\r\n const srcWidth = (pack.meansTextureL as Texture).getSize().width;\r\n\r\n material.setTexture(\"sogMeansLTex\", pack.meansTextureL);\r\n material.setTexture(\"sogMeansUTex\", pack.meansTextureU);\r\n material.setTexture(\"sogScalesTex\", pack.scalesTexture);\r\n material.setTexture(\"sogQuatsTex\", pack.quatsTexture);\r\n material.setTexture(\"sogSh0Tex\", pack.sh0Texture);\r\n // Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.\r\n material.setTexture(\"sogCodebookTex\", pack.codebookTexture ?? pack.sh0Texture);\r\n\r\n material.setVector3(\"sogMeansMin\", new Vector3(pack.meansMin[0], pack.meansMin[1], pack.meansMin[2]));\r\n material.setVector3(\"sogMeansMax\", new Vector3(pack.meansMax[0], pack.meansMax[1], pack.meansMax[2]));\r\n const sMin = pack.scalesMin ?? [0, 0, 0];\r\n const sMax = pack.scalesMax ?? [0, 0, 0];\r\n material.setVector3(\"sogScalesMin\", new Vector3(sMin[0], sMin[1], sMin[2]));\r\n material.setVector3(\"sogScalesMax\", new Vector3(sMax[0], sMax[1], sMax[2]));\r\n const c0Min = pack.sh0Min ?? [0, 0, 0, 0];\r\n const c0Max = pack.sh0Max ?? [0, 0, 0, 0];\r\n material.setVector4(\"sogSh0Min\", new Vector4(c0Min[0], c0Min[1], c0Min[2], c0Min[3]));\r\n material.setVector4(\"sogSh0Max\", new Vector4(c0Max[0], c0Max[1], c0Max[2], c0Max[3]));\r\n\r\n material.setInt(\"uVersion\", pack.version);\r\n material.setInt(\"uOffset\", offset);\r\n material.setInt(\"uCount\", pack.splatCount);\r\n material.setInt(\"uDestWidth\", this._textureSize);\r\n material.setInt(\"uSrcWidth\", srcWidth);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,25 @@
1
+ /** This file must only contain pure code and pure imports */
2
+ /**
3
+ * Shared shader names for the SOG -> decoded work-buffer copy pass.
4
+ */
5
+ export declare const GaussianSplattingWorkBufferShaderName = "gsSogDecodeToWorkBuffer";
6
+ /**
7
+ * Pass-through vertex shader (GLSL): the geometry is a fullscreen triangle already in NDC.
8
+ */
9
+ export declare const GaussianSplattingWorkBufferVertexShaderGLSL = "precision highp float;\nattribute vec3 position;\nvoid main() {\n gl_Position = vec4(position.xy, 0.0, 1.0);\n}\n";
10
+ /**
11
+ * Fragment shader (GLSL/WebGL2): decodes one SOG source file into the decoded GS work-buffer layout,
12
+ * writing each splat into its allocated pixel. Mirrors the USE_SOG decode in ShadersInclude/gaussianSplatting.fx
13
+ * but outputs the decoded MRT (center, covA, covB, color) consumed by the standard (non-SOG) draw path.
14
+ *
15
+ * MRT layout: 0 = center (x,y,z,1), 1 = covA (Sigma00,01,02,11), 2 = covB (Sigma12,22,0,0), 3 = color (rgba).
16
+ */
17
+ export declare const GaussianSplattingWorkBufferFragmentShaderGLSL = "precision highp float;\nprecision highp int;\n\nuniform sampler2D sogMeansLTex;\nuniform sampler2D sogMeansUTex;\nuniform sampler2D sogScalesTex;\nuniform sampler2D sogQuatsTex;\nuniform sampler2D sogSh0Tex;\nuniform sampler2D sogCodebookTex;\n\nuniform vec3 sogMeansMin;\nuniform vec3 sogMeansMax;\nuniform vec3 sogScalesMin;\nuniform vec3 sogScalesMax;\nuniform vec4 sogSh0Min;\nuniform vec4 sogSh0Max;\nuniform int uVersion;\nuniform int uOffset;\nuniform int uCount;\nuniform int uDestWidth;\nuniform int uSrcWidth;\n\nlayout(location = 0) out vec4 glFragData[4];\n\nmat3 transposeM(mat3 m) {\n return mat3(m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]);\n}\n\nvoid main() {\n ivec2 p = ivec2(gl_FragCoord.xy);\n int global = p.y * uDestWidth + p.x;\n if (global < uOffset || global >= uOffset + uCount) {\n discard;\n }\n int k = global - uOffset;\n ivec2 src = ivec2(k - (k / uSrcWidth) * uSrcWidth, k / uSrcWidth);\n\n vec3 mL = texelFetch(sogMeansLTex, src, 0).xyz;\n vec3 mU = texelFetch(sogMeansUTex, src, 0).xyz;\n vec3 sRaw = texelFetch(sogScalesTex, src, 0).xyz;\n vec4 qRaw = texelFetch(sogQuatsTex, src, 0);\n vec4 c0 = texelFetch(sogSh0Tex, src, 0);\n\n // Position: q16 = (u<<8)|l normalized; n = lerp(min,max,q16); pos = sign(n)*(exp(|n|)-1)\n vec3 q16 = (mU * 256.0 + mL) * (255.0 / 65535.0);\n vec3 nPos = mix(sogMeansMin, sogMeansMax, q16);\n vec3 center = sign(nPos) * (exp(abs(nPos)) - vec3(1.0));\n\n // Scale (v1: lerp+exp ; v2: codebook lookup)\n vec3 splatScale;\n if (uVersion == 2) {\n vec3 sIdx = floor(sRaw * 255.0 + 0.5);\n splatScale.x = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.x), 0), 0).r);\n splatScale.y = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.y), 0), 0).r);\n splatScale.z = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.z), 0), 0).r);\n } else {\n splatScale = exp(mix(sogScalesMin, sogScalesMax, sRaw));\n }\n\n // Quaternion (largest-omitted, mode in alpha as 252 + omitted-index)\n const float invSqrt2 = 0.70710678118;\n vec3 qabc = (qRaw.xyz - vec3(0.5)) * 2.0 * invSqrt2;\n int qMode = int(qRaw.w * 255.0 + 0.5) - 252;\n float qd = sqrt(max(0.0, 1.0 - dot(qabc, qabc)));\n vec4 quat;\n if (qMode == 0) {\n quat = vec4(qd, qabc.x, qabc.y, qabc.z);\n } else if (qMode == 1) {\n quat = vec4(qabc.x, qd, qabc.y, qabc.z);\n } else if (qMode == 2) {\n quat = vec4(qabc.x, qabc.y, qd, qabc.z);\n } else {\n quat = vec4(qabc.x, qabc.y, qabc.z, qd);\n }\n\n float qw = quat.x, qx = quat.y, qy = quat.z, qz = quat.w;\n mat3 R = mat3(\n 1.0 - 2.0 * (qy * qy + qz * qz), 2.0 * (qx * qy + qw * qz), 2.0 * (qx * qz - qw * qy),\n 2.0 * (qx * qy - qw * qz), 1.0 - 2.0 * (qx * qx + qz * qz), 2.0 * (qy * qz + qw * qx),\n 2.0 * (qx * qz + qw * qy), 2.0 * (qy * qz - qw * qx), 1.0 - 2.0 * (qx * qx + qy * qy)\n );\n mat3 S2 = mat3(\n 4.0 * splatScale.x * splatScale.x, 0.0, 0.0,\n 0.0, 4.0 * splatScale.y * splatScale.y, 0.0,\n 0.0, 0.0, 4.0 * splatScale.z * splatScale.z\n );\n mat3 Sigma = R * S2 * transposeM(R);\n\n // Color (sh0)\n const float SH_C0 = 0.28209479177387814;\n vec3 colRgb;\n float colA;\n if (uVersion == 2) {\n vec3 c3;\n c3.x = texelFetch(sogCodebookTex, ivec2(256 + int(c0.x * 255.0 + 0.5), 0), 0).r;\n c3.y = texelFetch(sogCodebookTex, ivec2(256 + int(c0.y * 255.0 + 0.5), 0), 0).r;\n c3.z = texelFetch(sogCodebookTex, ivec2(256 + int(c0.z * 255.0 + 0.5), 0), 0).r;\n colRgb = vec3(0.5) + c3 * SH_C0;\n colA = c0.w;\n } else {\n vec4 cLerp = mix(sogSh0Min, sogSh0Max, c0);\n colRgb = vec3(0.5) + cLerp.xyz * SH_C0;\n colA = 1.0 / (1.0 + exp(-cLerp.w));\n }\n\n glFragData[0] = vec4(center, 1.0);\n glFragData[1] = vec4(Sigma[0][0], Sigma[0][1], Sigma[0][2], Sigma[1][1]);\n glFragData[2] = vec4(Sigma[1][2], Sigma[2][2], 0.0, 0.0);\n glFragData[3] = vec4(colRgb, colA);\n}\n";
18
+ /**
19
+ * Pass-through vertex shader (WGSL).
20
+ */
21
+ export declare const GaussianSplattingWorkBufferVertexShaderWGSL = "\nattribute position : vec3<f32>;\n@vertex\nfn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.position = vec4<f32>(input.position.xy, 0.0, 1.0);\n}\n";
22
+ /**
23
+ * Fragment shader (WGSL/WebGPU) — same decode as the GLSL variant, writing 4 MRT attachments.
24
+ */
25
+ export declare const GaussianSplattingWorkBufferFragmentShaderWGSL = "\nvar sogMeansLTexSampler : sampler;\nvar sogMeansLTex : texture_2d<f32>;\nvar sogMeansUTexSampler : sampler;\nvar sogMeansUTex : texture_2d<f32>;\nvar sogScalesTexSampler : sampler;\nvar sogScalesTex : texture_2d<f32>;\nvar sogQuatsTexSampler : sampler;\nvar sogQuatsTex : texture_2d<f32>;\nvar sogSh0TexSampler : sampler;\nvar sogSh0Tex : texture_2d<f32>;\nvar sogCodebookTexSampler : sampler;\nvar sogCodebookTex : texture_2d<f32>;\n\nuniform sogMeansMin : vec3<f32>;\nuniform sogMeansMax : vec3<f32>;\nuniform sogScalesMin : vec3<f32>;\nuniform sogScalesMax : vec3<f32>;\nuniform sogSh0Min : vec4<f32>;\nuniform sogSh0Max : vec4<f32>;\nuniform uVersion : i32;\nuniform uOffset : i32;\nuniform uCount : i32;\nuniform uDestWidth : i32;\nuniform uSrcWidth : i32;\n\n@fragment\nfn main(input : FragmentInputs) -> FragmentOutputs {\n let p : vec2<i32> = vec2<i32>(i32(fragmentInputs.position.x), i32(fragmentInputs.position.y));\n let global : i32 = p.y * uniforms.uDestWidth + p.x;\n if (global < uniforms.uOffset || global >= uniforms.uOffset + uniforms.uCount) {\n discard;\n }\n let k : i32 = global - uniforms.uOffset;\n let src : vec2<i32> = vec2<i32>(k - (k / uniforms.uSrcWidth) * uniforms.uSrcWidth, k / uniforms.uSrcWidth);\n\n let mL : vec3<f32> = textureLoad(sogMeansLTex, src, 0).xyz;\n let mU : vec3<f32> = textureLoad(sogMeansUTex, src, 0).xyz;\n let sRaw : vec3<f32> = textureLoad(sogScalesTex, src, 0).xyz;\n let qRaw : vec4<f32> = textureLoad(sogQuatsTex, src, 0);\n let c0 : vec4<f32> = textureLoad(sogSh0Tex, src, 0);\n\n let q16 : vec3<f32> = (mU * 256.0 + mL) * (255.0 / 65535.0);\n let nPos : vec3<f32> = mix(uniforms.sogMeansMin, uniforms.sogMeansMax, q16);\n let center : vec3<f32> = sign(nPos) * (exp(abs(nPos)) - vec3<f32>(1.0));\n\n var splatScale : vec3<f32>;\n if (uniforms.uVersion == 2) {\n let sIdx : vec3<f32> = floor(sRaw * 255.0 + 0.5);\n splatScale.x = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.x), 0), 0).r);\n splatScale.y = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.y), 0), 0).r);\n splatScale.z = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.z), 0), 0).r);\n } else {\n splatScale = exp(mix(uniforms.sogScalesMin, uniforms.sogScalesMax, sRaw));\n }\n\n let invSqrt2 : f32 = 0.70710678118;\n let qabc : vec3<f32> = (qRaw.xyz - vec3<f32>(0.5)) * 2.0 * invSqrt2;\n let qMode : i32 = i32(qRaw.w * 255.0 + 0.5) - 252;\n let qd : f32 = sqrt(max(0.0, 1.0 - dot(qabc, qabc)));\n var quat : vec4<f32>;\n if (qMode == 0) {\n quat = vec4<f32>(qd, qabc.x, qabc.y, qabc.z);\n } else if (qMode == 1) {\n quat = vec4<f32>(qabc.x, qd, qabc.y, qabc.z);\n } else if (qMode == 2) {\n quat = vec4<f32>(qabc.x, qabc.y, qd, qabc.z);\n } else {\n quat = vec4<f32>(qabc.x, qabc.y, qabc.z, qd);\n }\n\n let qw : f32 = quat.x;\n let qx : f32 = quat.y;\n let qy : f32 = quat.z;\n let qz : f32 = quat.w;\n let R : mat3x3<f32> = mat3x3<f32>(\n 1.0 - 2.0 * (qy * qy + qz * qz), 2.0 * (qx * qy + qw * qz), 2.0 * (qx * qz - qw * qy),\n 2.0 * (qx * qy - qw * qz), 1.0 - 2.0 * (qx * qx + qz * qz), 2.0 * (qy * qz + qw * qx),\n 2.0 * (qx * qz + qw * qy), 2.0 * (qy * qz - qw * qx), 1.0 - 2.0 * (qx * qx + qy * qy)\n );\n let S2 : mat3x3<f32> = mat3x3<f32>(\n 4.0 * splatScale.x * splatScale.x, 0.0, 0.0,\n 0.0, 4.0 * splatScale.y * splatScale.y, 0.0,\n 0.0, 0.0, 4.0 * splatScale.z * splatScale.z\n );\n let Sigma : mat3x3<f32> = R * S2 * transpose(R);\n\n let SH_C0 : f32 = 0.28209479177387814;\n var colRgb : vec3<f32>;\n var colA : f32;\n if (uniforms.uVersion == 2) {\n var c3 : vec3<f32>;\n c3.x = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.x * 255.0 + 0.5), 0), 0).r;\n c3.y = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.y * 255.0 + 0.5), 0), 0).r;\n c3.z = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.z * 255.0 + 0.5), 0), 0).r;\n colRgb = vec3<f32>(0.5) + c3 * SH_C0;\n colA = c0.w;\n } else {\n let cLerp : vec4<f32> = mix(uniforms.sogSh0Min, uniforms.sogSh0Max, c0);\n colRgb = vec3<f32>(0.5) + cLerp.xyz * SH_C0;\n colA = 1.0 / (1.0 + exp(-cLerp.w));\n }\n\n fragmentOutputs.fragData0 = vec4<f32>(center, 1.0);\n fragmentOutputs.fragData1 = vec4<f32>(Sigma[0][0], Sigma[0][1], Sigma[0][2], Sigma[1][1]);\n fragmentOutputs.fragData2 = vec4<f32>(Sigma[1][2], Sigma[2][2], 0.0, 0.0);\n fragmentOutputs.fragData3 = vec4<f32>(colRgb, colA);\n}\n";