@@ -37,7 +37,7 @@ const defaultOptions: Partial<NgtMesh> & NgtsText3DOptions = {
37
37
standalone : true ,
38
38
template : `
39
39
<ngt-mesh #mesh [parameters]="parameters()">
40
- <ngt-text-geometry *args="textArgs()" />
40
+ <ngt-text-geometry #textGeometry *args="textArgs()" />
41
41
<ng-content />
42
42
</ngt-mesh>
43
43
` ,
@@ -63,7 +63,8 @@ export class NgtsText3D {
63
63
'smooth' ,
64
64
] ) ;
65
65
66
- meshRef = viewChild < ElementRef < Mesh > > ( 'mesh' ) ;
66
+ meshRef = viewChild . required < ElementRef < Mesh > > ( 'mesh' ) ;
67
+ private textGeometryRef = viewChild < ElementRef < TextGeometry > > ( 'textGeometry' ) ;
67
68
68
69
loadedFont = injectFont ( this . font ) ;
69
70
private smooth = pick ( this . options , 'smooth' ) ;
@@ -90,12 +91,16 @@ export class NgtsText3D {
90
91
extend ( { Mesh, TextGeometry } ) ;
91
92
92
93
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 ;
95
100
96
101
const smooth = this . smooth ( ) ;
97
102
if ( smooth ) {
98
- mesh . geometry = mergeVertices ( mesh . geometry , smooth ) ;
103
+ mesh . geometry = mergeVertices ( textGeometry , smooth ) ;
99
104
mesh . geometry . computeVertexNormals ( ) ;
100
105
}
101
106
} ) ;
0 commit comments