studio: scale the camera's near and far planes with the model fit (carry of #2136) #3092

Merged
MoonEyes merged 2 commits from upstream-pr/3092 into main 2026-12-02 11:46:28 +00:00
MoonEyes commented 2026-12-02 10:30:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:30:48Z.


Claimed in the coordination issue as: STUDIO-FIT-CLIP-PLANES (the original author's item ID, from the description of #2136; the claim comment there was announced as "to follow")

What and why

Carry of #2136 (syfyra), unchanged since 2026-11-25 (last commit; the only later activity is two review comments by a collaborator on 2026-12-01). Branch = main + the author's head (commit kept) + conflict resolution. I added no commit of my own: the only review points on #2136 are the merge conflict and the missing CI run, and neither is a code defect.

viewer/studio.html creates its camera once with near = 0.1 and far = 1000, and the auto-fit in loadModel never changes either plane. Since the fit puts the camera about 2.63 x maxDim from the model's centre, a model under about 6 cm lies wholly in front of the near plane and one over about 290 m (a terrain tile, a far LOD) wholly beyond the far plane, so the canvas stays empty. The fit now sets near to 1/1000 and far to 100 times that distance and calls updateProjectionMatrix().

Conflict resolution: the only conflict was in tests/test_viewer_studio.cjs. Main's harness camera now has controls.saveState()/reset() and main added a loading-bar timer test; I kept all of that and added the PR's near, far, projections and updateProjectionMatrix to main's fake camera, and kept both tests. viewer/studio.html merged without conflict.

Tested

Windows 11, no GPU, no game files, on main 80910637f plus this branch (Node v26.13.0).

  • node --test tests/test_viewer_studio.cjs: 21 pass, 0 fail.
  • Red: with main's viewer/studio.html restored over the branch's, the same command gives 20 pass, 1 fail: "the camera fit keeps a 2 cm prop and a 600 m terrain tile between the near and far planes" (0.02 m: near 0.1 clips the model). The file was restored afterwards and the working tree is clean.
  • python -I scripts/check_no_game_data.py tests/test_viewer_studio.cjs viewer/studio.html: clean.
  • Not checked in a browser.
  • Not run: the full suite, CI.

GPUs tested: n/a (unit tests only)

AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fixes, tests); separate read-only reviewer agent: Claude Opus 5.5.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

Supersedes #2136 once merged; the original stays open until a maintainer decides.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5604613067 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3092). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:30:48Z. --- Claimed in the coordination issue as: STUDIO-FIT-CLIP-PLANES (the original author's item ID, from the description of #2136; the claim comment there was announced as "to follow") ### What and why Carry of #2136 (syfyra), unchanged since 2026-11-25 (last commit; the only later activity is two review comments by a collaborator on 2026-12-01). Branch = main + the author's head (commit kept) + conflict resolution. I added no commit of my own: the only review points on #2136 are the merge conflict and the missing CI run, and neither is a code defect. `viewer/studio.html` creates its camera once with `near = 0.1` and `far = 1000`, and the auto-fit in `loadModel` never changes either plane. Since the fit puts the camera about 2.63 x maxDim from the model's centre, a model under about 6 cm lies wholly in front of the near plane and one over about 290 m (a terrain tile, a far LOD) wholly beyond the far plane, so the canvas stays empty. The fit now sets `near` to 1/1000 and `far` to 100 times that distance and calls `updateProjectionMatrix()`. Conflict resolution: the only conflict was in `tests/test_viewer_studio.cjs`. Main's harness camera now has `controls.saveState()`/`reset()` and main added a loading-bar timer test; I kept all of that and added the PR's `near`, `far`, `projections` and `updateProjectionMatrix` to main's fake camera, and kept both tests. `viewer/studio.html` merged without conflict. ### Tested Windows 11, no GPU, no game files, on main 80910637f plus this branch (Node v26.13.0). - `node --test tests/test_viewer_studio.cjs`: 21 pass, 0 fail. - Red: with main's `viewer/studio.html` restored over the branch's, the same command gives 20 pass, 1 fail: "the camera fit keeps a 2 cm prop and a 600 m terrain tile between the near and far planes" (`0.02 m: near 0.1 clips the model`). The file was restored afterwards and the working tree is clean. - `python -I scripts/check_no_game_data.py tests/test_viewer_studio.cjs viewer/studio.html`: clean. - Not checked in a browser. - Not run: the full suite, CI. GPUs tested: n/a (unit tests only) AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fixes, tests); separate read-only reviewer agent: Claude Opus 5.5. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) Supersedes #2136 once merged; the original stays open until a maintainer decides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kal0s-design commented 2026-12-02 11:12:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T11:12:59Z.


Checked in a real browser, since the description says it was not.

Setup:

  • Windows 11, PR head beb6cee90.
  • tools/gallery.py --models-dir served three cube glTF files that I generated: 0.01 m, 1 m and 2000 m on a side, one red material each, no game data.
  • The page ran in a Chromium-based browser. I read the camera values from the page's own camera global after each load.
Model main near / far Canvas on main This PR near / far Canvas with this PR
1 cm cube 0.1 / 1000 empty 2.6e-5 / 2.63 cube fills the view
1 m cube 0.1 / 1000 (not re-run) 2.6e-3 / 263 cube plus grid
2 km cube 0.1 / 1000 empty 5.26 / 5.26e5 cube fills the view

For the red runs, main's viewer/studio.html was swapped in and served by the same server, with the same models and the same window. The camera distance was the same in both trees: 0.0263 for the 1 cm cube and 5265 for the 2 km one. So the only difference is the clip planes, which matches the comment in the diff.

Reset Camera: controls.saveState() runs after the new planes are set, and Reset Camera only calls controls.reset(), so it goes back to the fitted view. The planes are not touched again until the next model loads.

One cosmetic side effect: the 20 m grid is clipped by the new planes. With the 1 cm cube only the grid lines close to the model are drawn, and with the 2 km cube the grid is too small to see. That seems fine for an inspector.

Not checked: real game models and texture previews.

GPUs tested: one NVIDIA desktop card (WebGL in the browser).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7343594902 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3092#issuecomment-7343594902). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T11:12:59Z. --- Checked in a real browser, since the description says it was not. **Setup:** - Windows 11, PR head `beb6cee90`. - `tools/gallery.py --models-dir` served three cube glTF files that I generated: 0.01 m, 1 m and 2000 m on a side, one red material each, no game data. - The page ran in a Chromium-based browser. I read the camera values from the page's own `camera` global after each load. | Model | `main` near / far | Canvas on `main` | This PR near / far | Canvas with this PR | |---|---|---|---|---| | 1 cm cube | 0.1 / 1000 | empty | 2.6e-5 / 2.63 | cube fills the view | | 1 m cube | 0.1 / 1000 | (not re-run) | 2.6e-3 / 263 | cube plus grid | | 2 km cube | 0.1 / 1000 | empty | 5.26 / 5.26e5 | cube fills the view | For the red runs, `main`'s `viewer/studio.html` was swapped in and served by the same server, with the same models and the same window. The camera distance was the same in both trees: 0.0263 for the 1 cm cube and 5265 for the 2 km one. So the only difference is the clip planes, which matches the comment in the diff. **Reset Camera:** `controls.saveState()` runs after the new planes are set, and Reset Camera only calls `controls.reset()`, so it goes back to the fitted view. The planes are not touched again until the next model loads. **One cosmetic side effect:** the 20 m grid is clipped by the new planes. With the 1 cm cube only the grid lines close to the model are drawn, and with the 2 km cube the grid is too small to see. That seems fine for an inspector. Not checked: real game models and texture previews. GPUs tested: one NVIDIA desktop card (WebGL in the browser). AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 11:31:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:31:39Z.


Merging. Head beb6cee90 merges cleanly with main 40ac04183 and does not force a rebase of #2566. Carry of #2136. Checked on head beb6cee90: all 5 CI checks green; third-party red/green by Kal0s-design on this exact head in a browser (main: empty canvas for a 1 cm and a 2 km model, this head: the model fills the view, Reset Camera returns to the fitted view); the author's commits are kept; no CI, security or rendering paths; conflict-free merge against main. #2136 stays open until a maintainer decides. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344042656 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3092#issuecomment-7344042656). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:31:39Z. --- Merging. Head `beb6cee90` merges cleanly with `main` `40ac04183` and does not force a rebase of #2566. Carry of #2136. Checked on head beb6cee90: all 5 CI checks green; third-party red/green by Kal0s-design on this exact head in a browser (main: empty canvas for a 1 cm and a 2 km model, this head: the model fills the view, Reset Camera returns to the fitted view); the author's commits are kept; no CI, security or rendering paths; conflict-free merge against main. #2136 stays open until a maintainer decides. Merged by MoonEyes. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3092
No description provided.