mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
allow changing the current value of a spring (similar to sources)
This commit is contained in:
parent
fbe2f01bb9
commit
c73cc4bc39
1 changed files with 21 additions and 3 deletions
|
|
@ -201,9 +201,27 @@ local function spring<T>(source: () -> T, period: number?, damping_ratio: number
|
||||||
-- set output to goal
|
-- set output to goal
|
||||||
output.cache = data.source_value
|
output.cache = data.source_value
|
||||||
|
|
||||||
return function()
|
return function(...)
|
||||||
push_child_to_scope(output)
|
if select("#", ...) == 0 then -- no args were given
|
||||||
return output.cache
|
push_child_to_scope(output)
|
||||||
|
return output.cache
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set current position to value
|
||||||
|
local v = ... :: T
|
||||||
|
data.x0_123, data.x0_456 = type_to_vec6[typeof(v)](v)
|
||||||
|
|
||||||
|
-- reset velocity
|
||||||
|
data.v_123 = ZERO
|
||||||
|
data.v_456 = ZERO
|
||||||
|
|
||||||
|
-- schedule spring
|
||||||
|
springs[data] = output
|
||||||
|
|
||||||
|
-- set output to value
|
||||||
|
output.cache = v
|
||||||
|
|
||||||
|
return v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue