浏览代码

PR feedback from Ranaan

Dave Solares 4 年之前
父节点
当前提交
09e9079829
共有 2 个文件被更改,包括 21 次插入22 次删除
  1. 14 15
      src/DeviceInput/deviceInputSystem.ts
  2. 7 7
      src/Inputs/scene.inputManager.ts

+ 14 - 15
src/DeviceInput/deviceInputSystem.ts

@@ -325,16 +325,16 @@ export class DeviceInputSystem implements IDisposable {
                 pointer[PointerInput.DeltaVertical] = evt.movementY;
 
                 if (this.onInputChanged) {
-                    if (previousHorizontal != evt.clientX) {
+                    if (previousHorizontal !== evt.clientX) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Horizontal, previousHorizontal, pointer[PointerInput.Horizontal]);
                     }
-                    if (previousVertical != evt.clientY) {
+                    if (previousVertical !== evt.clientY) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Vertical, previousVertical, pointer[PointerInput.Vertical]);
                     }
-                    if (pointer[PointerInput.DeltaHorizontal] != 0) {
+                    if (pointer[PointerInput.DeltaHorizontal] !== 0) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.DeltaHorizontal, previousDeltaHorizontal, pointer[PointerInput.DeltaHorizontal]);
                     }
-                    if (pointer[PointerInput.DeltaVertical] != 0) {
+                    if (pointer[PointerInput.DeltaVertical] !== 0) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.DeltaVertical, previousDeltaVertical, pointer[PointerInput.DeltaVertical]);
                     }
                 }
@@ -364,10 +364,10 @@ export class DeviceInputSystem implements IDisposable {
                 pointer[evt.button + 2] = 1;
 
                 if (this.onInputChanged) {
-                    if (previousHorizontal != evt.clientX) {
+                    if (previousHorizontal !== evt.clientX) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Horizontal, previousHorizontal, pointer[PointerInput.Horizontal]);
                     }
-                    if (previousVertical != evt.clientY) {
+                    if (previousVertical !== evt.clientY) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Vertical, previousVertical, pointer[PointerInput.Vertical]);
                     }
                     this.onInputChanged(deviceType, deviceSlot, evt.button + 2, previousButton, pointer[evt.button + 2]);
@@ -390,17 +390,17 @@ export class DeviceInputSystem implements IDisposable {
                 pointer[evt.button + 2] = 0;
 
                 if (this.onInputChanged) {
-                    if (previousHorizontal != evt.clientX) {
+                    if (previousHorizontal !== evt.clientX) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Horizontal, previousHorizontal, pointer[PointerInput.Horizontal]);
                     }
-                    if (previousVertical != evt.clientY) {
+                    if (previousVertical !== evt.clientY) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.Vertical, previousVertical, pointer[PointerInput.Vertical]);
                     }
                     this.onInputChanged(deviceType, deviceSlot, evt.button + 2, previousButton, pointer[evt.button + 2]);
                 }
             }
             // We don't want to unregister the mouse because we may miss input data when a mouse is moving after a click
-            if (evt.pointerType != "mouse") {
+            if (evt.pointerType !== "mouse") {
                 this._unregisterDevice(deviceType, deviceSlot);
             }
 
@@ -428,13 +428,12 @@ export class DeviceInputSystem implements IDisposable {
             };
 
             this._elementToAttachTo.addEventListener("test", noop, options);
-            this._elementToAttachTo.removeEventListener("test", noop, options)
+            this._elementToAttachTo.removeEventListener("test", noop, options);
         }
         catch (e) {
             /* */
         }
 
-
         this._pointerWheelEvent = ((evt) => {
             const deviceType = DeviceType.Mouse;
             const deviceSlot = 0;
@@ -460,13 +459,13 @@ export class DeviceInputSystem implements IDisposable {
                 pointer[PointerInput.MouseWheelZ] = evt.deltaZ;
 
                 if (this.onInputChanged) {
-                    if (evt.deltaX != 0) {
+                    if (evt.deltaX !== 0) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.MouseWheelX, previousWheelScrollX, pointer[PointerInput.MouseWheelX]);
                     }
-                    if (evt.deltaY != 0) {
+                    if (evt.deltaY !== 0) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.MouseWheelY, previousWheelScrollY, pointer[PointerInput.MouseWheelY]);
                     }
-                    if (evt.deltaZ != 0) {
+                    if (evt.deltaZ !== 0) {
                         this.onInputChanged(deviceType, deviceSlot, PointerInput.MouseWheelZ, previousWheelScrollZ, pointer[PointerInput.MouseWheelZ]);
                     }
                 }
@@ -511,7 +510,7 @@ export class DeviceInputSystem implements IDisposable {
         // Gamepads
         const gp = navigator.getGamepads()[deviceSlot];
 
-        if (gp && deviceType == this._gamepads[deviceSlot]) {
+        if (gp && deviceType === this._gamepads[deviceSlot]) {
             const device = this._inputs[deviceType][deviceSlot];
 
             if (inputIndex >= gp.buttons.length) {

+ 7 - 7
src/Inputs/scene.inputManager.ts

@@ -306,7 +306,7 @@ export class InputManager {
                         var pickResult = scene.pick(
                             this._unTranslatedPointerX,
                             this._unTranslatedPointerY,
-                            (mesh: AbstractMesh): boolean => <boolean>(mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(Constants.ACTION_OnLongPressTrigger) && mesh == this._pickedDownMesh),
+                            (mesh: AbstractMesh): boolean => <boolean>(mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(Constants.ACTION_OnLongPressTrigger) && mesh === this._pickedDownMesh),
                             false,
                             scene.cameraToUseForPointers
                         );
@@ -635,7 +635,7 @@ export class InputManager {
                     mesh.isVisible &&
                     mesh.isReady() &&
                     mesh.isEnabled() &&
-                    (mesh.enablePointerMoveEvents || scene.constantlyUpdateMeshUnderPointer || mesh._getActionManagerForTrigger() != null) &&
+                    (mesh.enablePointerMoveEvents || scene.constantlyUpdateMeshUnderPointer || mesh._getActionManagerForTrigger() !== null) &&
                     (!scene.cameraToUseForPointers || (scene.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
             }
 
@@ -826,11 +826,11 @@ export class InputManager {
                 evt.key = String.fromCharCode(inputIndex);
                 evt.keyCode = inputIndex;
 
-                if (currentState == 1) {
+                if (currentState === 1) {
                     this._onKeyDown((evt as IKeyboardEvent));
                 }
 
-                if (currentState == 0) {
+                if (currentState === 0) {
                     this._onKeyUp((evt as IKeyboardEvent));
                 }
             }
@@ -856,14 +856,14 @@ export class InputManager {
                 evt.x = pointerX;
                 evt.y = pointerY;
 
-                if (attachDown && inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick && currentState == 1) {   // Pointer Down
+                if (attachDown && inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick && currentState === 1) {   // Pointer Down
                     evt.type = "pointerdown";
                     evt.button = (inputIndex - 2);
 
                     this._onPointerDown((evt as IPointerEvent));
                 }
 
-                if (attachUp && inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick && currentState == 0) {   // Pointer Up
+                if (attachUp && inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick && currentState === 0) {   // Pointer Up
                     evt.type = "pointerup";
                     evt.button = (inputIndex - 2);
 
@@ -893,7 +893,7 @@ export class InputManager {
                         evt.deltaZ = deltaZ;
 
                         // If we have a delta, use it.
-                        if (deltaX != 0 || deltaY != 0 || deltaZ != 0) {
+                        if (deltaX !== 0 || deltaY !== 0 || deltaZ !== 0) {
                             this._onPointerMove((evt as IWheelEvent));
                         }
                     }