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

描述

该方法用于将SingletonFuzzySet对象转化为JSON对象。

语法

SingletonFuzzySet.toJSON()

返回值

返回一个JSON格式的对象,包含SingletonFuzzySet对象的关键信息,如下所示:

{
    "name": "SingletonFuzzySet",
    "params": {
        "member": 0.5,
        "min": 0,
        "max": 1
    }
}

其中,"name"表示该对象类型为"SingletonFuzzySet";"params"中包含了该对象的关键信息,其中"member"表示该集合的唯一成员,"min"表示该成员可能取到的最小值,"max"表示可能取到的最大值。

示例

let mySet = new SingletonFuzzySet(0.5, 0, 1);
let jsonSet = mySet.toJSON();
console.log(jsonSet);

输出结果:

{
    "name": "SingletonFuzzySet",
    "params": {
        "member": 0.5,
        "min": 0,
        "max": 1
    }
}

注意事项

如果该对象已经转换为了JSON格式,再次调用toJSON方法将会得到相同的结果。此外,该方法只能用于SingletonFuzzySet类型的对象,其他类型的模糊集合需要使用对应的方法进行转换。