@@ -3,21 +3,29 @@ import { injectBeforeRender, resolveRef } from 'angular-three';
3
3
import { assertInjector } from 'ngxtension/assert-injector' ;
4
4
import { AnimationAction , AnimationClip , AnimationMixer , Object3D } from 'three' ;
5
5
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 [ ] ;
8
16
mixer : AnimationMixer ;
9
17
names : T [ 'name' ] [ ] ;
10
18
actions : { [ key in T [ 'name' ] ] : AnimationAction | null } ;
11
19
} ;
12
20
13
- export type NgtsAnimation < TAnimation extends AnimationClip = AnimationClip > =
21
+ export type NgtsAnimation < TAnimation extends NgtsAnimationClip = NgtsAnimationClip > =
14
22
| TAnimation [ ]
15
23
| { animations : TAnimation [ ] } ;
16
24
17
25
/**
18
26
* Use afterNextRender
19
27
*/
20
- export function injectAnimations < TAnimation extends AnimationClip > (
28
+ export function injectAnimations < TAnimation extends NgtsAnimationClip > (
21
29
animations : ( ) => NgtsAnimation < TAnimation > | undefined | null ,
22
30
object : ElementRef < Object3D > | Object3D | ( ( ) => ElementRef < Object3D > | Object3D | undefined | null ) ,
23
31
{ injector } : { injector ?: Injector } = { } ,
0 commit comments