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

position

NavNode中的position属性指定了节点的位置信息,包括x、y值和水平、垂直方向的对齐方式。

语法

navNode.position = {
  x: 0,
  y: 0,
  align: {
    horizontal: 'left',   // 可选:left、center、right
    vertical: 'top'       // 可选:top、middle、bottom
  }
};

说明

  • NavNode对象的position属性只有在该节点被加入到NavMap中后才会生效。
  • x和y指定了节点的位置坐标,以NavMap的左上角为原点。
  • align指定了节点内容布局的对齐方式,包括水平和垂直方向。可选的值有左对齐、中心对齐、右对齐,以及顶部对齐、垂直居中、底部对齐。

示例

var node = navMap.createNode('node1');
node.position = {
  x: 100,
  y: 50,
  align: {
    horizontal: 'center',
    vertical: 'middle'
  }
};

该例子创建了一个名为"node1"的节点,并将其放置在NavMap的坐标系中的(100, 50)位置。同时,该节点的内容被设置为水平和垂直方向都居中对齐。