提交 82517012 编写于 作者: B Ben Houston

optimize Box3.setFromPoints to be as fast as previous code in Geometry.js

上级 b50a1a52
......@@ -29,10 +29,40 @@ THREE.Box3.prototype = {
setFromPoints: function ( points ) {
this.makeEmpty();
for( var i = 0, numPoints = points.length; i < numPoints; i ++ ) {
this.expandByPoint( points[i] );
if( points.length > 0 ) {
var p = points[0];
this.min.copy( p );
this.max.copy( p );
for( var i = 1, numPoints = points.length; i < numPoints; i ++ ) {
p = points[ v ];
if ( p.x < this.min.x ) {
this.min.x = p.x;
}
else if ( p.x > this.max.x ) {
this.max.x = p.x;
}
if ( p.y < this.min.y ) {
this.min.y = p.y;
}
else if ( p.y > this.max.y ) {
this.max.y = p.y;
}
if ( p.z < this.min.z ) {
this.min.z = p.z;
}
else if ( p.z > this.max.z ) {
this.max.z = p.z;
}
}
}
else {
this.makeEmpty();
}
return this;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册