Closed v2img closed 2 months ago
So my question is, i wonder why is the event handlers not cleaned up properly, and how do i properly dispose it?
Im wondering when your dispose function promises catches an error, does the keyboard listener still get removed?
After investigation, it seems like it is orbital controls fault that the event listeners are not being cleaned up. Any suggestions on how to clean it up?
Ok i found the fix. in your viewer's dispose,
add in
this.orthographicControls.dispose(); this.perspectiveControls.dispose();
Ah, good catch! I'll add this fix to the next release.
I pushed an update to the memory-optimizations branch, could you see if that fixes it for you?
ok! I dont see any other push, other than the ReadMe change, can i know which commit is it?
So apparently I lied earlier 😄 The change should be in there now.
HAHA xD Yes it works! Thanks :D Looking forward to next release
Great! The next release should hopefully go out in the next couple of days.
Thanks for your amazing talent and contribution ser
A little context: my application renders 3d splat model inside a div in a component. When i navigate away from the div and unmounts the component, i do a viewer.dispose but it always fails due to that error.
My canvas is not the child of the document.
Also, this stemmed from another issue. The event listeners WASD, was not cleaned up properly and after i load the gaussian 3D model from the .ply file using a normal Viewer (not drop in), my WASD are disabled through my application permenantly until a refresh of the tab.
This is my code to initialise the viewer:
viewer = new GaussianSplats3D.Viewer({ cameraUp: [0, 1, 0], initialCameraPosition: [0, 0, 7], initialCameraLookAt: [0, 0, 0], rootElement: containerRef.current, sharedMemoryForWorkers: false, dynamicScene: true, });
this is how i dispose it:
viewer .dispose() .then(() => { console.log('viewer disposed'); }) .catch((err: any) => { console.log("Didn't successfully dispose viewer", err); });