David `Deltakosh` Catuhe 5 anni fa
parent
commit
1bb5348342
2 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 2 0
      src/XR/features/WebXRControllerTeleportation.ts
  2. 11 0
      src/XR/webXRCamera.ts

+ 2 - 0
src/XR/features/WebXRControllerTeleportation.ts

@@ -743,9 +743,11 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
         // do the movement forward here
         if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
             const height = this._options.xrInput.xrCamera.realWorldHeight;
+            this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position);
             this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position);
             this._options.xrInput.xrCamera.position.y += height;
             this._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(Quaternion.FromEulerAngles(0, controllerData.teleportationState.currentRotation - (this._xrSessionManager.scene.useRightHandedSystem ? Math.PI : 0), 0));
+            this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position);
         }
     }
 }

+ 11 - 0
src/XR/webXRCamera.ts

@@ -5,6 +5,7 @@ import { FreeCamera } from "../Cameras/freeCamera";
 import { TargetCamera } from "../Cameras/targetCamera";
 import { WebXRSessionManager } from "./webXRSessionManager";
 import { Viewport } from "../Maths/math.viewport";
+import { Observable } from '../Misc/observable';
 
 /**
  * WebXR Camera which holds the views for the xrSession
@@ -18,6 +19,16 @@ export class WebXRCamera extends FreeCamera {
     private _xrInvQuaternionCache = Quaternion.Identity();
 
     /**
+     * Observable raised before camera teleportation
+     */
+    public onBeforeCameraTeleport = new Observable<Vector3>();
+
+    /**
+     *  Observable raised after camera teleportation
+     */
+    public onAfterCameraTeleport = new Observable<Vector3>();    
+
+    /**
      * Should position compensation execute on first frame.
      * This is used when copying the position from a native (non XR) camera
      */