1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 | global.window = {};
|
6 |
|
7 | var test = require('tape');
|
8 | var THREE = require('three');
|
9 | var index = require('../build/index.common.js');
|
10 |
|
11 | test('Test three', function (t) {
|
12 | t.ok(true, 'Can run a test');
|
13 | var vec = new THREE.Vector3(1,2,3);
|
14 | t.equal(vec.x,1,'Vector x');
|
15 | t.equal(vec.lengthSq(),1+4+9, 'Vector length');
|
16 |
|
17 | var camera = new THREE.PerspectiveCamera( 45, 1.0, 1, 1000 );
|
18 | t.equal(camera.far, 1000, 'Camera far');
|
19 |
|
20 | t.end();
|
21 | });
|
22 |
|
23 | test('Test three plugins', function (t) {
|
24 | var shadow = new index.ShadowBuilder();
|
25 | t.ok(shadow, 'Can create a shadow builder');
|
26 | t.end();
|
27 | });
|
28 |
|
29 | test('Test camera focus', function (t) {
|
30 | var camera = new THREE.PerspectiveCamera(30, 1.33, 0.1, 100000);
|
31 | camera.position.set(25, 100, 130);
|
32 |
|
33 | var geometry = new THREE.SphereBufferGeometry( 5000, 32, 32 );
|
34 | var material = new THREE.MeshBasicMaterial( {color: 0xffff00} );
|
35 | var sphere = new THREE.Mesh( geometry, material );
|
36 | sphere.position.set(25, 10000, 130);
|
37 |
|
38 | var controls = new index.EditorControls(camera, {addEventListener: function(){}});
|
39 | controls.focus(sphere, true);
|
40 | t.ok(camera.position.y > 0, 'Camera stays above ground');
|
41 | t.end();
|
42 | });
|