11import { computed , effect , ElementRef , Injector , isSignal , signal , untracked } from '@angular/core' ;
2- import { injectBeforeRender , resolveRef } from 'angular-three' ;
2+ import { beforeRender , resolveRef } from 'angular-three' ;
33import { assertInjector } from 'ngxtension/assert-injector' ;
44import * as THREE from 'three' ;
55
@@ -38,17 +38,17 @@ export type NgtsAnimation<TAnimation extends NgtsAnimationClip = NgtsAnimationCl
3838/**
3939 * Use afterNextRender
4040 */
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 ,
4343 object :
4444 | ElementRef < THREE . Object3D >
4545 | THREE . Object3D
4646 | ( ( ) => ElementRef < THREE . Object3D > | THREE . Object3D | undefined | null ) ,
4747 { injector } : { injector ?: Injector } = { } ,
4848) : NgtsAnimationApi < TAnimation > {
49- return assertInjector ( injectAnimations , injector , ( ) => {
49+ return assertInjector ( animations , injector , ( ) => {
5050 const mixer = new THREE . AnimationMixer ( null ! ) ;
51- injectBeforeRender ( ( { delta } ) => {
51+ beforeRender ( ( { delta } ) => {
5252 if ( ! mixer . getRoot ( ) ) return ;
5353 mixer . update ( delta ) ;
5454 } ) ;
@@ -74,7 +74,7 @@ export function injectAnimations<TAnimation extends NgtsAnimationClip>(
7474
7575 Object . assign ( mixer , { _root : obj } ) ;
7676
77- const maybeAnimationClips = animations ( ) ;
77+ const maybeAnimationClips = animationsFactory ( ) ;
7878 if ( ! maybeAnimationClips ) return ;
7979
8080 const animationClips = Array . isArray ( maybeAnimationClips )
@@ -117,10 +117,27 @@ export function injectAnimations<TAnimation extends NgtsAnimationClip>(
117117 } ) ;
118118 } ) ;
119119
120- const result = { ready , clips, mixer, actions, names } as unknown as NgtsAnimationApi < TAnimation > ;
120+ const result = { clips, mixer, actions, names } as NgtsAnimationApi < TAnimation > ;
121121
122122 Object . defineProperty ( result , 'isReady' , { get : ready } ) ;
123123
124124 return result ;
125125 } ) ;
126126}
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