Skip to content

Commit

Permalink
fix: updating rotationX and rotationY now correctly updates direction3D
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Jan 21, 2023
1 parent 5f87e62 commit 6a1bf56
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
private val propRotationY = SimpleDoubleProperty(0.0)
private val propRotationZ = SimpleDoubleProperty(angle)

init {
propRotationX.addListener { _, _, _ ->
updateDirection()
}

propRotationY.addListener { _, _, _ ->
updateDirection()
}
}

var x: Double
get() = propX.value
set(value) { propX.value = value }
Expand Down Expand Up @@ -315,27 +325,19 @@ class TransformComponent(x: Double, y: Double, angle: Double, scaleX: Double, sc
private set

fun lookUpBy(angle: Double) {
propRotationX.value += angle

updateDirection()
rotationX += angle
}

fun lookDownBy(angle: Double) {
propRotationX.value -= angle

updateDirection()
rotationX -= angle
}

fun lookLeftBy(angle: Double) {
propRotationY.value -= angle

updateDirection()
rotationY -= angle
}

fun lookRightBy(angle: Double) {
propRotationY.value += angle

updateDirection()
rotationY += angle
}

fun lookAt(point: Point3D) {
Expand Down

0 comments on commit 6a1bf56

Please sign in to comment.