File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export class MouseController
4040 forwardVector = new THREE . Vector3 ( 0 , 0 , - 1 ) ;
4141
4242 /** A reference to the main scene camera. */
43- camera ! : THREE . Camera ;
43+ camera ? : THREE . Camera ;
4444
4545 constructor ( ) {
4646 super ( ) ;
@@ -63,7 +63,7 @@ export class MouseController
6363 if ( ! this . userData . connected ) {
6464 return ;
6565 }
66- this . position . copy ( this . camera . position ) ;
66+ this . position . copy ( this . camera ! . position ) ;
6767 }
6868
6969 /**
@@ -73,6 +73,9 @@ export class MouseController
7373 * @param event - The mouse event containing clientX and clientY coordinates.
7474 */
7575 updateMousePositionFromEvent ( event : MouseEvent ) {
76+ if ( this . camera === undefined ) {
77+ return ;
78+ }
7679 // The controller's origin point is always the camera's position.
7780 this . position . copy ( this . camera . position ) ;
7881
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ export class SimulatorControlMode {
8181
8282 updateControllerPositions ( ) {
8383 this . camera . updateMatrixWorld ( ) ;
84- for ( let i = 0 ; i < 2 ; i ++ ) {
84+ for ( let i = 0 ; i < 2 && i < this . input . controllers . length ; i ++ ) {
8585 const controller = this . input . controllers [ i ] ;
8686 controller . position
8787 . copy ( this . simulatorControllerState . localControllerPositions [ i ] )
You can’t perform that action at this time.
0 commit comments