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

containsPoint

描述

containsPoint是Yuka js库中的BoundingSphere类的一个方法,用于判断该BoundingSphere是否包含给定的点。

语法

sphere.containsPoint(point)

参数

  • point: 表示要判断的点,是一个Vector3类型的向量。

返回值

  • 返回一个Boolean类型的值,表示该BoundingSphere是否包含给定的点。

示例

const sphere = new YUKA.BoundingSphere( new YUKA.Vector3(), 1 );
const point1 = new YUKA.Vector3( 0, 0, 0 );
const point2 = new YUKA.Vector3( 2, 0, 0 );

console.log( sphere.containsPoint( point1 ) ); // true
console.log( sphere.containsPoint( point2 ) ); // false

实现思路

首先将传入的点和BoundingSphere的中心点的距离计算出来,如果该距离小于或等于BoundingSphere的半径,则返回true,否则返回false。

注意事项

当BoundingSphere的半径为0时,该方法始终返回false。

参考链接