This commit is contained in:
2024-11-30 19:52:25 +01:00
parent 828297aef2
commit 2edb23e9ec
8 changed files with 72 additions and 41 deletions
@@ -14,6 +14,7 @@ import kotlin.random.Random
class LerpCurves(val function: (Float) -> Float) {
companion object {
val Constant = LerpCurves { _ -> 1.0f }
val Linear = LerpCurves { y -> y }
val Sqrt = LerpCurves { y -> sqrt(y) }
val Exponent = LerpCurves { y -> y.pow(2.0f) }
@@ -166,7 +167,8 @@ fun transformOffsetByScale(offset: Vector3f, scale: Vector3f): Vector3f {
fun lerp(x: Float, y: Float, t: Float) : Float {
return x + (y - x) * t
val clampedT = t.coerceIn(0f, 1f)
return x + (y - x) * clampedT
}