rive-app / rive-wasm

Wasm/JS runtime for Rive
MIT License
669 stars 46 forks source link

Types: LinearAnimation vs LineraAnimationInstance #286

Open GrandSchtroumpf opened 1 year ago

GrandSchtroumpf commented 1 year ago

In the type the LinearAnimationInstance has properties like workStart or workEnd, which are not accessible once we instantiate the class with the LinearAnimation. https://github.com/rive-app/rive-wasm/blob/master/js/src/rive_advanced.mjs.d.ts#L402

It would be better to differentiate the LinearAnimation provided in the constructor, which has these properties, from the LinearAnimationInstance.

It might be the same problem with the StateMachine & StateMachineInstance

zplata commented 1 year ago

Is there a reason you need LinearAnimation ? The latest guidance is to use LinearAnimationInstance and StateMachineInstance when using the low-level runtime APIs. I think in the next major version we'll want to sunset the LinearAnimation and StateMachine classes so as not to make a confusing developer experience on which to use.

More here: https://help.rive.app/runtimes/overview/web-js/low-level-api-usage

GrandSchtroumpf commented 1 year ago

I need it to get the workStart, workEnd and fps values. ng-rive has a riv-player component that enables you advance the linear animation For example:

<canvas riv="poison-loader" width="500" height="500">
  <riv-player #player="rivPlayer" name="idle" [time]="time"></riv-player>
</canvas>
<input type="range" step="0.1" (input)="time = $event.target.value" [min]="player.startTime" [max]="player.endTime" />

Here we can get the startTime & endTime derived from the workStart & workEnd.

When you say you want to sunset the LinearAnimation do you mean removing it from the bindings or not exposing it as a type ?