Prechádzať zdrojové kódy

Refactoring VRHelper for Firefox compatibility

David Rousset 8 rokov pred
rodič
commit
efe7a3116c
23 zmenil súbory, kde vykonal 30386 pridanie a 30344 odobranie
  1. 6650 6647
      dist/preview release/babylon.d.ts
  2. 36 36
      dist/preview release/babylon.js
  3. 21 12
      dist/preview release/babylon.max.js
  4. 6650 6647
      dist/preview release/babylon.module.d.ts
  5. 37 37
      dist/preview release/babylon.worker.js
  6. 8312 8309
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 39 39
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 21 12
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 8312 8309
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  10. 2 2
      dist/preview release/gui/babylon.gui.js
  11. 3 3
      dist/preview release/gui/babylon.gui.min.js
  12. 265 265
      dist/preview release/inspector/babylon.inspector.bundle.js
  13. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  14. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  15. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  16. 2 2
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  17. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  18. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  19. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  20. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  21. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  22. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  23. 24 12
      src/Cameras/VR/babylon.vrExperienceHelper.ts

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 6650 - 6647
dist/preview release/babylon.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 36 - 36
dist/preview release/babylon.js


+ 21 - 12
dist/preview release/babylon.max.js

@@ -66881,17 +66881,17 @@ var BABYLON;
             this._isInVRMode = false;
             this._scene = scene;
             if (!this._scene.activeCamera) {
-                this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
             }
             else {
-                var newCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
                 if (scene.activeCamera.rotation) {
-                    newCamera.rotation = scene.activeCamera.rotation.clone();
+                    this._deviceOrientationCamera.rotation = scene.activeCamera.rotation.clone();
                 }
-                newCamera.minZ = this._scene.activeCamera.minZ;
-                newCamera.maxZ = this._scene.activeCamera.maxZ;
-                this._scene.activeCamera = newCamera;
+                this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
+                this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
             }
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._position = this._scene.activeCamera.position;
             this._canvas = scene.getEngine().getRenderingCanvas();
             this._scene.activeCamera.attachControl(this._canvas);
@@ -66924,13 +66924,14 @@ var BABYLON;
             if (navigator.getVRDisplays) {
                 navigator.getVRDisplays().then(function (headsets) {
                     if (headsets.length > 0) {
-                        scene.getEngine().initWebVR();
+                        _this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", _this._position, _this._scene);
                         _this._webVRsupportedAndReady = true;
                     }
                     document.body.appendChild(_this._btnVR);
                 });
             }
             else {
+                this._vrDeviceOrientationCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
                 document.body.appendChild(this._btnVR);
             }
             this._btnVR.addEventListener("click", function () {
@@ -66938,13 +66939,14 @@ var BABYLON;
             });
         }
         VRExperienceHelper.prototype.enterVR = function () {
-            this._scene.activeCamera.dispose();
             // If WebVR is supported and a headset is connected
             if (this._webVRsupportedAndReady) {
-                this._scene.activeCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene);
+                this._webVRCamera.position = this._position;
+                this._scene.activeCamera = this._webVRCamera;
             }
             else {
-                this._scene.activeCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
+                this._vrDeviceOrientationCamera.position = this._position;
+                this._scene.activeCamera = this._vrDeviceOrientationCamera;
                 this._scene.getEngine().switchFullscreen(true);
             }
             this._scene.activeCamera.attachControl(this._canvas);
@@ -66957,9 +66959,9 @@ var BABYLON;
             }
             if (this._scene.activeCamera) {
                 this._position = this._scene.activeCamera.position;
-                this._scene.activeCamera.dispose();
             }
-            this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, this._scene);
+            this._deviceOrientationCamera.position = this._position;
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._scene.activeCamera.attachControl(this._canvas);
             this._isInVRMode = false;
             this._btnVR.style.display = "";
@@ -66979,6 +66981,13 @@ var BABYLON;
             if (this._isInVRMode) {
                 this.exitVR();
             }
+            this._deviceOrientationCamera.dispose();
+            if (this._webVRCamera) {
+                this._webVRCamera.dispose();
+            }
+            if (this._vrDeviceOrientationCamera) {
+                this._vrDeviceOrientationCamera.dispose();
+            }
             document.body.removeChild(this._btnVR);
         };
         VRExperienceHelper.prototype.getClassName = function () {

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 6650 - 6647
dist/preview release/babylon.module.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 37 - 37
dist/preview release/babylon.worker.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 8312 - 8309
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 39 - 39
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 21 - 12
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -66881,17 +66881,17 @@ var BABYLON;
             this._isInVRMode = false;
             this._scene = scene;
             if (!this._scene.activeCamera) {
-                this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
             }
             else {
-                var newCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
                 if (scene.activeCamera.rotation) {
-                    newCamera.rotation = scene.activeCamera.rotation.clone();
+                    this._deviceOrientationCamera.rotation = scene.activeCamera.rotation.clone();
                 }
-                newCamera.minZ = this._scene.activeCamera.minZ;
-                newCamera.maxZ = this._scene.activeCamera.maxZ;
-                this._scene.activeCamera = newCamera;
+                this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
+                this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
             }
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._position = this._scene.activeCamera.position;
             this._canvas = scene.getEngine().getRenderingCanvas();
             this._scene.activeCamera.attachControl(this._canvas);
@@ -66924,13 +66924,14 @@ var BABYLON;
             if (navigator.getVRDisplays) {
                 navigator.getVRDisplays().then(function (headsets) {
                     if (headsets.length > 0) {
-                        scene.getEngine().initWebVR();
+                        _this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", _this._position, _this._scene);
                         _this._webVRsupportedAndReady = true;
                     }
                     document.body.appendChild(_this._btnVR);
                 });
             }
             else {
+                this._vrDeviceOrientationCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
                 document.body.appendChild(this._btnVR);
             }
             this._btnVR.addEventListener("click", function () {
@@ -66938,13 +66939,14 @@ var BABYLON;
             });
         }
         VRExperienceHelper.prototype.enterVR = function () {
-            this._scene.activeCamera.dispose();
             // If WebVR is supported and a headset is connected
             if (this._webVRsupportedAndReady) {
-                this._scene.activeCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene);
+                this._webVRCamera.position = this._position;
+                this._scene.activeCamera = this._webVRCamera;
             }
             else {
-                this._scene.activeCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
+                this._vrDeviceOrientationCamera.position = this._position;
+                this._scene.activeCamera = this._vrDeviceOrientationCamera;
                 this._scene.getEngine().switchFullscreen(true);
             }
             this._scene.activeCamera.attachControl(this._canvas);
@@ -66957,9 +66959,9 @@ var BABYLON;
             }
             if (this._scene.activeCamera) {
                 this._position = this._scene.activeCamera.position;
-                this._scene.activeCamera.dispose();
             }
-            this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, this._scene);
+            this._deviceOrientationCamera.position = this._position;
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._scene.activeCamera.attachControl(this._canvas);
             this._isInVRMode = false;
             this._btnVR.style.display = "";
@@ -66979,6 +66981,13 @@ var BABYLON;
             if (this._isInVRMode) {
                 this.exitVR();
             }
+            this._deviceOrientationCamera.dispose();
+            if (this._webVRCamera) {
+                this._webVRCamera.dispose();
+            }
+            if (this._vrDeviceOrientationCamera) {
+                this._vrDeviceOrientationCamera.dispose();
+            }
             document.body.removeChild(this._btnVR);
         };
         VRExperienceHelper.prototype.getClassName = function () {

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 8312 - 8309
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 2 - 2
dist/preview release/gui/babylon.gui.js

@@ -313,8 +313,8 @@ var BABYLON;
                     var camera = scene.cameraToUseForPointers || scene.activeCamera;
                     var engine = scene.getEngine();
                     var viewport = camera.viewport;
-                    var x = (scene.pointerX - viewport.x * engine.getRenderWidth()) / viewport.width;
-                    var y = (scene.pointerY - viewport.y * engine.getRenderHeight()) / viewport.height;
+                    var x = (scene.pointerX / engine.getHardwareScalingLevel() - viewport.x * engine.getRenderWidth()) / viewport.width;
+                    var y = (scene.pointerY / engine.getHardwareScalingLevel() - viewport.y * engine.getRenderHeight()) / viewport.height;
                     _this._shouldBlockPointer = false;
                     _this._doPicking(x, y, pi.type);
                     pi.skipOnPointerObservable = _this._shouldBlockPointer && pi.type !== BABYLON.PointerEventTypes.POINTERUP;

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 265 - 265
dist/preview release/inspector/babylon.inspector.bundle.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


+ 24 - 12
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -6,22 +6,25 @@ module BABYLON {
         private _webVRsupportedAndReady = false;
         private _canvas: HTMLCanvasElement;
         private _isInVRMode = false;
+        private _webVRCamera: WebVRFreeCamera;
+        private _vrDeviceOrientationCamera: VRDeviceOrientationFreeCamera;
+        private _deviceOrientationCamera: DeviceOrientationCamera;
         
         constructor(scene: Scene, private webVROptions: WebVROptions = {}) {
             this._scene = scene;
 
             if (!this._scene.activeCamera) {
-                this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", new BABYLON.Vector3(0, 2, 0), scene);
             }
             else {
-                var newCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
+                this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._scene.activeCamera.position, scene);
                 if ((<FreeCamera>scene.activeCamera).rotation) {
-                    newCamera.rotation = (<FreeCamera>scene.activeCamera).rotation.clone();
+                    this._deviceOrientationCamera.rotation = (<FreeCamera>scene.activeCamera).rotation.clone();
                 }
-                newCamera.minZ = this._scene.activeCamera.minZ;
-                newCamera.maxZ = this._scene.activeCamera.maxZ;
-                this._scene.activeCamera = newCamera;
+                this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
+                this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
             }
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._position = this._scene.activeCamera.position;
             this._canvas = scene.getEngine().getRenderingCanvas();
             this._scene.activeCamera.attachControl(this._canvas);
@@ -61,13 +64,14 @@ module BABYLON {
             if (navigator.getVRDisplays) {
                 navigator.getVRDisplays().then((headsets) => {
                     if (headsets.length > 0) {
-                        scene.getEngine().initWebVR();
+                        this._webVRCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene);
                         this._webVRsupportedAndReady = true;
                     }
                     document.body.appendChild(this._btnVR); 
                 });
             }
             else {
+                this._vrDeviceOrientationCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
                 document.body.appendChild(this._btnVR); 
             }
 
@@ -77,13 +81,14 @@ module BABYLON {
         }
 
         public enterVR() {
-            this._scene.activeCamera.dispose();
             // If WebVR is supported and a headset is connected
             if (this._webVRsupportedAndReady) {
-                this._scene.activeCamera = new BABYLON.WebVRFreeCamera("WebVRHelper", this._position, this._scene);
+                this._webVRCamera.position = this._position;
+                this._scene.activeCamera = this._webVRCamera;
             }
             else {
-                this._scene.activeCamera = new BABYLON.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper", this._position, this._scene);
+                this._vrDeviceOrientationCamera.position = this._position;
+                this._scene.activeCamera = this._vrDeviceOrientationCamera;
                 this._scene.getEngine().switchFullscreen(true); 
             }
             this._scene.activeCamera.attachControl(this._canvas);
@@ -97,9 +102,9 @@ module BABYLON {
             }
             if (this._scene.activeCamera) {
                 this._position = this._scene.activeCamera.position;
-                this._scene.activeCamera.dispose();
             }
-            this._scene.activeCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, this._scene); 
+            this._deviceOrientationCamera.position = this._position;
+            this._scene.activeCamera = this._deviceOrientationCamera;
             this._scene.activeCamera.attachControl(this._canvas);
             this._isInVRMode = false;
             this._btnVR.style.display = ""; 
@@ -118,6 +123,13 @@ module BABYLON {
             if (this._isInVRMode) {
                 this.exitVR();
             }
+            this._deviceOrientationCamera.dispose();
+            if (this._webVRCamera) {
+                this._webVRCamera.dispose();
+            }
+            if (this._vrDeviceOrientationCamera) {
+                this._vrDeviceOrientationCamera.dispose();
+            }
             document.body.removeChild(this._btnVR);
         }