ThreeJS: Remove object from scene

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

    THIS WORKS GREAT - I tested it so, please SET NAME for every object

    give the name to the object upon creation

        mesh.name = 'nameMeshObject';
    

    and use this if you have to delete an object

        delete3DOBJ('nameMeshObject');
    
    
    
        function delete3DOBJ(objName){
            var selectedObject = scene.getObjectByName(objName);
            scene.remove( selectedObject );
            animate();
        }
    

    open a new scene , add object

    delete an object and create new

提交回复
热议问题