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方法

描述

toJSON方法用于将Yuka.js库的BoundingSphere对象转化为JSON格式的字符串。

语法

toJSON()

返回值

一个表示Yuka.js库的BoundingSphere对象的JSON字符串。

示例

const boundingSphere = new BoundingSphere( new Vector3( 10, 20, 30 ), 5 );
const json = boundingSphere.toJSON();

console.log( json );

输出结果:

{"type":"BoundingSphere","center":{"x":10,"y":20,"z":30},"radius":5}

参数

该方法没有任何参数。

异常

该方法不会抛出异常。

备注

JSON字符串中的每个对象都包含 type 属性,表示对象的类型。BoundingSphere 类对应的 type 属性的值为 "BoundingSphere"

在默认情况下,JSON字符串中的每个属性都带有引号。若希望省略引号,则需要手动修改。