瀏覽代碼

Merge pull request #288 from demonixis/master

Fixed WebVRCamera to detect the device
deltakosh 11 年之前
父節點
當前提交
b634a52473
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 3 2
      Babylon/Cameras/babylon.webVRCamera.js
  2. 2 3
      Babylon/Cameras/babylon.webVRCamera.ts

+ 3 - 2
Babylon/Cameras/babylon.webVRCamera.js

@@ -26,7 +26,8 @@ var BABYLON;
             this._sensorDevice = null;
             this._hmdDevice = null;
 
-            while (i > 0 && this._hmdDevice === null) {
+            // Search for a HmdDevice.
+            while (i < size && this._hmdDevice === null) { 
                 if (devices[i] instanceof HMDVRDevice) {
                     this._hmdDevice = devices[i];
                 }
@@ -35,7 +36,7 @@ var BABYLON;
 
             i = 0;
 
-            while (i > 0 && this._sensorDevice === null) {
+            while (i < size && this._sensorDevice === null) {
                 if (devices[i] instanceof PositionSensorVRDevice && (!this._hmdDevice || devices[i].hardwareUnitId === this._hmdDevice.hardwareUnitId)) {
                     this._sensorDevice = devices[i];
                 }

+ 2 - 3
Babylon/Cameras/babylon.webVRCamera.ts

@@ -24,7 +24,7 @@ module BABYLON {
             this._hmdDevice = null;
 
             // Search for a HmdDevice.
-            while (i > 0 && this._hmdDevice === null) {
+            while (i < size && this._hmdDevice === null) { 
                 if (devices[i] instanceof HMDVRDevice) {
                     this._hmdDevice = devices[i];
                 }
@@ -33,8 +33,7 @@ module BABYLON {
 
             i = 0;
 
-            // Search for a PositionSensorVRDevice
-            while (i > 0 && this._sensorDevice === null) {
+            while (i < size && this._sensorDevice === null) {
                 if (devices[i] instanceof PositionSensorVRDevice && (!this._hmdDevice || devices[i].hardwareUnitId === this._hmdDevice.hardwareUnitId)) {
                     this._sensorDevice = devices[i];
                 }