LeonYuanYao 5 ani în urmă
părinte
comite
4e3276dce8
1 a modificat fișierele cu 219 adăugiri și 219 ștergeri
  1. 219 219
      examples/jsm/utils/GeometryCompressionUtils.js

+ 219 - 219
examples/jsm/utils/GeometryCompressionUtils.js

@@ -28,27 +28,27 @@ var GeometryCompressionUtils = {
 		 * @param {String} encodeMethod		"DEFAULT" || "OCT1Byte" || "OCT2Byte" || "ANGLES"
 		 *
 		 */
-	compressNormals: function (mesh, encodeMethod) {
+	compressNormals: function ( mesh, encodeMethod ) {
 
-		if (!mesh.geometry) {
+		if ( !mesh.geometry ) {
 
-			console.error("Mesh must contain geometry. ");
+			console.error( "Mesh must contain geometry. " );
 
 		}
 
 		let normal = mesh.geometry.attributes.normal;
 
-		if (!normal) {
+		if ( !normal ) {
 
-			console.error("Geometry must contain normal attribute. ");
+			console.error( "Geometry must contain normal attribute. " );
 
 		}
 
-		if (normal.isPacked) return;
+		if ( normal.isPacked ) return;
 
-		if (normal.itemSize != 3) {
+		if ( normal.itemSize != 3 ) {
 
-			console.error("normal.itemSize is not 3, which cannot be encoded. ");
+			console.error( "normal.itemSize is not 3, which cannot be encoded. " );
 
 		}
 
@@ -56,27 +56,27 @@ var GeometryCompressionUtils = {
 		let count = normal.count;
 
 		let result;
-		if (encodeMethod == "DEFAULT") {
+		if ( encodeMethod == "DEFAULT" ) {
 
 			// TODO: Add 1 byte to the result, making the encoded length to be 4 bytes. 
-			result = new Uint8Array(count * 3);
+			result = new Uint8Array( count * 3 );
 
-			for (let idx = 0; idx < array.length; idx += 3) {
+			for ( let idx = 0; idx < array.length; idx += 3 ) {
 
 				let encoded;
 
-				encoded = this.EncodingFuncs.defaultEncode(array[idx], array[idx + 1], array[idx + 2], 1);
+				encoded = this.EncodingFuncs.defaultEncode( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 1 );
 
-				result[idx + 0] = encoded[0];
-				result[idx + 1] = encoded[1];
-				result[idx + 2] = encoded[2];
+				result[ idx + 0 ] = encoded[ 0 ];
+				result[ idx + 1 ] = encoded[ 1 ];
+				result[ idx + 2 ] = encoded[ 2 ];
 
 			}
 
-			mesh.geometry.setAttribute('normal', new BufferAttribute(result, 3, true));
+			mesh.geometry.setAttribute( 'normal', new BufferAttribute( result, 3, true ) );
 			mesh.geometry.attributes.normal.bytes = result.length * 1;
 
-		} else if (encodeMethod == "OCT1Byte") {
+		} else if ( encodeMethod == "OCT1Byte" ) {
 
 			/**
 			* It is not recommended to use 1-byte octahedron normals encoding unless you want to extremely reduce the memory usage
@@ -84,61 +84,61 @@ var GeometryCompressionUtils = {
 			* Please refer to @zeux 's comments in https://github.com/mrdoob/three.js/pull/18208
 			*/
 
-			result = new Int8Array(count * 2);
+			result = new Int8Array( count * 2 );
 
-			for (let idx = 0; idx < array.length; idx += 3) {
+			for ( let idx = 0; idx < array.length; idx += 3 ) {
 
 				let encoded;
 
-				encoded = this.EncodingFuncs.octEncodeBest(array[idx], array[idx + 1], array[idx + 2], 1);
+				encoded = this.EncodingFuncs.octEncodeBest( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 1 );
 
-				result[idx / 3 * 2 + 0] = encoded[0];
-				result[idx / 3 * 2 + 1] = encoded[1];
+				result[ idx / 3 * 2 + 0 ] = encoded[ 0 ];
+				result[ idx / 3 * 2 + 1 ] = encoded[ 1 ];
 
 			}
 
-			mesh.geometry.setAttribute('normal', new BufferAttribute(result, 2, true));
+			mesh.geometry.setAttribute( 'normal', new BufferAttribute( result, 2, true ) );
 			mesh.geometry.attributes.normal.bytes = result.length * 1;
 
-		} else if (encodeMethod == "OCT2Byte") {
+		} else if ( encodeMethod == "OCT2Byte" ) {
 
-			result = new Int16Array(count * 2);
+			result = new Int16Array( count * 2 );
 
-			for (let idx = 0; idx < array.length; idx += 3) {
+			for ( let idx = 0; idx < array.length; idx += 3 ) {
 
 				let encoded;
 
-				encoded = this.EncodingFuncs.octEncodeBest(array[idx], array[idx + 1], array[idx + 2], 2);
+				encoded = this.EncodingFuncs.octEncodeBest( array[ idx ], array[ idx + 1 ], array[ idx + 2 ], 2 );
 
-				result[idx / 3 * 2 + 0] = encoded[0];
-				result[idx / 3 * 2 + 1] = encoded[1];
+				result[ idx / 3 * 2 + 0 ] = encoded[ 0 ];
+				result[ idx / 3 * 2 + 1 ] = encoded[ 1 ];
 
 			}
 
-			mesh.geometry.setAttribute('normal', new BufferAttribute(result, 2, true));
+			mesh.geometry.setAttribute( 'normal', new BufferAttribute( result, 2, true ) );
 			mesh.geometry.attributes.normal.bytes = result.length * 2;
 
-		} else if (encodeMethod == "ANGLES") {
+		} else if ( encodeMethod == "ANGLES" ) {
 
-			result = new Uint16Array(count * 2);
+			result = new Uint16Array( count * 2 );
 
-			for (let idx = 0; idx < array.length; idx += 3) {
+			for ( let idx = 0; idx < array.length; idx += 3 ) {
 
 				let encoded;
 
-				encoded = this.EncodingFuncs.anglesEncode(array[idx], array[idx + 1], array[idx + 2]);
+				encoded = this.EncodingFuncs.anglesEncode( array[ idx ], array[ idx + 1 ], array[ idx + 2 ] );
 
-				result[idx / 3 * 2 + 0] = encoded[0];
-				result[idx / 3 * 2 + 1] = encoded[1];
+				result[ idx / 3 * 2 + 0 ] = encoded[ 0 ];
+				result[ idx / 3 * 2 + 1 ] = encoded[ 1 ];
 
 			}
 
-			mesh.geometry.setAttribute('normal', new BufferAttribute(result, 2, true));
+			mesh.geometry.setAttribute( 'normal', new BufferAttribute( result, 2, true ) );
 			mesh.geometry.attributes.normal.bytes = result.length * 2;
 
 		} else {
 
-			console.error("Unrecognized encoding method, should be `DEFAULT` or `ANGLES` or `OCT`. ");
+			console.error( "Unrecognized encoding method, should be `DEFAULT` or `ANGLES` or `OCT`. " );
 
 		}
 
@@ -147,28 +147,28 @@ var GeometryCompressionUtils = {
 		mesh.geometry.attributes.normal.packingMethod = encodeMethod;
 
 		// modify material
-		if (!(mesh.material instanceof PackedPhongMaterial)) {
+		if ( !( mesh.material instanceof PackedPhongMaterial ) ) {
 
-			mesh.material = new PackedPhongMaterial().copy(mesh.material);
+			mesh.material = new PackedPhongMaterial().copy( mesh.material );
 
 		}
 
-		if (encodeMethod == "ANGLES") {
+		if ( encodeMethod == "ANGLES" ) {
 
 			mesh.material.defines.USE_PACKED_NORMAL = 0;
 
 		}
-		if (encodeMethod == "OCT1Byte") {
+		if ( encodeMethod == "OCT1Byte" ) {
 
 			mesh.material.defines.USE_PACKED_NORMAL = 1;
 
 		}
-		if (encodeMethod == "OCT2Byte") {
+		if ( encodeMethod == "OCT2Byte" ) {
 
 			mesh.material.defines.USE_PACKED_NORMAL = 1;
 
 		}
-		if (encodeMethod == "DEFAULT") {
+		if ( encodeMethod == "DEFAULT" ) {
 
 			mesh.material.defines.USE_PACKED_NORMAL = 2;
 
@@ -184,51 +184,51 @@ var GeometryCompressionUtils = {
 		 * @param {THREE.Mesh} mesh
 		 *
 		 */
-	compressPositions: function (mesh) {
+	compressPositions: function ( mesh ) {
 
-		if (!mesh.geometry) {
+		if ( !mesh.geometry ) {
 
-			console.error("Mesh must contain geometry. ");
+			console.error( "Mesh must contain geometry. " );
 
 		}
 
 		let position = mesh.geometry.attributes.position;
 
-		if (!position) {
+		if ( !position ) {
 
-			console.error("Geometry must contain position attribute. ");
+			console.error( "Geometry must contain position attribute. " );
 
 		}
 
-		if (position.isPacked) return;
+		if ( position.isPacked ) return;
 
-		if (position.itemSize != 3) {
+		if ( position.itemSize != 3 ) {
 
-			console.error("position.itemSize is not 3, which cannot be packed. ");
+			console.error( "position.itemSize is not 3, which cannot be packed. " );
 
 		}
 
 		let array = position.array;
 		let encodingBytes = 2;
 
-		let result = this.EncodingFuncs.quantizedEncode(array, encodingBytes);
+		let result = this.EncodingFuncs.quantizedEncode( array, encodingBytes );
 
 		let quantized = result.quantized;
 		let decodeMat = result.decodeMat;
 
 		// IMPORTANT: calculate original geometry bounding info first, before updating packed positions
-		if (mesh.geometry.boundingBox == null) mesh.geometry.computeBoundingBox();
-		if (mesh.geometry.boundingSphere == null) mesh.geometry.computeBoundingSphere();
+		if ( mesh.geometry.boundingBox == null ) mesh.geometry.computeBoundingBox();
+		if ( mesh.geometry.boundingSphere == null ) mesh.geometry.computeBoundingSphere();
 
-		mesh.geometry.setAttribute('position', new BufferAttribute(quantized, 3));
+		mesh.geometry.setAttribute( 'position', new BufferAttribute( quantized, 3 ) );
 		mesh.geometry.attributes.position.isPacked = true;
 		mesh.geometry.attributes.position.needsUpdate = true;
 		mesh.geometry.attributes.position.bytes = quantized.length * encodingBytes;
 
 		// modify material
-		if (!(mesh.material instanceof PackedPhongMaterial)) {
+		if ( !( mesh.material instanceof PackedPhongMaterial ) ) {
 
-			mesh.material = new PackedPhongMaterial().copy(mesh.material);
+			mesh.material = new PackedPhongMaterial().copy( mesh.material );
 
 		}
 
@@ -246,59 +246,59 @@ var GeometryCompressionUtils = {
 		 * @param {THREE.Mesh} mesh
 		 *
 		 */
-	compressUvs: function (mesh) {
+	compressUvs: function ( mesh ) {
 
-		if (!mesh.geometry) {
+		if ( !mesh.geometry ) {
 
-			console.error("Mesh must contain geometry property. ");
+			console.error( "Mesh must contain geometry property. " );
 
 		}
 
 		let uvs = mesh.geometry.attributes.uv;
 
-		if (!uvs) {
+		if ( !uvs ) {
 
-			console.error("Geometry must contain uv attribute. ");
+			console.error( "Geometry must contain uv attribute. " );
 
 		}
 
-		if (uvs.isPacked) return;
+		if ( uvs.isPacked ) return;
 
 		let range = { min: Infinity, max: - Infinity };
 
 		let array = uvs.array;
 
-		for (let i = 0; i < array.length; i++) {
+		for ( let i = 0; i < array.length; i++ ) {
 
-			range.min = Math.min(range.min, array[i]);
-			range.max = Math.max(range.max, array[i]);
+			range.min = Math.min( range.min, array[ i ] );
+			range.max = Math.max( range.max, array[ i ] );
 
 		}
 
 		let result;
 
-		if (range.min >= - 1.0 && range.max <= 1.0) {
+		if ( range.min >= - 1.0 && range.max <= 1.0 ) {
 
 			// use default encoding method
-			result = new Uint16Array(array.length);
+			result = new Uint16Array( array.length );
 
-			for (let i = 0; i < array.length; i += 2) {
+			for ( let i = 0; i < array.length; i += 2 ) {
 
-				let encoded = this.EncodingFuncs.defaultEncode(array[i], array[i + 1], 0, 2);
+				let encoded = this.EncodingFuncs.defaultEncode( array[ i ], array[ i + 1 ], 0, 2 );
 
-				result[i] = encoded[0];
-				result[i + 1] = encoded[1];
+				result[ i ] = encoded[ 0 ];
+				result[ i + 1 ] = encoded[ 1 ];
 
 			}
 
-			mesh.geometry.setAttribute('uv', new BufferAttribute(result, 2, true));
+			mesh.geometry.setAttribute( 'uv', new BufferAttribute( result, 2, true ) );
 			mesh.geometry.attributes.uv.isPacked = true;
 			mesh.geometry.attributes.uv.needsUpdate = true;
 			mesh.geometry.attributes.uv.bytes = result.length * 2;
 
-			if (!(mesh.material instanceof PackedPhongMaterial)) {
+			if ( !( mesh.material instanceof PackedPhongMaterial ) ) {
 
-				mesh.material = new PackedPhongMaterial().copy(mesh.material);
+				mesh.material = new PackedPhongMaterial().copy( mesh.material );
 
 			}
 
@@ -307,16 +307,16 @@ var GeometryCompressionUtils = {
 		} else {
 
 			// use quantized encoding method
-			result = this.EncodingFuncs.quantizedEncodeUV(array, 2);
+			result = this.EncodingFuncs.quantizedEncodeUV( array, 2 );
 
-			mesh.geometry.setAttribute('uv', new BufferAttribute(result.quantized, 2));
+			mesh.geometry.setAttribute( 'uv', new BufferAttribute( result.quantized, 2 ) );
 			mesh.geometry.attributes.uv.isPacked = true;
 			mesh.geometry.attributes.uv.needsUpdate = true;
 			mesh.geometry.attributes.uv.bytes = result.quantized.length * 2;
 
-			if (!(mesh.material instanceof PackedPhongMaterial)) {
+			if ( !( mesh.material instanceof PackedPhongMaterial ) ) {
 
-				mesh.material = new PackedPhongMaterial().copy(mesh.material);
+				mesh.material = new PackedPhongMaterial().copy( mesh.material );
 
 			}
 
@@ -335,103 +335,103 @@ var GeometryCompressionUtils = {
 
 	EncodingFuncs: {
 
-		defaultEncode: function (x, y, z, bytes) {
+		defaultEncode: function ( x, y, z, bytes ) {
 
-			if (bytes == 1) {
+			if ( bytes == 1 ) {
 
-				let tmpx = Math.round((x + 1) * 0.5 * 255);
-				let tmpy = Math.round((y + 1) * 0.5 * 255);
-				let tmpz = Math.round((z + 1) * 0.5 * 255);
-				return new Uint8Array([tmpx, tmpy, tmpz]);
+				let tmpx = Math.round( ( x + 1 ) * 0.5 * 255 );
+				let tmpy = Math.round( ( y + 1 ) * 0.5 * 255 );
+				let tmpz = Math.round( ( z + 1 ) * 0.5 * 255 );
+				return new Uint8Array( [ tmpx, tmpy, tmpz ] );
 
-			} else if (bytes == 2) {
+			} else if ( bytes == 2 ) {
 
-				let tmpx = Math.round((x + 1) * 0.5 * 65535);
-				let tmpy = Math.round((y + 1) * 0.5 * 65535);
-				let tmpz = Math.round((z + 1) * 0.5 * 65535);
-				return new Uint16Array([tmpx, tmpy, tmpz]);
+				let tmpx = Math.round( ( x + 1 ) * 0.5 * 65535 );
+				let tmpy = Math.round( ( y + 1 ) * 0.5 * 65535 );
+				let tmpz = Math.round( ( z + 1 ) * 0.5 * 65535 );
+				return new Uint16Array( [ tmpx, tmpy, tmpz ] );
 
 			} else {
 
-				console.error("number of bytes must be 1 or 2");
+				console.error( "number of bytes must be 1 or 2" );
 
 			}
 
 		},
 
-		defaultDecode: function (array, bytes) {
+		defaultDecode: function ( array, bytes ) {
 
-			if (bytes == 1) {
+			if ( bytes == 1 ) {
 
 				return [
-					((array[0] / 255) * 2.0) - 1.0,
-					((array[1] / 255) * 2.0) - 1.0,
-					((array[2] / 255) * 2.0) - 1.0,
+					( ( array[ 0 ] / 255 ) * 2.0 ) - 1.0,
+					( ( array[ 1 ] / 255 ) * 2.0 ) - 1.0,
+					( ( array[ 2 ] / 255 ) * 2.0 ) - 1.0,
 				];
 
-			} else if (bytes == 2) {
+			} else if ( bytes == 2 ) {
 
 				return [
-					((array[0] / 65535) * 2.0) - 1.0,
-					((array[1] / 65535) * 2.0) - 1.0,
-					((array[2] / 65535) * 2.0) - 1.0,
+					( ( array[ 0 ] / 65535 ) * 2.0 ) - 1.0,
+					( ( array[ 1 ] / 65535 ) * 2.0 ) - 1.0,
+					( ( array[ 2 ] / 65535 ) * 2.0 ) - 1.0,
 				];
 
 			} else {
 
-				console.error("number of bytes must be 1 or 2");
+				console.error( "number of bytes must be 1 or 2" );
 
 			}
 
 		},
 
 		// for `Angles` encoding
-		anglesEncode: function (x, y, z) {
+		anglesEncode: function ( x, y, z ) {
 
-			let normal0 = parseInt(0.5 * (1.0 + Math.atan2(y, x) / Math.PI) * 65535);
-			let normal1 = parseInt(0.5 * (1.0 + z) * 65535);
-			return new Uint16Array([normal0, normal1]);
+			let normal0 = parseInt( 0.5 * ( 1.0 + Math.atan2( y, x ) / Math.PI ) * 65535 );
+			let normal1 = parseInt( 0.5 * ( 1.0 + z ) * 65535 );
+			return new Uint16Array( [ normal0, normal1 ] );
 
 		},
 
 		// for `Octahedron` encoding
-		octEncodeBest: function (x, y, z, bytes) {
+		octEncodeBest: function ( x, y, z, bytes ) {
 
 			var oct, dec, best, currentCos, bestCos;
 
 			// Test various combinations of ceil and floor
 			// to minimize rounding errors
-			best = oct = octEncodeVec3(x, y, z, "floor", "floor");
-			dec = octDecodeVec2(oct);
-			bestCos = dot(x, y, z, dec);
+			best = oct = octEncodeVec3( x, y, z, "floor", "floor" );
+			dec = octDecodeVec2( oct );
+			bestCos = dot( x, y, z, dec );
 
-			oct = octEncodeVec3(x, y, z, "ceil", "floor");
-			dec = octDecodeVec2(oct);
-			currentCos = dot(x, y, z, dec);
+			oct = octEncodeVec3( x, y, z, "ceil", "floor" );
+			dec = octDecodeVec2( oct );
+			currentCos = dot( x, y, z, dec );
 
-			if (currentCos > bestCos) {
+			if ( currentCos > bestCos ) {
 
 				best = oct;
 				bestCos = currentCos;
 
 			}
 
-			oct = octEncodeVec3(x, y, z, "floor", "ceil");
-			dec = octDecodeVec2(oct);
-			currentCos = dot(x, y, z, dec);
+			oct = octEncodeVec3( x, y, z, "floor", "ceil" );
+			dec = octDecodeVec2( oct );
+			currentCos = dot( x, y, z, dec );
 
-			if (currentCos > bestCos) {
+			if ( currentCos > bestCos ) {
 
 				best = oct;
 				bestCos = currentCos;
 
 			}
 
-			oct = octEncodeVec3(x, y, z, "ceil", "ceil");
-			dec = octDecodeVec2(oct);
-			currentCos = dot(x, y, z, dec);
+			oct = octEncodeVec3( x, y, z, "ceil", "ceil" );
+			dec = octDecodeVec2( oct );
+			currentCos = dot( x, y, z, dec );
 
-			if (currentCos > bestCos) {
+			if ( currentCos > bestCos ) {
 
 				best = oct;
 
@@ -439,21 +439,21 @@ var GeometryCompressionUtils = {
 
 			return best;
 
-			function octEncodeVec3(x0, y0, z0, xfunc, yfunc) {
+			function octEncodeVec3 ( x0, y0, z0, xfunc, yfunc ) {
 
-				var x = x0 / (Math.abs(x0) + Math.abs(y0) + Math.abs(z0));
-				var y = y0 / (Math.abs(x0) + Math.abs(y0) + Math.abs(z0));
+				var x = x0 / ( Math.abs( x0 ) + Math.abs( y0 ) + Math.abs( z0 ) );
+				var y = y0 / ( Math.abs( x0 ) + Math.abs( y0 ) + Math.abs( z0 ) );
 
-				if (z < 0) {
+				if ( z < 0 ) {
 
-					var tempx = tempx = (1 - Math.abs(y)) * (x >= 0 ? 1 : - 1);
-					var tempy = tempy = (1 - Math.abs(x)) * (y >= 0 ? 1 : - 1);
+					var tempx = tempx = ( 1 - Math.abs( y ) ) * ( x >= 0 ? 1 : - 1 );
+					var tempy = tempy = ( 1 - Math.abs( x ) ) * ( y >= 0 ? 1 : - 1 );
 
 					x = tempx;
 					y = tempy;
 
-					var diff = 1 - Math.abs(x) - Math.abs(y);
-					if (diff > 0) {
+					var diff = 1 - Math.abs( x ) - Math.abs( y );
+					if ( diff > 0 ) {
 
 						diff += 0.001;
 						x += x > 0 ? diff / 2 : - diff / 2;
@@ -463,37 +463,37 @@ var GeometryCompressionUtils = {
 
 				}
 
-				if (bytes == 1) {
+				if ( bytes == 1 ) {
 
-					return new Int8Array([
-						Math[xfunc](x * 127.5 + (x < 0 ? 1 : 0)),
-						Math[yfunc](y * 127.5 + (y < 0 ? 1 : 0))
-					]);
+					return new Int8Array( [
+						Math[ xfunc ]( x * 127.5 + ( x < 0 ? 1 : 0 ) ),
+						Math[ yfunc ]( y * 127.5 + ( y < 0 ? 1 : 0 ) )
+					] );
 
 				}
-				if (bytes == 2) {
+				if ( bytes == 2 ) {
 
-					return new Int16Array([
-						Math[xfunc](x * 32767.5 + (x < 0 ? 1 : 0)),
-						Math[yfunc](y * 32767.5 + (y < 0 ? 1 : 0))
-					]);
+					return new Int16Array( [
+						Math[ xfunc ]( x * 32767.5 + ( x < 0 ? 1 : 0 ) ),
+						Math[ yfunc ]( y * 32767.5 + ( y < 0 ? 1 : 0 ) )
+					] );
 
 				}
 
 
 			}
 
-			function octDecodeVec2(oct) {
+			function octDecodeVec2 ( oct ) {
 
-				var x = oct[0];
-				var y = oct[1];
+				var x = oct[ 0 ];
+				var y = oct[ 1 ];
 
-				if (bytes == 1) {
+				if ( bytes == 1 ) {
 
 					x /= x < 0 ? 127 : 128;
 					y /= y < 0 ? 127 : 128;
 
-				} else if (bytes == 2) {
+				} else if ( bytes == 2 ) {
 
 					x /= x < 0 ? 32767 : 32768;
 					y /= y < 0 ? 32767 : 32768;
@@ -501,17 +501,17 @@ var GeometryCompressionUtils = {
 				}
 
 
-				var z = 1 - Math.abs(x) - Math.abs(y);
+				var z = 1 - Math.abs( x ) - Math.abs( y );
 
-				if (z < 0) {
+				if ( z < 0 ) {
 
 					var tmpx = x;
-					x = (1 - Math.abs(y)) * (x >= 0 ? 1 : - 1);
-					y = (1 - Math.abs(tmpx)) * (y >= 0 ? 1 : - 1);
+					x = ( 1 - Math.abs( y ) ) * ( x >= 0 ? 1 : - 1 );
+					y = ( 1 - Math.abs( tmpx ) ) * ( y >= 0 ? 1 : - 1 );
 
 				}
 
-				var length = Math.sqrt(x * x + y * y + z * z);
+				var length = Math.sqrt( x * x + y * y + z * z );
 
 				return [
 					x / length,
@@ -521,77 +521,77 @@ var GeometryCompressionUtils = {
 
 			}
 
-			function dot(x, y, z, vec3) {
+			function dot ( x, y, z, vec3 ) {
 
-				return x * vec3[0] + y * vec3[1] + z * vec3[2];
+				return x * vec3[ 0 ] + y * vec3[ 1 ] + z * vec3[ 2 ];
 
 			}
 
 		},
 
-		quantizedEncode: function (array, bytes) {
+		quantizedEncode: function ( array, bytes ) {
 
 			let quantized, segments;
 
-			if (bytes == 1) {
+			if ( bytes == 1 ) {
 
-				quantized = new Uint8Array(array.length);
+				quantized = new Uint8Array( array.length );
 				segments = 255;
 
-			} else if (bytes == 2) {
+			} else if ( bytes == 2 ) {
 
-				quantized = new Uint16Array(array.length);
+				quantized = new Uint16Array( array.length );
 				segments = 65535;
 
 			} else {
 
-				console.error("number of bytes error! ");
+				console.error( "number of bytes error! " );
 
 			}
 
 			let decodeMat = new Matrix4();
 
-			let min = new Float32Array(3);
-			let max = new Float32Array(3);
+			let min = new Float32Array( 3 );
+			let max = new Float32Array( 3 );
 
-			min[0] = min[1] = min[2] = Number.MAX_VALUE;
-			max[0] = max[1] = max[2] = - Number.MAX_VALUE;
+			min[ 0 ] = min[ 1 ] = min[ 2 ] = Number.MAX_VALUE;
+			max[ 0 ] = max[ 1 ] = max[ 2 ] = - Number.MAX_VALUE;
 
-			for (let i = 0; i < array.length; i += 3) {
+			for ( let i = 0; i < array.length; i += 3 ) {
 
-				min[0] = Math.min(min[0], array[i + 0]);
-				min[1] = Math.min(min[1], array[i + 1]);
-				min[2] = Math.min(min[2], array[i + 2]);
-				max[0] = Math.max(max[0], array[i + 0]);
-				max[1] = Math.max(max[1], array[i + 1]);
-				max[2] = Math.max(max[2], array[i + 2]);
+				min[ 0 ] = Math.min( min[ 0 ], array[ i + 0 ] );
+				min[ 1 ] = Math.min( min[ 1 ], array[ i + 1 ] );
+				min[ 2 ] = Math.min( min[ 2 ], array[ i + 2 ] );
+				max[ 0 ] = Math.max( max[ 0 ], array[ i + 0 ] );
+				max[ 1 ] = Math.max( max[ 1 ], array[ i + 1 ] );
+				max[ 2 ] = Math.max( max[ 2 ], array[ i + 2 ] );
 
 			}
 
-			decodeMat.scale(new Vector3(
-				(max[0] - min[0]) / segments,
-				(max[1] - min[1]) / segments,
-				(max[2] - min[2]) / segments
-			));
+			decodeMat.scale( new Vector3(
+				( max[ 0 ] - min[ 0 ] ) / segments,
+				( max[ 1 ] - min[ 1 ] ) / segments,
+				( max[ 2 ] - min[ 2 ] ) / segments
+			) );
 
-			decodeMat.elements[12] = min[0];
-			decodeMat.elements[13] = min[1];
-			decodeMat.elements[14] = min[2];
+			decodeMat.elements[ 12 ] = min[ 0 ];
+			decodeMat.elements[ 13 ] = min[ 1 ];
+			decodeMat.elements[ 14 ] = min[ 2 ];
 
 			decodeMat.transpose();
 
 
-			let multiplier = new Float32Array([
-				max[0] !== min[0] ? segments / (max[0] - min[0]) : 0,
-				max[1] !== min[1] ? segments / (max[1] - min[1]) : 0,
-				max[2] !== min[2] ? segments / (max[2] - min[2]) : 0
-			]);
+			let multiplier = new Float32Array( [
+				max[ 0 ] !== min[ 0 ] ? segments / ( max[ 0 ] - min[ 0 ] ) : 0,
+				max[ 1 ] !== min[ 1 ] ? segments / ( max[ 1 ] - min[ 1 ] ) : 0,
+				max[ 2 ] !== min[ 2 ] ? segments / ( max[ 2 ] - min[ 2 ] ) : 0
+			] );
 
-			for (let i = 0; i < array.length; i += 3) {
+			for ( let i = 0; i < array.length; i += 3 ) {
 
-				quantized[i + 0] = Math.floor((array[i + 0] - min[0]) * multiplier[0]);
-				quantized[i + 1] = Math.floor((array[i + 1] - min[1]) * multiplier[1]);
-				quantized[i + 2] = Math.floor((array[i + 2] - min[2]) * multiplier[2]);
+				quantized[ i + 0 ] = Math.floor( ( array[ i + 0 ] - min[ 0 ] ) * multiplier[ 0 ] );
+				quantized[ i + 1 ] = Math.floor( ( array[ i + 1 ] - min[ 1 ] ) * multiplier[ 1 ] );
+				quantized[ i + 2 ] = Math.floor( ( array[ i + 2 ] - min[ 2 ] ) * multiplier[ 2 ] );
 
 			}
 
@@ -603,62 +603,62 @@ var GeometryCompressionUtils = {
 		},
 
 
-		quantizedEncodeUV: function (array, bytes) {
+		quantizedEncodeUV: function ( array, bytes ) {
 
 			let quantized, segments;
 
-			if (bytes == 1) {
+			if ( bytes == 1 ) {
 
-				quantized = new Uint8Array(array.length);
+				quantized = new Uint8Array( array.length );
 				segments = 255;
 
-			} else if (bytes == 2) {
+			} else if ( bytes == 2 ) {
 
-				quantized = new Uint16Array(array.length);
+				quantized = new Uint16Array( array.length );
 				segments = 65535;
 
 			} else {
 
-				console.error("number of bytes error! ");
+				console.error( "number of bytes error! " );
 
 			}
 
 			let decodeMat = new Matrix3();
 
-			let min = new Float32Array(2);
-			let max = new Float32Array(2);
+			let min = new Float32Array( 2 );
+			let max = new Float32Array( 2 );
 
-			min[0] = min[1] = Number.MAX_VALUE;
-			max[0] = max[1] = - Number.MAX_VALUE;
+			min[ 0 ] = min[ 1 ] = Number.MAX_VALUE;
+			max[ 0 ] = max[ 1 ] = - Number.MAX_VALUE;
 
-			for (let i = 0; i < array.length; i += 2) {
+			for ( let i = 0; i < array.length; i += 2 ) {
 
-				min[0] = Math.min(min[0], array[i + 0]);
-				min[1] = Math.min(min[1], array[i + 1]);
-				max[0] = Math.max(max[0], array[i + 0]);
-				max[1] = Math.max(max[1], array[i + 1]);
+				min[ 0 ] = Math.min( min[ 0 ], array[ i + 0 ] );
+				min[ 1 ] = Math.min( min[ 1 ], array[ i + 1 ] );
+				max[ 0 ] = Math.max( max[ 0 ], array[ i + 0 ] );
+				max[ 1 ] = Math.max( max[ 1 ], array[ i + 1 ] );
 
 			}
 
 			decodeMat.scale(
-				(max[0] - min[0]) / segments,
-				(max[1] - min[1]) / segments
+				( max[ 0 ] - min[ 0 ] ) / segments,
+				( max[ 1 ] - min[ 1 ] ) / segments
 			);
 
-			decodeMat.elements[6] = min[0];
-			decodeMat.elements[7] = min[1];
+			decodeMat.elements[ 6 ] = min[ 0 ];
+			decodeMat.elements[ 7 ] = min[ 1 ];
 
 			decodeMat.transpose();
 
-			let multiplier = new Float32Array([
-				max[0] !== min[0] ? segments / (max[0] - min[0]) : 0,
-				max[1] !== min[1] ? segments / (max[1] - min[1]) : 0
-			]);
+			let multiplier = new Float32Array( [
+				max[ 0 ] !== min[ 0 ] ? segments / ( max[ 0 ] - min[ 0 ] ) : 0,
+				max[ 1 ] !== min[ 1 ] ? segments / ( max[ 1 ] - min[ 1 ] ) : 0
+			] );
 
-			for (let i = 0; i < array.length; i += 2) {
+			for ( let i = 0; i < array.length; i += 2 ) {
 
-				quantized[i + 0] = Math.floor((array[i + 0] - min[0]) * multiplier[0]);
-				quantized[i + 1] = Math.floor((array[i + 1] - min[1]) * multiplier[1]);
+				quantized[ i + 0 ] = Math.floor( ( array[ i + 0 ] - min[ 0 ] ) * multiplier[ 0 ] );
+				quantized[ i + 1 ] = Math.floor( ( array[ i + 1 ] - min[ 1 ] ) * multiplier[ 1 ] );
 
 			}
 
@@ -680,12 +680,12 @@ var GeometryCompressionUtils = {
  *
  * @param {Object} parameters
  */
-function PackedPhongMaterial(parameters) {
+function PackedPhongMaterial ( parameters ) {
 
-	MeshPhongMaterial.call(this);
+	MeshPhongMaterial.call( this );
 	this.defines = {};
 	this.type = 'PackedPhongMaterial';
-	this.uniforms = UniformsUtils.merge([
+	this.uniforms = UniformsUtils.merge( [
 
 		ShaderLib.phong.uniforms,
 
@@ -694,7 +694,7 @@ function PackedPhongMaterial(parameters) {
 			quantizeMatUV: { value: null }
 		}
 
-	]);
+	] );
 
 	this.vertexShader = [
 		"#define PHONG",
@@ -912,12 +912,12 @@ function PackedPhongMaterial(parameters) {
 		ShaderChunk.premultiplied_alpha_fragment,
 		ShaderChunk.dithering_fragment,
 		"}",
-	].join("\n");
+	].join( "\n" );
 
-	this.setValues(parameters);
+	this.setValues( parameters );
 
 }
 
-PackedPhongMaterial.prototype = Object.create(MeshPhongMaterial.prototype);
+PackedPhongMaterial.prototype = Object.create( MeshPhongMaterial.prototype );
 
 export { GeometryCompressionUtils, PackedPhongMaterial };