[orx-camera] Add option to disable motion damping
This commit is contained in:
@@ -20,7 +20,16 @@ class Orbital : Extension {
|
||||
var keySpeed = 1.0
|
||||
var projectionType = ProjectionType.PERSPECTIVE
|
||||
|
||||
val camera by lazy { OrbitalCamera(eye, lookAt, fov, near, far, projectionType) }
|
||||
/**
|
||||
* Damping factor for camera motion, set to 0 for no damping
|
||||
*/
|
||||
var dampingFactor = 0.05
|
||||
|
||||
val camera by lazy {
|
||||
OrbitalCamera(eye, lookAt, fov, near, far, projectionType).apply {
|
||||
dampingFactor = this@Orbital.dampingFactor
|
||||
}
|
||||
}
|
||||
val controls by lazy { OrbitalControls(camera, userInteraction, keySpeed) }
|
||||
|
||||
override fun setup(program: Program) {
|
||||
|
||||
@@ -104,6 +104,11 @@ class OrbitalCamera(eye: Vector3 = Vector3.ZERO, lookAt: Vector3 = Vector3.UNIT_
|
||||
dirty = true
|
||||
}
|
||||
|
||||
fun scaleTo(s: Double) {
|
||||
magnitudeEnd = s
|
||||
dirty = true
|
||||
}
|
||||
|
||||
fun zoom(degrees: Double) {
|
||||
fovEnd += degrees
|
||||
dirty = true
|
||||
@@ -118,7 +123,7 @@ class OrbitalCamera(eye: Vector3 = Vector3.ZERO, lookAt: Vector3 = Vector3.UNIT_
|
||||
if (!dirty) return
|
||||
dirty = false
|
||||
|
||||
val dampingFactor = dampingFactor * timeDelta / 0.0060
|
||||
val dampingFactor = if (dampingFactor > 0.0) { dampingFactor * timeDelta / 0.0060 } else 1.0
|
||||
val sphericalDelta = sphericalEnd - spherical
|
||||
val lookAtDelta = lookAtEnd - lookAt
|
||||
val fovDelta = fovEnd - fov
|
||||
|
||||
Reference in New Issue
Block a user