You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/Geometry/GeUtils.test.ts

60 lines
1.4 KiB

import { Vector3 } from 'three';
import { getLoocAtUpVec, rotatePoint, ComparePointFnGenerate } from './../../src/Geometry/GeUtils';
test('getLoocAtUpVec', () =>
{
//俯视图 0,1,0
expect(getLoocAtUpVec(new Vector3(0, 0, 1)) /*?*/).toMatchSnapshot();
//仰视图
expect(getLoocAtUpVec(new Vector3(0, 0, -1)) /*?*/).toMatchSnapshot();
//左视图
expect(getLoocAtUpVec(new Vector3(-1, 0, 0)) /*?*/).toMatchSnapshot();
//右视图
expect(getLoocAtUpVec(new Vector3(1, 0, 0)) /*?*/).toMatchSnapshot();
//前视图
expect(getLoocAtUpVec(new Vector3(0, 1, 0)) /*?*/).toMatchSnapshot();
});
test('旋转量', () =>
{
let v = new Vector3(1, 0, 0);
rotatePoint(v, 0.5);
expect(v).toMatchSnapshot();
rotatePoint(v, -0.5);
expect(v).toMatchSnapshot();
});
describe('排序测试', () =>
{
let pts = [
new Vector3(6, 2, 4),
new Vector3(1, 4, 3),
new Vector3(2, 2, 2),
new Vector3(3, 3, 1),
new Vector3(1, 3, 1),
new Vector3(1, 2, 1),
];
test('排序点xyz', () =>
{
pts.sort(ComparePointFnGenerate("xyz"));
expect(pts).toMatchSnapshot();
});
test('排序点Xyz', () =>
{
pts.sort(ComparePointFnGenerate("Xyz"));
expect(pts).toMatchSnapshot();
});
test('排序点Zx', () =>
{
pts.sort(ComparePointFnGenerate("Zx"));
expect(pts).toMatchSnapshot();
});
});