Przeglądaj źródła

Merge pull request #7193 from LeoRodz/master

Add easingFunction option to VRTeleportationOptions
David Catuhe 5 lat temu
rodzic
commit
d115c861bf

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

@@ -160,6 +160,7 @@
 - Added option to change the teleportation duration in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - Added option to change the teleportation duration in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - Added support to teleport the camera at constant speed in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - Added support to teleport the camera at constant speed in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 - VRExperienceHelper has now an XR fallback to force XR usage (Beta) ([RaananW](https://github.com/RaananW/))
 - VRExperienceHelper has now an XR fallback to force XR usage (Beta) ([RaananW](https://github.com/RaananW/))
+- Added option to change the teleportation easing function in the VRExperienceHelper class ([https://github.com/LeoRodz](https://github.com/LeoRodz))
 
 
 ### Ray
 ### Ray
 
 

+ 10 - 1
src/Cameras/VR/vrExperienceHelper.ts

@@ -65,6 +65,10 @@ export interface VRTeleportationOptions {
      * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
      * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
      */
      */
     teleportationSpeed?: number;
     teleportationSpeed?: number;
+    /**
+     * The easing function used in the animation or null for Linear. (default CircleEase)
+     */
+    easingFunction?: EasingFunction;
 }
 }
 
 
 /**
 /**
@@ -408,6 +412,7 @@ export class VRExperienceHelper {
     private _teleportationMode: number = VRExperienceHelper.TELEPORTATIONMODE_CONSTANTTIME;
     private _teleportationMode: number = VRExperienceHelper.TELEPORTATIONMODE_CONSTANTTIME;
     private _teleportationTime: number = 122;
     private _teleportationTime: number = 122;
     private _teleportationSpeed: number = 20;
     private _teleportationSpeed: number = 20;
+    private _teleportationEasing: EasingFunction;
     private _rotationAllowed: boolean = true;
     private _rotationAllowed: boolean = true;
     private _teleportBackwardsVector = new Vector3(0, -1, -1);
     private _teleportBackwardsVector = new Vector3(0, -1, -1);
     private _teleportationTarget: Mesh;
     private _teleportationTarget: Mesh;
@@ -983,6 +988,7 @@ export class VRExperienceHelper {
         //create easing functions
         //create easing functions
         this._circleEase = new CircleEase();
         this._circleEase = new CircleEase();
         this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT);
         this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT);
+        this._teleportationEasing = this._circleEase;
 
 
         // Allow clicking in the vrDeviceOrientationCamera
         // Allow clicking in the vrDeviceOrientationCamera
         scene.onPointerObservable.add((e) => {
         scene.onPointerObservable.add((e) => {
@@ -1492,6 +1498,9 @@ export class VRExperienceHelper {
             if (vrTeleportationOptions.teleportationSpeed && vrTeleportationOptions.teleportationSpeed > 0) {
             if (vrTeleportationOptions.teleportationSpeed && vrTeleportationOptions.teleportationSpeed > 0) {
                 this._teleportationSpeed = vrTeleportationOptions.teleportationSpeed;
                 this._teleportationSpeed = vrTeleportationOptions.teleportationSpeed;
             }
             }
+            if (vrTeleportationOptions.easingFunction !== undefined) {
+                this._teleportationEasing = vrTeleportationOptions.easingFunction;
+            }
 
 
             if (this._leftController != null) {
             if (this._leftController != null) {
                 this._enableTeleportationOnController(this._leftController);
                 this._enableTeleportationOnController(this._leftController);
@@ -2017,7 +2026,7 @@ export class VRExperienceHelper {
         ];
         ];
 
 
         animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
         animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
-        animationCameraTeleportation.setEasingFunction(this._circleEase);
+        animationCameraTeleportation.setEasingFunction(this._teleportationEasing);
         this.currentVRCamera.animations.push(animationCameraTeleportation);
         this.currentVRCamera.animations.push(animationCameraTeleportation);
 
 
         this._postProcessMove.animations = [];
         this._postProcessMove.animations = [];