@@ -27,17 +27,23 @@ const $detachAnimation = Symbol('detachAnimation');
2727const $paused = Symbol ( 'paused' ) ;
2828
2929interface PlayAnimationOptions {
30- repetitions : number , pingpong : boolean ,
30+ repetitions : number ;
31+ pingpong : boolean ;
3132}
3233
3334interface AppendAnimationOptions {
34- pingpong : boolean , repetitions : number | null , weight : number ,
35- timeScale : number , fade : boolean | number , warp : boolean | number ,
36- relativeWarp : boolean , time : number | null
35+ pingpong ?: boolean ;
36+ repetitions ?: number | null ;
37+ weight ?: number ;
38+ timeScale ?: number ;
39+ fade ?: boolean | number ;
40+ warp ?: boolean | number ;
41+ relativeWarp ?: boolean ;
42+ time ?: number | null ;
3743}
3844
3945interface DetachAnimationOptions {
40- fade : boolean | number
46+ fade ? : boolean | number ;
4147}
4248
4349const DEFAULT_PLAY_OPTIONS : PlayAnimationOptions = {
@@ -262,9 +268,10 @@ export const AnimationMixin = <T extends Constructor<ModelViewerElementBase>>(
262268
263269 [ $appendAnimation ] (
264270 animationName : string = '' ,
265- options : AppendAnimationOptions = DEFAULT_APPEND_OPTIONS ) {
266- const repetitions = options . repetitions ?? Infinity ;
267- const mode = options . pingpong ?
271+ options : AppendAnimationOptions = { } ) {
272+ const opts = { ...DEFAULT_APPEND_OPTIONS , ...options } ;
273+ const repetitions = opts . repetitions ?? Infinity ;
274+ const mode = opts . pingpong ?
268275 LoopPingPong :
269276 ( repetitions === 1 ? LoopOnce : LoopRepeat ) ;
270277
@@ -274,12 +281,12 @@ export const AnimationMixin = <T extends Constructor<ModelViewerElementBase>>(
274281 animationName ? animationName : this . animationName ,
275282 mode ,
276283 repetitions ,
277- options . weight ,
278- options . timeScale ,
279- options . fade ,
280- options . warp ,
281- options . relativeWarp ,
282- options . time ,
284+ opts . weight ,
285+ opts . timeScale ,
286+ opts . fade ,
287+ opts . warp ,
288+ opts . relativeWarp ,
289+ opts . time ,
283290 needsToStop ) ;
284291
285292 // If we are currently paused, we need to force a render so that
@@ -292,9 +299,10 @@ export const AnimationMixin = <T extends Constructor<ModelViewerElementBase>>(
292299
293300 [ $detachAnimation ] (
294301 animationName : string = '' ,
295- options : DetachAnimationOptions = DEFAULT_DETACH_OPTIONS ) {
302+ options : DetachAnimationOptions = { } ) {
303+ const opts = { ...DEFAULT_DETACH_OPTIONS , ...options } ;
296304 this [ $scene ] . detachAnimation (
297- animationName ? animationName : this . animationName , options . fade ) ;
305+ animationName ? animationName : this . animationName , opts . fade ) ;
298306
299307 // If we are currently paused, we need to force a render so that
300308 // the scene updates to the first frame of the new animation
0 commit comments