提交 34c0ff3c 编写于 作者: W WestLangley

Support 2nd set of UVs in fromGeometry()

上级 1f1d418e
......@@ -190,7 +190,10 @@ THREE.BufferGeometry.prototype = {
var faces = geometry.faces;
var faceVertexUvs = geometry.faceVertexUvs;
var vertexColors = settings.vertexColors;
var hasFaceVertexUv = faceVertexUvs[ 0 ].length > 0;
var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
var hasFaceVertexNormals = faces[ 0 ].vertexNormals.length == 3;
var positions = new Float32Array( faces.length * 3 * 3 );
......@@ -213,6 +216,13 @@ THREE.BufferGeometry.prototype = {
}
if ( hasFaceVertexUv2 === true ) {
var uvs2 = new Float32Array( faces.length * 3 * 2 );
this.addAttribute( 'uv2', new THREE.BufferAttribute( uvs, 2 ) );
}
for ( var i = 0, i2 = 0, i3 = 0; i < faces.length; i ++, i2 += 6, i3 += 9 ) {
var face = faces[ i ];
......@@ -322,6 +332,23 @@ THREE.BufferGeometry.prototype = {
}
if ( hasFaceVertexUv2 === true ) {
var uva = faceVertexUvs[ 1 ][ i ][ 0 ];
var uvb = faceVertexUvs[ 1 ][ i ][ 1 ];
var uvc = faceVertexUvs[ 1 ][ i ][ 2 ];
uvs2[ i2 ] = uva.x;
uvs2[ i2 + 1 ] = uva.y;
uvs2[ i2 + 2 ] = uvb.x;
uvs2[ i2 + 3 ] = uvb.y;
uvs2[ i2 + 4 ] = uvc.x;
uvs2[ i2 + 5 ] = uvc.y;
}
}
this.computeBoundingSphere();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册