|
@@ -1,27 +1,81 @@
|
|
|
module BABYLON {
|
|
|
+ /**
|
|
|
+ * This represents all the required metrics to create a VR camera.
|
|
|
+ * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
|
|
|
+ */
|
|
|
export class VRCameraMetrics {
|
|
|
+ /**
|
|
|
+ * Define the horizontal resolution off the screen.
|
|
|
+ */
|
|
|
public hResolution: number;
|
|
|
+ /**
|
|
|
+ * Define the vertical resolution off the screen.
|
|
|
+ */
|
|
|
public vResolution: number;
|
|
|
+ /**
|
|
|
+ * Define the horizontal screen size.
|
|
|
+ */
|
|
|
public hScreenSize: number;
|
|
|
+ /**
|
|
|
+ * Define the vertical screen size.
|
|
|
+ */
|
|
|
public vScreenSize: number;
|
|
|
+ /**
|
|
|
+ * Define the vertical screen center position.
|
|
|
+ */
|
|
|
public vScreenCenter: number;
|
|
|
+ /**
|
|
|
+ * Define the distance of the eyes to the screen.
|
|
|
+ */
|
|
|
public eyeToScreenDistance: number;
|
|
|
+ /**
|
|
|
+ * Define the distance between both lenses
|
|
|
+ */
|
|
|
public lensSeparationDistance: number;
|
|
|
+ /**
|
|
|
+ * Define the distance between both viewer's eyes.
|
|
|
+ */
|
|
|
public interpupillaryDistance: number;
|
|
|
+ /**
|
|
|
+ * Define the distortion factor of the VR postprocess.
|
|
|
+ * Please, touch with care.
|
|
|
+ */
|
|
|
public distortionK: number[];
|
|
|
+ /**
|
|
|
+ * Define the chromatic aberration correction factors for the VR post process.
|
|
|
+ */
|
|
|
public chromaAbCorrection: number[];
|
|
|
+ /**
|
|
|
+ * Define the scale factor of the post process.
|
|
|
+ * The smaller the better but the slower.
|
|
|
+ */
|
|
|
public postProcessScaleFactor: number;
|
|
|
+ /**
|
|
|
+ * Define an offset for the lens center.
|
|
|
+ */
|
|
|
public lensCenterOffset: number;
|
|
|
+ /**
|
|
|
+ * Define if the current vr camera should compensate the distortion of the lense or not.
|
|
|
+ */
|
|
|
public compensateDistortion = true;
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the rendering aspect ratio based on the provided resolutions.
|
|
|
+ */
|
|
|
public get aspectRatio(): number {
|
|
|
return this.hResolution / (2 * this.vResolution);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
|
|
|
+ */
|
|
|
public get aspectRatioFov(): number {
|
|
|
return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
public get leftHMatrix(): Matrix {
|
|
|
var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
|
|
|
var h = (4 * meters) / this.hScreenSize;
|
|
@@ -29,6 +83,9 @@
|
|
|
return Matrix.Translation(h, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
public get rightHMatrix(): Matrix {
|
|
|
var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
|
|
|
var h = (4 * meters) / this.hScreenSize;
|
|
@@ -36,14 +93,24 @@
|
|
|
return Matrix.Translation(-h, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
public get leftPreViewMatrix(): Matrix {
|
|
|
return Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @hidden
|
|
|
+ */
|
|
|
public get rightPreViewMatrix(): Matrix {
|
|
|
return Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the default VRMetrics based on the most generic setup.
|
|
|
+ * @returns the default vr metrics
|
|
|
+ */
|
|
|
public static GetDefault(): VRCameraMetrics {
|
|
|
var result = new VRCameraMetrics();
|
|
|
|