Skip to content

Commit 6a1bf56

Browse files
committed
fix: updating rotationX and rotationY now correctly updates direction3D #924
1 parent 5f87e62 commit 6a1bf56

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

fxgl-entity/src/main/kotlin/com/almasb/fxgl/entity/components/TransformComponent.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
5555
private val propRotationY = SimpleDoubleProperty(0.0)
5656
private val propRotationZ = SimpleDoubleProperty(angle)
5757

58+
init {
59+
propRotationX.addListener { _, _, _ ->
60+
updateDirection()
61+
}
62+
63+
propRotationY.addListener { _, _, _ ->
64+
updateDirection()
65+
}
66+
}
67+
5868
var x: Double
5969
get() = propX.value
6070
set(value) { propX.value = value }
@@ -315,27 +325,19 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
315325
private set
316326

317327
fun lookUpBy(angle: Double) {
318-
propRotationX.value += angle
319-
320-
updateDirection()
328+
rotationX += angle
321329
}
322330

323331
fun lookDownBy(angle: Double) {
324-
propRotationX.value -= angle
325-
326-
updateDirection()
332+
rotationX -= angle
327333
}
328334

329335
fun lookLeftBy(angle: Double) {
330-
propRotationY.value -= angle
331-
332-
updateDirection()
336+
rotationY -= angle
333337
}
334338

335339
fun lookRightBy(angle: Double) {
336-
propRotationY.value += angle
337-
338-
updateDirection()
340+
rotationY += angle
339341
}
340342

341343
fun lookAt(point: Point3D) {

0 commit comments

Comments
 (0)