@@ -260,7 +260,8 @@ export class MainView extends React.Component<IProps, IStates> {
260260
261261 this . _scene = new THREE . Scene ( ) ;
262262
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 ) ;
264265
265266 this . _cameraLight = new THREE . PointLight ( 0xffffff , 1 ) ;
266267 this . _cameraLight . decay = 0 ;
@@ -313,6 +314,7 @@ export class MainView extends React.Component<IProps, IStates> {
313314 this . _onKeyDown ( e ) ;
314315 } ) ;
315316
317+ // Not enabling damping since it makes the syncing between cameraL and camera trickier
316318 this . _controls = new OrbitControls (
317319 this . _camera ,
318320 this . _renderer . domElement
@@ -323,8 +325,6 @@ export class MainView extends React.Component<IProps, IStates> {
323325 this . _scene . position . y ,
324326 this . _scene . position . z
325327 ) ;
326- this . _controls . enableDamping = true ;
327- this . _controls . dampingFactor = 0.15 ;
328328
329329 this . _renderer . domElement . addEventListener ( 'mousedown' , e => {
330330 this . _mouseDrag . start . set ( e . clientX , e . clientY ) ;
@@ -579,26 +579,33 @@ export class MainView extends React.Component<IProps, IStates> {
579579 this . _renderer . setRenderTarget ( null ) ;
580580 this . _renderer . clear ( ) ;
581581
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+
583591 this . _renderer . setScissor (
584592 0 ,
585593 0 ,
586594 this . _sliderPos ,
587595 this . _divRef . current ?. clientHeight || 0
588596 ) ;
589- this . _renderer . render ( this . _sceneL , this . _camera ) ;
597+ this . _renderer . render ( this . _sceneL , this . _cameraL ) ;
590598
591599 this . _renderer . setScissor (
592600 this . _sliderPos ,
593601 0 ,
594602 this . _divRef . current ?. clientWidth || 0 ,
595603 this . _divRef . current ?. clientHeight || 0
596604 ) ;
597- this . _renderer . render ( this . _scene , this . _camera ) ;
598- } else {
599- this . _renderer . render ( this . _scene , this . _camera ) ;
600605 }
601606
607+ this . _renderer . render ( this . _scene , this . _camera ) ;
608+
602609 this . _viewHelper . render ( this . _renderer ) ;
603610 this . updateCameraRotation ( ) ;
604611 } ;
@@ -620,6 +627,12 @@ export class MainView extends React.Component<IProps, IStates> {
620627 this . _camera . bottom = this . _divRef . current . clientHeight / - 2 ;
621628 }
622629 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+ }
623636 }
624637 } ;
625638
@@ -1693,6 +1706,12 @@ export class MainView extends React.Component<IProps, IStates> {
16931706 this . _camera . position . copy ( position ) ;
16941707 this . _camera . up . copy ( up ) ;
16951708
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+
16961715 this . _transformControls . camera = this . _camera ;
16971716 this . _clipPlaneTransformControls . camera = this . _camera ;
16981717
@@ -1710,16 +1729,16 @@ export class MainView extends React.Component<IProps, IStates> {
17101729 this . _sliderPos = ( this . _divRef . current ?. clientWidth ?? 0 ) / 2 ;
17111730 this . _sceneL = new THREE . Scene ( ) ;
17121731 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 ( ) ) ;
17181736 this . initSlider ( true ) ;
17191737 } else {
17201738 this . _renderer . setScissorTest ( false ) ;
17211739 this . _sceneL ?. clear ( ) ;
17221740 this . _sceneL = undefined ;
1741+ this . _cameraL = undefined ;
17231742 this . initSlider ( false ) ;
17241743 }
17251744 }
@@ -2006,6 +2025,7 @@ export class MainView extends React.Component<IProps, IStates> {
20062025 private _currentSelection : { [ key : string ] : ISelection } | null = null ;
20072026
20082027 private _scene : THREE . Scene ; // Threejs scene
2028+ private _ambientLight : THREE . AmbientLight ;
20092029 private _camera : THREE . PerspectiveCamera | THREE . OrthographicCamera ; // Threejs camera
20102030 private _cameraLight : THREE . PointLight ;
20112031 private _raycaster = new THREE . Raycaster ( ) ;
@@ -2032,5 +2052,9 @@ export class MainView extends React.Component<IProps, IStates> {
20322052 private _sliderPos = 0 ;
20332053 private _slideInit = false ;
20342054 private _sceneL : THREE . Scene | undefined = undefined ;
2055+ private _cameraL :
2056+ | THREE . PerspectiveCamera
2057+ | THREE . OrthographicCamera
2058+ | undefined = undefined ; // Threejs camera
20352059 private _keyDownHandler : ( event : KeyboardEvent ) => void ;
20362060}
0 commit comments