Remove a group from scene

爱⌒轻易说出口 提交于 2019-12-11 10:49:43

问题


I´m using Three.js, and I created a group of meshes and inside another group

pgrupo= new Array ();
fgrupo=new Array ();

scene.add(pgrupo[0])

pgrupo[0].add(fgrupo[0]):
pgrupo[0].add(fgrupo[1]):

How can I remove a fgroup from the scene?

if I use:

scene.remove(fgrupo[0]);

or

scene.remove(pgrupo[0]);

Nothing happened. How can I delete this things from the scene?


回答1:


Instead of using an Array use the THREE.Object3D and the .add() and .remove() methods.

So

pgrupo = new THREE.Object3D();
fgrupo = = new THREE.Object3D();

scene.add (pgrupo);

Also the method .children gives you an Array with object's children.



来源:https://stackoverflow.com/questions/26303578/remove-a-group-from-scene

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!