Browse Source

Merge pull request #17184 from Mugen87/dev33

Helpers: Remove IIFEs I.
Mr.doob 6 years ago
parent
commit
d662925f3e

+ 22 - 26
src/helpers/ArrowHelper.js

@@ -24,7 +24,8 @@ import { Mesh } from '../objects/Mesh.js';
 import { Line } from '../objects/Line.js';
 import { Vector3 } from '../math/Vector3.js';
 
-var lineGeometry, coneGeometry;
+var _axis;
+var _lineGeometry, _coneGeometry;
 
 function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 
@@ -39,23 +40,23 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 	if ( headLength === undefined ) headLength = 0.2 * length;
 	if ( headWidth === undefined ) headWidth = 0.2 * headLength;
 
-	if ( lineGeometry === undefined ) {
+	if ( _lineGeometry === undefined ) {
 
-		lineGeometry = new BufferGeometry();
-		lineGeometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
+		_lineGeometry = new BufferGeometry();
+		_lineGeometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );
 
-		coneGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 );
-		coneGeometry.translate( 0, - 0.5, 0 );
+		_coneGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 );
+		_coneGeometry.translate( 0, - 0.5, 0 );
 
 	}
 
 	this.position.copy( origin );
 
-	this.line = new Line( lineGeometry, new LineBasicMaterial( { color: color } ) );
+	this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color } ) );
 	this.line.matrixAutoUpdate = false;
 	this.add( this.line );
 
-	this.cone = new Mesh( coneGeometry, new MeshBasicMaterial( { color: color } ) );
+	this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color } ) );
 	this.cone.matrixAutoUpdate = false;
 	this.add( this.cone );
 
@@ -67,36 +68,31 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 ArrowHelper.prototype = Object.create( Object3D.prototype );
 ArrowHelper.prototype.constructor = ArrowHelper;
 
-ArrowHelper.prototype.setDirection = ( function () {
+ArrowHelper.prototype.setDirection = function ( dir ) {
 
-	var axis = new Vector3();
-	var radians;
+	if ( _axis === undefined ) _axis = new Vector3();
 
-	return function setDirection( dir ) {
-
-		// dir is assumed to be normalized
-
-		if ( dir.y > 0.99999 ) {
+	// dir is assumed to be normalized
 
-			this.quaternion.set( 0, 0, 0, 1 );
+	if ( dir.y > 0.99999 ) {
 
-		} else if ( dir.y < - 0.99999 ) {
+		this.quaternion.set( 0, 0, 0, 1 );
 
-			this.quaternion.set( 1, 0, 0, 0 );
+	} else if ( dir.y < - 0.99999 ) {
 
-		} else {
+		this.quaternion.set( 1, 0, 0, 0 );
 
-			axis.set( dir.z, 0, - dir.x ).normalize();
+	} else {
 
-			radians = Math.acos( dir.y );
+		_axis.set( dir.z, 0, - dir.x ).normalize();
 
-			this.quaternion.setFromAxisAngle( axis, radians );
+		var radians = Math.acos( dir.y );
 
-		}
+		this.quaternion.setFromAxisAngle( _axis, radians );
 
-	};
+	}
 
-}() );
+};
 
 ArrowHelper.prototype.setLength = function ( length, headLength, headWidth ) {
 

+ 40 - 41
src/helpers/BoxHelper.js

@@ -9,6 +9,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
+var _box;
+
 function BoxHelper( object, color ) {
 
 	this.object = object;
@@ -33,64 +35,61 @@ function BoxHelper( object, color ) {
 BoxHelper.prototype = Object.create( LineSegments.prototype );
 BoxHelper.prototype.constructor = BoxHelper;
 
-BoxHelper.prototype.update = ( function () {
-
-	var box = new Box3();
+BoxHelper.prototype.update = function ( object ) {
 
-	return function update( object ) {
+	if ( _box === undefined ) _box = new Box3();
 
-		if ( object !== undefined ) {
+	if ( object !== undefined ) {
 
-			console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' );
+		console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' );
 
-		}
+	}
 
-		if ( this.object !== undefined ) {
+	if ( this.object !== undefined ) {
 
-			box.setFromObject( this.object );
+		_box.setFromObject( this.object );
 
-		}
+	}
 
-		if ( box.isEmpty() ) return;
+	if ( _box.isEmpty() ) return;
 
-		var min = box.min;
-		var max = box.max;
+	var min = _box.min;
+	var max = _box.max;
 
-		/*
-		  5____4
-		1/___0/|
-		| 6__|_7
-		2/___3/
+	/*
+	  5____4
+	1/___0/|
+	| 6__|_7
+	2/___3/
 
-		0: max.x, max.y, max.z
-		1: min.x, max.y, max.z
-		2: min.x, min.y, max.z
-		3: max.x, min.y, max.z
-		4: max.x, max.y, min.z
-		5: min.x, max.y, min.z
-		6: min.x, min.y, min.z
-		7: max.x, min.y, min.z
-		*/
+	0: max.x, max.y, max.z
+	1: min.x, max.y, max.z
+	2: min.x, min.y, max.z
+	3: max.x, min.y, max.z
+	4: max.x, max.y, min.z
+	5: min.x, max.y, min.z
+	6: min.x, min.y, min.z
+	7: max.x, min.y, min.z
+	*/
 
-		var position = this.geometry.attributes.position;
-		var array = position.array;
+	var position = this.geometry.attributes.position;
+	var array = position.array;
 
-		array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z;
-		array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z;
-		array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z;
-		array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z;
-		array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z;
-		array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z;
-		array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z;
-		array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z;
+	array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z;
+	array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z;
+	array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z;
+	array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z;
+	array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z;
+	array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z;
+	array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z;
+	array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z;
 
-		position.needsUpdate = true;
+	position.needsUpdate = true;
 
-		this.geometry.computeBoundingSphere();
+	this.geometry.computeBoundingSphere();
 
-	};
 
-} )();
+};
 
 BoxHelper.prototype.setFromObject = function ( object ) {
 

+ 21 - 19
src/helpers/DirectionalLightHelper.js

@@ -11,6 +11,8 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 
+var _v1, _v2, _v3;
+
 function DirectionalLightHelper( light, size, color ) {
 
 	Object3D.call( this );
@@ -63,36 +65,36 @@ DirectionalLightHelper.prototype.dispose = function () {
 
 DirectionalLightHelper.prototype.update = function () {
 
-	var v1 = new Vector3();
-	var v2 = new Vector3();
-	var v3 = new Vector3();
+	if ( _v3 === undefined ) {
 
-	return function update() {
+		_v1 = new Vector3();
+		_v2 = new Vector3();
+		_v3 = new Vector3();
 
-		v1.setFromMatrixPosition( this.light.matrixWorld );
-		v2.setFromMatrixPosition( this.light.target.matrixWorld );
-		v3.subVectors( v2, v1 );
+	}
 
-		this.lightPlane.lookAt( v2 );
+	_v1.setFromMatrixPosition( this.light.matrixWorld );
+	_v2.setFromMatrixPosition( this.light.target.matrixWorld );
+	_v3.subVectors( _v2, _v1 );
 
-		if ( this.color !== undefined ) {
+	this.lightPlane.lookAt( _v2 );
 
-			this.lightPlane.material.color.set( this.color );
-			this.targetLine.material.color.set( this.color );
+	if ( this.color !== undefined ) {
 
-		} else {
+		this.lightPlane.material.color.set( this.color );
+		this.targetLine.material.color.set( this.color );
 
-			this.lightPlane.material.color.copy( this.light.color );
-			this.targetLine.material.color.copy( this.light.color );
+	} else {
 
-		}
+		this.lightPlane.material.color.copy( this.light.color );
+		this.targetLine.material.color.copy( this.light.color );
 
-		this.targetLine.lookAt( v2 );
-		this.targetLine.scale.z = v3.length();
+	}
 
-	};
+	this.targetLine.lookAt( _v2 );
+	this.targetLine.scale.z = _v3.length();
 
-}();
+};
 
 
 export { DirectionalLightHelper };

+ 33 - 31
src/helpers/FaceNormalsHelper.js

@@ -10,6 +10,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
+var _v1, _v2, _normalMatrix;
+
 function FaceNormalsHelper( object, size, hex, linewidth ) {
 
 	// FaceNormalsHelper only supports THREE.Geometry
@@ -58,61 +60,61 @@ function FaceNormalsHelper( object, size, hex, linewidth ) {
 FaceNormalsHelper.prototype = Object.create( LineSegments.prototype );
 FaceNormalsHelper.prototype.constructor = FaceNormalsHelper;
 
-FaceNormalsHelper.prototype.update = ( function () {
+FaceNormalsHelper.prototype.update = function () {
 
-	var v1 = new Vector3();
-	var v2 = new Vector3();
-	var normalMatrix = new Matrix3();
+	if ( _normalMatrix === undefined ) {
 
-	return function update() {
+		_v1 = new Vector3();
+		_v2 = new Vector3();
+		_normalMatrix = new Matrix3();
 
-		this.object.updateMatrixWorld( true );
+	}
 
-		normalMatrix.getNormalMatrix( this.object.matrixWorld );
+	this.object.updateMatrixWorld( true );
 
-		var matrixWorld = this.object.matrixWorld;
+	_normalMatrix.getNormalMatrix( this.object.matrixWorld );
 
-		var position = this.geometry.attributes.position;
+	var matrixWorld = this.object.matrixWorld;
 
-		//
+	var position = this.geometry.attributes.position;
 
-		var objGeometry = this.object.geometry;
+	//
 
-		var vertices = objGeometry.vertices;
+	var objGeometry = this.object.geometry;
 
-		var faces = objGeometry.faces;
+	var vertices = objGeometry.vertices;
 
-		var idx = 0;
+	var faces = objGeometry.faces;
 
-		for ( var i = 0, l = faces.length; i < l; i ++ ) {
+	var idx = 0;
 
-			var face = faces[ i ];
+	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
-			var normal = face.normal;
+		var face = faces[ i ];
 
-			v1.copy( vertices[ face.a ] )
-				.add( vertices[ face.b ] )
-				.add( vertices[ face.c ] )
-				.divideScalar( 3 )
-				.applyMatrix4( matrixWorld );
+		var normal = face.normal;
 
-			v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );
+		_v1.copy( vertices[ face.a ] )
+			.add( vertices[ face.b ] )
+			.add( vertices[ face.c ] )
+			.divideScalar( 3 )
+			.applyMatrix4( matrixWorld );
 
-			position.setXYZ( idx, v1.x, v1.y, v1.z );
+		_v2.copy( normal ).applyMatrix3( _normalMatrix ).normalize().multiplyScalar( this.size ).add( _v1 );
 
-			idx = idx + 1;
+		position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
 
-			position.setXYZ( idx, v2.x, v2.y, v2.z );
+		idx = idx + 1;
 
-			idx = idx + 1;
+		position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
 
-		}
+		idx = idx + 1;
 
-		position.needsUpdate = true;
+	}
 
-	};
+	position.needsUpdate = true;
 
-}() );
+};
 
 
 export { FaceNormalsHelper };

+ 22 - 21
src/helpers/HemisphereLightHelper.js

@@ -13,6 +13,8 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
 import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry.js';
 import { BufferAttribute } from '../core/BufferAttribute.js';
 
+var _vector, _color1, _color2;
+
 function HemisphereLightHelper( light, size, color ) {
 
 	Object3D.call( this );
@@ -54,43 +56,42 @@ HemisphereLightHelper.prototype.dispose = function () {
 
 HemisphereLightHelper.prototype.update = function () {
 
-	var vector = new Vector3();
-
-	var color1 = new Color();
-	var color2 = new Color();
-
-	return function update() {
+	if ( _color2 === undefined ) {
 
-		var mesh = this.children[ 0 ];
+		_vector = new Vector3();
+		_color1 = new Color();
+		_color2 = new Color();
 
-		if ( this.color !== undefined ) {
+	}
 
-			this.material.color.set( this.color );
+	var mesh = this.children[ 0 ];
 
-		} else {
+	if ( this.color !== undefined ) {
 
-			var colors = mesh.geometry.getAttribute( 'color' );
+		this.material.color.set( this.color );
 
-			color1.copy( this.light.color );
-			color2.copy( this.light.groundColor );
+	} else {
 
-			for ( var i = 0, l = colors.count; i < l; i ++ ) {
+		var colors = mesh.geometry.getAttribute( 'color' );
 
-				var color = ( i < ( l / 2 ) ) ? color1 : color2;
+		_color1.copy( this.light.color );
+		_color2.copy( this.light.groundColor );
 
-				colors.setXYZ( i, color.r, color.g, color.b );
+		for ( var i = 0, l = colors.count; i < l; i ++ ) {
 
-			}
+			var color = ( i < ( l / 2 ) ) ? _color1 : _color2;
 
-			colors.needsUpdate = true;
+			colors.setXYZ( i, color.r, color.g, color.b );
 
 		}
 
-		mesh.lookAt( vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
+		colors.needsUpdate = true;
 
-	};
+	}
 
-}();
+	mesh.lookAt( _vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
+
+};
 
 
 export { HemisphereLightHelper };

+ 4 - 8
src/helpers/LightProbeHelper.js

@@ -140,16 +140,12 @@ LightProbeHelper.prototype.dispose = function () {
 
 LightProbeHelper.prototype.onBeforeRender = function () {
 
-	return function update() {
+	this.position.copy( this.lightProbe.position );
 
-		this.position.copy( this.lightProbe.position );
+	this.scale.set( 1, 1, 1 ).multiplyScalar( this.size );
 
-		this.scale.set( 1, 1, 1 ).multiplyScalar( this.size );
+	this.material.uniforms.intensity.value = this.lightProbe.intensity;
 
-		this.material.uniforms.intensity.value = this.lightProbe.intensity;
-
-	};
-
-}();
+};
 
 export { LightProbeHelper };

+ 26 - 25
src/helpers/SkeletonHelper.js

@@ -16,6 +16,8 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { Object3D } from '../core/Object3D.js';
 
+var _vector, _boneMatrix, _matrixWorldInv;
+
 function getBoneList( object ) {
 
 	var boneList = [];
@@ -81,48 +83,47 @@ function SkeletonHelper( object ) {
 SkeletonHelper.prototype = Object.create( LineSegments.prototype );
 SkeletonHelper.prototype.constructor = SkeletonHelper;
 
-SkeletonHelper.prototype.updateMatrixWorld = function () {
-
-	var vector = new Vector3();
+SkeletonHelper.prototype.updateMatrixWorld = function ( force ) {
 
-	var boneMatrix = new Matrix4();
-	var matrixWorldInv = new Matrix4();
+	if ( _matrixWorldInv === undefined ) {
 
-	return function updateMatrixWorld( force ) {
+		_vector = new Vector3();
+		_boneMatrix = new Matrix4();
+		_matrixWorldInv = new Matrix4();
 
-		var bones = this.bones;
+	}
 
-		var geometry = this.geometry;
-		var position = geometry.getAttribute( 'position' );
+	var bones = this.bones;
 
-		matrixWorldInv.getInverse( this.root.matrixWorld );
+	var geometry = this.geometry;
+	var position = geometry.getAttribute( 'position' );
 
-		for ( var i = 0, j = 0; i < bones.length; i ++ ) {
+	_matrixWorldInv.getInverse( this.root.matrixWorld );
 
-			var bone = bones[ i ];
+	for ( var i = 0, j = 0; i < bones.length; i ++ ) {
 
-			if ( bone.parent && bone.parent.isBone ) {
+		var bone = bones[ i ];
 
-				boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld );
-				vector.setFromMatrixPosition( boneMatrix );
-				position.setXYZ( j, vector.x, vector.y, vector.z );
+		if ( bone.parent && bone.parent.isBone ) {
 
-				boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld );
-				vector.setFromMatrixPosition( boneMatrix );
-				position.setXYZ( j + 1, vector.x, vector.y, vector.z );
+			_boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld );
+			_vector.setFromMatrixPosition( _boneMatrix );
+			position.setXYZ( j, _vector.x, _vector.y, _vector.z );
 
-				j += 2;
+			_boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld );
+			_vector.setFromMatrixPosition( _boneMatrix );
+			position.setXYZ( j + 1, _vector.x, _vector.y, _vector.z );
 
-			}
+			j += 2;
 
 		}
 
-		geometry.getAttribute( 'position' ).needsUpdate = true;
+	}
 
-		Object3D.prototype.updateMatrixWorld.call( this, force );
+	geometry.getAttribute( 'position' ).needsUpdate = true;
 
-	};
+	Object3D.prototype.updateMatrixWorld.call( this, force );
 
-}();
+};
 
 export { SkeletonHelper };

+ 15 - 17
src/helpers/SpotLightHelper.js

@@ -11,6 +11,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
+var _vector;
+
 function SpotLightHelper( light, color ) {
 
 	Object3D.call( this );
@@ -68,34 +70,30 @@ SpotLightHelper.prototype.dispose = function () {
 
 SpotLightHelper.prototype.update = function () {
 
-	var vector = new Vector3();
-
-	return function update() {
-
-		this.light.updateMatrixWorld();
+	if ( _vector === undefined ) _vector = new Vector3();
 
-		var coneLength = this.light.distance ? this.light.distance : 1000;
-		var coneWidth = coneLength * Math.tan( this.light.angle );
+	this.light.updateMatrixWorld();
 
-		this.cone.scale.set( coneWidth, coneWidth, coneLength );
+	var coneLength = this.light.distance ? this.light.distance : 1000;
+	var coneWidth = coneLength * Math.tan( this.light.angle );
 
-		vector.setFromMatrixPosition( this.light.target.matrixWorld );
+	this.cone.scale.set( coneWidth, coneWidth, coneLength );
 
-		this.cone.lookAt( vector );
+	_vector.setFromMatrixPosition( this.light.target.matrixWorld );
 
-		if ( this.color !== undefined ) {
+	this.cone.lookAt( _vector );
 
-			this.cone.material.color.set( this.color );
+	if ( this.color !== undefined ) {
 
-		} else {
+		this.cone.material.color.set( this.color );
 
-			this.cone.material.color.copy( this.light.color );
+	} else {
 
-		}
+		this.cone.material.color.copy( this.light.color );
 
-	};
+	}
 
-}();
+};
 
 
 export { SpotLightHelper };

+ 47 - 46
src/helpers/VertexNormalsHelper.js

@@ -10,6 +10,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
+var _v1, _v2, _normalMatrix, _keys;
+
 function VertexNormalsHelper( object, size, hex, linewidth ) {
 
 	this.object = object;
@@ -57,97 +59,96 @@ function VertexNormalsHelper( object, size, hex, linewidth ) {
 VertexNormalsHelper.prototype = Object.create( LineSegments.prototype );
 VertexNormalsHelper.prototype.constructor = VertexNormalsHelper;
 
-VertexNormalsHelper.prototype.update = ( function () {
-
-	var v1 = new Vector3();
-	var v2 = new Vector3();
-	var normalMatrix = new Matrix3();
+VertexNormalsHelper.prototype.update = function () {
 
-	return function update() {
+	if ( _normalMatrix === undefined ) {
 
-		var keys = [ 'a', 'b', 'c' ];
+		_v1 = new Vector3();
+		_v2 = new Vector3();
+		_normalMatrix = new Matrix3();
+		_keys = [ 'a', 'b', 'c' ];
 
-		this.object.updateMatrixWorld( true );
+	}
 
-		normalMatrix.getNormalMatrix( this.object.matrixWorld );
+	this.object.updateMatrixWorld( true );
 
-		var matrixWorld = this.object.matrixWorld;
+	_normalMatrix.getNormalMatrix( this.object.matrixWorld );
 
-		var position = this.geometry.attributes.position;
+	var matrixWorld = this.object.matrixWorld;
 
-		//
+	var position = this.geometry.attributes.position;
 
-		var objGeometry = this.object.geometry;
+	//
 
-		if ( objGeometry && objGeometry.isGeometry ) {
+	var objGeometry = this.object.geometry;
 
-			var vertices = objGeometry.vertices;
+	if ( objGeometry && objGeometry.isGeometry ) {
 
-			var faces = objGeometry.faces;
+		var vertices = objGeometry.vertices;
 
-			var idx = 0;
+		var faces = objGeometry.faces;
 
-			for ( var i = 0, l = faces.length; i < l; i ++ ) {
+		var idx = 0;
 
-				var face = faces[ i ];
+		for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
-				for ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {
+			var face = faces[ i ];
 
-					var vertex = vertices[ face[ keys[ j ] ] ];
+			for ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {
 
-					var normal = face.vertexNormals[ j ];
+				var vertex = vertices[ face[ _keys[ j ] ] ];
 
-					v1.copy( vertex ).applyMatrix4( matrixWorld );
+				var normal = face.vertexNormals[ j ];
 
-					v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );
+				_v1.copy( vertex ).applyMatrix4( matrixWorld );
 
-					position.setXYZ( idx, v1.x, v1.y, v1.z );
+				_v2.copy( normal ).applyMatrix3( _normalMatrix ).normalize().multiplyScalar( this.size ).add( _v1 );
 
-					idx = idx + 1;
+				position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
 
-					position.setXYZ( idx, v2.x, v2.y, v2.z );
+				idx = idx + 1;
 
-					idx = idx + 1;
+				position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
 
-				}
+				idx = idx + 1;
 
 			}
 
-		} else if ( objGeometry && objGeometry.isBufferGeometry ) {
+		}
 
-			var objPos = objGeometry.attributes.position;
+	} else if ( objGeometry && objGeometry.isBufferGeometry ) {
 
-			var objNorm = objGeometry.attributes.normal;
+		var objPos = objGeometry.attributes.position;
 
-			var idx = 0;
+		var objNorm = objGeometry.attributes.normal;
 
-			// for simplicity, ignore index and drawcalls, and render every normal
+		var idx = 0;
 
-			for ( var j = 0, jl = objPos.count; j < jl; j ++ ) {
+		// for simplicity, ignore index and drawcalls, and render every normal
 
-				v1.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld );
+		for ( var j = 0, jl = objPos.count; j < jl; j ++ ) {
 
-				v2.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) );
+			_v1.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld );
 
-				v2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );
+			_v2.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) );
 
-				position.setXYZ( idx, v1.x, v1.y, v1.z );
+			_v2.applyMatrix3( _normalMatrix ).normalize().multiplyScalar( this.size ).add( _v1 );
 
-				idx = idx + 1;
+			position.setXYZ( idx, _v1.x, _v1.y, _v1.z );
 
-				position.setXYZ( idx, v2.x, v2.y, v2.z );
+			idx = idx + 1;
 
-				idx = idx + 1;
+			position.setXYZ( idx, _v2.x, _v2.y, _v2.z );
 
-			}
+			idx = idx + 1;
 
 		}
 
-		position.needsUpdate = true;
+	}
 
-	};
+	position.needsUpdate = true;
 
-}() );
+};
 
 
 export { VertexNormalsHelper };