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

该函数用于将FollowPathBehavior实例转换为JSON数据对象。

语法

behavior.toJSON()

返回值

返回一个JSON数据对象,包含FollowPathBehavior实例的所有属性和方法。

示例

const myBehavior = new Yuka.FollowPathBehavior();
const jsonData = myBehavior.toJSON();
console.log(JSON.stringify(jsonData));

输出:

{"type":"FollowPathBehavior","path":null,"arrivalDistance":1,"time":0,"currentParam":0,"currentSegmentIndex":0}

属性

  • type: 类型名,固定为 FollowPathBehavior.
  • path: 路径对象,代表当前FollowPathBehavior实例要遵循的路径信息。
  • arrivalDistance: 代表小车到达路径点的距离阈值,当小车距离路径点的距离小于该阈值时,认为已经到达该路径点。默认值为1.
  • time: 代表当前实例已经执行行驶时间的毫秒数,用于计算路径上当前小车位置的参数值。
  • currentParam: 代表当前小车在路径上的参数位置,值为[0, 1]之间的一个数值。
  • currentSegmentIndex: 代表当前小车所处的路径段的索引值,该索引值对应路径对象中存储的路径段数组中的数组下标值。

方法

  • toJSON(): 将当前FollowPathBehavior实例转换为JSON数据对象并返回。

参考

Yuka.js官方文档