更新了ribit的测试文件. 修复了错误

pull/7/head
cx 7 years ago
parent c21a601db4
commit 87c287e204

@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`测试求向量 1`] = `
Vector3 {
"x": 0,
"y": -1,
"z": 0,
}
`;
exports[`测试求向量 2`] = `
Vector3 {
"x": 0,
"y": -1,
"z": 0,
}
`;
exports[`测试求向量 3`] = `
Vector3 {
"x": 0,
"y": 1,
"z": 0,
}
`;
exports[`测试求向量 4`] = `
Vector3 {
"x": 0.7071067811865475,
"y": 0,
"z": 0.7071067811865475,
}
`;

@ -1,7 +1,8 @@
import { Orbit } from '../../src/Geometry/Orbit';
import * as THREE from 'three';
import { GeUtils } from '../../src/Geometry/GeUtils';
test("测试平行", () =>
import { Vector3 } from 'three';
test("", () =>
{
//构造一个控制类.
let orb = new Orbit();
@ -62,4 +63,36 @@ test("测试平行", () =>
orb.UpdateDirection(dir);
console.log('dir: ', dir);
expect(GeUtils.equal(dir, dirc)).toBe(true);
let newD = orb.UpdateDirection();
console.log(newD);
expect(GeUtils.equal(newD, new THREE.Vector3(0, 0, -1))).toBe(true);
})
test("测试求向量", () =>
{
let dir = new THREE.Vector3(0, 0, 1);
let up = Orbit.ComputUpDirection(dir);
console.log(up);
expect(up).toMatchSnapshot();
Orbit.ComputUpDirection(dir, up);
console.log(up);
expect(up).toMatchSnapshot();
dir.z = -1;
Orbit.ComputUpDirection(dir, up);
console.log('up: ', up);
expect(up).toMatchSnapshot();
dir.x = 1;
Orbit.ComputUpDirection(dir, up);
console.log('up: ', up);
expect(up).toMatchSnapshot();
})

@ -34,13 +34,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;
}
@ -75,11 +75,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
{

Loading…
Cancel
Save