ThreeJS: Remove object from scene

前端 未结 8 1968
后悔当初
后悔当初 2021-01-30 06:45

I\'m using ThreeJS to develop a web application that displays a list of entities, each with corresponding \"View\" and \"Hide\" button; e.g. entityName View Hide

8条回答
  •  生来不讨喜
    2021-01-30 07:22

    I started to save this as a function, and call it as needed for whatever reactions require it:

    function Remove(){
        while(scene.children.length > 0){ 
        scene.remove(scene.children[0]); 
    }
    }
    

    Now you can call the Remove(); function where appropriate.

提交回复
热议问题