如何在一个对象中组合两个立方体?

时间:2013-09-16 14:20:44

标签: three.js

我需要将对象组的位置作为一个项目进行管理。

我有:

tankMesh1 = new THREE.Mesh(geometry, material);
tankMesh2 = new THREE.Mesh(geometry, material);
scene.add(tankMesh1);
scene.add(tankMesh2);

tankMesh2.position = tankMesh2.position + offset * cos ( angle )

我需要:

tankMeshBig = new THREE.Mesh(tankMesh1 , tankMesh2 );

示例:http://jsfiddle.net/ksRyQ/2287/

1 个答案:

答案 0 :(得分:1)

您可以使用新的THREE.Object3D()

JS:

var group=new THREE.Object3D();

tankMesh1 = new THREE.Mesh(geometry, material);
group.add(tankMesh1);

geometry = new THREE.CubeGeometry(3, 2, 5);
tankMesh2 = new THREE.Mesh(geometry, material);
tankMesh2.position.y = 3;
group.add(tankMesh2);

group.rotation.y = 3.141/3;

scene.add(group);

http://jsfiddle.net/zYLSC/