Player and controls
Player (from @maomi/sge/player) is a CharacterEntity with a capsule body, a camera, an Inventory, and an input controller it picks by itself.
const player = new Player({ camera });
player.position = new THREE.Vector3(0, 1, 0);
fps.add(player);
const el = fps.start(player);Options: radius (capsule radius, default 0.4), walkSpeed (default 6 units/s), and forceTouch to override the input autodetection.
Desktop
DesktopController: click the canvas to grab the mouse (PointerLockControls), then WASD to walk, mouse to look, Space to jump. Releasing pointer lock (Esc) stops movement — a game that wants a "click to play" prompt can watch player.inputController.isLocked().
Touch
MobileController: a left-side stick to walk, swipe anywhere else to look, a jump button. No pointer lock involved — a touchscreen has no cursor to capture.
Which one you get
export const TOUCH_ENABLED = /* coarse pointer, or ontouchstart, or ?touch in the URL */TOUCH_ENABLED is evaluated once per page load. Appending ?touch to any URL forces the touch controls on desktop — the easiest way to develop them. Per-instance, pass new Player({ camera, forceTouch: true }).
The camera is not parented
The camera is deliberately not a child of the player's body: PointerLockControls owns the camera's world orientation, and nesting it under a yawing body would compose two yaws. The player syncs the camera's position to its body each frame (eye height above the capsule center) and reads the camera's yaw back when deciding what "forward" means.
Respawn
Fall off the world and the player teleports back to its spawn point (the position it had when added) once it drops below a threshold — a guard rail for level-building mistakes, not a game mechanic.
Suspending input
Modal UI (a dialog, a lesson overlay) should stop the player without tearing anything down:
import { suspendInput, restoreInput } from '@maomi/sge/input-lock';
suspendInput(player, cursor); // stop look/move, release pointer lock, hide the cursor
restoreInput(player, cursor);