Luca Davanzo Luca Davanzo - 1 year ago 443
Javascript Question

How can I destroy THREEJS Scene?

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.

Answer Source

I used this:

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

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

function empty(elem) {
    while (elem.lastChild) elem.removeChild(elem.lastChild);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download