@babylonjs/loaders 9.12.0 → 9.13.0
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.
- package/FBX/fbxFileLoader.d.ts +194 -0
- package/FBX/fbxFileLoader.js +2440 -0
- package/FBX/fbxFileLoader.js.map +1 -0
- package/FBX/fbxFileLoader.metadata.d.ts +11 -0
- package/FBX/fbxFileLoader.metadata.js +11 -0
- package/FBX/fbxFileLoader.metadata.js.map +1 -0
- package/FBX/index.d.ts +3 -0
- package/FBX/index.js +3 -0
- package/FBX/index.js.map +1 -0
- package/FBX/interpreter/animation.d.ts +122 -0
- package/FBX/interpreter/animation.js +648 -0
- package/FBX/interpreter/animation.js.map +1 -0
- package/FBX/interpreter/blendShapes.d.ts +44 -0
- package/FBX/interpreter/blendShapes.js +192 -0
- package/FBX/interpreter/blendShapes.js.map +1 -0
- package/FBX/interpreter/connections.d.ts +95 -0
- package/FBX/interpreter/connections.js +233 -0
- package/FBX/interpreter/connections.js.map +1 -0
- package/FBX/interpreter/fbxInterpreter.d.ts +149 -0
- package/FBX/interpreter/fbxInterpreter.js +496 -0
- package/FBX/interpreter/fbxInterpreter.js.map +1 -0
- package/FBX/interpreter/geometry.d.ts +55 -0
- package/FBX/interpreter/geometry.js +573 -0
- package/FBX/interpreter/geometry.js.map +1 -0
- package/FBX/interpreter/materials.d.ts +50 -0
- package/FBX/interpreter/materials.js +144 -0
- package/FBX/interpreter/materials.js.map +1 -0
- package/FBX/interpreter/propertyTemplates.d.ts +22 -0
- package/FBX/interpreter/propertyTemplates.js +125 -0
- package/FBX/interpreter/propertyTemplates.js.map +1 -0
- package/FBX/interpreter/rig.d.ts +20 -0
- package/FBX/interpreter/rig.js +259 -0
- package/FBX/interpreter/rig.js.map +1 -0
- package/FBX/interpreter/sceneDiagnostics.d.ts +14 -0
- package/FBX/interpreter/sceneDiagnostics.js +55 -0
- package/FBX/interpreter/sceneDiagnostics.js.map +1 -0
- package/FBX/interpreter/skeleton.d.ts +93 -0
- package/FBX/interpreter/skeleton.js +515 -0
- package/FBX/interpreter/skeleton.js.map +1 -0
- package/FBX/interpreter/transform.d.ts +21 -0
- package/FBX/interpreter/transform.js +92 -0
- package/FBX/interpreter/transform.js.map +1 -0
- package/FBX/parsers/fbxAsciiParser.d.ts +5 -0
- package/FBX/parsers/fbxAsciiParser.js +330 -0
- package/FBX/parsers/fbxAsciiParser.js.map +1 -0
- package/FBX/parsers/fbxBinaryParser.d.ts +6 -0
- package/FBX/parsers/fbxBinaryParser.js +255 -0
- package/FBX/parsers/fbxBinaryParser.js.map +1 -0
- package/FBX/parsers/zlibInflate.d.ts +7 -0
- package/FBX/parsers/zlibInflate.js +350 -0
- package/FBX/parsers/zlibInflate.js.map +1 -0
- package/FBX/types/fbxTypes.d.ts +54 -0
- package/FBX/types/fbxTypes.js +66 -0
- package/FBX/types/fbxTypes.js.map +1 -0
- package/SPLAT/gaussianSplattingStream.d.ts +404 -0
- package/SPLAT/gaussianSplattingStream.js +1159 -0
- package/SPLAT/gaussianSplattingStream.js.map +1 -0
- package/SPLAT/gaussianSplattingWorkBuffer.d.ts +71 -0
- package/SPLAT/gaussianSplattingWorkBuffer.js +249 -0
- package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -0
- package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +25 -0
- package/SPLAT/gaussianSplattingWorkBufferShaders.js +255 -0
- package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -0
- package/SPLAT/index.d.ts +1 -0
- package/SPLAT/index.js +1 -0
- package/SPLAT/index.js.map +1 -1
- package/SPLAT/sog.d.ts +6 -1
- package/SPLAT/sog.js +111 -25
- package/SPLAT/sog.js.map +1 -1
- package/SPLAT/splatFileLoader.d.ts +8 -0
- package/SPLAT/splatFileLoader.js +49 -0
- package/SPLAT/splatFileLoader.js.map +1 -1
- package/dynamic.js +9 -0
- package/dynamic.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- 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,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,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;AAuG5E,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,CAAC;AACtC,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,IAAI,OAA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C,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,IAAI,OAAQ,MAAc,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBAChD,MAAM,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,IAAI,uCAAuC,CAAC,CAAC;YAC3G,CAAC;YACD,YAAY,GAAI,MAAc,CAAC,MAAM,CAAC;QAC1C,CAAC;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAA+B,CAAC;QAC5E,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import { GaussianSplattingMesh } from \"core/Meshes/GaussianSplatting/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 { Frustum } from \"core/Maths/math.frustum\";\r\nimport { Plane } from \"core/Maths/math.plane\";\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 /** True when the node's bounding box currently intersects the camera frustum. Drives the LOD bias that\r\n * pushes off-screen nodes to the coarsest level (they stay rendered, not hidden). */\r\n inFrustum?: boolean;\r\n /** Cached local-space bounding info used for the per-node frustum test (created once per leaf). */\r\n cullBounds?: BoundingInfo;\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 * When true (default), LOD nodes outside the camera frustum are biased to their coarsest LOD rather than\r\n * rendered at full detail. They stay in the sort/render set so they appear instantly (at low detail) when\r\n * the camera turns toward them, then refine. Set to `false` to render every node at its distance LOD.\r\n */\r\n frustumCulling?: boolean;\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 // Frustum LOD bias: when enabled, nodes outside the camera frustum are rendered at their coarsest LOD.\r\n private _frustumCulling = true;\r\n // Reused world-space frustum planes and view-projection scratch matrix (avoids per-frame allocation).\r\n private readonly _frustumPlanes: Plane[] = [\r\n new Plane(0, 0, 0, 0),\r\n new Plane(0, 0, 0, 0),\r\n new Plane(0, 0, 0, 0),\r\n new Plane(0, 0, 0, 0),\r\n new Plane(0, 0, 0, 0),\r\n new Plane(0, 0, 0, 0),\r\n ];\r\n private readonly _cullViewProj = new Matrix();\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 // True once GPU position readback has been validated against a CPU decode (see _probeReadbackAsync). While\r\n // false, positions are decoded on the CPU from the means images; once validated, every SOG image uses the\r\n // fast direct upload and positions are read back from the work buffer (non-blocking).\r\n private _useGpuPositionReadback = false;\r\n // Whether the engine reports GPU readback support (candidate to validate on the first decode).\r\n private _readbackCandidate = false;\r\n // Set once the one-time readback validation has run (success or failure).\r\n private _readbackProbed = false;\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.frustumCulling !== undefined) {\r\n this._frustumCulling = options.frustumCulling;\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 (default), nodes whose bounding box is outside the camera frustum are biased to the coarsest\r\n * LOD instead of being hidden. They stay in the sort/render set (their off-screen splats are clipped), so\r\n * turning the camera toward them shows low detail immediately with no invisible frames, then refines.\r\n * Changes take effect in real time.\r\n */\r\n public get frustumCulling(): boolean {\r\n return this._frustumCulling;\r\n }\r\n\r\n public set frustumCulling(value: boolean) {\r\n if (this._frustumCulling === value) {\r\n return;\r\n }\r\n this._frustumCulling = value;\r\n // Re-evaluate LODs next frame so the off-screen bias is applied/removed immediately.\r\n this._forceLodUpdate = true;\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(false).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\r\n // Frustum-based LOD bias: nodes outside the camera frustum are pushed to the coarsest allowed\r\n // level instead of being hidden. They stay in the render/sort set (their splats are off-screen\r\n // and clipped anyway), so when the camera turns to include them they are already present at low\r\n // detail with no invisible frames, then refine to the distance-optimal level.\r\n if (this._frustumCulling && node.inFrustum === false) {\r\n optimalLod = rangeMax;\r\n }\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 node.inFrustum = true;\r\n // Local-space bounds for the per-node frustum test; the mesh world matrix is applied per evaluation.\r\n node.cullBounds = new BoundingInfo(Vector3.FromArray(node.bound.min), Vector3.FromArray(node.bound.max));\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 // GPU readback is only enabled after it is validated against a CPU decode on the first file (see\r\n // _probeReadbackAsync); until then positions are decoded on the CPU so there is always a correct result.\r\n this._readbackCandidate = this._workBuffer.supportsAsyncCentersReadback;\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 * Writes a decoded splat range's positions into the shared buffer, expands the bounds, and incrementally\r\n * patches the sort worker.\r\n * @param positions stride-4 positions for the range\r\n * @param base first splat index of the range in the work buffer\r\n * @param count number of splats in the range\r\n */\r\n private _applyPositions(positions: Float32Array, base: number, count: number): void {\r\n this._splatPositions!.set(positions, base * 4);\r\n this._updateBounds(positions, count);\r\n // Incrementally patch only this range in the sort worker (avoids the full position-buffer re-copy).\r\n this._postWorkerPositionsRange(base, count);\r\n }\r\n\r\n /**\r\n * One-time validation of GPU position readback: reads a sample of the just-decoded range back from the work\r\n * buffer and compares it to the CPU-decoded positions. Enables {@link _useGpuPositionReadback} only on an\r\n * exact (within float tolerance) match, so an unsupported or incorrect readback (e.g. a backend without the\r\n * required texture usage, or an orientation mismatch) safely keeps the CPU decode path.\r\n * @param base first splat index of the validated range\r\n * @param count number of splats in the range\r\n * @param cpuPositions the CPU-decoded stride-4 positions for the range (ground truth)\r\n */\r\n private async _probeReadbackAsync(base: number, count: number, cpuPositions: Float32Array): Promise<void> {\r\n this._readbackProbed = true;\r\n if (!this._workBuffer) {\r\n return;\r\n }\r\n const sampleCount = Math.min(count, 1024);\r\n let ok = false;\r\n try {\r\n const gpu = await this._workBuffer.readCentersRangeAsync(base, sampleCount);\r\n if (this._disposed) {\r\n return;\r\n }\r\n if (gpu && gpu.length >= sampleCount * 4) {\r\n ok = true;\r\n for (let i = 0; i < sampleCount && ok; i++) {\r\n for (let j = 0; j < 3; j++) {\r\n const a = gpu[i * 4 + j];\r\n const b = cpuPositions[i * 4 + j];\r\n if (Math.abs(a - b) > 1e-2 * (1 + Math.abs(b))) {\r\n ok = false;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n } catch {\r\n ok = false;\r\n }\r\n this._useGpuPositionReadback = ok;\r\n Logger.Log(\r\n ok\r\n ? \"GaussianSplattingStream: GPU position readback validated; streamed LOD positions are read back from the GPU.\"\r\n : \"GaussianSplattingStream: GPU position readback unavailable; decoding LOD positions on the CPU.\"\r\n );\r\n }\r\n\r\n /**\r\n * Resolves the decoded positions for a splat range and applies them. Once GPU readback has been validated,\r\n * positions are read back from the work buffer (non-blocking) and `pack.positions` is empty; otherwise the\r\n * CPU-decoded `pack.positions` are used, and — on the first such decode — the GPU readback is validated\r\n * against them so subsequent decodes can use the fast path.\r\n * @param pack the parsed SOG pack (its `positions` is populated only on the CPU path)\r\n * @param base first splat index of the range in the work buffer\r\n * @param count number of splats in the range\r\n * @returns whether positions were applied\r\n */\r\n private async _applyDecodedPositionsAsync(pack: ISogTexturePack, base: number, count: number): Promise<boolean> {\r\n if (this._useGpuPositionReadback && this._workBuffer) {\r\n const positions = await this._workBuffer.readCentersRangeAsync(base, count);\r\n if (this._disposed) {\r\n return false;\r\n }\r\n if (positions && this._splatPositions) {\r\n this._applyPositions(positions, base, count);\r\n return true;\r\n }\r\n // Validated readback unexpectedly returned nothing; fall through to the (likely empty) CPU positions.\r\n }\r\n\r\n const cpu = pack.positions.length >= count * 4 ? (pack.positions.subarray(0, count * 4) as Float32Array) : null;\r\n if (!cpu || !this._splatPositions) {\r\n return false;\r\n }\r\n this._applyPositions(cpu, base, count);\r\n // First CPU decode while readback is a candidate: validate it so later decodes can use the fast path.\r\n if (!this._readbackProbed && this._readbackCandidate) {\r\n await this._probeReadbackAsync(base, count, cpu);\r\n }\r\n return true;\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, !this._useGpuPositionReadback);\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 await this._applyDecodedPositionsAsync(pack, range.offset, range.count);\r\n if (this._disposed) {\r\n return;\r\n }\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, !this._useGpuPositionReadback);\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 await this._applyDecodedPositionsAsync(pack, base, count);\r\n if (this._disposed) {\r\n return;\r\n }\r\n this._decodedFiles.add(fileId);\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, and runs the\r\n * cheap per-node frustum test every frame so the off-screen LOD bias tracks camera rotation. The LOD\r\n * re-evaluation is throttled to at most every {@link _lodUpdateInterval} frames once the camera has\r\n * translated far enough, but also runs immediately whenever a node enters/leaves the frustum (so its\r\n * detail upgrades/downgrades promptly) or a cap change forces it. Active ranges rebuild on any LOD change.\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 // Per-node frustum test runs every frame (cheap) so the off-screen LOD bias tracks camera rotation,\r\n // not just the translation that gates the throttled LOD re-evaluation below.\r\n const frustumChanged = this._updateNodeFrustum();\r\n\r\n let runLodEval = this._forceLodUpdate || frustumChanged;\r\n if (!runLodEval && ++this._framesSinceLodUpdate >= this._lodUpdateInterval) {\r\n const camera = this._scene.activeCamera;\r\n const threshold = this._lodUpdateDistance;\r\n if (!camera || Vector3.DistanceSquared(camera.globalPosition, this._lastLodCamPos) >= threshold * threshold) {\r\n if (camera) {\r\n this._lastLodCamPos.copyFrom(camera.globalPosition);\r\n }\r\n runLodEval = true;\r\n }\r\n }\r\n\r\n if (runLodEval) {\r\n this._forceLodUpdate = false;\r\n this._framesSinceLodUpdate = 0;\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 /**\r\n * Updates each leaf node's {@link ISOGLODNode.inFrustum} flag from a per-node frustum test against the\r\n * active camera. When {@link frustumCulling} is disabled (or there is no camera) every node is marked\r\n * in-frustum. Bounds are static (from the LOD tree), so flags are valid for all nodes regardless of\r\n * decode state. Returns true when any node's in-frustum state changed (so the LOD bias must be re-applied).\r\n * @returns whether any node's in-frustum state changed\r\n */\r\n private _updateNodeFrustum(): boolean {\r\n const camera = this._scene.activeCamera;\r\n let changed = false;\r\n\r\n if (!this._frustumCulling || !camera) {\r\n for (const node of this._leafNodes) {\r\n if (node.inFrustum === false) {\r\n node.inFrustum = true;\r\n changed = true;\r\n }\r\n }\r\n return changed;\r\n }\r\n\r\n // World-space frustum planes from the current view-projection, tested against each node's world AABB.\r\n // force=false uses the renderId/sync fast-path (still recomputes when the transform actually changed),\r\n // avoiding a full world-matrix recompute every frame for the per-node frustum test.\r\n const world = this.computeWorldMatrix(false);\r\n camera.getViewMatrix().multiplyToRef(camera.getProjectionMatrix(), this._cullViewProj);\r\n Frustum.GetPlanesToRef(this._cullViewProj, this._frustumPlanes);\r\n\r\n for (const node of this._leafNodes) {\r\n node.cullBounds!.update(world);\r\n const inFrustum = node.cullBounds!.isInFrustum(this._frustumPlanes);\r\n if (inFrustum !== node.inFrustum) {\r\n node.inFrustum = inFrustum;\r\n changed = true;\r\n }\r\n }\r\n return changed;\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,71 @@
|
|
|
1
|
+
import { type Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
|
2
|
+
import { type Scene } from "@babylonjs/core/scene.js";
|
|
3
|
+
import { type Nullable } from "@babylonjs/core/types.js";
|
|
4
|
+
import { type ISogTexturePack } from "./splatDefs.js";
|
|
5
|
+
/**
|
|
6
|
+
* A unified, GPU-decoded Gaussian Splatting work buffer.
|
|
7
|
+
*
|
|
8
|
+
* Holds a square MRT texture set (centers / covA / covB / colors) sized to a fixed splat capacity
|
|
9
|
+
* (PlayCanvas-style: `ceil(sqrt(capacity))`). Each streamed SOG file is decoded directly on the GPU
|
|
10
|
+
* (no CPU readback) into its allocated pixel range. The decoded textures are consumed unchanged by the
|
|
11
|
+
* standard (non-SOG) Gaussian Splatting draw path.
|
|
12
|
+
*
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
export declare class GaussianSplattingWorkBuffer {
|
|
16
|
+
private readonly _scene;
|
|
17
|
+
private readonly _mrt;
|
|
18
|
+
private readonly _textureSize;
|
|
19
|
+
private readonly _shaderLanguage;
|
|
20
|
+
private readonly _material;
|
|
21
|
+
private readonly _quad;
|
|
22
|
+
private _disposed;
|
|
23
|
+
private _readFbo;
|
|
24
|
+
/**
|
|
25
|
+
* True when the engine supports the non-blocking GPU readback used by {@link readCentersRangeAsync}:
|
|
26
|
+
* WebGL2 (PBO + fence) or WebGPU (copyTextureToBuffer + mapAsync). When false (e.g. WebGL1), callers must
|
|
27
|
+
* decode positions on the CPU instead.
|
|
28
|
+
*/
|
|
29
|
+
get supportsAsyncCentersReadback(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Square edge length (in pixels) of the work-buffer textures.
|
|
32
|
+
*/
|
|
33
|
+
get textureSize(): number;
|
|
34
|
+
/**
|
|
35
|
+
* The decoded work-buffer textures: [centers, covA, covB, colors].
|
|
36
|
+
*/
|
|
37
|
+
get textures(): Texture[];
|
|
38
|
+
/**
|
|
39
|
+
* Creates a work buffer sized to hold `capacity` splats.
|
|
40
|
+
* @param scene hosting scene
|
|
41
|
+
* @param capacity total number of splats the work buffer must address
|
|
42
|
+
*/
|
|
43
|
+
constructor(scene: Scene, capacity: number);
|
|
44
|
+
/**
|
|
45
|
+
* Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously
|
|
46
|
+
* decoded files are preserved). Resolves once the GPU decode has been issued. The caller may
|
|
47
|
+
* dispose the source pack textures after this resolves.
|
|
48
|
+
* @param pack the SOG texture pack (GPU source textures + per-file decode parameters)
|
|
49
|
+
* @param offset first splat index (pixel offset) for this file in the work buffer
|
|
50
|
+
*/
|
|
51
|
+
decodeAsync(pack: ISogTexturePack, offset: number): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Asynchronously reads back the decoded splat centers (stride-4 xyzw, w=1) for a contiguous splat range
|
|
54
|
+
* from the work buffer's centers texture, using a non-blocking GPU readback (WebGL2 PBO + fence, or WebGPU
|
|
55
|
+
* copyTextureToBuffer + mapAsync) so it never stalls the frame the way a CPU image decode does. The centers
|
|
56
|
+
* texture already holds the GPU-decoded positions (identical to the CPU decode), so this replaces decoding
|
|
57
|
+
* positions on the CPU from the means images. Returns null when async readback is unsupported (caller should
|
|
58
|
+
* fall back to CPU decoding).
|
|
59
|
+
* @param splatOffset first splat index of the range
|
|
60
|
+
* @param splatCount number of splats in the range
|
|
61
|
+
* @returns a stride-4 Float32Array of length `splatCount * 4`, or null when unsupported/failed
|
|
62
|
+
*/
|
|
63
|
+
readCentersRangeAsync(splatOffset: number, splatCount: number): Promise<Nullable<Float32Array>>;
|
|
64
|
+
/**
|
|
65
|
+
* Disposes the work buffer and its decode resources.
|
|
66
|
+
*/
|
|
67
|
+
dispose(): void;
|
|
68
|
+
private _createQuad;
|
|
69
|
+
private _createMaterial;
|
|
70
|
+
private _applyPack;
|
|
71
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
* True when the engine supports the non-blocking GPU readback used by {@link readCentersRangeAsync}:
|
|
22
|
+
* WebGL2 (PBO + fence) or WebGPU (copyTextureToBuffer + mapAsync). When false (e.g. WebGL1), callers must
|
|
23
|
+
* decode positions on the CPU instead.
|
|
24
|
+
*/
|
|
25
|
+
get supportsAsyncCentersReadback() {
|
|
26
|
+
const engine = this._scene.getEngine();
|
|
27
|
+
if (engine.isWebGPU) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
const glEngine = engine;
|
|
31
|
+
return !!glEngine._gl && typeof glEngine._readPixelsAsync === "function" && (glEngine.webGLVersion ?? 0) >= 2;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Square edge length (in pixels) of the work-buffer textures.
|
|
35
|
+
*/
|
|
36
|
+
get textureSize() {
|
|
37
|
+
return this._textureSize;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The decoded work-buffer textures: [centers, covA, covB, colors].
|
|
41
|
+
*/
|
|
42
|
+
get textures() {
|
|
43
|
+
return this._mrt.textures;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a work buffer sized to hold `capacity` splats.
|
|
47
|
+
* @param scene hosting scene
|
|
48
|
+
* @param capacity total number of splats the work buffer must address
|
|
49
|
+
*/
|
|
50
|
+
constructor(scene, capacity) {
|
|
51
|
+
this._disposed = false;
|
|
52
|
+
// Reused WebGL framebuffer for the async centers readback (created lazily, freed in dispose).
|
|
53
|
+
this._readFbo = null;
|
|
54
|
+
this._scene = scene;
|
|
55
|
+
this._shaderLanguage = scene.getEngine().isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */;
|
|
56
|
+
this._textureSize = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, capacity))));
|
|
57
|
+
this._mrt = new MultiRenderTarget("gsWorkBuffer", { width: this._textureSize, height: this._textureSize }, 4, scene, {
|
|
58
|
+
types: [Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_FLOAT, Constants.TEXTURETYPE_UNSIGNED_BYTE],
|
|
59
|
+
samplingModes: [
|
|
60
|
+
Constants.TEXTURE_NEAREST_SAMPLINGMODE,
|
|
61
|
+
Constants.TEXTURE_NEAREST_SAMPLINGMODE,
|
|
62
|
+
Constants.TEXTURE_NEAREST_SAMPLINGMODE,
|
|
63
|
+
Constants.TEXTURE_NEAREST_SAMPLINGMODE,
|
|
64
|
+
],
|
|
65
|
+
formats: [Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA, Constants.TEXTUREFORMAT_RGBA],
|
|
66
|
+
generateDepthBuffer: false,
|
|
67
|
+
generateDepthTexture: false,
|
|
68
|
+
generateMipMaps: false,
|
|
69
|
+
}, ["gsWorkCenters", "gsWorkCovA", "gsWorkCovB", "gsWorkColors"]);
|
|
70
|
+
this._mrt.clearColor = new Color4(0, 0, 0, 0);
|
|
71
|
+
this._mrt.renderList = [];
|
|
72
|
+
// Take over clearing (no-op) so each decode accumulates into the buffer instead of wiping
|
|
73
|
+
// previously-decoded files. Undecoded regions are never sampled (only active intervals render).
|
|
74
|
+
this._mrt.onClearObservable.add(() => { });
|
|
75
|
+
// One persistent decode material + fullscreen-triangle quad, reused (with per-file uniforms)
|
|
76
|
+
// for every decode so the shader is compiled only once.
|
|
77
|
+
this._material = this._createMaterial();
|
|
78
|
+
this._quad = this._createQuad();
|
|
79
|
+
this._quad.material = this._material;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Decodes one SOG file into the work buffer at the given splat offset (accumulating; previously
|
|
83
|
+
* decoded files are preserved). Resolves once the GPU decode has been issued. The caller may
|
|
84
|
+
* dispose the source pack textures after this resolves.
|
|
85
|
+
* @param pack the SOG texture pack (GPU source textures + per-file decode parameters)
|
|
86
|
+
* @param offset first splat index (pixel offset) for this file in the work buffer
|
|
87
|
+
*/
|
|
88
|
+
async decodeAsync(pack, offset) {
|
|
89
|
+
if (this._disposed) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this._applyPack(pack, offset);
|
|
93
|
+
// Render the decode pass at the start of a frame (the safe point for custom render targets),
|
|
94
|
+
// once the shader is compiled — never re-entrantly from a promise/observable continuation.
|
|
95
|
+
await new Promise((resolve) => {
|
|
96
|
+
const attempt = () => {
|
|
97
|
+
if (this._disposed) {
|
|
98
|
+
resolve();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!this._material.isReady(this._quad)) {
|
|
102
|
+
this._scene.onBeforeRenderObservable.addOnce(attempt);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this._mrt.renderList = [this._quad];
|
|
106
|
+
this._mrt.render();
|
|
107
|
+
resolve();
|
|
108
|
+
};
|
|
109
|
+
this._scene.onBeforeRenderObservable.addOnce(attempt);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Asynchronously reads back the decoded splat centers (stride-4 xyzw, w=1) for a contiguous splat range
|
|
114
|
+
* from the work buffer's centers texture, using a non-blocking GPU readback (WebGL2 PBO + fence, or WebGPU
|
|
115
|
+
* copyTextureToBuffer + mapAsync) so it never stalls the frame the way a CPU image decode does. The centers
|
|
116
|
+
* texture already holds the GPU-decoded positions (identical to the CPU decode), so this replaces decoding
|
|
117
|
+
* positions on the CPU from the means images. Returns null when async readback is unsupported (caller should
|
|
118
|
+
* fall back to CPU decoding).
|
|
119
|
+
* @param splatOffset first splat index of the range
|
|
120
|
+
* @param splatCount number of splats in the range
|
|
121
|
+
* @returns a stride-4 Float32Array of length `splatCount * 4`, or null when unsupported/failed
|
|
122
|
+
*/
|
|
123
|
+
async readCentersRangeAsync(splatOffset, splatCount) {
|
|
124
|
+
if (this._disposed || splatCount <= 0 || !this.supportsAsyncCentersReadback) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const width = this._textureSize;
|
|
128
|
+
// The range maps to whole texel rows [rowStart, rowEnd); read that rectangle and slice the exact range.
|
|
129
|
+
// Splat i lives at texel (i % width, floor(i / width)) in both decode and draw, so the readback (which
|
|
130
|
+
// indexes the same texture storage directly, with no UV/flip) yields splat i at buffer position
|
|
131
|
+
// i - rowStart * width on every backend.
|
|
132
|
+
const rowStart = Math.floor(splatOffset / width);
|
|
133
|
+
const rowEnd = Math.ceil((splatOffset + splatCount) / width);
|
|
134
|
+
const rowCount = rowEnd - rowStart;
|
|
135
|
+
const startInBuffer = (splatOffset - rowStart * width) * 4;
|
|
136
|
+
const sliceEnd = startInBuffer + splatCount * 4;
|
|
137
|
+
const centers = this._mrt.textures[0];
|
|
138
|
+
const engine = this._scene.getEngine();
|
|
139
|
+
if (engine.isWebGPU) {
|
|
140
|
+
// WebGPU: copyTextureToBuffer of the row span + mapAsync (genuinely non-blocking). noDataConversion
|
|
141
|
+
// returns the raw RGBA32F floats tightly packed (the 256-byte row alignment is removed internally).
|
|
142
|
+
const result = await centers.readPixels(0, 0, null, true, true, 0, rowStart, width, rowCount);
|
|
143
|
+
if (this._disposed || !result) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const floats = result instanceof Float32Array ? result : new Float32Array(result.buffer, result.byteOffset, result.byteLength / 4);
|
|
147
|
+
return floats.length >= sliceEnd ? floats.subarray(startInBuffer, sliceEnd) : null;
|
|
148
|
+
}
|
|
149
|
+
// WebGL2: read directly from the centers texture via a reused FBO + async PBO readback.
|
|
150
|
+
const glEngine = engine;
|
|
151
|
+
const gl = glEngine._gl;
|
|
152
|
+
const hardware = centers.getInternalTexture()?._hardwareTexture?.underlyingResource;
|
|
153
|
+
if (!hardware) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const buffer = new Float32Array(width * rowCount * 4);
|
|
157
|
+
if (!this._readFbo) {
|
|
158
|
+
this._readFbo = gl.createFramebuffer();
|
|
159
|
+
}
|
|
160
|
+
const previousFbo = glEngine._currentFramebuffer;
|
|
161
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._readFbo);
|
|
162
|
+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, hardware, 0);
|
|
163
|
+
gl.readBuffer(gl.COLOR_ATTACHMENT0);
|
|
164
|
+
// _readPixelsAsync issues the readPixels into a PBO synchronously, then resolves once the GPU fence
|
|
165
|
+
// signals — so the framebuffer can be restored immediately while the transfer completes off-thread.
|
|
166
|
+
const promise = glEngine._readPixelsAsync(0, rowStart, width, rowCount, gl.RGBA, gl.FLOAT, buffer);
|
|
167
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, previousFbo);
|
|
168
|
+
// gl.readBuffer is global state: restore the default-framebuffer read source (BACK) so later
|
|
169
|
+
// readPixels on the default framebuffer aren't left pointing at COLOR_ATTACHMENT0. When restoring to
|
|
170
|
+
// another FBO, COLOR_ATTACHMENT0 is the correct default read buffer, so only reset for the default one.
|
|
171
|
+
if (!previousFbo) {
|
|
172
|
+
gl.readBuffer(gl.BACK);
|
|
173
|
+
}
|
|
174
|
+
if (!promise) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
await promise;
|
|
178
|
+
if (this._disposed || buffer.length < sliceEnd) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
return buffer.subarray(startInBuffer, sliceEnd);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Disposes the work buffer and its decode resources.
|
|
185
|
+
*/
|
|
186
|
+
dispose() {
|
|
187
|
+
this._disposed = true;
|
|
188
|
+
if (this._readFbo) {
|
|
189
|
+
this._scene.getEngine()._gl?.deleteFramebuffer(this._readFbo);
|
|
190
|
+
this._readFbo = null;
|
|
191
|
+
}
|
|
192
|
+
this._quad.dispose();
|
|
193
|
+
this._material.dispose(true, false);
|
|
194
|
+
this._mrt.dispose();
|
|
195
|
+
}
|
|
196
|
+
_createQuad() {
|
|
197
|
+
const quad = new Mesh("gsWorkBufferQuad", this._scene);
|
|
198
|
+
const vertexData = new VertexData();
|
|
199
|
+
// Fullscreen triangle in clip space (the vertex shader passes positions straight through).
|
|
200
|
+
vertexData.positions = [-1, -1, 0, 3, -1, 0, -1, 3, 0];
|
|
201
|
+
vertexData.indices = [0, 1, 2];
|
|
202
|
+
vertexData.applyToMesh(quad);
|
|
203
|
+
// Render only inside the work-buffer MRT, never in the main scene pass.
|
|
204
|
+
this._scene.removeMesh(quad);
|
|
205
|
+
return quad;
|
|
206
|
+
}
|
|
207
|
+
_createMaterial() {
|
|
208
|
+
const isWGSL = this._shaderLanguage === 1 /* ShaderLanguage.WGSL */;
|
|
209
|
+
const material = new ShaderMaterial("gsSogDecode", this._scene, {
|
|
210
|
+
vertexSource: isWGSL ? GaussianSplattingWorkBufferVertexShaderWGSL : GaussianSplattingWorkBufferVertexShaderGLSL,
|
|
211
|
+
fragmentSource: isWGSL ? GaussianSplattingWorkBufferFragmentShaderWGSL : GaussianSplattingWorkBufferFragmentShaderGLSL,
|
|
212
|
+
}, {
|
|
213
|
+
attributes: ["position"],
|
|
214
|
+
uniforms: ["sogMeansMin", "sogMeansMax", "sogScalesMin", "sogScalesMax", "sogSh0Min", "sogSh0Max", "uVersion", "uOffset", "uCount", "uDestWidth", "uSrcWidth"],
|
|
215
|
+
samplers: ["sogMeansLTex", "sogMeansUTex", "sogScalesTex", "sogQuatsTex", "sogSh0Tex", "sogCodebookTex"],
|
|
216
|
+
shaderLanguage: this._shaderLanguage,
|
|
217
|
+
});
|
|
218
|
+
material.backFaceCulling = false;
|
|
219
|
+
material.disableDepthWrite = true;
|
|
220
|
+
return material;
|
|
221
|
+
}
|
|
222
|
+
_applyPack(pack, offset) {
|
|
223
|
+
const material = this._material;
|
|
224
|
+
const srcWidth = pack.meansTextureL.getSize().width;
|
|
225
|
+
material.setTexture("sogMeansLTex", pack.meansTextureL);
|
|
226
|
+
material.setTexture("sogMeansUTex", pack.meansTextureU);
|
|
227
|
+
material.setTexture("sogScalesTex", pack.scalesTexture);
|
|
228
|
+
material.setTexture("sogQuatsTex", pack.quatsTexture);
|
|
229
|
+
material.setTexture("sogSh0Tex", pack.sh0Texture);
|
|
230
|
+
// Codebook only used for v2; bind a harmless placeholder otherwise so the sampler is always set.
|
|
231
|
+
material.setTexture("sogCodebookTex", pack.codebookTexture ?? pack.sh0Texture);
|
|
232
|
+
material.setVector3("sogMeansMin", new Vector3(pack.meansMin[0], pack.meansMin[1], pack.meansMin[2]));
|
|
233
|
+
material.setVector3("sogMeansMax", new Vector3(pack.meansMax[0], pack.meansMax[1], pack.meansMax[2]));
|
|
234
|
+
const sMin = pack.scalesMin ?? [0, 0, 0];
|
|
235
|
+
const sMax = pack.scalesMax ?? [0, 0, 0];
|
|
236
|
+
material.setVector3("sogScalesMin", new Vector3(sMin[0], sMin[1], sMin[2]));
|
|
237
|
+
material.setVector3("sogScalesMax", new Vector3(sMax[0], sMax[1], sMax[2]));
|
|
238
|
+
const c0Min = pack.sh0Min ?? [0, 0, 0, 0];
|
|
239
|
+
const c0Max = pack.sh0Max ?? [0, 0, 0, 0];
|
|
240
|
+
material.setVector4("sogSh0Min", new Vector4(c0Min[0], c0Min[1], c0Min[2], c0Min[3]));
|
|
241
|
+
material.setVector4("sogSh0Max", new Vector4(c0Max[0], c0Max[1], c0Max[2], c0Max[3]));
|
|
242
|
+
material.setInt("uVersion", pack.version);
|
|
243
|
+
material.setInt("uOffset", offset);
|
|
244
|
+
material.setInt("uCount", pack.splatCount);
|
|
245
|
+
material.setInt("uDestWidth", this._textureSize);
|
|
246
|
+
material.setInt("uSrcWidth", srcWidth);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
//# 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;AAK1D,OAAO,EACH,2CAA2C,EA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I,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,QAAQ,CAAC,UAAU,CAAC,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;QACtF,QAAQ,CAAC,UAAU,CAAC,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 Nullable } from \"core/types\";\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 // Reused WebGL framebuffer for the async centers readback (created lazily, freed in dispose).\r\n private _readFbo: Nullable<WebGLFramebuffer> = null;\r\n\r\n /**\r\n * True when the engine supports the non-blocking GPU readback used by {@link readCentersRangeAsync}:\r\n * WebGL2 (PBO + fence) or WebGPU (copyTextureToBuffer + mapAsync). When false (e.g. WebGL1), callers must\r\n * decode positions on the CPU instead.\r\n */\r\n public get supportsAsyncCentersReadback(): boolean {\r\n const engine = this._scene.getEngine();\r\n if (engine.isWebGPU) {\r\n return true;\r\n }\r\n const glEngine = engine as unknown as { _gl?: WebGL2RenderingContext; _readPixelsAsync?: unknown; webGLVersion?: number };\r\n return !!glEngine._gl && typeof glEngine._readPixelsAsync === \"function\" && (glEngine.webGLVersion ?? 0) >= 2;\r\n }\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 * Asynchronously reads back the decoded splat centers (stride-4 xyzw, w=1) for a contiguous splat range\r\n * from the work buffer's centers texture, using a non-blocking GPU readback (WebGL2 PBO + fence, or WebGPU\r\n * copyTextureToBuffer + mapAsync) so it never stalls the frame the way a CPU image decode does. The centers\r\n * texture already holds the GPU-decoded positions (identical to the CPU decode), so this replaces decoding\r\n * positions on the CPU from the means images. Returns null when async readback is unsupported (caller should\r\n * fall back to CPU decoding).\r\n * @param splatOffset first splat index of the range\r\n * @param splatCount number of splats in the range\r\n * @returns a stride-4 Float32Array of length `splatCount * 4`, or null when unsupported/failed\r\n */\r\n public async readCentersRangeAsync(splatOffset: number, splatCount: number): Promise<Nullable<Float32Array>> {\r\n if (this._disposed || splatCount <= 0 || !this.supportsAsyncCentersReadback) {\r\n return null;\r\n }\r\n\r\n const width = this._textureSize;\r\n // The range maps to whole texel rows [rowStart, rowEnd); read that rectangle and slice the exact range.\r\n // Splat i lives at texel (i % width, floor(i / width)) in both decode and draw, so the readback (which\r\n // indexes the same texture storage directly, with no UV/flip) yields splat i at buffer position\r\n // i - rowStart * width on every backend.\r\n const rowStart = Math.floor(splatOffset / width);\r\n const rowEnd = Math.ceil((splatOffset + splatCount) / width);\r\n const rowCount = rowEnd - rowStart;\r\n const startInBuffer = (splatOffset - rowStart * width) * 4;\r\n const sliceEnd = startInBuffer + splatCount * 4;\r\n const centers = this._mrt.textures[0];\r\n\r\n const engine = this._scene.getEngine();\r\n\r\n if (engine.isWebGPU) {\r\n // WebGPU: copyTextureToBuffer of the row span + mapAsync (genuinely non-blocking). noDataConversion\r\n // returns the raw RGBA32F floats tightly packed (the 256-byte row alignment is removed internally).\r\n const result = await centers.readPixels(0, 0, null, true, true, 0, rowStart, width, rowCount);\r\n if (this._disposed || !result) {\r\n return null;\r\n }\r\n const floats = result instanceof Float32Array ? result : new Float32Array(result.buffer, result.byteOffset, result.byteLength / 4);\r\n return floats.length >= sliceEnd ? (floats.subarray(startInBuffer, sliceEnd) as Float32Array) : null;\r\n }\r\n\r\n // WebGL2: read directly from the centers texture via a reused FBO + async PBO readback.\r\n const glEngine = engine as unknown as {\r\n _gl: WebGL2RenderingContext;\r\n _currentFramebuffer: Nullable<WebGLFramebuffer>;\r\n _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, o: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;\r\n };\r\n const gl = glEngine._gl;\r\n const hardware = centers.getInternalTexture()?._hardwareTexture?.underlyingResource as Nullable<WebGLTexture>;\r\n if (!hardware) {\r\n return null;\r\n }\r\n const buffer = new Float32Array(width * rowCount * 4);\r\n if (!this._readFbo) {\r\n this._readFbo = gl.createFramebuffer();\r\n }\r\n const previousFbo = glEngine._currentFramebuffer;\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, this._readFbo);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, hardware, 0);\r\n gl.readBuffer(gl.COLOR_ATTACHMENT0);\r\n\r\n // _readPixelsAsync issues the readPixels into a PBO synchronously, then resolves once the GPU fence\r\n // signals — so the framebuffer can be restored immediately while the transfer completes off-thread.\r\n const promise = glEngine._readPixelsAsync(0, rowStart, width, rowCount, gl.RGBA, gl.FLOAT, buffer);\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, previousFbo);\r\n // gl.readBuffer is global state: restore the default-framebuffer read source (BACK) so later\r\n // readPixels on the default framebuffer aren't left pointing at COLOR_ATTACHMENT0. When restoring to\r\n // another FBO, COLOR_ATTACHMENT0 is the correct default read buffer, so only reset for the default one.\r\n if (!previousFbo) {\r\n gl.readBuffer(gl.BACK);\r\n }\r\n if (!promise) {\r\n return null;\r\n }\r\n await promise;\r\n if (this._disposed || buffer.length < sliceEnd) {\r\n return null;\r\n }\r\n return buffer.subarray(startInBuffer, sliceEnd) as Float32Array;\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 if (this._readFbo) {\r\n (this._scene.getEngine() as unknown as { _gl?: WebGL2RenderingContext })._gl?.deleteFramebuffer(this._readFbo);\r\n this._readFbo = null;\r\n }\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"]}
|