AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

intersectsPlane

说明

该方法用于判断一个包围球(BoundingSphere)是否与平面(Plane)相交。

语法

intersectsPlane(plane: Plane) : Boolean

参数

  • planePlane类型的参数,用于表示平面。

返回值

  • Boolean类型的值。若相交,则返回 true,否则返回 false

示例

const sphere = new BoundingSphere(new Vector3(0, 0, 0), 1);
const plane = new Plane(new Vector3(0, 1, 0), 0);

if (sphere.intersectsPlane(plane)) {
    console.log('包围球与平面相交');
} else {
    console.log('包围球与平面不相交');
}

实现原理

判断一个包围球是否与一个平面相交,就是判断包围球的中心点到平面的距离是否小于等于包围球的半径。

具体实现可参考以下代码:

intersectsPlane( plane ) {

	// 获取平面法向量长度的倒数
	const distanceToPoint = plane.distanceToPoint( this.center );

	// 判断距离是否小于等于半径
	return distanceToPoint <= this.radius;

}

注意事项

  • 该方法只适用于平面与包围球的相交判断,不适用于其他图形或物体的相交判断。
  • Plane 类型的参数必须是已经创建好的实例。