@@ -6,6 +6,7 @@ function parse(fileName, gltf, options = {}) {
6
6
const animations = gltf . animations ;
7
7
const hasAnimations = animations . length > 0 ;
8
8
const selector = options . selector ?? "app-model" ;
9
+ const componentName = options . name ?? "Model" ;
9
10
const ngtTypes = new Set ( ) ;
10
11
11
12
// Collect all objects
@@ -107,7 +108,8 @@ function parse(fileName, gltf, options = {}) {
107
108
108
109
if ( animations . length ) {
109
110
types . push (
110
- `type ActionName = ${ animations . map ( ( clip , i ) => `"${ clip . name } "` ) . join ( " | " ) } ;` ,
111
+ `type ActionName = ${ animations . map ( ( clip , i ) => `"${ clip . name } "` ) . join ( " | " ) } ;
112
+ type GLTFAnimationClips = NgtsAnimationClips<ActionName>;` ,
111
113
) ;
112
114
}
113
115
@@ -581,7 +583,7 @@ function parse(fileName, gltf, options = {}) {
581
583
import { Component, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, Signal, input, viewChild, ElementRef, inject, effect${ hasAnimations ? ", computed, model" : "" } } from '@angular/core';
582
584
import { injectGLTF } from 'angular-three-soba/loaders';
583
585
import { GLTF } from 'three-stdlib';
584
- ${ hasAnimations ? "import { injectAnimations } from 'angular-three-soba/misc';" : "" }
586
+ ${ hasAnimations ? "import { injectAnimations, NgtsAnimationClips } from 'angular-three-soba/misc';" : "" }
585
587
${ ngtTypes . has ( "PerspectiveCamera" ) ? "import { NgtsPerspectiveCamera } from 'angular-three-soba/cameras';" : "" }
586
588
${ ngtTypes . has ( "OrthographicCamera" ) ? "import { NgtsOrthographicCamera } from 'angular-three-soba/cameras';" : "" }
587
589
` ;
@@ -641,11 +643,11 @@ ${printTypes(objects, animations)}
641
643
schemas: [CUSTOM_ELEMENTS_SCHEMA],
642
644
changeDetection: ChangeDetectionStrategy.OnPush
643
645
})
644
- export class Model {
646
+ export class ${ componentName } {
645
647
protected readonly Math = Math;
646
648
647
649
options = input({} as Partial<NgtGroup>);
648
- ${ hasAnimations ? "animations = model<any >();" : "" }
650
+ ${ hasAnimations ? "animations = model<ReturnType<typeof injectAnimations<GLTFAnimationClips>> >();" : "" }
649
651
modelRef = viewChild<ElementRef<Group>>('model');
650
652
651
653
protected gltf = injectGLTF(() => "${ url } "${ gltfOptions ? `, ${ JSON . stringify ( gltfOptions ) } ` : "" } ) as unknown as Signal<GLTFResult | null>;
0 commit comments