Skip to content

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.

new BatchedMeshBVH(target, coordinateSystem, margin, accurateCulling): BatchedMeshBVH

Defined in: core/BatchedMeshBVH.ts:39

BatchedMesh

The target BatchedMesh.

CoordinateSystem

number = 0

The margin applied for bounding box calculations (default is 0).

boolean = true

Flag to enable accurate frustum culling without considering margin (default is true).

BatchedMeshBVH

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: Map<number, BVHNode<{ }, number>>

Defined in: core/BatchedMeshBVH.ts:23

A map that stores the BVH nodes for each instance.


target: BatchedMesh

Defined in: core/BatchedMeshBVH.ts:15

The target BatchedMesh object that the BVH is managing.

clear(): void

Defined in: core/BatchedMeshBVH.ts:124

Clears the BVH.

void


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.

void


delete(id): void

Defined in: core/BatchedMeshBVH.ts:114

Deletes an instance from the BVH.

number

The id of the instance to delete.

void


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.

Matrix4

The projection screen matrix for frustum culling.

onFrustumIntersectionCallback<{ }, number>

Callback function invoked when an instance intersects the frustum.

void


insert(id): void

Defined in: core/BatchedMeshBVH.ts:77

Inserts an instance into the BVH.

number

The id of the instance to insert.

void


insertRange(ids): void

Defined in: core/BatchedMeshBVH.ts:86

Inserts a range of instances into the BVH.

number[]

An array of ids to insert.

void


intersectBox(target, onIntersection): boolean

Defined in: core/BatchedMeshBVH.ts:169

Checks if a given box intersects with any instance bounding box.

Box3

The target bounding box.

onIntersectionCallback<number>

Callback function invoked when an intersection occurs.

boolean

True if there is an intersection, otherwise false.


move(id): void

Defined in: core/BatchedMeshBVH.ts:103

Moves an instance within the BVH.

number

The id of the instance to move.

void


raycast(raycaster, onIntersection): void

Defined in: core/BatchedMeshBVH.ts:151

Performs raycasting to check if a ray intersects any instances.

Raycaster

The raycaster used for raycasting.

onIntersectionRayCallback<number>

Callback function invoked when a ray intersects an instance.

void