|
@@ -1,4 +1,4 @@
|
|
-var __extends = this.__extends || function (d, b) {
|
|
|
|
|
|
+var __extends = (this && this.__extends) || function (d, b) {
|
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
function __() { this.constructor = d; }
|
|
function __() { this.constructor = d; }
|
|
__.prototype = b.prototype;
|
|
__.prototype = b.prototype;
|
|
@@ -6,6 +6,75 @@ var __extends = this.__extends || function (d, b) {
|
|
};
|
|
};
|
|
var BABYLON;
|
|
var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
|
|
+ var VRCameraMetrics = (function () {
|
|
|
|
+ function VRCameraMetrics() {
|
|
|
|
+ this.compensateDistorsion = true;
|
|
|
|
+ }
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return this.hResolution / (2 * this.vResolution);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
|
|
|
|
+ get: function () {
|
|
|
|
+ var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
|
|
|
|
+ var h = (4 * meters) / this.hScreenSize;
|
|
|
|
+ return BABYLON.Matrix.Translation(h, 0, 0);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
|
|
|
|
+ get: function () {
|
|
|
|
+ var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
|
|
|
|
+ var h = (4 * meters) / this.hScreenSize;
|
|
|
|
+ return BABYLON.Matrix.Translation(-h, 0, 0);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return BABYLON.Matrix.Translation(0.5 * this.interpupillaryDistance, 0, 0);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return BABYLON.Matrix.Translation(-0.5 * this.interpupillaryDistance, 0, 0);
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ VRCameraMetrics.GetDefault = function () {
|
|
|
|
+ var result = new VRCameraMetrics();
|
|
|
|
+ result.hResolution = 1280;
|
|
|
|
+ result.vResolution = 800;
|
|
|
|
+ result.hScreenSize = 0.149759993;
|
|
|
|
+ result.vScreenSize = 0.0935999975;
|
|
|
|
+ result.vScreenCenter = 0.0467999987,
|
|
|
|
+ result.eyeToScreenDistance = 0.0410000011;
|
|
|
|
+ result.lensSeparationDistance = 0.0635000020;
|
|
|
|
+ result.interpupillaryDistance = 0.0640000030;
|
|
|
|
+ result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
|
|
|
|
+ result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
|
|
|
|
+ result.postProcessScaleFactor = 1.714605507808412;
|
|
|
|
+ result.lensCenterOffset = 0.151976421;
|
|
|
|
+ return result;
|
|
|
|
+ };
|
|
|
|
+ return VRCameraMetrics;
|
|
|
|
+ })();
|
|
|
|
+ BABYLON.VRCameraMetrics = VRCameraMetrics;
|
|
var Camera = (function (_super) {
|
|
var Camera = (function (_super) {
|
|
__extends(Camera, _super);
|
|
__extends(Camera, _super);
|
|
function Camera(name, position, scene) {
|
|
function Camera(name, position, scene) {
|
|
@@ -24,9 +93,12 @@ var BABYLON;
|
|
this.mode = Camera.PERSPECTIVE_CAMERA;
|
|
this.mode = Camera.PERSPECTIVE_CAMERA;
|
|
this.isIntermediate = false;
|
|
this.isIntermediate = false;
|
|
this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
|
|
this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
|
|
- this.subCameras = [];
|
|
|
|
- this.layerMask = 0xFFFFFFFF;
|
|
|
|
|
|
+ this.layerMask = 0x0FFFFFFF;
|
|
this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
|
|
this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
|
|
|
|
+ // Camera rig members
|
|
|
|
+ this.cameraRigMode = Camera.RIG_MODE_NONE;
|
|
|
|
+ this._rigCameras = new Array();
|
|
|
|
+ // Cache
|
|
this._computedViewMatrix = BABYLON.Matrix.Identity();
|
|
this._computedViewMatrix = BABYLON.Matrix.Identity();
|
|
this._projectionMatrix = new BABYLON.Matrix();
|
|
this._projectionMatrix = new BABYLON.Matrix();
|
|
this._postProcesses = new Array();
|
|
this._postProcesses = new Array();
|
|
@@ -66,6 +138,48 @@ var BABYLON;
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
});
|
|
});
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_NONE", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_NONE;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_STEREOSCOPIC_ANAGLYPH", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_STEREOSCOPIC_ANAGLYPH;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_STEREOSCOPIC_OVERUNDER", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_STEREOSCOPIC_OVERUNDER;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ Object.defineProperty(Camera, "RIG_MODE_VR", {
|
|
|
|
+ get: function () {
|
|
|
|
+ return Camera._RIG_MODE_VR;
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
Object.defineProperty(Camera.prototype, "globalPosition", {
|
|
Object.defineProperty(Camera.prototype, "globalPosition", {
|
|
get: function () {
|
|
get: function () {
|
|
return this._globalPosition;
|
|
return this._globalPosition;
|
|
@@ -126,19 +240,29 @@ var BABYLON;
|
|
Camera.prototype._isSynchronizedViewMatrix = function () {
|
|
Camera.prototype._isSynchronizedViewMatrix = function () {
|
|
if (!_super.prototype._isSynchronized.call(this))
|
|
if (!_super.prototype._isSynchronized.call(this))
|
|
return false;
|
|
return false;
|
|
- return this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent();
|
|
|
|
|
|
+ return this._cache.position.equals(this.position)
|
|
|
|
+ && this._cache.upVector.equals(this.upVector)
|
|
|
|
+ && this.isSynchronizedWithParent();
|
|
};
|
|
};
|
|
Camera.prototype._isSynchronizedProjectionMatrix = function () {
|
|
Camera.prototype._isSynchronizedProjectionMatrix = function () {
|
|
- var check = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
|
|
|
|
|
|
+ var check = this._cache.mode === this.mode
|
|
|
|
+ && this._cache.minZ === this.minZ
|
|
|
|
+ && this._cache.maxZ === this.maxZ;
|
|
if (!check) {
|
|
if (!check) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
var engine = this.getEngine();
|
|
var engine = this.getEngine();
|
|
if (this.mode === Camera.PERSPECTIVE_CAMERA) {
|
|
if (this.mode === Camera.PERSPECTIVE_CAMERA) {
|
|
- check = this._cache.fov === this.fov && this._cache.aspectRatio === engine.getAspectRatio(this);
|
|
|
|
|
|
+ check = this._cache.fov === this.fov
|
|
|
|
+ && this._cache.aspectRatio === engine.getAspectRatio(this);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- check = this._cache.orthoLeft === this.orthoLeft && this._cache.orthoRight === this.orthoRight && this._cache.orthoBottom === this.orthoBottom && this._cache.orthoTop === this.orthoTop && this._cache.renderWidth === engine.getRenderWidth() && this._cache.renderHeight === engine.getRenderHeight();
|
|
|
|
|
|
+ check = this._cache.orthoLeft === this.orthoLeft
|
|
|
|
+ && this._cache.orthoRight === this.orthoRight
|
|
|
|
+ && this._cache.orthoBottom === this.orthoBottom
|
|
|
|
+ && this._cache.orthoTop === this.orthoTop
|
|
|
|
+ && this._cache.renderWidth === engine.getRenderWidth()
|
|
|
|
+ && this._cache.renderHeight === engine.getRenderHeight();
|
|
}
|
|
}
|
|
return check;
|
|
return check;
|
|
};
|
|
};
|
|
@@ -148,6 +272,12 @@ var BABYLON;
|
|
Camera.prototype.detachControl = function (element) {
|
|
Camera.prototype.detachControl = function (element) {
|
|
};
|
|
};
|
|
Camera.prototype._update = function () {
|
|
Camera.prototype._update = function () {
|
|
|
|
+ this._checkInputs();
|
|
|
|
+ if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
|
|
|
|
+ this._updateRigCameras();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ Camera.prototype._checkInputs = function () {
|
|
};
|
|
};
|
|
Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
|
|
Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
|
|
if (insertAt === void 0) { insertAt = null; }
|
|
if (insertAt === void 0) { insertAt = null; }
|
|
@@ -226,20 +356,25 @@ var BABYLON;
|
|
Camera.prototype._getViewMatrix = function () {
|
|
Camera.prototype._getViewMatrix = function () {
|
|
return BABYLON.Matrix.Identity();
|
|
return BABYLON.Matrix.Identity();
|
|
};
|
|
};
|
|
- Camera.prototype.getViewMatrix = function () {
|
|
|
|
- this._computedViewMatrix = this._computeViewMatrix();
|
|
|
|
- if (!this.parent || !this.parent.getWorldMatrix || this.isSynchronized()) {
|
|
|
|
- this._globalPosition.copyFrom(this.position);
|
|
|
|
|
|
+ Camera.prototype.getViewMatrix = function (force) {
|
|
|
|
+ this._computedViewMatrix = this._computeViewMatrix(force);
|
|
|
|
+ if (!force && this._isSynchronizedViewMatrix()) {
|
|
return this._computedViewMatrix;
|
|
return this._computedViewMatrix;
|
|
}
|
|
}
|
|
- if (!this._worldMatrix) {
|
|
|
|
- this._worldMatrix = BABYLON.Matrix.Identity();
|
|
|
|
|
|
+ if (!this.parent || !this.parent.getWorldMatrix) {
|
|
|
|
+ this._globalPosition.copyFrom(this.position);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ if (!this._worldMatrix) {
|
|
|
|
+ this._worldMatrix = BABYLON.Matrix.Identity();
|
|
|
|
+ }
|
|
|
|
+ this._computedViewMatrix.invertToRef(this._worldMatrix);
|
|
|
|
+ this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix);
|
|
|
|
+ this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12], this._computedViewMatrix.m[13], this._computedViewMatrix.m[14]);
|
|
|
|
+ this._computedViewMatrix.invert();
|
|
|
|
+ this._markSyncedWithParent();
|
|
}
|
|
}
|
|
- this._computedViewMatrix.invertToRef(this._worldMatrix);
|
|
|
|
- this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix);
|
|
|
|
- this._computedViewMatrix.invert();
|
|
|
|
this._currentRenderId = this.getScene().getRenderId();
|
|
this._currentRenderId = this.getScene().getRenderId();
|
|
- this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12], this._computedViewMatrix.m[13], this._computedViewMatrix.m[14]);
|
|
|
|
return this._computedViewMatrix;
|
|
return this._computedViewMatrix;
|
|
};
|
|
};
|
|
Camera.prototype._computeViewMatrix = function (force) {
|
|
Camera.prototype._computeViewMatrix = function (force) {
|
|
@@ -247,9 +382,7 @@ var BABYLON;
|
|
return this._computedViewMatrix;
|
|
return this._computedViewMatrix;
|
|
}
|
|
}
|
|
this._computedViewMatrix = this._getViewMatrix();
|
|
this._computedViewMatrix = this._getViewMatrix();
|
|
- if (!this.parent || !this.parent.getWorldMatrix) {
|
|
|
|
- this._currentRenderId = this.getScene().getRenderId();
|
|
|
|
- }
|
|
|
|
|
|
+ this._currentRenderId = this.getScene().getRenderId();
|
|
return this._computedViewMatrix;
|
|
return this._computedViewMatrix;
|
|
};
|
|
};
|
|
Camera.prototype.getProjectionMatrix = function (force) {
|
|
Camera.prototype.getProjectionMatrix = function (force) {
|
|
@@ -272,15 +405,123 @@ var BABYLON;
|
|
Camera.prototype.dispose = function () {
|
|
Camera.prototype.dispose = function () {
|
|
// Remove from scene
|
|
// Remove from scene
|
|
this.getScene().removeCamera(this);
|
|
this.getScene().removeCamera(this);
|
|
|
|
+ while (this._rigCameras.length > 0) {
|
|
|
|
+ this._rigCameras.pop().dispose();
|
|
|
|
+ }
|
|
|
|
+ // Postprocesses
|
|
for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
|
|
for (var i = 0; i < this._postProcessesTakenIndices.length; ++i) {
|
|
this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
|
|
this._postProcesses[this._postProcessesTakenIndices[i]].dispose(this);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+ // ---- Camera rigs section ----
|
|
|
|
+ Camera.prototype.setCameraRigMode = function (mode, rigParams) {
|
|
|
|
+ while (this._rigCameras.length > 0) {
|
|
|
|
+ this._rigCameras.pop().dispose();
|
|
|
|
+ }
|
|
|
|
+ this.cameraRigMode = mode;
|
|
|
|
+ this._cameraRigParams = {};
|
|
|
|
+ switch (this.cameraRigMode) {
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
|
|
|
|
+ this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
|
|
|
|
+ //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
|
|
|
|
+ //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
|
|
|
|
+ this._cameraRigParams.stereoHalfAngle = BABYLON.Tools.ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
|
|
|
|
+ this._rigCameras.push(this.createRigCamera(this.name + "_L", 0));
|
|
|
|
+ this._rigCameras.push(this.createRigCamera(this.name + "_R", 1));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ var postProcesses = new Array();
|
|
|
|
+ switch (this.cameraRigMode) {
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
|
|
|
|
+ postProcesses.push(new BABYLON.PassPostProcess(this.name + "_passthru", 1.0, this._rigCameras[0]));
|
|
|
|
+ this._rigCameras[0].isIntermediate = true;
|
|
|
|
+ postProcesses.push(new BABYLON.AnaglyphPostProcess(this.name + "_anaglyph", 1.0, this._rigCameras[1]));
|
|
|
|
+ postProcesses[1].onApply = function (effect) {
|
|
|
|
+ effect.setTextureFromPostProcess("leftSampler", postProcesses[0]);
|
|
|
|
+ };
|
|
|
|
+ break;
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
|
|
|
|
+ case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
|
|
|
|
+ var isStereoscopicHoriz = (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL || this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED);
|
|
|
|
+ var firstCamIndex = (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : 0;
|
|
|
|
+ var secondCamIndex = 1 - firstCamIndex;
|
|
|
|
+ postProcesses.push(new BABYLON.PassPostProcess(this.name + "_passthru", 1.0, this._rigCameras[firstCamIndex]));
|
|
|
|
+ this._rigCameras[firstCamIndex].isIntermediate = true;
|
|
|
|
+ postProcesses.push(new BABYLON.StereoscopicInterlacePostProcess(this.name + "_stereoInterlace", this._rigCameras[secondCamIndex], postProcesses[0], isStereoscopicHoriz));
|
|
|
|
+ break;
|
|
|
|
+ case Camera.RIG_MODE_VR:
|
|
|
|
+ this._rigCameras.push(this.createRigCamera(this.name + "_L", 0));
|
|
|
|
+ this._rigCameras.push(this.createRigCamera(this.name + "_R", 1));
|
|
|
|
+ var metrics = rigParams.vrCameraMetrics || VRCameraMetrics.GetDefault();
|
|
|
|
+ this._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
|
|
|
|
+ this._rigCameras[0].viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
|
|
|
|
+ this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new BABYLON.Matrix();
|
|
|
|
+ this._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
|
|
|
|
+ this._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
|
|
|
|
+ this._rigCameras[0].getProjectionMatrix = this._rigCameras[0]._getVRProjectionMatrix;
|
|
|
|
+ if (metrics.compensateDistorsion) {
|
|
|
|
+ postProcesses.push(new BABYLON.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left", this._rigCameras[0], false, metrics));
|
|
|
|
+ }
|
|
|
|
+ this._rigCameras[1]._cameraRigParams.vrMetrics = this._rigCameras[0]._cameraRigParams.vrMetrics;
|
|
|
|
+ this._rigCameras[1].viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
|
|
|
|
+ this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new BABYLON.Matrix();
|
|
|
|
+ this._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
|
|
|
|
+ this._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
|
|
|
|
+ this._rigCameras[1].getProjectionMatrix = this._rigCameras[1]._getVRProjectionMatrix;
|
|
|
|
+ if (metrics.compensateDistorsion) {
|
|
|
|
+ postProcesses.push(new BABYLON.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right", this._rigCameras[1], true, metrics));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ this._update();
|
|
|
|
+ };
|
|
|
|
+ Camera.prototype._getVRProjectionMatrix = function () {
|
|
|
|
+ BABYLON.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
|
|
|
|
+ this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
|
|
|
|
+ return this._projectionMatrix;
|
|
|
|
+ };
|
|
|
|
+ Camera.prototype.setCameraRigParameter = function (name, value) {
|
|
|
|
+ this._cameraRigParams[name] = value;
|
|
|
|
+ //provisionnally:
|
|
|
|
+ if (name === "interaxialDistance") {
|
|
|
|
+ this._cameraRigParams.stereoHalfAngle = BABYLON.Tools.ToRadians(value / 0.0637);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * May needs to be overridden by children so sub has required properties to be copied
|
|
|
|
+ */
|
|
|
|
+ Camera.prototype.createRigCamera = function (name, cameraIndex) {
|
|
|
|
+ return null;
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * May needs to be overridden by children
|
|
|
|
+ */
|
|
|
|
+ Camera.prototype._updateRigCameras = function () {
|
|
|
|
+ for (var i = 0; i < this._rigCameras.length; i++) {
|
|
|
|
+ this._rigCameras[i].minZ = this.minZ;
|
|
|
|
+ this._rigCameras[i].maxZ = this.maxZ;
|
|
|
|
+ this._rigCameras[i].fov = this.fov;
|
|
|
|
+ }
|
|
|
|
+ // only update viewport when ANAGLYPH
|
|
|
|
+ if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
|
|
|
|
+ this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
// Statics
|
|
// Statics
|
|
Camera._PERSPECTIVE_CAMERA = 0;
|
|
Camera._PERSPECTIVE_CAMERA = 0;
|
|
Camera._ORTHOGRAPHIC_CAMERA = 1;
|
|
Camera._ORTHOGRAPHIC_CAMERA = 1;
|
|
Camera._FOVMODE_VERTICAL_FIXED = 0;
|
|
Camera._FOVMODE_VERTICAL_FIXED = 0;
|
|
Camera._FOVMODE_HORIZONTAL_FIXED = 1;
|
|
Camera._FOVMODE_HORIZONTAL_FIXED = 1;
|
|
|
|
+ Camera._RIG_MODE_NONE = 0;
|
|
|
|
+ Camera._RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
|
|
|
|
+ Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
|
|
|
|
+ Camera._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
|
|
|
|
+ Camera._RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
|
|
|
|
+ Camera._RIG_MODE_VR = 20;
|
|
return Camera;
|
|
return Camera;
|
|
})(BABYLON.Node);
|
|
})(BABYLON.Node);
|
|
BABYLON.Camera = Camera;
|
|
BABYLON.Camera = Camera;
|