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

apply @gero3 's suggestion to Box2.clampPoint() as well.

上级 5f592093
......@@ -177,7 +177,24 @@ THREE.Box2.prototype = {
clampPoint: function ( point ) {
return new THREE.Vector2().copy( point ).maxSelf( this.min ).minSelf( this.max );
var p = new THREE.Vector2().copy( point );
// this requires less if's then a point.minSelf( this.max ).maxSelf( this.min )
if( p.x < this.min.x ) {
p.x = this.min.x;
}
else if( p.x > this.max.x ) {
p.x = this.max.x;
}
if( p.y < this.min.y ) {
p.y = this.min.y;
}
else if( p.y > this.max.y ) {
p.y = this.max.y;
}
return p;
},
distanceToPoint: function ( point ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册