提交 7360ed9c 编写于 作者: D Daniel Hritzkiv

Simplify faces creation with for loop

上级 b14b902a
......@@ -15,6 +15,8 @@ THREE.OBJExporter.prototype = {
var indexVertex = 0;
var indexVertexUvs = 0;
var indexNormals = 0;
var faceVertexKeys = ["a", "b", "c"];
var parseMesh = function ( mesh ) {
......@@ -112,18 +114,19 @@ THREE.OBJExporter.prototype = {
}
}
// faces
for ( var i = 0, j = 1, l = faces.length; i < l; i ++, j += 3 ) {
var face = faces[ i ];
output += 'f ';
output += ( indexVertex + face.a + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 0 + 1 ) : '' ) + '/' + ( indexNormals + j + 0 + 1 ) + ' ';
output += ( indexVertex + face.b + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 1 + 1 ) : '' ) + '/' + ( indexNormals + j + 1 + 1 ) + ' ';
output += ( indexVertex + face.c + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + 2 + 1 ) : '' ) + '/' + ( indexNormals + j + 2 + 1 ) + '\n';
for ( var m = 0; m < 3; m ++ ) {
output += ( indexVertex + face[ faceVertexKeys[ m ] ] + 1 ) + '/' + ( hasVertexUvs ? ( indexVertexUvs + j + m + 1 ) : '' ) + '/' + ( indexNormals + j + m + 1 );
output += m === 2 ? "\n" : " ";
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册