-
Notifications
You must be signed in to change notification settings - Fork 124
Description
Summary
When building an application that switches between multiple SplatMesh objects in the same scene/renderer, there's a brief visual flash where the previous mesh is visible before the new mesh appears. This happens even when following best practices of hiding meshes, clearing the renderer, and forcing renders.
Use Case
I'm building a application where users can switch between different Gaussian splat worlds by clicking through a story. The app pre-loads multiple .spz files as SplatMesh objects and swaps their visibility to transition between worlds.
Current Implementation
// Hide all meshes
splatMeshes.forEach((mesh) => {
mesh.visible = false;
});
// Clear and render empty scene
renderer.clear();
renderer.render(scene, camera);
// Show new mesh
newMesh.visible = true;
// Clear and render new scene
renderer.clear();
renderer.render(scene, camera);
renderer.render(scene, camera);
// Show container
container.classList.add('active');Expected Behavior
When swapping between pre-loaded SplatMesh objects, the transition should be seamless without showing the previous mesh.
Actual Behavior
There's a brief flash (< 100ms) where the previous mesh is visible before the new mesh appears, especially when returning to a previously displayed mesh.
Environment
- Spark.js version: v0.1.10
- Three.js version: v0.170.0
- Browser: Chrome/Safari (tested on both)
- Platform: macOS
Reproduction Steps
- Create a scene with a renderer and camera
- Load multiple
SplatMeshobjects (e.g., 2-3 different.spzfiles) - Add one mesh to the scene, make it visible
- Implement a function to swap meshes:
- Hide all meshes
- Show a different mesh
- Render the scene
- Call the swap function multiple times between different meshes
- Observe the brief flash of the previous mesh during transitions
Feature Request
It would be helpful to have one or more of the following:
- Built-in mesh swapping API: A method like
SparkRenderer.swapMesh(oldMesh, newMesh)that handles the transition cleanly - Explicit buffer clearing: A
SparkRenderer.clearBuffer()orSplatMesh.clear()method to ensure the canvas is fully cleared - Documentation: Best practices guide for applications that need to switch between multiple splats dynamically
- Transition callbacks: Events or promises that fire when a mesh is fully rendered and ready to display
Workarounds Tried
- Pausing the animation loop during transitions
- Multiple calls to
renderer.clear()andrenderer.render() - Using
requestAnimationFrameto wait for render completion - Hiding the container until after forced renders
- Setting
mesh.visible = falsebefore showing new mesh
All of these reduce the flash but don't eliminate it completely.
Additional Context
This is likely a timing issue with WebGL/Three.js rendering where the canvas retains the last frame until a new one is drawn. However, official guidance or built-in support from Spark.js would be valuable for developers building multi-splat applications.
Would appreciate any guidance or suggestions for eliminating this visual artifact!