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
readonly
mouse:Mouse
The position of the mouse in the screen.
onDisposed
readonly
onDisposed:Event
<unknown
>
Implementation of
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
,position
):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 | Description |
---|---|---|
items | Object3D <Object3DEventMap >[] | the meshes |
to query. If not provided, it will query all the meshes stored in | ||
Components.meshes. | ||
position | Vector2 | the screen position to use for raycasting. If not provided, |
the last pointer (mouse/touch) position will be used. |
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
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