Browse Source

Updated builds.

Mr.doob 5 years ago
parent
commit
7bd2bf96b3
3 changed files with 381 additions and 405 deletions
  1. 32 44
      build/three.js
  2. 317 317
      build/three.min.js
  3. 32 44
      build/three.module.js

+ 32 - 44
build/three.js

@@ -10754,66 +10754,62 @@
 		computeVertexNormals: function () {
 		computeVertexNormals: function () {
 
 
 			var index = this.index;
 			var index = this.index;
-			var attributes = this.attributes;
+			var positionAttribute = this.getAttribute( 'position' );
 
 
-			if ( attributes.position ) {
+			if ( positionAttribute !== undefined ) {
 
 
-				var positions = attributes.position.array;
+				var normalAttribute = this.getAttribute( 'normal' );
 
 
-				if ( attributes.normal === undefined ) {
+				if ( normalAttribute === undefined ) {
 
 
-					this.setAttribute( 'normal', new BufferAttribute( new Float32Array( positions.length ), 3 ) );
+					normalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );
+					this.setAttribute( 'normal', normalAttribute );
 
 
 				} else {
 				} else {
 
 
 					// reset existing normals to zero
 					// reset existing normals to zero
 
 
-					var array = attributes.normal.array;
+					for ( var i = 0, il = normalAttribute.count; i < il; i ++ ) {
 
 
-					for ( var i = 0, il = array.length; i < il; i ++ ) {
-
-						array[ i ] = 0;
+						normalAttribute.setXYZ( i, 0, 0, 0 );
 
 
 					}
 					}
 
 
 				}
 				}
 
 
-				var normals = attributes.normal.array;
-
 				var pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
 				var pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
+				var nA = new Vector3(), nB = new Vector3(), nC = new Vector3();
 				var cb = new Vector3(), ab = new Vector3();
 				var cb = new Vector3(), ab = new Vector3();
 
 
 				// indexed elements
 				// indexed elements
 
 
 				if ( index ) {
 				if ( index ) {
 
 
-					var indices = index.array;
-
 					for ( var i$1 = 0, il$1 = index.count; i$1 < il$1; i$1 += 3 ) {
 					for ( var i$1 = 0, il$1 = index.count; i$1 < il$1; i$1 += 3 ) {
 
 
-						var vA = indices[ i$1 + 0 ] * 3;
-						var vB = indices[ i$1 + 1 ] * 3;
-						var vC = indices[ i$1 + 2 ] * 3;
+						var vA = index.getX( i$1 + 0 );
+						var vB = index.getX( i$1 + 1 );
+						var vC = index.getX( i$1 + 2 );
 
 
-						pA.fromArray( positions, vA );
-						pB.fromArray( positions, vB );
-						pC.fromArray( positions, vC );
+						pA.fromBufferAttribute( positionAttribute, vA );
+						pB.fromBufferAttribute( positionAttribute, vB );
+						pC.fromBufferAttribute( positionAttribute, vC );
 
 
 						cb.subVectors( pC, pB );
 						cb.subVectors( pC, pB );
 						ab.subVectors( pA, pB );
 						ab.subVectors( pA, pB );
 						cb.cross( ab );
 						cb.cross( ab );
 
 
-						normals[ vA ] += cb.x;
-						normals[ vA + 1 ] += cb.y;
-						normals[ vA + 2 ] += cb.z;
+						nA.fromBufferAttribute( normalAttribute, vA );
+						nB.fromBufferAttribute( normalAttribute, vB );
+						nC.fromBufferAttribute( normalAttribute, vC );
 
 
-						normals[ vB ] += cb.x;
-						normals[ vB + 1 ] += cb.y;
-						normals[ vB + 2 ] += cb.z;
+						nA.add( cb );
+						nB.add( cb );
+						nC.add( cb );
 
 
-						normals[ vC ] += cb.x;
-						normals[ vC + 1 ] += cb.y;
-						normals[ vC + 2 ] += cb.z;
+						normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );
+						normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );
+						normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );
 
 
 					}
 					}
 
 
@@ -10821,27 +10817,19 @@
 
 
 					// non-indexed elements (unconnected triangle soup)
 					// non-indexed elements (unconnected triangle soup)
 
 
-					for ( var i$2 = 0, il$2 = positions.length; i$2 < il$2; i$2 += 9 ) {
+					for ( var i$2 = 0, il$2 = positionAttribute.count; i$2 < il$2; i$2 += 3 ) {
 
 
-						pA.fromArray( positions, i$2 );
-						pB.fromArray( positions, i$2 + 3 );
-						pC.fromArray( positions, i$2 + 6 );
+						pA.fromBufferAttribute( positionAttribute, i$2 + 0 );
+						pB.fromBufferAttribute( positionAttribute, i$2 + 1 );
+						pC.fromBufferAttribute( positionAttribute, i$2 + 2 );
 
 
 						cb.subVectors( pC, pB );
 						cb.subVectors( pC, pB );
 						ab.subVectors( pA, pB );
 						ab.subVectors( pA, pB );
 						cb.cross( ab );
 						cb.cross( ab );
 
 
-						normals[ i$2 ] = cb.x;
-						normals[ i$2 + 1 ] = cb.y;
-						normals[ i$2 + 2 ] = cb.z;
-
-						normals[ i$2 + 3 ] = cb.x;
-						normals[ i$2 + 4 ] = cb.y;
-						normals[ i$2 + 5 ] = cb.z;
-
-						normals[ i$2 + 6 ] = cb.x;
-						normals[ i$2 + 7 ] = cb.y;
-						normals[ i$2 + 8 ] = cb.z;
+						normalAttribute.setXYZ( i$2 + 0, cb.x, cb.y, cb.z );
+						normalAttribute.setXYZ( i$2 + 1, cb.x, cb.y, cb.z );
+						normalAttribute.setXYZ( i$2 + 2, cb.x, cb.y, cb.z );
 
 
 					}
 					}
 
 
@@ -10849,7 +10837,7 @@
 
 
 				this.normalizeNormals();
 				this.normalizeNormals();
 
 
-				attributes.normal.needsUpdate = true;
+				normalAttribute.needsUpdate = true;
 
 
 			}
 			}
 
 

File diff suppressed because it is too large
+ 317 - 317
build/three.min.js


+ 32 - 44
build/three.module.js

@@ -10748,66 +10748,62 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 	computeVertexNormals: function () {
 	computeVertexNormals: function () {
 
 
 		const index = this.index;
 		const index = this.index;
-		const attributes = this.attributes;
+		const positionAttribute = this.getAttribute( 'position' );
 
 
-		if ( attributes.position ) {
+		if ( positionAttribute !== undefined ) {
 
 
-			const positions = attributes.position.array;
+			let normalAttribute = this.getAttribute( 'normal' );
 
 
-			if ( attributes.normal === undefined ) {
+			if ( normalAttribute === undefined ) {
 
 
-				this.setAttribute( 'normal', new BufferAttribute( new Float32Array( positions.length ), 3 ) );
+				normalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );
+				this.setAttribute( 'normal', normalAttribute );
 
 
 			} else {
 			} else {
 
 
 				// reset existing normals to zero
 				// reset existing normals to zero
 
 
-				const array = attributes.normal.array;
+				for ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {
 
 
-				for ( let i = 0, il = array.length; i < il; i ++ ) {
-
-					array[ i ] = 0;
+					normalAttribute.setXYZ( i, 0, 0, 0 );
 
 
 				}
 				}
 
 
 			}
 			}
 
 
-			const normals = attributes.normal.array;
-
 			const pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
 			const pA = new Vector3(), pB = new Vector3(), pC = new Vector3();
+			const nA = new Vector3(), nB = new Vector3(), nC = new Vector3();
 			const cb = new Vector3(), ab = new Vector3();
 			const cb = new Vector3(), ab = new Vector3();
 
 
 			// indexed elements
 			// indexed elements
 
 
 			if ( index ) {
 			if ( index ) {
 
 
-				const indices = index.array;
-
 				for ( let i = 0, il = index.count; i < il; i += 3 ) {
 				for ( let i = 0, il = index.count; i < il; i += 3 ) {
 
 
-					const vA = indices[ i + 0 ] * 3;
-					const vB = indices[ i + 1 ] * 3;
-					const vC = indices[ i + 2 ] * 3;
+					const vA = index.getX( i + 0 );
+					const vB = index.getX( i + 1 );
+					const vC = index.getX( i + 2 );
 
 
-					pA.fromArray( positions, vA );
-					pB.fromArray( positions, vB );
-					pC.fromArray( positions, vC );
+					pA.fromBufferAttribute( positionAttribute, vA );
+					pB.fromBufferAttribute( positionAttribute, vB );
+					pC.fromBufferAttribute( positionAttribute, vC );
 
 
 					cb.subVectors( pC, pB );
 					cb.subVectors( pC, pB );
 					ab.subVectors( pA, pB );
 					ab.subVectors( pA, pB );
 					cb.cross( ab );
 					cb.cross( ab );
 
 
-					normals[ vA ] += cb.x;
-					normals[ vA + 1 ] += cb.y;
-					normals[ vA + 2 ] += cb.z;
+					nA.fromBufferAttribute( normalAttribute, vA );
+					nB.fromBufferAttribute( normalAttribute, vB );
+					nC.fromBufferAttribute( normalAttribute, vC );
 
 
-					normals[ vB ] += cb.x;
-					normals[ vB + 1 ] += cb.y;
-					normals[ vB + 2 ] += cb.z;
+					nA.add( cb );
+					nB.add( cb );
+					nC.add( cb );
 
 
-					normals[ vC ] += cb.x;
-					normals[ vC + 1 ] += cb.y;
-					normals[ vC + 2 ] += cb.z;
+					normalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );
+					normalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );
+					normalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );
 
 
 				}
 				}
 
 
@@ -10815,27 +10811,19 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 
 				// non-indexed elements (unconnected triangle soup)
 				// non-indexed elements (unconnected triangle soup)
 
 
-				for ( let i = 0, il = positions.length; i < il; i += 9 ) {
+				for ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {
 
 
-					pA.fromArray( positions, i );
-					pB.fromArray( positions, i + 3 );
-					pC.fromArray( positions, i + 6 );
+					pA.fromBufferAttribute( positionAttribute, i + 0 );
+					pB.fromBufferAttribute( positionAttribute, i + 1 );
+					pC.fromBufferAttribute( positionAttribute, i + 2 );
 
 
 					cb.subVectors( pC, pB );
 					cb.subVectors( pC, pB );
 					ab.subVectors( pA, pB );
 					ab.subVectors( pA, pB );
 					cb.cross( ab );
 					cb.cross( ab );
 
 
-					normals[ i ] = cb.x;
-					normals[ i + 1 ] = cb.y;
-					normals[ i + 2 ] = cb.z;
-
-					normals[ i + 3 ] = cb.x;
-					normals[ i + 4 ] = cb.y;
-					normals[ i + 5 ] = cb.z;
-
-					normals[ i + 6 ] = cb.x;
-					normals[ i + 7 ] = cb.y;
-					normals[ i + 8 ] = cb.z;
+					normalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );
+					normalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );
+					normalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );
 
 
 				}
 				}
 
 
@@ -10843,7 +10831,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 
 			this.normalizeNormals();
 			this.normalizeNormals();
 
 
-			attributes.normal.needsUpdate = true;
+			normalAttribute.needsUpdate = true;
 
 
 		}
 		}
 
 

Some files were not shown because too many files changed in this diff