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