Parcourir la source

Geometry: normalize clean up.

Mr.doob il y a 10 ans
Parent
commit
f8fe602fd7
1 fichiers modifiés avec 12 ajouts et 10 suppressions
  1. 12 10
      src/core/Geometry.js

+ 12 - 10
src/core/Geometry.js

@@ -220,22 +220,24 @@ THREE.Geometry.prototype = {
 
 	},
 
-	normalize: function() {
+	normalize: function () {
 
 		this.computeBoundingSphere();
 
-		var COM = this.boundingSphere.center;
-		var R = this.boundingSphere.radius;
+		var center = this.boundingSphere.center;
+		var radius = this.boundingSphere.radius;
 
-		var s = (R === 0 ? 1 : 1.0 / R);
+		var s = radius === 0 ? 1 : 1.0 / radius;
 
-		var m = new THREE.Matrix4().set(
-			s, 0, 0, -s * COM.x,
-			0, s, 0, -s * COM.y,
-			0, 0, s, -s * COM.z,
-			0, 0, 0, 1 );
+		var matrix = new THREE.Matrix4();
+		matrix.set(
+			s, 0, 0, -s * center.x,
+			0, s, 0, -s * center.y,
+			0, 0, s, -s * center.z,
+			0, 0, 0, 1
+		);
 
-		this.applyMatrix( m );
+		this.applyMatrix( matrix );
 
 		return this;
 	},