Skip to content

Multi-mode camera with HUD and C key cycling#3

Open
gitdolucas wants to merge 2 commits intomrdoob:masterfrom
gitdolucas:camera-switch
Open

Multi-mode camera with HUD and C key cycling#3
gitdolucas wants to merge 2 commits intomrdoob:masterfrom
gitdolucas:camera-switch

Conversation

@gitdolucas
Copy link
Copy Markdown

Summary

Adds three camera modes (Eagle, third-person, and hood) with smoothed transitions between them, optional speed-based FOV widening, and hood-view roll tied to lateral acceleration. Includes a small HUD under the lap timer listing modes and a Switch control (same as C / gamepad equivalent).

Changes

  • js/Camera.jsCAMERA_MODE enum; per-mode placement (orbital eagle, chase, hood); smootherstep transitions with mode-pair-specific durations; FOV boost at speed; hood barrel roll from vehicle lateral accel; advanceMode() / getHudMode() for cycling and UI.
  • js/CameraHud.js (new) — DOM overlay: Switch button + mode list; positioned below #lap-timer on resize; updates active state from camera.
  • js/main.js — Wire CameraHud, call advanceMode on cycleCamera, cameraHud.update(cam) each frame.
  • js/Controls.js — Expose cycleCamera on C edge (keyboard / existing gamepad path).
  • js/Vehicle.js — Track lateralAccel (world-space along car right, XZ) for cockpit roll.

How to test

  1. Run the game, drive with keyboard or gamepad.
  2. Press C (or use the HUD Switch button): Eagle → Third person → Hood → …
  3. Confirm transitions feel smooth; third-person chase follows the car; hood view shows subtle roll in turns; FOV widens noticeably at higher speeds.

Notes

  • HUD stacks under the lap timer; if #lap-timer is missing it falls back to top: 12px.

gitdolucas and others added 2 commits May 3, 2026 20:54
- Cycle eagle / third / hood on Key C (edge-detected in Controls)
- Smooth transitions with per-edge durations; third uses vehicle yaw chase
- Third→hood two-phase path (roof approach); fix lookAt via real PerspectiveCamera
- Speed-based FOV in third and hood; hood barrel roll from steering × speed
- Vehicle: lateral velocity derivative (optional); pass full vehicle to Camera

Co-authored-by: Cursor <cursoragent@cursor.com>
- CameraHud: Switch button (camera icon + label), mode list with active styling
- Position below #lap-timer when present; Camera.getHudMode() for highlight sync
- Wire HUD in main loop with same advanceMode callback as Key C

Co-authored-by: Cursor <cursoragent@cursor.com>
@gitdolucas
Copy link
Copy Markdown
Author

gitdolucas commented May 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant