ThreeJS: Remove object from scene

前端 未结 8 1985
后悔当初
后悔当初 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:14

    You can use this

    function removeEntity(object) {
        var scene = document.querySelectorAll("scene");                               //clear the objects from the scene
        for (var i = 0; i < scene.length; i++) {                                    //loop through to get all object in the scene
        var scene =document.getElementById("scene");                                  
        scene.removeChild(scene.childNodes[0]);                                        //remove all specified objects
      }   
    

提交回复
热议问题