Skip to content

Commit

Permalink
ensure animation curve is a function.
Browse files Browse the repository at this point in the history
  • Loading branch information
petteramland committed Aug 29, 2024
1 parent f618139 commit 8fe2fc9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions taptapir.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,12 @@ function set_fullscreen(value) {

curves = {
'linear' : (a, b, t) => {
return lerp(a, b, t)},
return lerp(a, b, t)
},

'out_expo' : (a, b, t) => {
return lerp(a, b, t*t)}
return lerp(a, b, t*t)
}
}

ASSETS_FOLDER = ''
Expand Down Expand Up @@ -729,8 +731,13 @@ class Entity {
if (!entity.enabled) {
return false}
var t = i / duration / 60
// entity[variable_name] = lerp(start_value, target_value, t)
entity[variable_name] = curve(start_value, target_value, t)
if (typeof curve === 'function') {
entity[variable_name] = curve(start_value, target_value, t)
}
else {
// fallback to linear
// entity[variable_name] = lerp(start_value, target_value, t)
}
},
1000*i/60
)
Expand Down

0 comments on commit 8fe2fc9

Please sign in to comment.