studio: scale the camera's near and far planes with the model fit (carry of #2136) #3092
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3092"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.htmlcreates its camera once withnear = 0.1andfar = 1000, and the auto-fit inloadModelnever 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 setsnearto 1/1000 andfarto 100 times that distance and callsupdateProjectionMatrix().Conflict resolution: the only conflict was in
tests/test_viewer_studio.cjs. Main's harness camera now hascontrols.saveState()/reset()and main added a loading-bar timer test; I kept all of that and added the PR'snear,far,projectionsandupdateProjectionMatrixto main's fake camera, and kept both tests.viewer/studio.htmlmerged without conflict.Tested
Windows 11, no GPU, no game files, on main
80910637fplus this branch (Node v26.13.0).node --test tests/test_viewer_studio.cjs: 21 pass, 0 fail.viewer/studio.htmlrestored 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.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
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).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
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:
beb6cee90.tools/gallery.py --models-dirserved 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.cameraglobal after each load.mainnear / farmainFor the red runs,
main'sviewer/studio.htmlwas 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 callscontrols.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).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:31:39Z.
Merging. Head
beb6cee90merges cleanly withmain40ac04183and does not force a rebase of #2566. Carry of #2136. Checked on headbeb6cee90: 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).