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是Yuka js库的一种方法,用于解决当前实例的引用关系。

方法概述

resolveReferences 方法将递归查找当前实例的 Cell 属性,并将每个 Cell 中的引用实例解析为其相应实例对象。

方法语法

resolveReferences()

方法参数

该方法无需传递任何参数。

方法示例

import { Cell } from 'yuka';
import { Vector3, Object3D } from 'three';

class MyEntity extends Object3D {
  constructor() {
    super();

    // 定义实例的 Cell 属性
    this.positionCell = new Cell( new Vector3() );
    this.targetCell = new Cell( null );
  }
}

const entityA = new MyEntity();
const entityB = new MyEntity();

// 设置实例的引用关系
entityA.targetCell.value = entityB.positionCell;

// 解决实例引用关系
entityA.resolveReferences();

console.log( entityA.targetCell.value ); // Vector3 { x: 0, y: 0, z: 0 }
console.log( entityA.targetCell.value ); // Vector3 { x: 0, y: 0, z: 0 }

注意事项

  • resolveReferences 方法必须在设置引用关系操作完成后立即调用,以确保当前实例的每个 Cell 属性都被正确解析。
  • resolveReferences 方法仅适用于 Cell 属性。如果实例中没有 Cell 属性,则此方法不执行任何操作。