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

fromJSON

该方法用于从JSON对象中生成NavNode实例。

语法

NavNode.fromJSON(json)

参数

  • json:必需,JSON对象。包含从NavNode实例序列化而来的导航节点的数据。

返回值

  • 返回一个新的NavNode实例。

示例

const json = {
  "name": "Home",
  "url": "/",
  "children": [
    {"name": "About", "url": "/about"},
    {
      "name": "Products",
      "url": "/products",
      "children": [
        {"name": "Product1", "url": "/product1"},
        {"name": "Product2", "url": "/product2"}
      ]
    }
  ]
}

const node = NavNode.fromJSON(json);

说明

  • json参数必须是从NavNode实例序列化而来的JSON对象。

  • 生成的新的NavNode实例将包含原始节点的所有属性和子节点。

  • 如果JSON对象格式不正确,则可能会引发异常。