5
5
CUSTOM_ELEMENTS_SCHEMA ,
6
6
ElementRef ,
7
7
input ,
8
+ signal ,
8
9
TemplateRef ,
9
10
viewChild ,
10
11
} from '@angular/core' ;
@@ -54,7 +55,6 @@ import boldFont from './bold.blob';
54
55
bevelOffset: 0,
55
56
}"
56
57
(dblclick)="onDblClick($any($event))"
57
- (pointermissed)="onPointerMissed($any($event))"
58
58
>
59
59
<ngts-mesh-transmission-material
60
60
[options]="$any({ clearcoat: 1, samples: 3, thickness: 40, chromaticAberration: 0.25, anisotropy: 0.4 })"
@@ -109,6 +109,8 @@ export class Letter {
109
109
private controls = this . store . select ( 'controls' ) ;
110
110
protected eventsCompute = this . store . select ( 'events' , 'compute' ) ;
111
111
112
+ private focused = signal ( false ) ;
113
+
112
114
constructor ( ) {
113
115
injectBeforeRender ( ( ) => {
114
116
const contents = this . contentsRef ( ) ?. nativeElement ;
@@ -123,15 +125,13 @@ export class Letter {
123
125
const controls = this . controls ( ) as CameraControls ;
124
126
if ( ! controls ) return ;
125
127
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
+ }
134
134
135
- void controls . reset ( true ) ;
135
+ this . focused . update ( ( v ) => ! v ) ;
136
136
}
137
137
}
0 commit comments