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

简介

fromJSON是Yuka js库中的FuzzySet类的一个方法,用于将JSON格式的字符串转换成FuzzySet对象。

语法

FuzzySet.fromJSON(jsonString: string): FuzzySet

参数

  • jsonString: JSON格式的字符串,用于创建FuzzySet对象。

返回值

  • 返回一个新创建的FuzzySet对象。

例子

const jsonString = '{"dimension": 3, "members": [{"name": "Bob", "values": [0.1, 0.2, 0.4]}, {"name": "Alice", "values": [0.5, 0.6, 0.8]}]}';

const fuzzySet = FuzzySet.fromJSON(jsonString);

注意事项

  • 参数jsonString必须是符合JSON格式的字符串,否则会抛出异常。
  • JSON格式字符串中必须包含dimensionmembers这两个属性,且members属性的值必须是一个数组。
  • members数组中的每个元素必须具有namevalues这两个属性。
  • values属性的值必须是长度为dimension的数组。

参考链接