Selaa lähdekoodia

Right handed systems support

Raanan Weber 5 vuotta sitten
vanhempi
commit
4221aa0e56

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

@@ -76,6 +76,7 @@
 - Playground doesn't update FPS when in XR in main and frame ([#7875](https://github.com/BabylonJS/Babylon.js/issues/7875)) ([RaananW](https://github.com/RaananW))
 - Added support for teleportation using pointer events ([RaananW](https://github.com/RaananW))
 - AR reference space type recommendation changed to 'unbounded' ([#7959](https://github.com/BabylonJS/Babylon.js/issues/7959)) ([RaananW](https://github.com/RaananW))
+- Support for pointer selection and teleportation in right handed systems ([#7959](https://github.com/BabylonJS/Babylon.js/issues/7959)) ([RaananW](https://github.com/RaananW))
 
 ### Collisions
 

+ 4 - 4
src/Maths/math.vector.ts

@@ -1437,15 +1437,15 @@ export class Vector3 {
      * Returns a new Vector3 set to (0.0, 0.0, 1.0)
      * @returns a new forward Vector3
      */
-    public static Forward(): Vector3 {
-        return new Vector3(0.0, 0.0, 1.0);
+    public static Forward(rightHandedSystem: boolean = false): Vector3 {
+        return new Vector3(0.0, 0.0, (rightHandedSystem ? -1.0 : 1.0));
     }
     /**
      * Returns a new Vector3 set to (0.0, 0.0, -1.0)
      * @returns a new forward Vector3
      */
-    public static Backward(): Vector3 {
-        return new Vector3(0.0, 0.0, -1.0);
+    public static Backward(rightHandedSystem: boolean = false): Vector3 {
+        return new Vector3(0.0, 0.0, (rightHandedSystem ? 1.0 : -1.0));
     }
     /**
      * Returns a new Vector3 set to (1.0, 0.0, 0.0)

+ 1 - 1
src/XR/features/WebXRControllerTeleportation.ts

@@ -468,7 +468,7 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
                                 if (!controllerData.teleportationState.backwards) {
                                     controllerData.teleportationState.backwards = true;
                                     // teleport backwards ONCE
-                                    this._tmpVector.set(0, 0, this.backwardsTeleportationDistance!);
+                                    this._tmpVector.set(0, 0, this.backwardsTeleportationDistance * (this._xrSessionManager.scene.useRightHandedSystem ? -1.0 : 1.0));
                                     this._tmpVector.rotateByQuaternionToRef(this._options.xrInput.xrCamera.rotationQuaternion!, this._tmpVector);
                                     this._tmpVector.addInPlace(this._options.xrInput.xrCamera.position);
                                     this._options.xrInput.xrCamera.position.subtractToRef(this._tmpVector, this._tmpVector);

+ 1 - 1
src/XR/webXRInputSource.ts

@@ -141,7 +141,7 @@ export class WebXRInputSource {
         const object = gripIfAvailable && this.grip ? this.grip : this.pointer;
         let worldMatrix = object.computeWorldMatrix();
         worldMatrix.decompose(undefined, this._tmpQuaternion, undefined);
-        this._tmpVector.set(0, 0, 1);
+        this._tmpVector.set(0, 0, (this._scene.useRightHandedSystem ? -1.0 : 1.0));
         this._tmpVector.rotateByQuaternionToRef(this._tmpQuaternion, this._tmpVector);
         result.origin.copyFrom(object.absolutePosition);
         result.direction.copyFrom(this._tmpVector);