@spearwolf/twopoint5d
Version:
a library to create 2.5d realtime graphics and pixelart with three.js
50 lines • 2.06 kB
JavaScript
import { OrthographicCamera } from 'three';
import { describe, expect, it } from 'vitest';
import { OrthographicProjection } from './OrthographicProjection.js';
import { ProjectionPlane } from './ProjectionPlane.js';
describe('OrthographicProjection', () => {
describe('construction', () => {
it('without arguments', () => {
const projection = new OrthographicProjection();
expect(projection).toBeDefined();
});
it('with plane and specs', () => {
const projection = new OrthographicProjection(ProjectionPlane.get('xy|bottom-left'), {
fit: 'contain',
width: 640,
});
expect(projection).toBeDefined();
expect(projection.viewSpecs).toBeDefined();
expect(projection.projectionPlane).toBeDefined();
});
});
it('updateViewRect + getViewRect', () => {
const projection = new OrthographicProjection(ProjectionPlane.get('xy|bottom-left'), {
fit: 'contain',
width: 640,
});
projection.updateViewRect(800, 600);
expect(projection.getViewRect()).toEqual([640, 480, 1.25, 1.25]);
});
it('getZoom', () => {
const projection = new OrthographicProjection(ProjectionPlane.get('xy|bottom-left'), {
fit: 'contain',
width: 640,
distanceToProjectionPlane: 300,
});
projection.updateViewRect(800, 600);
expect(projection.getZoom(666)).toEqual(1);
expect(projection.getZoom(300)).toEqual(1);
expect(projection.getZoom(23)).toEqual(1);
expect(projection.getZoom(0)).toEqual(1);
});
it('createCamera', () => {
const projection = new OrthographicProjection(ProjectionPlane.get('xy|bottom-left'), {
fit: 'contain',
width: 640,
});
projection.updateViewRect(800, 600);
expect(projection.createCamera()).toBeInstanceOf(OrthographicCamera);
});
});
//# sourceMappingURL=OrthographicProjection.spec.js.map