@@ -21,6 +21,7 @@ export default class FreeControlsNavigator extends ControlsNavigator {
2121 private yawMinusKeyPressed : boolean = false ;
2222 private yawPlusKeyPressed : boolean = false ;
2323 private pointerLocked : boolean = false ;
24+ private bikeMode : boolean = false ;
2425
2526 public constructor (
2627 element : HTMLElement ,
@@ -216,11 +217,18 @@ export default class FreeControlsNavigator extends ControlsNavigator {
216217 } ;
217218 }
218219
220+ public setBikeMode ( bikeMode : boolean ) : void {
221+ this . bikeMode = bikeMode ;
222+ }
223+
219224 public update ( deltaTime : number ) : void {
220225 const mat = this . camera . matrixWorld . values ;
221226 const forwardDir = Vec3 . normalize ( new Vec3 ( mat [ 8 ] , mat [ 9 ] , mat [ 10 ] ) ) ;
222227 const rightDir = Vec3 . normalize ( new Vec3 ( mat [ 0 ] , mat [ 1 ] , mat [ 2 ] ) ) ;
223- const speed = this . fastMovementKeyPressed ? Config . FreeCameraSpeedFast : Config . FreeCameraSpeed ;
228+ const fastSpeed = this . bikeMode ? Config . BikeCameraSpeedFast : Config . FreeCameraSpeedFast ;
229+ const slowSpeed = this . bikeMode ? Config . BikeCameraSpeed : Config . FreeCameraSpeed ;
230+
231+ const speed = this . fastMovementKeyPressed ? fastSpeed : slowSpeed ;
224232
225233 let movementDelta = new Vec3 ( ) ;
226234 if ( this . forwardKeyPressed ) {
@@ -242,7 +250,12 @@ export default class FreeControlsNavigator extends ControlsNavigator {
242250 this . camera . position . z += movementDelta . z ;
243251
244252 const heightmapValue = this . getHeightmapValueAtPosition ( this . camera . position . x , this . camera . position . z ) ;
245- this . camera . position . y = Math . max ( this . camera . position . y , heightmapValue + Config . MinFreeCameraHeight ) ;
253+ if ( this . bikeMode ) {
254+ this . camera . position . y = heightmapValue + Config . FreeCameraBikeHeight ;
255+ } else {
256+ this . camera . position . y = Math . max ( this . camera . position . y , heightmapValue + Config . MinFreeCameraHeight ) ;
257+ }
258+
246259
247260 this . camera . updateMatrix ( ) ;
248261
0 commit comments