Skip to content

feat: viewport gizmo grid snapping (translate, rotate, scale)#818

Open
yuripourre wants to merge 6 commits intoBabylonJS:masterfrom
yuripourre:feat/snap
Open

feat: viewport gizmo grid snapping (translate, rotate, scale)#818
yuripourre wants to merge 6 commits intoBabylonJS:masterfrom
yuripourre:feat/snap

Conversation

@yuripourre
Copy link
Copy Markdown
Contributor

@yuripourre yuripourre commented Mar 30, 2026

Title

UE-style toolbar toggles with inspector-style scrub fields

Summary

  • Add localStorage-backed snap preferences
  • Optional Edit Preferences section
  • Wire Babylon PositionGizmo, RotationGizmo, and ScaleGizmo snapDistance.

Changes Made

  • Add localStorage-backed snap preferences
  • Optional Edit Preferences section
  • Wire Babylon PositionGizmo, RotationGizmo, and ScaleGizmo snapDistance.

Benefits

  • Ability to use snap for translation, rotation and scale.
Screenshot From 2026-04-03 13-07-38

Add localStorage-backed snap preferences, UE-style toolbar toggles with
inspector-style scrub fields, and optional Edit Preferences section.
Wire Babylon PositionGizmo, RotationGizmo, and ScaleGizmo snapDistance.
Copy link
Copy Markdown
Contributor

@julien-moreau julien-moreau left a comment

Choose a reason for hiding this comment

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

Thanks a lot !! It's a missing feature that I planned to do but you did it thanks a lot !!!
Just some comments, in order to prepare the future :)

Copy link
Copy Markdown
Contributor

@julien-moreau julien-moreau left a comment

Choose a reason for hiding this comment

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

Just some new findings

const directory = dirname(path);
const project = (await readJSON(path, "utf-8")) as IEditorProject;
const packageManager = project.packageManager ?? "yarn";
const gizmoSnap = roundGizmoSnapSteps({ ...defaultGizmoSnapPreferences });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should the argument no come from project? Because you save it in the project you should use it

/**
* Gizmo snap for the current session (translate, rotate, scale); not persisted in the project file.
*/
gizmoSnap: IGizmoSnapPreferences;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be stored only in the Preview component. Does it have a sense to be global instead of being scoped to preview stuff?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True! Those are left overs from before the last commit. Nice catch

@yuripourre
Copy link
Copy Markdown
Contributor Author

@julien-moreau I've made some changes, please let me know if that's what you had in mind

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