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

set

描述

set() 方法用于在OBB树中给定的路径设置值。如果给定的路径不存在,则创建该路径。

语法

obb.set(path, value)

参数

  • path: 必需。字符串或路径数组,表示设置值的路径。例如 path = "a.b.c"path = ["a", "b", "c"]
  • value: 必需。任意类型,表示要设置的值。

返回值

undefined

示例

const myObb = new OBB({a: {b: {c: 1}}});

// 使用字符串作为路径设置值
myObb.set('a.b.c', 2);

// 使用路径数组作为路径设置值
myObb.set(['a', 'b', 'd'], 3);

console.log(myObb.get('a.b.c')); // 输出 2
console.log(myObb.get('a.b.d')); // 输出 3

在上面的示例中,我们创建了一个包含路径 a.b.c 的OBB。然后,我们使用 set() 方法在该路径上设置值为 2。然后,我们使用路径数组 ['a', 'b', 'd'] 设置一个新路径 a.b.d 的值为 3,并将其添加到OBB中。最后,我们使用 get() 方法检查已更改的值。