Three.V8

3D rendering engine using JavaScript as user script.

View on GitHub

<–Home

class BoundingVolumeHierarchy

Acceleration structure for ray-casting.

class BoundingVolumeHierarchy

Name Description
Constructors  
BoundingVolumeHierarchy() Creates a new BoundingVolumeHierarchy.
Methods  
dispose Dispose the unmanaged resource.
update Update the BVH with a new model.
remove Remove a model from the BVH.
intersect Intersect the given ray with the acceleration structure.

Constructors

BoundingVolumeHierarchy()

BoundingVolumeHierarchy(objects: Array)

Create a BoundingVolumeHierarchy from a list of Object3D objects.

Methods

dispose()

.dispose(): undefined

Dispose the unmanaged resource.

update()

.update(obj: Object3D): undefined

Update the BVH with a new model.

remove()

.remove(obj: Object3D): undefined

Remove a model from the BVH.

intersect()

.intersect(ray: Object): Object

Intersect the given ray with the acceleration structure.

The input ray object should have the following properties:

ray.origin: Vector3

Origin of the ray.

ray.direction: Vector3

Direction of the ray.

ray.near: Number

Optional. Nearest distance of search.

ray.far: Number

Optional. Furthest distance of search.

The returned object has the following properties:

.name: String

Name of the first intersected object.

.distance: Number

Distance of the first intersection point.

At the event of missing intersection, it will return null;