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

resolveReferences

resolveReferences是Think中Yuka js库的一个函数,用于解析引用。

语法

resolveReferences( object: Object, maxDepth?: number )

参数

  • object(必填):待解析的对象。
  • maxDepth(可选):设置对象属性的最大深度,超过最大深度的属性不会被解析,默认值为10。

返回值

解析后的对象。

功能

resolveReferences用于解析引用。如果目标对象属于另一个对象,或者引用了另一个对象,则可以使用这个函数将引用解析为实际的对象。

示例

const obj = {
  a: { $ref: "#/b" },
  b: { c: "hello" }
};

resolveReferences( obj );

解析后输出:

{
  a: { c: "hello" },
  b: { c: "hello" }
}

注意事项

对解析后的对象进行操作时,请注意对原对象的影响。如果进行引用循环,会导致死循环。建议在使用前先对参数进行检查。