瀏覽代碼

sensibility factor for axisScaleGizmo

Cedric Guillemet 5 年之前
父節點
當前提交
9740962b9f
共有 2 個文件被更改,包括 20 次插入1 次删除
  1. 5 1
      src/Gizmos/axisScaleGizmo.ts
  2. 15 0
      src/Gizmos/scaleGizmo.ts

+ 5 - 1
src/Gizmos/axisScaleGizmo.ts

@@ -37,6 +37,10 @@ export class AxisScaleGizmo extends Gizmo {
      * If the scaling operation should be done on all axis (default: false)
      */
     public uniformScaling = false;
+    /**
+     * Custom sensibility value for the drag strength
+     */
+    public sensibility = 1;
 
     private _isEnabled: boolean = true;
     private _parent: Nullable<ScaleGizmo> = null;
@@ -92,7 +96,7 @@ export class AxisScaleGizmo extends Gizmo {
         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());
+                var dragStrength = this.sensibility * event.dragDistance * ((this.scaleRatio * 3) / this._rootMesh.scaling.length());
 
                 // Snapping logic
                 var snapped = false;

+ 15 - 0
src/Gizmos/scaleGizmo.ts

@@ -142,6 +142,21 @@ export class ScaleGizmo extends Gizmo {
     }
 
     /**
+     * Ratio for the scale of the gizmo (Default: 1)
+     */
+    public set sensibility(value: number) {
+        this._sensibility = value;
+        [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach((gizmo) => {
+            if (gizmo) {
+                gizmo.sensibility = value;
+            }
+        });
+    }
+    public get sensibility() {
+        return this._sensibility;
+    }
+
+    /**
      * Disposes of the gizmo
      */
     public dispose() {