@@ -222,6 +222,30 @@ AxisAlignedBoundingBox.intersectPlane = function (box, plane) {
222222 return Intersect . INTERSECTING ;
223223} ;
224224
225+ /**
226+ * Determines whether two axis aligned bounding boxes intersect.
227+ *
228+ * @param {AxisAlignedBoundingBox } box first box
229+ * @param {AxisAlignedBoundingBox } other second box
230+ * @returns {boolean } <code>true</code> if the boxes intersect; otherwise, <code>false</code>.
231+ */
232+ AxisAlignedBoundingBox . intersectAxisAlignedBoundingBox = function ( box , other ) {
233+ //>>includeStart('debug', pragmas.debug);
234+ Check . defined ( "box" , box ) ;
235+ Check . defined ( "other" , other ) ;
236+ //>>includeEnd('debug');
237+
238+ // This short circuits in favor of AABBs that do not intersect.
239+ return (
240+ box . minimum . x <= other . maximum . x &&
241+ box . maximum . x >= other . minimum . x &&
242+ box . minimum . y <= other . maximum . y &&
243+ box . maximum . y >= other . minimum . y &&
244+ box . minimum . z <= other . maximum . z &&
245+ box . maximum . z >= other . minimum . z
246+ ) ;
247+ } ;
248+
225249/**
226250 * Duplicates this AxisAlignedBoundingBox instance.
227251 *
@@ -245,6 +269,18 @@ AxisAlignedBoundingBox.prototype.intersectPlane = function (plane) {
245269 return AxisAlignedBoundingBox . intersectPlane ( this , plane ) ;
246270} ;
247271
272+ /**
273+ * Determines whether some other axis aligned bounding box intersects this box.
274+ *
275+ * @param {AxisAlignedBoundingBox } other The other axis aligned bounding box.
276+ * @returns {boolean } <code>true</code> if the boxes intersect; otherwise, <code>false</code>.
277+ */
278+ AxisAlignedBoundingBox . prototype . intersectAxisAlignedBoundingBox = function (
279+ other ,
280+ ) {
281+ return AxisAlignedBoundingBox . intersectAxisAlignedBoundingBox ( this , other ) ;
282+ } ;
283+
248284/**
249285 * Compares this AxisAlignedBoundingBox against the provided AxisAlignedBoundingBox componentwise and returns
250286 * <code>true</code> if they are equal, <code>false</code> otherwise.
0 commit comments