|
@@ -0,0 +1,65 @@
|
|
1
|
+/*
|
|
2
|
+ * encantar.js
|
|
3
|
+ * GPU-accelerated Augmented Reality for the web
|
|
4
|
+ * Copyright (C) 2022-2024 Alexandre Martins <alemartf(at)gmail.com>
|
|
5
|
+ *
|
|
6
|
+ * This program is free software: you can redistribute it and/or modify
|
|
7
|
+ * it under the terms of the GNU Lesser General Public License as published
|
|
8
|
+ * by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+ * (at your option) any later version.
|
|
10
|
+ *
|
|
11
|
+ * This program is distributed in the hope that it will be useful,
|
|
12
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+ * GNU Lesser General Public License for more details.
|
|
15
|
+ *
|
|
16
|
+ * You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+ *
|
|
19
|
+ * ray.ts
|
|
20
|
+ * Rays
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+import { Vector3 } from './vector3';
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+/**
|
|
27
|
+ * A ray with origin and direction
|
|
28
|
+ */
|
|
29
|
+export class Ray
|
|
30
|
+{
|
|
31
|
+ /** origin of the ray, a point */
|
|
32
|
+ private _origin: Vector3;
|
|
33
|
+
|
|
34
|
+ /** direction, a unit vector */
|
|
35
|
+ private _direction: Vector3;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+ /**
|
|
40
|
+ * Constructor
|
|
41
|
+ * @param origin a point
|
|
42
|
+ * @param direction a unit vector
|
|
43
|
+ */
|
|
44
|
+ constructor(origin: Vector3, direction: Vector3)
|
|
45
|
+ {
|
|
46
|
+ this._origin = origin;
|
|
47
|
+ this._direction = direction;
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ /**
|
|
51
|
+ * The origin point of the ray
|
|
52
|
+ */
|
|
53
|
+ get origin(): Vector3
|
|
54
|
+ {
|
|
55
|
+ return this._origin;
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * The direction of the ray, a unit vector
|
|
60
|
+ */
|
|
61
|
+ get direction(): Vector3
|
|
62
|
+ {
|
|
63
|
+ return this._direction;
|
|
64
|
+ }
|
|
65
|
+}
|