@@ -260,7 +260,8 @@ export class MainView extends React.Component<IProps, IStates> {
260
260
261
261
this . _scene = new THREE . Scene ( ) ;
262
262
263
- this . _scene . add ( new THREE . AmbientLight ( 0xffffff , 0.5 ) ) ; // soft white light
263
+ this . _ambientLight = new THREE . AmbientLight ( 0xffffff , 0.5 ) ; // soft white light
264
+ this . _scene . add ( this . _ambientLight ) ;
264
265
265
266
this . _cameraLight = new THREE . PointLight ( 0xffffff , 1 ) ;
266
267
this . _cameraLight . decay = 0 ;
@@ -313,6 +314,7 @@ export class MainView extends React.Component<IProps, IStates> {
313
314
this . _onKeyDown ( e ) ;
314
315
} ) ;
315
316
317
+ // Not enabling damping since it makes the syncing between cameraL and camera trickier
316
318
this . _controls = new OrbitControls (
317
319
this . _camera ,
318
320
this . _renderer . domElement
@@ -323,8 +325,6 @@ export class MainView extends React.Component<IProps, IStates> {
323
325
this . _scene . position . y ,
324
326
this . _scene . position . z
325
327
) ;
326
- this . _controls . enableDamping = true ;
327
- this . _controls . dampingFactor = 0.15 ;
328
328
329
329
this . _renderer . domElement . addEventListener ( 'mousedown' , e => {
330
330
this . _mouseDrag . start . set ( e . clientX , e . clientY ) ;
@@ -579,26 +579,33 @@ export class MainView extends React.Component<IProps, IStates> {
579
579
this . _renderer . setRenderTarget ( null ) ;
580
580
this . _renderer . clear ( ) ;
581
581
582
- if ( this . _sceneL ) {
582
+ if ( this . _sceneL && this . _cameraL ) {
583
+ this . _cameraL . matrixWorld . copy ( this . _camera . matrixWorld ) ;
584
+ this . _cameraL . matrixWorld . decompose (
585
+ this . _cameraL . position ,
586
+ this . _cameraL . quaternion ,
587
+ this . _cameraL . scale
588
+ ) ;
589
+ this . _cameraL . updateProjectionMatrix ( ) ;
590
+
583
591
this . _renderer . setScissor (
584
592
0 ,
585
593
0 ,
586
594
this . _sliderPos ,
587
595
this . _divRef . current ?. clientHeight || 0
588
596
) ;
589
- this . _renderer . render ( this . _sceneL , this . _camera ) ;
597
+ this . _renderer . render ( this . _sceneL , this . _cameraL ) ;
590
598
591
599
this . _renderer . setScissor (
592
600
this . _sliderPos ,
593
601
0 ,
594
602
this . _divRef . current ?. clientWidth || 0 ,
595
603
this . _divRef . current ?. clientHeight || 0
596
604
) ;
597
- this . _renderer . render ( this . _scene , this . _camera ) ;
598
- } else {
599
- this . _renderer . render ( this . _scene , this . _camera ) ;
600
605
}
601
606
607
+ this . _renderer . render ( this . _scene , this . _camera ) ;
608
+
602
609
this . _viewHelper . render ( this . _renderer ) ;
603
610
this . updateCameraRotation ( ) ;
604
611
} ;
@@ -620,6 +627,12 @@ export class MainView extends React.Component<IProps, IStates> {
620
627
this . _camera . bottom = this . _divRef . current . clientHeight / - 2 ;
621
628
}
622
629
this . _camera . updateProjectionMatrix ( ) ;
630
+
631
+ if ( this . _sceneL && this . _cameraL ) {
632
+ this . _sceneL . remove ( this . _cameraL ) ;
633
+ this . _cameraL = this . _camera . clone ( ) ;
634
+ this . _sceneL . add ( this . _cameraL ) ;
635
+ }
623
636
}
624
637
} ;
625
638
@@ -1693,6 +1706,12 @@ export class MainView extends React.Component<IProps, IStates> {
1693
1706
this . _camera . position . copy ( position ) ;
1694
1707
this . _camera . up . copy ( up ) ;
1695
1708
1709
+ if ( this . _sceneL && this . _cameraL ) {
1710
+ this . _sceneL . remove ( this . _cameraL ) ;
1711
+ this . _cameraL = this . _camera . clone ( ) ;
1712
+ this . _sceneL . add ( this . _cameraL ) ;
1713
+ }
1714
+
1696
1715
this . _transformControls . camera = this . _camera ;
1697
1716
this . _clipPlaneTransformControls . camera = this . _camera ;
1698
1717
@@ -1710,16 +1729,16 @@ export class MainView extends React.Component<IProps, IStates> {
1710
1729
this . _sliderPos = ( this . _divRef . current ?. clientWidth ?? 0 ) / 2 ;
1711
1730
this . _sceneL = new THREE . Scene ( ) ;
1712
1731
this . _sceneL . background = SPLITVIEW_BACKGROUND_COLOR ;
1713
- this . _sceneL . add ( new THREE . AmbientLight ( 0xffffff , 0.5 ) ) ; // soft white light
1714
- const light = new THREE . HemisphereLight ( 0xffffff , 0x444444 , 0.5 ) ;
1715
- this . _sceneL . add ( light ) ;
1716
- this . _sceneL . add ( this . _camera ) ;
1717
- this . _sceneL . add ( this . _meshGroup . clone ( true ) ) ;
1732
+ this . _sceneL . add ( this . _ambientLight . clone ( ) ) ; // soft white light
1733
+ this . _cameraL = this . _camera . clone ( ) ;
1734
+ this . _sceneL . add ( this . _cameraL ) ;
1735
+ this . _sceneL . add ( this . _meshGroup . clone ( ) ) ;
1718
1736
this . initSlider ( true ) ;
1719
1737
} else {
1720
1738
this . _renderer . setScissorTest ( false ) ;
1721
1739
this . _sceneL ?. clear ( ) ;
1722
1740
this . _sceneL = undefined ;
1741
+ this . _cameraL = undefined ;
1723
1742
this . initSlider ( false ) ;
1724
1743
}
1725
1744
}
@@ -2006,6 +2025,7 @@ export class MainView extends React.Component<IProps, IStates> {
2006
2025
private _currentSelection : { [ key : string ] : ISelection } | null = null ;
2007
2026
2008
2027
private _scene : THREE . Scene ; // Threejs scene
2028
+ private _ambientLight : THREE . AmbientLight ;
2009
2029
private _camera : THREE . PerspectiveCamera | THREE . OrthographicCamera ; // Threejs camera
2010
2030
private _cameraLight : THREE . PointLight ;
2011
2031
private _raycaster = new THREE . Raycaster ( ) ;
@@ -2032,5 +2052,9 @@ export class MainView extends React.Component<IProps, IStates> {
2032
2052
private _sliderPos = 0 ;
2033
2053
private _slideInit = false ;
2034
2054
private _sceneL : THREE . Scene | undefined = undefined ;
2055
+ private _cameraL :
2056
+ | THREE . PerspectiveCamera
2057
+ | THREE . OrthographicCamera
2058
+ | undefined = undefined ; // Threejs camera
2035
2059
private _keyDownHandler : ( event : KeyboardEvent ) => void ;
2036
2060
}
0 commit comments