Skip to main content

SimpleRaycaster

A simple raycaster that allows to easily get items from the scene using the mouse and touch events.

Implements

Properties

components

components: Components

The components instance to which this Raycaster belongs.


enabled

enabled: boolean = true

Component.enabled


mouse

readonly mouse: Mouse

The position of the mouse in the screen.


onDisposed

readonly onDisposed: Event<unknown>

Disposable.onDisposed

Implementation of

Disposable . onDisposed


three

readonly three: Raycaster

A reference to the Three.js Raycaster instance. This is used for raycasting operations.


world

world: World

A reference to the world instance to which this Raycaster belongs. This is used to access the camera and meshes.

Methods

castRay()

castRay(items): null | Intersection<Object3D<Object3DEventMap>>

Throws a ray from the camera to the mouse or touch event point and returns the first item found. This also takes into account the clipping planes used by the renderer.

Parameters

ParameterTypeDescription
itemsObject3D<Object3DEventMap>[]the meshes
to query. If not provided, it will query all the meshes stored in
Components.meshes.

Returns

null | Intersection<Object3D<Object3DEventMap>>


castRayFromVector()

castRayFromVector(origin, direction, items): null | Intersection<Object3D<Object3DEventMap>>

Casts a ray from a given origin in a given direction and returns the first item found. This method also takes into account the clipping planes used by the renderer.

Parameters

ParameterTypeDescription
originVector3The origin of the ray.
directionVector3The direction of the ray.
itemsMesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>[]The meshes to query. If not provided, it will query all the meshes stored in World.meshes.

Returns

null | Intersection<Object3D<Object3DEventMap>>

The first intersection found or null if no intersection was found.


dispose()

dispose(): void

Disposable.dispose

Returns

void

Implementation of

Disposable . dispose