Threepp.Raycaster¶
Raycaster
Uses a ray to test for intersections with objects.
Members¶
Constructors¶
Properties¶
Methods¶
Raycaster¶
Constructor
Arguments
| Arguments | Default | Description |
|---|---|---|
origin |
|
Origin. |
direction |
|
Direction. |
near |
0 |
Near distance. |
far |
Infinity |
Far distance. |
Description
Constructor
nearPlane¶
Property \ Access: r/w
Description
Near distance
farPlane¶
Property \ Access: r/w
Description
Far distance
set¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
origin |
|
|
direction |
|
Description
Sets the origin and direction (direction must be normalized)
setFromCameraNDC¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
ndcX |
|
Normalized device coordinate X [-1,1] (left edge of the screen -1, right edge +1). |
ndcY |
|
Normalized device coordinate Y [-1,1] (bottom edge of the screen -1, top edge +1). |
camera |
|
PerspectiveCamera or OrthographicCamera. |
Description
Sets the ray from a camera and normalized device coordinates (equivalent to three.js's setFromCamera)
setFromCameraPixel¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
px |
|
Pixel X (top-left origin; Kirikiri layer coordinates). |
py |
|
Pixel Y (top-left origin; positive downward). |
viewW |
|
Viewport width (width of the drawing layer). |
viewH |
|
Viewport height (height of the drawing layer). |
camera |
|
Camera. |
Description
Convenience version that sets the ray from pixel coordinates (top-left origin) and the viewport size
You can pass mouse coordinates directly; they are converted to NDC internally.
intersectObjects¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
objects |
|
Array of Object3D to test (e.g. [vrm.getScene(), boxMesh]). |
recursive |
true |
Whether to test descendants recursively (default true). |
Return value
Array of hits. Each element is a dictionary: object … the hit root object passed in the argument array (the same instance). Even when recursive finds a hit on a descendant, the corresponding ancestor in the argument array is returned. distance … distance from the ray origin x, y, z … hit point in world coordinates The array is sorted by ascending distance (result[0] is the nearest). With no hits, count=0.
Description
Tests for intersections with a set of objects and returns the hits as an array sorted by distance, nearest first