1
1
import { computed , effect , ElementRef , Injector , isSignal , signal , untracked } from '@angular/core' ;
2
- import { injectBeforeRender , resolveRef } from 'angular-three' ;
2
+ import { beforeRender , resolveRef } from 'angular-three' ;
3
3
import { assertInjector } from 'ngxtension/assert-injector' ;
4
4
import * as THREE from 'three' ;
5
5
@@ -38,17 +38,17 @@ export type NgtsAnimation<TAnimation extends NgtsAnimationClip = NgtsAnimationCl
38
38
/**
39
39
* Use afterNextRender
40
40
*/
41
- export function injectAnimations < TAnimation extends NgtsAnimationClip > (
42
- animations : ( ) => NgtsAnimation < TAnimation > | undefined | null ,
41
+ export function animations < TAnimation extends NgtsAnimationClip > (
42
+ animationsFactory : ( ) => NgtsAnimation < TAnimation > | undefined | null ,
43
43
object :
44
44
| ElementRef < THREE . Object3D >
45
45
| THREE . Object3D
46
46
| ( ( ) => ElementRef < THREE . Object3D > | THREE . Object3D | undefined | null ) ,
47
47
{ injector } : { injector ?: Injector } = { } ,
48
48
) : NgtsAnimationApi < TAnimation > {
49
- return assertInjector ( injectAnimations , injector , ( ) => {
49
+ return assertInjector ( animations , injector , ( ) => {
50
50
const mixer = new THREE . AnimationMixer ( null ! ) ;
51
- injectBeforeRender ( ( { delta } ) => {
51
+ beforeRender ( ( { delta } ) => {
52
52
if ( ! mixer . getRoot ( ) ) return ;
53
53
mixer . update ( delta ) ;
54
54
} ) ;
@@ -74,7 +74,7 @@ export function injectAnimations<TAnimation extends NgtsAnimationClip>(
74
74
75
75
Object . assign ( mixer , { _root : obj } ) ;
76
76
77
- const maybeAnimationClips = animations ( ) ;
77
+ const maybeAnimationClips = animationsFactory ( ) ;
78
78
if ( ! maybeAnimationClips ) return ;
79
79
80
80
const animationClips = Array . isArray ( maybeAnimationClips )
@@ -117,10 +117,27 @@ export function injectAnimations<TAnimation extends NgtsAnimationClip>(
117
117
} ) ;
118
118
} ) ;
119
119
120
- const result = { ready , clips, mixer, actions, names } as unknown as NgtsAnimationApi < TAnimation > ;
120
+ const result = { clips, mixer, actions, names } as NgtsAnimationApi < TAnimation > ;
121
121
122
122
Object . defineProperty ( result , 'isReady' , { get : ready } ) ;
123
123
124
124
return result ;
125
125
} ) ;
126
126
}
127
+
128
+ /**
129
+ * @deprecated use animations instead. Will be removed in v5.0.0
130
+ * @since v4.0.0
131
+ */
132
+ export function injectAnimations < TAnimation extends NgtsAnimationClip > (
133
+ animationsFactory : ( ) => NgtsAnimation < TAnimation > | undefined | null ,
134
+ object :
135
+ | ElementRef < THREE . Object3D >
136
+ | THREE . Object3D
137
+ | ( ( ) => ElementRef < THREE . Object3D > | THREE . Object3D | undefined | null ) ,
138
+ { injector } : { injector ?: Injector } = { } ,
139
+ ) : NgtsAnimationApi < TAnimation > {
140
+ return assertInjector ( injectAnimations , injector , ( ) => {
141
+ return animations ( animationsFactory , object , { injector } ) ;
142
+ } ) ;
143
+ }
0 commit comments