javascript Three.js中是否有容器类型的对象来转换一组孩子?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10776495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:00:47  来源:igfitidea点击:

is there a container type object in three.js to transform a group of children?

javascriptwebglthree.js

提问by JayDee

is there a container or node object in three.js in which multiple meshes can be added as child so that they can be transformed together?

Three.js 中是否有容器或节点对象,其中可以将多个网格添加为子对象,以便它们可以一起转换?

(an invisible container that allows to perform transformations on all child objects as in a group?)

(一个不可见的容器,允许对组中的所有子对象执行转换?)

thanks

谢谢

回答by mrdoob

Example.

例子

var group = new THREE.Group();

for ( var i = 0; i < 1000; i ++ ) {

    var mesh = new THREE.Mesh( geometry, material );
    mesh.position.x = Math.random() * 2000 - 1000;
    mesh.position.y = Math.random() * 2000 - 1000;
    mesh.position.z = Math.random() * 2000 - 1000;

    mesh.rotation.x = Math.random() * 360 * ( Math.PI / 180 );
    mesh.rotation.y = Math.random() * 360 * ( Math.PI / 180 );

    group.add( mesh );

}

scene.add( group );

r69+

r69+