|
@@ -281,6 +281,53 @@ THREE.Box3.prototype = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ intersectsPlane: function ( plane ) {
|
|
|
+
|
|
|
+ // We compute the minimum and maximum dot product values. If those values
|
|
|
+ // are on the same side (back or front) of the plane, then there is no intersection.
|
|
|
+
|
|
|
+ var min, max;
|
|
|
+
|
|
|
+ if( plane.normal.x > 0 ) {
|
|
|
+
|
|
|
+ min = plane.normal.x * this.min.x;
|
|
|
+ max = plane.normal.x * this.max.x;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ min = plane.normal.x * this.max.x;
|
|
|
+ max = plane.normal.x * this.min.x;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if( plane.normal.y > 0 ) {
|
|
|
+
|
|
|
+ min += plane.normal.y * this.min.y;
|
|
|
+ max += plane.normal.y * this.max.y;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ min += plane.normal.y * this.max.y;
|
|
|
+ max += plane.normal.y * this.min.y;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if( plane.normal.z > 0 ) {
|
|
|
+
|
|
|
+ min += plane.normal.z * this.min.z;
|
|
|
+ max += plane.normal.z * this.max.z;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ min += plane.normal.z * this.max.z;
|
|
|
+ max += plane.normal.z * this.min.z;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return ( min <= plane.constant && max >= plane.constant );
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
clampPoint: function ( point, optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new THREE.Vector3();
|