Skip to content

GaussianSplattingMesh: serialization support#18032

Open
kzhsw wants to merge 35 commits intoBabylonJS:masterfrom
kzhsw:patch-1
Open

GaussianSplattingMesh: serialization support#18032
kzhsw wants to merge 35 commits intoBabylonJS:masterfrom
kzhsw:patch-1

Conversation

@kzhsw
Copy link
Copy Markdown
Contributor

@kzhsw kzhsw commented Mar 5, 2026

This PR adds support of serialization to GaussianSplattingMesh and GaussianSplattingPartProxyMesh. Instead of a dummy mesh, GaussianSplattingMesh and GaussianSplattingPartProxyMesh can be serialized to .babylon format, and parsed from it, so link the issue #16671.

Some notes for reviewers:

  • keepInRam must be true to serialize splat data
  • Parts and GaussianSplattingPartProxyMesh are supported, but a dummy proxiedMesh with only getBoundingInfo() is created for each GaussianSplattingPartProxyMesh so constructor does not break.
  • partIndices is compressed with Run-Length Encoding (RLE) during serialization, and recovered on Parse
  • flipY from IUpdateOptions is stored to the instance on _updateData to keep parsing correct
  • Mesh.Parse and BabylonFileLoader is updated without importing the classes to make it work with .babylon files
  • Geometry and Material are not imported for GaussianSplattingMesh and GaussianSplattingPartProxyMesh, where GaussianSplattingMesh would create them at runtime, and GaussianSplattingPartProxyMesh would not need it.

Forum post for discussion: https://forum.babylonjs.com/t/gaussiansplattingmesh-serializer/62659

kzhsw added 15 commits March 5, 2026 09:37
GaussianSplattingPartProxyMesh would be serialized with the GaussianSplattingMesh holding it in later commits
Updated the proxiedMesh property to accept an IBoundingInfoProvider interface for better flexibility in handling bounding info and allows deserialization.
Feel free to rename, move or export this interface if needed.
CompressPartIndices and ParsePartIndices can compress partIndices to a very small array using Run-Length Encoding (RLE).
Feel free to move, rename, or export these functions if needed.
It saves the flipY option from last call to _updateData, for future use in serialization.
Added serialization method to GaussianSplattingPartProxyMesh.
Added parsing functionality for serialized GaussianSplattingPartProxyMesh.
Should note that it works only after GaussianSplattingMesh and GaussianSplattingPartProxyMesh being imported, where the side effect would update these holder functions on importing.
Also note that Geometry should not be imported for GaussianSplattingMesh and GaussianSplattingPartProxyMesh, where Geometry of GaussianSplattingMesh is created at runtime, and GaussianSplattingPartProxyMesh does not have a Geometry.
This allows Mesh.Parse work with serialized GaussianSplattingPartProxyMesh after imported
This allows Mesh.Parse work with serialized GaussianSplattingMesh after imported
It's created at runtime, no need to serialize.
These materials are created at runtime, no need to serialize.
@sebavan
Copy link
Copy Markdown
Member

sebavan commented Mar 5, 2026

LGTM but lets have @Popov72 check it as well

@sebavan
Copy link
Copy Markdown
Member

sebavan commented Mar 5, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Mar 5, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Mar 5, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Mar 5, 2026

Reviewer - this PR has made changes to the build configuration file.

This build will release a new package on npm

If that was unintentional please make sure to revert those changes or close this PR.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds .babylon serialization/parsing support for GaussianSplattingMesh (including compound parts via GaussianSplattingPartProxyMesh), so gaussian splat scenes can round-trip through the Babylon scene serializer/loader pipeline.

Changes:

  • Extend Mesh.Parse dispatch to support GaussianSplattingMesh and GaussianSplattingPartProxyMesh types and skip geometry import for them.
  • Implement serialize() / Parse() for gaussian splat meshes, including base64-encoded splat buffers and RLE-compressed partIndices, and embedding part proxies inside the owning mesh serialization.
  • Update scene serialization and asset-container loading to avoid double-serializing part proxies and to ensure proxies are included in AssetContainer.meshes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/dev/core/src/Misc/sceneSerializer.ts Skips top-level serialization of GaussianSplattingPartProxyMesh meshes.
packages/dev/core/src/Meshes/mesh.ts Adds parser hooks for gaussian splat mesh types and bypasses geometry import for them.
packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.ts Adds custom serialization/parse for part proxy meshes and registers the parser hook.
packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts Adds splat mesh serialization/parse (buffers + RLE part indices) and registers the parser hook; marks internal meshes/materials as non-serializable.
packages/dev/core/src/Materials/GaussianSplatting/gaussianSplattingMaterial.ts Marks internally created shader materials as doNotSerialize.
packages/dev/core/src/Loading/Plugins/babylonFileLoader.ts Ensures part proxy meshes created during gaussian splat parsing are added to AssetContainer.meshes.
Comments suppressed due to low confidence (1)

packages/dev/core/src/Misc/sceneSerializer.ts:334

  • This change makes scene serialization skip GaussianSplattingPartProxyMesh entries in scene.meshes. There are existing unit tests for SceneSerializer (see packages/dev/core/test/unit/Scene/babylon.sceneSerializer.test.ts); please add a focused test to ensure proxy meshes are not emitted at top level (and that they are instead serialized via the owning GaussianSplattingMesh), so regressions don’t reintroduce duplicate/invalid meshes in .babylon output.
            // GaussianSplattingPartProxyMesh would be serialized with the GaussianSplattingMesh holding it
            if (abstractMesh instanceof Mesh && abstractMesh.getClassName() !== "GaussianSplattingPartProxyMesh") {
                const mesh = abstractMesh;
                if (!mesh.doNotSerialize) {
                    if (mesh.delayLoadState === Constants.DELAYLOADSTATE_LOADED || mesh.delayLoadState === Constants.DELAYLOADSTATE_NONE) {
                        serializationObject.meshes.push(SerializeMesh(mesh, serializationObject));
                    }

You can also share your feedback on Copilot code review. Take the survey.

kzhsw added 5 commits March 6, 2026 08:24
`GaussianSplattingMesh.serialize()` can produce a serialized mesh without `splatsData` when `_keepInRam` is false (or when data was never kept), but `GaussianSplattingMesh.Parse()` always calls `mesh.updateData(splatsData, ...)` and will crash if `parsedMesh.splatsData` is missing/undefined.
This commit checks for existance of splatsData in parsedMesh.
Reference: <BabylonJS#18032 (comment)>
kzhsw added 2 commits April 3, 2026 13:32
The creation of the material is forced in constructor and cameraMesh is created at runtime
This test reuses referenceImage from "Gaussian Splatting Part Test", ensuring the GaussianSplattingMesh after serialize and Parse renders to the same result as directly loaded.
Requested here: <BabylonJS#18032 (comment)>
@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 3, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 3, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 3, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 3, 2026

@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 7, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 7, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 7, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 7, 2026

@sebavan
Copy link
Copy Markdown
Member

sebavan commented Apr 7, 2026

Looking great, @CedricGuillemet I ll let you do the final review and merge

@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 9, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 9, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 9, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 9, 2026

kzhsw added 2 commits April 10, 2026 09:28
Combine the compound GaussianSplatting serialization changes with the worker-gating merge fixes and restore backward-compatible parse defaults.

Use the base default viewUpdateThreshold when older serialized data does not provide one, keep disableDepthSort parsing explicit, and expose the threshold constant to the subclass parser.

Register parsed GaussianSplatting part proxies in both babylon file loader paths using their serialized unique ids so nodes parented to proxies reconnect correctly after scene or asset-container loading.
@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 10, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 10, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants