diff --git a/src/extras/geometries/CubeGeometry.js b/src/extras/geometries/CubeGeometry.js index 81aa6e605e3778b35e037dece26f32ee02a596e2..7f2bce76f43c7487bb6246795641b32805a3ed90 100644 --- a/src/extras/geometries/CubeGeometry.js +++ b/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 ] ); } diff --git a/src/extras/geometries/CylinderGeometry.js b/src/extras/geometries/CylinderGeometry.js index 07c05be54adb664ae1be3850332be93d5155839e..c7043dea6d45e018bbd7f0dc87d622048ef17162 100644 --- a/src/extras/geometries/CylinderGeometry.js +++ b/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 ] ); } diff --git a/src/extras/geometries/LatheGeometry.js b/src/extras/geometries/LatheGeometry.js index 91c7fe7acd24c414779dc7c4890f97cbc279f350..d5229d786ed57846ea338f5bb4eb13b5640503af 100644 --- a/src/extras/geometries/LatheGeometry.js +++ b/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 ) diff --git a/src/extras/geometries/ParametricGeometry.js b/src/extras/geometries/ParametricGeometry.js index c141a2512ce26ee839de84f0f1785b79fbecba2e..db32acc864d1ac6e3ce4c0091038453129c33729 100644 --- a/src/extras/geometries/ParametricGeometry.js +++ b/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 ] ); } diff --git a/src/extras/geometries/PlaneGeometry.js b/src/extras/geometries/PlaneGeometry.js index ed536825b31e9eb38303df63961374f99004cb4a..619a4158ed3af79600b8ce73605d186158ea2f6d 100644 --- a/src/extras/geometries/PlaneGeometry.js +++ b/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 ] ); } diff --git a/src/extras/geometries/SphereGeometry.js b/src/extras/geometries/SphereGeometry.js index fc5c6262718c1695d92c00c84332b108ae0de6cc..b0739040d710c3d0372443a6b1ed60affd925205 100644 --- a/src/extras/geometries/SphereGeometry.js +++ b/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 ] ); } diff --git a/src/extras/geometries/TorusGeometry.js b/src/extras/geometries/TorusGeometry.js index ecd7f0c678aaee91fda0eca6f970fa4df0989c84..28e3a003c0cfb3447f982e5f36090ac7219febda 100644 --- a/src/extras/geometries/TorusGeometry.js +++ b/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() ] ); } } diff --git a/src/extras/geometries/TorusKnotGeometry.js b/src/extras/geometries/TorusKnotGeometry.js index db735f9a8ec68c976c35fff0b522462b3a46eef4..951d8ff5488014c2b7ad9415c3a462d1631262ef 100644 --- a/src/extras/geometries/TorusKnotGeometry.js +++ b/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 ] ); } } diff --git a/src/extras/geometries/TubeGeometry.js b/src/extras/geometries/TubeGeometry.js index b02fbb6a1ee8856f895b76ee4b7023104f3efe4c..9e83553e22270441b3eec06666be51619b44d14d 100644 --- a/src/extras/geometries/TubeGeometry.js +++ b/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 ] ); } }