@@ -3,21 +3,29 @@ import { injectBeforeRender, resolveRef } from 'angular-three';
33import { assertInjector } from 'ngxtension/assert-injector' ;
44import { AnimationAction , AnimationClip , AnimationMixer , Object3D } from 'three' ;
55
6- type NgtsAnimationApi < T extends AnimationClip > = {
7- clips : AnimationClip [ ] ;
6+ /**
7+ * name: any to allow consumers to pass in type-safe animation clips
8+ */
9+ type NgtsAnimationClipWithoutName = Omit < AnimationClip , 'name' > & { name : any } ;
10+ type NgtsAnimationClip = Omit < NgtsAnimationClipWithoutName , 'clone' > & { clone : ( ) => NgtsAnimationClip } ;
11+ type NgtsAnimationClips < TAnimationNames extends string > = {
12+ [ Name in TAnimationNames ] : Omit < NgtsAnimationClip , 'name' > & { name : Name } ;
13+ } [ TAnimationNames ] ;
14+ type NgtsAnimationApi < T extends NgtsAnimationClip > = {
15+ clips : T [ ] ;
816 mixer : AnimationMixer ;
917 names : T [ 'name' ] [ ] ;
1018 actions : { [ key in T [ 'name' ] ] : AnimationAction | null } ;
1119} ;
1220
13- export type NgtsAnimation < TAnimation extends AnimationClip = AnimationClip > =
21+ export type NgtsAnimation < TAnimation extends NgtsAnimationClip = NgtsAnimationClip > =
1422 | TAnimation [ ]
1523 | { animations : TAnimation [ ] } ;
1624
1725/**
1826 * Use afterNextRender
1927 */
20- export function injectAnimations < TAnimation extends AnimationClip > (
28+ export function injectAnimations < TAnimation extends NgtsAnimationClip > (
2129 animations : ( ) => NgtsAnimation < TAnimation > | undefined | null ,
2230 object : ElementRef < Object3D > | Object3D | ( ( ) => ElementRef < Object3D > | Object3D | undefined | null ) ,
2331 { injector } : { injector ?: Injector } = { } ,
0 commit comments