@@ -37,7 +37,7 @@ const defaultOptions: Partial<NgtMesh> & NgtsText3DOptions = {
3737 standalone : true ,
3838 template : `
3939 <ngt-mesh #mesh [parameters]="parameters()">
40- <ngt-text-geometry *args="textArgs()" />
40+ <ngt-text-geometry #textGeometry *args="textArgs()" />
4141 <ng-content />
4242 </ngt-mesh>
4343 ` ,
@@ -63,7 +63,8 @@ export class NgtsText3D {
6363 'smooth' ,
6464 ] ) ;
6565
66- meshRef = viewChild < ElementRef < Mesh > > ( 'mesh' ) ;
66+ meshRef = viewChild . required < ElementRef < Mesh > > ( 'mesh' ) ;
67+ private textGeometryRef = viewChild < ElementRef < TextGeometry > > ( 'textGeometry' ) ;
6768
6869 loadedFont = injectFont ( this . font ) ;
6970 private smooth = pick ( this . options , 'smooth' ) ;
@@ -90,12 +91,16 @@ export class NgtsText3D {
9091 extend ( { Mesh, TextGeometry } ) ;
9192
9293 effect ( ( ) => {
93- const [ mesh , textArgs ] = [ this . meshRef ( ) ?. nativeElement , this . textArgs ( ) ] ;
94- if ( ! textArgs || ! mesh ) return ;
94+ const [ mesh , textGeometry , textArgs ] = [
95+ this . meshRef ( ) ?. nativeElement ,
96+ this . textGeometryRef ( ) ?. nativeElement ,
97+ this . textArgs ( ) ,
98+ ] ;
99+ if ( ! textArgs || ! textGeometry || ! mesh ) return ;
95100
96101 const smooth = this . smooth ( ) ;
97102 if ( smooth ) {
98- mesh . geometry = mergeVertices ( mesh . geometry , smooth ) ;
103+ mesh . geometry = mergeVertices ( textGeometry , smooth ) ;
99104 mesh . geometry . computeVertexNormals ( ) ;
100105 }
101106 } ) ;
0 commit comments