intersectsPlane method

bool intersectsPlane(
  1. Plane plane
)

Returns true if the given plane intersects this AABB.

Reference: Testing Box Against Plane in Real-Time Collision Detection by Christer Ericson (chapter 5.2.3)

Implementation

bool intersectsPlane(Plane plane ) {
	final normal = plane.normal;

	getCenter( center );
	size.subVectors( max, center ); // positive extends

	// compute the projection interval radius of b onto L(t) = c + t * plane.normal
	final r = size.x * normal.x.abs(  ) + size.y * normal.y.abs(  ) + size.z * normal.z.abs(  );

	// compute distance of box center from plane
	final s = plane.distanceToPoint( center );
	return s.abs(  ) <= r;
}