@ringozz/godot 4.7.2-583 → 4.7.2-592
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/gen/classes/ArrayOccluder3D.ts +1 -1
- package/gen/classes/CPUParticles2D.ts +3 -3
- package/gen/classes/CPUParticles3D.ts +3 -3
- package/gen/classes/CSGPolygon3D.ts +1 -1
- package/gen/classes/CollisionPolygon2D.ts +1 -1
- package/gen/classes/CollisionPolygon3D.ts +1 -1
- package/gen/classes/ColorPalette.ts +1 -1
- package/gen/classes/ConcavePolygonShape2D.ts +1 -1
- package/gen/classes/ConcavePolygonShape3D.ts +1 -1
- package/gen/classes/ConvexPolygonShape2D.ts +1 -1
- package/gen/classes/ConvexPolygonShape3D.ts +1 -1
- package/gen/classes/FontVariation.ts +1 -1
- package/gen/classes/Gradient.ts +1 -1
- package/gen/classes/Line2D.ts +1 -1
- package/gen/classes/MultiMesh.ts +4 -4
- package/gen/classes/NavigationMesh.ts +1 -1
- package/gen/classes/NavigationObstacle2D.ts +1 -1
- package/gen/classes/NavigationObstacle3D.ts +1 -1
- package/gen/classes/NavigationPathQueryResult2D.ts +1 -1
- package/gen/classes/NavigationPathQueryResult3D.ts +1 -1
- package/gen/classes/NavigationPolygon.ts +1 -1
- package/gen/classes/OccluderPolygon2D.ts +1 -1
- package/gen/classes/Polygon2D.ts +3 -3
- package/gen/classes/PolygonOccluder3D.ts +1 -1
- package/gen/classes/Window.ts +1 -1
- package/gen/index.ts +0 -3
- package/gen/utility-functions.ts +114 -114
- package/gen/value-types/AABB.ts +267 -277
- package/gen/value-types/Basis.ts +313 -264
- package/gen/value-types/Color.ts +398 -268
- package/gen/value-types/Plane.ts +121 -125
- package/gen/value-types/Projection.ts +178 -126
- package/gen/value-types/Quaternion.ts +180 -179
- package/gen/value-types/Rect2.ts +169 -171
- package/gen/value-types/Rect2i.ts +148 -150
- package/gen/value-types/Transform2D.ts +192 -194
- package/gen/value-types/Transform3D.ts +133 -126
- package/gen/value-types/Vector2.ts +370 -354
- package/gen/value-types/Vector2i.ts +192 -191
- package/gen/value-types/Vector3.ts +354 -354
- package/gen/value-types/Vector3i.ts +187 -192
- package/gen/value-types/Vector4.ts +263 -274
- package/gen/value-types/Vector4i.ts +187 -198
- package/gen/value-types/index.ts +16 -16
- package/package.json +20 -4
- package/src/debug.ts +30 -27
- package/src/index.ts +0 -2
- package/src/runtime.ts +16 -7
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Auto-generated from extension_api.json - DO NOT EDIT
|
|
2
2
|
// Generated by dev/codegen.ts
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { _V } from '../../src/runtime.ts';
|
|
5
5
|
import type { GodotArray, GodotDictionary, PackedVector2Array, Variant } from '../heap-types/index.ts';
|
|
6
|
-
import type { Transform2D, Vector2i } from '
|
|
6
|
+
import type { Transform2D, Vector2i } from './index.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A 2-element structure that can be used to represent 2D coordinates or any other pair of numeric values.
|
|
@@ -11,355 +11,371 @@ import type { Transform2D, Vector2i } from '../value-types/index.ts';
|
|
|
11
11
|
* See {@link Vector2i} for its integer counterpart.
|
|
12
12
|
* **Note:** In a boolean context, a Vector2 will evaluate to `false` if it's equal to `Vector2(0, 0)`. Otherwise, a Vector2 will always evaluate to `true`.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
14
|
+
export type Vector2 = [x: number, y: number];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns this vector's angle with respect to the positive X axis, or `(1, 0)` vector, in radians.
|
|
18
|
+
* For example, `Vector2.RIGHT.angle()` will return zero, `Vector2.DOWN.angle()` will return `PI / 2` (a quarter turn, or 90 degrees), and `Vector2(1, -1).angle()` will return `-PI / 4` (a negative eighth turn, or -45 degrees).
|
|
19
|
+
* This is equivalent to calling {@link atan2} with {@link y} and {@link x}.
|
|
20
|
+
* [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle.png)
|
|
21
|
+
*/
|
|
22
|
+
export function angle(self: Vector2): number { return _V(5, 1448, self) as number; }
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Returns the signed angle to the given vector, in radians. The result ranges from `-PI` to `PI` (inclusive).
|
|
26
|
+
* [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to.png)
|
|
27
|
+
*/
|
|
28
|
+
export function angleTo(self: Vector2, to: Vector2): number { return _V(5, 1453, self, to) as number; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns the signed angle between the X axis and the line from this vector to point `to`, in radians. The result ranges from `-PI` to `PI` (inclusive).
|
|
32
|
+
* `a.angle_to_point(b)` is equivalent to `(b - a).angle()`. See also {@link angle}.
|
|
33
|
+
* [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to_point.png)
|
|
34
|
+
*/
|
|
35
|
+
export function angleToPoint(self: Vector2, to: Vector2): number { return _V(5, 1454, self, to) as number; }
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns the normalized vector pointing from this vector to `to`.
|
|
39
|
+
* `a.direction_to(b)` is equivalent to `(b - a).normalized()`. See also {@link normalized}.
|
|
40
|
+
*/
|
|
41
|
+
export function directionTo(self: Vector2, to: Vector2): Vector2 { return _V(5, 2792, self, to) as Vector2; }
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
|
|
45
|
+
*/
|
|
46
|
+
export function distanceTo(self: Vector2, to: Vector2): number { return _V(5, 2850, self, to) as number; }
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the squared [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
|
|
50
|
+
* This method runs faster than {@link distanceTo}, so prefer it if you need to compare vectors or need the squared distance for some formula.
|
|
51
|
+
*/
|
|
52
|
+
export function distanceSquaredTo(self: Vector2, to: Vector2): number { return _V(5, 2849, self, to) as number; }
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the length (magnitude) of this vector.
|
|
56
|
+
*/
|
|
57
|
+
export function length(self: Vector2): number { return _V(5, 8546, self) as number; }
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns the squared length (squared magnitude) of this vector.
|
|
61
|
+
* This method runs faster than {@link length}, so prefer it if you need to compare vectors or need the squared distance for some formula.
|
|
62
|
+
*/
|
|
63
|
+
export function lengthSquared(self: Vector2): number { return _V(5, 8547, self) as number; }
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns the vector with a maximum length by limiting its length to `length`. If the vector is non-finite, the result is undefined.
|
|
67
|
+
*/
|
|
68
|
+
export function limitLength(self: Vector2, length?: number /* = 1.0 */): Vector2 { return _V(5, 8615, self, length) as Vector2; }
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns the result of scaling the vector to unit length. Equivalent to `v / v.length()`. Returns `(0, 0)` if `v.length() == 0`. See also {@link isNormalized}.
|
|
72
|
+
* **Note:** This function may return incorrect values if the input vector length is near zero.
|
|
73
|
+
*/
|
|
74
|
+
export function normalized(self: Vector2): Vector2 { return _V(5, 9103, self) as Vector2; }
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns `true` if the vector is normalized, i.e. its length is approximately equal to 1.
|
|
78
|
+
*/
|
|
79
|
+
export function isNormalized(self: Vector2): boolean { return _V(5, 8138, self) as boolean; }
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns `true` if this vector and `to` are approximately equal, by running {@link isEqualApprox} on each component.
|
|
83
|
+
*/
|
|
84
|
+
export function isEqualApprox(self: Vector2, to: Vector2): boolean { return _V(5, 7938, self, to) as boolean; }
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Returns `true` if this vector's values are approximately zero, by running {@link isZeroApprox} on each component.
|
|
88
|
+
* This method is faster than using {@link isEqualApprox} with one value as a zero vector.
|
|
89
|
+
*/
|
|
90
|
+
export function isZeroApprox(self: Vector2): boolean { return _V(5, 8459, self) as boolean; }
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Returns `true` if this vector is finite, by calling {@link isFinite} on each component.
|
|
94
|
+
*/
|
|
95
|
+
export function isFinite(self: Vector2): boolean { return _V(5, 7951, self) as boolean; }
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns a vector composed of the {@link fposmod} of this vector's components and `mod`.
|
|
99
|
+
*/
|
|
100
|
+
export function posmod(self: Vector2, mod: number): Vector2 { return _V(5, 9518, self, mod) as Vector2; }
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns a vector composed of the {@link fposmod} of this vector's components and `modv`'s components.
|
|
104
|
+
*/
|
|
105
|
+
export function posmodv(self: Vector2, modv: Vector2): Vector2 { return _V(5, 9519, self, modv) as Vector2; }
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Returns a new vector resulting from projecting this vector onto the given vector `b`. The resulting new vector is parallel to `b`. See also {@link slide}.
|
|
109
|
+
* **Note:** If the vector `b` is a zero vector, the components of the resulting new vector will be `NAN`.
|
|
110
|
+
*/
|
|
111
|
+
export function project(self: Vector2, b: Vector2): Vector2 { return _V(5, 9589, self, b) as Vector2; }
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns the result of the linear interpolation between this vector and `to` by amount `weight`. `weight` is on the range of `0.0` to `1.0`, representing the amount of interpolation.
|
|
115
|
+
*/
|
|
116
|
+
export function lerp(self: Vector2, to: Vector2, weight: number): Vector2 { return _V(5, 8548, self, to, weight) as Vector2; }
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns the result of spherical linear interpolation between this vector and `to`, by amount `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
|
120
|
+
* This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like {@link lerp}.
|
|
121
|
+
*/
|
|
122
|
+
export function slerp(self: Vector2, to: Vector2, weight: number): Vector2 { return _V(5, 13656, self, to, weight) as Vector2; }
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
|
126
|
+
*/
|
|
127
|
+
export function cubicInterpolate(self: Vector2, b: Vector2, preA: Vector2, postB: Vector2, weight: number): Vector2 { return _V(5, 2590, self, b, preA, postB, weight) as Vector2; }
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
|
|
131
|
+
* It can perform smoother interpolation than {@link cubicInterpolate} by the time values.
|
|
132
|
+
*/
|
|
133
|
+
export function cubicInterpolateInTime(self: Vector2, b: Vector2, preA: Vector2, postB: Vector2, weight: number, bT: number, preAT: number, postBT: number): Vector2 { return _V(5, 2593, self, b, preA, postB, weight, bT, preAT, postBT) as Vector2; }
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns the point at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
|
|
137
|
+
*/
|
|
138
|
+
export function bezierInterpolate(self: Vector2, control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _V(5, 1757, self, control1, control2, end, t) as Vector2; }
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Returns the derivative at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
|
|
142
|
+
*/
|
|
143
|
+
export function bezierDerivative(self: Vector2, control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _V(5, 1756, self, control1, control2, end, t) as Vector2; }
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Returns the axis of the vector's highest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_X}.
|
|
147
|
+
*/
|
|
148
|
+
export function maxAxisIndex(self: Vector2): number { return _V(5, 8806, self) as number; }
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Returns the axis of the vector's lowest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_Y}.
|
|
152
|
+
*/
|
|
153
|
+
export function minAxisIndex(self: Vector2): number { return _V(5, 8911, self) as number; }
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns a new vector moved toward `to` by the fixed `delta` amount. Will not go past the final value.
|
|
157
|
+
*/
|
|
158
|
+
export function moveToward(self: Vector2, to: Vector2, delta: number): Vector2 { return _V(5, 9004, self, to, delta) as Vector2; }
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the result of rotating this vector by `angle` (in radians). See also {@link degToRad}.
|
|
162
|
+
*/
|
|
163
|
+
export function rotated(self: Vector2, angle: number): Vector2 { return _V(5, 10144, self, angle) as Vector2; }
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length.
|
|
167
|
+
*/
|
|
168
|
+
export function orthogonal(self: Vector2): Vector2 { return _V(5, 9228, self) as Vector2; }
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Returns a new vector with all components rounded down (towards negative infinity).
|
|
172
|
+
*/
|
|
173
|
+
export function floor(self: Vector2): Vector2 { return _V(5, 3335, self) as Vector2; }
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Returns a new vector with all components rounded up (towards positive infinity).
|
|
177
|
+
*/
|
|
178
|
+
export function ceil(self: Vector2): Vector2 { return _V(5, 2156, self) as Vector2; }
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
|
|
182
|
+
*/
|
|
183
|
+
export function round(self: Vector2): Vector2 { return _V(5, 10166, self) as Vector2; }
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Returns this vector's aspect ratio, which is {@link x} divided by {@link y}.
|
|
187
|
+
*/
|
|
188
|
+
export function aspect(self: Vector2): number { return _V(5, 1602, self) as number; }
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Returns the dot product of this vector and `with`. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
|
|
192
|
+
* The dot product will be `0` for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
|
|
193
|
+
* When using unit (normalized) vectors, the result will always be between `-1.0` (180 degree angle) when the vectors are facing opposite directions, and `1.0` (0 degree angle) when the vectors are aligned.
|
|
194
|
+
* **Note:** `a.dot(b)` is equivalent to `b.dot(a)`.
|
|
195
|
+
*/
|
|
196
|
+
export function dot(self: Vector2, _with: Vector2): number { return _V(5, 2871, self, _with) as number; }
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Returns a new vector resulting from sliding this vector along a line with normal `n`. The resulting new vector is perpendicular to `n`, and is equivalent to this vector minus its projection on `n`. See also {@link project}.
|
|
200
|
+
* **Note:** The vector `n` must be normalized. See also {@link normalized}.
|
|
201
|
+
*/
|
|
202
|
+
export function slide(self: Vector2, n: Vector2): Vector2 { return _V(5, 13659, self, n) as Vector2; }
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Returns the vector "bounced off" from a line defined by the given normal `n` perpendicular to the line.
|
|
206
|
+
* **Note:** {@link bounce} performs the operation that most engines and frameworks call {@link code skip-lint}reflect()[/code].
|
|
207
|
+
*/
|
|
208
|
+
export function bounce(self: Vector2, n: Vector2): Vector2 { return _V(5, 1902, self, n) as Vector2; }
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Returns the result of reflecting the vector from a line defined by the given direction vector `line`.
|
|
212
|
+
* **Note:** {@link reflect} differs from what other engines and frameworks call {@link code skip-lint}reflect()[/code]. In other engines, {@link code skip-lint}reflect()[/code] takes a normal direction which is a direction perpendicular to the line. In Godot, you specify the direction of the line directly. See also {@link bounce} which does what most engines call {@link code skip-lint}reflect()[/code].
|
|
213
|
+
*/
|
|
214
|
+
export function reflect(self: Vector2, line: Vector2): Vector2 { return _V(5, 9776, self, line) as Vector2; }
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Returns the 2D analog of the cross product for this vector and `with`.
|
|
218
|
+
* This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area. If the two vectors are parallel this returns zero, making it useful for testing if two vectors are parallel.
|
|
219
|
+
* **Note:** Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog.
|
|
220
|
+
*/
|
|
221
|
+
export function cross(self: Vector2, _with: Vector2): number { return _V(5, 2586, self, _with) as number; }
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Returns a new vector with all components in absolute values (i.e. positive).
|
|
225
|
+
*/
|
|
226
|
+
export function abs(self: Vector2): Vector2 { return _V(5, 1053, self) as Vector2; }
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Returns a new vector with each component set to `1.0` if it's positive, `-1.0` if it's negative, and `0.0` if it's zero. The result is identical to calling {@link sign} on each component.
|
|
230
|
+
*/
|
|
231
|
+
export function sign(self: Vector2): Vector2 { return _V(5, 13597, self) as Vector2; }
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Returns a new vector with all components clamped between the components of `min` and `max`, by running {@link clamp} on each component.
|
|
235
|
+
*/
|
|
236
|
+
export function clamp(self: Vector2, min: Vector2, max: Vector2): Vector2 { return _V(5, 2202, self, min, max) as Vector2; }
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Returns a new vector with all components clamped between `min` and `max`, by running {@link clamp} on each component.
|
|
240
|
+
*/
|
|
241
|
+
export function clampf(self: Vector2, min: number, max: number): Vector2 { return _V(5, 2205, self, min, max) as Vector2; }
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Returns a new vector with each component snapped to the nearest multiple of the corresponding component in `step`. This can also be used to round the components to an arbitrary number of decimals.
|
|
245
|
+
*/
|
|
246
|
+
export function snapped(self: Vector2, step: Vector2): Vector2 { return _V(5, 13674, self, step) as Vector2; }
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Returns a new vector with each component snapped to the nearest multiple of `step`. This can also be used to round the components to an arbitrary number of decimals.
|
|
250
|
+
*/
|
|
251
|
+
export function snappedf(self: Vector2, step: number): Vector2 { return _V(5, 13675, self, step) as Vector2; }
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with.x), minf(y, with.y))`.
|
|
255
|
+
*/
|
|
256
|
+
export function min(self: Vector2, _with: Vector2): Vector2 { return _V(5, 8910, self, _with) as Vector2; }
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with), minf(y, with))`.
|
|
260
|
+
*/
|
|
261
|
+
export function minf(self: Vector2, _with: number): Vector2 { return _V(5, 8921, self, _with) as Vector2; }
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with.x), maxf(y, with.y))`.
|
|
265
|
+
*/
|
|
266
|
+
export function max(self: Vector2, _with: Vector2): Vector2 { return _V(5, 8804, self, _with) as Vector2; }
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with), maxf(y, with))`.
|
|
270
|
+
*/
|
|
271
|
+
export function maxf(self: Vector2, _with: number): Vector2 { return _V(5, 8839, self, _with) as Vector2; }
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Creates a {@link Vector2} rotated to the given `angle` in radians. This is equivalent to doing `Vector2(cos(angle), sin(angle))` or `Vector2.RIGHT.rotated(angle)`.
|
|
275
|
+
*
|
|
276
|
+
* ```text
|
|
277
|
+
*
|
|
278
|
+
* print(Vector2.from_angle(0)) # Prints (1.0, 0.0)
|
|
279
|
+
* print(Vector2(1, 0).angle()) # Prints 0.0, which is the angle used above.
|
|
280
|
+
* print(Vector2.from_angle(PI / 2)) # Prints (0.0, 1.0)
|
|
281
|
+
*
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* **Note:** The length of the returned {@link Vector2} is *approximately* `1.0`, but is is not guaranteed to be exactly `1.0` due to floating-point precision issues. Call {@link normalized} on the returned {@link Vector2} if you require a unit vector.
|
|
285
|
+
*/
|
|
286
|
+
export function fromAngle(angle: number): Vector2 { return _V(5, 3592, undefined, angle) as Vector2; }
|
|
287
|
+
|
|
288
|
+
export function equals(a: Vector2, b: Variant | Vector2): boolean { return _V(5, -1, a, b) as boolean; }
|
|
289
|
+
|
|
290
|
+
export function notEquals(a: Vector2, b: Variant | Vector2): boolean { return _V(5, -2, a, b) as boolean; }
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Returns the negative value of the {@link Vector2}. This is the same as writing `Vector2(-v.x, -v.y)`. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
|
|
294
|
+
*/
|
|
295
|
+
export function neg(self: Vector2): Vector2 { return _V(5, -11, self, undefined) as Vector2; }
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Returns the same value as if the `+` was not there. Unary `+` does nothing, but sometimes it can make your code more readable.
|
|
299
|
+
*/
|
|
300
|
+
export function pos(self: Vector2): Vector2 { return _V(5, -12, self, undefined) as Vector2; }
|
|
301
|
+
|
|
302
|
+
export function not(self: Vector2): boolean { return _V(5, -24, self, undefined) as boolean; }
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Multiplies each component of the {@link Vector2} by the given {@link int}.
|
|
306
|
+
*/
|
|
307
|
+
export function mul(a: Vector2, b: number | Vector2 | Transform2D): Vector2 { return _V(5, -9, a, b) as Vector2; }
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Divides each component of the {@link Vector2} by the given {@link int}.
|
|
311
|
+
*/
|
|
312
|
+
export function div(a: Vector2, b: number | Vector2): Vector2 { return _V(5, -10, a, b) as Vector2; }
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
|
|
316
|
+
* **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
|
|
317
|
+
*/
|
|
318
|
+
export function lessThan(a: Vector2, b: Vector2): boolean { return _V(5, -3, a, b) as boolean; }
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
|
|
322
|
+
* **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
|
|
323
|
+
*/
|
|
324
|
+
export function lessThanOrEqual(a: Vector2, b: Vector2): boolean { return _V(5, -4, a, b) as boolean; }
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
|
|
328
|
+
* **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
|
|
329
|
+
*/
|
|
330
|
+
export function greaterThan(a: Vector2, b: Vector2): boolean { return _V(5, -5, a, b) as boolean; }
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
|
|
334
|
+
* **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
|
|
335
|
+
*/
|
|
336
|
+
export function greaterThanOrEqual(a: Vector2, b: Vector2): boolean { return _V(5, -6, a, b) as boolean; }
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Adds each component of the {@link Vector2} by the components of the given {@link Vector2}.
|
|
340
|
+
*
|
|
341
|
+
* ```text
|
|
342
|
+
*
|
|
343
|
+
* print(Vector2(10, 20) + Vector2(3, 4)) # Prints (13.0, 24.0)
|
|
344
|
+
*
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
export function add(a: Vector2, b: Vector2): Vector2 { return _V(5, -7, a, b) as Vector2; }
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Subtracts each component of the {@link Vector2} by the components of the given {@link Vector2}.
|
|
351
|
+
*
|
|
352
|
+
* ```text
|
|
353
|
+
*
|
|
354
|
+
* print(Vector2(10, 20) - Vector2(3, 4)) # Prints (7.0, 16.0)
|
|
355
|
+
*
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
export function sub(a: Vector2, b: Vector2): Vector2 { return _V(5, -8, a, b) as Vector2; }
|
|
359
|
+
|
|
360
|
+
export function contains(a: Vector2, b: GodotDictionary | GodotArray | PackedVector2Array): boolean { return _V(5, -25, a, b) as boolean; }
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Constructs a default-initialized {@link Vector2} with all components set to `0`.
|
|
364
|
+
*/
|
|
365
|
+
export function create(): Vector2 { return _V(5, -4096, 0) as Vector2; }
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Constructs a {@link Vector2} as a copy of the given {@link Vector2}.
|
|
369
|
+
*/
|
|
370
|
+
export function fromVector2(from: Vector2): Vector2 { return _V(5, -4096, 1, from) as Vector2; }
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Constructs a new {@link Vector2} from {@link Vector2i}.
|
|
374
|
+
*/
|
|
375
|
+
export function fromVector2i(from: Vector2i): Vector2 { return _V(5, -4096, 2, from) as Vector2; }
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Constructs a new {@link Vector2} from the given `x` and `y`.
|
|
379
|
+
*/
|
|
380
|
+
export function fromXY(x: number, y: number): Vector2 { return _V(5, -4096, 3, x, y) as Vector2; }
|
|
381
|
+
|