Browse Source

scale objects based on gizmo size to correct for smaller objects

Trevor Baron 6 years ago
parent
commit
86689790a0
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/Gizmos/axisScaleGizmo.ts

+ 5 - 2
src/Gizmos/axisScaleGizmo.ts

@@ -82,6 +82,9 @@ export class AxisScaleGizmo extends Gizmo {
         var tmpSnapEvent = { snapDistance: 0 };
         this.dragBehavior.onDragObservable.add((event) => {
             if (this.attachedMesh) {
+                // Drag strength is modified by the scale of the gizmo (eg. for small objects like boombox the strength will be increased to match the behavior of larger objects)
+                var dragStrength = event.dragDistance*((this.scaleRatio*3)/this._rootMesh.scaling.length());
+                
                 // Snapping logic
                 var snapped = false;
                 var dragSteps = 0;
@@ -94,9 +97,9 @@ export class AxisScaleGizmo extends Gizmo {
                     tmpVector.copyFrom(dragAxis);
                 }
                 if (this.snapDistance == 0) {
-                    tmpVector.scaleToRef(event.dragDistance, tmpVector);
+                    tmpVector.scaleToRef(dragStrength, tmpVector);
                 } else {
-                    currentSnapDragDistance += event.dragDistance;
+                    currentSnapDragDistance += dragStrength;
                     if (Math.abs(currentSnapDragDistance) > this.snapDistance) {
                         dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);
                         if (currentSnapDragDistance < 0) {