Skip to content

ASSET-412: Keep small and large Studio models inside camera clip planes - #5083

Open
Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/studio-camera-clipping
Open

Hiiva wants to merge 1 commit into
ItsNotRexed:mainfrom
Hiiva:fix/studio-camera-clipping

Conversation

@Hiiva

@Hiiva Hiiva commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What and why

ASSET-412, claimed in the coordination thread.

Studio moves the camera according to each loaded model's bounds, but keeps fixed clipping planes at near=0.1 and far=1000. The auto-fit therefore hides otherwise valid small and large models: the actual load callback places every corner of a synthetic 0.01-unit cube before the near plane and every corner of a 1000-unit cube beyond the far plane.

Scale both clipping planes with the same model extent used to position the camera, preserving the existing far/near ratio, and refresh the projection matrix. Four production lines change. Add synthetic Node tests that execute the actual loadModel callback and project all eight model corners into the resulting clip volume, including repeated selections of different sizes and centers.

Depends on: #5017

This is an integration dependency for the adjacent camera-fit block. Its controls.saveState insertion should be retained; the test stub supports that method. No semantic dependency on the Reset Camera fix.

Validation

Windows 11, Node 24.18, upstream 3faac557b1584d39004357918e60325b4d4ff0fe:

  • Before the fix, all four new tests fail. The small and large cube cases explicitly fail the clip-volume check. The ordinary-size case and repeated selections also verify projection refresh.
  • node --test tests/test_viewer_studio_clipping.cjs tests/test_viewer_streaming.cjs: 55/55 pass (4 new, 51 existing).
  • Independent review reran all four new tests successfully.
  • git diff --check passes.

CPU geometry/callback tests only; no browser, WebGL, GPU, or driver validation claimed. All bounds and models in the tests are synthetic. No game files accessed or included. AI-assisted: yes.

Verified integration with #5017

Combining #5017 at 86047cb0afd49c505eace070b63d4baf54ceabe1 with this head needs one test-mock addition in tests/test_viewer_studio_camera.cjs:

-    const camera = { position: new Vector3(0, 2, 5), zoom: 1 };
+    const camera = { position: new Vector3(0, 2, 5), zoom: 1, updateProjectionMatrix() {} };

Retain controls.saveState() after controls.update() alongside the clip-plane/projection changes. The stock combined camera/clipping run gives 5 passes and 1 TypeError. With only this mock change, all 6 tests pass on Node 24.18.0. The clipping test stays byte-identical to this PR. This is a local CPU callback integration check; the separate published heads were left unchanged.

@Hiiva
Hiiva marked this pull request as ready for review November 23, 2026 08:15

@Kam471 Kam471 left a comment

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.

Ran this at c457ea308 on Windows 11 (Node 24.22.3): node --test tests/test_viewer_studio_clipping.cjs -> 4 tests, 4 pass, 0 fail; git diff --check clean.

The Studio viewer's camera near/far planes now scale with the loaded model's bounds instead of using fixed values, so a tiny and a very large model both stay inside the clip range; the new Node test covers both sizes and the no-model case. No blocking issue.

@whattheflop

Copy link
Copy Markdown
Contributor

T3 Preview integration at c457ea30 with #5017 86047cb0 and #4763 e04cee84 on 3faac557, clean merged tree aa2ba8e9. I used the stock Gallery route with Three.js r128 and synthetic 0.01-unit and 1000-unit cubes. With the actual fitted Studio camera, both cubes covered 1,166/4,096 pixels in an isolated render-target readback. Restoring fixed planes 0.1/1000 in memory produced 0 covered pixels on each. Selecting the tiny cube, large cube, then tiny cube again and using Reset Camera restored the expected position, target, zoom and clip planes each time. The scratch Gallery served the pinned Three.js scripts locally.

One integration test needs updating. The combined stock Node run passed 66/67. The camera stub in #5017's reset test lacks updateProjectionMatrix(), which #5083 now calls. Adding that no-op method to the test stub in memory resolved the failure. The actual OrbitControls reset and WebGL rendering passed. AI-assisted, synthetic inputs only.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested c457ea3 on Windows Server 2022, CPython 3.13.12: pass

  • node tests/test_viewer_studio_clipping.cjs -> pass 4, fail 0 (Node v24.22.2)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

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.

4 participants