diff --git a/src/extras/geometries/CylinderGeometry.js b/src/extras/geometries/CylinderGeometry.js index 9fda0b4d193586ea824aa6dabf2eaddab317563c..054b73cfec68ab9a3b9ca0ed167ad6c3a73eb0ec 100644 --- a/src/extras/geometries/CylinderGeometry.js +++ b/src/extras/geometries/CylinderGeometry.js @@ -130,7 +130,7 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme var uv2 = uvs[ 0 ][ x + 1 ].clone(); var uv3 = new THREE.Vector2( uv2.x, 0 ); - this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) ); + this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ], undefined, 1 ) ); this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] ); } @@ -157,7 +157,7 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme var uv2 = uvs[ heightSegments ][ x ].clone(); var uv3 = new THREE.Vector2( uv2.x, 1 ); - this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) ); + this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ], undefined, 2 ) ); this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] ); } diff --git a/src/extras/geometries/PolyhedronGeometry.js b/src/extras/geometries/PolyhedronGeometry.js index c2d6ba07aaa8dd85caa7badd09515fb51f97392f..b7dff9890b898b7f277b687a472f22945ccccaaa 100644 --- a/src/extras/geometries/PolyhedronGeometry.js +++ b/src/extras/geometries/PolyhedronGeometry.js @@ -38,7 +38,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { var v2 = p[ indices[ i + 1 ] ]; var v3 = p[ indices[ i + 2 ] ]; - faces[ j ] = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] ); + faces[ j ] = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ], undefined, j ); } @@ -115,9 +115,9 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { // Approximate a curved face with recursively sub-divided triangles. - function make( v1, v2, v3 ) { + function make( v1, v2, v3, materialIndex ) { - var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] ); + var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ], undefined, materialIndex ); that.faces.push( face ); centroid.copy( v1 ).add( v2 ).add( v3 ).divideScalar( 3 ); @@ -143,6 +143,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { var c = prepare( that.vertices[ face.c ] ); var v = []; + var materialIndex = face.materialIndex; + // Construct all of the vertices for this subdivision. for ( var i = 0 ; i <= cols; i ++ ) { @@ -182,7 +184,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { make( v[ i ][ k + 1 ], v[ i + 1 ][ k ], - v[ i ][ k ] + v[ i ][ k ], + materialIndex ); } else { @@ -190,7 +193,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) { make( v[ i ][ k + 1 ], v[ i + 1 ][ k + 1 ], - v[ i + 1 ][ k ] + v[ i + 1 ][ k ], + materialIndex ); }