Bladeren bron

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 6 jaren geleden
bovenliggende
commit
d4255233f5

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

@@ -198,7 +198,7 @@
 - Context loss causing unexpected results with dynamic textures, geometries with the same name and reflectionTextures ([TrevorDev](https://github.com/TrevorDev))
 - Context loss causing unexpected results with dynamic textures, geometries with the same name and reflectionTextures ([TrevorDev](https://github.com/TrevorDev))
 - CreateScreenshotUsingRenderTarget stretches mirror textures when setting both width and height ([TrevorDev](https://github.com/TrevorDev))
 - CreateScreenshotUsingRenderTarget stretches mirror textures when setting both width and height ([TrevorDev](https://github.com/TrevorDev))
 - VR helper only updating vr cameras position when entering vr, rotation was missing, laser distance stopped working ([TrevorDev](https://github.com/TrevorDev))
 - VR helper only updating vr cameras position when entering vr, rotation was missing, laser distance stopped working ([TrevorDev](https://github.com/TrevorDev))
-- Fix VR controllers after gltfLoader transformNode change ([TrevorDev](https://github.com/TrevorDev))
+- Fix VR controllers after gltfLoader transformNode was changed ([TrevorDev](https://github.com/TrevorDev))
 - Bounding Box fixedDragMeshScreenSize stopped working and allow rotating through bounding box ([TrevorDev](https://github.com/TrevorDev))
 - Bounding Box fixedDragMeshScreenSize stopped working and allow rotating through bounding box ([TrevorDev](https://github.com/TrevorDev))
 - VR helper would rotate non vr camera while in VR ([TrevorDev](https://github.com/TrevorDev))
 - VR helper would rotate non vr camera while in VR ([TrevorDev](https://github.com/TrevorDev))
 - PointerDragBahavior using Mesh as base type, causing type-checking problems with AbstractMesh ([Poolminer](https://github.com/Poolminer/))
 - PointerDragBahavior using Mesh as base type, causing type-checking problems with AbstractMesh ([Poolminer](https://github.com/Poolminer/))
@@ -262,6 +262,7 @@
 - Add hemispheric lighting to gizmos to avoid flat look ([TrevorDev](https://github.com/TrevorDev))
 - Add hemispheric lighting to gizmos to avoid flat look ([TrevorDev](https://github.com/TrevorDev))
 - Fix a bug causing `WebRequest.open` to crash if `WebRequest.CustomRequestHeaders` are set [#6055](https://github.com/BabylonJS/Babylon.js/issues/6055)([susares](https://github.com/susares))
 - Fix a bug causing `WebRequest.open` to crash if `WebRequest.CustomRequestHeaders` are set [#6055](https://github.com/BabylonJS/Babylon.js/issues/6055)([susares](https://github.com/susares))
 - Fix a bug causing `Mesh.clone` to crash if no physicsEngineComponent is used  ([barroij](https://github.com/barroij))
 - Fix a bug causing `Mesh.clone` to crash if no physicsEngineComponent is used  ([barroij](https://github.com/barroij))
+- Fix zoom inertia making it difficult to zoom out with ArcRotateCamera ([TrevorDev](https://github.com/TrevorDev))
 
 
 ### Viewer
 ### Viewer
 
 

+ 22 - 5
src/Cameras/Inputs/arcRotateCameraMouseWheelInput.ts

@@ -31,6 +31,16 @@ export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCam
     private _wheel: Nullable<(p: PointerInfo, s: EventState) => void>;
     private _wheel: Nullable<(p: PointerInfo, s: EventState) => void>;
     private _observer: Nullable<Observer<PointerInfo>>;
     private _observer: Nullable<Observer<PointerInfo>>;
 
 
+    private computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent: any, radius: number) {
+        var delta = 0;
+        var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * this.wheelDeltaPercentage) * radius;
+        if (mouseWheelLegacyEvent.wheelDelta > 0) {
+            delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);
+        } else {
+            delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);
+        }
+        return delta;
+    }
     /**
     /**
      * Attach the input controls to a specific dom element to get the input from.
      * Attach the input controls to a specific dom element to get the input from.
      * @param element Defines the element the controls should be listened from
      * @param element Defines the element the controls should be listened from
@@ -46,11 +56,18 @@ export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCam
             let mouseWheelLegacyEvent = event as any;
             let mouseWheelLegacyEvent = event as any;
             if (mouseWheelLegacyEvent.wheelDelta) {
             if (mouseWheelLegacyEvent.wheelDelta) {
                 if (this.wheelDeltaPercentage) {
                 if (this.wheelDeltaPercentage) {
-                    var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * this.wheelDeltaPercentage) * this.camera.radius;
-                    if (mouseWheelLegacyEvent.wheelDelta > 0) {
-                        delta = wheelDelta / (1.0 + this.wheelDeltaPercentage);
-                    } else {
-                        delta = wheelDelta * (1.0 + this.wheelDeltaPercentage);
+                    delta = this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, this.camera.radius);
+
+                    // If zooming in, estimate the target radius and use that to compute the delta for inertia
+                    // this will stop multiple scroll events zooming in from adding too much inertia
+                    if (delta > 0) {
+                        var estimatedTargetRadius = this.camera.radius;
+                        var targetInertia = this.camera.inertialRadiusOffset + delta;
+                        for (var i = 0; i < 20 && Math.abs(targetInertia) > 0.001; i++) {
+                            estimatedTargetRadius -= targetInertia;
+                            targetInertia *= this.camera.inertia;
+                        }
+                        delta = this.computeDeltaFromMouseWheelLegacyEvent(mouseWheelLegacyEvent, estimatedTargetRadius);
                     }
                     }
                 } else {
                 } else {
                     delta = mouseWheelLegacyEvent.wheelDelta / (this.wheelPrecision * 40);
                     delta = mouseWheelLegacyEvent.wheelDelta / (this.wheelPrecision * 40);

+ 6 - 0
src/Cameras/VR/vrExperienceHelper.ts

@@ -1114,6 +1114,12 @@ export class VRExperienceHelper {
             });
             });
 
 
             this._hasEnteredVR = false;
             this._hasEnteredVR = false;
+
+            // Update engine state to re enable non-vr camera input
+            var engine = this._scene.getEngine();
+            if (engine._onVrDisplayPresentChange) {
+                engine._onVrDisplayPresentChange();
+            }
         }
         }
     }
     }