new Raycaster(origin, direction, nearopt, faropt)
This creates a new raycaster object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
origin |
zen3d.Vector3 | — The origin vector where the ray casts from. | ||
direction |
zen3d.Vector3 | — The direction vector that gives direction to the ray. Should be normalized. | ||
near |
number |
<optional> |
0 | — All results returned are further away than near. Near can't be negative. |
far |
number |
<optional> |
Infinity | All results returned are closer than far. Far can't be lower than near. |
- Source:
Members
far :number
The far factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be larger than the near property.
Type:
- number
- Source:
near :number
The near factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be smaller than the far property.
Type:
- number
- Source:
ray :zen3d.Ray
The Ray used for the raycasting.
Type:
- Source:
Methods
intersectObject(object, recursive=opt) → {Array.<Object>}
Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. An array of intersections is returned:
[ { distance, point, face, faceIndex, object }, ... ]
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
zen3d.Object3D | — The object to check for intersection with the ray. | |
recursive= |
boolean |
<optional> |
— If true, it also checks all descendants. Otherwise it only checks intersecton with the object. |
- Source:
Returns:
An array of intersections
- Type
- Array.<Object>
intersectObjects(objects, recursive=opt) → {Array.<Object>}
Checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. An array of intersections is returned:
[ { distance, point, face, faceIndex, object }, ... ]
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
objects |
Array.<zen3d.Object3D> | — The objects to check for intersection with the ray. | |
recursive= |
boolean |
<optional> |
— If true, it also checks all descendants. Otherwise it only checks intersecton with the object. |
- Source:
Returns:
An array of intersections
- Type
- Array.<Object>
set(origin, direction)
Updates the ray with a new origin and direction.
Parameters:
Name | Type | Description |
---|---|---|
origin |
zen3d.Vector3 | — The origin vector where the ray casts from. |
direction |
zen3d.Vector3 | — The normalized direction vector that gives direction to the ray. |
- Source:
setFromCamera(coords, camera, type)
Updates the ray with a new origin and direction.
Parameters:
Name | Type | Description |
---|---|---|
coords |
zen3d.Vector2 | — 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1. |
camera |
zen3d.Camera | — camera from which the ray should originate. |
type |
string | camera type: 'perspective' or 'orthographic' |
- Source: