|
@@ -55,6 +55,8 @@ module BABYLON {
|
|
public deviceRotationQuaternion = new Quaternion();
|
|
public deviceRotationQuaternion = new Quaternion();
|
|
public deviceScaleFactor: number = 1;
|
|
public deviceScaleFactor: number = 1;
|
|
|
|
|
|
|
|
+ public controllers: Array<WebVRController> = [];
|
|
|
|
+
|
|
constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = false, private webVROptions: WebVROptions = {}) {
|
|
constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = false, private webVROptions: WebVROptions = {}) {
|
|
super(name, position, scene);
|
|
super(name, position, scene);
|
|
|
|
|
|
@@ -159,6 +161,9 @@ module BABYLON {
|
|
if (this._vrEnabled) {
|
|
if (this._vrEnabled) {
|
|
this.getEngine().enableVR(this._vrDevice)
|
|
this.getEngine().enableVR(this._vrDevice)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // try to attach the controllers, if found.
|
|
|
|
+ this.initControllers();
|
|
}
|
|
}
|
|
|
|
|
|
public detachControl(element: HTMLElement): void {
|
|
public detachControl(element: HTMLElement): void {
|
|
@@ -254,6 +259,17 @@ module BABYLON {
|
|
Matrix.FromArrayToRef(projectionArray, 0, this._projectionMatrix);
|
|
Matrix.FromArrayToRef(projectionArray, 0, this._projectionMatrix);
|
|
return this._projectionMatrix;
|
|
return this._projectionMatrix;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public initControllers() {
|
|
|
|
+ this.controllers = [];
|
|
|
|
+ new BABYLON.Gamepads((gp) => {
|
|
|
|
+ if (gp.type === BABYLON.Gamepad.POSE_ENABLED) {
|
|
|
|
+ let webVrController: WebVRController = <WebVRController>gp;
|
|
|
|
+ webVrController.attachToPoseControlledCamera(this);
|
|
|
|
+ this.controllers.push(webVrController);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
export class WebVRGamepadCamera extends WebVRFreeCamera {
|
|
export class WebVRGamepadCamera extends WebVRFreeCamera {
|