diff --git a/__test__/DatabaseServices/EntityData.test.ts b/__test__/DatabaseServices/EntityData.test.ts index bb734ed29..7873b1c5a 100644 --- a/__test__/DatabaseServices/EntityData.test.ts +++ b/__test__/DatabaseServices/EntityData.test.ts @@ -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); }) diff --git a/__test__/Geometry/orbit.test.ts b/__test__/Geometry/orbit.test.ts index d17c28c7f..1e18ea296 100644 --- a/__test__/Geometry/orbit.test.ts +++ b/__test__/Geometry/orbit.test.ts @@ -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); + }) diff --git a/src/DatabaseServices/EntityData.ts b/src/DatabaseServices/EntityData.ts index 0a9f29cfd..92324b7d2 100644 --- a/src/DatabaseServices/EntityData.ts +++ b/src/DatabaseServices/EntityData.ts @@ -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) { diff --git a/src/Geometry/Orbit.ts b/src/Geometry/Orbit.ts index f23102088..61daab1fe 100644 --- a/src/Geometry/Orbit.ts +++ b/src/Geometry/Orbit.ts @@ -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 { diff --git a/wallaby.conf.js b/wallaby.conf.js new file mode 100644 index 000000000..eb5dae6a1 --- /dev/null +++ b/wallaby.conf.js @@ -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', + }; +}; \ No newline at end of file