从场景中删除一个组 [英] Remove a group from scene

查看:29
本文介绍了从场景中删除一个组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Three.js,我创建了一组网格并在另一个组中

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]):

如何从场景中删除 fgroup?

How can I remove a fgroup from the scene?

如果我使用:

scene.remove(fgrupo[0]);

scene.remove(pgrupo[0]);

什么都没发生.如何从场景中删除这些东西?

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

推荐答案

不要使用数组,而是使用 THREE.Object3D 和 .add() 和 .remove() 方法.

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

所以

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

scene.add (pgrupo);

还有方法 .children 为您提供了一个包含对象子代的数组.

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

这篇关于从场景中删除一个组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆