如何使幾何體中的合併網格在一次安寧而不是3次紋理化?在我的示例代碼中,紋理是在每個分離的幾何體上完成的(請參閱圖像,點1和2)。兩個立方體和一個圓筒。使用合併網格上的均勻紋理
代碼:
scene = new THREE.Scene();
var texture = new THREE.TextureLoader().load('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;
}
是的,這是做的工作。另外,我們可以將圖像/紋理旋轉90度嗎? –
簡單地翻轉U和V座標。這會產生旋轉90度的效果。 – griffin2000
再次罰款。但是現在我遇到了紫外線不能正確使用側邊紋理和最差的問題,即圓柱體的問題。我發現這種技術使用曲面法線,但它不起作用。 (http://stackoverflow.com/questions/20774648/three-js-generate-uv-coordinate) –