ソースを参照

Merge pull request #9569 from mrdunk/tidyInputsBase

Small tidy up around Camera Inputs Base classes.
David Catuhe 4 年 前
コミット
55a7ee9f4d

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

@@ -67,6 +67,8 @@
 - Fix detail map not working in WebGL1 ([Popov72](https://github.com/Popov72))
 - Fix ArcRotateCamera behaviour when panning is disabled on multiTouch event ([NicolasBuecher](https://github.com/NicolasBuecher))
 - Fix vertically interlaced stereoscopic rendering (`RIG_MODE_STEREOSCOPIC_INTERLACED`) not working (follow-up [#7425](https://github.com/BabylonJS/Babylon.js/issues/7425), [#8000](https://github.com/BabylonJS/Babylon.js/issues/8000)) ([foxxyz](https://github.com/foxxyz))
+- Fix accessibility of BaseCameraMouseWheelInput and BaseCameraPointersInput. They appear in documentation but were not available for include. ([mrdunk](https://github.com/mrdunk))
+- Fix function creation inside regularly called freeCameraMouseWheelInput method leading to excessive GC load. ([mrdunk](https://github.com/mrdunk))
 
 ## Breaking changes
 

+ 48 - 48
src/Cameras/Inputs/freeCameraMouseWheelInput.ts

@@ -334,60 +334,60 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
      * mouse-wheel axis.
      */
     private _updateCamera(): void {
-        const moveRelative = this._moveRelative;
-        const rotateRelative = this._rotateRelative;
-        const moveScene = this._moveScene;
-
-        let updateCameraProperty = function(/* Mouse-wheel delta. */
-                                            value: number,
-                                            /* Camera property to be changed. */
-                                            cameraProperty: Nullable<_CameraProperty>,
-                                            /* Axis of Camera property to be changed. */
-                                            coordinate: Nullable<Coordinate>): void {
-                if (value === 0) {
-                    // Mouse wheel has not moved.
-                    return;
-                }
-                if (cameraProperty === null || coordinate === null) {
-                    // Mouse wheel axis not configured.
-                    return;
-                }
-
-                let action = null;
-                switch (cameraProperty) {
-                    case _CameraProperty.MoveRelative:
-                        action = moveRelative;
-                        break;
-                    case _CameraProperty.RotateRelative:
-                        action = rotateRelative;
-                        break;
-                    case _CameraProperty.MoveScene:
-                        action = moveScene;
-                        break;
-                }
-
-                switch (coordinate) {
-                    case Coordinate.X:
-                        action.set(value, 0, 0);
-                        break;
-                    case Coordinate.Y:
-                        action.set(0, value, 0);
-                        break;
-                    case Coordinate.Z:
-                        action.set(0, 0, value);
-                        break;
-                }
-            };
-
         // Do the camera updates for each of the 3 touch-wheel axis.
-        updateCameraProperty(
+        this._updateCameraProperty(
             this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate);
-        updateCameraProperty(
+        this._updateCameraProperty(
             this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate);
-        updateCameraProperty(
+        this._updateCameraProperty(
             this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate);
     }
 
+    /**
+     * Update one property of the camera.
+     */
+    private _updateCameraProperty(
+        /* Mouse-wheel delta. */
+        value: number,
+        /* Camera property to be changed. */
+        cameraProperty: Nullable<_CameraProperty>,
+        /* Axis of Camera property to be changed. */
+        coordinate: Nullable<Coordinate>
+    ): void {
+        if (value === 0) {
+            // Mouse wheel has not moved.
+            return;
+        }
+        if (cameraProperty === null || coordinate === null) {
+            // Mouse wheel axis not configured.
+            return;
+        }
+
+        let action = null;
+        switch (cameraProperty) {
+            case _CameraProperty.MoveRelative:
+                action = this._moveRelative;
+                break;
+            case _CameraProperty.RotateRelative:
+                action = this._rotateRelative;
+                break;
+            case _CameraProperty.MoveScene:
+                action = this._moveScene;
+                break;
+        }
+
+        switch (coordinate) {
+            case Coordinate.X:
+                action.set(value, 0, 0);
+                break;
+            case Coordinate.Y:
+                action.set(0, value, 0);
+                break;
+            case Coordinate.Z:
+                action.set(0, 0, value);
+                break;
+        }
+    }
 }
 
 (<any>CameraInputTypes)["FreeCameraMouseWheelInput"] = FreeCameraMouseWheelInput;

+ 2 - 0
src/Cameras/Inputs/index.ts

@@ -1,3 +1,5 @@
+export * from "./BaseCameraMouseWheelInput";
+export * from "./BaseCameraPointersInput";
 export * from "./arcRotateCameraGamepadInput";
 export * from "./arcRotateCameraKeyboardMoveInput";
 export * from "./arcRotateCameraMouseWheelInput";