ThreeJS: Remove object from scene

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

    When you use : scene.remove(object); The object is removed from the scene, but the collision with it is still enabled !

    To remove also the collsion with the object, you can use that (for an array) : objectsArray.splice(i, 1);

    Example :

    for (var i = 0; i < objectsArray.length; i++) {
    //::: each object ::://
    var object = objectsArray[i]; 
    //::: remove all objects from the scene ::://
    scene.remove(object); 
    //::: remove all objects from the array ::://
    objectsArray.splice(i, 1); 
    

    }

提交回复
热议问题