Skip to content

fix(editor): point compass needle at true north, not camera#427

Merged
wass08 merged 1 commit into
mainfrom
fix/compass-north
Jun 18, 2026
Merged

fix(editor): point compass needle at true north, not camera#427
wass08 merged 1 commit into
mainfrom
fix/compass-north

Conversation

@wass08

@wass08 wass08 commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Problem

The compass needle in the viewer pointed in the direction the camera was facing instead of at true north — as you orbited, the needle swung with the camera rather than staying pinned to a fixed world direction.

Cause

The needle rotation was -floorplanUserRotationDeg. The 2D/3D views are kept in sync via floorplanUserRotationDeg = cameraAzimuth − 90°, and working through the projection math (three.js spherical θ → screen, and the SVG rotate() for the 2D case) true north lands at +floorplanUserRotationDeg. The negated sign made the needle rotate opposite to north.

The formula was originally written for the 2D-floorplan-only compass and reused verbatim when the compass was portaled into the 3D viewer, so both FloorplanCompassButton instances carried the flipped sign.

Fix

Drop the negation on both compass instances (3D-viewer portal + 2D-floorplan fallback):

- northRotationDeg={-floorplanUserRotationDeg}
+ northRotationDeg={floorplanUserRotationDeg}

"Align to north" is unaffected (resets userRotation → 0 → needle up).

Testing

Verified manually against the community server — orbiting the camera now keeps the red needle pinned to a fixed world direction.

Note: for buildings with a non-zero rotation the 2D floorplan de-rotates the building while the 3D view shows true world angle, so the two branches strictly diverge by buildingRotationDeg. This PR keeps the minimal sign-flip (correct for the common axis-aligned case).

🤖 Generated with Claude Code

The compass needle rotation was `-floorplanUserRotationDeg`, but the
2D-floorplan SVG and 3D camera projections both place true north at
`+floorplanUserRotationDeg` (= cameraAzimuth − 90°). The negated sign
made the needle rotate opposite to north as the camera orbits, so it
appeared to track the camera instead of pointing north.

The formula was written for the 2D floorplan and reused verbatim when
the compass was portaled into the 3D viewer; both instances had the
flipped sign. "Align to north" is unaffected (userRotation 0 → up).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wass08 wass08 merged commit 9e7beb8 into main Jun 18, 2026
1 check passed
@wass08 wass08 deleted the fix/compass-north branch June 18, 2026 13:16
@mintlify

mintlify Bot commented Jun 18, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 18, 2026, 1:25 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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