Open Linkersem opened 3 days ago
You can use Viewer.removeSplatScene(<scene index>)
, which returns a promise, to remove a splat scene and when that call completes you can load a different splat scene using Viewer.addSplatScene()
thx for your reply! i will try it and give a response.
Hi, @mkkellogg I tried what you said, he can delete the scene I don't need when rendering, but the whole page will turn black when deleting, is this normal? What should I do so that when I delete scene data, the entire page does not go black? For example, when I'm in scene C, I want to delete scene A, but it shouldn't affect what I'm looking at at scene C at that moment. Thx for your greate work!
And i also want to ask how to delete multiple scenes ?
Well most likely you're still rendering while the scene removal or scene addition is in process. If you post your code I can help fix it, but you need to make sure not to render until the promises returned by Viewer.removeSplatScene(<scene index>)
or Viewer.addSplatScene()
complete.
As for deleting multiple scenes, there is not a great way to do that unfortunately. The only way is to make multiple calls to removeSplatScene()
(one at a time of course).
I will try to add a removeSplatScenes()
function to the next release to remove multiple splat scenes at once.
Ohhh,thx for your reply! Regarding the black screen issue after deleting scenes, I may be able to provide some useful code snippets this week, regarding the case of deleting multiple scenes, I am calling this function multiple times now, looking forward to your update. But I have some confusion. For example, when I delete scene A, I do not delete scene C. So theoretically, scene C should still be rendering. Therefore, I do not understand your statement, "you're still rendering while the scene removal or scene addition is in process."
Well Viewer.addSplatScene()
actually works by removing all of the scenes, clearing out all of the viewer's resources, and then adding the scenes you want to keep back in. That's why you see black for a small amount of time if you keep rendering while that function is executing.
Hahaha, then what should I do to achieve the purpose I am talking about? Thank you again for your patient reply!
Well during the call to removeSplatScene()
, you need to make not to call the render()
function of whatever three.js renderer you are using.
Here's an example of how it might work, where a function removeScene()
could be called to remove a scene:
// main animation loop
let renderPause = false;
requestAnimationFrame(update);
function update() {
requestAnimationFrame(update);
if (!renderPause) {
// renderer = three.js WebGLRenderer
// threeScene is the three.js Scene instance
renderer.render(threeScene, camera);
}
}
const removeScene = () => {
renderPause = true;
viewer.removeSplatScene(0).then(() => {
renderPause = false;
});
);
Hi All, I encountered the same black screen issue. It seems that the renderPause was not able to avoid this black screen problem. My code logic is:
Thx for your pacience!
Here attached my sample.
Would you both be able to post your full source code for me to debug? @lucylucy27 The code you posted is incomplete and cannot be run.
Hello, thank you for your excellent work, I have 5 ply data (A, B, C, D, E), I load three ply at once, when my camera moves to scene C, I want to be able to load the ply of scene D and delete the data of scene A, what should I do?