feat: make options for appendAnimation and detachAnimation optional#5025
feat: make options for appendAnimation and detachAnimation optional#5025Frank3K wants to merge 3 commits intogoogle:masterfrom
Conversation
Such that the following is possible:
// Example: Only specify repetitions
appendAnimation('some-animation', { repetitions: 5 });
// Example: Only specify fade for detach
detachAnimation('some-animation', { fade: 200 });
| LoopPingPong : | ||
| (repetitions === 1 ? LoopOnce : LoopRepeat); | ||
|
|
||
| const needsToStop = repetitions !== Infinity || mode !== LoopPingPong; |
There was a problem hiding this comment.
@mohammadbaghaei I am particularly not 100% sure about this line.
|
Thanks for requesting these changes, I'll need to test them before submitting |
|
I believe these are all optional already. If you look at the example in https://modelviewer.dev/examples/animation/index.html#appendAnimation Do you mind checking again @Frank3K ? In case this change is not necessary. |
…nd-detach-options-optional
Thanks for reviewing! You're right that the More importantly, it's also a runtime bug. Default parameter values only apply when the argument is This PR fixes both issues by making the properties optional and merging with defaults inside the function I've updated with master and fixed conflicts. |
|
Thanks for the explanation and changes. I'm trying to figure out fi the broken tests are flaky |
Description
This PR makes all parameters of
AppendAnimationOptionsandDetachAnimationOptionsoptional.Such that the following is possible:
Previously, you had to pass all options, or no options at all (in case the default was used). Current code in
master:model-viewer/packages/model-viewer/src/features/animation.ts
Lines 33 to 41 in 4efaf8e
@mohammadbaghaei Would you be so kind to do the review? I tried to use appendAnimation, but then I was a bit surprised I needed to pass all parameters. I have no real experience with these methods, so it would be nice if you can take a look and functionally test.
Reference Issue