Explorar o código

Have initial created camera oriented like the previous camera

Trevor Baron %!s(int64=7) %!d(string=hai) anos
pai
achega
01f53c9fbb
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 11 - 0
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -113,6 +113,17 @@ module BABYLON {
                 this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
                 this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                 this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
+                // Set rotation from previous camera
+                if(this._scene.activeCamera instanceof TargetCamera){
+                    var targetCamera = this._scene.activeCamera;
+                    if(targetCamera.rotationQuaternion && targetCamera.rotation){
+                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
+                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
+                    }else if(targetCamera.rotation){
+                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(Quaternion.RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
+                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
+                    }
+                }
             }
             this._scene.activeCamera = this._deviceOrientationCamera;
             this._canvas = scene.getEngine().getRenderingCanvas();