Browse Source

Add Viewer.forwardRay()

customisations
alemart 10 months ago
parent
commit
6c7143329a
2 changed files with 24 additions and 0 deletions
  1. 12
    0
      docs/api/viewer.md
  2. 12
    0
      src/geometry/viewer.ts

+ 12
- 0
docs/api/viewer.md View File

@@ -61,3 +61,15 @@ Cast a [ray](ray.md) from a point in the image space associated with this viewer
61 61
 **Returns**
62 62
 
63 63
 A ray in world space that corresponds to the given point.
64
+
65
+### forwardRay
66
+
67
+`viewer.forwardRay(): Ray`
68
+
69
+Compute a [ray](ray.md) in the forward direction from the viewer.
70
+
71
+*Since:* 0.4.0
72
+
73
+**Returns**
74
+
75
+A new ray in world space.

+ 12
- 0
src/geometry/viewer.ts View File

@@ -145,4 +145,16 @@ export class Viewer
145 145
 
146 146
         return new Ray(origin, direction);
147 147
     }
148
+
149
+    /**
150
+     * Compute a ray in the forward direction from the viewer
151
+     * @returns a new ray in world space
152
+     */
153
+    forwardRay(): Ray
154
+    {
155
+        const origin = this._pose.transform.position;
156
+        const direction = this._pose.transform.forward;
157
+
158
+        return new Ray(origin, direction);
159
+    }
148 160
 }

Loading…
Cancel
Save