Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Rotation Snap by default and make it customisable #661

Merged
merged 9 commits into from
Jan 7, 2025
Next Next commit
rotation snap
arjxn-py committed Jan 6, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 9910bc4426d450555d9f9c51e5a88b9e386be542
12 changes: 12 additions & 0 deletions packages/base/src/3dview/mainview.tsx
Original file line number Diff line number Diff line change
@@ -421,6 +421,18 @@ export class MainView extends React.Component<IProps, IStates> {
this._transformControls.addEventListener('dragging-changed', event => {
this._controls.enabled = !event.value;
});
// Add event listener for keydown and keyup to enable/disable rotation snapping
document.addEventListener('keydown', event => {
if (event.key === 'Control') {
this._transformControls.rotationSnap = THREE.MathUtils.degToRad(10);
}
});

document.addEventListener('keyup', event => {
if (event.key === 'Control') {
this._transformControls.rotationSnap = null;
}
});
// Update the currently transformed object in the shared model once finished moving
this._transformControls.addEventListener('mouseUp', async () => {
const updatedObject = this._selectedMeshes[0];