浏览代码

calling orientationChanged on attachControl.

When attachControl is called after the device changed its orientation,
the rotation is wrong.
This solve the issue.
Raanan Weber 9 年之前
父节点
当前提交
f20318835e
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.ts

+ 3 - 0
src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.ts

@@ -28,6 +28,9 @@ module BABYLON {
         attachControl(element: HTMLElement, noPreventDefault?: boolean) {
             window.addEventListener("orientationchange", this._orientationChanged);
             window.addEventListener("deviceorientation", this._deviceOrientation);
+            //In certain cases, the attach control is called AFTER orientation was changed,
+            //So this is needed.
+            this._orientationChanged();
         }
 
         private _orientationChanged = () => {