Skip to content

fix(editor): compass needle follows align-north in 3D-only view#487

Merged
Aymericr merged 1 commit into
mainfrom
fix/compass-follow-hidden-align-north
Jul 10, 2026
Merged

fix(editor): compass needle follows align-north in 3D-only view#487
Aymericr merged 1 commit into
mainfrom
fix/compass-follow-hidden-align-north

Conversation

@Aymericr

@Aymericr Aymericr commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the compass needle staying frozen when clicking align-north while only the 3D view is visible (2D panel hidden). The hidden-panel align-north branch publishes a single '2d' navigation pose that the camera applies through the echo-suppressed pending-pose path — no '3d' poses ever flow back, so the needle subscription (which only reacted to '3d' poses) never moved it. In 2D and split view the open floorplan animates its own rotation, which is why those worked.

The fix drives the needle with a local rAF exponential-decay animation when a '2d' pose arrives while the panel is hidden, using the same 90 ms time constant as the 2D view animation and the camera's effective smoothTime, so camera and needle stay visually in step. A live '3d' pose (e.g. the user grabs the camera mid-transition) cancels the local animation and hands the needle back to the camera stream.

How to test

  1. bun dev, open a scene, and close the 2D floorplan panel so only the 3D view is visible.
  2. Orbit the camera off-north, then click the compass. Expected: the camera rotates to north AND the needle animates smoothly to vertical in step with it.
  3. Click the compass, then immediately drag to orbit mid-transition. Expected: the needle follows the live camera without snapping.
  4. Regression: repeat align-north in split view and in 2D-only view — behavior unchanged (instant, in sync).

Screenshots / screen recording

N/A — 15-second behavior fix; reviewer steps above reproduce it directly.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Note

Low Risk
Localized floorplan/compass navigation-sync behavior with no security or data impact; split and 2D-only paths are unchanged when the panel is open.

Overview
When the floorplan panel is closed, align-north only publishes a '2d' navigation pose (the camera moves without returning '3d' frames), so the compass needle no longer updates if the subscription only handled '3d' poses.

The hidden-panel branch now reacts to both pose sources: '3d' still drives the needle imperatively and cancels any in-flight local animation; '2d' triggers a requestAnimationFrame exponential-decay rotation on the needle (same 90 ms time constant as the 2D view animation). Subscription cleanup cancels that animation on unmount.

Reviewed by Cursor Bugbot for commit cbcc705. Bugbot is set up for automated code reviews on this repo. Configure here.

When the 2D panel is hidden, align-north publishes a single '2d' pose that
the camera applies through the echo-suppressed pending-pose path, so no
'3d' poses ever reach the compass subscription and the needle stayed
frozen. Drive the needle with a local rAF exponential decay (same 90ms
time constant as the 2D view animation and the camera's effective
smoothTime); a live '3d' pose cancels it and takes back ownership.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Aymericr Aymericr force-pushed the fix/compass-follow-hidden-align-north branch from 3693db1 to cbcc705 Compare July 10, 2026 08:15

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cbcc705. Configure here.

}
return
} else {
animateHiddenCompassNeedle(nextDeg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orbit cannot cancel needle animation

Medium Severity

After align-north with the floorplan hidden, animateHiddenCompassNeedle runs on the '2d' pose, but yielding to the camera relies on later '3d' poses calling cancelHiddenCompassAnimation. While the camera is still damping toward that '2d' target, publishCurrentNavigationPose keeps pendingFloorplanNavigationPose set and returns without publishing '3d', so orbiting mid-transition never cancels the local animation and the needle can keep moving toward north while the live camera diverges.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cbcc705. Configure here.

}
if (nextDeg !== targetDeg) {
hiddenCompassAnimationRef.current = requestAnimationFrame(tick)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale compass state after animation

Medium Severity

Hidden-panel align-north drives the compass via animateHiddenCompassNeedle, which updates latestFloorplanUserRotationDegRef and the DOM but never floorplanUserRotationDeg. After the animation finishes, reopening the floorplan copies stale state into the ref and the compass northRotationDeg prop, so the needle can jump away from the heading shown in 3D-only mode. The reopen catch-up effect still syncs only 3d poses, so a lingering 2d navigation pose after hidden align does not refresh the floorplan view.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cbcc705. Configure here.

@Aymericr Aymericr merged commit 7d6879c into main Jul 10, 2026
2 checks passed
@Aymericr Aymericr deleted the fix/compass-follow-hidden-align-north branch July 10, 2026 08:22
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