Forráskód Böngészése

do not scale button multiple times with multitouch

Trevor Baron 6 éve
szülő
commit
62a25a9596
2 módosított fájl, 10 hozzáadás és 3 törlés
  1. 1 0
      dist/preview release/what's new.md
  2. 9 3
      gui/src/3D/controls/button3D.ts

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

@@ -228,6 +228,7 @@
 - Fix ArcRotateCamera rebuildAnglesAndRadius when upVector modified ([sable](https://github.com/thscott))
 - Fix code branch, that does not try to (re)load an `EquiRectangularCubeTexture`/`HDRCubeTexture` when the caching returns an empty or corrupt `InternalTexture` ([Dennis Dervisis](https://github.com/ddervisis))
 - Add error eventlistener (bubbling up the onError callback chain) in case an `EquiRectangularCubeTexture` cannot be loaded, because of a wrong path or IO problems ([Dennis Dervisis](https://github.com/ddervisis))
+- 3D GUI buttons no longer will scale up when pressing with multitouch devices ([TrevorDev](https://github.com/TrevorDev))
 
 ### Core Engine
 - Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))

+ 9 - 3
gui/src/3D/controls/button3D.ts

@@ -22,6 +22,7 @@ export class Button3D extends AbstractButton3D {
     private _content: Control;
     private _contentResolution = 512;
     private _contentScaleRatio = 2;
+    private _pressed = false;
 
     /**
      * Gets or sets the texture resolution used to render content (512 by default)
@@ -91,8 +92,10 @@ export class Button3D extends AbstractButton3D {
             if (!this.mesh) {
                 return;
             }
-
-            this.mesh.scaling.scaleInPlace(0.95);
+            if (!this._pressed) {
+                this.mesh.scaling.scaleInPlace(0.95);
+                this._pressed = true;
+            }
         };
 
         this.pointerUpAnimation = () => {
@@ -100,7 +103,10 @@ export class Button3D extends AbstractButton3D {
                 return;
             }
 
-            this.mesh.scaling.scaleInPlace(1.0 / 0.95);
+            if (this._pressed) {
+                this.mesh.scaling.scaleInPlace(1.0 / 0.95);
+                this._pressed = false;
+            }
         };
     }