55 CUSTOM_ELEMENTS_SCHEMA ,
66 ElementRef ,
77 input ,
8+ signal ,
89 TemplateRef ,
910 viewChild ,
1011} from '@angular/core' ;
@@ -54,7 +55,6 @@ import boldFont from './bold.blob';
5455 bevelOffset: 0,
5556 }"
5657 (dblclick)="onDblClick($any($event))"
57- (pointermissed)="onPointerMissed($any($event))"
5858 >
5959 <ngts-mesh-transmission-material
6060 [options]="$any({ clearcoat: 1, samples: 3, thickness: 40, chromaticAberration: 0.25, anisotropy: 0.4 })"
@@ -109,6 +109,8 @@ export class Letter {
109109 private controls = this . store . select ( 'controls' ) ;
110110 protected eventsCompute = this . store . select ( 'events' , 'compute' ) ;
111111
112+ private focused = signal ( false ) ;
113+
112114 constructor ( ) {
113115 injectBeforeRender ( ( ) => {
114116 const contents = this . contentsRef ( ) ?. nativeElement ;
@@ -123,15 +125,13 @@ export class Letter {
123125 const controls = this . controls ( ) as CameraControls ;
124126 if ( ! controls ) return ;
125127
126- // NOTE: if any of the render-texture scene has other controls, it messes this up
127- void controls . fitToBox ( this . centerRef ( ) . groupRef ( ) . nativeElement , true ) ;
128- }
129-
130- onPointerMissed ( event : NgtThreeEvent < MouseEvent > ) {
131- event . stopPropagation ( ) ;
132- const controls = this . controls ( ) as CameraControls ;
133- if ( ! controls ) return ;
128+ if ( this . focused ( ) ) {
129+ void controls . reset ( true ) ;
130+ } else {
131+ // NOTE: if any of the render-texture scene has other controls, it messes this up
132+ void controls . fitToBox ( this . centerRef ( ) . groupRef ( ) . nativeElement , true ) ;
133+ }
134134
135- void controls . reset ( true ) ;
135+ this . focused . update ( ( v ) => ! v ) ;
136136 }
137137}
0 commit comments