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

entities

简介

EntityManager 是 Yuka js 库中的一个重要组成部分,用于管理场景中的所有实体。 entities 属性是 EntityManager 中的一个方法,其返回一个包含所有实体的数组。

语法

entityManager.entities

返回值

entities 方法返回一个数组,其中包含所有实体对象。

示例

import { EntityManager } from 'yuka';

const entityManager = new EntityManager();

const entity1 = entityManager.createEntity(...);
const entity2 = entityManager.createEntity(...);
const entity3 = entityManager.createEntity(...);

const allEntities = entityManager.entities;
// 返回值:[ entity1, entity2, entity3 ]

注意事项

entities 方法返回的数组是一个实时快照,即该数组中的实体对象是随着场景中实体数量的变化而动态更新的。因此,在使用此方法时,需注意每次调用的结果均可能会不同。为避免此类情况,推荐使用 forEach 等方法遍历实体数组时把数组复制到变量中,确保对同一组实体进行处理。