FlyControls

FlyControls

Implements controls to fly in the geometry using the keyboard. This is inspired from Three.js FlyControls

Constructor

new FlyControls(camera, keyboard)

Source:

Constructor (and not the one of the three.js camera in the virtual euclidean space).

Parameters:
Name Type Default Description
camera DollyCamera

the non-euclidean camera (needed to get the orientation of the observer when using both VR and keyboard).

keyboard string us

the keyboard type (us, fr, etc)

Methods

onKeyDown(event)

Source:

Event handler when a key is pressed

Parameters:
Name Type Description
event KeyboardEvent

the caught event

onKeyUp(event)

Source:

Event handler when a key is pressed

Parameters:
Name Type Description
event KeyboardEvent

the caught event

pause()

Source:

Stop listening to the event

restore()

Source:

Restor the event listener

setKeyboard(keyboard)

Source:

Set the type of keyboard used for the controls. Just an alias of the setter, that can be called easily as a function.

Parameters:
Name Type Description
keyboard string

the new keyboard ('fr', 'us', etc).

update(delta)

Source:
To Do:
  • Dispatch an event, when the position has sufficiently changed.

Function to update the position

Assume that the current position is (g,m) where

  • g is the boost, i.e. subgroup element * local boost
  • m is the facing, i.e. an element of O(3)

Denote by a the Matrix4 representing the Three.js camera orientation, understood as an element of O(3) as well. Denote by e = (e1, e2, e3) the reference frame in the tangent space at the origin. Then the frame at p = go attach to the camera is f = d_og . m . a . e That is the camera is looking at the direction -f3 = - d_og . m . a . e3

Assume now that we want to move in the direction of v = (v1,v2,v3) where the vector is given in the frame f, i.e. v = v1. f1 + v2 . f2 + v3. f3. We need to flow the current position in the direction w, where w corresponds to v written in the "position frame", i.e. d_og . m . e. In other words w = a . u, where u = v1 . e1 + v2 . e2 + v3 . e3. Note that we do not change the camera orientation.

A similar strategy works for the rotations.

Parameters:
Name Type Description
delta number

time delta between two updates

updateMovementVector()

Source:

Update the movement vector

updateRotationVector()

Source:

Update the rotation vector