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
mouse
readonlymouse:Mouse
The position of the mouse in the screen.
onDisposed
readonlyonDisposed:Event<unknown>
Implementation of
three
readonlythree:Raycaster
A reference to the Three.js Raycaster instance. This is used for raycasting operations.
useFastModelPicking
useFastModelPicking:
boolean=false
Whether to use fast model picking to optimize raycasting. When enabled, the raycaster will first use FastModelPicker to identify which model is under the mouse, then only raycast that specific model. This can significantly improve performance when there are many models.
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(
data?):Promise<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
| Parameter | Type |
|---|---|
data? | object |
data.items? | Object3D<Object3DEventMap>[] |
data.position? | Vector2 |
data.snappingClasses? | SnappingClass[] |
Returns
Promise<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
| Parameter | Type | Description |
|---|---|---|
origin | Vector3 | The origin of the ray. |
direction | Vector3 | The direction of the ray. |
items | Mesh<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
Returns
void