Sunday, June 2, 2024
30
rated 0 times [  32] [ 2]  / answers: 1 / hits: 21138  / 11 Years ago, thu, january 30, 2014, 12:00:00

I created a Threejs Scene, adding camera, lights and various objects.



The question is simple: how can I destroy scene? Removing from scene all components?



I need to destroy scene because and I do not want to delegate the task to the garbage collector.


More From » garbage-collection

 Answers
11

I used this:



    cancelAnimationFrame(this.id);// Stop the animation
this.renderer.domElement.addEventListener('dblclick', null, false); //remove listener to render
this.scene = null;
this.projector = null;
this.camera = null;
this.controls = null;
empty(this.modelContainer);


The method empty is a substitute to jQuery empty, you can use it:



function empty(elem) {
while (elem.lastChild) elem.removeChild(elem.lastChild);
}

[#72843] Wednesday, January 29, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
minab

Total Points: 701
Total Questions: 104
Total Answers: 91

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;