Skip to content

Move pure orbit-camera math to src/utils/camera#359

Merged
rulkens merged 1 commit into
mainfrom
refactor/camera-math-to-utils
Jun 20, 2026
Merged

Move pure orbit-camera math to src/utils/camera#359
rulkens merged 1 commit into
mainfrom
refactor/camera-math-to-utils

Conversation

@rulkens

@rulkens rulkens commented Jun 20, 2026

Copy link
Copy Markdown
Owner

What

src/services/camera/orbitCamera.ts was already a pure, dependency-free state-to-matrices module (its own header: "intentionally free of browser or WebGPU dependencies so it can be tested in a plain Node/Vitest environment"). It belongs under src/utils, alongside the other pure math helpers — not in services/camera/, which is now just the DOM-bound orbitControls + the drag-register seeder.

Changes

Split into src/utils/camera/ per the one-function-per-file utils/ convention:

  • clampDistance.tsclampDistance + the MIN/MAX_DISTANCE_MPC clamp-policy constants (kept together as the single source of truth for the zoom envelope)
  • updatePosition.ts — spherical → Cartesian position
  • createOrbitCamera.ts — construction (imports ./updatePosition)
  • computeViewProj.ts — view-projection matrix (incl. Rodrigues roll)

All didactic comments preserved. Repointed all 11 importers (src + tools + tests + the EngineState typeof type import). Moved the cohesive math test to tests/utils/camera/orbitCamera.test.ts (mirrors the clampVolume.test.ts cluster-grouping precedent).

orbitControls.ts stays put — it's input handling, not pure math.

Verification

  • npm run typecheck clean (src + tools)
  • npm test2977 passed

🤖 Generated with Claude Code

orbitCamera.ts was already a pure, dependency-free state-to-matrices
module — it belongs under src/utils, not services/camera (which is now
just the DOM-bound orbitControls + the drag-register seeder).

Split per the one-function-per-file utils convention:
  - clampDistance.ts  (+ MIN/MAX_DISTANCE_MPC clamp policy)
  - updatePosition.ts
  - createOrbitCamera.ts
  - computeViewProj.ts

Repoint all importers; move the cohesive math test to tests/utils/camera.
typecheck clean; full suite 2977 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 20, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
skymap 8496adf Commit Preview URL

Branch Preview URL
Jun 20 2026, 05:25 PM

@rulkens rulkens merged commit b947722 into main Jun 20, 2026
2 checks passed
@rulkens rulkens deleted the refactor/camera-math-to-utils branch June 20, 2026 22:27
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