Bläddra i källkod

Merge pull request #5699 from TrevorDev/snappingIssue

snap correctly in the negative direction
David Catuhe 6 år sedan
förälder
incheckning
479b382b00

+ 1 - 0
dist/preview release/what's new.md

@@ -131,6 +131,7 @@
 - Update physics position using absolutePosition instead of pivotPosition ([TrevorDev](https://github.com/TrevorDev))
 - Disable camera arrow key controls when the Command key is selected on Mac OS ([kcoley](https://github.com/kcoley))
 - Viewer should not set receiveShadows on an instanced mesh ([TrevorDev](https://github.com/TrevorDev))
+- Rotation/Scaling snapping not working in the negative direction ([TrevorDev](https://github.com/TrevorDev))
 - Updated comment in TransformNode.rotationQuaternion to include undefined as one of the potential return values ([nathankmiller](https://github.com/nathankmiller))
 - CannonJS ignores connectedPivot joint parameter ([TrevorDev](https://github.com/TrevorDev))
 - Fix case sensitive paths ([mrdunk](https://github.com))

+ 4 - 1
src/Gizmos/babylon.axisScaleGizmo.ts

@@ -86,7 +86,10 @@ module BABYLON {
                     } else {
                         currentSnapDragDistance += event.dragDistance;
                         if (Math.abs(currentSnapDragDistance) > this.snapDistance) {
-                            dragSteps = Math.floor(currentSnapDragDistance / this.snapDistance);
+                            dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);
+                            if (currentSnapDragDistance < 0) {
+                                dragSteps *= -1;
+                            }
                             currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;
                             tmpVector.scaleToRef(this.snapDistance * dragSteps, tmpVector);
                             snapped = true;

+ 4 - 1
src/Gizmos/babylon.planeRotationGizmo.ts

@@ -117,7 +117,10 @@ module BABYLON {
                     if (this.snapDistance != 0) {
                         currentSnapDragDistance += angle;
                         if (Math.abs(currentSnapDragDistance) > this.snapDistance) {
-                            var dragSteps = Math.floor(currentSnapDragDistance / this.snapDistance);
+                            var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);
+                            if (currentSnapDragDistance < 0) {
+                                dragSteps *= -1;
+                            }
                             currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;
                             angle = this.snapDistance * dragSteps;
                             snapped = true;