three-story-controls

Home > three-story-controls > FreeMovementControls

FreeMovementControls class

Control scheme to move the camera with arrow/WASD keys and mouse wheel; and rotate the camera with click-and-drag events.

Signature:

export declare class FreeMovementControls implements BaseControls 

Implements: BaseControls

Remarks

Control scheme to move the camera with arrow/WASD keys and mouse wheel; and rotate the camera with click-and-drag events. On a touch device, 1 finger swipe rotates the camera, and 2 fingers tranlsate/move the camera.

Note: CSS property touch-action: none will probably be needed on listener element.

See FreeMovementControlsProps for all properties that can be passed to the constructor.

DEMO

Example

const scene = new Scene()
const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
const cameraRig = new CameraRig(camera, scene)
const controls = new FreeMovementControls(cameraRig)

controls.enable()

// render loop
function animate(t) {
 controls.update(t)
}

Constructors

Constructor Modifiers Description
(constructor)(cameraRig, props)   Constructs a new instance of the FreeMovementControls class

Properties

Property Modifiers Type Description
cameraRig   CameraRig  

Methods

Method Modifiers Description
disable()    
enable()    
isEnabled()    
update(time)