我需要得到UV貼圖將在three.js所正確地呈現UV幫助質感。我在Blender中創建了一個重複貼圖紋理的模型。瓷磚紋理用UV貼圖應用,它看起來像這樣,如果被正確渲染它: Render image using Blender 。然而,當使用JSONLoader由three.js所加載,瓷磚只是拉伸以填充每個多邊形,給人怪異結果如下:Screenshot of render using three.js 。我試着在我的代碼設置THREE.RepeatWrapping但什麼都沒有改變:three.js所使用的重複JSONLoader
bodyLoader = new THREE.JSONLoader();
bodyLoader.load('./starofthesea_threejs.json', function(geometry, materials) {
mainBodyMaterials = new THREE.MeshFaceMaterial(materials);
console.log(materials);
mainBodyMaterials.wrapS = THREE.RepeatWrapping;
mainBodyMaterials.wrapT = THREE.RepeatWrapping;
mainBodyMaterials.needsUpdate = true;
mainBody = new THREE.Mesh(geometry, mainBodyMaterials);
mainBody.traverse (function (child) {
if (child instanceof THREE.Mesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
mainBody.scale.x = mainBody.scale.y = mainBody.scale.z = 1;
geometry.computeBoundingBox();
geometry.computeFaceNormals();
geometry.computeFlatVertexNormals();
scene.add(mainBody);
});
這有什麼錯在我的代碼,或變通方法來得到它正確呈現?所有的幫助深表謝意。
只是一個想法,你需要設置mainBodyMaterials.repeat.set(10,10);並做紋理需要是2寬度高度的權力?在材料 – Sentinel
設置重複只是拋出一個「未定義」的錯誤,和紋理的所有維度都設置爲2的冪已經 – kychung