소스 검색

Updated baselines for tests, removed magic number and added event specific constants

Dave Solares 4 년 전
부모
커밋
4285604c36

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"thinEngineOnly":130009,"engineOnly":167383,"sceneOnly":522497,"minGridMaterial":698122,"minStandardMaterial":860714}
+{"thinEngineOnly":130129,"engineOnly":167503,"sceneOnly":532854,"minGridMaterial":708600,"minStandardMaterial":871072}

+ 2 - 2
src/Cameras/Inputs/BaseCameraMouseWheelInput.ts

@@ -5,7 +5,7 @@ import { Camera } from "../../Cameras/camera";
 import { ICameraInput } from "../../Cameras/cameraInputsManager";
 import { PointerInfo, PointerEventTypes } from "../../Events/pointerEvents";
 import { Tools } from "../../Misc/tools";
-import { IWheelEvent } from "../../Events/deviceInputEvents";
+import { EventConstants, IWheelEvent } from "../../Events/deviceInputEvents";
 
 /**
  * Base class for mouse wheel input..
@@ -64,7 +64,7 @@ export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera>
 
             const event = <IWheelEvent>pointer.event;
 
-            const platformScale = event.deltaMode === 0x01 ? this._ffMultiplier : 1;  // If this happens to be set to DOM_DELTA_LINE, adjust accordingly
+            const platformScale = event.deltaMode === EventConstants.DOM_DELTA_LINE ? this._ffMultiplier : 1;  // If this happens to be set to DOM_DELTA_LINE, adjust accordingly
 
             if (event.deltaY !== undefined) {
                 // Most recent browsers versions have delta properties.

+ 20 - 0
src/Events/deviceInputEvents.ts

@@ -258,4 +258,24 @@ export interface IWheelEvent extends IMouseEvent {
      * Z-Axis scroll delta
      */
     deltaZ: number;
+}
+
+/**
+ * Constants used for Events
+ */
+export class EventConstants {
+    /**
+     * Pixel delta for Wheel Events (Default)
+     */
+    public static DOM_DELTA_PIXEL = 0x00;
+
+    /**
+     * Line delta for Wheel Events
+     */
+    public static DOM_DELTA_LINE = 0x01;
+
+    /**
+     * Page delta for Wheel Events
+     */
+    public static DOM_DELTA_PAGE = 0x02;
 }

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

@@ -9,7 +9,7 @@ import { Constants } from "../Engines/constants";
 import { ActionEvent } from "../Actions/actionEvent";
 import { KeyboardEventTypes, KeyboardInfoPre, KeyboardInfo } from "../Events/keyboardEvents";
 import { DeviceType, PointerInput } from '../DeviceInput/InputDevices/deviceEnums';
-import { IKeyboardEvent, IMouseEvent, IPointerEvent, IWheelEvent } from '../Events/deviceInputEvents';
+import { EventConstants, IKeyboardEvent, IMouseEvent, IPointerEvent, IWheelEvent } from '../Events/deviceInputEvents';
 import { DeviceInputSystem } from '../DeviceInput/deviceInputSystem';
 
 declare type Scene = import("../scene").Scene;
@@ -887,7 +887,7 @@ export class InputManager {
                         const deltaZ = this._deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelZ);
 
                         evt.type = "wheel";
-                        evt.deltaMode = 0x00;
+                        evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;
                         evt.deltaX = deltaX;
                         evt.deltaY = deltaY;
                         evt.deltaZ = deltaZ;