forked from Orillusion/orillusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plane.test.ts
30 lines (22 loc) · 985 Bytes
/
Plane.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { test, expect, end, delay } from '../util'
import { Engine3D, Plane, Ray, Vector3 } from '@orillusion/core';
await test('Plane intersectsLine', async () => {
let plane = new Plane(Vector3.ZERO, Vector3.X_AXIS);
let intersection = new Vector3();
let result = plane.intersectsLine(new Vector3(-10, 0, 0), new Vector3(10, 0, 0), intersection);
expect(result).toEqual(true);
expect(intersection.x).toSubequal(0);
expect(intersection.y).toSubequal(0);
expect(intersection.z).toSubequal(0);
})
await test('Plane intersectsRay', async () => {
let plane = new Plane(Vector3.ZERO, Vector3.X_AXIS);
let ray = new Ray(new Vector3(-10, 0, 0), new Vector3(1, 0, 0));
let intersection = new Vector3();
let result = plane.intersectsRay(ray, intersection);
expect(result).toEqual(true);
expect(intersection.x).toSubequal(0);
expect(intersection.y).toSubequal(0);
expect(intersection.z).toSubequal(0);
})
setTimeout(end, 500)