Transform Controls Rotation Snapping

In the transform controls example it seems to suggest that if I hold Ctrl there will be snapping.

case 17: // Ctrl
control.setTranslationSnap( 100 );
control.setRotationSnap( Math.degToRad( 15 ) );

This works for the linear movement but not for rotations. Can anyone confirm if I am missing something and how you achieve rotation snapping?

It’s possible that it’s not actually implemented for rotation, and only translation. Being an example, the best thing to do is study it, and then extend it.

1 Like

I thought it seemed strange that whoever made the example would put in code that isn’t implemented, so as suggested I have tried to follow it through and it does seem that it should be doing something:

if ( space === 'local' && this.mode === 'rotate' ) {
var snap = this.rotationSnap;
     if ( this.axis === 'X' && snap ) this.object.rotation.x = Math.round( this.object.rotation.x / snap ) * snap;
     if ( this.axis === 'Y' && snap ) this.object.rotation.y = Math.round( this.object.rotation.y / snap ) * snap;
     if ( this.axis === 'Z' && snap ) this.object.rotation.z = Math.round( this.object.rotation.z / snap ) * snap;

I sort of think I must be missing something!? If anyone has some suggestions I would very much appreciate it