@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,333 @@
1
+ import { IClone } from "./IClone";
2
+ import { ICopy } from "./ICopy";
3
+ import { Matrix3x3 } from "./Matrix3x3";
4
+ import { Vector3 } from "./Vector3";
5
+ /**
6
+ * Represents a four dimensional mathematical quaternion.
7
+ */
8
+ export declare class Quaternion implements IClone<Quaternion>, ICopy<QuaternionLike, Quaternion> {
9
+ /**
10
+ * Determines the sum of two quaternions.
11
+ * @param left - The first quaternion to add
12
+ * @param right - The second quaternion to add
13
+ * @param out - The sum of two quaternions
14
+ */
15
+ static add(left: Quaternion, right: Quaternion, out: Quaternion): void;
16
+ /**
17
+ * Determines the product of two quaternions.
18
+ * @param left - The first quaternion to multiply
19
+ * @param right - The second quaternion to multiply
20
+ * @param out - The product of two quaternions
21
+ */
22
+ static multiply(left: Quaternion, right: Quaternion, out: Quaternion): void;
23
+ /**
24
+ * Calculate quaternion that contains conjugated version of the specified quaternion.
25
+ * @param a - The specified quaternion
26
+ * @param out - The conjugate version of the specified quaternion
27
+ */
28
+ static conjugate(a: Quaternion, out: Quaternion): void;
29
+ /**
30
+ * Determines the dot product of two quaternions.
31
+ * @param left - The first quaternion to dot
32
+ * @param right - The second quaternion to dot
33
+ * @returns The dot product of two quaternions
34
+ */
35
+ static dot(left: Quaternion, right: Quaternion): number;
36
+ /**
37
+ * Determines whether the specified quaternions are equals.
38
+ * @param left - The first quaternion to compare
39
+ * @param right - The second quaternion to compare
40
+ * @returns True if the specified quaternions are equals, false otherwise
41
+ */
42
+ static equals(left: Quaternion, right: Quaternion): boolean;
43
+ /**
44
+ * Calculate a quaternion rotates around an arbitrary axis.
45
+ * @param axis - The axis
46
+ * @param rad - The rotation angle in radians
47
+ * @param out - The quaternion after rotate
48
+ */
49
+ static rotationAxisAngle(axis: Vector3, rad: number, out: Quaternion): void;
50
+ /**
51
+ * Calculate a quaternion rotates around x, y, z axis (pitch/yaw/roll).
52
+ * @param x - The radian of rotation around X (pitch)
53
+ * @param y - The radian of rotation around Y (yaw)
54
+ * @param z - The radian of rotation around Z (roll)
55
+ * @param out - The calculated quaternion
56
+ */
57
+ static rotationEuler(x: number, y: number, z: number, out: Quaternion): void;
58
+ /**
59
+ * Calculate a quaternion from the specified yaw, pitch and roll angles.
60
+ * @param yaw - Yaw around the y axis in radians
61
+ * @param pitch - Pitch around the x axis in radians
62
+ * @param roll - Roll around the z axis in radians
63
+ * @param out - The calculated quaternion
64
+ */
65
+ static rotationYawPitchRoll(yaw: number, pitch: number, roll: number, out: Quaternion): void;
66
+ /**
67
+ * Calculate a quaternion from the specified 3x3 matrix.
68
+ * @param m - The specified 3x3 matrix
69
+ * @param out - The calculated quaternion
70
+ */
71
+ static rotationMatrix3x3(m: Matrix3x3, out: Quaternion): void;
72
+ /**
73
+ * Calculate the inverse of the specified quaternion.
74
+ * @param a - The quaternion whose inverse is to be calculated
75
+ * @param out - The inverse of the specified quaternion
76
+ */
77
+ static invert(a: Quaternion, out: Quaternion): void;
78
+ /**
79
+ * Performs a linear blend between two quaternions.
80
+ * @param start - The first quaternion
81
+ * @param end - The second quaternion
82
+ * @param t - The blend amount where 0 returns start and 1 end
83
+ * @param out - The result of linear blending between two quaternions
84
+ */
85
+ static lerp(start: Quaternion, end: Quaternion, t: number, out: Quaternion): void;
86
+ /**
87
+ * Performs a spherical linear blend between two quaternions.
88
+ * @param start - The first quaternion
89
+ * @param end - The second quaternion
90
+ * @param amount - The blend amount where 0 returns start and 1 end
91
+ * @param out - The result of spherical linear blending between two quaternions
92
+ */
93
+ static slerp(start: Quaternion, end: Quaternion, amount: number, out: Quaternion): void;
94
+ /**
95
+ * Scales the specified quaternion magnitude to unit length.
96
+ * @param a - The specified quaternion
97
+ * @param out - The normalized quaternion
98
+ */
99
+ static normalize(a: Quaternion, out: Quaternion): void;
100
+ /**
101
+ * Calculate a quaternion rotate around X axis.
102
+ * @param rad - The rotation angle in radians
103
+ * @param out - The calculated quaternion
104
+ */
105
+ static rotationX(rad: number, out: Quaternion): void;
106
+ /**
107
+ * Calculate a quaternion rotate around Y axis.
108
+ * @param rad - The rotation angle in radians
109
+ * @param out - The calculated quaternion
110
+ */
111
+ static rotationY(rad: number, out: Quaternion): void;
112
+ /**
113
+ * Calculate a quaternion rotate around Z axis.
114
+ * @param rad - The rotation angle in radians
115
+ * @param out - The calculated quaternion
116
+ */
117
+ static rotationZ(rad: number, out: Quaternion): void;
118
+ /**
119
+ * Calculate a quaternion that the specified quaternion rotate around X axis.
120
+ * @param quaternion - The specified quaternion
121
+ * @param rad - The rotation angle in radians
122
+ * @param out - The calculated quaternion
123
+ */
124
+ static rotateX(quaternion: Quaternion, rad: number, out: Quaternion): void;
125
+ /**
126
+ * Calculate a quaternion that the specified quaternion rotate around Y axis.
127
+ * @param quaternion - The specified quaternion
128
+ * @param rad - The rotation angle in radians
129
+ * @param out - The calculated quaternion
130
+ */
131
+ static rotateY(quaternion: Quaternion, rad: number, out: Quaternion): void;
132
+ /**
133
+ * Calculate a quaternion that the specified quaternion rotate around Z axis.
134
+ * @param quaternion - The specified quaternion
135
+ * @param rad - The rotation angle in radians
136
+ * @param out - The calculated quaternion
137
+ */
138
+ static rotateZ(quaternion: Quaternion, rad: number, out: Quaternion): void;
139
+ /**
140
+ * Scale a quaternion by a given number.
141
+ * @param a - The quaternion
142
+ * @param s - The given number
143
+ * @param out - The scaled quaternion
144
+ */
145
+ static scale(a: Quaternion, s: number, out: Quaternion): void;
146
+ /**
147
+ * The x component of the quaternion.
148
+ */
149
+ get x(): number;
150
+ set x(value: number);
151
+ /**
152
+ * The y component of the quaternion.
153
+ */
154
+ get y(): number;
155
+ set y(value: number);
156
+ /**
157
+ * The z component of the quaternion.
158
+ */
159
+ get z(): number;
160
+ set z(value: number);
161
+ /**
162
+ * Indicting whether this instance is normalized.
163
+ */
164
+ get normalized(): boolean;
165
+ /**
166
+ * The w component of the quaternion.
167
+ */
168
+ get w(): number;
169
+ set w(value: number);
170
+ /**
171
+ * Constructor of Quaternion.
172
+ * @param x - The x component of the quaternion, default 0
173
+ * @param y - The y component of the quaternion, default 0
174
+ * @param z - The z component of the quaternion, default 0
175
+ * @param w - The w component of the quaternion, default 1
176
+ */
177
+ constructor(x?: number, y?: number, z?: number, w?: number);
178
+ /**
179
+ * Set the value of this quaternion, and return this quaternion.
180
+ * @param x - The x component of the quaternion
181
+ * @param y - The y component of the quaternion
182
+ * @param z - The z component of the quaternion
183
+ * @param w - The w component of the quaternion
184
+ * @returns This quaternion
185
+ */
186
+ set(x: number, y: number, z: number, w: number): Quaternion;
187
+ /**
188
+ * Transforms this quaternion into its conjugated version.
189
+ * @returns This quaternion
190
+ */
191
+ conjugate(): Quaternion;
192
+ /**
193
+ * Get the rotation axis and rotation angle of the quaternion (unit: radians).
194
+ * @param out - The axis as an output parameter
195
+ * @returns The rotation angle (unit: radians)
196
+ */
197
+ getAxisAngle(out: Vector3): number;
198
+ /**
199
+ * Identity this quaternion.
200
+ * @returns This quaternion after identity
201
+ */
202
+ identity(): Quaternion;
203
+ /**
204
+ * Calculate the length of this quaternion.
205
+ * @returns The length of this quaternion
206
+ */
207
+ length(): number;
208
+ /**
209
+ * Calculates the squared length of this quaternion.
210
+ * @returns The squared length of this quaternion
211
+ */
212
+ lengthSquared(): number;
213
+ /**
214
+ * Converts this quaternion into a unit quaternion.
215
+ * @returns This quaternion
216
+ */
217
+ normalize(): Quaternion;
218
+ /**
219
+ * Get the euler of this quaternion.
220
+ * @param out - The euler (in radians) as an output parameter
221
+ * @returns Euler x->pitch y->yaw z->roll
222
+ */
223
+ toEuler(out: Vector3): Vector3;
224
+ /**
225
+ * Get the euler of this quaternion.
226
+ * @param out - The euler (in radians) as an output parameter
227
+ * @returns Euler x->yaw y->pitch z->roll
228
+ */
229
+ toYawPitchRoll(out: Vector3): Vector3;
230
+ /**
231
+ * Calculate this quaternion rotate around X axis.
232
+ * @param rad - The rotation angle in radians
233
+ * @returns This quaternion
234
+ */
235
+ rotateX(rad: number): Quaternion;
236
+ /**
237
+ * Calculate this quaternion rotate around Y axis.
238
+ * @param rad - The rotation angle in radians
239
+ * @returns This quaternion
240
+ */
241
+ rotateY(rad: number): Quaternion;
242
+ /**
243
+ * Calculate this quaternion rotate around Z axis.
244
+ * @param rad - The rotation angle in radians
245
+ * @returns This quaternion
246
+ */
247
+ rotateZ(rad: number): Quaternion;
248
+ /**
249
+ * Calculate this quaternion rotates around an arbitrary axis.
250
+ * @param axis - The axis
251
+ * @param rad - The rotation angle in radians
252
+ * @returns This quaternion
253
+ */
254
+ rotationAxisAngle(axis: Vector3, rad: number): Quaternion;
255
+ /**
256
+ * Determines the product of this quaternion and the specified quaternion.
257
+ * @param quat - The specified quaternion
258
+ * @returns The product of the two quaternions
259
+ */
260
+ multiply(quat: Quaternion): Quaternion;
261
+ /**
262
+ * Invert this quaternion.
263
+ * @returns This quaternion after invert
264
+ */
265
+ invert(): Quaternion;
266
+ /**
267
+ * Determines the dot product of this quaternion and the specified quaternion.
268
+ * @param quat - The specified quaternion
269
+ * @returns The dot product of two quaternions
270
+ */
271
+ dot(quat: Quaternion): number;
272
+ /**
273
+ * Performs a linear blend between this quaternion and the specified quaternion.
274
+ * @param quat - The specified quaternion
275
+ * @param t - The blend amount where 0 returns this and 1 quat
276
+ * @returns - The result of linear blending between two quaternions
277
+ */
278
+ lerp(quat: Quaternion, t: number): Quaternion;
279
+ /**
280
+ * Calculate this quaternion rotation around an arbitrary axis.
281
+ * @param axis - The axis
282
+ * @param rad - The rotation angle in radians
283
+ * @returns This quaternion
284
+ */
285
+ rotateAxisAngle(axis: Vector3, rad: number): Quaternion;
286
+ /**
287
+ * Creates a clone of this quaternion.
288
+ * @returns A clone of this quaternion
289
+ */
290
+ clone(): Quaternion;
291
+ /**
292
+ * Copy this quaternion from the specified quaternion.
293
+ * @param source - The specified quaternion
294
+ * @returns This quaternion
295
+ */
296
+ copyFrom(source: QuaternionLike): Quaternion;
297
+ /**
298
+ * Copy this quaternion to the specified quaternion.
299
+ * @param target - The specified quaternion
300
+ * @returns This specified quaternion
301
+ */
302
+ copyTo(target: QuaternionLike): QuaternionLike;
303
+ /**
304
+ * Copy the value of this quaternion from an array.
305
+ * @param array - The array
306
+ * @param offset - The start offset of the array
307
+ * @returns This quaternion
308
+ */
309
+ copyFromArray(array: ArrayLike<number>, offset?: number): Quaternion;
310
+ /**
311
+ * Copy the value of this quaternion to an array.
312
+ * @param out - The array
313
+ * @param outOffset - The start offset of the array
314
+ */
315
+ copyToArray(out: number[] | Float32Array | Float64Array, outOffset?: number): void;
316
+ /**
317
+ * Serialize this quaternion to a JSON representation.
318
+ * @returns A JSON Object representation of this quaternion
319
+ */
320
+ toJSON(): QuaternionLike;
321
+ private _toYawPitchRoll;
322
+ }
323
+ interface QuaternionLike {
324
+ /** {@inheritDoc Quaternion.x} */
325
+ x: number;
326
+ /** {@inheritDoc Quaternion.y} */
327
+ y: number;
328
+ /** {@inheritDoc Quaternion.z} */
329
+ z: number;
330
+ /** {@inheritDoc Quaternion.w} */
331
+ w: number;
332
+ }
333
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Random number generator based on the xorshift128+ algorithm.
3
+ * https://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf
4
+ */
5
+ export declare class Rand {
6
+ private _state0;
7
+ private _state1;
8
+ /**
9
+ * Create a random number generator.
10
+ * @param seed0 - Seed 0 used to initialize the generator
11
+ * @param seed1 - Seed 1 used to initialize the generator
12
+ */
13
+ constructor(seed0: number, seed1: number);
14
+ /**
15
+ * Generate a integer 32bit random number.
16
+ * @returns - A random number
17
+ */
18
+ randomInt32(): number;
19
+ /**
20
+ * Generate a number between 0 and 1.
21
+ * @returns - A random number
22
+ */
23
+ random(): number;
24
+ /**
25
+ * Reset the generator by new seeds.
26
+ * @param seed0 - Random seed0
27
+ * @param seed1 - Random seed1
28
+ */
29
+ reset(seed0: number, seed1: number): void;
30
+ }
package/types/Ray.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { BoundingBox } from "./BoundingBox";
2
+ import { BoundingSphere } from "./BoundingSphere";
3
+ import { Plane } from "./Plane";
4
+ import { Vector3 } from "./Vector3";
5
+ /**
6
+ * Represents a ray with an origin and a direction in 3D space.
7
+ */
8
+ export declare class Ray {
9
+ /** The origin of the ray. */
10
+ readonly origin: Vector3;
11
+ /** The normalized direction of the ray. */
12
+ readonly direction: Vector3;
13
+ /**
14
+ * Constructor of Ray.
15
+ * @param origin - The origin vector
16
+ * @param direction - The direction vector
17
+ */
18
+ constructor(origin?: Vector3, direction?: Vector3);
19
+ /**
20
+ * Check if this ray intersects the specified plane.
21
+ * @param plane - The specified plane
22
+ * @returns The distance from this ray to the specified plane if intersecting, -1 otherwise
23
+ */
24
+ intersectPlane(plane: Plane): number;
25
+ /**
26
+ * Check if this ray intersects the specified sphere.
27
+ * @param sphere - The specified sphere
28
+ * @returns The distance from this ray to the specified sphere if intersecting, -1 otherwise
29
+ */
30
+ intersectSphere(sphere: BoundingSphere): number;
31
+ /**
32
+ * Check if this ray intersects the specified box (AABB).
33
+ * @param box - The specified box
34
+ * @returns The distance from this ray to the specified box if intersecting, -1 otherwise
35
+ */
36
+ intersectBox(box: BoundingBox): number;
37
+ /**
38
+ * The coordinates of the specified distance from the origin in the ray direction.
39
+ * @param distance - The specified distance
40
+ * @param out - The coordinates as an output parameter
41
+ * @returns The out
42
+ */
43
+ getPoint(distance: number, out: Vector3): Vector3;
44
+ }
@@ -0,0 +1,52 @@
1
+ import { IClone } from "./IClone";
2
+ import { ICopy } from "./ICopy";
3
+ export declare class Rect implements IClone<Rect>, ICopy<Rect, Rect> {
4
+ /**
5
+ * The x coordinate of the rectangle.
6
+ */
7
+ get x(): number;
8
+ set x(value: number);
9
+ /**
10
+ * The y coordinate of the rectangle.
11
+ */
12
+ get y(): number;
13
+ set y(value: number);
14
+ /**
15
+ * The width of the rectangle, measured from the x position.
16
+ */
17
+ get width(): number;
18
+ set width(value: number);
19
+ /**
20
+ * The height of the rectangle, measured from the y position.
21
+ */
22
+ get height(): number;
23
+ set height(value: number);
24
+ /**
25
+ * Constructor of Rect.
26
+ * @param x - The x coordinate of the rectangle, default 0
27
+ * @param y - The y coordinate of the rectangle, default 0
28
+ * @param width - The width of the rectangle, measured from the x position, default 0
29
+ * @param height - The height of the rectangle, measured from the y position, default 0
30
+ */
31
+ constructor(x?: number, y?: number, width?: number, height?: number);
32
+ /**
33
+ * Set the value of this rectangle.
34
+ * @param x - The x coordinate of the rectangle
35
+ * @param y - The y coordinate of the rectangle
36
+ * @param width - The width of the rectangle, measured from the x position
37
+ * @param height - The height of the rectangle, measured from the y position
38
+ * @returns This rectangle
39
+ */
40
+ set(x: number, y: number, width: number, height: number): Rect;
41
+ /**
42
+ * Creates a clone of this rect.
43
+ * @returns A clone of this rect
44
+ */
45
+ clone(): Rect;
46
+ /**
47
+ * Copy this rect from the specified rect.
48
+ * @param source - The specified rect
49
+ * @returns This rect
50
+ */
51
+ copyFrom(source: Rect): Rect;
52
+ }
@@ -0,0 +1,56 @@
1
+ import { Color } from "./Color";
2
+ import { IClone } from "./IClone";
3
+ import { ICopy } from "./ICopy";
4
+ import { Vector3 } from "./Vector3";
5
+ /**
6
+ * Use SH3 to represent irradiance environment maps efficiently, allowing for interactive rendering of diffuse objects under distant illumination.
7
+ * @remarks
8
+ * https://graphics.stanford.edu/papers/envmap/envmap.pdf
9
+ * http://www.ppsloan.org/publications/StupidSH36.pdf
10
+ * https://google.github.io/filament/Filament.md.html#annex/sphericalharmonics
11
+ */
12
+ export declare class SphericalHarmonics3 implements IClone<SphericalHarmonics3>, ICopy<SphericalHarmonics3, SphericalHarmonics3> {
13
+ /** The coefficients of SphericalHarmonics3. */
14
+ coefficients: Float32Array;
15
+ /**
16
+ * Add light to SphericalHarmonics3.
17
+ * @param direction - Light direction
18
+ * @param color - Light color
19
+ * @param deltaSolidAngle - The delta solid angle of the light
20
+ */
21
+ addLight(direction: Vector3, color: Color, deltaSolidAngle: number): void;
22
+ /**
23
+ * Evaluates the color for the specified direction.
24
+ * @param direction - Specified direction
25
+ * @param out - Out color
26
+ */
27
+ evaluate(direction: Vector3, out: Color): Color;
28
+ /**
29
+ * Scale the coefficients.
30
+ * @param s - The amount by which to scale the SphericalHarmonics3
31
+ */
32
+ scale(s: number): void;
33
+ /**
34
+ * Creates a clone of this SphericalHarmonics3.
35
+ * @returns A clone of this SphericalHarmonics3
36
+ */
37
+ clone(): SphericalHarmonics3;
38
+ /**
39
+ * Copy this SphericalHarmonics3 from the specified SphericalHarmonics3.
40
+ * @param source - The specified SphericalHarmonics3
41
+ * @returns This SphericalHarmonics3
42
+ */
43
+ copyFrom(source: SphericalHarmonics3): SphericalHarmonics3;
44
+ /**
45
+ * Copy the value of this spherical harmonics from an array.
46
+ * @param array - The array
47
+ * @param offset - The start offset of the array
48
+ */
49
+ copyFromArray(array: ArrayLike<number>, offset?: number): void;
50
+ /**
51
+ * Copy the value of this spherical harmonics to an array.
52
+ * @param out - The array
53
+ * @param outOffset - The start offset of the array
54
+ */
55
+ copyToArray(out: number[] | Float32Array | Float64Array, outOffset?: number): void;
56
+ }