Bladeren bron

Vector2, Vector3: add instantiation methods

customisations
alemart 10 maanden geleden
bovenliggende
commit
a5d0ebabe9
3 gewijzigde bestanden met toevoegingen van 72 en 0 verwijderingen
  1. 23
    0
      docs/api/vector2.md
  2. 24
    0
      docs/api/vector3.md
  3. 25
    0
      src/main.ts

+ 23
- 0
docs/api/vector2.md Bestand weergeven

@@ -4,6 +4,29 @@ A vector in 2D space.
4 4
 
5 5
 *Since:* 0.4.0
6 6
 
7
+## Instantiation
8
+
9
+### AR.Vector2
10
+
11
+`AR.Vector2(x: number, y: number): Vector2`
12
+
13
+Create a new vector with the provided coordinates.
14
+
15
+**Arguments**
16
+
17
+* `x: number`. x coordinate.
18
+* `y: number`. y coordinate.
19
+
20
+**Returns**
21
+
22
+A new vector.
23
+
24
+**Example**
25
+
26
+```js
27
+const zero = AR.Vector2(0, 0);
28
+```
29
+
7 30
 ## Properties
8 31
 
9 32
 ### x

+ 24
- 0
docs/api/vector3.md Bestand weergeven

@@ -4,6 +4,30 @@ A vector in 3D space.
4 4
 
5 5
 *Since:* 0.4.0
6 6
 
7
+## Instantiation
8
+
9
+### AR.Vector3
10
+
11
+`AR.Vector3(x: number, y: number, z: number): Vector3`
12
+
13
+Create a new vector with the provided coordinates.
14
+
15
+**Arguments**
16
+
17
+* `x: number`. x coordinate.
18
+* `y: number`. y coordinate.
19
+* `z: number`. z coordinate.
20
+
21
+**Returns**
22
+
23
+A new vector.
24
+
25
+**Example**
26
+
27
+```js
28
+const zero = AR.Vector3(0, 0, 0);
29
+```
30
+
7 31
 ## Properties
8 32
 
9 33
 ### x

+ 25
- 0
src/main.ts Bestand weergeven

@@ -27,6 +27,8 @@ import { Session, SessionOptions } from './core/session';
27 27
 import { TrackerFactory } from './trackers/tracker-factory';
28 28
 import { SourceFactory } from './sources/source-factory';
29 29
 import { Viewport, ViewportSettings } from './core/viewport';
30
+import { Vector2 } from './geometry/vector2';
31
+import { Vector3 } from './geometry/vector3';
30 32
 import { Utils } from './utils/utils';
31 33
 
32 34
 declare const __AR_VERSION__: string;
@@ -103,6 +105,29 @@ export default class AR
103 105
     }
104 106
 
105 107
     /**
108
+     * Create a new 2D vector
109
+     * @param x x-coordinate
110
+     * @param y y-coordinate
111
+     * @returns a new 2D vector with the provided coordinates
112
+     */
113
+    static Vector2(x: number, y: number): Vector2
114
+    {
115
+        return new Vector2(x, y);
116
+    }
117
+
118
+    /**
119
+     * Create a new 3D vector
120
+     * @param x x-coordinate
121
+     * @param y y-coordinate
122
+     * @param z z-coordinate
123
+     * @returns a new 3D vector with the provided coordinates
124
+     */
125
+    static Vector3(x: number, y: number, z: number): Vector3
126
+    {
127
+        return new Vector3(x, y, z);
128
+    }
129
+
130
+    /**
106 131
      * Global Settings
107 132
      */
108 133
     static get Settings(): typeof Settings

Laden…
Annuleren
Opslaan