|
@@ -174,10 +174,20 @@ SubdivisionModifier.prototype.modify = function ( geometry ) {
|
|
|
|
|
|
oldVertices = geometry.vertices; // { x, y, z}
|
|
oldVertices = geometry.vertices; // { x, y, z}
|
|
oldFaces = geometry.faces; // { a: oldVertex1, b: oldVertex2, c: oldVertex3 }
|
|
oldFaces = geometry.faces; // { a: oldVertex1, b: oldVertex2, c: oldVertex3 }
|
|
- oldUvs = geometry.faceVertexUvs[ 0 ];
|
|
|
|
|
|
+ oldUvs = geometry.faceVertexUvs;
|
|
|
|
|
|
var hasUvs = oldUvs !== undefined && oldUvs.length > 0;
|
|
var hasUvs = oldUvs !== undefined && oldUvs.length > 0;
|
|
|
|
|
|
|
|
+ if ( hasUvs ) {
|
|
|
|
+
|
|
|
|
+ for ( var j = 0; j < oldUvs.length; j ++ ) {
|
|
|
|
+
|
|
|
|
+ newUVs.push( [] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/******************************************************
|
|
/******************************************************
|
|
*
|
|
*
|
|
* Step 0: Preprocess Geometry to Generate edges Lookup
|
|
* Step 0: Preprocess Geometry to Generate edges Lookup
|
|
@@ -375,21 +385,25 @@ SubdivisionModifier.prototype.modify = function ( geometry ) {
|
|
|
|
|
|
if ( hasUvs ) {
|
|
if ( hasUvs ) {
|
|
|
|
|
|
- uv = oldUvs[ i ];
|
|
|
|
|
|
+ for ( var j = 0; j < oldUvs.length; j ++ ) {
|
|
|
|
+
|
|
|
|
+ uv = oldUvs[ j ][ i ];
|
|
|
|
|
|
- x0 = uv[ 0 ];
|
|
|
|
- x1 = uv[ 1 ];
|
|
|
|
- x2 = uv[ 2 ];
|
|
|
|
|
|
+ x0 = uv[ 0 ];
|
|
|
|
+ x1 = uv[ 1 ];
|
|
|
|
+ x2 = uv[ 2 ];
|
|
|
|
|
|
- x3.set( midpoint( x0.x, x1.x ), midpoint( x0.y, x1.y ) );
|
|
|
|
- x4.set( midpoint( x1.x, x2.x ), midpoint( x1.y, x2.y ) );
|
|
|
|
- x5.set( midpoint( x0.x, x2.x ), midpoint( x0.y, x2.y ) );
|
|
|
|
|
|
+ x3.set( midpoint( x0.x, x1.x ), midpoint( x0.y, x1.y ) );
|
|
|
|
+ x4.set( midpoint( x1.x, x2.x ), midpoint( x1.y, x2.y ) );
|
|
|
|
+ x5.set( midpoint( x0.x, x2.x ), midpoint( x0.y, x2.y ) );
|
|
|
|
|
|
- newUv( newUVs, x3, x4, x5 );
|
|
|
|
- newUv( newUVs, x0, x3, x5 );
|
|
|
|
|
|
+ newUv( newUVs[ j ], x3, x4, x5 );
|
|
|
|
+ newUv( newUVs[ j ], x0, x3, x5 );
|
|
|
|
|
|
- newUv( newUVs, x1, x4, x3 );
|
|
|
|
- newUv( newUVs, x2, x5, x4 );
|
|
|
|
|
|
+ newUv( newUVs[ j ], x1, x4, x3 );
|
|
|
|
+ newUv( newUVs[ j ], x2, x5, x4 );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -398,7 +412,7 @@ SubdivisionModifier.prototype.modify = function ( geometry ) {
|
|
// Overwrite old arrays
|
|
// Overwrite old arrays
|
|
geometry.vertices = newVertices;
|
|
geometry.vertices = newVertices;
|
|
geometry.faces = newFaces;
|
|
geometry.faces = newFaces;
|
|
- if ( hasUvs ) geometry.faceVertexUvs[ 0 ] = newUVs;
|
|
|
|
|
|
+ if ( hasUvs ) geometry.faceVertexUvs = newUVs;
|
|
|
|
|
|
// console.log('done');
|
|
// console.log('done');
|
|
|
|
|