瀏覽代碼

support clicking when using the fallback vr camera

Trevor Baron 6 年之前
父節點
當前提交
313fe65dbd
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/Cameras/VR/vrExperienceHelper.ts

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

@@ -819,6 +819,19 @@ export class VRExperienceHelper {
         this._circleEase = new CircleEase();
         this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT);
 
+        // Allow clicking in the vrDeviceOrientationCamera
+        scene.onPointerObservable.add((e) => {
+            if (this._interactionsEnabled) {
+                if (scene.activeCamera == this.vrDeviceOrientationCamera && (e.event as PointerEvent).pointerType == "mouse") {
+                    if (e.type == PointerEventTypes.POINTERDOWN) {
+                        this._cameraGazer._selectionPointerDown();
+                    }else if (e.type == PointerEventTypes.POINTERUP) {
+                        this._cameraGazer._selectionPointerUp();
+                    }
+                }
+            }
+        });
+
         if (this.webVROptions.floorMeshes) {
             this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
         }