Skip to content

feat(viz): named camera presets (Shift+1..5)#12

Merged
WomB0ComB0 merged 1 commit into
mainfrom
feat/camera-presets
Apr 20, 2026
Merged

feat(viz): named camera presets (Shift+1..5)#12
WomB0ComB0 merged 1 commit into
mainfrom
feat/camera-presets

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

Summary

Item #6 of the polish plan. Five keyboard-bound camera framings for demo work:

Bind Preset Description
Shift+1 OVERVIEW top-down 45° hero shot of the whole swarm
Shift+2 TACTICAL 45° oblique at mesh altitude, classic sim-game angle
Shift+3 COCKPIT FPV follow of the selected drone (no-op if none selected)
Shift+4 GROUND operator eye-level (1.8 m), looking up at the swarm
Shift+5 INVESTOR toggles the 90s scripted dolly (same as Ctrl+Shift+R)

Why

Investor mode and the scenario intro landed in the last PRs, but the recording workflow was still "manually drag the camera until it looks right, then hit record." Presets give you named angles to hit before the recording starts; the investor dolly does the rest.

How it works

  • Framings compute the swarm centroid + extent from the last VizFrame, so the same keybinds work for single, swarm-5, or multi-agency-sar without per-scenario tuning.
  • New UnityCamera.setPose(position, target) method — snaps to a pose, resyncs orbit state from the resulting quaternion so mouse/wheel input continues smoothly from the new angle. Releases any scripted or follow override first.
  • Shift+Digit1..5 is handled in app.ts before the existing switch; controls.ts early-returns on shifted digits so Shift+1 doesn't also run the single scenario.

Changes

File Change
client/cameraPresets.ts (new) CameraPresets class with five framings + _bounds() helper
client/cameraControl.ts Public setPose(pos, target) on UnityCamera — additive, resets scripted/follow
client/app.ts Instantiate, pass the four deps (scene, droneManager, investorMode, getDrones), bind Shift+Digit1..5
client/controls.ts Skip shifted digits in the scenario keyboard handler

Backwards compat

Additive. Unshifted Digit1..5 still runs scenarios (now including multi-agency-sar from the last PR). Ctrl+Shift+R still works for investor mode (bound separately). setPose is a new public method on UnityCamera — no existing caller affected.

Local verification

tsc --noEmit                                   → clean
vite build (via Release MSBuild)               → green
dotnet build ResQ.Viz.sln -c Release           → 0 / 0
dotnet format --verify-no-changes --severity warn → exit 0
dotnet test -c Release                         → 82 / 82 passing

Test plan

  • Load any scenario — Shift+1..5 cycles through the five framings
  • Shift+3 with a drone selected — camera follows; with none selected — no-op
  • After any preset, mouse-orbit / WASD-fly continues from the new pose
  • Unshifted 5 still runs multi-agency-sar; Shift+5 toggles investor mode

🤖 Generated with Claude Code

Five keyboard-bound camera framings for demo work (item #6 of the
polish plan):

  Shift+1  OVERVIEW   top-down 45° hero shot of the whole swarm
  Shift+2  TACTICAL   45° oblique at mesh altitude, sim-game angle
  Shift+3  COCKPIT    FPV follow of the selected drone
  Shift+4  GROUND     operator eye-level (1.8 m), looking up
  Shift+5  INVESTOR   toggles the 90s scripted dolly (also Ctrl+Shift+R)

Swarm-aware: framings compute swarm centroid + extent from the last
VizFrame, so the same keybinds work for single drone, swarm-5, or
multi-agency-sar without per-scenario tuning. After a preset lands,
user input (orbit, zoom, WASD fly) continues from the new pose.

Changes:
* `client/cameraPresets.ts` (new) — `CameraPresets` class with the
  five framings and a shared swarm-bounds helper.
* `client/cameraControl.ts` — adds public `UnityCamera.setPose(pos, target)`.
  Releases scripted and follow modes; resyncs orbit yaw/pitch/distance
  from the new quaternion so subsequent user input feels continuous.
* `client/app.ts` — instantiate + bind `Shift+Digit1..5` before the
  existing switch; checks shiftKey first so it can't fire the wrong
  handler.
* `client/controls.ts` — early-return on shifted digits so Shift+1
  doesn't also run the `single` scenario.

Verified: tsc clean, build/format green, 82 / 82 tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@WomB0ComB0 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 18 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 18 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b161a34a-21e2-44f2-9fae-f25fa28c1508

📥 Commits

Reviewing files that changed from the base of the PR and between 89d5265 and b3413c4.

📒 Files selected for processing (4)
  • src/ResQ.Viz.Web/client/app.ts
  • src/ResQ.Viz.Web/client/cameraControl.ts
  • src/ResQ.Viz.Web/client/cameraPresets.ts
  • src/ResQ.Viz.Web/client/controls.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/camera-presets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@WomB0ComB0 WomB0ComB0 merged commit 53fe84c into main Apr 20, 2026
35 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a camera preset system allowing users to switch between predefined views (Overview, Tactical, Cockpit, Ground, and Investor) using Shift+1..5 keys. It includes a new CameraPresets class, a setPose method in the UnityCamera for smooth state resyncing, and updates to keyboard event handling to prevent shortcut collisions. Feedback was provided regarding the GROUND preset, suggesting that the camera altitude should be calculated relative to the actual terrain height to avoid clipping issues on non-flat maps.

Comment on lines +64 to +73
ground(): void {
const positions = this._readyPositions();
if (positions.length === 0) return;

const { center, extent } = this._bounds(positions);
const offset = Math.max(extent * 1.1, 40);
const pos = new THREE.Vector3(center.x, 1.8, center.z + offset);
const target = new THREE.Vector3(center.x, center.y + 8, center.z);
this._d.viz.cameraController.setPose(pos, target);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The GROUND preset currently uses a hardcoded altitude of 1.8 for the camera position. On non-flat terrain (e.g., the 'alpine' preset), this will likely place the camera inside the terrain geometry. While the UnityCamera ground-clamping logic will eventually lift the camera to terrainHeight + 2.5, it would be more accurate to calculate the position relative to the actual terrain height at the camera's XZ coordinates to maintain the intended 'operator eye-level' (1.8m).

    ground(): void {
        const positions = this._readyPositions();
        if (positions.length === 0) return;

        const { center, extent } = this._bounds(positions);
        const offset = Math.max(extent * 1.1, 40);
        const camX = center.x;
        const camZ = center.z + offset;
        // Import terrainHeight from './terrain' if not already available
        const groundY = typeof terrainHeight === 'function' ? terrainHeight(camX, camZ) : 0;
        const pos = new THREE.Vector3(camX, groundY + 1.8, camZ);
        const target = new THREE.Vector3(center.x, center.y + 8, center.z);
        this._d.viz.cameraController.setPose(pos, target);
    }

@WomB0ComB0 WomB0ComB0 deleted the feat/camera-presets branch April 20, 2026 07:25
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