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字符串生成CompositeGoal对象。

语法

CompositeGoal.fromJSON(jsonString: string): CompositeGoal

参数

  • jsonString:必选,字符串类型,表示要解析的JSON格式字符串。

返回值

返回解析后的CompositeGoal对象。

示例

import { CompositeGoal } from 'yuka';

const jsonString = '{ "type": "CompositeGoal", "status": "inactive", "subgoals": [ { "type": "MoveToGoal", "position": [ 1, 0, 1 ] } ] }';
const goal = CompositeGoal.fromJSON( jsonString );

console.log( goal.constructor.name ); // 'CompositeGoal'
console.log( goal.status ); // 'inactive'
console.log( goal.subgoals[ 0 ].constructor.name ); // 'MoveToGoal'

异常

如果提供的JSON字符串无效或者不含有必要的数据,将抛出异常。

备注

如果你想要将一个完整的复合目标(composite goal)及其中包含的所有子目标序列化为一个JSON字符串,可以使用JSON.stringify()方法。