[orx-camera] convert to MPP
This commit is contained in:
@@ -8,6 +8,7 @@ import org.openrndr.math.Matrix44
|
||||
import org.openrndr.math.Spherical
|
||||
import org.openrndr.math.Vector3
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
import org.openrndr.math.transforms.lookAt as lookAt_
|
||||
|
||||
enum class ProjectionType {
|
||||
@@ -69,12 +70,12 @@ class OrbitalCamera(eye: Vector3 = Vector3.ZERO, lookAt: Vector3 = Vector3.UNIT_
|
||||
}
|
||||
|
||||
fun dollyIn() {
|
||||
val zoomScale = Math.pow(0.95, zoomSpeed)
|
||||
val zoomScale = pow(0.95, zoomSpeed)
|
||||
dolly(sphericalEnd.radius * zoomScale - sphericalEnd.radius)
|
||||
}
|
||||
|
||||
fun dollyOut() {
|
||||
val zoomScale = Math.pow(0.95, zoomSpeed)
|
||||
val zoomScale = pow(0.95, zoomSpeed)
|
||||
dolly(sphericalEnd.radius / zoomScale - sphericalEnd.radius)
|
||||
}
|
||||
|
||||
@@ -218,4 +219,6 @@ fun OrbitalCamera.applyTo(drawer: Drawer) {
|
||||
drawer.drawStyle.depthWrite = true
|
||||
drawer.drawStyle.depthTestPass = DepthTestPass.LESS_OR_EQUAL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun pow(a:Double, x:Double): Double = a.pow(x)
|
||||
@@ -3,6 +3,7 @@ package org.openrndr.extras.camera
|
||||
import org.openrndr.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.asRadians
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.tan
|
||||
@@ -51,7 +52,7 @@ class OrbitalControls(val orbitalCamera: OrbitalCamera, val userInteraction: Boo
|
||||
val offset = Vector3.fromSpherical(orbitalCamera.spherical) - orbitalCamera.lookAt
|
||||
|
||||
// half of the fov is center to top of screen
|
||||
val targetDistance = offset.length * tan((Math.toRadians((fov) / 2)))
|
||||
val targetDistance = offset.length * tan(fov / 2).asRadians
|
||||
val panX = (2 * delta.x * targetDistance / program.window.size.x)
|
||||
val panY = (2 * delta.y * targetDistance / program.window.size.y)
|
||||
|
||||
Reference in New Issue
Block a user