Browse Source

Removed face.centroid and geometry.computeCentroids()
centroid was originally used by CanvasRenderer, now that it computes it as needed we don't need the bloat anymore.

Mr.doob 11 years ago
parent
commit
f46a2b841e
47 changed files with 56 additions and 125 deletions
  1. 0 5
      docs/api/core/Face3.html
  2. 0 5
      docs/api/core/Geometry.html
  3. 0 2
      examples/canvas_geometry_terrain.html
  4. 2 0
      examples/js/Octree.js
  5. 0 2
      examples/js/geometries/ConvexGeometry.js
  6. 0 1
      examples/js/loaders/AssimpJSONLoader.js
  7. 0 1
      examples/js/loaders/BinaryLoader.js
  8. 0 1
      examples/js/loaders/ColladaLoader.js
  9. 0 1
      examples/js/loaders/OBJLoader.js
  10. 0 1
      examples/js/loaders/OBJMTLLoader.js
  11. 0 1
      examples/js/loaders/PLYLoader.js
  12. 0 2
      examples/js/loaders/STLLoader.js
  13. 0 1
      examples/js/loaders/VTKLoader.js
  14. 0 1
      examples/js/loaders/gltf/glTFLoader.js
  15. 1 1
      examples/js/modifiers/SubdivisionModifier.js
  16. 4 1
      examples/js/renderers/SVGRenderer.js
  17. 0 1
      examples/misc_ubiquity_test.html
  18. 0 1
      examples/obj/Bird.js
  19. 0 1
      examples/obj/Qrcode.js
  20. 9 3
      examples/webgl_geometry_normals.html
  21. 0 2
      examples/webgl_geometry_subdivision.html
  22. 0 1
      examples/webgl_gpgpu_birds.html
  23. 1 1
      examples/webgl_interactive_buffergeometry.html
  24. 0 1
      examples/webgl_particles_shapes.html
  25. 0 3
      src/core/Face3.js
  26. 0 20
      src/core/Geometry.js
  27. 0 2
      src/core/Projector.js
  28. 0 8
      src/extras/GeometryUtils.js
  29. 2 3
      src/extras/core/CurvePath.js
  30. 0 1
      src/extras/geometries/BoxGeometry.js
  31. 0 1
      src/extras/geometries/CircleGeometry.js
  32. 0 1
      src/extras/geometries/CylinderGeometry.js
  33. 1 3
      src/extras/geometries/ExtrudeGeometry.js
  34. 0 1
      src/extras/geometries/LatheGeometry.js
  35. 0 1
      src/extras/geometries/ParametricGeometry.js
  36. 0 2
      src/extras/geometries/PlaneGeometry.js
  37. 7 5
      src/extras/geometries/PolyhedronGeometry.js
  38. 0 1
      src/extras/geometries/RingGeometry.js
  39. 0 1
      src/extras/geometries/ShapeGeometry.js
  40. 0 1
      src/extras/geometries/SphereGeometry.js
  41. 0 1
      src/extras/geometries/TorusGeometry.js
  42. 0 1
      src/extras/geometries/TorusKnotGeometry.js
  43. 0 1
      src/extras/geometries/TubeGeometry.js
  44. 25 27
      src/extras/helpers/FaceNormalsHelper.js
  45. 0 1
      src/loaders/JSONLoader.js
  46. 4 1
      src/renderers/CanvasRenderer.js
  47. 0 2
      src/renderers/renderables/RenderableFace.js

+ 0 - 5
docs/api/core/Face3.html

@@ -81,11 +81,6 @@
 		Material index (points to [page:MeshFaceMaterial MeshFaceMaterial.materials]).
 		Material index (points to [page:MeshFaceMaterial MeshFaceMaterial.materials]).
 		</div>
 		</div>
 
 
-		<h3>.[page:Vector3 centroid]</h3>
-		<div>
-		Face centroid.
-		</div>
-
 		<h2>Methods</h2>
 		<h2>Methods</h2>
 
 
 		<h3>.clone()</h3>
 		<h3>.clone()</h3>

+ 0 - 5
docs/api/core/Geometry.html

@@ -188,11 +188,6 @@
 		Bakes matrix transform directly into vertex coordinates.
 		Bakes matrix transform directly into vertex coordinates.
 		</div>
 		</div>
 
 
-		<h3>.computeCentroids()</h3>
-		<div>
-		Computes centroids for all faces.
-		</div>
-
 		<h3>.computeFaceNormals()</h3>
 		<h3>.computeFaceNormals()</h3>
 		<div>
 		<div>
 		Computes face normals.
 		Computes face normals.

+ 0 - 2
examples/canvas_geometry_terrain.html

@@ -82,8 +82,6 @@
 
 
 				}
 				}
 
 
-				plane.computeCentroids();
-
 				mesh = new THREE.Mesh( plane, material );
 				mesh = new THREE.Mesh( plane, material );
 				scene.add( mesh );
 				scene.add( mesh );
 
 

+ 2 - 0
examples/js/Octree.js

@@ -686,6 +686,8 @@
 		},
 		},
 		
 		
 		getFace3BoundingRadius: function ( object, face ) {
 		getFace3BoundingRadius: function ( object, face ) {
+
+			if ( face.centroid === undefined ) face.centroid = new THREE.Vector3();
 			
 			
 			var geometry = object.geometry || object,
 			var geometry = object.geometry || object,
 				vertices = geometry.vertices,
 				vertices = geometry.vertices,

+ 0 - 2
examples/js/geometries/ConvexGeometry.js

@@ -213,8 +213,6 @@ THREE.ConvexGeometry = function( vertices ) {
 
 
 	}
 	}
 
 
-
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 	this.computeVertexNormals();
 
 

+ 0 - 1
examples/js/loaders/AssimpJSONLoader.js

@@ -158,7 +158,6 @@ THREE.AssimpJSONLoader.prototype = {
 		}
 		}
 
 
 
 
-		geometry.computeCentroids();
 		//geometry.computeFaceNormals();
 		//geometry.computeFaceNormals();
 		//geometry.computeVertexNormals();
 		//geometry.computeVertexNormals();
 		//geometry.computeTangents();
 		//geometry.computeTangents();

+ 0 - 1
examples/js/loaders/BinaryLoader.js

@@ -208,7 +208,6 @@ THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texture
 		init_quads_flat( start_quad_flat );
 		init_quads_flat( start_quad_flat );
 		init_quads_smooth( start_quad_smooth );
 		init_quads_smooth( start_quad_smooth );
 
 
-		this.computeCentroids();
 		this.computeFaceNormals();
 		this.computeFaceNormals();
 
 
 		function handlePadding( n ) {
 		function handlePadding( n ) {

+ 0 - 1
examples/js/loaders/ColladaLoader.js

@@ -2616,7 +2616,6 @@ THREE.ColladaLoader = function () {
 
 
 		}
 		}
 
 
-		this.geometry3js.computeCentroids();
 		this.geometry3js.computeFaceNormals();
 		this.geometry3js.computeFaceNormals();
 
 
 		if ( this.geometry3js.calcNormals ) {
 		if ( this.geometry3js.calcNormals ) {

+ 0 - 1
examples/js/loaders/OBJLoader.js

@@ -315,7 +315,6 @@ THREE.OBJLoader.prototype = {
 
 
 			var geometry = children[ i ].geometry;
 			var geometry = children[ i ].geometry;
 
 
-			geometry.computeCentroids();
 			geometry.computeFaceNormals();
 			geometry.computeFaceNormals();
 			geometry.computeBoundingSphere();
 			geometry.computeBoundingSphere();
 
 

+ 0 - 1
examples/js/loaders/OBJMTLLoader.js

@@ -87,7 +87,6 @@ THREE.OBJMTLLoader.prototype = {
 				geometry.vertices = vertices;
 				geometry.vertices = vertices;
 
 
 				geometry.mergeVertices();
 				geometry.mergeVertices();
-				geometry.computeCentroids();
 				geometry.computeFaceNormals();
 				geometry.computeFaceNormals();
 				geometry.computeBoundingSphere();
 				geometry.computeBoundingSphere();
 
 

+ 0 - 1
examples/js/loaders/PLYLoader.js

@@ -311,7 +311,6 @@ THREE.PLYLoader.prototype = {
 			
 			
 		}
 		}
 
 
-		geometry.computeCentroids();
 		geometry.computeBoundingSphere();
 		geometry.computeBoundingSphere();
 
 
 		return geometry;
 		return geometry;

+ 0 - 2
examples/js/loaders/STLLoader.js

@@ -136,7 +136,6 @@ THREE.STLLoader.prototype.parseBinary = function (data) {
 
 
 	}
 	}
 
 
-	geometry.computeCentroids();
 	geometry.computeBoundingSphere();
 	geometry.computeBoundingSphere();
 
 
 	return geometry;
 	return geometry;
@@ -174,7 +173,6 @@ THREE.STLLoader.prototype.parseASCII = function (data) {
 
 
 	}
 	}
 
 
-	geometry.computeCentroids();
 	geometry.computeBoundingBox();
 	geometry.computeBoundingBox();
 	geometry.computeBoundingSphere();
 	geometry.computeBoundingSphere();
 
 

+ 0 - 1
examples/js/loaders/VTKLoader.js

@@ -95,7 +95,6 @@ THREE.VTKLoader.prototype = {
 
 
 		}
 		}
 
 
-		geometry.computeCentroids();
 		geometry.computeFaceNormals();
 		geometry.computeFaceNormals();
 		geometry.computeVertexNormals();
 		geometry.computeVertexNormals();
 		geometry.computeBoundingSphere();
 		geometry.computeBoundingSphere();

+ 0 - 1
examples/js/loaders/gltf/glTFLoader.js

@@ -133,7 +133,6 @@ THREE.glTFLoader.prototype.load = function( url, callback ) {
         // Allow Three.js to calculate some values for us
         // Allow Three.js to calculate some values for us
         geometry.computeBoundingBox();
         geometry.computeBoundingBox();
         geometry.computeBoundingSphere();
         geometry.computeBoundingSphere();
-        geometry.computeCentroids();
         geometry.computeFaceNormals();
         geometry.computeFaceNormals();
         if(!normals) {
         if(!normals) {
             geometry.computeVertexNormals();
             geometry.computeVertexNormals();

+ 1 - 1
examples/js/modifiers/SubdivisionModifier.js

@@ -31,7 +31,7 @@ THREE.SubdivisionModifier.prototype.modify = function ( geometry ) {
 	}
 	}
 
 
 	delete geometry.__tmpVertices;
 	delete geometry.__tmpVertices;
-	geometry.computeCentroids();
+
 	geometry.computeFaceNormals();
 	geometry.computeFaceNormals();
 	geometry.computeVertexNormals();
 	geometry.computeVertexNormals();
 
 

+ 4 - 1
examples/js/renderers/SVGRenderer.js

@@ -25,6 +25,7 @@ THREE.SVGRenderer = function () {
 
 
 	_w, // z-buffer to w-buffer
 	_w, // z-buffer to w-buffer
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
+	_centroid = new THREE.Vector3(),
 
 
 	_svgPathPool = [], _svgLinePool = [], _svgRectPool = [],
 	_svgPathPool = [], _svgLinePool = [], _svgRectPool = [],
 	_svgNode, _pathCount = 0, _lineCount = 0, _rectCount = 0,
 	_svgNode, _pathCount = 0, _lineCount = 0, _rectCount = 0,
@@ -329,7 +330,9 @@ THREE.SVGRenderer = function () {
 
 
 			_color.copy( _ambientLight );
 			_color.copy( _ambientLight );
 
 
-			calculateLight( _lights, element.centroidModel, element.normalModel, _color );
+			_centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 );
+
+			calculateLight( _lights, _centroid, element.normalModel, _color );
 
 
 			_color.multiply( _diffuseColor ).add( material.emissive );
 			_color.multiply( _diffuseColor ).add( material.emissive );
 
 

+ 0 - 1
examples/misc_ubiquity_test.html

@@ -135,7 +135,6 @@
 				}
 				}
 
 
 				geometry.computeFaceNormals();
 				geometry.computeFaceNormals();
-				geometry.computeCentroids();
 
 
 				group = new THREE.Mesh( geometry, material );
 				group = new THREE.Mesh( geometry, material );
 				group.scale.set( 2, 2, 2 );
 				group.scale.set( 2, 2, 2 );

+ 0 - 1
examples/obj/Bird.js

@@ -20,7 +20,6 @@ var Bird = function () {
 	f3( 4, 7, 6 );
 	f3( 4, 7, 6 );
 	f3( 5, 6, 7 );
 	f3( 5, 6, 7 );
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	function v( x, y, z ) {
 	function v( x, y, z ) {

+ 0 - 1
examples/obj/Qrcode.js

@@ -1434,7 +1434,6 @@ var Qrcode = function () {
 	f4(20,21,363,362,color2);
 	f4(20,21,363,362,color2);
 	f4(19,20,362,361,color2);
 	f4(19,20,362,361,color2);
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	function v( x, y, z ) {
 	function v( x, y, z ) {

+ 9 - 3
examples/webgl_geometry_normals.html

@@ -15,7 +15,7 @@
 	</head>
 	</head>
 	<body>
 	<body>
 
 
-		<script src="../build/three.js"></script>
+		<script src="../build/three.min.js"></script>
 		<script src="js/controls/OrbitControls.js"></script>
 		<script src="js/controls/OrbitControls.js"></script>
 		<script src="js/libs/stats.min.js"></script>
 		<script src="js/libs/stats.min.js"></script>
 		<script src="fonts/helvetiker_regular.typeface.js"></script>
 		<script src="fonts/helvetiker_regular.typeface.js"></script>
@@ -182,7 +182,6 @@
 
 
 				// in case of duplicated vertices
 				// in case of duplicated vertices
 				geometry.mergeVertices();
 				geometry.mergeVertices();
-				geometry.computeCentroids();
 				geometry.computeFaceNormals();
 				geometry.computeFaceNormals();
 				geometry.computeVertexNormals( true );
 				geometry.computeVertexNormals( true );
 
 
@@ -225,9 +224,16 @@
 
 
 				for( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
 				for( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
 					var face = geometry.faces[ f ];
 					var face = geometry.faces[ f ];
+
+					var centroid = new THREE.Vector3()
+						.add( geometry.vertices[ face.a ] )
+						.add( geometry.vertices[ face.b ] )
+						.add( geometry.vertices[ face.c ] )
+						.divideScalar( 3 );
+
 					var arrow = new THREE.ArrowHelper( 
 					var arrow = new THREE.ArrowHelper( 
 							face.normal,
 							face.normal,
-							face.centroid,
+							centroid,
 							normalLength,
 							normalLength,
 							0x3333FF );
 							0x3333FF );
 					mesh.add( arrow );
 					mesh.add( arrow );

+ 0 - 2
examples/webgl_geometry_subdivision.html

@@ -206,8 +206,6 @@
 
 
 				// mergeVertices(); is run in case of duplicated vertices
 				// mergeVertices(); is run in case of duplicated vertices
 				smooth.mergeVertices();
 				smooth.mergeVertices();
-
-				smooth.computeCentroids();
 				smooth.computeFaceNormals();
 				smooth.computeFaceNormals();
 				smooth.computeVertexNormals();
 				smooth.computeVertexNormals();
 
 

+ 0 - 1
examples/webgl_gpgpu_birds.html

@@ -464,7 +464,6 @@
 
 
 				this.applyMatrix( new THREE.Matrix4().makeScale( 0.2, 0.2, 0.2 ) );
 				this.applyMatrix( new THREE.Matrix4().makeScale( 0.2, 0.2, 0.2 ) );
 
 
-				this.computeCentroids();
 				this.computeFaceNormals();
 				this.computeFaceNormals();
 				this.computeVertexNormals();
 				this.computeVertexNormals();
 
 

+ 1 - 1
examples/webgl_interactive_buffergeometry.html

@@ -204,7 +204,7 @@
 				mouse = new THREE.Vector2();
 				mouse = new THREE.Vector2();
 
 
 				var geometry = new THREE.BufferGeometry();
 				var geometry = new THREE.BufferGeometry();
-				geometry.addAttribute( 'position', Float32Array, 4, 3 );
+				geometry.addAttribute( 'position', new Float32Array( 4 * 3 ), 3 );
 
 
 				var material = new THREE.LineBasicMaterial( { color: 0xffffff, linewidth: 2, transparent: true } );
 				var material = new THREE.LineBasicMaterial( { color: 0xffffff, linewidth: 2, transparent: true } );
 
 

+ 0 - 1
examples/webgl_particles_shapes.html

@@ -472,7 +472,6 @@
 
 
 
 
 				sparksEmitter.addInitializer( new SPARKS.Velocity( new SPARKS.PointZone( new THREE.Vector3( 0, -5, 1 ) ) ) );
 				sparksEmitter.addInitializer( new SPARKS.Velocity( new SPARKS.PointZone( new THREE.Vector3( 0, -5, 1 ) ) ) );
-				// TOTRY Set velocity to move away from centroid
 
 
 				sparksEmitter.addAction( new SPARKS.Age() );
 				sparksEmitter.addAction( new SPARKS.Age() );
 				sparksEmitter.addAction( new SPARKS.Accelerate( 0, 0, -50 ) );
 				sparksEmitter.addAction( new SPARKS.Accelerate( 0, 0, -50 ) );

+ 0 - 3
src/core/Face3.js

@@ -19,8 +19,6 @@ THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {
 
 
 	this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
 	this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
 
 
-	this.centroid = new THREE.Vector3();
-
 };
 };
 
 
 THREE.Face3.prototype = {
 THREE.Face3.prototype = {
@@ -33,7 +31,6 @@ THREE.Face3.prototype = {
 
 
 		face.normal.copy( this.normal );
 		face.normal.copy( this.normal );
 		face.color.copy( this.color );
 		face.color.copy( this.color );
-		face.centroid.copy( this.centroid );
 
 
 		face.materialIndex = this.materialIndex;
 		face.materialIndex = this.materialIndex;
 
 

+ 0 - 20
src/core/Geometry.js

@@ -77,8 +77,6 @@ THREE.Geometry.prototype = {
 
 
 			}
 			}
 
 
-			face.centroid.applyMatrix4( matrix );
-
 		}
 		}
 
 
 		if ( this.boundingBox instanceof THREE.Box3 ) {
 		if ( this.boundingBox instanceof THREE.Box3 ) {
@@ -95,24 +93,6 @@ THREE.Geometry.prototype = {
 
 
 	},
 	},
 
 
-	computeCentroids: function () {
-
-		var f, fl, face;
-
-		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
-
-			face = this.faces[ f ];
-			face.centroid.set( 0, 0, 0 );
-
-			face.centroid.add( this.vertices[ face.a ] );
-			face.centroid.add( this.vertices[ face.b ] );
-			face.centroid.add( this.vertices[ face.c ] );
-			face.centroid.divideScalar( 3 );
-
-		}
-
-	},
-
 	computeFaceNormals: function () {
 	computeFaceNormals: function () {
 
 
 		var cb = new THREE.Vector3(), ab = new THREE.Vector3();
 		var cb = new THREE.Vector3(), ab = new THREE.Vector3();

+ 0 - 2
src/core/Projector.js

@@ -476,8 +476,6 @@ THREE.Projector = function () {
 
 
 						_face.normalModel.applyMatrix3( _normalMatrix ).normalize();
 						_face.normalModel.applyMatrix3( _normalMatrix ).normalize();
 
 
-						_face.centroidModel.copy( face.centroid ).applyMatrix4( _modelMatrix );
-
 						faceVertexNormals = face.vertexNormals;
 						faceVertexNormals = face.vertexNormals;
 
 
 						for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) {
 						for ( var n = 0, nl = Math.min( faceVertexNormals.length, 3 ); n < nl; n ++ ) {

+ 0 - 8
src/extras/GeometryUtils.js

@@ -88,14 +88,6 @@ THREE.GeometryUtils = {
 
 
 			faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
 			faceCopy.materialIndex = face.materialIndex + materialIndexOffset;
 
 
-			faceCopy.centroid.copy( face.centroid );
-
-			if ( matrix ) {
-
-				faceCopy.centroid.applyMatrix4( matrix );
-
-			}
-
 			faces1.push( faceCopy );
 			faces1.push( faceCopy );
 
 
 		}
 		}

+ 2 - 3
src/extras/core/CurvePath.js

@@ -134,7 +134,7 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
 
 
 
 
 
 
-// Returns min and max coordinates, as well as centroid
+// Returns min and max coordinates
 
 
 THREE.CurvePath.prototype.getBoundingBox = function () {
 THREE.CurvePath.prototype.getBoundingBox = function () {
 
 
@@ -178,8 +178,7 @@ THREE.CurvePath.prototype.getBoundingBox = function () {
 		minX: minX,
 		minX: minX,
 		minY: minY,
 		minY: minY,
 		maxX: maxX,
 		maxX: maxX,
-		maxY: maxY,
-		centroid: sum.divideScalar( il )
+		maxY: maxY
 
 
 	};
 	};
 
 

+ 0 - 1
src/extras/geometries/BoxGeometry.js

@@ -112,7 +112,6 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
 
 
 	}
 	}
 
 
-	this.computeCentroids();
 	this.mergeVertices();
 	this.mergeVertices();
 
 
 };
 };

+ 0 - 1
src/extras/geometries/CircleGeometry.js

@@ -44,7 +44,6 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
 
 
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );

+ 0 - 1
src/extras/geometries/CylinderGeometry.js

@@ -149,7 +149,6 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
 
 
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 }
 }

+ 1 - 3
src/extras/geometries/ExtrudeGeometry.js

@@ -39,7 +39,6 @@ THREE.ExtrudeGeometry = function ( shapes, options ) {
 
 
 	this.addShapeList( shapes, options );
 	this.addShapeList( shapes, options );
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	// can't really use automatic vertex normals
 	// can't really use automatic vertex normals
@@ -347,7 +346,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		for ( i = 0, il = contour.length; i < il; i ++ ) {
 		for ( i = 0, il = contour.length; i < il; i ++ ) {
 
 
 			vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
 			vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
-			//vert = scalePt( contour[ i ], contourCentroid, bs, false );
+
 			v( vert.x, vert.y,  - z );
 			v( vert.x, vert.y,  - z );
 
 
 		}
 		}
@@ -362,7 +361,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 			for ( i = 0, il = ahole.length; i < il; i++ ) {
 			for ( i = 0, il = ahole.length; i < il; i++ ) {
 
 
 				vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
 				vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
-				//vert = scalePt( ahole[ i ], holesCentroids[ h ], bs, true );
 
 
 				v( vert.x, vert.y,  -z );
 				v( vert.x, vert.y,  -z );
 
 

+ 0 - 1
src/extras/geometries/LatheGeometry.js

@@ -87,7 +87,6 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
 	}
 	}
 
 
 	this.mergeVertices();
 	this.mergeVertices();
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 	this.computeVertexNormals();
 
 

+ 0 - 1
src/extras/geometries/ParametricGeometry.js

@@ -68,7 +68,6 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) {
 	// var diff = this.mergeVertices();
 	// var diff = this.mergeVertices();
 	// console.log('removed ', diff, ' vertices by merging');
 	// console.log('removed ', diff, ' vertices by merging');
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 	this.computeVertexNormals();
 
 

+ 0 - 2
src/extras/geometries/PlaneGeometry.js

@@ -73,8 +73,6 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
 
 
 	}
 	}
 
 
-	this.computeCentroids();
-
 };
 };
 
 
 THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
 THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );

+ 7 - 5
src/extras/geometries/PolyhedronGeometry.js

@@ -22,6 +22,7 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 	var midpoints = [], p = this.vertices;
 	var midpoints = [], p = this.vertices;
 
 
 	var f = [];
 	var f = [];
+
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
 
 		var v1 = p[ faces[ i ][ 0 ] ];
 		var v1 = p[ faces[ i ][ 0 ] ];
@@ -32,6 +33,8 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 
 
 	}
 	}
 
 
+	var centroid = new THREE.Vector3();
+
 	for ( var i = 0, l = f.length; i < l; i ++ ) {
 	for ( var i = 0, l = f.length; i < l; i ++ ) {
 
 
 		subdivide(f[ i ], detail);
 		subdivide(f[ i ], detail);
@@ -76,8 +79,6 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 
 
 	this.mergeVertices();
 	this.mergeVertices();
 
 
-	this.computeCentroids();
-
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
@@ -106,10 +107,11 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 	function make( v1, v2, v3 ) {
 	function make( v1, v2, v3 ) {
 
 
 		var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
 		var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
-		face.centroid.add( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
 		that.faces.push( face );
 		that.faces.push( face );
 
 
-		var azi = azimuth( face.centroid );
+		centroid.copy( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
+
+		var azi = azimuth( centroid );
 
 
 		that.faceVertexUvs[ 0 ].push( [
 		that.faceVertexUvs[ 0 ].push( [
 			correctUV( v1.uv, v1, azi ),
 			correctUV( v1.uv, v1, azi ),
@@ -122,7 +124,7 @@ THREE.PolyhedronGeometry = function ( vertices, faces, radius, detail ) {
 
 
 	// Analytically subdivide a face to the required detail level.
 	// Analytically subdivide a face to the required detail level.
 
 
-	function subdivide(face, detail ) {
+	function subdivide( face, detail ) {
 
 
 		var cols = Math.pow(2, detail);
 		var cols = Math.pow(2, detail);
 		var cells = Math.pow(4, detail);
 		var cells = Math.pow(4, detail);

+ 0 - 1
src/extras/geometries/RingGeometry.js

@@ -62,7 +62,6 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm
 		}
 		}
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );

+ 0 - 1
src/extras/geometries/ShapeGeometry.js

@@ -24,7 +24,6 @@ THREE.ShapeGeometry = function ( shapes, options ) {
 
 
 	this.addShapeList( shapes, options );
 	this.addShapeList( shapes, options );
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 };
 };

+ 0 - 1
src/extras/geometries/SphereGeometry.js

@@ -91,7 +91,6 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
 
 
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
 	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );

+ 0 - 1
src/extras/geometries/TorusGeometry.js

@@ -64,7 +64,6 @@ THREE.TorusGeometry = function ( radius, tube, radialSegments, tubularSegments,
 
 
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
 };
 };

+ 0 - 1
src/extras/geometries/TorusKnotGeometry.js

@@ -79,7 +79,6 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
 		}
 		}
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 	this.computeVertexNormals();
 
 

+ 0 - 1
src/extras/geometries/TubeGeometry.js

@@ -119,7 +119,6 @@ THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed )
 		}
 		}
 	}
 	}
 
 
-	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 	this.computeVertexNormals();
 
 

+ 25 - 27
src/extras/helpers/FaceNormalsHelper.js

@@ -19,8 +19,7 @@ THREE.FaceNormalsHelper = function ( object, size, hex, linewidth ) {
 
 
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
 
-		geometry.vertices.push( new THREE.Vector3() );
-		geometry.vertices.push( new THREE.Vector3() );
+		geometry.vertices.push( new THREE.Vector3(), new THREE.Vector3() );
 
 
 	}
 	}
 
 
@@ -36,41 +35,40 @@ THREE.FaceNormalsHelper = function ( object, size, hex, linewidth ) {
 
 
 THREE.FaceNormalsHelper.prototype = Object.create( THREE.Line.prototype );
 THREE.FaceNormalsHelper.prototype = Object.create( THREE.Line.prototype );
 
 
-THREE.FaceNormalsHelper.prototype.update = ( function ( object ) {
+THREE.FaceNormalsHelper.prototype.update = function () {
 
 
-	var v1 = new THREE.Vector3();
+	var vertices = this.geometry.vertices;
 
 
-	return function ( object ) {
+	var object = this.object;
+	var objectVertices = object.geometry.vertices;
+	var objectFaces = object.geometry.faces;
+	var objectWorldMatrix = object.matrixWorld;
 
 
-		this.object.updateMatrixWorld( true );
+	object.updateMatrixWorld( true );
 
 
-		this.normalMatrix.getNormalMatrix( this.object.matrixWorld );
+	this.normalMatrix.getNormalMatrix( objectWorldMatrix );
 
 
-		var vertices = this.geometry.vertices;
+	for ( var i = 0, i2 = 0, l = objectFaces.length; i < l; i ++, i2 += 2 ) {
 
 
-		var faces = this.object.geometry.faces;
+		var face = objectFaces[ i ];
 
 
-		var worldMatrix = this.object.matrixWorld;
+		vertices[ i2 ].copy( objectVertices[ face.a ] )
+			.add( objectVertices[ face.b ] )
+			.add( objectVertices[ face.c ] )
+			.divideScalar( 3 )
+			.applyMatrix4( objectWorldMatrix );
 
 
-		for ( var i = 0, l = faces.length; i < l; i ++ ) {
+		vertices[ i2 + 1 ].copy( face.normal )
+			.applyMatrix3( this.normalMatrix )
+			.normalize()
+			.multiplyScalar( this.size )
+			.add( vertices[ i2 ] );
 
 
-			var face = faces[ i ];
-
-			v1.copy( face.normal ).applyMatrix3( this.normalMatrix ).normalize().multiplyScalar( this.size );
-
-			var idx = 2 * i;
-
-			vertices[ idx ].copy( face.centroid ).applyMatrix4( worldMatrix );
-
-			vertices[ idx + 1 ].addVectors( vertices[ idx ], v1 );
-
-		}
-
-		this.geometry.verticesNeedUpdate = true;
+	}
 
 
-		return this;
+	this.geometry.verticesNeedUpdate = true;
 
 
-	}
+	return this;
 
 
-}());
+};
 
 

+ 0 - 1
src/loaders/JSONLoader.js

@@ -113,7 +113,6 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) {
 	parseSkin();
 	parseSkin();
 	parseMorphing( scale );
 	parseMorphing( scale );
 
 
-	geometry.computeCentroids();
 	geometry.computeFaceNormals();
 	geometry.computeFaceNormals();
 	geometry.computeBoundingSphere();
 	geometry.computeBoundingSphere();
 
 

+ 4 - 1
src/renderers/CanvasRenderer.js

@@ -74,6 +74,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 	_pointLights = new THREE.Color(),
 	_pointLights = new THREE.Color(),
 
 
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
 	_vector3 = new THREE.Vector3(), // Needed for PointLight
+	_centroid = new THREE.Vector3(),
 	_normal = new THREE.Vector3(),
 	_normal = new THREE.Vector3(),
 	_normalViewMatrix = new THREE.Matrix3();
 	_normalViewMatrix = new THREE.Matrix3();
 
 
@@ -641,7 +642,9 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 
 			_color.copy( _ambientLight );
 			_color.copy( _ambientLight );
 
 
-			calculateLight( element.centroidModel, element.normalModel, _color );
+			_centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 );
+
+			calculateLight( _centroid, element.normalModel, _color );
 
 
 			_color.multiply( _diffuseColor ).add( _emissiveColor );
 			_color.multiply( _diffuseColor ).add( _emissiveColor );
 
 

+ 0 - 2
src/renderers/renderables/RenderableFace.js

@@ -10,8 +10,6 @@ THREE.RenderableFace = function () {
 	this.v2 = new THREE.RenderableVertex();
 	this.v2 = new THREE.RenderableVertex();
 	this.v3 = new THREE.RenderableVertex();
 	this.v3 = new THREE.RenderableVertex();
 
 
-	this.centroidModel = new THREE.Vector3();
-
 	this.normalModel = new THREE.Vector3();
 	this.normalModel = new THREE.Vector3();
 
 
 	this.vertexNormalsModel = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
 	this.vertexNormalsModel = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];