@defold-typescript/types 0.49.0 → 0.50.0

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.
Files changed (76) hide show
  1. package/api-availability.json +696 -624
  2. package/api-signatures.json +6799 -160
  3. package/api-targets.json +393 -2
  4. package/examples/translations.json +12 -0
  5. package/generated/b2d.d.ts +15 -0
  6. package/generated/bullet3d.d.ts +16 -0
  7. package/generated/font.d.ts +7 -3
  8. package/generated/graphics.d.ts +7 -0
  9. package/generated/gui.d.ts +5 -4
  10. package/generated/label.d.ts +3 -3
  11. package/generated/render.d.ts +16 -1
  12. package/generated/versions/defold-1.13.2/b2d.d.ts +709 -0
  13. package/generated/versions/defold-1.13.2/b2d_body.d.ts +593 -0
  14. package/generated/versions/defold-1.13.2/b2d_chain.d.ts +105 -0
  15. package/generated/versions/defold-1.13.2/b2d_fixture.d.ts +175 -0
  16. package/generated/versions/defold-1.13.2/b2d_joint.d.ts +1301 -0
  17. package/generated/versions/defold-1.13.2/b2d_shape.d.ts +423 -0
  18. package/generated/versions/defold-1.13.2/b2d_world.d.ts +308 -0
  19. package/generated/versions/defold-1.13.2/buffer.d.ts +192 -0
  20. package/generated/versions/defold-1.13.2/bullet3d.d.ts +91 -0
  21. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +433 -0
  22. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +818 -0
  23. package/generated/versions/defold-1.13.2/bullet3d_rigid_body.d.ts +429 -0
  24. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +123 -0
  25. package/generated/versions/defold-1.13.2/bullet3d_world.d.ts +492 -0
  26. package/generated/versions/defold-1.13.2/camera.d.ts +300 -0
  27. package/generated/versions/defold-1.13.2/collectionfactory.d.ts +148 -0
  28. package/generated/versions/defold-1.13.2/collectionproxy.d.ts +109 -0
  29. package/generated/versions/defold-1.13.2/compute.d.ts +107 -0
  30. package/generated/versions/defold-1.13.2/crash.d.ts +157 -0
  31. package/generated/versions/defold-1.13.2/editor-vm/http.d.ts +139 -0
  32. package/generated/versions/defold-1.13.2/editor-vm/image.d.ts +48 -0
  33. package/generated/versions/defold-1.13.2/editor-vm/json.d.ts +21 -0
  34. package/generated/versions/defold-1.13.2/editor-vm/localization.d.ts +42 -0
  35. package/generated/versions/defold-1.13.2/editor-vm/tilemap_tiles.d.ts +126 -0
  36. package/generated/versions/defold-1.13.2/editor-vm/zip.d.ts +38 -0
  37. package/generated/versions/defold-1.13.2/editor-vm/zlib.d.ts +24 -0
  38. package/generated/versions/defold-1.13.2/editor.d.ts +2177 -0
  39. package/generated/versions/defold-1.13.2/factory.d.ts +121 -0
  40. package/generated/versions/defold-1.13.2/font.d.ts +123 -0
  41. package/generated/versions/defold-1.13.2/go.d.ts +1166 -0
  42. package/generated/versions/defold-1.13.2/graphics.d.ts +613 -0
  43. package/generated/versions/defold-1.13.2/gui.d.ts +2212 -0
  44. package/generated/versions/defold-1.13.2/html5.d.ts +55 -0
  45. package/generated/versions/defold-1.13.2/http.d.ts +83 -0
  46. package/generated/versions/defold-1.13.2/image.d.ts +181 -0
  47. package/generated/versions/defold-1.13.2/index.d.ts +63 -0
  48. package/generated/versions/defold-1.13.2/json.d.ts +94 -0
  49. package/generated/versions/defold-1.13.2/kinds/editor-script.d.ts +14 -0
  50. package/generated/versions/defold-1.13.2/label.d.ts +164 -0
  51. package/generated/versions/defold-1.13.2/liveupdate.d.ts +143 -0
  52. package/generated/versions/defold-1.13.2/material.d.ts +490 -0
  53. package/generated/versions/defold-1.13.2/model.d.ts +287 -0
  54. package/generated/versions/defold-1.13.2/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.13.2/particlefx.d.ts +155 -0
  56. package/generated/versions/defold-1.13.2/physics.d.ts +789 -0
  57. package/generated/versions/defold-1.13.2/profiler.d.ts +228 -0
  58. package/generated/versions/defold-1.13.2/render.d.ts +1153 -0
  59. package/generated/versions/defold-1.13.2/resource.d.ts +1628 -0
  60. package/generated/versions/defold-1.13.2/socket.d.ts +797 -0
  61. package/generated/versions/defold-1.13.2/sound.d.ts +323 -0
  62. package/generated/versions/defold-1.13.2/sprite.d.ts +179 -0
  63. package/generated/versions/defold-1.13.2/sys.d.ts +754 -0
  64. package/generated/versions/defold-1.13.2/tilemap.d.ts +206 -0
  65. package/generated/versions/defold-1.13.2/timer.d.ts +136 -0
  66. package/generated/versions/defold-1.13.2/types.d.ts +61 -0
  67. package/generated/versions/defold-1.13.2/vmath.d.ts +775 -0
  68. package/generated/versions/defold-1.13.2/window.d.ts +196 -0
  69. package/generated/versions/defold-1.13.2/zlib.d.ts +41 -0
  70. package/identity-vocabulary.json +1 -0
  71. package/package.json +2 -2
  72. package/scripts/import-defold-release.ts +3 -31
  73. package/scripts/materialize-version.ts +13 -7
  74. package/scripts/regen.ts +63 -29
  75. package/scripts/sync-api-docs.ts +31 -2
  76. package/src/emit-dts.ts +25 -3
@@ -0,0 +1,775 @@
1
+ /** @noSelfInFile */
2
+ import type { Matrix4, Quaternion, Vector, Vector3, Vector4 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Functions for mathematical operations on vectors, matrices and quaternions.
7
+ *
8
+ * - The vector types (`vmath.vector3` and `vmath.vector4`) supports addition and subtraction
9
+ * with vectors of the same type. Vectors can be negated and multiplied (scaled) or divided by numbers.
10
+ * - The quaternion type (`vmath.quat`) supports multiplication with other quaternions.
11
+ * - The matrix type (`vmath.matrix4`) can be multiplied with numbers, other matrices
12
+ * and `vmath.vector4` values.
13
+ * - All types performs equality comparison by each component value.
14
+ *
15
+ * The following components are available for the various types:
16
+ *
17
+ * vector3
18
+ * : `x`, `y` and `z`. Example: `v.y`
19
+ *
20
+ * vector4
21
+ * : `x`, `y`, `z`, and `w`. Example: `v.w`
22
+ *
23
+ * quaternion
24
+ * : `x`, `y`, `z`, and `w`. Example: `q.w`
25
+ *
26
+ * matrix4
27
+ * : `m00` to `m33` where the first number is the row (starting from 0) and the second
28
+ * number is the column. Columns can be accessed with `c0` to `c3`, returning a `vector4`.
29
+ * Example: `m.m21` which is equal to `m.c1.z`
30
+ *
31
+ * vector
32
+ * : indexed by number 1 to the vector length. Example: `v[3]`
33
+ */
34
+ namespace vmath {
35
+ type vector = Vector;
36
+ /**
37
+ * Calculates the conjugate of a quaternion. The result is a
38
+ * quaternion with the same magnitudes but with the sign of
39
+ * the imaginary (vector) parts changed:
40
+ * `q* = [w, -v]`
41
+ *
42
+ * @param q1 - quaternion of which to calculate the conjugate
43
+ * @returns the conjugate
44
+ * @example
45
+ * ```ts
46
+ * const quat = vmath.quat(1, 2, 3, 4);
47
+ * print(vmath.conj(quat)); // => vmath.quat(-1, -2, -3, 4)
48
+ * ```
49
+ */
50
+ function conj(q1: Quaternion): Quaternion;
51
+ /**
52
+ * Given two linearly independent vectors P and Q, the cross product,
53
+ * P × Q, is a vector that is perpendicular to both P and Q and
54
+ * therefore normal to the plane containing them.
55
+ * If the two vectors have the same direction (or have the exact
56
+ * opposite direction from one another, i.e. are not linearly independent)
57
+ * or if either one has zero length, then their cross product is zero.
58
+ *
59
+ * @param v1 - first vector
60
+ * @param v2 - second vector
61
+ * @returns a new vector representing the cross product
62
+ * @example
63
+ * ```ts
64
+ * const vec1 = vmath.vector3(1, 0, 0);
65
+ * const vec2 = vmath.vector3(0, 1, 0);
66
+ * print(vmath.cross(vec1, vec2)); // => vmath.vector3(0, 0, 1)
67
+ * const vec3 = vmath.vector3(-1, 0, 0);
68
+ * print(vmath.cross(vec1, vec3)); // => vmath.vector3(0, -0, 0)
69
+ * ```
70
+ */
71
+ function cross(v1: Vector3, v2: Vector3): Vector3;
72
+ /**
73
+ * The returned value is a scalar defined as:
74
+ * `P ⋅ Q = |P| |Q| cos θ`
75
+ * where θ is the angle between the vectors P and Q.
76
+ *
77
+ * - If the dot product is positive then the angle between the vectors is below 90 degrees.
78
+ * - If the dot product is zero the vectors are perpendicular (at right-angles to each other).
79
+ * - If the dot product is negative then the angle between the vectors is more than 90 degrees.
80
+ *
81
+ * @param v1 - first vector
82
+ * @param v2 - second vector
83
+ * @returns dot product
84
+ * @example
85
+ * ```ts
86
+ * const vector1 = vmath.vector3(1, 0, 0);
87
+ * const vector2 = vmath.vector3(0, 1, 0);
88
+ *
89
+ * if (vmath.dot(vector1, vector2) === 0) {
90
+ * // The two vectors are perpendicular (at right-angles to each other)
91
+ * // ...
92
+ * }
93
+ * ```
94
+ */
95
+ function dot(v1: Vector3 | Vector4, v2: Vector3 | Vector4): number;
96
+ /**
97
+ * The resulting matrix is the inverse of the supplied matrix.
98
+ * For ortho-normal matrices, e.g. regular object transformation,
99
+ * use `vmath.ortho_inv()` instead.
100
+ * The specialized inverse for ortho-normalized matrices is much faster
101
+ * than the general inverse.
102
+ *
103
+ * @param m1 - matrix to invert
104
+ * @returns inverse of the supplied matrix
105
+ * @example
106
+ * ```ts
107
+ * const mat1 = vmath.matrix4_rotation_z(3.141592653);
108
+ * const mat2 = vmath.inv(mat1);
109
+ * // M * inv(M) = identity matrix
110
+ * print(mat1.mul(mat2)); // => vmath.matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
111
+ * ```
112
+ */
113
+ function inv(m1: Matrix4): Matrix4;
114
+ /**
115
+ * Returns the length of the supplied vector or quaternion.
116
+ * If you are comparing the lengths of vectors or quaternions, you should compare
117
+ * the length squared instead as it is slightly more efficient to calculate
118
+ * (it eliminates a square root calculation).
119
+ *
120
+ * @param v - value of which to calculate the length
121
+ * @returns length
122
+ * @example
123
+ * ```ts
124
+ * function below_max_speed(self: { velocity: Vector3 }, max_velocity: number) {
125
+ * if (vmath.length(self.velocity) < max_velocity) {
126
+ * // The speed (velocity vector) is below max.
127
+ *
128
+ * // TODO: max_velocity can be expressed as squared
129
+ * // so we can compare with length_sqr() instead.
130
+ * // ...
131
+ * }
132
+ * }
133
+ * ```
134
+ */
135
+ function length(v: Vector3 | Vector4 | Quaternion): number;
136
+ /**
137
+ * Returns the squared length of the supplied vector or quaternion.
138
+ *
139
+ * @param v - value of which to calculate the squared length
140
+ * @returns squared length
141
+ * @example
142
+ * ```ts
143
+ * const vector1 = vmath.vector3(1, 0, 0);
144
+ * const vector2 = vmath.vector3(0, 2, 0);
145
+ *
146
+ * if (vmath.length_sqr(vector1) < vmath.length_sqr(vector2)) {
147
+ * // Vector 1 has less magnitude than vector 2
148
+ * // ...
149
+ * }
150
+ * ```
151
+ */
152
+ function length_sqr(v: Vector3 | Vector4 | Quaternion): number;
153
+ /**
154
+ * The resulting identity matrix describes a transform with
155
+ * no translation or rotation.
156
+ *
157
+ * @returns identity matrix
158
+ * @example
159
+ * ```ts
160
+ * const mat = vmath.matrix4();
161
+ * print(mat); // => vmath.matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
162
+ * // get column 0:
163
+ * print(mat.c0); // => vmath.vector4(1, 0, 0, 0)
164
+ * // get the value in row 3 and column 2:
165
+ * print(mat.m32); // => 0
166
+ * ```
167
+ */
168
+ function matrix4(): Matrix4;
169
+ /**
170
+ * Creates a new matrix with all components set to the
171
+ * corresponding values from the supplied matrix. I.e.
172
+ * the function creates a copy of the given matrix.
173
+ *
174
+ * @param m1 - existing matrix
175
+ * @returns matrix which is a copy of the specified matrix
176
+ * @example
177
+ * ```ts
178
+ * const mat1 = vmath.matrix4_rotation_x(3.141592653);
179
+ * const mat2 = vmath.matrix4(mat1);
180
+ * if (mat1 === mat2) {
181
+ * // yes, they are equal
182
+ * print(mat2); // => vmath.matrix4(1, 0, 0, 0, 0, -1, 8.7422776573476e-08, 0, 0, -8.7422776573476e-08, -1, 0, 0, 0, 0, 1)
183
+ * }
184
+ * ```
185
+ */
186
+ function matrix4(m1: Matrix4): Matrix4;
187
+ /**
188
+ * The resulting matrix describes a rotation around the axis by the specified angle.
189
+ *
190
+ * @param v - axis
191
+ * @param angle - angle in radians
192
+ * @returns matrix represented by axis and angle
193
+ * @example
194
+ * ```ts
195
+ * const vec = vmath.vector4(1, 1, 0, 0);
196
+ * const axis = vmath.vector3(0, 0, 1); // z-axis
197
+ * const mat = vmath.matrix4_axis_angle(axis, 3.141592653);
198
+ * print(mat.mul(vec)); // => vmath.vector4(-0.99999994039536, -1.0000001192093, 0, 0)
199
+ * ```
200
+ */
201
+ function matrix4_axis_angle(v: Vector3, angle: number): Matrix4;
202
+ /**
203
+ * Creates a new matrix constructed from separate
204
+ * translation vector, roation quaternion and scale vector
205
+ *
206
+ * @param translation - translation
207
+ * @param rotation - rotation
208
+ * @param scale - scale
209
+ * @returns new matrix4
210
+ * @example
211
+ * ```ts
212
+ * const translation = vmath.vector3(103, -95, 14);
213
+ * const quat = vmath.quat(1, 2, 3, 4);
214
+ * const scale = vmath.vector3(1, 0.5, 0.5);
215
+ * const result = vmath.matrix4_compose(translation, quat, scale);
216
+ * print(result); // => vmath.matrix4(-25, -10, 11, 103, 28, -9.5, 2, -95, -10, 10, -4.5, 14, 0, 0, 0, 1)
217
+ * ```
218
+ */
219
+ function matrix4_compose(translation: Vector3 | Vector4, rotation: Quaternion, scale: Vector3): Matrix4;
220
+ /**
221
+ * Constructs a frustum matrix from the given values. The left, right,
222
+ * top and bottom coordinates of the view cone are expressed as distances
223
+ * from the center of the near clipping plane. The near and far coordinates
224
+ * are expressed as distances from the tip of the view frustum cone.
225
+ *
226
+ * @param left - coordinate for left clipping plane
227
+ * @param right - coordinate for right clipping plane
228
+ * @param bottom - coordinate for bottom clipping plane
229
+ * @param top - coordinate for top clipping plane
230
+ * @param near - coordinate for near clipping plane
231
+ * @param far - coordinate for far clipping plane
232
+ * @returns matrix representing the frustum
233
+ * @example
234
+ * ```ts
235
+ * // Construct a projection frustum with a vertical and horizontal FOV of
236
+ * // 45 degrees. Useful for rendering a square view.
237
+ * const proj = vmath.matrix4_frustum(-1, 1, -1, 1, 1, 1000);
238
+ * render.set_projection(proj);
239
+ * ```
240
+ */
241
+ function matrix4_frustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
242
+ /**
243
+ * The resulting matrix is created from the supplied look-at parameters.
244
+ * This is useful for constructing a view matrix for a camera or
245
+ * rendering in general.
246
+ *
247
+ * @param eye - eye position
248
+ * @param look_at - look-at position
249
+ * @param up - up vector
250
+ * @returns look-at matrix
251
+ * @example
252
+ * ```ts
253
+ * // Set up a perspective camera at z 100 with 45 degrees (pi/2) FOV, aspect ratio 4:3.
254
+ * const eye = vmath.vector3(0, 0, 100);
255
+ * const look_at = vmath.vector3(0, 0, 0);
256
+ * const up = vmath.vector3(0, 1, 0);
257
+ * const view = vmath.matrix4_look_at(eye, look_at, up);
258
+ * render.set_view(view);
259
+ * const proj = vmath.matrix4_perspective(3.141592 / 2, 4 / 3, 1, 1000);
260
+ * render.set_projection(proj);
261
+ * ```
262
+ */
263
+ function matrix4_look_at(eye: Vector3, look_at: Vector3, up: Vector3): Matrix4;
264
+ /**
265
+ * Creates an orthographic projection matrix.
266
+ * This is useful to construct a projection matrix for a camera or rendering in general.
267
+ *
268
+ * @param left - coordinate for left clipping plane
269
+ * @param right - coordinate for right clipping plane
270
+ * @param bottom - coordinate for bottom clipping plane
271
+ * @param top - coordinate for top clipping plane
272
+ * @param near - coordinate for near clipping plane
273
+ * @param far - coordinate for far clipping plane
274
+ * @returns orthographic projection matrix
275
+ * @example
276
+ * ```ts
277
+ * // Set up an orthographic projection based on the width and height of the
278
+ * // game window.
279
+ * const w = render.get_width();
280
+ * const h = render.get_height();
281
+ * const proj = vmath.matrix4_orthographic(-w / 2, w / 2, -h / 2, h / 2, -1000, 1000);
282
+ * render.set_projection(proj);
283
+ * ```
284
+ */
285
+ function matrix4_orthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4;
286
+ /**
287
+ * Creates a perspective projection matrix.
288
+ * This is useful to construct a projection matrix for a camera or rendering in general.
289
+ *
290
+ * @param fov - angle of the full vertical field of view in radians
291
+ * @param aspect - aspect ratio
292
+ * @param near - coordinate for near clipping plane
293
+ * @param far - coordinate for far clipping plane
294
+ * @returns perspective projection matrix
295
+ * @example
296
+ * ```ts
297
+ * // Set up a perspective camera at z 100 with 45 degrees (pi/2) FOV, aspect ratio 4:3.
298
+ * const eye = vmath.vector3(0, 0, 100);
299
+ * const look_at = vmath.vector3(0, 0, 0);
300
+ * const up = vmath.vector3(0, 1, 0);
301
+ * const view = vmath.matrix4_look_at(eye, look_at, up);
302
+ * render.set_view(view);
303
+ * const proj = vmath.matrix4_perspective(3.141592 / 2, 4 / 3, 1, 1000);
304
+ * render.set_projection(proj);
305
+ * ```
306
+ */
307
+ function matrix4_perspective(fov: number, aspect: number, near: number, far: number): Matrix4;
308
+ /**
309
+ * The resulting matrix describes the same rotation as the quaternion, but does not have any translation (also like the quaternion).
310
+ *
311
+ * @param q - quaternion to create matrix from
312
+ * @returns matrix represented by quaternion
313
+ * @example
314
+ * ```ts
315
+ * const vec = vmath.vector4(1, 1, 0, 0);
316
+ * const quat = vmath.quat_rotation_z(3.141592653);
317
+ * const mat = vmath.matrix4_quat(quat);
318
+ * print(mat.mul(vec)); // => vmath.matrix4_frustum(-1, 1, -1, 1, 1, 1000)
319
+ * ```
320
+ */
321
+ function matrix4_quat(q: Quaternion): Matrix4;
322
+ /**
323
+ * The resulting matrix describes a rotation around the x-axis
324
+ * by the specified angle.
325
+ *
326
+ * @param angle - angle in radians around x-axis
327
+ * @returns matrix from rotation around x-axis
328
+ * @example
329
+ * ```ts
330
+ * const vec = vmath.vector4(1, 1, 0, 0);
331
+ * const mat = vmath.matrix4_rotation_x(3.141592653);
332
+ * print(mat.mul(vec)); // => vmath.vector4(1, -1, -8.7422776573476e-08, 0)
333
+ * ```
334
+ */
335
+ function matrix4_rotation_x(angle: number): Matrix4;
336
+ /**
337
+ * The resulting matrix describes a rotation around the y-axis
338
+ * by the specified angle.
339
+ *
340
+ * @param angle - angle in radians around y-axis
341
+ * @returns matrix from rotation around y-axis
342
+ * @example
343
+ * ```ts
344
+ * const vec = vmath.vector4(1, 1, 0, 0);
345
+ * const mat = vmath.matrix4_rotation_y(3.141592653);
346
+ * print(mat.mul(vec)); // => vmath.vector4(-1, 1, 8.7422776573476e-08, 0)
347
+ * ```
348
+ */
349
+ function matrix4_rotation_y(angle: number): Matrix4;
350
+ /**
351
+ * The resulting matrix describes a rotation around the z-axis
352
+ * by the specified angle.
353
+ *
354
+ * @param angle - angle in radians around z-axis
355
+ * @returns matrix from rotation around z-axis
356
+ * @example
357
+ * ```ts
358
+ * const vec = vmath.vector4(1, 1, 0, 0);
359
+ * const mat = vmath.matrix4_rotation_z(3.141592653);
360
+ * print(mat.mul(vec)); // => vmath.vector4(-0.99999994039536, -1.0000001192093, 0, 0)
361
+ * ```
362
+ */
363
+ function matrix4_rotation_z(angle: number): Matrix4;
364
+ /**
365
+ * Creates a new matrix constructed from scale vector
366
+ *
367
+ * @param scale - scale
368
+ * @returns new matrix4
369
+ * @example
370
+ * ```ts
371
+ * const scale = vmath.vector3(1, 0.5, 0.5);
372
+ * const result = vmath.matrix4_scale(scale);
373
+ * print(result); // => vmath.matrix4(1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
374
+ * ```
375
+ */
376
+ function matrix4_scale(scale: Vector3): Matrix4;
377
+ /**
378
+ * creates a new matrix4 from uniform scale
379
+ *
380
+ * @param scale - scale
381
+ * @returns new matrix4
382
+ * @example
383
+ * ```ts
384
+ * const result = vmath.matrix4_scale(0.5);
385
+ * print(result); // => vmath.matrix4(0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
386
+ * ```
387
+ */
388
+ function matrix4_scale(scale: number): Matrix4;
389
+ /**
390
+ * Creates a new matrix4 from three scale components
391
+ *
392
+ * @param scale_x - scale along X axis
393
+ * @param scale_y - sclae along Y axis
394
+ * @param scale_z - scale along Z asis
395
+ * @returns new matrix4
396
+ * @example
397
+ * ```ts
398
+ * const result = vmath.matrix4_scale(1, 0.5, 0.5);
399
+ * print(result); // => vmath.matrix4(1, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 1)
400
+ * ```
401
+ */
402
+ function matrix4_scale(scale_x: number, scale_y: number, scale_z: number): Matrix4;
403
+ /**
404
+ * The resulting matrix describes a translation of a point
405
+ * in euclidean space.
406
+ *
407
+ * @param position - position vector to create matrix from
408
+ * @returns matrix from the supplied position vector
409
+ * @example
410
+ * ```ts
411
+ * // Set camera view from custom view and translation matrices.
412
+ * const mat_trans = vmath.matrix4_translation(vmath.vector3(0, 10, 100));
413
+ * const mat_view = vmath.matrix4_rotation_y(-3.141592 / 4);
414
+ * render.set_view(mat_view.mul(mat_trans));
415
+ * ```
416
+ */
417
+ function matrix4_translation(position: Vector3 | Vector4): Matrix4;
418
+ /**
419
+ * The resulting matrix is the inverse of the supplied matrix.
420
+ * The supplied matrix has to be an ortho-normal matrix, e.g.
421
+ * describe a regular object transformation.
422
+ * For matrices that are not ortho-normal
423
+ * use the general inverse `vmath.inv()` instead.
424
+ *
425
+ * @param m1 - ortho-normalized matrix to invert
426
+ * @returns inverse of the supplied matrix
427
+ * @example
428
+ * ```ts
429
+ * const mat1 = vmath.matrix4_rotation_z(3.141592653);
430
+ * const mat2 = vmath.ortho_inv(mat1);
431
+ * // M * inv(M) = identity matrix
432
+ * print(mat1.mul(mat2)); // => vmath.matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
433
+ * ```
434
+ */
435
+ function ortho_inv(m1: Matrix4): Matrix4;
436
+ /**
437
+ * Calculates the extent the projection of the first vector onto the second.
438
+ * The returned value is a scalar p defined as:
439
+ * `p = |P| cos θ / |Q|`
440
+ * where θ is the angle between the vectors P and Q.
441
+ *
442
+ * @param v1 - vector to be projected on the second
443
+ * @param v2 - vector onto which the first will be projected, must not have zero length
444
+ * @returns the projected extent of the first vector onto the second
445
+ * @example
446
+ * ```ts
447
+ * const v1 = vmath.vector3(1, 1, 0);
448
+ * const v2 = vmath.vector3(2, 0, 0);
449
+ * print(vmath.project(v1, v2)); // => 0.5
450
+ * ```
451
+ */
452
+ function project(v1: Vector3, v2: Vector3): number;
453
+ /**
454
+ * Creates a new identity quaternion. The identity
455
+ * quaternion is equal to:
456
+ * `vmath.quat(0, 0, 0, 1)`
457
+ *
458
+ * @returns new identity quaternion
459
+ * @example
460
+ * ```ts
461
+ * const quat = vmath.quat();
462
+ * print(quat); // => vmath.quat(0, 0, 0, 1)
463
+ * print(quat.w); // => 1
464
+ * ```
465
+ */
466
+ function quat(): Quaternion;
467
+ /**
468
+ * Creates a new quaternion with all components set to the
469
+ * corresponding values from the supplied quaternion. I.e.
470
+ * This function creates a copy of the given quaternion.
471
+ *
472
+ * @param q1 - existing quaternion
473
+ * @returns new quaternion
474
+ * @example
475
+ * ```ts
476
+ * const quat1 = vmath.quat(1, 2, 3, 4);
477
+ * const quat2 = vmath.quat(quat1);
478
+ * if (quat1 === quat2) {
479
+ * // yes, they are equal
480
+ * print(quat2); // => vmath.quat(1, 2, 3, 4)
481
+ * }
482
+ * ```
483
+ */
484
+ function quat(q1: Quaternion): Quaternion;
485
+ /**
486
+ * Creates a new quaternion with the components set
487
+ * according to the supplied parameter values.
488
+ *
489
+ * @param x - x coordinate
490
+ * @param y - y coordinate
491
+ * @param z - z coordinate
492
+ * @param w - w coordinate
493
+ * @returns new quaternion
494
+ * @example
495
+ * ```ts
496
+ * const quat = vmath.quat(1, 2, 3, 4);
497
+ * print(quat); // => vmath.quat(1, 2, 3, 4)
498
+ * ```
499
+ */
500
+ function quat(x: number, y: number, z: number, w: number): Quaternion;
501
+ /**
502
+ * The resulting quaternion describes a rotation of `angle`
503
+ * radians around the axis described by the unit vector `v`.
504
+ *
505
+ * @param v - axis
506
+ * @param angle - angle
507
+ * @returns quaternion representing the axis-angle rotation
508
+ * @example
509
+ * ```ts
510
+ * const axis = vmath.vector3(1, 0, 0);
511
+ * const rot = vmath.quat_axis_angle(axis, 3.141592653);
512
+ * const vec = vmath.vector3(1, 1, 0);
513
+ * print(vmath.rotate(rot, vec)); // => vmath.vector3(1, -1, -8.7422776573476e-08)
514
+ * ```
515
+ */
516
+ function quat_axis_angle(v: Vector3, angle: number): Quaternion;
517
+ /**
518
+ * The resulting quaternion describes the rotation from the
519
+ * identity quaternion (no rotation) to the coordinate system
520
+ * as described by the given x, y and z base unit vectors.
521
+ *
522
+ * @param x - x base vector
523
+ * @param y - y base vector
524
+ * @param z - z base vector
525
+ * @returns quaternion representing the rotation of the specified base vectors
526
+ * @example
527
+ * ```ts
528
+ * // Axis rotated 90 degrees around z.
529
+ * const rot_x = vmath.vector3(0, -1, 0);
530
+ * const rot_y = vmath.vector3(1, 0, 0);
531
+ * const z = vmath.vector3(0, 0, 1);
532
+ * const rot1 = vmath.quat_basis(rot_x, rot_y, z);
533
+ * const rot2 = vmath.quat_from_to(vmath.vector3(0, 1, 0), vmath.vector3(1, 0, 0));
534
+ * if (rot1 === rot2) {
535
+ * // These quaternions are equal!
536
+ * print(rot2); // => vmath.quat(0, 0, -0.70710676908493, 0.70710676908493)
537
+ * }
538
+ * ```
539
+ */
540
+ function quat_basis(x: Vector3, y: Vector3, z: Vector3): Quaternion;
541
+ /**
542
+ * The resulting quaternion describes the rotation that,
543
+ * if applied to the first vector, would rotate the first
544
+ * vector to the second. The two vectors must be unit
545
+ * vectors (of length 1).
546
+ * The result is undefined if the two vectors point in opposite directions
547
+ *
548
+ * @param v1 - first unit vector, before rotation
549
+ * @param v2 - second unit vector, after rotation
550
+ * @returns quaternion representing the rotation from first to second vector
551
+ * @example
552
+ * ```ts
553
+ * const v1 = vmath.vector3(1, 0, 0);
554
+ * const v2 = vmath.vector3(0, 1, 0);
555
+ * const rot = vmath.quat_from_to(v1, v2);
556
+ * print(vmath.rotate(rot, v1)); // => vmath.vector3(0, 0.99999994039536, 0)
557
+ * ```
558
+ */
559
+ function quat_from_to(v1: Vector3, v2: Vector3): Quaternion;
560
+ /**
561
+ * Creates a new quaternion with the components set
562
+ * according to the supplied parameter values.
563
+ *
564
+ * @param matrix - source matrix4
565
+ * @returns new quaternion
566
+ */
567
+ function quat_matrix4(matrix: Matrix4): Quaternion;
568
+ /**
569
+ * The resulting quaternion describes a rotation of `angle`
570
+ * radians around the x-axis.
571
+ *
572
+ * @param angle - angle in radians around x-axis
573
+ * @returns quaternion representing the rotation around the x-axis
574
+ * @example
575
+ * ```ts
576
+ * const rot = vmath.quat_rotation_x(3.141592653);
577
+ * const vec = vmath.vector3(1, 1, 0);
578
+ * print(vmath.rotate(rot, vec)); // => vmath.vector3(1, -1, -8.7422776573476e-08)
579
+ * ```
580
+ */
581
+ function quat_rotation_x(angle: number): Quaternion;
582
+ /**
583
+ * The resulting quaternion describes a rotation of `angle`
584
+ * radians around the y-axis.
585
+ *
586
+ * @param angle - angle in radians around y-axis
587
+ * @returns quaternion representing the rotation around the y-axis
588
+ * @example
589
+ * ```ts
590
+ * const rot = vmath.quat_rotation_y(3.141592653);
591
+ * const vec = vmath.vector3(1, 1, 0);
592
+ * print(vmath.rotate(rot, vec)); // => vmath.vector3(-1, 1, 8.7422776573476e-08)
593
+ * ```
594
+ */
595
+ function quat_rotation_y(angle: number): Quaternion;
596
+ /**
597
+ * The resulting quaternion describes a rotation of `angle`
598
+ * radians around the z-axis.
599
+ *
600
+ * @param angle - angle in radians around z-axis
601
+ * @returns quaternion representing the rotation around the z-axis
602
+ * @example
603
+ * ```ts
604
+ * const rot = vmath.quat_rotation_z(3.141592653);
605
+ * const vec = vmath.vector3(1, 1, 0);
606
+ * print(vmath.rotate(rot, vec)); // => vmath.vector3(-0.99999988079071, -1, 0)
607
+ * ```
608
+ */
609
+ function quat_rotation_z(angle: number): Quaternion;
610
+ /**
611
+ * Converts a quaternion into euler angles (r0, r1, r2), based on YZX rotation order.
612
+ * To handle gimbal lock (singularity at r1 ~ +/- 90 degrees), the cut off is at r0 = +/- 88.85 degrees, which snaps to +/- 90.
613
+ * The provided quaternion is expected to be normalized.
614
+ * The error is guaranteed to be less than +/- 0.02 degrees
615
+ *
616
+ * @param q - source quaternion
617
+ * @example
618
+ * ```ts
619
+ * const q = vmath.quat_rotation_z(math.rad(90));
620
+ * print(vmath.quat_to_euler(q)); // => 0 0 90
621
+ *
622
+ * const q2 = vmath.quat_rotation_y(math.rad(45)).mul(vmath.quat_rotation_z(math.rad(90)));
623
+ * const [ex, ey, ez] = vmath.quat_to_euler(q2);
624
+ * const v = vmath.vector3(ex, ey, ez);
625
+ * print(v); // => vmath.vector3(0, 45, 90)
626
+ * ```
627
+ */
628
+ function quat_to_euler(q: Quaternion): LuaMultiReturn<[number, number, number]>;
629
+ /**
630
+ * Returns a new vector from the supplied vector that is
631
+ * rotated by the rotation described by the supplied
632
+ * quaternion.
633
+ *
634
+ * @param q - quaternion
635
+ * @param v1 - vector to rotate
636
+ * @returns the rotated vector
637
+ * @example
638
+ * ```ts
639
+ * const vec = vmath.vector3(1, 1, 0);
640
+ * const rot = vmath.quat_rotation_z(3.141592563);
641
+ * print(vmath.rotate(rot, vec)); // => vmath.vector3(-1.0000002384186, -0.99999988079071, 0)
642
+ * ```
643
+ */
644
+ function rotate(q: Quaternion, v1: Vector3): Vector3;
645
+ /**
646
+ * Creates a new zero vector with all components set to 0.
647
+ *
648
+ * @returns new zero vector
649
+ * @example
650
+ * ```ts
651
+ * const vec = vmath.vector3();
652
+ * pprint(vec); // => vmath.vector3(0, 0, 0)
653
+ * print(vec.x); // => 0
654
+ * ```
655
+ */
656
+ function vector3(): Vector3;
657
+ /**
658
+ * Creates a new vector with all components set to the
659
+ * supplied scalar value.
660
+ *
661
+ * @param n - scalar value to splat
662
+ * @returns new vector
663
+ * @example
664
+ * ```ts
665
+ * const vec = vmath.vector3(1.0);
666
+ * print(vec); // => vmath.vector3(1, 1, 1)
667
+ * print(vec.x); // => 1
668
+ * ```
669
+ */
670
+ function vector3(n: number): Vector3;
671
+ /**
672
+ * Creates a new vector with all components set to the
673
+ * corresponding values from the supplied vector. I.e.
674
+ * This function creates a copy of the given vector.
675
+ *
676
+ * @param v1 - existing vector
677
+ * @returns new vector
678
+ * @example
679
+ * ```ts
680
+ * const vec1 = vmath.vector3(1.0);
681
+ * const vec2 = vmath.vector3(vec1);
682
+ * if (vec1 === vec2) {
683
+ * // yes, they are equal
684
+ * print(vec2); // => vmath.vector3(1, 1, 1)
685
+ * }
686
+ * ```
687
+ */
688
+ function vector3(v1: Vector3): Vector3;
689
+ /**
690
+ * Creates a new vector with the components set to the
691
+ * supplied values.
692
+ *
693
+ * @param x - x coordinate
694
+ * @param y - y coordinate
695
+ * @param z - z coordinate
696
+ * @returns new vector
697
+ * @example
698
+ * ```ts
699
+ * const vec = vmath.vector3(1.0, 2.0, 3.0);
700
+ * print(vec); // => vmath.vector3(1, 2, 3)
701
+ * print(vec.unm()); // => vmath.vector3(-1, -2, -3)
702
+ * print(vec.mul(2)); // => vmath.vector3(2, 4, 6)
703
+ * print(vec.add(vmath.vector3(2.0))); // => vmath.vector3(3, 4, 5)
704
+ * print(vec.sub(vmath.vector3(2.0))); // => vmath.vector3(-1, 0, 1)
705
+ * ```
706
+ */
707
+ function vector3(x: number, y: number, z: number): Vector3;
708
+ /**
709
+ * Creates a new zero vector with all components set to 0.
710
+ *
711
+ * @returns new zero vector
712
+ * @example
713
+ * ```ts
714
+ * const vec = vmath.vector4();
715
+ * print(vec); // => vmath.vector4(0, 0, 0, 0)
716
+ * print(vec.w); // => 0
717
+ * ```
718
+ */
719
+ function vector4(): Vector4;
720
+ /**
721
+ * Creates a new vector with all components set to the
722
+ * supplied scalar value.
723
+ *
724
+ * @param n - scalar value to splat
725
+ * @returns new vector
726
+ * @example
727
+ * ```ts
728
+ * const vec = vmath.vector4(1.0);
729
+ * print(vec); // => vmath.vector4(1, 1, 1, 1)
730
+ * print(vec.w); // => 1
731
+ * ```
732
+ */
733
+ function vector4(n: number): Vector4;
734
+ /**
735
+ * Creates a new vector with all components set to the
736
+ * corresponding values from the supplied vector. I.e.
737
+ * This function creates a copy of the given vector.
738
+ *
739
+ * @param v1 - existing vector
740
+ * @returns new vector
741
+ * @example
742
+ * ```ts
743
+ * const vec1 = vmath.vector4(1.0);
744
+ * const vec2 = vmath.vector4(vec1);
745
+ * if (vec1 === vec2) {
746
+ * // yes, they are equal
747
+ * print(vec2); // => vmath.vector4(1, 1, 1, 1)
748
+ * }
749
+ * ```
750
+ */
751
+ function vector4(v1: Vector4): Vector4;
752
+ /**
753
+ * Creates a new vector with the components set to the
754
+ * supplied values.
755
+ *
756
+ * @param x - x coordinate
757
+ * @param y - y coordinate
758
+ * @param z - z coordinate
759
+ * @param w - w coordinate
760
+ * @returns new vector
761
+ * @example
762
+ * ```ts
763
+ * const vec = vmath.vector4(1.0, 2.0, 3.0, 4.0);
764
+ * print(vec); // => vmath.vector4(1, 2, 3, 4)
765
+ * print(vec.unm()); // => vmath.vector4(-1, -2, -3, -4)
766
+ * print(vec.mul(2)); // => vmath.vector4(2, 4, 6, 8)
767
+ * print(vec.add(vmath.vector4(2.0))); // => vmath.vector4(3, 4, 5, 6)
768
+ * print(vec.sub(vmath.vector4(2.0))); // => vmath.vector4(-1, 0, 1, 2)
769
+ * ```
770
+ */
771
+ function vector4(x: number, y: number, z: number, w: number): Vector4;
772
+ }
773
+ }
774
+
775
+ export {};