Skip to content

Add up-axis selection for the file's coordinate system (#14) - #19

Open
tatsy wants to merge 1 commit into
mainfrom
dev
Open

Add up-axis selection for the file's coordinate system (#14)#19
tatsy wants to merge 1 commit into
mainfrom
dev

Conversation

@tatsy

@tatsy tatsy commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses #14. Files exported from Z-up tools (Blender) or Y-down conventions (OpenCV, COLMAP) appeared tilted because three.js is Y-up. This adds the 3dpreview.upAxis setting and an "Up axis" GUI dropdown with +X, -X, +Y, -Y, +Z, -Z.

Design

  • Rotate the scene graph, not the data. Points, mesh and wireframe now live in a THREE.Group. Changing the up axis only sets the group's rotation, so switching is instant, repeatable and cannot introduce mirroring (every entry is a pure rotation). This replaces the vertex-rewriting approach of feat: Add the option to change coordinate conventions #16.
  • Rotate in place. The rotation is taken about the model's bounding-box centre, so the model stays where it is and only its orientation changes.
  • Axes helper follows the file. It is a child of the group and therefore shows the file's own coordinate axes.
  • Grid stays in world space so it always reads as the floor.
  • Camera is left untouched when the axis changes (to be decided after review whether it should reset instead).
  • utils.getBBoxCenter / getBBoxMaxExtent / autoCameraPos accept either a geometry or a THREE.Box3, so world-space boxes can be used for camera placement and grid positioning.

Only the up axis is configurable; the rotation about it is left to the user's mouse, which keeps the setting to a single dropdown.

Verification

  • npm run compile and npm run lint pass.
  • Headless Chromium: bunny.obj loaded with each of the six axes renders without console errors, and the axes helper visibly follows the rotation.
  • Loading with +Y and switching the dropdown to +Z produces a screenshot identical (0 differing bytes) to loading with +Z directly, confirming the camera is retained and the model rotates about its centre.
  • Earlier smoke tests (controls, attenuation, light, flat/smooth shading) still pass with no new console errors.

Closes #14

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kvyv4yLA7eMxRmEGDhHt4m


Generated by Claude Code

Files exported from Z-up tools (Blender) or Y-down conventions
(OpenCV, COLMAP) appeared tilted because three.js is Y-up. Add the
`3dpreview.upAxis` setting and an "Up axis" GUI dropdown offering
+X, -X, +Y, -Y, +Z and -Z.

Instead of rewriting vertex data, all loaded objects now live in a
THREE.Group that is rotated about the model's bounding-box centre, so
the model stays in place, switching is instant and repeatable, and no
mirroring can occur. The axes helper is a child of that group and shows
the file's own axes; the grid helper stays in world space so it always
reads as the floor. The camera is left untouched when the axis changes.

Bounding-box helpers in utils.js now accept either a geometry or a
THREE.Box3 so that world-space boxes can be used for camera placement
and grid positioning.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kvyv4yLA7eMxRmEGDhHt4m
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.

Adding support for changing coordinate system

2 participants