fix lerp for vec3, update tests for broken lerp case
This commit is contained in:
parent
f6ad9335cc
commit
0ff68c69fd
@ -74,7 +74,7 @@ end
|
||||
-- @param progress (0-1)
|
||||
-- @return number
|
||||
function utils.lerp(low, high, progress)
|
||||
return (1 - progress) * low + progress * high
|
||||
return low * (1 - progress) + high * progress
|
||||
end
|
||||
|
||||
--- Exponential decay
|
||||
|
@ -16,6 +16,11 @@ describe("utils:", function()
|
||||
local b = vec3(1, 1, 1)
|
||||
local c = vec3(0.5, 0.5, 0.5)
|
||||
assert.is.equal(utils.lerp(a, b, 0.5), c)
|
||||
|
||||
a = vec3(5, 5, 5)
|
||||
b = vec3(0, 0, 0)
|
||||
c = vec3(2.5, 2.5, 2.5)
|
||||
assert.is.equal(utils.lerp(a, b, 0.5), c)
|
||||
end)
|
||||
|
||||
it("decays exponentially", function()
|
||||
|
Loading…
x
Reference in New Issue
Block a user