How can I destroy THREEJS Scene?

后端 未结 1 1327
天命终不由人
天命终不由人 2020-12-16 13:55

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

相关标签:
1条回答
  • 2020-12-16 14:18

    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);
    }
    
    0 讨论(0)
提交回复
热议问题