添加 wallaby 设置 更新代码通过单元测试

pull/7/head
ChenX 7 years ago
parent 52fc8e18ae
commit 2db632c8de

@ -1,6 +1,7 @@
import * as mst from 'mobx-state-tree';
import { EntityData } from '../../src/DatabaseServices/EntityData';
import * as THREE from 'three';
test("Entity", () =>
{
let d = EntityData.create({ size: [0, 1, 2] })
@ -11,7 +12,6 @@ test("Entity", () =>
d.setSize(1, 1, 1000);
console.log(d.getSize());
expect(d.getSize().x).toBe(1);
})

@ -27,7 +27,6 @@ test("测试平行", () =>
orb.UpdateDirection(dir);
expect(GeUtils.equal(dir, new THREE.Vector3(1, 0, 0))).toBe(true);
//试试新的
dir.set(0.5, 0.5, 0).normalize();
@ -39,8 +38,6 @@ test("测试平行", () =>
console.log('dir: ', dir);
expect(GeUtils.equal(dir, dirc)).toBe(true);
//试试新的
dir.set(0.5, 0.5, 1).normalize();
dirc = dir.clone();
@ -62,4 +59,21 @@ test("测试平行", () =>
orb.UpdateDirection(dir);
console.log('dir: ', dir);
expect(GeUtils.equal(dir, dirc)).toBe(true);
let newDir = orb.UpdateDirection();
console.log('newDir: ', newDir);
let up = Orbit.ComputUpDirection(new THREE.Vector3(0, 0, 1));
expect(GeUtils.equal(up, new THREE.Vector3(0, -1, 0))).toBe(true);
Orbit.ComputUpDirection(new THREE.Vector3(0, 0, -1), up);
console.log(up);
Orbit.ComputUpDirection(new THREE.Vector3(0, 0, 1), up);
console.log(up);
Orbit.ComputUpDirection(new THREE.Vector3(1, 0, 0), up);
})

@ -28,7 +28,9 @@ export const EntityData = mst.types.model(
return {
setSize(x, y, z)
{
self.size.clear().concat([x, y, z]);
self.size[0] = x;
self.size[1] = y;
self.size[2] = z;
},
setErase(isErase: boolean)
{

@ -33,13 +33,13 @@ export class Orbit
{
let rtDir = dir ? dir : new THREE.Vector3();
dir.z = Math.sin(this.m_RoX);
rtDir.z = Math.sin(this.m_RoX);
//归一化专用.
let d = Math.abs(Math.cos(this.m_RoX));
dir.x = Math.cos(this.RoZ) * d;
dir.y = Math.sin(this.RoZ) * d;
rtDir.x = Math.cos(this.RoZ) * d;
rtDir.y = Math.sin(this.RoZ) * d;
return rtDir;
}
@ -74,11 +74,11 @@ export class Orbit
let upRes = up ? up : new THREE.Vector3();
if (dir.equals(new THREE.Vector3(0, 0, -1)))
{
upRes.set(0, 1, 0)
upRes.set(0, 1, 0);
}
else if (dir.equals(new THREE.Vector3(0, 0, 1)))
{
upRes.set(0, -1, 0)
upRes.set(0, -1, 0);
}
else
{

@ -0,0 +1,18 @@
module.exports = function () {
return {
files: [
'tsconfig.json', // <--
'src/**/*.ts',
'src/**/*.js'],
tests: ['__test__/**/*.ts'],
env: {
type: 'node',
runner: 'node'
},
testFramework: 'jest',
};
};
Loading…
Cancel
Save