2017-09-09 5 views
1

古いコードが見つかりました。ほとんど動作します。Face4をFace3に固定する方法

var geom = new THREE.Geometry(); 
geom.vertices = testRect.verts(); 

for (var i = 0; i < verts.length; i+=4) { 
    geom.faceVertexUvs[0].push([ 
     new THREE.Vector2(1.0 - ((verts[i].x - testRect.x)/testRect.width), 1.0 - ((verts[i].z - testRect.y)/testRect.height)), 
     new THREE.Vector2(1.0 - ((verts[i+1].x - testRect.x)/testRect.width), 1.0 - ((verts[i+1].z - testRect.y)/testRect.height)), 
     new THREE.Vector2(1.0 - ((verts[i+2].x - testRect.x)/testRect.width), 1.0 - ((verts[i+2].z - testRect.y)/testRect.height)), 
     new THREE.Vector2(1.0 - ((verts[i+3].x - testRect.x)/testRect.width), 1.0 - ((verts[i+3].z - testRect.y)/testRect.height)) 
    ]); 
} 
for (var i=0, vl=verts.length; i<vl; i+=4) { 

    geom.faces.push(new THREE.Face4(i, i+1, i+2, i+3)); 
} 

私は

THREE.Face4 = function (a, b, c, d, normal, color, materialIndex) { 

    return new THREE.Face3(a, b, c, normal, color, materialIndex); 

}; 

Face3Face4)それを修正する方法を見つけたが、http://dt-byte.ru/fea28697.png

はそう

for (var i=0, vl=verts.length; i<vl; i+=4) { 
    geom.faces.push(new THREE.Face4(i, i+1, i+2, i+3)); 
    geom.faces.push(new THREE.Face4(i, i+3, i+2, i+1)); 
} 

実行しようとしました十分なポリゴンが存在しないようですしかし何かが助けになりませんでした(

この問題の解決に役立つ)

答えて

2

形状が(A、B、C、D)カッドによって定義されている場合、同一の幾何学的形状は、2つの三角形(A、B、C)によって描画することができ、 (A、C、D)とする。

quad to triangles

次のように何とかコードを適応:

for (var i=0, vl=verts.length; i<vl; i+=4) { 

    geom.faces.push(new THREE.Face3(i, i+1, i+2)); 
    geom.faces.push(new THREE.Face3(i, i+2, i+3)); 
} 
関連する問題