fix(editor): point compass needle at true north, not camera#427
Merged
Conversation
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>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viafloorplanUserRotationDeg = cameraAzimuth − 90°, and working through the projection math (three.js spherical θ → screen, and the SVGrotate()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
FloorplanCompassButtoninstances carried the flipped sign.Fix
Drop the negation on both compass instances (3D-viewer portal + 2D-floorplan fallback):
"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.
🤖 Generated with Claude Code