0
我想将几个几何体合并在一起,然后应用纹理使其看起来像一块真正的木头。合并网格几何体上的木材纹理
可能吗?在这里我得到了结果:
这里是我的尝试:
var texture = new THREE.TextureLoader().load('Escaliers 3D/1-3-2-5-Bois.jpg');
var mesh = [], no = 0;
var meshes = [];
var geometry = new THREE.CubeGeometry(2, 10, 1);
mesh[no] = new THREE.Mesh(geometry);
meshes.push(mesh[no]);
no++;
geometry = new THREE.CylinderGeometry(0.5, 0.5, 10, 32);
mesh[no] = new THREE.Mesh(geometry);
mesh[no].position.set(1, 0, 0);
mesh[no].rotation.x = 0;
mesh[no].rotation.y = Math.PI/2;
mesh[no].rotation.z = 0;
meshes.push(mesh[no]);
no++;
geometry = new THREE.CubeGeometry(5, 10, 1);
mesh[no] = new THREE.Mesh(geometry);
mesh[no].position.set(-3.5, 0, 0);
meshes.push(mesh[no]);
no++;
geometry = mergeMeshes(meshes);
var material = new THREE.MeshBasicMaterial({ map: texture });
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
function mergeMeshes (meshes) {
var combined = new THREE.Geometry();
for (var i = 0; i < meshes.length; i++) {
meshes[i].updateMatrix();
combined.merge(meshes[i].geometry, meshes[i].matrix);
}
return combined;
}
谢谢。
如果我理解正确,图像代表你从上面的代码得到的结果,对吧? – Marcs
是的,但它需要像一个真正的木楼梯一样更统一。 –
_unify像一个真正的木楼梯._你是什么意思?你想在一个对象中的所有网格物体? – Marcs