浏览代码

Swaped edge orientation... (abc,acd to abd,bcd)

Mr.doob 12 年之前
父节点
当前提交
631d6e367a

+ 9 - 12
src/extras/geometries/CubeGeometry.js

@@ -85,29 +85,26 @@ THREE.CubeGeometry = function ( width, height, depth, widthSegments, heightSegme
 				var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
 				var d = ( ix + 1 ) + gridX1 * iy;
 
-				var face = new THREE.Face3( a + offset, b + offset, c + offset );
+				var uva = new THREE.Vector2( ix / gridX, 1 - iy / gridY );
+				var uvb = new THREE.Vector2( ix / gridX, 1 - ( iy + 1 ) / gridY );
+				var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iy + 1 ) / gridY );
+				var uvd = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iy / gridY );
+
+				var face = new THREE.Face3( a + offset, b + offset, d + offset );
 				face.normal.copy( normal );
 				face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
 				face.materialIndex = materialIndex;
 
 				scope.faces.push( face );
-				scope.faceVertexUvs[ 0 ].push( [
-					new THREE.Vector2( ix / gridX, 1 - iy / gridY ),
-					new THREE.Vector2( ix / gridX, 1 - ( iy + 1 ) / gridY ),
-					new THREE.Vector2( ( ix + 1 ) / gridX, 1- ( iy + 1 ) / gridY )
-				] );
+				scope.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 
-				face = new THREE.Face3( a + offset, c + offset, d + offset );
+				face = new THREE.Face3( b + offset, c + offset, d + offset );
 				face.normal.copy( normal );
 				face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
 				face.materialIndex = materialIndex;
 
 				scope.faces.push( face );
-				scope.faceVertexUvs[ 0 ].push( [
-					new THREE.Vector2( ix / gridX, 1 - iy / gridY ),
-					new THREE.Vector2( ( ix + 1 ) / gridX, 1- ( iy + 1 ) / gridY ),
-					new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iy / gridY )
-				] );
+				scope.faceVertexUvs[ 0 ].push( [ uvb, uvc, uvd ] );
 
 			}
 

+ 4 - 4
src/extras/geometries/CylinderGeometry.js

@@ -85,11 +85,11 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
 			var uv3 = uvs[ y + 1 ][ x + 1 ].clone();
 			var uv4 = uvs[ y ][ x + 1 ].clone();
 
-			this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
-			this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
+			this.faces.push( new THREE.Face3( v1, v2, v4, [ n1, n2, n4 ] ) );
+			this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv4 ] );
 
-			this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) );
-			this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] );
+			this.faces.push( new THREE.Face3( v2, v3, v4, [ n2, n3, n4 ] ) );
+			this.faceVertexUvs[ 0 ].push( [ uv2, uv3, uv4 ] );
 
 		}
 

+ 4 - 4
src/extras/geometries/LatheGeometry.js

@@ -61,21 +61,21 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
 			var u1 = u0 + inverseSegments;
 			var v1 = v0 + inversePointLength;
 
-			this.faces.push( new THREE.Face3( a, b, c ) );
+			this.faces.push( new THREE.Face3( a, b, d ) );
 
 			this.faceVertexUvs[ 0 ].push( [
 
 				new THREE.Vector2( u0, v0 ),
 				new THREE.Vector2( u1, v0 ),
-				new THREE.Vector2( u1, v1 )
+				new THREE.Vector2( u0, v1 )
 
 			] );
 
-			this.faces.push( new THREE.Face3( a, c, d ) );
+			this.faces.push( new THREE.Face3( b, c, d ) );
 
 			this.faceVertexUvs[ 0 ].push( [
 
-				new THREE.Vector2( u0, v0 ),
+				new THREE.Vector2( u1, v0 ),
 				new THREE.Vector2( u1, v1 ),
 				new THREE.Vector2( u0, v1 )
 

+ 8 - 8
src/extras/geometries/ParametricGeometry.js

@@ -44,19 +44,19 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) {
 
 			a = i * sliceCount + j;
 			b = i * sliceCount + j + 1;
-			c = (i + 1) * sliceCount + j;
-			d = (i + 1) * sliceCount + j + 1;
+			c = (i + 1) * sliceCount + j + 1;
+			d = (i + 1) * sliceCount + j;
 
 			uva = new THREE.Vector2( j / slices, i / stacks );
 			uvb = new THREE.Vector2( ( j + 1 ) / slices, i / stacks );
-			uvc = new THREE.Vector2( j / slices, ( i + 1 ) / stacks );
-			uvd = new THREE.Vector2( ( j + 1 ) / slices, ( i + 1 ) / stacks );
+			uvc = new THREE.Vector2( ( j + 1 ) / slices, ( i + 1 ) / stacks );
+			uvd = new THREE.Vector2( j / slices, ( i + 1 ) / stacks );
 
-			faces.push( new THREE.Face3( a, b, c ) );
-			uvs.push( [ uva, uvb, uvc ] );
+			faces.push( new THREE.Face3( a, b, d ) );
+			uvs.push( [ uva, uvb, uvd ] );
 
-			faces.push( new THREE.Face3( a, c, d ) );
-			uvs.push( [ uva, uvc, uvd ] );
+			faces.push( new THREE.Face3( b, c, d ) );
+			uvs.push( [ uvb, uvc, uvd ] );
 
 		}
 

+ 9 - 13
src/extras/geometries/PlaneGeometry.js

@@ -50,28 +50,24 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
 			var c = ( ix + 1 ) + gridX1 * ( iz + 1 );
 			var d = ( ix + 1 ) + gridX1 * iz;
 
-			var face = new THREE.Face3( a, b, c );
+			var uva = new THREE.Vector2( ix / gridX, 1 - iz / gridZ );
+			var uvb = new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ );
+			var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ );
+			var uvd = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iz / gridZ );
+
+			var face = new THREE.Face3( a, b, d );
 			face.normal.copy( normal );
 			face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
 
 			this.faces.push( face );
-			this.faceVertexUvs[ 0 ].push( [
-				new THREE.Vector2( ix / gridX, 1 - iz / gridZ ),
-				new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ ),
-				new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ )
-			] );
-
+			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 
-			face = new THREE.Face3( a, c, d );
+			face = new THREE.Face3( b, c, d );
 			face.normal.copy( normal );
 			face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
 
 			this.faces.push( face );
-			this.faceVertexUvs[ 0 ].push( [
-				new THREE.Vector2( ix / gridX, 1 - iz / gridZ ),
-				new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ ),
-				new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iz / gridZ )
-			] );
+			this.faceVertexUvs[ 0 ].push( [ uvb, uvc, uvd ] );
 
 		}
 

+ 4 - 4
src/extras/geometries/SphereGeometry.js

@@ -77,11 +77,11 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
 
 			} else {
 
-				this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
-				this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
+				this.faces.push( new THREE.Face3( v1, v2, v4, [ n1, n2, n4 ] ) );
+				this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv4 ] );
 
-				this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) );
-				this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] );
+				this.faces.push( new THREE.Face3( v2, v3, v4, [ n2, n3, n4 ] ) );
+				this.faceVertexUvs[ 0 ].push( [ uv2, uv3, uv4 ] );
 
 			}
 

+ 6 - 6
src/extras/geometries/TorusGeometry.js

@@ -51,25 +51,25 @@ THREE.TorusGeometry = function ( radius, tube, radialSegments, tubularSegments,
 			var c = ( this.tubularSegments + 1 ) * ( j - 1 ) + i;
 			var d = ( this.tubularSegments + 1 ) * j + i;
 
-			var face = new THREE.Face3( a, b, c, [ normals[ a ], normals[ b ], normals[ c ] ] );
+			var face = new THREE.Face3( a, b, d, [ normals[ a ], normals[ b ], normals[ d ] ] );
 			face.normal.add( normals[ a ] );
 			face.normal.add( normals[ b ] );
-			face.normal.add( normals[ c ] );
+			face.normal.add( normals[ d ] );
 			face.normal.normalize();
 
 			this.faces.push( face );
 
-			this.faceVertexUvs[ 0 ].push( [ uvs[ a ].clone(), uvs[ b ].clone(), uvs[ c ].clone() ] );
+			this.faceVertexUvs[ 0 ].push( [ uvs[ a ].clone(), uvs[ b ].clone(), uvs[ d ].clone() ] );
 
-			face = new THREE.Face3( a, c, d, [ normals[ a ], normals[ c ], normals[ d ] ] );
-			face.normal.add( normals[ a ] );
+			face = new THREE.Face3( b, c, d, [ normals[ b ], normals[ c ], normals[ d ] ] );
+			face.normal.add( normals[ b ] );
 			face.normal.add( normals[ c ] );
 			face.normal.add( normals[ d ] );
 			face.normal.normalize();
 
 			this.faces.push( face );
 
-			this.faceVertexUvs[ 0 ].push( [ uvs[ a ].clone(), uvs[ c ].clone(), uvs[ d ].clone() ] );
+			this.faceVertexUvs[ 0 ].push( [ uvs[ b ].clone(), uvs[ c ].clone(), uvs[ d ].clone() ] );
 		}
 
 	}

+ 4 - 4
src/extras/geometries/TorusKnotGeometry.js

@@ -70,11 +70,11 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
 			var uvc = new THREE.Vector2( ( i + 1 ) / this.radialSegments, ( j + 1 ) / this.tubularSegments );
 			var uvd = new THREE.Vector2( i / this.radialSegments, ( j + 1 ) / this.tubularSegments );
 
-			this.faces.push( new THREE.Face3( a, b, c ) );
-			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvc ] );
+			this.faces.push( new THREE.Face3( a, b, d ) );
+			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 
-			this.faces.push( new THREE.Face3( a, c, d ) );
-			this.faceVertexUvs[ 0 ].push( [ uva, uvc, uvd ] );
+			this.faces.push( new THREE.Face3( b, c, d ) );
+			this.faceVertexUvs[ 0 ].push( [ uvb, uvc, uvd ] );
 
 		}
 	}

+ 4 - 4
src/extras/geometries/TubeGeometry.js

@@ -110,11 +110,11 @@ THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed )
 			uvc = new THREE.Vector2( ( i + 1 ) / this.segments, ( j + 1 ) / this.radialSegments );
 			uvd = new THREE.Vector2( i / this.segments, ( j + 1 ) / this.radialSegments );
 
-			this.faces.push( new THREE.Face3( a, b, c ) );
-			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvc ] );
+			this.faces.push( new THREE.Face3( a, b, d ) );
+			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 
-			this.faces.push( new THREE.Face3( a, c, d ) );
-			this.faceVertexUvs[ 0 ].push( [ uva, uvc, uvd ] );
+			this.faces.push( new THREE.Face3( b, c, d ) );
+			this.faceVertexUvs[ 0 ].push( [ uvb, uvc, uvd ] );
 
 		}
 	}