浏览代码

Merge pull request #7070 from RaananW/edge-ftw

fixing a bug with edge and VR
David Catuhe 5 年之前
父节点
当前提交
d9bc65dc5b
共有 3 个文件被更改,包括 13 次插入4 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 4 4
      src/Cameras/VR/vrExperienceHelper.ts
  3. 8 0
      src/Engines/Extensions/engine.webVR.ts

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

@@ -212,6 +212,7 @@
 - Cloning of `ShaderMaterial` also clone `shaderPath` and `options` properties ([Popov72](https://github.com/Popov72))
 - Prevent an infinite loop when calling `engine.dispose()` in a scene with multiple `SoundTracks` defined ([kirbysayshi](https://github.com/kirbysayshi))
 - Fixed missing properties in serialization / parsing of `coneParticleEmitter` ([Popov72](https://github.com/Popov72))
+- Fix a bug with exit VR and Edge ([RaananW](https://github.com/RaananW/))
 
 ## Breaking changes
 

+ 4 - 4
src/Cameras/VR/vrExperienceHelper.ts

@@ -776,7 +776,7 @@ export class VRExperienceHelper {
                 if (!this.isInVRMode) {
                     this.enterVR();
                 } else {
-                    this.exitVR();
+                    this._scene.getEngine().disableVR();
                 }
             });
         }
@@ -1107,9 +1107,6 @@ export class VRExperienceHelper {
             if (this._deviceOrientationCamera) {
                 this._deviceOrientationCamera.position = this._position;
                 this._scene.activeCamera = this._deviceOrientationCamera;
-                if (this._inputElement) {
-                    this._scene.activeCamera.attachControl(this._inputElement);
-                }
 
                 // Restore angular sensibility
                 if (this._cachedAngularSensibility.angularSensibilityX) {
@@ -1127,6 +1124,9 @@ export class VRExperienceHelper {
             } else if (this._existingCamera) {
                 this._existingCamera.position = this._position;
                 this._scene.activeCamera = this._existingCamera;
+                if (this._inputElement) {
+                    this._scene.activeCamera.attachControl(this._inputElement);
+                }
 
                 // Restore angular sensibility
                 if (this._cachedAngularSensibility.angularSensibilityX) {

+ 8 - 0
src/Engines/Extensions/engine.webVR.ts

@@ -269,6 +269,14 @@ Engine.prototype._connectVREvents = function(canvas?: HTMLCanvasElement, documen
     };
 
     this._onVRDisplayPointerUnrestricted = () => {
+        // Edge fix - for some reason document is not present and this is window
+        if (!document) {
+            let hostWindow = this.getHostWindow()!;
+            if (hostWindow.document && hostWindow.document.exitPointerLock) {
+                hostWindow.document.exitPointerLock();
+            }
+            return;
+        }
         if (!document.exitPointerLock) {
             return;
         }