Introduction
The raycaster component does general intersection testing with a raycaster. Raycasting is the method of extending a line from an origin towards a direction, and checking whether that line intersects with other entites. The raycaster component is a wrapper on top of the three.js raycaster. It checks for intersections at a certain interval against a list of objects, and will emit events on the entity when it detects intersections or clearing of intersections (i.e., when the raycaster is no longer
Parameters
Parameter | Details |
---|
far | Maximum distance under which resulting entities are returned. Cannot be lower then near. |
interval | Number of milliseconds to wait in between each intersection test. Lower number is better for faster updates. Higher number is better for performance. |
near | Minimum distance over which resuilting entities are returned. Cannot be lower than 0. |
objects | Query selector to pick which objects to test for intersection. If not specified, all entities will be tested. |
recursive | Checks all children of objects if set. Else only checks intersections with root objects. |
Events
Name | Details |
---|
raycaster-intersected | Emitted on the intersected entity. Entity is intersecting with a raycaster. Event detail will contain el, the raycasting entity, and intersection, an object containing detailed data about the intersection. |
raycaster-intersected-cleared | Emitted on the intersected entity. Entity is no longer intersecting with a raycaster. Event detail will contain el, the raycasting entity. |
raycaster-intersection | Emitted on the raycasting entity. Raycaster is intersecting with one or more entities. Event detail will contain els, an array with the intersected entities, and intersections, an array of objects containing detailed data about the intersections. |
raycaster-intersection-cleared | Emitted on the raycasting entity. Raycaster is no longer intersecting with an entity. Event detail will contain el, the formerly intersected entity. |
Member
Member | Description |
---|
intersectedEls | Entities currently intersecting the raycaster. |
objects | three.js objects to test for intersections. Will be scene.children if not objects property is not specified. |
raycaster | three.js raycaster object. |
Methode
Method | Description |
---|
refreshObjects | Refreshes the list of objects based off of the objects property to test for intersection. |