@@ -111,6 +111,8 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
111
111
} ,
112
112
} ;
113
113
this . action = {
114
+ loading : false ,
115
+ oldState : '' ,
114
116
scan : null ,
115
117
selectable : true ,
116
118
frameCoordinates : {
@@ -216,6 +218,35 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
216
218
} ) ,
217
219
) ;
218
220
}
221
+ if ( this . model . mode === Mode . DRAW && e . ctrlKey && this . model . data . drawData . initialState ) {
222
+ const { x, y, z } = this . cube . perspective . position ;
223
+ const { x : width , y : height , z : depth } = this . cube . perspective . scale ;
224
+ const { x : rotationX , y : rotationY , z : rotationZ } = this . cube . perspective . rotation ;
225
+ const points = [ x , y , z , rotationX , rotationY , rotationZ , width , height , depth , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
226
+ const initState = this . model . data . drawData . initialState ;
227
+ let label ;
228
+ if ( initState ) {
229
+ ( { label } = initState ) ;
230
+ }
231
+ this . dispatchEvent (
232
+ new CustomEvent ( 'canvas.drawn' , {
233
+ bubbles : false ,
234
+ cancelable : true ,
235
+ detail : {
236
+ state : {
237
+ ...initState ,
238
+ shapeType : 'cuboid' ,
239
+ frame : this . model . data . imageID ,
240
+ points,
241
+ label,
242
+ } ,
243
+ continue : true ,
244
+ duration : 0 ,
245
+ } ,
246
+ } ) ,
247
+ ) ;
248
+ this . action . oldState = Mode . DRAW ;
249
+ }
219
250
} ) ;
220
251
221
252
canvasTopView . addEventListener ( 'mousedown' , this . startAction . bind ( this , 'top' ) ) ;
@@ -293,7 +324,7 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
293
324
this . views . perspective . scene . children [ 0 ] . children ,
294
325
false ,
295
326
) ;
296
- if ( intersects . length !== 0 ) {
327
+ if ( intersects . length !== 0 || this . controller . focused . clientID !== null ) {
297
328
this . setDefaultZoom ( ) ;
298
329
} else {
299
330
const { x, y, z } = this . action . frameCoordinates ;
@@ -417,6 +448,12 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
417
448
viewType . controls . mouseButtons . right = CameraControls . ACTION . NONE ;
418
449
} else {
419
450
viewType . controls = new CameraControls ( viewType . camera , viewType . renderer . domElement ) ;
451
+ viewType . controls . mouseButtons . left = CameraControls . ACTION . NONE ;
452
+ viewType . controls . mouseButtons . right = CameraControls . ACTION . NONE ;
453
+ viewType . controls . mouseButtons . wheel = CameraControls . ACTION . NONE ;
454
+ viewType . controls . touches . one = CameraControls . ACTION . NONE ;
455
+ viewType . controls . touches . two = CameraControls . ACTION . NONE ;
456
+ viewType . controls . touches . three = CameraControls . ACTION . NONE ;
420
457
}
421
458
viewType . controls . minDistance = CONST . MIN_DISTANCE ;
422
459
viewType . controls . maxDistance = CONST . MAX_DISTANCE ;
@@ -493,6 +530,7 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
493
530
494
531
private startAction ( view : any , event : MouseEvent ) : void {
495
532
if ( event . detail !== 1 ) return ;
533
+ if ( this . model . mode === Mode . DRAG_CANVAS ) return ;
496
534
const { clientID } = this . model . data . activeElement ;
497
535
if ( clientID === 'null' ) return ;
498
536
const canvas = this . views [ view as keyof Views ] . renderer . domElement ;
@@ -517,6 +555,7 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
517
555
518
556
private moveAction ( view : any , event : MouseEvent ) : void {
519
557
event . preventDefault ( ) ;
558
+ if ( this . model . mode === Mode . DRAG_CANVAS ) return ;
520
559
const { clientID } = this . model . data . activeElement ;
521
560
if ( clientID === 'null' ) return ;
522
561
const canvas = this . views [ view as keyof Views ] . renderer . domElement ;
@@ -571,10 +610,13 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
571
610
recentMouseVector : new THREE . Vector2 ( 0 , 0 ) ,
572
611
} ,
573
612
} ;
613
+ this . model . mode = Mode . IDLE ;
614
+ this . action . selectable = true ;
574
615
}
575
616
576
617
private completeActions ( ) : void {
577
618
const { scan, detected } = this . action ;
619
+ if ( this . model . mode === Mode . DRAG_CANVAS ) return ;
578
620
if ( ! detected ) {
579
621
this . resetActions ( ) ;
580
622
return ;
@@ -604,8 +646,6 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
604
646
this . adjustPerspectiveCameras ( ) ;
605
647
this . translateReferencePlane ( new THREE . Vector3 ( x , y , z ) ) ;
606
648
this . resetActions ( ) ;
607
- this . model . mode = Mode . IDLE ;
608
- this . action . selectable = true ;
609
649
}
610
650
611
651
private onGroupDone ( objects ?: any [ ] ) : void {
@@ -718,6 +758,7 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
718
758
const object = this . model . data . objects [ i ] ;
719
759
this . setupObject ( object , true ) ;
720
760
}
761
+ this . action . loading = false ;
721
762
}
722
763
}
723
764
@@ -735,6 +776,13 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
735
776
public notify ( model : Canvas3dModel & Master , reason : UpdateReasons ) : void {
736
777
if ( reason === UpdateReasons . IMAGE_CHANGED ) {
737
778
if ( ! model . data . image ) return ;
779
+ this . dispatchEvent ( new CustomEvent ( 'canvas.canceled' ) ) ;
780
+ if ( this . model . mode === Mode . DRAW ) {
781
+ this . model . data . drawData . enabled = false ;
782
+ }
783
+ this . views . perspective . renderer . dispose ( ) ;
784
+ this . model . mode = Mode . BUSY ;
785
+ this . action . loading = true ;
738
786
const loader = new PCDLoader ( ) ;
739
787
const objectURL = URL . createObjectURL ( model . data . image . imageData ) ;
740
788
this . clearScene ( ) ;
@@ -766,12 +814,21 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
766
814
this . setupObjects ( ) ;
767
815
} else if ( reason === UpdateReasons . DRAG_CANVAS ) {
768
816
this . dispatchEvent (
769
- new CustomEvent ( this . mode === Mode . DRAG_CANVAS ? 'canvas.dragstart' : 'canvas.dragstop' , {
817
+ new CustomEvent ( this . model . mode === Mode . DRAG_CANVAS ? 'canvas.dragstart' : 'canvas.dragstop' , {
770
818
bubbles : false ,
771
819
cancelable : true ,
772
820
} ) ,
773
821
) ;
774
822
this . model . data . activeElement . clientID = 'null' ;
823
+ if ( this . model . mode === Mode . DRAG_CANVAS ) {
824
+ const { controls } = this . views . perspective ;
825
+ controls . mouseButtons . left = CameraControls . ACTION . ROTATE ;
826
+ controls . mouseButtons . right = CameraControls . ACTION . TRUCK ;
827
+ controls . mouseButtons . wheel = CameraControls . ACTION . DOLLY ;
828
+ controls . touches . one = CameraControls . ACTION . TOUCH_ROTATE ;
829
+ controls . touches . two = CameraControls . ACTION . TOUCH_DOLLY_TRUCK ;
830
+ controls . touches . three = CameraControls . ACTION . TOUCH_TRUCK ;
831
+ }
775
832
this . setupObjects ( ) ;
776
833
} else if ( reason === UpdateReasons . CANCEL ) {
777
834
if ( this . mode === Mode . DRAW ) {
@@ -783,7 +840,14 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
783
840
}
784
841
this . model . data . groupData . grouped = [ ] ;
785
842
this . setHelperVisibility ( false ) ;
786
- this . mode = Mode . IDLE ;
843
+ this . model . mode = Mode . IDLE ;
844
+ const { controls } = this . views . perspective ;
845
+ controls . mouseButtons . left = CameraControls . ACTION . NONE ;
846
+ controls . mouseButtons . right = CameraControls . ACTION . NONE ;
847
+ controls . mouseButtons . wheel = CameraControls . ACTION . NONE ;
848
+ controls . touches . one = CameraControls . ACTION . NONE ;
849
+ controls . touches . two = CameraControls . ACTION . NONE ;
850
+ controls . touches . three = CameraControls . ACTION . NONE ;
787
851
this . dispatchEvent ( new CustomEvent ( 'canvas.canceled' ) ) ;
788
852
} else if ( reason === UpdateReasons . FITTED_CANVAS ) {
789
853
this . dispatchEvent ( new CustomEvent ( 'canvas.fit' ) ) ;
@@ -1153,6 +1217,8 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
1153
1217
}
1154
1218
this . updateRotationHelperPos ( ) ;
1155
1219
this . updateResizeHelperPos ( ) ;
1220
+ } else {
1221
+ this . resetActions ( ) ;
1156
1222
}
1157
1223
}
1158
1224
}
@@ -1166,6 +1232,16 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
1166
1232
this . action . detachCam = false ;
1167
1233
}
1168
1234
}
1235
+ if ( this . model . mode === Mode . BUSY && ! this . action . loading ) {
1236
+ if ( this . action . oldState !== '' ) {
1237
+ this . model . mode = this . action . oldState ;
1238
+ this . action . oldState = '' ;
1239
+ } else {
1240
+ this . model . mode = Mode . IDLE ;
1241
+ }
1242
+ } else if ( this . model . data . objectUpdating && ! this . action . loading ) {
1243
+ this . model . data . objectUpdating = false ;
1244
+ }
1169
1245
}
1170
1246
1171
1247
private adjustPerspectiveCameras ( ) : void {
@@ -1729,9 +1805,6 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
1729
1805
true ,
1730
1806
) ;
1731
1807
if ( intersectsBox . length !== 0 ) {
1732
- // const [state] = this.model.data.objects.filter(
1733
- // (_state: any): boolean => _state.clientID === Number(this.model.data.selected[view].name),
1734
- // );
1735
1808
if ( state . pinned ) return ;
1736
1809
this . action . translation . helper = viewType . rayCaster . mouseVector . clone ( ) ;
1737
1810
this . action . translation . inverseMatrix = intersectsBox [ 0 ] . object . parent . matrixWorld . invert ( ) ;
@@ -1749,26 +1822,24 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
1749
1822
public keyControls ( key : any ) : void {
1750
1823
const { controls } = this . views . perspective ;
1751
1824
if ( ! controls ) return ;
1752
- switch ( key . code ) {
1753
- case CameraAction . ROTATE_RIGHT :
1754
- controls . rotate ( 0.1 * THREE . MathUtils . DEG2RAD * this . speed , 0 , true ) ;
1755
- break ;
1756
- case CameraAction . ROTATE_LEFT :
1757
- controls . rotate ( - 0.1 * THREE . MathUtils . DEG2RAD * this . speed , 0 , true ) ;
1758
- break ;
1759
- case CameraAction . TILT_UP :
1760
- controls . rotate ( 0 , - 0.05 * THREE . MathUtils . DEG2RAD * this . speed , true ) ;
1761
- break ;
1762
- case CameraAction . TILT_DOWN :
1763
- controls . rotate ( 0 , 0.05 * THREE . MathUtils . DEG2RAD * this . speed , true ) ;
1764
- break ;
1765
- case 'ControlLeft' :
1766
- this . action . selectable = ! key . ctrlKey ;
1767
- break ;
1768
- default :
1769
- break ;
1770
- }
1771
- if ( key . altKey === true ) {
1825
+ if ( key . shiftKey ) {
1826
+ switch ( key . code ) {
1827
+ case CameraAction . ROTATE_RIGHT :
1828
+ controls . rotate ( 0.1 * THREE . MathUtils . DEG2RAD * this . speed , 0 , true ) ;
1829
+ break ;
1830
+ case CameraAction . ROTATE_LEFT :
1831
+ controls . rotate ( - 0.1 * THREE . MathUtils . DEG2RAD * this . speed , 0 , true ) ;
1832
+ break ;
1833
+ case CameraAction . TILT_UP :
1834
+ controls . rotate ( 0 , - 0.05 * THREE . MathUtils . DEG2RAD * this . speed , true ) ;
1835
+ break ;
1836
+ case CameraAction . TILT_DOWN :
1837
+ controls . rotate ( 0 , 0.05 * THREE . MathUtils . DEG2RAD * this . speed , true ) ;
1838
+ break ;
1839
+ default :
1840
+ break ;
1841
+ }
1842
+ } else if ( key . altKey === true ) {
1772
1843
switch ( key . code ) {
1773
1844
case CameraAction . ZOOM_IN :
1774
1845
controls . dolly ( CONST . DOLLY_FACTOR , true ) ;
@@ -1791,6 +1862,8 @@ export class Canvas3dViewImpl implements Canvas3dView, Listener {
1791
1862
default :
1792
1863
break ;
1793
1864
}
1865
+ } else if ( key . code === 'ControlLeft' ) {
1866
+ this . action . selectable = ! key . ctrlKey ;
1794
1867
}
1795
1868
}
1796
1869
0 commit comments