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

updateNeighborhood

updateNeighborhood 函数用于更新车辆周围的车辆信息。在车辆行驶时,会不断与周围的车辆进行通信,获取车辆信息。每当有新的车辆加入或离开周围环境时,需要调用该函数更新车辆周围的车辆信息。

语法

vehicle.updateNeighborhood(vehicles);

参数

  • vehicles: 必选参数,类型为 Array,表示周围车辆的信息。

返回值

updateNeighborhood 函数不返回任何值。

示例

var vehicles = [
    {
        id: "vehicle-01",
        position: [10, 20],
        speed: 30,
        direction: 0
    },
    {
        id: "vehicle-02",
        position: [20, 30],
        speed: 40,
        direction: Math.PI / 2
    }
];

vehicle.updateNeighborhood(vehicles);

以上示例代码表示更新了 vehicle 周围的车辆信息,包括 idpositionspeeddirection

注意事项

  • 该函数只会更新车辆周围车辆的信息,不会对车辆自身的信息进行更新。
  • vehicles 数组中的每个元素应该包含车辆的唯一标识符 id、位置信息 position、速度 speed 和行驶方向 direction