makeLookController()
First-person look from mouse (pointer lock after a click, or drag without it), touch drag, the right stick and optional turn keys. Movement is gathered as events arrive and applied in update(dt), so stick and key speed is framerate-independent and the mouse is counted once.
function makeLookController(input: Input, opts?: LookOptions): LookController;Defined in: engine/src/input/look.ts:80
Parameters
| Parameter | Type | Description |
|---|---|---|
input | Input | The surface's input. Touches on makeTouchControls controls never reach it. |
opts? | LookOptions | - |
Returns
The look state; feed yaw() and pitch() to the renderer's firstPersonFrame.
Example
const look = makeLookController(input, { pitch: -10, keys: { left: ["KeyQ"], right: ["KeyE"] } });
// per frame:
input.update();
look.update(dt);
const y = (look.yaw() * Math.PI) / 180;
const forward = [Math.sin(y), Math.cos(y)], right = [-Math.cos(y), Math.sin(y)];makeActions()
Bind named actions to keys, gamepad and on-screen controls. Sources are strings: key:<KeyboardEvent.code>, pad:<PadButton> (0..1), pad:<PadAxis> (-1..1), touch:<id> (a makeTouchControls control; a joystick adds <id>.x and <id>.y), and a trailing + or - for one half of a signed source. Screen and...
makeOrbitController()
An orbit camera over an input: turntable, look-around room or pan-only map, depending on rotate and pan. Desktop: primary drag rotates, right/middle or shift+drag pans (with pan: "secondary"), wheel and ctrl+wheel zoom. Touch: one finger rotates, two pinch to zoom and drag to pan (or to turn,...