nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/gamnit: intro `EulerCamera::look_at`
[nit.git]
/
lib
/
gamnit
/
cameras.nit
diff --git
a/lib/gamnit/cameras.nit
b/lib/gamnit/cameras.nit
index
2dfc706
..
df29341
100644
(file)
--- a/
lib/gamnit/cameras.nit
+++ b/
lib/gamnit/cameras.nit
@@
-98,6
+98,17
@@
class EulerCamera
position.y += dy
end
position.y += dy
end
+ # Aim the camera at `x, y, z`
+ fun look_at(x, y, z: Float)
+ do
+ var dx = position.x
+ var dy = position.y
+ var dz = position.z
+
+ yaw = atan2(dx, dz)
+ pitch = atan2(-dy, dz)
+ end
+
# Rotation matrix produced by the current rotation of the camera
protected fun rotation_matrix: Matrix
do
# Rotation matrix produced by the current rotation of the camera
protected fun rotation_matrix: Matrix
do