问题:
如何将N个THREE.BoxGeometry对象合并为一个THREE.BufferedGeometry?
现在我有这样的事情:
var buffer = new THREE.BufferGeometry();
for (var i = 0; i < meshList.length; ++i) {
var item = meshList[i];
var geometry = <THREE.BoxGeometry>item.geometry;
buffer.fromGeometry(geometry);
}
buffer.computeBoundingSphere();
var buffer_material = new THREE.MeshPhongMaterial({
color: 0x999999,
specular: 0x333333,
shininess: 50,
side: THREE.DoubleSide,
vertexColors: THREE.VertexColors,
shading: THREE.SmoothShading
});
var buffer_mesh = new THREE.Mesh(buffer, buffer_material);
this.Scene.add(buffer_mesh);
不幸的是,这并不完全奏效。我只看到一个盒子(而不是很多盒子)。我需要指定“位置”吗?如果是这样,我该怎么做?
谢谢!
答案 0 :(得分:1)
您可以合并THREE.Geometry
,然后使用如下模式将结果转换为THREE.BufferGeometry
:
var geometry = new THREE.Geometry();
for ( var count = 0; count < 10; count ++ ) {
var geo = new THREE.BoxGeometry( 5, 5, 5 );
geo.translate( THREE.Math.randFloat( - 5, 5 ), THREE.Math.randFloat( - 5, 5 ), THREE.Math.randFloat( - 5, 5 ) );
geometry.merge( geo );
}
geometry = new THREE.BufferGeometry().fromGeometry( geometry );
three.js r.75