1 /**
2 * @author mrdoob / http://mrdoob.com/
3 * @author greggman / http://games.greggman.com/
4 * @author zz85 / http://www.lab4games.net/zz85/blog
5 */
6
7 /**@constructor*/
8 THREE.PerspectiveCamera = function ( fov, aspect, near, far ) {
9
10 THREE.Camera.call( this );
11
12 this.fov = fov !== undefined ? fov : 50;
13 this.aspect = aspect !== undefined ? aspect : 1;
14 this.near = near !== undefined ? near : 0.1;
15 this.far = far !== undefined ? far : 2000;
16
17 this.updateProjectionMatrix();
18
19 };
20
21 THREE.PerspectiveCamera.prototype = Object.create( THREE.Camera.prototype );
22
23
24 /**
25 * Uses Focal Length (in mm) to estimate and set FOV
26 * 35mm (fullframe) camera is used if frame size is not specified;
27 * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
28 */
29
30 THREE.PerspectiveCamera.prototype.setLens = function ( focalLength, frameHeight ) {
31
32 if ( frameHeight === undefined ) frameHeight = 24;
33
34 this.fov = 2 * Math.atan( frameHeight / ( focalLength * 2 ) ) * ( 180 / Math.PI );
35 this.updateProjectionMatrix();
36
37 }
38
39
40 /**
41 * Sets an offset in a larger frustum. This is useful for multi-window or
42 * multi-monitor/multi-machine setups.
43 *
44 * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
45 * the monitors are in grid like this
46 *
47 * +---+---+---+
48 * | A | B | C |
49 * +---+---+---+
50 * | D | E | F |
51 * +---+---+---+
52 *
53 * then for each monitor you would call it like this
54 *
55 * var w = 1920;
56 * var h = 1080;
57 * var fullWidth = w * 3;
58 * var fullHeight = h * 2;
59 *
60 * --A--
61 * camera.setOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
62 * --B--
63 * camera.setOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
64 * --C--
65 * camera.setOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
66 * --D--
67 * camera.setOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
68 * --E--
69 * camera.setOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
70 * --F--
71 * camera.setOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
72 *
73 * Note there is no reason monitors have to be the same size or in a grid.
74 */
75
76 THREE.PerspectiveCamera.prototype.setViewOffset = function ( fullWidth, fullHeight, x, y, width, height ) {
77
78 this.fullWidth = fullWidth;
79 this.fullHeight = fullHeight;
80 this.x = x;
81 this.y = y;
82 this.width = width;
83 this.height = height;
84
85 this.updateProjectionMatrix();
86
87 };
88
89
90 THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function () {
91
92 if ( this.fullWidth ) {
93
94 var aspect = this.fullWidth / this.fullHeight;
95 var top = Math.tan( this.fov * Math.PI / 360 ) * this.near;
96 var bottom = -top;
97 var left = aspect * bottom;
98 var right = aspect * top;
99 var width = Math.abs( right - left );
100 var height = Math.abs( top - bottom );
101
102 this.projectionMatrix.makeFrustum(
103 left + this.x * width / this.fullWidth,
104 left + ( this.x + this.width ) * width / this.fullWidth,
105 top - ( this.y + this.height ) * height / this.fullHeight,
106 top - this.y * height / this.fullHeight,
107 this.near,
108 this.far
109 );
110
111 } else {
112
113 this.projectionMatrix.makePerspective( this.fov, this.aspect, this.near, this.far );
114
115 }
116
117 };
118
nike free rn
new balance hombre baratas
cinturones gucci
ugg rebajas
cinturon gucci
ray ban baratas
nike cortez
peuterey mujer
christian louboutin madrid
mbt zapatos
gafas ray ban baratas
mbt ofertas
air max blancas
mbt barcelona
nike air max 90
woolrich barcelona
nike mujer
botas ugg
gafas de sol carrera aratas
air max 2016 baratas
oakley baratas
nike air max 2016