Просмотр исходного кода

Merge pull request #3479 from CarlosLanderas/lande/vrhelper-teleport-events

[VRHelper] Add onBeforeCameraTeleport and onAfterCameraTeleport observables
Raanan Weber 7 лет назад
Родитель
Сommit
6300a5ac62
1 измененных файлов с 15 добавлено и 1 удалено
  1. 15 1
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 15 - 1
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -113,6 +113,16 @@ module BABYLON {
         private _circleEase: CircleEase;
 
         /**
+         * Observable raised before camera teleportation        
+        */
+        public onBeforeCameraTeleport = new Observable<Vector3>();
+
+        /**
+         *  Observable raised after camera teleportation
+        */
+        public onAfterCameraTeleport = new Observable<Vector3>();
+
+        /**
         * Observable raised when current selected mesh gets unselected
         */
         public onSelectedMeshUnselected = new Observable<AbstractMesh>();
@@ -1223,6 +1233,8 @@ module BABYLON {
                 this._workingVector.y += this._defaultHeight;
             }
 
+            this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
+
             // Create animation from the camera's position to the new location
             this.currentVRCamera.animations = [];
             var animationCameraTeleportation = new Animation("animationCameraTeleportation", "position", 90, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
@@ -1289,7 +1301,9 @@ module BABYLON {
             this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, () => {
                 this._webVRCamera.detachPostProcess(this._postProcessMove)
             });
-            this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1);
+            this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, () => {
+                this.onAfterCameraTeleport.notifyObservers(this._workingVector);
+            });
         }
 
         private _castRayAndSelectObject() {