1 /*
  2  *	@author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
  3  *
  4  *	A general perpose camera, for setting FOV, Lens Focal Length,
  5  *		and switching between perspective and orthographic views easily.
  6  *		Use this only if you do not wish to manage
  7  *		both a Orthographic and Perspective Camera
  8  *
  9  */
 10 
 11 
 12 /**@constructor*/
 13 THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orthoFar ) {
 14 
 15 	THREE.Camera.call( this );
 16 
 17 	this.fov = fov;
 18 
 19 	this.left = -width / 2;
 20 	this.right = width / 2
 21 	this.top = height / 2;
 22 	this.bottom = -height / 2;
 23 
 24 	// We could also handle the projectionMatrix internally, but just wanted to test nested camera objects
 25 
 26 	this.cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 	orthoNear, orthoFar );
 27 	this.cameraP = new THREE.PerspectiveCamera( fov, width / height, near, far );
 28 
 29 	this.zoom = 1;
 30 
 31 	this.toPerspective();
 32 
 33 	var aspect = width/height;
 34 
 35 };
 36 
 37 THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
 38 
 39 THREE.CombinedCamera.prototype.toPerspective = function () {
 40 
 41 	// Switches to the Perspective Camera
 42 
 43 	this.near = this.cameraP.near;
 44 	this.far = this.cameraP.far;
 45 
 46 	this.cameraP.fov =  this.fov / this.zoom ;
 47 
 48 	this.cameraP.updateProjectionMatrix();
 49 
 50 	this.projectionMatrix = this.cameraP.projectionMatrix;
 51 
 52 	this.inPerspectiveMode = true;
 53 	this.inOrthographicMode = false;
 54 
 55 };
 56 
 57 THREE.CombinedCamera.prototype.toOrthographic = function () {
 58 
 59 	// Switches to the Orthographic camera estimating viewport from Perspective
 60 
 61 	var fov = this.fov;
 62 	var aspect = this.cameraP.aspect;
 63 	var near = this.cameraP.near;
 64 	var far = this.cameraP.far;
 65 
 66 	// The size that we set is the mid plane of the viewing frustum
 67 
 68 	var hyperfocus = ( near + far ) / 2;
 69 
 70 	var halfHeight = Math.tan( fov / 2 ) * hyperfocus;
 71 	var planeHeight = 2 * halfHeight;
 72 	var planeWidth = planeHeight * aspect;
 73 	var halfWidth = planeWidth / 2;
 74 
 75 	halfHeight /= this.zoom;
 76 	halfWidth /= this.zoom;
 77 
 78 	this.cameraO.left = -halfWidth;
 79 	this.cameraO.right = halfWidth;
 80 	this.cameraO.top = halfHeight;
 81 	this.cameraO.bottom = -halfHeight;
 82 
 83 	// this.cameraO.left = -farHalfWidth;
 84 	// this.cameraO.right = farHalfWidth;
 85 	// this.cameraO.top = farHalfHeight;
 86 	// this.cameraO.bottom = -farHalfHeight;
 87 
 88 	// this.cameraO.left = this.left / this.zoom;
 89 	// this.cameraO.right = this.right / this.zoom;
 90 	// this.cameraO.top = this.top / this.zoom;
 91 	// this.cameraO.bottom = this.bottom / this.zoom;
 92 
 93 	this.cameraO.updateProjectionMatrix();
 94 
 95 	this.near = this.cameraO.near;
 96 	this.far = this.cameraO.far;
 97 	this.projectionMatrix = this.cameraO.projectionMatrix;
 98 
 99 	this.inPerspectiveMode = false;
100 	this.inOrthographicMode = true;
101 
102 };
103 
104 
105 THREE.CombinedCamera.prototype.setSize = function( width, height ) {
106 
107 	this.cameraP.aspect = width / height;
108 	this.left = -width / 2;
109 	this.right = width / 2
110 	this.top = height / 2;
111 	this.bottom = -height / 2;
112 
113 };
114 
115 
116 THREE.CombinedCamera.prototype.setFov = function( fov ) {
117 
118 	this.fov = fov;
119 
120 	if ( this.inPerspectiveMode ) {
121 
122 		this.toPerspective();
123 
124 	} else {
125 
126 		this.toOrthographic();
127 
128 	}
129 
130 };
131 
132 // For mantaining similar API with PerspectiveCamera
133 
134 THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {
135 
136 	if ( this.inPerspectiveMode ) {
137 
138 		this.toPerspective();
139 
140 	} else {
141 
142 		this.toPerspective();
143 		this.toOrthographic();
144 
145 	}
146 
147 };
148 
149 /*
150 * Uses Focal Length (in mm) to estimate and set FOV
151 * 35mm (fullframe) camera is used if frame size is not specified;
152 * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
153 */
154 THREE.CombinedCamera.prototype.setLens = function ( focalLength, frameHeight ) {
155 
156 	if ( frameHeight === undefined ) frameHeight = 24;
157 
158 	var fov = 2 * Math.atan( frameHeight / ( focalLength * 2 ) ) * ( 180 / Math.PI );
159 
160 	this.setFov( fov );
161 
162 	return fov;
163 };
164 
165 
166 THREE.CombinedCamera.prototype.setZoom = function( zoom ) {
167 
168 	this.zoom = zoom;
169 
170 	if ( this.inPerspectiveMode ) {
171 
172 		this.toPerspective();
173 
174 	} else {
175 
176 		this.toOrthographic();
177 
178 	}
179 
180 };
181 
182 THREE.CombinedCamera.prototype.toFrontView = function() {
183 
184 	this.rotation.x = 0;
185 	this.rotation.y = 0;
186 	this.rotation.z = 0;
187 
188 	// should we be modifing the matrix instead?
189 
190 	this.rotationAutoUpdate = false;
191 
192 };
193 
194 THREE.CombinedCamera.prototype.toBackView = function() {
195 
196 	this.rotation.x = 0;
197 	this.rotation.y = Math.PI;
198 	this.rotation.z = 0;
199 	this.rotationAutoUpdate = false;
200 
201 };
202 
203 THREE.CombinedCamera.prototype.toLeftView = function() {
204 
205 	this.rotation.x = 0;
206 	this.rotation.y = - Math.PI / 2;
207 	this.rotation.z = 0;
208 	this.rotationAutoUpdate = false;
209 
210 };
211 
212 THREE.CombinedCamera.prototype.toRightView = function() {
213 
214 	this.rotation.x = 0;
215 	this.rotation.y = Math.PI / 2;
216 	this.rotation.z = 0;
217 	this.rotationAutoUpdate = false;
218 
219 };
220 
221 THREE.CombinedCamera.prototype.toTopView = function() {
222 
223 	this.rotation.x = - Math.PI / 2;
224 	this.rotation.y = 0;
225 	this.rotation.z = 0;
226 	this.rotationAutoUpdate = false;
227 
228 };
229 
230 THREE.CombinedCamera.prototype.toBottomView = function() {
231 
232 	this.rotation.x = Math.PI / 2;
233 	this.rotation.y = 0;
234 	this.rotation.z = 0;
235 	this.rotationAutoUpdate = false;
236 
237 };
238 
239 

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

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea