forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerspectiveCamera.js
More file actions
50 lines (39 loc) · 1.37 KB
/
PerspectiveCamera.js
File metadata and controls
50 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @author simonThiele / https://github.com/simonThiele
*/
module( "PerspectiveCamera" );
test( "updateProjectionMatrix", function() {
var cam = new THREE.PerspectiveCamera( 75, 16 / 9, 0.1, 300.0 );
// updateProjectionMatrix is called in contructor
var m = cam.projectionMatrix;
// perspective projection is given my the 4x4 Matrix
// 2n/r-l 0 l+r/r-l 0
// 0 2n/t-b t+b/t-b 0
// 0 0 -(f+n/f-n) -(2fn/f-n)
// 0 0 -1 0
// this matrix was calculated by hand via glMatrix.perspective(75, 16 / 9, 0.1, 300.0, pMatrix)
// to get a reference matrix from plain WebGL
var reference = new THREE.Matrix4().set(
0.7330642938613892, 0, 0, 0,
0, 1.3032253980636597, 0, 0,
0, 0, -1.000666856765747, -0.2000666856765747,
0, 0, -1, 0
);
ok( reference.equals(m) );
});
test( "clone", function() {
var near = 1,
far = 3,
bottom = -1,
top = 1,
aspect = 16 / 9,
fov = 90;
var cam = new THREE.PerspectiveCamera( fov, aspect, near, far );
var clonedCam = cam.clone();
ok( cam.fov === clonedCam.fov , "fov is equal" );
ok( cam.aspect === clonedCam.aspect , "aspect is equal" );
ok( cam.near === clonedCam.near , "near is equal" );
ok( cam.far === clonedCam.far , "far is equal" );
ok( cam.zoom === clonedCam.zoom , "zoom is equal" );
ok( cam.projectionMatrix.equals(clonedCam.projectionMatrix) , "projectionMatrix is equal" );
});