浏览代码

Vector2, Vector3: add instantiation methods

customisations
alemart 10 个月前
父节点
当前提交
a5d0ebabe9
共有 3 个文件被更改,包括 72 次插入0 次删除
  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 查看文件

4
 
4
 
5
 *Since:* 0.4.0
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
 ## Properties
30
 ## Properties
8
 
31
 
9
 ### x
32
 ### x

+ 24
- 0
docs/api/vector3.md 查看文件

4
 
4
 
5
 *Since:* 0.4.0
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
 ## Properties
31
 ## Properties
8
 
32
 
9
 ### x
33
 ### x

+ 25
- 0
src/main.ts 查看文件

27
 import { TrackerFactory } from './trackers/tracker-factory';
27
 import { TrackerFactory } from './trackers/tracker-factory';
28
 import { SourceFactory } from './sources/source-factory';
28
 import { SourceFactory } from './sources/source-factory';
29
 import { Viewport, ViewportSettings } from './core/viewport';
29
 import { Viewport, ViewportSettings } from './core/viewport';
30
+import { Vector2 } from './geometry/vector2';
31
+import { Vector3 } from './geometry/vector3';
30
 import { Utils } from './utils/utils';
32
 import { Utils } from './utils/utils';
31
 
33
 
32
 declare const __AR_VERSION__: string;
34
 declare const __AR_VERSION__: string;
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
      * Global Settings
131
      * Global Settings
107
      */
132
      */
108
     static get Settings(): typeof Settings
133
     static get Settings(): typeof Settings

正在加载...
取消
保存