forked from divan/three
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraycaster.go
More file actions
32 lines (26 loc) · 1022 Bytes
/
raycaster.go
File metadata and controls
32 lines (26 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package three
import "github.com/gopherjs/gopherjs/js"
// Raycaster assists with raycasting (used for mouse picking)
// See https://threejs.org/docs/#api/en/core/Raycaster
type Raycaster struct {
*js.Object
Far float64 `js:"far"`
Near float64 `js:"near"`
LinePrecision float64 `js:"linePrecision"`
}
// NewRaycaster creates a new raycaster.
func NewRaycaster() *Raycaster {
return &Raycaster{
Object: three.Get("Raycaster").New(),
}
}
// SetFromCamera updates the ray with a new origin and direction.
// coords - 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1.
// camera from which the ray should originate
// TODO(divan): abstract camera away
func (r Raycaster) SetFromCamera(coords Vector2, camera PerspectiveCamera) {
r.Object.Call("setFromCamera", coords, camera)
}
func (r Raycaster) IntersectObjects(objects *js.Object, recursive bool) *js.Object {
return r.Object.Call("intersectObjects", objects, recursive)
}