Browse Source

Box3: Refactored .setFromObject()

Mugen87 8 years ago
parent
commit
08a93236a2
1 changed files with 6 additions and 19 deletions
  1. 6 19
      src/math/Box3.js

+ 6 - 19
src/math/Box3.js

@@ -131,6 +131,7 @@ Box3.prototype = {
 		return function setFromObject( object ) {
 		return function setFromObject( object ) {
 
 
 			var scope = this;
 			var scope = this;
+			var i, l;
 
 
 			object.updateMatrixWorld( true );
 			object.updateMatrixWorld( true );
 
 
@@ -146,7 +147,7 @@ Box3.prototype = {
 
 
 						var vertices = geometry.vertices;
 						var vertices = geometry.vertices;
 
 
-						for ( var i = 0, il = vertices.length; i < il; i ++ ) {
+						for ( i = 0, il = vertices.length; i < il; i ++ ) {
 
 
 							v1.copy( vertices[ i ] );
 							v1.copy( vertices[ i ] );
 							v1.applyMatrix4( node.matrixWorld );
 							v1.applyMatrix4( node.matrixWorld );
@@ -161,25 +162,11 @@ Box3.prototype = {
 
 
 						if ( attribute !== undefined ) {
 						if ( attribute !== undefined ) {
 
 
-							var array, offset, stride;
+							for ( i = 0, l = attribute.count; i < l; i ++ ) {
 
 
-							if ( attribute.isInterleavedBufferAttribute ) {
-
-								array = attribute.data.array;
-								offset = attribute.offset;
-								stride = attribute.data.stride;
-
-							} else {
-
-								array = attribute.array;
-								offset = 0;
-								stride = 3;
-
-							}
-
-							for ( var i = offset, il = array.length; i < il; i += stride ) {
-
-								v1.fromArray( array, i );
+								v1.x = attribute.getX( i );
+								v1.y = attribute.getY( i );
+								v1.z = attribute.getZ( i );
 								v1.applyMatrix4( node.matrixWorld );
 								v1.applyMatrix4( node.matrixWorld );
 
 
 								scope.expandByPoint( v1 );
 								scope.expandByPoint( v1 );