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

update

Yuka js库中的TriggerRegion类具有update方法来更新触发区域。该方法用于定期更新触发区域的位置和大小,以确保它们与相应的实体(entity)保持同步。以下是该方法的详细说明。

方法签名

update( entity: Entity, offset: Vector3, quaternion: Quaternion );

参数

  • entity:要更新的实体。
  • offset:实体的偏移量。
  • quaternion:实体的旋转角度。

返回值

该方法没有返回值。

方法描述

该方法根据给定的实体偏移量和旋转角度,以及已知的触发区域大小和形状,更新触发区域的位置和大小。

该方法内部会调用TriggereArea类的updateBounds方法,用于更新触发区域的边界框。

在每次动态更新实体的位置时,都应该调用update方法来更新触发区域,以便正确地检测碰撞和触发事件。

示例

const entity = new Entity();
const triggerRegion = new TriggerRegion( new Sphere( 1 ), callbackFunction );
const offset = new Vector3( 10, 0, 0 );
const quaternion = new Quaternion();

// Update the trigger region every frame
function updateTrigger() {
  triggerRegion.update( entity, offset, quaternion );
}

// Call updateTrigger() every frame to update the trigger region

以上是TriggerRegion的update方法的详细说明,调用该方法可以确保触发区域始终与实体同步,以便正确检测碰撞和触发事件。