Skip to content

Fix rotation gizmo to sync quaternion with Euler angles#583

Merged
tracygardner merged 1 commit intomainfrom
claude/fix-issue-582-Pv3JL
Apr 29, 2026
Merged

Fix rotation gizmo to sync quaternion with Euler angles#583
tracygardner merged 1 commit intomainfrom
claude/fix-issue-582-Pv3JL

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Apr 29, 2026

Summary

Fixed the rotation gizmo to properly synchronize mesh rotation state by converting quaternion-based rotations back to Euler angles after interaction.

Key Changes

  • Updated configureRotationGizmo() call to pass { updateToMatchAttachedMesh: true } option, ensuring the gizmo stays synchronized with the mesh's current rotation state
  • Added quaternion-to-Euler conversion logic after rotation gizmo interaction completes:
    • Converts mesh.rotationQuaternion to Euler angles and assigns to mesh.rotation
    • Clears the quaternion to prevent dual rotation representations

Implementation Details

The fix addresses a rotation state inconsistency where meshes using quaternion-based rotation could end up with misaligned rotation representations. By converting quaternions back to Euler angles after gizmo interaction and clearing the quaternion property, we ensure a single source of truth for the mesh's rotation state, which is then properly reflected in the Blockly rotation block update.

https://claude.ai/code/session_015w2ie2ZbMdLcLRi7Kk4Rhm

Summary by CodeRabbit

  • Bug Fixes
    • Improved rotation gizmo synchronization to ensure mesh rotation states are properly matched when attached and correctly normalized after rotation interactions.

Switch to local space (updateToMatchAttachedMesh: true) so each gizmo ring
rotates around the mesh's own axis, preventing Euler decomposition from
spreading across multiple components. Also clear rotationQuaternion before
reading back to Euler in rotDragEnd, matching the keyboard rotation approach.

Fixes #582

https://claude.ai/code/session_015w2ie2ZbMdLcLRi7Kk4Rhm
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

Rotation gizmo initialization now passes updateToMatchAttachedMesh: true to configureRotationGizmo for better synchronization. On rotation drag end, the code normalizes quaternion-based rotation into Euler angles by copying rotationQuaternion to mesh.rotation and nulling rotationQuaternion before updating the rotation block.

Changes

Cohort / File(s) Summary
Rotation Gizmo Synchronization
ui/gizmos.js
Updated gizmo initialization to enable automatic matching of gizmo state to attached mesh via updateToMatchAttachedMesh: true. Modified drag end behavior to normalize quaternion-based rotation by transferring rotationQuaternion to mesh.rotation, clearing rotationQuaternion, and triggering a rotation block update.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A gizmo spins with quaternion grace,
Now synced to mesh in perfect place,
From complex rotations, Euler stays true,
Drag ends smooth—fresh angles renew! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the rotation gizmo to sync quaternion with Euler angles, which matches the core implementation of converting quaternion-based rotations to Euler angles.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-issue-582-Pv3JL

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/gizmos.js (1)

1-1: ⚠️ Potential issue | 🟡 Minor

Run Prettier to clear CI failure.

The pipeline reports a Prettier mismatch, so formatting needs to be normalized before merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/gizmos.js` at line 1, This file fails CI due to Prettier formatting; run
the project's Prettier (e.g., npx prettier --write) against the file that
contains the import line "import * as Blockly from \"blockly\";" (ui/gizmos.js)
to normalize formatting, then stage and commit the formatted changes so the
pipeline passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ui/gizmos.js`:
- Line 1: This file fails CI due to Prettier formatting; run the project's
Prettier (e.g., npx prettier --write) against the file that contains the import
line "import * as Blockly from \"blockly\";" (ui/gizmos.js) to normalize
formatting, then stage and commit the formatted changes so the pipeline passes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6d464e8f-3392-4124-ab89-9e246c2ad5b0

📥 Commits

Reviewing files that changed from the base of the PR and between b8dc98d and 2be3dbc.

📒 Files selected for processing (1)
  • ui/gizmos.js

@tracygardner tracygardner merged commit 0b8e8d6 into main Apr 29, 2026
9 checks passed
@tracygardner tracygardner deleted the claude/fix-issue-582-Pv3JL branch April 29, 2026 14:49
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.

2 participants