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

toJSON

SeparationBehavior.toJSON() 方法用于将当前的SeparationBehavior实例转换为JSON格式。

格式

{
  "type": "SeparationBehavior",
  "settings": {
    "distance": 50,
    "factor": 1
  }
}

参数

该方法不接收任何参数。

返回值

返回生成的JSON格式对象,其包含以下属性:

  • typeString类型。表示该对象的类型,值为"SeparationBehavior"
  • settingsObject类型。表示该对象的设置,包含以下属性:
    • distanceNumber类型。表示行为的作用范围,即传递给SeparationBehavior构造函数的distance参数的值。
    • factorNumber类型。表示行为的强度系数,即传递给SeparationBehavior构造函数的factor参数的值。

示例

const behavior = new YUKA.SeparationBehavior(50, 1);
const jsonObject = behavior.toJSON();
console.log(jsonObject);
// 输出:{"type":"SeparationBehavior","settings":{"distance":50,"factor":1}}