@@ -340,9 +340,21 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
340
340
rotationY += angle
341
341
}
342
342
343
+
/**
344
+
* Makes this transform look (incl. rotations) at a given [point].
345
+
* Note that direction3D is updated to approximated and normalised value by calling [setDirectionVector3D].
346
+
*/
343
347
fun lookAt(point: Point3D) {
344
348
val directionToLook = point.subtract(x, y, z)
345
349
350
+
setDirectionVector3D(directionToLook)
351
+
}
352
+
353
+
/**
354
+
* Makes this transform look (incl. rotations) in a given [directionToLook].
355
+
* Note that direction3D is updated to approximated and normalised [directionToLook].
356
+
*/
357
+
fun setDirectionVector3D(directionToLook: Point3D) {
346
358
// ignore the Y axis and use XZ as 2D plane
347
359
rotationY = 90 - Math.toDegrees(Math.atan2(directionToLook.z, directionToLook.x))
348
360
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4