我想在网格上使用多种材质和多种纹理。我使用3种材料和geometry.faceVertexUvs
两种Uv阵列。第一个纹理的一个UV阵列和第二个纹理的一个UV阵列。然而,这并不是很有效。 Three.js总是使用第一个数组的uvs,从不使用geometry.faceVertexUvs[1]
。我是否必须将geometry.faceVertexUvs[0]
中的所有紫外线都放在两个纹理中,还是以不同的方式工作?如果我必须将所有uv放入geometry.faceVertexUvs[0]
,那么我想知道为什么geometry.faceVertexUvs
是一个数组。解释会很棒。那里的Three.js文档不是很详细。
这里是我的示例代码和坦克家伙!汤姆
var geometry = new THREE.BoxGeometry(60, 60, 60);
var texture1 = new THREE.TextureLoader().load( "../sons.png" );
var texture2 = new THREE.TextureLoader().load( "../Richard-branson.jpg" );
var material0 = new THREE.MeshBasicMaterial( {color:0xffff00});
var material1 = new THREE.MeshPhongMaterial({map:texture1, shininess:100});
var material2 = new THREE.MeshPhongMaterial({map:texture2, shininess:100});
for(var i=0; i< geometry.faces.length;i++){
geometry.faces[i].materialIndex = i%3;
geometry.faceVertexUvs[0][i][0] = new THREE.Vector2(0,0);
geometry.faceVertexUvs[0][i][1] = new THREE.Vector2(1,0);
geometry.faceVertexUvs[0][i][2] = new THREE.Vector2(0,1);
geometry.faceVertexUvs[1]= [];
geometry.faceVertexUvs[1][i] = [];
geometry.faceVertexUvs[1][i][0] = new THREE.Vector2(1,1);
geometry.faceVertexUvs[1][i][1] = new THREE.Vector2(1,0);
geometry.faceVertexUvs[1][i][2] = new THREE.Vector2(0,1);
}
var mesh = new THREE.Mesh(geometry, [material0, material1, material2]);
view.scene.add(mesh);
view.render();