Browse Source

BufferGeometry: computeBoundingSphere() robustness. Fixes #9021.

Mr.doob 9 years ago
parent
commit
fbf9be7a1a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      src/core/BufferGeometry.js

+ 5 - 4
src/core/BufferGeometry.js

@@ -589,13 +589,14 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 			}
 
-			var positions = this.attributes.position.array;
+			var positions = this.attributes.position;
 
 			if ( positions ) {
 
+				var array = positions.array;
 				var center = this.boundingSphere.center;
 
-				box.setFromArray( positions );
+				box.setFromArray( array );
 				box.center( center );
 
 				// hoping to find a boundingSphere with a radius smaller than the
@@ -603,9 +604,9 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 				var maxRadiusSq = 0;
 
-				for ( var i = 0, il = positions.length; i < il; i += 3 ) {
+				for ( var i = 0, il = array.length; i < il; i += 3 ) {
 
-					vector.fromArray( positions, i );
+					vector.fromArray( array, i );
 					maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
 
 				}