提交 859f5077 编写于 作者: M Mr.doob

Updated builds.

上级 1de68da7
......@@ -3466,48 +3466,52 @@ THREE.Box3.prototype = {
},
setFromPoints: function ( points ) {
addPoint: function ( point ) {
if ( points.length > 0 ) {
if ( point.x < this.min.x ) {
var point = points[ 0 ];
this.min.x = point.x;
this.min.copy( point );
this.max.copy( point );
} else if ( point.x > this.max.x ) {
for ( var i = 1, il = points.length; i < il; i ++ ) {
this.max.x = point.x;
point = points[ i ];
}
if ( point.x < this.min.x ) {
if ( point.y < this.min.y ) {
this.min.x = point.x;
this.min.y = point.y;
} else if ( point.x > this.max.x ) {
} else if ( point.y > this.max.y ) {
this.max.x = point.x;
this.max.y = point.y;
}
}
if ( point.y < this.min.y ) {
if ( point.z < this.min.z ) {
this.min.y = point.y;
this.min.z = point.z;
} else if ( point.y > this.max.y ) {
} else if ( point.z > this.max.z ) {
this.max.y = point.y;
this.max.z = point.z;
}
}
if ( point.z < this.min.z ) {
},
this.min.z = point.z;
setFromPoints: function ( points ) {
} else if ( point.z > this.max.z ) {
if ( points.length > 0 ) {
this.max.z = point.z;
var point = points[ 0 ];
}
this.min.copy( point );
this.max.copy( point );
for ( var i = 1, il = points.length; i < il; i ++ ) {
this.addPoint( points[ i ] )
}
......@@ -5505,25 +5509,30 @@ THREE.Sphere.prototype = {
setFromPoints: function () {
var _box = new THREE.Box3();
var _center = new THREE.Vector3();
var box = new THREE.Box3();
return function ( points, optionalCenter ) {
// use boundingBox center as sphere center
var center = this.center;
if ( optionalCenter !== undefined ) {
var center = optionalCenter || _box.setFromPoints( points ).center( _center );
center.copy( optionalCenter );
} else {
box.setFromPoints( points ).center( center );
}
var maxRadiusSq = 0;
for ( var i = 0, il = points.length; i < il; i ++ ) {
var radiusSq = center.distanceToSquared( points[ i ] );
maxRadiusSq = Math.max( maxRadiusSq, radiusSq );
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
}
this.center.copy( center );
this.radius = Math.sqrt( maxRadiusSq );
return this;
......@@ -9108,35 +9117,48 @@ THREE.BufferGeometry.prototype = {
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 );
}
box.center( center );
var maxRadiusSq = 0;
for ( var i = 0, il = positions.length; i < il; i += 3 ) {
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
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 () {
......@@ -11223,7 +11245,7 @@ THREE.BufferGeometryLoader.prototype = {
if ( boundingSphere !== undefined ) {
geometry.boundingSphere = new THREE.Sphere( undefined, boundingSphere.radius );
geometry.boundingSphere = new THREE.Sphere( boundingSphere.center, boundingSphere.radius );
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册