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

addObstacle

addObstacleYukajs库中的一个方法,该方法用于向场景中添加障碍物。

语法

addObstacle(obstacle: Obstacle): void
  • obstacle(必选):一个Obstacle对象,表示要添加的障碍物。

描述

通过addObstacle方法,我们可以在场景中添加一个新的障碍物,从而丰富场景内容。该方法接收一个Obstacle对象作为参数,该对象包含了关于障碍物的位置、大小、形状等信息。

示例

在场景中添加一个方形障碍物:

const obstacle = new Obstacle({
  position: new Vector3(1, 0, 0),
  width: 2,
  height: 2,
  depth: 2,
  shape: ObstacleShape.BOX
});

addObstacle(obstacle);

在场景中添加一个球形障碍物:

const obstacle = new Obstacle({
  position: new Vector3(-1, 0, 0),
  radius: 1,
  shape: ObstacleShape.SPHERE
});

addObstacle(obstacle);

异常

如果传递给addObstacle方法的参数不是一个有效的Obstacle对象,将抛出一个TypeError异常。