|
@@ -1,7 +1,9 @@
|
|
|
/* global QUnit */
|
|
|
|
|
|
import { PerspectiveCamera } from '../../../../src/cameras/PerspectiveCamera.js';
|
|
|
+
|
|
|
import { Matrix4 } from '../../../../src/math/Matrix4.js';
|
|
|
+import { Camera } from '../../../../src/cameras/Camera.js';
|
|
|
|
|
|
export default QUnit.module( 'Cameras', () => {
|
|
|
|
|
@@ -17,7 +19,7 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( var i = 0, il = a.elements.length; i < il; i ++ ) {
|
|
|
+ for ( let i = 0, il = a.elements.length; i < il; i ++ ) {
|
|
|
|
|
|
var delta = a.elements[ i ] - b.elements[ i ];
|
|
|
if ( delta > tolerance ) {
|
|
@@ -33,9 +35,13 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
};
|
|
|
|
|
|
// INHERITANCE
|
|
|
- QUnit.todo( 'Extending', ( assert ) => {
|
|
|
+ QUnit.test( 'Extending', ( assert ) => {
|
|
|
|
|
|
- assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+ const object = new PerspectiveCamera();
|
|
|
+ assert.strictEqual(
|
|
|
+ object instanceof Camera, true,
|
|
|
+ 'PerspectiveCamera extends from Camera'
|
|
|
+ );
|
|
|
|
|
|
} );
|
|
|
|
|
@@ -46,13 +52,82 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
|
|
|
} );
|
|
|
|
|
|
- // PUBLIC STUFF
|
|
|
- QUnit.todo( 'isPerspectiveCamera', ( assert ) => {
|
|
|
+ // PROPERTIES
|
|
|
+ QUnit.test( 'type', ( assert ) => {
|
|
|
+
|
|
|
+ const object = new PerspectiveCamera();
|
|
|
+ assert.ok(
|
|
|
+ object.type === 'PerspectiveCamera',
|
|
|
+ 'PerspectiveCamera.type should be PerspectiveCamera'
|
|
|
+ );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'fov', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'zoom', ( assert ) => {
|
|
|
|
|
|
assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
|
|
|
} );
|
|
|
|
|
|
+ QUnit.todo( 'near', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'far', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'focus', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'aspect', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'view', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'filmGauge', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ QUnit.todo( 'filmOffset', ( assert ) => {
|
|
|
+
|
|
|
+ assert.ok( false, 'everything\'s gonna be alright' );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+ // PUBLIC
|
|
|
+ QUnit.test( 'isPerspectiveCamera', ( assert ) => {
|
|
|
+
|
|
|
+ const object = new PerspectiveCamera();
|
|
|
+ assert.ok(
|
|
|
+ object.isPerspectiveCamera,
|
|
|
+ 'PerspectiveCamera.isPerspectiveCamera should be true'
|
|
|
+ );
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
QUnit.todo( 'copy', ( assert ) => {
|
|
|
|
|
|
assert.ok( false, 'everything\'s gonna be alright' );
|
|
@@ -103,10 +178,10 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
|
|
|
QUnit.test( 'updateProjectionMatrix', ( assert ) => {
|
|
|
|
|
|
- var cam = new PerspectiveCamera( 75, 16 / 9, 0.1, 300.0 );
|
|
|
+ const cam = new PerspectiveCamera( 75, 16 / 9, 0.1, 300.0 );
|
|
|
|
|
|
// updateProjectionMatrix is called in constructor
|
|
|
- var m = cam.projectionMatrix;
|
|
|
+ const m = cam.projectionMatrix;
|
|
|
|
|
|
// perspective projection is given my the 4x4 Matrix
|
|
|
// 2n/r-l 0 l+r/r-l 0
|
|
@@ -116,7 +191,7 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
|
|
|
// 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 Matrix4().set(
|
|
|
+ const reference = new Matrix4().set(
|
|
|
0.7330642938613892, 0, 0, 0,
|
|
|
0, 1.3032253980636597, 0, 0,
|
|
|
0, 0, - 1.000666856765747, - 0.2000666856765747,
|
|
@@ -135,17 +210,17 @@ export default QUnit.module( 'Cameras', () => {
|
|
|
} );
|
|
|
|
|
|
// OTHERS
|
|
|
- // TODO: no no no clone is a camera methods that relied to copy method
|
|
|
+ // TODO: clone is a camera methods that relied to copy method
|
|
|
QUnit.test( 'clone', ( assert ) => {
|
|
|
|
|
|
- var near = 1,
|
|
|
+ const near = 1,
|
|
|
far = 3,
|
|
|
aspect = 16 / 9,
|
|
|
fov = 90;
|
|
|
|
|
|
- var cam = new PerspectiveCamera( fov, aspect, near, far );
|
|
|
+ const cam = new PerspectiveCamera( fov, aspect, near, far );
|
|
|
|
|
|
- var clonedCam = cam.clone();
|
|
|
+ const clonedCam = cam.clone();
|
|
|
|
|
|
assert.ok( cam.fov === clonedCam.fov, 'fov is equal' );
|
|
|
assert.ok( cam.aspect === clonedCam.aspect, 'aspect is equal' );
|