Fix OrbitalCamera and OrbitalControls to be compatible with OR 0.3.36

This commit is contained in:
edwin
2019-11-25 19:27:58 +01:00
parent 471b2d5bf7
commit 6c9c0d622d
3 changed files with 7 additions and 7 deletions

View File

@@ -39,7 +39,7 @@ class OrbitalCamera(eye: Vector3 = Vector3.ZERO, lookAt: Vector3 = Vector3.UNIT_
}
fun rotate(rotX: Double, rotY: Double) {
sphericalEnd += Spherical(0.0, rotX, rotY)
sphericalEnd += Spherical(rotX, rotY, 0.0)
sphericalEnd = sphericalEnd.makeSafe()
dirty = true
}
@@ -67,7 +67,7 @@ class OrbitalCamera(eye: Vector3 = Vector3.ZERO, lookAt: Vector3 = Vector3.UNIT_
}
fun dolly(distance: Double) {
sphericalEnd += Spherical(distance, 0.0, 0.0)
sphericalEnd += Spherical(0.0, 0.0, distance)
dirty = true
}

View File

@@ -40,15 +40,15 @@ class OrbitalControls(val orbitalCamera: OrbitalCamera , val userInteraction: Bo
val offset = Vector3.fromSpherical(orbitalCamera.spherical) - orbitalCamera.lookAt
// half of the fov is center to top of screen
val targetDistance = offset.length * tan((fov / 2) * PI / 180)
val targetDistance = offset.length * tan((Math.toRadians((fov) / 2) ) )
val panX = (2 * delta.x * targetDistance / program.window.size.x)
val panY = (2 * delta.y * targetDistance / program.window.size.y)
orbitalCamera.pan(panX, -panY, 0.0)
} else {
val rotX = 2 * PI * delta.x / program.window.size.x
val rotY = 2 * PI * delta.y / program.window.size.y
val rotX = 360.0 * delta.x / program.window.size.x
val rotY = 360.0 * delta.y / program.window.size.y
orbitalCamera.rotate(rotX, rotY)
}