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

getRegionForPoint

介绍

getRegionForPoint是Yuka js库中NavMesh的一个方法。该方法用于找到点所属的区域。

语法

NavMesh.getRegionForPoint( point );

参数

  • point:object类型,表示需要寻找区域的点。该对象拥有以下属性:

    • x:number类型,表示点的横坐标。
    • y:number类型,表示点的纵坐标。
    • z:number类型,表示点的深度坐标。

返回值

返回点所属的区域的索引号。如果点不在任何区域内,则返回-1。

示例

import { NavMesh } from 'yuka';

const navMesh = new NavMesh();

// 代码中设定了一个mesh数据并添加了多个区域

const point = {
    x: 0,
    y: 0,
    z: 0
};

const regionIndex = navMesh.getRegionForPoint(point);
if (regionIndex !== -1) {
    console.log(`点在第${regionIndex}个区域内。`);
} else {
    console.log(`点不在任何区域内。`);
}

参考资料