@galacean/engine-math 0.0.0-experimental-backup.3 → 0.0.0-experimental-backup.4

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.
@@ -0,0 +1,219 @@
1
+ import { IClone } from "./IClone";
2
+ import { ICopy } from "./ICopy";
3
+ /**
4
+ * Describes a 2D-vector.
5
+ */
6
+ export declare class Vector2 implements IClone<Vector2>, ICopy<Vector2Like, Vector2> {
7
+ /**
8
+ * Determines the sum of two vectors.
9
+ * @param left - The first vector to add
10
+ * @param right - The second vector to add
11
+ * @param out - The sum of two vectors
12
+ */
13
+ static add(left: Vector2, right: Vector2, out: Vector2): void;
14
+ /**
15
+ * Determines the difference between two vectors.
16
+ * @param left - The first vector to subtract
17
+ * @param right - The second vector to subtract
18
+ * @param out - The difference between two vectors
19
+ */
20
+ static subtract(left: Vector2, right: Vector2, out: Vector2): void;
21
+ /**
22
+ * Determines the product of two vectors.
23
+ * @param left - The first vector to multiply
24
+ * @param right - The second vector to multiply
25
+ * @param out - The product of two vectors
26
+ */
27
+ static multiply(left: Vector2, right: Vector2, out: Vector2): void;
28
+ /**
29
+ * Determines the divisor of two vectors.
30
+ * @param left - The first vector to divide
31
+ * @param right - The second vector to divide
32
+ * @param out - The divisor of two vectors
33
+ */
34
+ static divide(left: Vector2, right: Vector2, out: Vector2): void;
35
+ /**
36
+ * Determines the dot product of two vectors.
37
+ * @param left - The first vector to dot
38
+ * @param right - The second vector to dot
39
+ * @returns The dot product of two vectors
40
+ */
41
+ static dot(left: Vector2, right: Vector2): number;
42
+ /**
43
+ * Determines the distance of two vectors.
44
+ * @param left - The first vector
45
+ * @param right - The second vector
46
+ * @returns The distance of two vectors
47
+ */
48
+ static distance(left: Vector2, right: Vector2): number;
49
+ /**
50
+ * Determines the squared distance of two vectors.
51
+ * @param left - The first vector
52
+ * @param right - The second vector
53
+ * @returns The squared distance of two vectors
54
+ */
55
+ static distanceSquared(left: Vector2, right: Vector2): number;
56
+ /**
57
+ * Determines whether the specified vectors are equals.
58
+ * @param left - The first vector to compare
59
+ * @param right - The second vector to compare
60
+ * @returns True if the specified vectors are equals, false otherwise
61
+ */
62
+ static equals(left: Vector2, right: Vector2): boolean;
63
+ /**
64
+ * Performs a linear interpolation between two vectors.
65
+ * @param left - The first vector
66
+ * @param right - The second vector
67
+ * @param t - The blend amount where 0 returns left and 1 right
68
+ * @param out - The result of linear blending between two vectors
69
+ */
70
+ static lerp(left: Vector2, right: Vector2, t: number, out: Vector2): void;
71
+ /**
72
+ * Calculate a vector containing the largest components of the specified vectors.
73
+ * @param left - The first vector
74
+ * @param right - The second vector
75
+ * @param out - The vector containing the largest components of the specified vectors
76
+ */
77
+ static max(left: Vector2, right: Vector2, out: Vector2): void;
78
+ /**
79
+ * Calculate a vector containing the smallest components of the specified vectors.
80
+ * @param left - The first vector
81
+ * @param right - The second vector
82
+ * @param out - The vector containing the smallest components of the specified vectors
83
+ */
84
+ static min(left: Vector2, right: Vector2, out: Vector2): void;
85
+ /**
86
+ * Reverses the direction of a given vector.
87
+ * @param left - The vector to negate
88
+ * @param out - The vector facing in the opposite direction
89
+ */
90
+ static negate(left: Vector2, out: Vector2): void;
91
+ /**
92
+ * Converts the vector into a unit vector.
93
+ * @param left - The vector to normalize
94
+ * @param out - The normalized vector
95
+ */
96
+ static normalize(left: Vector2, out: Vector2): void;
97
+ /**
98
+ * Scale a vector by the given value.
99
+ * @param left - The vector to scale
100
+ * @param s - The amount by which to scale the vector
101
+ * @param out - The scaled vector
102
+ */
103
+ static scale(left: Vector2, s: number, out: Vector2): void;
104
+ /**
105
+ * The x component of the vector.
106
+ */
107
+ get x(): number;
108
+ set x(value: number);
109
+ /**
110
+ * The y component of the vector.
111
+ */
112
+ get y(): number;
113
+ set y(value: number);
114
+ /**
115
+ * Constructor of Vector2.
116
+ * @param x - The x component of the vector, default 0
117
+ * @param y - The y component of the vector, default 0
118
+ */
119
+ constructor(x?: number, y?: number);
120
+ /**
121
+ * Set the value of this vector.
122
+ * @param x - The x component of the vector
123
+ * @param y - The y component of the vector
124
+ * @returns This vector
125
+ */
126
+ set(x: number, y: number): Vector2;
127
+ /**
128
+ * Determines the sum of this vector and the specified vector.
129
+ * @param right - The specified vector
130
+ * @returns This vector
131
+ */
132
+ add(right: Vector2): Vector2;
133
+ /**
134
+ * Determines the difference of this vector and the specified vector.
135
+ * @param right - The specified vector
136
+ * @returns This vector
137
+ */
138
+ subtract(right: Vector2): Vector2;
139
+ /**
140
+ * Determines the product of this vector and the specified vector.
141
+ * @param right - The specified vector
142
+ * @returns This vector
143
+ */
144
+ multiply(right: Vector2): Vector2;
145
+ /**
146
+ * Determines the divisor of this vector and the specified vector.
147
+ * @param right - The specified vector
148
+ * @returns This vector
149
+ */
150
+ divide(right: Vector2): Vector2;
151
+ /**
152
+ * Calculate the length of this vector.
153
+ * @returns The length of this vector
154
+ */
155
+ length(): number;
156
+ /**
157
+ * Calculate the squared length of this vector.
158
+ * @returns The squared length of this vector
159
+ */
160
+ lengthSquared(): number;
161
+ /**
162
+ * Reverses the direction of this vector.
163
+ * @returns This vector
164
+ */
165
+ negate(): Vector2;
166
+ /**
167
+ * Converts this vector into a unit vector.
168
+ * @returns This vector
169
+ */
170
+ normalize(): Vector2;
171
+ /**
172
+ * Scale this vector by the given value.
173
+ * @param s - The amount by which to scale the vector
174
+ * @returns This vector
175
+ */
176
+ scale(s: number): Vector2;
177
+ /**
178
+ * Creates a clone of this vector.
179
+ * @returns A clone of this vector
180
+ */
181
+ clone(): Vector2;
182
+ /**
183
+ * Copy from vector2 like object.
184
+ * @param source - Vector2 like object
185
+ * @returns This vector
186
+ */
187
+ copyFrom(source: Vector2Like): Vector2;
188
+ /**
189
+ * Copy to vector2 like object.
190
+ * @param target - Vector2 like object
191
+ * @returns This Vector2 like object
192
+ */
193
+ copyTo(target: Vector2Like): Vector2Like;
194
+ /**
195
+ * Copy the value of this vector from an array.
196
+ * @param array - The array
197
+ * @param offset - The start offset of the array
198
+ * @returns This vector
199
+ */
200
+ copyFromArray(array: ArrayLike<number>, offset?: number): Vector2;
201
+ /**
202
+ * Copy the value of this vector to an array.
203
+ * @param out - The array
204
+ * @param outOffset - The start offset of the array
205
+ */
206
+ copyToArray(out: number[] | Float32Array | Float64Array, outOffset?: number): void;
207
+ /**
208
+ * Serialize this vector to a JSON representation.
209
+ * @returns A JSON representation of this vector
210
+ */
211
+ toJSON(): Vector2Like;
212
+ }
213
+ interface Vector2Like {
214
+ /** {@inheritDoc Vector2.x} */
215
+ x: number;
216
+ /** {@inheritDoc Vector2.y} */
217
+ y: number;
218
+ }
219
+ export {};
@@ -0,0 +1,321 @@
1
+ import { IClone } from "./IClone";
2
+ import { ICopy } from "./ICopy";
3
+ import { Matrix } from "./Matrix";
4
+ import { Quaternion } from "./Quaternion";
5
+ import { Vector4 } from "./Vector4";
6
+ /**
7
+ * Describes a 3D-vector.
8
+ */
9
+ export declare class Vector3 implements IClone<Vector3>, ICopy<Vector3Like, Vector3> {
10
+ /**
11
+ * Determines the sum of two vectors.
12
+ * @param left - The first vector to add
13
+ * @param right - The second vector to add
14
+ * @param out - The sum of two vectors
15
+ */
16
+ static add(left: Vector3, right: Vector3, out: Vector3): void;
17
+ /**
18
+ * Determines the difference between two vectors.
19
+ * @param left - The first vector to subtract
20
+ * @param right - The second vector to subtract
21
+ * @param out - The difference between two vectors
22
+ */
23
+ static subtract(left: Vector3, right: Vector3, out: Vector3): void;
24
+ /**
25
+ * Determines the product of two vectors.
26
+ * @param left - The first vector to multiply
27
+ * @param right - The second vector to multiply
28
+ * @param out - The product of two vectors
29
+ */
30
+ static multiply(left: Vector3, right: Vector3, out: Vector3): void;
31
+ /**
32
+ * Determines the divisor of two vectors.
33
+ * @param left - The first vector to divide
34
+ * @param right - The second vector to divide
35
+ * @param out - The divisor of two vectors
36
+ */
37
+ static divide(left: Vector3, right: Vector3, out: Vector3): void;
38
+ /**
39
+ * Determines the dot product of two vectors.
40
+ * @param left - The first vector to dot
41
+ * @param right - The second vector to dot
42
+ * @returns The dot product of two vectors
43
+ */
44
+ static dot(left: Vector3, right: Vector3): number;
45
+ /**
46
+ * Determines the cross product of two vectors.
47
+ * @param left - The first vector to cross
48
+ * @param right - The second vector to cross
49
+ * @param out - The cross product of two vectors
50
+ */
51
+ static cross(left: Vector3, right: Vector3, out: Vector3): void;
52
+ /**
53
+ * Determines the distance of two vectors.
54
+ * @param a - The first vector
55
+ * @param b - The second vector
56
+ * @returns The distance of two vectors
57
+ */
58
+ static distance(a: Vector3, b: Vector3): number;
59
+ /**
60
+ * Determines the squared distance of two vectors.
61
+ * @param a - The first vector
62
+ * @param b - The second vector
63
+ * @returns The squared distance of two vectors
64
+ */
65
+ static distanceSquared(a: Vector3, b: Vector3): number;
66
+ /**
67
+ * Determines whether the specified vectors are equals.
68
+ * @param left - The first vector to compare
69
+ * @param right - The second vector to compare
70
+ * @returns True if the specified vectors are equals, false otherwise
71
+ */
72
+ static equals(left: Vector3, right: Vector3): boolean;
73
+ /**
74
+ * Performs a linear interpolation between two vectors.
75
+ * @param start - The first vector
76
+ * @param end - The second vector
77
+ * @param t - The blend amount where 0 returns start and 1 end
78
+ * @param out - The result of linear blending between two vectors
79
+ */
80
+ static lerp(start: Vector3, end: Vector3, t: number, out: Vector3): void;
81
+ /**
82
+ * Calculate a vector containing the largest components of the specified vectors.
83
+ * @param left - The first vector
84
+ * @param right - The second vector
85
+ * @param out - The vector containing the largest components of the specified vectors
86
+ */
87
+ static max(left: Vector3, right: Vector3, out: Vector3): void;
88
+ /**
89
+ * Calculate a vector containing the smallest components of the specified vectors.
90
+ * @param left - The first vector
91
+ * @param right - The second vector
92
+ * @param out - The vector containing the smallest components of the specified vectors
93
+ */
94
+ static min(left: Vector3, right: Vector3, out: Vector3): void;
95
+ /**
96
+ * Reverses the direction of a given vector.
97
+ * @param a - The vector to negate
98
+ * @param out - The vector facing in the opposite direction
99
+ */
100
+ static negate(a: Vector3, out: Vector3): void;
101
+ /**
102
+ * Converts the vector into a unit vector.
103
+ * @param a - The vector to normalize
104
+ * @param out - The normalized vector
105
+ */
106
+ static normalize(a: Vector3, out: Vector3): void;
107
+ /**
108
+ * Scale a vector by the given value.
109
+ * @param a - The vector to scale
110
+ * @param s - The amount by which to scale the vector
111
+ * @param out - The scaled vector
112
+ */
113
+ static scale(a: Vector3, s: number, out: Vector3): void;
114
+ /**
115
+ * Performs a normal transformation using the given 4x4 matrix.
116
+ * @remarks
117
+ * A normal transform performs the transformation with the assumption that the w component
118
+ * is zero. This causes the fourth row and fourth column of the matrix to be unused. The
119
+ * end result is a vector that is not translated, but all other transformation properties
120
+ * apply. This is often preferred for normal vectors as normals purely represent direction
121
+ * rather than location because normal vectors should not be translated.
122
+ * @param v - The normal vector to transform
123
+ * @param m - The transform matrix
124
+ * @param out - The transformed normal
125
+ */
126
+ static transformNormal(v: Vector3, m: Matrix, out: Vector3): void;
127
+ /**
128
+ * Performs a transformation using the given 4x4 matrix.
129
+ * @param v - The vector to transform
130
+ * @param m - The transform matrix
131
+ * @param out - The transformed vector3
132
+ */
133
+ static transformToVec3(v: Vector3, m: Matrix, out: Vector3): void;
134
+ /**
135
+ * Performs a transformation from vector3 to vector4 using the given 4x4 matrix.
136
+ * @param v - The vector to transform
137
+ * @param m - The transform matrix
138
+ * @param out - The transformed vector4
139
+ */
140
+ static transformToVec4(v: Vector3, m: Matrix, out: Vector4): void;
141
+ /**
142
+ * Performs a coordinate transformation using the given 4x4 matrix.
143
+ *
144
+ * @remarks
145
+ * A coordinate transform performs the transformation with the assumption that the w component
146
+ * is one. The four dimensional vector obtained from the transformation operation has each
147
+ * component in the vector divided by the w component. This forces the w-component to be one and
148
+ * therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
149
+ * with coordinates as the w component can safely be ignored.
150
+ * @param v - The coordinate vector to transform
151
+ * @param m - The transform matrix
152
+ * @param out - The transformed coordinates
153
+ */
154
+ static transformCoordinate(v: Vector3, m: Matrix, out: Vector3): void;
155
+ /**
156
+ * Performs a transformation using the given quaternion.
157
+ * @param v - The vector to transform
158
+ * @param quaternion - The transform quaternion
159
+ * @param out - The transformed vector
160
+ */
161
+ static transformByQuat(v: Vector3, quaternion: Quaternion, out: Vector3): void;
162
+ /**
163
+ * The x component of the vector.
164
+ */
165
+ get x(): number;
166
+ set x(value: number);
167
+ /**
168
+ * The y component of the vector.
169
+ */
170
+ get y(): number;
171
+ set y(value: number);
172
+ /**
173
+ * The z component of the vector.
174
+ */
175
+ get z(): number;
176
+ set z(value: number);
177
+ /**
178
+ * Constructor of Vector3.
179
+ * @param x - The x component of the vector, default 0
180
+ * @param y - The y component of the vector, default 0
181
+ * @param z - The z component of the vector, default 0
182
+ */
183
+ constructor(x?: number, y?: number, z?: number);
184
+ /**
185
+ * Set the value of this vector.
186
+ * @param x - The x component of the vector
187
+ * @param y - The y component of the vector
188
+ * @param z - The z component of the vector
189
+ * @returns This vector
190
+ */
191
+ set(x: number, y: number, z: number): Vector3;
192
+ /**
193
+ * Determines the sum of this vector and the specified vector.
194
+ * @param right - The specified vector
195
+ * @returns This vector
196
+ */
197
+ add(right: Vector3): Vector3;
198
+ /**
199
+ * Determines the difference of this vector and the specified vector.
200
+ * @param right - The specified vector
201
+ * @returns This vector
202
+ */
203
+ subtract(right: Vector3): Vector3;
204
+ /**
205
+ * Determines the product of this vector and the specified vector.
206
+ * @param right - The specified vector
207
+ * @returns This vector
208
+ */
209
+ multiply(right: Vector3): Vector3;
210
+ /**
211
+ * Determines the divisor of this vector and the specified vector.
212
+ * @param right - The specified vector
213
+ * @returns This vector
214
+ */
215
+ divide(right: Vector3): Vector3;
216
+ /**
217
+ * Calculate the length of this vector.
218
+ * @returns The length of this vector
219
+ */
220
+ length(): number;
221
+ /**
222
+ * Calculate the squared length of this vector.
223
+ * @returns The squared length of this vector
224
+ */
225
+ lengthSquared(): number;
226
+ /**
227
+ * Reverses the direction of this vector.
228
+ * @returns This vector
229
+ */
230
+ negate(): Vector3;
231
+ /**
232
+ * Converts this vector into a unit vector.
233
+ * @returns This vector
234
+ */
235
+ normalize(): Vector3;
236
+ /**
237
+ * Scale this vector by the given value.
238
+ * @param s - The amount by which to scale the vector
239
+ * @returns This vector
240
+ */
241
+ scale(s: number): Vector3;
242
+ /**
243
+ * This vector performs a normal transformation using the given 4x4 matrix.
244
+ * @remarks
245
+ * A normal transform performs the transformation with the assumption that the w component
246
+ * is zero. This causes the fourth row and fourth column of the matrix to be unused. The
247
+ * end result is a vector that is not translated, but all other transformation properties
248
+ * apply. This is often preferred for normal vectors as normals purely represent direction
249
+ * rather than location because normal vectors should not be translated.
250
+ * @param m - The transform matrix
251
+ * @returns This vector
252
+ */
253
+ transformNormal(m: Matrix): Vector3;
254
+ /**
255
+ * This vector performs a transformation using the given 4x4 matrix.
256
+ * @param m - The transform matrix
257
+ * @returns This vector
258
+ */
259
+ transformToVec3(m: Matrix): Vector3;
260
+ /**
261
+ * This vector performs a coordinate transformation using the given 4x4 matrix.
262
+ * @remarks
263
+ * A coordinate transform performs the transformation with the assumption that the w component
264
+ * is one. The four dimensional vector obtained from the transformation operation has each
265
+ * component in the vector divided by the w component. This forces the w-component to be one and
266
+ * therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
267
+ * with coordinates as the w component can safely be ignored.
268
+ * @param m - The transform matrix
269
+ * @returns This vector
270
+ */
271
+ transformCoordinate(m: Matrix): Vector3;
272
+ /**
273
+ * This vector performs a transformation using the given quaternion.
274
+ * @param quaternion - The transform quaternion
275
+ * @returns This vector
276
+ */
277
+ transformByQuat(quaternion: Quaternion): Vector3;
278
+ /**
279
+ * Creates a clone of this vector.
280
+ * @returns A clone of this vector
281
+ */
282
+ clone(): Vector3;
283
+ /**
284
+ * Copy from vector3 like object.
285
+ * @param source - Vector3 like object.
286
+ * @returns This vector
287
+ */
288
+ copyFrom(source: Vector3Like): Vector3;
289
+ /**
290
+ * Copy to vector3 like object.
291
+ * @param target - Vector3 like object
292
+ * @returns This Vector3 like object
293
+ */
294
+ copyTo(target: Vector3Like): Vector3Like;
295
+ /**
296
+ * Copy the value of this vector from an array.
297
+ * @param array - The array
298
+ * @param offset - The start offset of the array
299
+ * @returns This vector
300
+ */
301
+ copyFromArray(array: ArrayLike<number>, offset?: number): Vector3;
302
+ /**
303
+ * Copy the value of this vector to an array.
304
+ * @param out - The array
305
+ * @param outOffset - The start offset of the array
306
+ */
307
+ copyToArray(out: number[] | Float32Array | Float64Array, outOffset?: number): void;
308
+ /**
309
+ * Serialize this vector to a JSON representation.
310
+ * @returns A JSON representation of this vector
311
+ */
312
+ toJSON(): Vector3Like;
313
+ }
314
+ export interface Vector3Like {
315
+ /** {@inheritDoc Vector3.x} */
316
+ x: number;
317
+ /** {@inheritDoc Vector3.y} */
318
+ y: number;
319
+ /** {@inheritDoc Vector3.z} */
320
+ z: number;
321
+ }