提交 b380dd45 编写于 作者: G Gregg Tavares

Added setViewOffset to Camera for multi-monitor displays.

Examples in another commit
上级 3bc83727
......@@ -41,7 +41,77 @@ THREE.Camera.prototype.translate = function ( distance, axis ) {
THREE.Camera.prototype.updateProjectionMatrix = function () {
this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
if ( this.fullWidth ) {
var aspect = this.fullWidth / this.fullHeight;
var top = Math.tan(this.fov * Math.PI / 360) * this.near;
var bottom = -top;
var left = aspect * bottom;
var right = aspect * top;
var width = Math.abs(right - left);
var height = Math.abs(top - bottom);
this.projectionMatrix = THREE.Matrix4.makeFrustum(
left + this.x * width / this.fullWidth,
left + (this.x + this.width) * width / this.fullWidth,
top - (this.y + this.height) * height / this.fullHeight,
top - this.y * height / this.fullHeight,
this.near,
this.far);
} else {
this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
}
};
/**
* Sets an offset in a larger frustum. This is useful for multi-window or
* multi-monitor/multi-machine setups.
*
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and
* the monitors are in grid like this
*
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
*
* then for monitor each monitor you would call it like this
*
* var w = 1920;
* var h = 1080;
* var fullWidth = w * 3;
* var fullHeight = h * 2;
*
* --A--
* camera.setOffset(fullWidth, fullHeight, w * 0, h * 0, w, h);
* --B--
* camera.setOffset(fullWidth, fullHeight, w * 1, h * 0, w, h);
* --C--
* camera.setOffset(fullWidth, fullHeight, w * 2, h * 0, w, h);
* --D--
* camera.setOffset(fullWidth, fullHeight, w * 0, h * 1, w, h);
* --E--
* camera.setOffset(fullWidth, fullHeight, w * 1, h * 1, w, h);
* --F--
* camera.setOffset(fullWidth, fullHeight, w * 2, h * 1, w, h);
*
* Note there is no reason monitors have to be the same size or in a grid.
*/
THREE.Camera.prototype.setViewOffset = function( fullWidth, fullHeight, x, y, width, height ) {
this.fullWidth = fullWidth;
this.fullHeight = fullHeight;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.updateProjectionMatrix();
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册