@@ -26,13 +26,7 @@ import { TheatreSheetObject } from './sheet-object';
26
26
selector : 'theatre-transform' ,
27
27
template : `
28
28
@if (selected()) {
29
- <ngts-transform-controls
30
- [object]="$any(group)"
31
- [options]="options()"
32
- (mouseDown)="onMouseDown()"
33
- (mouseUp)="onMouseUp()"
34
- (change)="onChange()"
35
- />
29
+ <ngts-transform-controls [object]="$any(group)" [options]="options()" />
36
30
}
37
31
38
32
<ngt-group #group>
@@ -51,6 +45,7 @@ export class TheatreSheetObjectTransform<TLabel extends string | undefined> {
51
45
) ;
52
46
53
47
groupRef = viewChild . required < ElementRef < THREE . Group > > ( 'group' ) ;
48
+ private controlsRef = viewChild ( NgtsTransformControls ) ;
54
49
55
50
private theatreSheetObject = inject ( TheatreSheetObject ) ;
56
51
sheetObject = computed ( ( ) => this . theatreSheetObject . sheetObject ( ) ) ;
@@ -139,6 +134,22 @@ export class TheatreSheetObjectTransform<TLabel extends string | undefined> {
139
134
onCleanup ( cleanup ) ;
140
135
} ) ;
141
136
137
+ // TODO: (chau) use event binding when they no longer trigger change detection
138
+ effect ( ( onCleanup ) => {
139
+ const controls = this . controlsRef ( ) ;
140
+ if ( ! controls ) return ;
141
+
142
+ const subs = [
143
+ controls . change . subscribe ( this . onChange . bind ( this ) ) ,
144
+ controls . mouseDown . subscribe ( this . onMouseDown . bind ( this ) ) ,
145
+ controls . mouseUp . subscribe ( this . onMouseUp . bind ( this ) ) ,
146
+ ] ;
147
+
148
+ onCleanup ( ( ) => {
149
+ subs . forEach ( ( sub ) => sub . unsubscribe ( ) ) ;
150
+ } ) ;
151
+ } ) ;
152
+
142
153
inject ( DestroyRef ) . onDestroy ( ( ) => {
143
154
const key = this . key ( ) ;
144
155
this . theatreSheetObject . removeProps ( key ? [ key ] : [ 'position' , 'rotation' , 'scale' ] ) ;
0 commit comments