|
@@ -141,35 +141,48 @@ THREE.BufferGeometry.prototype = {
|
|
|
|
|
|
computeBoundingSphere: function () {
|
|
computeBoundingSphere: function () {
|
|
|
|
|
|
- if ( this.boundingSphere === null ) {
|
|
|
|
|
|
+ var box = new THREE.Box3();
|
|
|
|
+ var vector = new THREE.Vector3();
|
|
|
|
|
|
- this.boundingSphere = new THREE.Sphere();
|
|
|
|
|
|
+ return function () {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if ( this.boundingSphere === null ) {
|
|
|
|
|
|
- var positions = this.attributes[ "position" ].array;
|
|
|
|
|
|
+ this.boundingSphere = new THREE.Sphere();
|
|
|
|
|
|
- if ( positions ) {
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- var radiusSq, maxRadiusSq = 0;
|
|
|
|
- var x, y, z;
|
|
|
|
|
|
+ var positions = this.attributes[ "position" ].array;
|
|
|
|
|
|
- for ( var i = 0, il = positions.length; i < il; i += 3 ) {
|
|
|
|
|
|
+ if ( positions ) {
|
|
|
|
|
|
- x = positions[ i ];
|
|
|
|
- y = positions[ i + 1 ];
|
|
|
|
- z = positions[ i + 2 ];
|
|
|
|
|
|
+ var center = this.boundingSphere.center;
|
|
|
|
|
|
- radiusSq = x * x + y * y + z * z;
|
|
|
|
- if ( radiusSq > maxRadiusSq ) maxRadiusSq = radiusSq;
|
|
|
|
|
|
+ for ( var i = 0, il = positions.length; i < il; i += 3 ) {
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ vector.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
|
|
|
|
+ box.addPoint( vector );
|
|
|
|
|
|
- this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ box.center( center );
|
|
|
|
+
|
|
|
|
+ var maxRadiusSq = 0;
|
|
|
|
+
|
|
|
|
+ for ( var i = 0, il = positions.length; i < il; i += 3 ) {
|
|
|
|
+
|
|
|
|
+ vector.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
|
|
|
|
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }(),
|
|
|
|
|
|
computeVertexNormals: function () {
|
|
computeVertexNormals: function () {
|
|
|
|
|