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

portalEdges

函数名称: portalEdges

函数功能: 返回传递的连通图数据中不被任何边缘连接的门户节点。

函数参数:

  • graphData - 连通图数据对象,包含节点和边缘信息

返回值:

  • 类型:对象数组
  • 一个数组对象,该对象包含门户节点的相关信息,如节点id、坐标位置等信息。

函数用法:

import { portalEdges } from 'yuka';
const nonConnectedPortals = portalEdges( graphData );

示例:

对于以下连通图数据:

const graphData = {
  "nodes": [
      { "id": 1, "x": 0, "y": 0 },
      { "id": 2, "x": 1, "y": 1 },
      { "id": 3, "x": -1, "y": -1 },
      { "id": 4, "x": -2, "y": 2 }
  ],
  "edges": [
      { "sourceNodeId": 1, "targetNodeId": 2 },
      { "sourceNodeId": 1, "targetNodeId": 3 },
      { "sourceNodeId": 2, "targetNodeId": 3 }
  ]
};

如果我们想要找出这个连通图中不被任何边缘连接的门户节点,可以使用如下代码:

import { portalEdges } from 'yuka';
const nonConnectedPortals = portalEdges( graphData );
console.log( nonConnectedPortals );

输出结果为:

[
   { "id": 4, "x": -2, "y": 2 }
]

这表明只有节点4是一个孤立的门户节点,因为它没有被任何边缘连接。