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

fromMeshGeometry

描述

fromMeshGeometry方法根据提供的网格几何数据创建一棵BVH树。

语法

Yuka.BVH.fromMeshGeometry( meshGeometry, maxDepth, maxTrisPerNode );

参数

  • meshGeometry: Object类型,必须,包含以下属性:
    • positions: Float32Array,必须,点位置数组
    • indices: Uint16Array/Uint32Array,必须,索引数组。可能是16位或32位
  • maxDepth: Number,可选,默认为8,树的最大深度
  • maxTrisPerNode: Number,可选,默认为5,每个节点的最大三角形数

返回值

返回一个 BVH 树实例。

示例

const meshGeometry = {
  positions: new Float32Array([...]),
  indices: new Uint16Array([...]),
  normals: new Float32Array([...]),
  uvs: new Float32Array([...])
};

const bvh = Yuka.BVH.fromMeshGeometry( meshGeometry );

异常

如果参数meshGeometry是无效的,则会抛出异常。