Browse Source

Merge with master

David Catuhe 8 years ago
parent
commit
4258d1b06d

File diff suppressed because it is too large
+ 4795 - 4800
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 15 - 15
dist/preview release/babylon.js


+ 17 - 7
dist/preview release/babylon.max.js

@@ -47613,9 +47613,6 @@ var BABYLON;
             }
         }
         Gamepads.prototype.dispose = function () {
-            if (Gamepads.gamepadDOMInfo) {
-                document.body.removeChild(Gamepads.gamepadDOMInfo);
-            }
             if (this._onGamepadConnectedEvent) {
                 window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
                 window.removeEventListener('gamepaddisconnected', this._onGamepadDisonnectedEvent, false);
@@ -47632,10 +47629,6 @@ var BABYLON;
         Gamepads.prototype._addNewGamepad = function (gamepad) {
             if (!this.oneGamepadConnected) {
                 this.oneGamepadConnected = true;
-                if (Gamepads.gamepadDOMInfo) {
-                    document.body.removeChild(Gamepads.gamepadDOMInfo);
-                    Gamepads.gamepadDOMInfo = null;
-                }
             }
             var newGamepad;
             var xboxOne = (gamepad.id.search("Xbox One") !== -1);
@@ -62251,6 +62244,7 @@ var BABYLON;
             _this.devicePosition = BABYLON.Vector3.Zero();
             _this.deviceScaleFactor = 1;
             _this.controllers = [];
+            _this.nonVRControllers = [];
             _this.rigParenting = true; // should the rig cameras be used as parent instead of this camera.
             //legacy support - the compensation boolean was removed.
             if (arguments.length === 5) {
@@ -62339,6 +62333,16 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(WebVRFreeCamera.prototype, "onNonVRControllerAttached", {
+            set: function (callback) {
+                this._onNonVRControllerAttached = callback;
+                this.nonVRControllers.forEach(function (controller) {
+                    callback(controller);
+                });
+            },
+            enumerable: true,
+            configurable: true
+        });
         WebVRFreeCamera.prototype.getControllerByName = function (name) {
             for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
                 var gp = _a[_i];
@@ -62555,6 +62559,12 @@ var BABYLON;
                         }
                     }
                 }
+                else {
+                    _this.nonVRControllers.push(gp);
+                    if (_this._onNonVRControllerAttached) {
+                        _this._onNonVRControllerAttached(gp);
+                    }
+                }
             });
         };
         return WebVRFreeCamera;

File diff suppressed because it is too large
+ 4795 - 4800
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 15 - 15
dist/preview release/babylon.worker.js


File diff suppressed because it is too large
+ 8 - 14
readme.md


+ 15 - 0
src/Cameras/VR/babylon.webVRCamera.ts

@@ -61,7 +61,9 @@ module BABYLON {
         public deviceScaleFactor: number = 1;
 
         public controllers: Array<WebVRController> = [];
+        public nonVRControllers: Array<Gamepad> = [];
         private _onControllersAttached: (controllers: Array<WebVRController>) => void;
+        private _onNonVRControllerAttached: (controller: Gamepad) => void;
 
         public rigParenting: boolean = true; // should the rig cameras be used as parent instead of this camera.
 
@@ -166,6 +168,13 @@ module BABYLON {
             }
         }
 
+        public set onNonVRControllerAttached(callback: (controller: Gamepad) => void) {
+            this._onNonVRControllerAttached = callback;
+            this.nonVRControllers.forEach((controller) => {
+                callback(controller)
+            });
+        }
+
         public getControllerByName(name: string): WebVRController {
             for (var gp of this.controllers) {
                 if (gp.hand === name) {
@@ -407,6 +416,12 @@ module BABYLON {
                         }
                     }
                 }
+                else {
+                    this.nonVRControllers.push(gp);
+                    if (this._onNonVRControllerAttached) {
+                        this._onNonVRControllerAttached(gp);
+                    }
+                }
             });
         }
     }

+ 0 - 1
src/Tools/babylon.extendedGamepad.ts

@@ -1,4 +1,3 @@
-
 module BABYLON {
 
     export enum PoseEnabledControllerType {

+ 0 - 11
src/Tools/babylon.gamepads.ts

@@ -13,9 +13,6 @@
         private _onGamepadConnectedEvent: (evt) => void;
         private _onGamepadDisonnectedEvent: (evt: Event) => void;
 
-        private static gamepadDOMInfo: HTMLElement;
-
-
         constructor(ongamedpadconnected: (gamepad: T) => void) {
             this._callbackGamepadConnected = ongamedpadconnected;
             if (this.gamepadSupport) {
@@ -42,10 +39,6 @@
         }
 
         public dispose() {
-            if (Gamepads.gamepadDOMInfo) {
-                document.body.removeChild(Gamepads.gamepadDOMInfo);
-            }
-
             if (this._onGamepadConnectedEvent) {
                 window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
                 window.removeEventListener('gamepaddisconnected', this._onGamepadDisonnectedEvent, false);
@@ -63,10 +56,6 @@
         private _addNewGamepad(gamepad): T {
             if (!this.oneGamepadConnected) {
                 this.oneGamepadConnected = true;
-                if (Gamepads.gamepadDOMInfo) {
-                    document.body.removeChild(Gamepads.gamepadDOMInfo);
-                    Gamepads.gamepadDOMInfo = null;
-                }
             }
 
             var newGamepad;