Hello - New to three.js. I was just wondering if someone could help on the best practise for updating a scene.
-I’m importing various GLTF model assets and using these to construct a door as a ‘singleDoorGrp’.
-I then have a function that clones the door, currently based on a GUI input to a ‘totalDoorsGrp’
-The user can select between 1 and 5 doors, with the starting default being 4.
-To update the doors on screen, I’m running the following code in the animate() loop.
Is it actually necessary to dispose() or is simply removing and adding back the totalDoorsGrp okay on its own?
if (totalDoorsGrp){
scene.remove(totalDoorsGrp);
totalDoorsGrp.traverse(function (obj) {
if (obj instanceof THREE.Mesh) {
obj.geometry.dispose()
obj.material.dispose();
}
});
totalDoorsGrp = cloneDoors(doorSetup,singleDoorGrp);
scene.add(totalDoorsGrp);
}
Many thanks