BatchedMeshBVH
Defined in: core/BatchedMeshBVH.ts:11
Class to manage BVH (Bounding Volume Hierarchy) for BatchedMesh
.
Provides methods for managing bounding volumes, frustum culling, raycasting, and bounding box computation.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BatchedMeshBVH(
target
,coordinateSystem
,margin
,accurateCulling
):BatchedMeshBVH
Defined in: core/BatchedMeshBVH.ts:39
Parameters
Section titled “Parameters”target
Section titled “target”BatchedMesh
The target BatchedMesh
.
coordinateSystem
Section titled “coordinateSystem”CoordinateSystem
margin
Section titled “margin”number
= 0
The margin applied for bounding box calculations (default is 0).
accurateCulling
Section titled “accurateCulling”boolean
= true
Flag to enable accurate frustum culling without considering margin (default is true).
Returns
Section titled “Returns”BatchedMeshBVH
Properties
Section titled “Properties”accurateCulling
Section titled “accurateCulling”accurateCulling:
boolean
Defined in: core/BatchedMeshBVH.ts:27
Enables accurate frustum culling by checking intersections without applying margin to the bounding box.
bvh:
BVH
<{ },number
>
Defined in: core/BatchedMeshBVH.ts:19
The BVH instance used to organize bounding volumes.
nodesMap
Section titled “nodesMap”nodesMap:
Map
<number
,BVHNode
<{ },number
>>
Defined in: core/BatchedMeshBVH.ts:23
A map that stores the BVH nodes for each instance.
target
Section titled “target”target:
BatchedMesh
Defined in: core/BatchedMeshBVH.ts:15
The target BatchedMesh
object that the BVH is managing.
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: core/BatchedMeshBVH.ts:124
Clears the BVH.
Returns
Section titled “Returns”void
create()
Section titled “create()”create():
void
Defined in: core/BatchedMeshBVH.ts:51
Builds the BVH from the target mesh’s instances using a top-down construction method. This approach is more efficient and accurate compared to incremental methods, which add one instance at a time.
Returns
Section titled “Returns”void
delete()
Section titled “delete()”delete(
id
):void
Defined in: core/BatchedMeshBVH.ts:114
Deletes an instance from the BVH.
Parameters
Section titled “Parameters”number
The id of the instance to delete.
Returns
Section titled “Returns”void
frustumCulling()
Section titled “frustumCulling()”frustumCulling(
projScreenMatrix
,onFrustumIntersection
):void
Defined in: core/BatchedMeshBVH.ts:134
Performs frustum culling to determine which instances are visible based on the provided projection matrix.
Parameters
Section titled “Parameters”projScreenMatrix
Section titled “projScreenMatrix”Matrix4
The projection screen matrix for frustum culling.
onFrustumIntersection
Section titled “onFrustumIntersection”onFrustumIntersectionCallback
<{ }, number
>
Callback function invoked when an instance intersects the frustum.
Returns
Section titled “Returns”void
insert()
Section titled “insert()”insert(
id
):void
Defined in: core/BatchedMeshBVH.ts:77
Inserts an instance into the BVH.
Parameters
Section titled “Parameters”number
The id of the instance to insert.
Returns
Section titled “Returns”void
insertRange()
Section titled “insertRange()”insertRange(
ids
):void
Defined in: core/BatchedMeshBVH.ts:86
Inserts a range of instances into the BVH.
Parameters
Section titled “Parameters”number
[]
An array of ids to insert.
Returns
Section titled “Returns”void
intersectBox()
Section titled “intersectBox()”intersectBox(
target
,onIntersection
):boolean
Defined in: core/BatchedMeshBVH.ts:169
Checks if a given box intersects with any instance bounding box.
Parameters
Section titled “Parameters”target
Section titled “target”Box3
The target bounding box.
onIntersection
Section titled “onIntersection”onIntersectionCallback
<number
>
Callback function invoked when an intersection occurs.
Returns
Section titled “Returns”boolean
True
if there is an intersection, otherwise false
.
move()
Section titled “move()”move(
id
):void
Defined in: core/BatchedMeshBVH.ts:103
Moves an instance within the BVH.
Parameters
Section titled “Parameters”number
The id of the instance to move.
Returns
Section titled “Returns”void
raycast()
Section titled “raycast()”raycast(
raycaster
,onIntersection
):void
Defined in: core/BatchedMeshBVH.ts:151
Performs raycasting to check if a ray intersects any instances.
Parameters
Section titled “Parameters”raycaster
Section titled “raycaster”Raycaster
The raycaster used for raycasting.
onIntersection
Section titled “onIntersection”onIntersectionRayCallback
<number
>
Callback function invoked when a ray intersects an instance.
Returns
Section titled “Returns”void