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

Faster Box2 and Box3 containsPoint.

上级 5c6b5746
......@@ -143,14 +143,14 @@ THREE.Box2.prototype = {
containsPoint: function ( point ) {
if ( ( this.min.x <= point.x ) && ( point.x <= this.max.x ) &&
( this.min.y <= point.y ) && ( point.y <= this.max.y ) ) {
if ( point.x < this.min.x || point.x > this.max.x ||
point.y < this.min.y || point.y > this.max.y ) {
return true;
return false;
}
return false;
return true;
},
......@@ -183,10 +183,8 @@ THREE.Box2.prototype = {
// using 6 splitting planes to rule out intersections.
if ( ( box.max.x < this.min.x ) ||
( box.min.x > this.max.x ) ||
( box.max.y < this.min.y ) ||
( box.min.y > this.max.y ) ) {
if ( box.max.x < this.min.x || box.min.x > this.max.x ||
box.max.y < this.min.y || box.min.y > this.max.y ) {
return false;
......
......@@ -157,15 +157,15 @@ THREE.Box3.prototype = {
containsPoint: function ( point ) {
if ( ( this.min.x <= point.x ) && ( point.x <= this.max.x ) &&
( this.min.y <= point.y ) && ( point.y <= this.max.y ) &&
( this.min.z <= point.z ) && ( point.z <= this.max.z ) ) {
if ( point.x < this.min.x || point.x > this.max.x ||
point.y < this.min.y || point.y > this.max.y ||
point.z < this.min.z || point.z > this.max.z ) {
return true;
return false;
}
return false;
return true;
},
......@@ -200,9 +200,9 @@ THREE.Box3.prototype = {
// using 6 splitting planes to rule out intersections.
if ( ( box.max.x < this.min.x ) || ( box.min.x > this.max.x ) ||
( box.max.y < this.min.y ) || ( box.min.y > this.max.y ) ||
( box.max.z < this.min.z ) || ( box.min.z > this.max.z ) ) {
if ( box.max.x < this.min.x || box.min.x > this.max.x ||
box.max.y < this.min.y || box.min.y > this.max.y ||
box.max.z < this.min.z || box.min.z > this.max.z ) {
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册