hrgdavor / jscadui

MIT License
30 stars 9 forks source link

animation slider #113

Closed hrgdavor closed 1 month ago

hrgdavor commented 3 months ago

postponed for next pr

TODO

Add simple support for running animations

// 5 seconds animation at 60Fps
{name:"anim1", type:"slider", min:0, max:5, step:0.016, fps:60}

// 2 seconds animation at 30Fps, start animating automatically after script is loaded
{name:"anim2", type:"slider", min:0, max:2, step:0.033, fps:30, autostart:true}

// starts from zero again when reaches end time
{name:"anim2", type:"slider", min:0, max:2, step:0.033, fps:30, autostart:true, loop:'restart'}

// reverses when reaches end/start time
{name:"anim2", type:"slider", min:0, max:2, step:0.033, fps:30, autostart:true, loop:'reverse'}

animation frame strategy

request frame send all parameters from form and the new value for time(t) FPS is honored only if possible only, time is sent to reflect current time animation needs to execute so animation will track time, but not be as smooth if render is > (1000/fps)ms

slider improvement

In preparation for animation option I have made improvements to slider UI in few ways

https://github.com/user-attachments/assets/ff42d217-68cf-4d45-a63e-15dd98b3ab2c