@galacean/engine-math 0.0.0-experimental-animator-additive.1

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/dist/module.js ADDED
@@ -0,0 +1,4841 @@
1
+ /**
2
+ * Defines how the bounding volumes intersects or contain one another.
3
+ */ var ContainmentType;
4
+ (function(ContainmentType) {
5
+ ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
6
+ ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
7
+ ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
8
+ })(ContainmentType || (ContainmentType = {}));
9
+
10
+ /**
11
+ * Defines the intersection between a plane and a bounding volume.
12
+ */ var PlaneIntersectionType;
13
+ (function(PlaneIntersectionType) {
14
+ PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
15
+ PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
16
+ PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
17
+ })(PlaneIntersectionType || (PlaneIntersectionType = {}));
18
+
19
+ /**
20
+ * Frustum face
21
+ */ var FrustumFace;
22
+ (function(FrustumFace) {
23
+ FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
24
+ FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
25
+ FrustumFace[FrustumFace[/** Left face */ "Left"] = 2] = "Left";
26
+ FrustumFace[FrustumFace[/** Right face */ "Right"] = 3] = "Right";
27
+ FrustumFace[FrustumFace[/** Bottom face */ "Bottom"] = 4] = "Bottom";
28
+ FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
29
+ })(FrustumFace || (FrustumFace = {}));
30
+
31
+ function _defineProperties(target, props) {
32
+ for (var i = 0; i < props.length; i++) {
33
+ var descriptor = props[i];
34
+ descriptor.enumerable = descriptor.enumerable || false;
35
+ descriptor.configurable = true;
36
+
37
+ if ("value" in descriptor) descriptor.writable = true;
38
+
39
+ Object.defineProperty(target, descriptor.key, descriptor);
40
+ }
41
+ }
42
+ function _create_class(Constructor, protoProps, staticProps) {
43
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
44
+ if (staticProps) _defineProperties(Constructor, staticProps);
45
+
46
+ return Constructor;
47
+ }
48
+
49
+ /**
50
+ * Common utility methods for math operations.
51
+ */ var MathUtil = /*#__PURE__*/ function() {
52
+ function MathUtil() {}
53
+ /**
54
+ * Clamps the specified value.
55
+ * @param v - The specified value
56
+ * @param min - The min value
57
+ * @param max - The max value
58
+ * @returns The result of clamping a value between min and max
59
+ */ MathUtil.clamp = function clamp(v, min, max) {
60
+ return Math.max(min, Math.min(max, v));
61
+ };
62
+ /**
63
+ * Checks if a and b are almost equals.
64
+ * The absolute value of the difference between a and b is close to zero.
65
+ * @param a - The left value to compare
66
+ * @param b - The right value to compare
67
+ * @returns True if a almost equal to b, false otherwise
68
+ */ MathUtil.equals = function equals(a, b) {
69
+ return Math.abs(a - b) <= MathUtil.zeroTolerance;
70
+ };
71
+ /**
72
+ * Determines whether the specified v is pow2.
73
+ * @param v - The specified v
74
+ * @returns True if the specified v is pow2, false otherwise
75
+ */ MathUtil.isPowerOf2 = function isPowerOf2(v) {
76
+ return (v & v - 1) === 0;
77
+ };
78
+ /**
79
+ * Modify the specified r from radian to degree.
80
+ * @param r - The specified r
81
+ * @returns The degree value
82
+ */ MathUtil.radianToDegree = function radianToDegree(r) {
83
+ return r * MathUtil.radToDegreeFactor;
84
+ };
85
+ /**
86
+ * Modify the specified d from degree to radian.
87
+ * @param d - The specified d
88
+ * @returns The radian value
89
+ */ MathUtil.degreeToRadian = function degreeToRadian(d) {
90
+ return d * MathUtil.degreeToRadFactor;
91
+ };
92
+ return MathUtil;
93
+ }();
94
+ (function() {
95
+ /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
96
+ })();
97
+ (function() {
98
+ /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
99
+ })();
100
+ (function() {
101
+ /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
102
+ })();
103
+
104
+ /**
105
+ * Describes a 3D-vector.
106
+ */ var Vector3 = /*#__PURE__*/ function() {
107
+ function Vector3(x, y, z) {
108
+ if (x === void 0) x = 0;
109
+ if (y === void 0) y = 0;
110
+ if (z === void 0) z = 0;
111
+ /** @internal */ this._onValueChanged = null;
112
+ this._x = x;
113
+ this._y = y;
114
+ this._z = z;
115
+ }
116
+ var _proto = Vector3.prototype;
117
+ /**
118
+ * Set the value of this vector.
119
+ * @param x - The x component of the vector
120
+ * @param y - The y component of the vector
121
+ * @param z - The z component of the vector
122
+ * @returns This vector
123
+ */ _proto.set = function set(x, y, z) {
124
+ this._x = x;
125
+ this._y = y;
126
+ this._z = z;
127
+ this._onValueChanged && this._onValueChanged();
128
+ return this;
129
+ };
130
+ /**
131
+ * Determines the sum of this vector and the specified vector.
132
+ * @param right - The specified vector
133
+ * @returns This vector
134
+ */ _proto.add = function add(right) {
135
+ this._x += right._x;
136
+ this._y += right._y;
137
+ this._z += right._z;
138
+ this._onValueChanged && this._onValueChanged();
139
+ return this;
140
+ };
141
+ /**
142
+ * Determines the difference of this vector and the specified vector.
143
+ * @param right - The specified vector
144
+ * @returns This vector
145
+ */ _proto.subtract = function subtract(right) {
146
+ this._x -= right._x;
147
+ this._y -= right._y;
148
+ this._z -= right._z;
149
+ this._onValueChanged && this._onValueChanged();
150
+ return this;
151
+ };
152
+ /**
153
+ * Determines the product of this vector and the specified vector.
154
+ * @param right - The specified vector
155
+ * @returns This vector
156
+ */ _proto.multiply = function multiply(right) {
157
+ this._x *= right._x;
158
+ this._y *= right._y;
159
+ this._z *= right._z;
160
+ this._onValueChanged && this._onValueChanged();
161
+ return this;
162
+ };
163
+ /**
164
+ * Determines the divisor of this vector and the specified vector.
165
+ * @param right - The specified vector
166
+ * @returns This vector
167
+ */ _proto.divide = function divide(right) {
168
+ this._x /= right._x;
169
+ this._y /= right._y;
170
+ this._z /= right._z;
171
+ this._onValueChanged && this._onValueChanged();
172
+ return this;
173
+ };
174
+ /**
175
+ * Calculate the length of this vector.
176
+ * @returns The length of this vector
177
+ */ _proto.length = function length() {
178
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z;
179
+ return Math.sqrt(_x * _x + _y * _y + _z * _z);
180
+ };
181
+ /**
182
+ * Calculate the squared length of this vector.
183
+ * @returns The squared length of this vector
184
+ */ _proto.lengthSquared = function lengthSquared() {
185
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z;
186
+ return _x * _x + _y * _y + _z * _z;
187
+ };
188
+ /**
189
+ * Reverses the direction of this vector.
190
+ * @returns This vector
191
+ */ _proto.negate = function negate() {
192
+ this._x = -this._x;
193
+ this._y = -this._y;
194
+ this._z = -this._z;
195
+ this._onValueChanged && this._onValueChanged();
196
+ return this;
197
+ };
198
+ /**
199
+ * Converts this vector into a unit vector.
200
+ * @returns This vector
201
+ */ _proto.normalize = function normalize() {
202
+ Vector3.normalize(this, this);
203
+ return this;
204
+ };
205
+ /**
206
+ * Scale this vector by the given value.
207
+ * @param s - The amount by which to scale the vector
208
+ * @returns This vector
209
+ */ _proto.scale = function scale(s) {
210
+ this._x *= s;
211
+ this._y *= s;
212
+ this._z *= s;
213
+ this._onValueChanged && this._onValueChanged();
214
+ return this;
215
+ };
216
+ /**
217
+ * This vector performs a normal transformation using the given 4x4 matrix.
218
+ * @remarks
219
+ * A normal transform performs the transformation with the assumption that the w component
220
+ * is zero. This causes the fourth row and fourth column of the matrix to be unused. The
221
+ * end result is a vector that is not translated, but all other transformation properties
222
+ * apply. This is often preferred for normal vectors as normals purely represent direction
223
+ * rather than location because normal vectors should not be translated.
224
+ * @param m - The transform matrix
225
+ * @returns This vector
226
+ */ _proto.transformNormal = function transformNormal(m) {
227
+ Vector3.transformNormal(this, m, this);
228
+ return this;
229
+ };
230
+ /**
231
+ * This vector performs a transformation using the given 4x4 matrix.
232
+ * @param m - The transform matrix
233
+ * @returns This vector
234
+ */ _proto.transformToVec3 = function transformToVec3(m) {
235
+ Vector3.transformToVec3(this, m, this);
236
+ return this;
237
+ };
238
+ /**
239
+ * This vector performs a coordinate transformation using the given 4x4 matrix.
240
+ * @remarks
241
+ * A coordinate transform performs the transformation with the assumption that the w component
242
+ * is one. The four dimensional vector obtained from the transformation operation has each
243
+ * component in the vector divided by the w component. This forces the w-component to be one and
244
+ * therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
245
+ * with coordinates as the w component can safely be ignored.
246
+ * @param m - The transform matrix
247
+ * @returns This vector
248
+ */ _proto.transformCoordinate = function transformCoordinate(m) {
249
+ Vector3.transformCoordinate(this, m, this);
250
+ return this;
251
+ };
252
+ /**
253
+ * This vector performs a transformation using the given quaternion.
254
+ * @param quaternion - The transform quaternion
255
+ * @returns This vector
256
+ */ _proto.transformByQuat = function transformByQuat(quaternion) {
257
+ Vector3.transformByQuat(this, quaternion, this);
258
+ return this;
259
+ };
260
+ /**
261
+ * Creates a clone of this vector.
262
+ * @returns A clone of this vector
263
+ */ _proto.clone = function clone() {
264
+ return new Vector3(this._x, this._y, this._z);
265
+ };
266
+ /**
267
+ * Copy from vector3 like object.
268
+ * @param source - Vector3 like object.
269
+ * @returns This vector
270
+ */ _proto.copyFrom = function copyFrom(source) {
271
+ this._x = source.x;
272
+ this._y = source.y;
273
+ this._z = source.z;
274
+ this._onValueChanged && this._onValueChanged();
275
+ return this;
276
+ };
277
+ /**
278
+ * Copy the value of this vector from an array.
279
+ * @param array - The array
280
+ * @param offset - The start offset of the array
281
+ * @returns This vector
282
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
283
+ if (offset === void 0) offset = 0;
284
+ this._x = array[offset];
285
+ this._y = array[offset + 1];
286
+ this._z = array[offset + 2];
287
+ this._onValueChanged && this._onValueChanged();
288
+ return this;
289
+ };
290
+ /**
291
+ * Copy the value of this vector to an array.
292
+ * @param out - The array
293
+ * @param outOffset - The start offset of the array
294
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
295
+ if (outOffset === void 0) outOffset = 0;
296
+ out[outOffset] = this._x;
297
+ out[outOffset + 1] = this._y;
298
+ out[outOffset + 2] = this._z;
299
+ };
300
+ /**
301
+ * Serialize this vector to a JSON representation.
302
+ * @returns A JSON representation of this vector
303
+ */ _proto.toJSON = function toJSON() {
304
+ return {
305
+ x: this._x,
306
+ y: this._y,
307
+ z: this._z
308
+ };
309
+ };
310
+ /**
311
+ * Determines the sum of two vectors.
312
+ * @param left - The first vector to add
313
+ * @param right - The second vector to add
314
+ * @param out - The sum of two vectors
315
+ */ Vector3.add = function add(left, right, out) {
316
+ out._x = left._x + right._x;
317
+ out._y = left._y + right._y;
318
+ out._z = left._z + right._z;
319
+ out._onValueChanged && out._onValueChanged();
320
+ };
321
+ /**
322
+ * Determines the difference between two vectors.
323
+ * @param left - The first vector to subtract
324
+ * @param right - The second vector to subtract
325
+ * @param out - The difference between two vectors
326
+ */ Vector3.subtract = function subtract(left, right, out) {
327
+ out._x = left._x - right._x;
328
+ out._y = left._y - right._y;
329
+ out._z = left._z - right._z;
330
+ out._onValueChanged && out._onValueChanged();
331
+ };
332
+ /**
333
+ * Determines the product of two vectors.
334
+ * @param left - The first vector to multiply
335
+ * @param right - The second vector to multiply
336
+ * @param out - The product of two vectors
337
+ */ Vector3.multiply = function multiply(left, right, out) {
338
+ out._x = left._x * right._x;
339
+ out._y = left._y * right._y;
340
+ out._z = left._z * right._z;
341
+ out._onValueChanged && out._onValueChanged();
342
+ };
343
+ /**
344
+ * Determines the divisor of two vectors.
345
+ * @param left - The first vector to divide
346
+ * @param right - The second vector to divide
347
+ * @param out - The divisor of two vectors
348
+ */ Vector3.divide = function divide(left, right, out) {
349
+ out._x = left._x / right._x;
350
+ out._y = left._y / right._y;
351
+ out._z = left._z / right._z;
352
+ out._onValueChanged && out._onValueChanged();
353
+ };
354
+ /**
355
+ * Determines the dot product of two vectors.
356
+ * @param left - The first vector to dot
357
+ * @param right - The second vector to dot
358
+ * @returns The dot product of two vectors
359
+ */ Vector3.dot = function dot(left, right) {
360
+ return left._x * right._x + left._y * right._y + left._z * right._z;
361
+ };
362
+ /**
363
+ * Determines the cross product of two vectors.
364
+ * @param left - The first vector to cross
365
+ * @param right - The second vector to cross
366
+ * @param out - The cross product of two vectors
367
+ */ Vector3.cross = function cross(left, right, out) {
368
+ var ax = left._x;
369
+ var ay = left._y;
370
+ var az = left._z;
371
+ var bx = right._x;
372
+ var by = right._y;
373
+ var bz = right._z;
374
+ out.set(ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx);
375
+ };
376
+ /**
377
+ * Determines the distance of two vectors.
378
+ * @param a - The first vector
379
+ * @param b - The second vector
380
+ * @returns The distance of two vectors
381
+ */ Vector3.distance = function distance(a, b) {
382
+ var x = b._x - a._x;
383
+ var y = b._y - a._y;
384
+ var z = b._z - a._z;
385
+ return Math.sqrt(x * x + y * y + z * z);
386
+ };
387
+ /**
388
+ * Determines the squared distance of two vectors.
389
+ * @param a - The first vector
390
+ * @param b - The second vector
391
+ * @returns The squared distance of two vectors
392
+ */ Vector3.distanceSquared = function distanceSquared(a, b) {
393
+ var x = b._x - a._x;
394
+ var y = b._y - a._y;
395
+ var z = b._z - a._z;
396
+ return x * x + y * y + z * z;
397
+ };
398
+ /**
399
+ * Determines whether the specified vectors are equals.
400
+ * @param left - The first vector to compare
401
+ * @param right - The second vector to compare
402
+ * @returns True if the specified vectors are equals, false otherwise
403
+ */ Vector3.equals = function equals(left, right) {
404
+ return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y) && MathUtil.equals(left._z, right._z);
405
+ };
406
+ /**
407
+ * Performs a linear interpolation between two vectors.
408
+ * @param start - The first vector
409
+ * @param end - The second vector
410
+ * @param t - The blend amount where 0 returns start and 1 end
411
+ * @param out - The result of linear blending between two vectors
412
+ */ Vector3.lerp = function lerp(start, end, t, out) {
413
+ var _x = start._x, _y = start._y, _z = start._z;
414
+ out._x = _x + (end._x - _x) * t;
415
+ out._y = _y + (end._y - _y) * t;
416
+ out._z = _z + (end._z - _z) * t;
417
+ out._onValueChanged && out._onValueChanged();
418
+ };
419
+ /**
420
+ * Calculate a vector containing the largest components of the specified vectors.
421
+ * @param left - The first vector
422
+ * @param right - The second vector
423
+ * @param out - The vector containing the largest components of the specified vectors
424
+ */ Vector3.max = function max(left, right, out) {
425
+ out._x = Math.max(left._x, right._x);
426
+ out._y = Math.max(left._y, right._y);
427
+ out._z = Math.max(left._z, right._z);
428
+ out._onValueChanged && out._onValueChanged();
429
+ };
430
+ /**
431
+ * Calculate a vector containing the smallest components of the specified vectors.
432
+ * @param left - The first vector
433
+ * @param right - The second vector
434
+ * @param out - The vector containing the smallest components of the specified vectors
435
+ */ Vector3.min = function min(left, right, out) {
436
+ out._x = Math.min(left._x, right._x);
437
+ out._y = Math.min(left._y, right._y);
438
+ out._z = Math.min(left._z, right._z);
439
+ out._onValueChanged && out._onValueChanged();
440
+ };
441
+ /**
442
+ * Reverses the direction of a given vector.
443
+ * @param a - The vector to negate
444
+ * @param out - The vector facing in the opposite direction
445
+ */ Vector3.negate = function negate(a, out) {
446
+ out._x = -a._x;
447
+ out._y = -a._y;
448
+ out._z = -a._z;
449
+ out._onValueChanged && out._onValueChanged();
450
+ };
451
+ /**
452
+ * Converts the vector into a unit vector.
453
+ * @param a - The vector to normalize
454
+ * @param out - The normalized vector
455
+ */ Vector3.normalize = function normalize(a, out) {
456
+ var _x = a._x, _y = a._y, _z = a._z;
457
+ var len = Math.sqrt(_x * _x + _y * _y + _z * _z);
458
+ if (len > MathUtil.zeroTolerance) {
459
+ len = 1 / len;
460
+ out.set(_x * len, _y * len, _z * len);
461
+ }
462
+ };
463
+ /**
464
+ * Scale a vector by the given value.
465
+ * @param a - The vector to scale
466
+ * @param s - The amount by which to scale the vector
467
+ * @param out - The scaled vector
468
+ */ Vector3.scale = function scale(a, s, out) {
469
+ out._x = a._x * s;
470
+ out._y = a._y * s;
471
+ out._z = a._z * s;
472
+ out._onValueChanged && out._onValueChanged();
473
+ };
474
+ /**
475
+ * Performs a normal transformation using the given 4x4 matrix.
476
+ * @remarks
477
+ * A normal transform performs the transformation with the assumption that the w component
478
+ * is zero. This causes the fourth row and fourth column of the matrix to be unused. The
479
+ * end result is a vector that is not translated, but all other transformation properties
480
+ * apply. This is often preferred for normal vectors as normals purely represent direction
481
+ * rather than location because normal vectors should not be translated.
482
+ * @param v - The normal vector to transform
483
+ * @param m - The transform matrix
484
+ * @param out - The transformed normal
485
+ */ Vector3.transformNormal = function transformNormal(v, m, out) {
486
+ var _x = v._x, _y = v._y, _z = v._z;
487
+ var e = m.elements;
488
+ out._x = _x * e[0] + _y * e[4] + _z * e[8];
489
+ out._y = _x * e[1] + _y * e[5] + _z * e[9];
490
+ out._z = _x * e[2] + _y * e[6] + _z * e[10];
491
+ out._onValueChanged && out._onValueChanged();
492
+ };
493
+ /**
494
+ * Performs a transformation using the given 4x4 matrix.
495
+ * @param v - The vector to transform
496
+ * @param m - The transform matrix
497
+ * @param out - The transformed vector3
498
+ */ Vector3.transformToVec3 = function transformToVec3(v, m, out) {
499
+ var _x = v._x, _y = v._y, _z = v._z;
500
+ var e = m.elements;
501
+ out._x = _x * e[0] + _y * e[4] + _z * e[8] + e[12];
502
+ out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
503
+ out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
504
+ out._onValueChanged && out._onValueChanged();
505
+ };
506
+ /**
507
+ * Performs a transformation from vector3 to vector4 using the given 4x4 matrix.
508
+ * @param v - The vector to transform
509
+ * @param m - The transform matrix
510
+ * @param out - The transformed vector4
511
+ */ Vector3.transformToVec4 = function transformToVec4(v, m, out) {
512
+ var _x = v._x, _y = v._y, _z = v._z;
513
+ var e = m.elements;
514
+ out._x = _x * e[0] + _y * e[4] + _z * e[8] + e[12];
515
+ out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
516
+ out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
517
+ out._w = _x * e[3] + _y * e[7] + _z * e[11] + e[15];
518
+ out._onValueChanged && out._onValueChanged();
519
+ };
520
+ /**
521
+ * Performs a coordinate transformation using the given 4x4 matrix.
522
+ *
523
+ * @remarks
524
+ * A coordinate transform performs the transformation with the assumption that the w component
525
+ * is one. The four dimensional vector obtained from the transformation operation has each
526
+ * component in the vector divided by the w component. This forces the w-component to be one and
527
+ * therefore makes the vector homogeneous. The homogeneous vector is often preferred when working
528
+ * with coordinates as the w component can safely be ignored.
529
+ * @param v - The coordinate vector to transform
530
+ * @param m - The transform matrix
531
+ * @param out - The transformed coordinates
532
+ */ Vector3.transformCoordinate = function transformCoordinate(v, m, out) {
533
+ var _x = v._x, _y = v._y, _z = v._z;
534
+ var e = m.elements;
535
+ var w = _x * e[3] + _y * e[7] + _z * e[11] + e[15];
536
+ w = 1.0 / w;
537
+ out._x = (_x * e[0] + _y * e[4] + _z * e[8] + e[12]) * w;
538
+ out._y = (_x * e[1] + _y * e[5] + _z * e[9] + e[13]) * w;
539
+ out._z = (_x * e[2] + _y * e[6] + _z * e[10] + e[14]) * w;
540
+ out._onValueChanged && out._onValueChanged();
541
+ };
542
+ /**
543
+ * Performs a transformation using the given quaternion.
544
+ * @param v - The vector to transform
545
+ * @param quaternion - The transform quaternion
546
+ * @param out - The transformed vector
547
+ */ Vector3.transformByQuat = function transformByQuat(v, quaternion, out) {
548
+ var _x = v._x, _y = v._y, _z = v._z;
549
+ var qx = quaternion._x, qy = quaternion._y, qz = quaternion._z, qw = quaternion._w;
550
+ // calculate quat * vec
551
+ var ix = qw * _x + qy * _z - qz * _y;
552
+ var iy = qw * _y + qz * _x - qx * _z;
553
+ var iz = qw * _z + qx * _y - qy * _x;
554
+ var iw = -qx * _x - qy * _y - qz * _z;
555
+ // calculate result * inverse quat
556
+ out._x = ix * qw - iw * qx - iy * qz + iz * qy;
557
+ out._y = iy * qw - iw * qy - iz * qx + ix * qz;
558
+ out._z = iz * qw - iw * qz - ix * qy + iy * qx;
559
+ out._onValueChanged && out._onValueChanged();
560
+ };
561
+ _create_class(Vector3, [
562
+ {
563
+ key: "x",
564
+ get: /**
565
+ * The x component of the vector.
566
+ */ function get() {
567
+ return this._x;
568
+ },
569
+ set: function set(value) {
570
+ this._x = value;
571
+ this._onValueChanged && this._onValueChanged();
572
+ }
573
+ },
574
+ {
575
+ key: "y",
576
+ get: /**
577
+ * The y component of the vector.
578
+ */ function get() {
579
+ return this._y;
580
+ },
581
+ set: function set(value) {
582
+ this._y = value;
583
+ this._onValueChanged && this._onValueChanged();
584
+ }
585
+ },
586
+ {
587
+ key: "z",
588
+ get: /**
589
+ * The z component of the vector.
590
+ */ function get() {
591
+ return this._z;
592
+ },
593
+ set: function set(value) {
594
+ this._z = value;
595
+ this._onValueChanged && this._onValueChanged();
596
+ }
597
+ }
598
+ ]);
599
+ return Vector3;
600
+ }();
601
+ (function() {
602
+ /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
603
+ })();
604
+ (function() {
605
+ /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
606
+ })();
607
+
608
+ /**
609
+ * A bounding sphere.
610
+ * */ var BoundingSphere = /*#__PURE__*/ function() {
611
+ function BoundingSphere(center, radius) {
612
+ if (center === void 0) center = null;
613
+ if (radius === void 0) radius = 0;
614
+ /** The center point of the sphere. */ this.center = new Vector3();
615
+ /** The radius of the sphere. */ this.radius = 0;
616
+ center && this.center.copyFrom(center);
617
+ this.radius = radius;
618
+ }
619
+ var _proto = BoundingSphere.prototype;
620
+ /**
621
+ * Creates a clone of this sphere.
622
+ * @returns A clone of this sphere
623
+ */ _proto.clone = function clone() {
624
+ return new BoundingSphere(this.center, this.radius);
625
+ };
626
+ /**
627
+ * Copy this sphere from the specified sphere.
628
+ * @param source - The specified sphere
629
+ * @returns This sphere
630
+ */ _proto.copyFrom = function copyFrom(source) {
631
+ this.center.copyFrom(source.center);
632
+ this.radius = source.radius;
633
+ return this;
634
+ };
635
+ /**
636
+ * Calculate a bounding sphere that fully contains the given points.
637
+ * @param points - The given points
638
+ * @param out - The calculated bounding sphere
639
+ */ BoundingSphere.fromPoints = function fromPoints(points, out) {
640
+ if (!points || points.length === 0) {
641
+ throw new Error("points must be array and length must > 0");
642
+ }
643
+ var len = points.length;
644
+ var center = BoundingSphere._tempVec30;
645
+ center.x = center.y = center.z = 0;
646
+ // Calculate the center of the sphere.
647
+ for(var i = 0; i < len; ++i){
648
+ Vector3.add(points[i], center, center);
649
+ }
650
+ // The center of the sphere.
651
+ Vector3.scale(center, 1 / len, out.center);
652
+ // Calculate the radius of the sphere.
653
+ var radius = 0.0;
654
+ for(var i1 = 0; i1 < len; ++i1){
655
+ var distance = Vector3.distanceSquared(center, points[i1]);
656
+ distance > radius && (radius = distance);
657
+ }
658
+ // The radius of the sphere.
659
+ out.radius = Math.sqrt(radius);
660
+ };
661
+ /**
662
+ * Calculate a bounding sphere from a given box.
663
+ * @param box - The given box
664
+ * @param out - The calculated bounding sphere
665
+ */ BoundingSphere.fromBox = function fromBox(box, out) {
666
+ var center = out.center;
667
+ var min = box.min, max = box.max;
668
+ center.x = (min.x + max.x) * 0.5;
669
+ center.y = (min.y + max.y) * 0.5;
670
+ center.z = (min.z + max.z) * 0.5;
671
+ out.radius = Vector3.distance(center, max);
672
+ };
673
+ return BoundingSphere;
674
+ }();
675
+ (function() {
676
+ BoundingSphere._tempVec30 = new Vector3();
677
+ })();
678
+
679
+ /**
680
+ * Axis Aligned Bound Box (AABB).
681
+ */ var BoundingBox = /*#__PURE__*/ function() {
682
+ function BoundingBox(min, max) {
683
+ if (min === void 0) min = null;
684
+ if (max === void 0) max = null;
685
+ /** The minimum point of the box. */ this.min = new Vector3();
686
+ /** The maximum point of the box. */ this.max = new Vector3();
687
+ min && this.min.copyFrom(min);
688
+ max && this.max.copyFrom(max);
689
+ }
690
+ var _proto = BoundingBox.prototype;
691
+ /**
692
+ * Get the center point of this bounding box.
693
+ * @param out - The center point of this bounding box
694
+ * @returns The center point of this bounding box
695
+ */ _proto.getCenter = function getCenter(out) {
696
+ Vector3.add(this.min, this.max, out);
697
+ Vector3.scale(out, 0.5, out);
698
+ return out;
699
+ };
700
+ /**
701
+ * Get the extent of this bounding box.
702
+ * @param out - The extent of this bounding box
703
+ * @returns The extent of this bounding box
704
+ */ _proto.getExtent = function getExtent(out) {
705
+ Vector3.subtract(this.max, this.min, out);
706
+ Vector3.scale(out, 0.5, out);
707
+ return out;
708
+ };
709
+ /**
710
+ * Get the eight corners of this bounding box.
711
+ * @param out - An array of points representing the eight corners of this bounding box
712
+ * @returns An array of points representing the eight corners of this bounding box
713
+ */ _proto.getCorners = function getCorners(out) {
714
+ if (out === void 0) out = [];
715
+ var _this = this, min = _this.min, max = _this.max;
716
+ var minX = min.x;
717
+ var minY = min.y;
718
+ var minZ = min.z;
719
+ var maxX = max.x;
720
+ var maxY = max.y;
721
+ var maxZ = max.z;
722
+ var len = out.length;
723
+ // The array length is less than 8 to make up
724
+ if (len < 8) {
725
+ for(var i = 0, l = 8 - len; i < l; ++i){
726
+ out[len + i] = new Vector3();
727
+ }
728
+ }
729
+ out[0].set(minX, maxY, maxZ);
730
+ out[1].set(maxX, maxY, maxZ);
731
+ out[2].set(maxX, minY, maxZ);
732
+ out[3].set(minX, minY, maxZ);
733
+ out[4].set(minX, maxY, minZ);
734
+ out[5].set(maxX, maxY, minZ);
735
+ out[6].set(maxX, minY, minZ);
736
+ out[7].set(minX, minY, minZ);
737
+ return out;
738
+ };
739
+ /**
740
+ * Transform a bounding box.
741
+ * @param matrix - The transform to apply to the bounding box
742
+ * @returns The transformed bounding box
743
+ */ _proto.transform = function transform(matrix) {
744
+ BoundingBox.transform(this, matrix, this);
745
+ return this;
746
+ };
747
+ /**
748
+ * Creates a clone of this box.
749
+ * @returns A clone of this box
750
+ */ _proto.clone = function clone() {
751
+ return new BoundingBox(this.min, this.max);
752
+ };
753
+ /**
754
+ * Copy this bounding box from the specified box.
755
+ * @param source - The specified box
756
+ * @returns This bounding box
757
+ */ _proto.copyFrom = function copyFrom(source) {
758
+ this.min.copyFrom(source.min);
759
+ this.max.copyFrom(source.max);
760
+ return this;
761
+ };
762
+ /**
763
+ * Calculate a bounding box from the center point and the extent of the bounding box.
764
+ * @param center - The center point
765
+ * @param extent - The extent of the bounding box
766
+ * @param out - The calculated bounding box
767
+ */ BoundingBox.fromCenterAndExtent = function fromCenterAndExtent(center, extent, out) {
768
+ Vector3.subtract(center, extent, out.min);
769
+ Vector3.add(center, extent, out.max);
770
+ };
771
+ /**
772
+ * Calculate a bounding box that fully contains the given points.
773
+ * @param points - The given points
774
+ * @param out - The calculated bounding box
775
+ */ BoundingBox.fromPoints = function fromPoints(points, out) {
776
+ if (!points || points.length === 0) {
777
+ throw new Error("points must be array and length must > 0");
778
+ }
779
+ var min = out.min, max = out.max;
780
+ min.x = min.y = min.z = Number.MAX_VALUE;
781
+ max.x = max.y = max.z = -Number.MAX_VALUE;
782
+ for(var i = 0, l = points.length; i < l; ++i){
783
+ var point = points[i];
784
+ Vector3.min(min, point, min);
785
+ Vector3.max(max, point, max);
786
+ }
787
+ };
788
+ /**
789
+ * Calculate a bounding box from a given sphere.
790
+ * @param sphere - The given sphere
791
+ * @param out - The calculated bounding box
792
+ */ BoundingBox.fromSphere = function fromSphere(sphere, out) {
793
+ var center = sphere.center, radius = sphere.radius;
794
+ var min = out.min, max = out.max;
795
+ min.x = center.x - radius;
796
+ min.y = center.y - radius;
797
+ min.z = center.z - radius;
798
+ max.x = center.x + radius;
799
+ max.y = center.y + radius;
800
+ max.z = center.z + radius;
801
+ };
802
+ /**
803
+ * Transform a bounding box.
804
+ * @param source - The original bounding box
805
+ * @param matrix - The transform to apply to the bounding box
806
+ * @param out - The transformed bounding box
807
+ */ BoundingBox.transform = function transform(source, matrix, out) {
808
+ // https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
809
+ var center = BoundingBox._tempVec30;
810
+ var extent = BoundingBox._tempVec31;
811
+ source.getCenter(center);
812
+ source.getExtent(extent);
813
+ Vector3.transformCoordinate(center, matrix, center);
814
+ var x = extent.x, y = extent.y, z = extent.z;
815
+ var e = matrix.elements;
816
+ extent.x = Math.abs(x * e[0]) + Math.abs(y * e[4]) + Math.abs(z * e[8]);
817
+ extent.y = Math.abs(x * e[1]) + Math.abs(y * e[5]) + Math.abs(z * e[9]);
818
+ extent.z = Math.abs(x * e[2]) + Math.abs(y * e[6]) + Math.abs(z * e[10]);
819
+ // set min、max
820
+ Vector3.subtract(center, extent, out.min);
821
+ Vector3.add(center, extent, out.max);
822
+ };
823
+ /**
824
+ * Calculate a bounding box that is as large as the total combined area of the two specified boxes.
825
+ * @param box1 - The first box to merge
826
+ * @param box2 - The second box to merge
827
+ * @param out - The merged bounding box
828
+ * @returns The merged bounding box
829
+ */ BoundingBox.merge = function merge(box1, box2, out) {
830
+ Vector3.min(box1.min, box2.min, out.min);
831
+ Vector3.max(box1.max, box2.max, out.max);
832
+ return out;
833
+ };
834
+ return BoundingBox;
835
+ }();
836
+ (function() {
837
+ BoundingBox._tempVec30 = new Vector3();
838
+ })();
839
+ (function() {
840
+ BoundingBox._tempVec31 = new Vector3();
841
+ })();
842
+
843
+ /**
844
+ * Contains static methods to help in determining intersections, containment, etc.
845
+ */ var CollisionUtil = /*#__PURE__*/ function() {
846
+ function CollisionUtil() {}
847
+ /**
848
+ * Calculate the intersection point of three plane.
849
+ * @param p1 - Plane 1
850
+ * @param p2 - Plane 2
851
+ * @param p3 - Plane 3
852
+ * @param out - intersection point
853
+ */ CollisionUtil.intersectionPointThreePlanes = function intersectionPointThreePlanes(p1, p2, p3, out) {
854
+ var p1Nor = p1.normal;
855
+ var p2Nor = p2.normal;
856
+ var p3Nor = p3.normal;
857
+ Vector3.cross(p2Nor, p3Nor, CollisionUtil._tempVec30);
858
+ Vector3.cross(p3Nor, p1Nor, CollisionUtil._tempVec31);
859
+ Vector3.cross(p1Nor, p2Nor, CollisionUtil._tempVec32);
860
+ var a = -Vector3.dot(p1Nor, CollisionUtil._tempVec30);
861
+ var b = -Vector3.dot(p2Nor, CollisionUtil._tempVec31);
862
+ var c = -Vector3.dot(p3Nor, CollisionUtil._tempVec32);
863
+ Vector3.scale(CollisionUtil._tempVec30, p1.distance / a, CollisionUtil._tempVec30);
864
+ Vector3.scale(CollisionUtil._tempVec31, p2.distance / b, CollisionUtil._tempVec31);
865
+ Vector3.scale(CollisionUtil._tempVec32, p3.distance / c, CollisionUtil._tempVec32);
866
+ Vector3.add(CollisionUtil._tempVec30, CollisionUtil._tempVec31, out);
867
+ Vector3.add(out, CollisionUtil._tempVec32, out);
868
+ };
869
+ /**
870
+ * Calculate the distance from a point to a plane.
871
+ * @param plane - The plane
872
+ * @param point - The point
873
+ * @returns The distance from a point to a plane
874
+ */ CollisionUtil.distancePlaneAndPoint = function distancePlaneAndPoint(plane, point) {
875
+ return Vector3.dot(plane.normal, point) + plane.distance;
876
+ };
877
+ /**
878
+ * Get the intersection type between a plane and a point.
879
+ * @param plane - The plane
880
+ * @param point - The point
881
+ * @returns The intersection type
882
+ */ CollisionUtil.intersectsPlaneAndPoint = function intersectsPlaneAndPoint(plane, point) {
883
+ var distance = CollisionUtil.distancePlaneAndPoint(plane, point);
884
+ if (distance > 0) {
885
+ return PlaneIntersectionType.Front;
886
+ }
887
+ if (distance < 0) {
888
+ return PlaneIntersectionType.Back;
889
+ }
890
+ return PlaneIntersectionType.Intersecting;
891
+ };
892
+ /**
893
+ * Get the intersection type between a plane and a box (AABB).
894
+ * @param plane - The plane
895
+ * @param box - The box
896
+ * @returns The intersection type
897
+ */ CollisionUtil.intersectsPlaneAndBox = function intersectsPlaneAndBox(plane, box) {
898
+ var min = box.min, max = box.max;
899
+ var normal = plane.normal;
900
+ var front = CollisionUtil._tempVec30;
901
+ var back = CollisionUtil._tempVec31;
902
+ if (normal.x >= 0) {
903
+ front.x = max.x;
904
+ back.x = min.x;
905
+ } else {
906
+ front.x = min.x;
907
+ back.x = max.x;
908
+ }
909
+ if (normal.y >= 0) {
910
+ front.y = max.y;
911
+ back.y = min.y;
912
+ } else {
913
+ front.y = min.y;
914
+ back.y = max.y;
915
+ }
916
+ if (normal.z >= 0) {
917
+ front.z = max.z;
918
+ back.z = min.z;
919
+ } else {
920
+ front.z = min.z;
921
+ back.z = max.z;
922
+ }
923
+ if (CollisionUtil.distancePlaneAndPoint(plane, front) < 0) {
924
+ return PlaneIntersectionType.Back;
925
+ }
926
+ if (CollisionUtil.distancePlaneAndPoint(plane, back) > 0) {
927
+ return PlaneIntersectionType.Front;
928
+ }
929
+ return PlaneIntersectionType.Intersecting;
930
+ };
931
+ /**
932
+ * Get the intersection type between a plane and a sphere.
933
+ * @param plane - The plane
934
+ * @param sphere - The sphere
935
+ * @returns The intersection type
936
+ */ CollisionUtil.intersectsPlaneAndSphere = function intersectsPlaneAndSphere(plane, sphere) {
937
+ var center = sphere.center, radius = sphere.radius;
938
+ var distance = CollisionUtil.distancePlaneAndPoint(plane, center);
939
+ if (distance > radius) {
940
+ return PlaneIntersectionType.Front;
941
+ }
942
+ if (distance < -radius) {
943
+ return PlaneIntersectionType.Back;
944
+ }
945
+ return PlaneIntersectionType.Intersecting;
946
+ };
947
+ /**
948
+ * Get the intersection type between a ray and a plane.
949
+ * @param ray - The ray
950
+ * @param plane - The plane
951
+ * @returns The distance from ray to plane if intersecting, -1 otherwise
952
+ */ CollisionUtil.intersectsRayAndPlane = function intersectsRayAndPlane(ray, plane) {
953
+ var normal = plane.normal;
954
+ var zeroTolerance = MathUtil.zeroTolerance;
955
+ var dir = Vector3.dot(normal, ray.direction);
956
+ // Parallel
957
+ if (Math.abs(dir) < zeroTolerance) {
958
+ return -1;
959
+ }
960
+ var position = Vector3.dot(normal, ray.origin);
961
+ var distance = (-plane.distance - position) / dir;
962
+ if (distance < 0) {
963
+ if (distance < -zeroTolerance) {
964
+ return -1;
965
+ }
966
+ distance = 0;
967
+ }
968
+ return distance;
969
+ };
970
+ /**
971
+ * Get the intersection type between a ray and a box (AABB).
972
+ * @param ray - The ray
973
+ * @param box - The box
974
+ * @returns The distance from ray to box if intersecting, -1 otherwise
975
+ */ CollisionUtil.intersectsRayAndBox = function intersectsRayAndBox(ray, box) {
976
+ var zeroTolerance = MathUtil.zeroTolerance;
977
+ var origin = ray.origin, direction = ray.direction;
978
+ var min = box.min, max = box.max;
979
+ var dirX = direction.x;
980
+ var dirY = direction.y;
981
+ var dirZ = direction.z;
982
+ var oriX = origin.x;
983
+ var oriY = origin.y;
984
+ var oriZ = origin.z;
985
+ var distance = 0;
986
+ var tmax = Number.MAX_VALUE;
987
+ if (Math.abs(dirX) < zeroTolerance) {
988
+ if (oriX < min.x || oriX > max.x) {
989
+ return -1;
990
+ }
991
+ } else {
992
+ var inverse = 1.0 / dirX;
993
+ var t1 = (min.x - oriX) * inverse;
994
+ var t2 = (max.x - oriX) * inverse;
995
+ if (t1 > t2) {
996
+ var temp = t1;
997
+ t1 = t2;
998
+ t2 = temp;
999
+ }
1000
+ distance = Math.max(t1, distance);
1001
+ tmax = Math.min(t2, tmax);
1002
+ if (distance > tmax) {
1003
+ return -1;
1004
+ }
1005
+ }
1006
+ if (Math.abs(dirY) < zeroTolerance) {
1007
+ if (oriY < min.y || oriY > max.y) {
1008
+ return -1;
1009
+ }
1010
+ } else {
1011
+ var inverse1 = 1.0 / dirY;
1012
+ var t11 = (min.y - oriY) * inverse1;
1013
+ var t21 = (max.y - oriY) * inverse1;
1014
+ if (t11 > t21) {
1015
+ var temp1 = t11;
1016
+ t11 = t21;
1017
+ t21 = temp1;
1018
+ }
1019
+ distance = Math.max(t11, distance);
1020
+ tmax = Math.min(t21, tmax);
1021
+ if (distance > tmax) {
1022
+ return -1;
1023
+ }
1024
+ }
1025
+ if (Math.abs(dirZ) < zeroTolerance) {
1026
+ if (oriZ < min.z || oriZ > max.z) {
1027
+ return -1;
1028
+ }
1029
+ } else {
1030
+ var inverse2 = 1.0 / dirZ;
1031
+ var t12 = (min.z - oriZ) * inverse2;
1032
+ var t22 = (max.z - oriZ) * inverse2;
1033
+ if (t12 > t22) {
1034
+ var temp2 = t12;
1035
+ t12 = t22;
1036
+ t22 = temp2;
1037
+ }
1038
+ distance = Math.max(t12, distance);
1039
+ tmax = Math.min(t22, tmax);
1040
+ if (distance > tmax) {
1041
+ return -1;
1042
+ }
1043
+ }
1044
+ return distance;
1045
+ };
1046
+ /**
1047
+ * Get the intersection type between a ray and a sphere.
1048
+ * @param ray - The ray
1049
+ * @param sphere - The sphere
1050
+ * @returns The distance from ray to sphere if intersecting, -1 otherwise
1051
+ */ CollisionUtil.intersectsRayAndSphere = function intersectsRayAndSphere(ray, sphere) {
1052
+ var origin = ray.origin, direction = ray.direction;
1053
+ var center = sphere.center, radius = sphere.radius;
1054
+ var m = CollisionUtil._tempVec30;
1055
+ Vector3.subtract(origin, center, m);
1056
+ var b = Vector3.dot(m, direction);
1057
+ var c = Vector3.dot(m, m) - radius * radius;
1058
+ if (b > 0 && c > 0) {
1059
+ return -1;
1060
+ }
1061
+ var discriminant = b * b - c;
1062
+ if (discriminant < 0) {
1063
+ return -1;
1064
+ }
1065
+ var distance = -b - Math.sqrt(discriminant);
1066
+ if (distance < 0) {
1067
+ distance = 0;
1068
+ }
1069
+ return distance;
1070
+ };
1071
+ /**
1072
+ * Check whether the boxes intersect.
1073
+ * @param boxA - The first box to check
1074
+ * @param boxB - The second box to check
1075
+ * @returns True if the boxes intersect, false otherwise
1076
+ */ CollisionUtil.intersectsBoxAndBox = function intersectsBoxAndBox(boxA, boxB) {
1077
+ if (boxA.min.x > boxB.max.x || boxB.min.x > boxA.max.x) {
1078
+ return false;
1079
+ }
1080
+ if (boxA.min.y > boxB.max.y || boxB.min.y > boxA.max.y) {
1081
+ return false;
1082
+ }
1083
+ return !(boxA.min.z > boxB.max.z || boxB.min.z > boxA.max.z);
1084
+ };
1085
+ /**
1086
+ * Check whether the spheres intersect.
1087
+ * @param sphereA - The first sphere to check
1088
+ * @param sphereB - The second sphere to check
1089
+ * @returns True if the spheres intersect, false otherwise
1090
+ */ CollisionUtil.intersectsSphereAndSphere = function intersectsSphereAndSphere(sphereA, sphereB) {
1091
+ var radiisum = sphereA.radius + sphereB.radius;
1092
+ return Vector3.distanceSquared(sphereA.center, sphereB.center) < radiisum * radiisum;
1093
+ };
1094
+ /**
1095
+ * Check whether the sphere and the box intersect.
1096
+ * @param sphere - The sphere to check
1097
+ * @param box - The box to check
1098
+ * @returns True if the sphere and the box intersect, false otherwise
1099
+ */ CollisionUtil.intersectsSphereAndBox = function intersectsSphereAndBox(sphere, box) {
1100
+ var center = sphere.center;
1101
+ var max = box.max;
1102
+ var min = box.min;
1103
+ var closestPoint = CollisionUtil._tempVec30;
1104
+ closestPoint.set(Math.max(min.x, Math.min(center.x, max.x)), Math.max(min.y, Math.min(center.y, max.y)), Math.max(min.z, Math.min(center.z, max.z)));
1105
+ var distance = Vector3.distanceSquared(center, closestPoint);
1106
+ return distance <= sphere.radius * sphere.radius;
1107
+ };
1108
+ /**
1109
+ * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
1110
+ * @param frustum - The frustum
1111
+ * @param box - The box
1112
+ * @returns True if bounding box intersects with this frustum, false otherwise
1113
+ */ CollisionUtil.intersectsFrustumAndBox = function intersectsFrustumAndBox(frustum, box) {
1114
+ var min = box.min, max = box.max;
1115
+ var p = CollisionUtil._tempVec30;
1116
+ for(var i = 0; i < 6; ++i){
1117
+ var plane = frustum.getPlane(i);
1118
+ var normal = plane.normal;
1119
+ p.set(normal.x >= 0 ? max.x : min.x, normal.y >= 0 ? max.y : min.y, normal.z >= 0 ? max.z : min.z);
1120
+ if (Vector3.dot(normal, p) < -plane.distance) {
1121
+ return false;
1122
+ }
1123
+ }
1124
+ return true;
1125
+ };
1126
+ /**
1127
+ * Get the containment type between a frustum and a box (AABB).
1128
+ * @param frustum - The frustum
1129
+ * @param box - The box
1130
+ * @returns The containment type
1131
+ */ CollisionUtil.frustumContainsBox = function frustumContainsBox(frustum, box) {
1132
+ var min = box.min, max = box.max;
1133
+ var p = CollisionUtil._tempVec30;
1134
+ var n = CollisionUtil._tempVec31;
1135
+ var result = ContainmentType.Contains;
1136
+ for(var i = 0; i < 6; ++i){
1137
+ var plane = frustum.getPlane(i);
1138
+ var normal = plane.normal;
1139
+ if (normal.x >= 0) {
1140
+ p.x = max.x;
1141
+ n.x = min.x;
1142
+ } else {
1143
+ p.x = min.x;
1144
+ n.x = max.x;
1145
+ }
1146
+ if (normal.y >= 0) {
1147
+ p.y = max.y;
1148
+ n.y = min.y;
1149
+ } else {
1150
+ p.y = min.y;
1151
+ n.y = max.y;
1152
+ }
1153
+ if (normal.z >= 0) {
1154
+ p.z = max.z;
1155
+ n.z = min.z;
1156
+ } else {
1157
+ p.z = min.z;
1158
+ n.z = max.z;
1159
+ }
1160
+ if (CollisionUtil.intersectsPlaneAndPoint(plane, p) === PlaneIntersectionType.Back) {
1161
+ return ContainmentType.Disjoint;
1162
+ }
1163
+ if (CollisionUtil.intersectsPlaneAndPoint(plane, n) === PlaneIntersectionType.Back) {
1164
+ result = ContainmentType.Intersects;
1165
+ }
1166
+ }
1167
+ return result;
1168
+ };
1169
+ /**
1170
+ * Get the containment type between a frustum and a sphere.
1171
+ * @param frustum - The frustum
1172
+ * @param sphere - The sphere
1173
+ * @returns The containment type
1174
+ */ CollisionUtil.frustumContainsSphere = function frustumContainsSphere(frustum, sphere) {
1175
+ var result = ContainmentType.Contains;
1176
+ for(var i = 0; i < 6; ++i){
1177
+ var plane = frustum.getPlane(i);
1178
+ var intersectionType = CollisionUtil.intersectsPlaneAndSphere(plane, sphere);
1179
+ if (intersectionType === PlaneIntersectionType.Back) {
1180
+ return ContainmentType.Disjoint;
1181
+ } else if (intersectionType === PlaneIntersectionType.Intersecting) {
1182
+ result = ContainmentType.Intersects;
1183
+ break;
1184
+ }
1185
+ }
1186
+ return result;
1187
+ };
1188
+ return CollisionUtil;
1189
+ }();
1190
+ (function() {
1191
+ CollisionUtil._tempVec30 = new Vector3();
1192
+ })();
1193
+ (function() {
1194
+ CollisionUtil._tempVec31 = new Vector3();
1195
+ })();
1196
+ (function() {
1197
+ CollisionUtil._tempVec32 = new Vector3();
1198
+ })();
1199
+
1200
+ /**
1201
+ * Represents a plane in three-dimensional space.
1202
+ */ var Plane = /*#__PURE__*/ function() {
1203
+ function Plane(normal, distance) {
1204
+ if (normal === void 0) normal = null;
1205
+ if (distance === void 0) distance = 0;
1206
+ /** The normal of the plane. */ this.normal = new Vector3();
1207
+ /** The distance of the plane along its normal to the origin. */ this.distance = 0;
1208
+ normal && this.normal.copyFrom(normal);
1209
+ this.distance = distance;
1210
+ }
1211
+ var _proto = Plane.prototype;
1212
+ /**
1213
+ * Normalize the normal vector of this plane.
1214
+ * @returns The plane after normalize
1215
+ */ _proto.normalize = function normalize() {
1216
+ Plane.normalize(this, this);
1217
+ return this;
1218
+ };
1219
+ /**
1220
+ * Creates a clone of this plane.
1221
+ * @returns A clone of this plane
1222
+ */ _proto.clone = function clone() {
1223
+ var out = new Plane();
1224
+ out.copyFrom(this);
1225
+ return out;
1226
+ };
1227
+ /**
1228
+ * Copy this plane from the specified plane.
1229
+ * @param source - The specified plane
1230
+ * @returns This plane
1231
+ */ _proto.copyFrom = function copyFrom(source) {
1232
+ this.normal.copyFrom(source.normal);
1233
+ this.distance = source.distance;
1234
+ return this;
1235
+ };
1236
+ /**
1237
+ * Normalize the normal vector of the specified plane.
1238
+ * @param p - The specified plane
1239
+ * @param out - A normalized version of the specified plane
1240
+ */ Plane.normalize = function normalize(p, out) {
1241
+ var normal = p.normal;
1242
+ var factor = 1.0 / normal.length();
1243
+ Vector3.scale(normal, factor, out.normal);
1244
+ out.distance = p.distance * factor;
1245
+ };
1246
+ /**
1247
+ * Calculate the plane that contains the three specified points.
1248
+ * @param point0 - The first point
1249
+ * @param point1 - The second point
1250
+ * @param point2 - The third point
1251
+ * @param out - The calculated plane
1252
+ */ Plane.fromPoints = function fromPoints(point0, point1, point2, out) {
1253
+ var x0 = point0.x;
1254
+ var y0 = point0.y;
1255
+ var z0 = point0.z;
1256
+ var x1 = point1.x - x0;
1257
+ var y1 = point1.y - y0;
1258
+ var z1 = point1.z - z0;
1259
+ var x2 = point2.x - x0;
1260
+ var y2 = point2.y - y0;
1261
+ var z2 = point2.z - z0;
1262
+ var yz = y1 * z2 - z1 * y2;
1263
+ var xz = z1 * x2 - x1 * z2;
1264
+ var xy = x1 * y2 - y1 * x2;
1265
+ var invPyth = 1.0 / Math.sqrt(yz * yz + xz * xz + xy * xy);
1266
+ var x = yz * invPyth;
1267
+ var y = xz * invPyth;
1268
+ var z = xy * invPyth;
1269
+ var normal = out.normal;
1270
+ normal.x = x;
1271
+ normal.y = y;
1272
+ normal.z = z;
1273
+ out.distance = -(x * x0 + y * y0 + z * z0);
1274
+ };
1275
+ return Plane;
1276
+ }();
1277
+
1278
+ /**
1279
+ * A bounding frustum.
1280
+ */ var BoundingFrustum = /*#__PURE__*/ function() {
1281
+ function BoundingFrustum(matrix) {
1282
+ if (matrix === void 0) matrix = null;
1283
+ this.near = new Plane();
1284
+ this.far = new Plane();
1285
+ this.left = new Plane();
1286
+ this.right = new Plane();
1287
+ this.top = new Plane();
1288
+ this.bottom = new Plane();
1289
+ matrix && this.calculateFromMatrix(matrix);
1290
+ }
1291
+ var _proto = BoundingFrustum.prototype;
1292
+ /**
1293
+ * Get the plane by the given frustum face.
1294
+ * @param face - The frustum face
1295
+ * @returns The plane get
1296
+ */ _proto.getPlane = function getPlane(face) {
1297
+ switch(face){
1298
+ case FrustumFace.Near:
1299
+ return this.near;
1300
+ case FrustumFace.Far:
1301
+ return this.far;
1302
+ case FrustumFace.Left:
1303
+ return this.left;
1304
+ case FrustumFace.Right:
1305
+ return this.right;
1306
+ case FrustumFace.Bottom:
1307
+ return this.bottom;
1308
+ case FrustumFace.Top:
1309
+ return this.top;
1310
+ default:
1311
+ return null;
1312
+ }
1313
+ };
1314
+ /**
1315
+ * Update all planes from the given matrix.
1316
+ * @param matrix - The given view-projection matrix
1317
+ */ _proto.calculateFromMatrix = function calculateFromMatrix(matrix) {
1318
+ var me = matrix.elements;
1319
+ var m11 = me[0];
1320
+ var m12 = me[1];
1321
+ var m13 = me[2];
1322
+ var m14 = me[3];
1323
+ var m21 = me[4];
1324
+ var m22 = me[5];
1325
+ var m23 = me[6];
1326
+ var m24 = me[7];
1327
+ var m31 = me[8];
1328
+ var m32 = me[9];
1329
+ var m33 = me[10];
1330
+ var m34 = me[11];
1331
+ var m41 = me[12];
1332
+ var m42 = me[13];
1333
+ var m43 = me[14];
1334
+ var m44 = me[15];
1335
+ // near
1336
+ var nearNormal = this.near.normal;
1337
+ nearNormal.set(m14 + m13, m24 + m23, m34 + m33);
1338
+ this.near.distance = m44 + m43;
1339
+ this.near.normalize();
1340
+ // far
1341
+ var farNormal = this.far.normal;
1342
+ farNormal.set(m14 - m13, m24 - m23, m34 - m33);
1343
+ this.far.distance = m44 - m43;
1344
+ this.far.normalize();
1345
+ // left
1346
+ var leftNormal = this.left.normal;
1347
+ leftNormal.set(m14 + m11, m24 + m21, m34 + m31);
1348
+ this.left.distance = m44 + m41;
1349
+ this.left.normalize();
1350
+ // right
1351
+ var rightNormal = this.right.normal;
1352
+ rightNormal.set(m14 - m11, m24 - m21, m34 - m31);
1353
+ this.right.distance = m44 - m41;
1354
+ this.right.normalize();
1355
+ // bottom
1356
+ var bottomNormal = this.bottom.normal;
1357
+ bottomNormal.set(m14 + m12, m24 + m22, m34 + m32);
1358
+ this.bottom.distance = m44 + m42;
1359
+ this.bottom.normalize();
1360
+ // top
1361
+ var topNormal = this.top.normal;
1362
+ topNormal.set(m14 - m12, m24 - m22, m34 - m32);
1363
+ this.top.distance = m44 - m42;
1364
+ this.top.normalize();
1365
+ };
1366
+ /**
1367
+ * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
1368
+ * @param box - The box for testing
1369
+ * @returns True if bounding box intersects with this frustum, false otherwise
1370
+ */ _proto.intersectsBox = function intersectsBox(box) {
1371
+ return CollisionUtil.intersectsFrustumAndBox(this, box);
1372
+ };
1373
+ /**
1374
+ * Get whether or not a specified bounding sphere intersects with this frustum (Contains or Intersects).
1375
+ * @param sphere - The sphere for testing
1376
+ * @returns True if bounding sphere intersects with this frustum, false otherwise
1377
+ */ _proto.intersectsSphere = function intersectsSphere(sphere) {
1378
+ return CollisionUtil.frustumContainsSphere(this, sphere) !== ContainmentType.Disjoint;
1379
+ };
1380
+ /**
1381
+ * Creates a clone of this frustum.
1382
+ * @returns A clone of this frustum
1383
+ */ _proto.clone = function clone() {
1384
+ var out = new BoundingFrustum();
1385
+ out.copyFrom(this);
1386
+ return out;
1387
+ };
1388
+ /**
1389
+ * Copy this frustum from the specified frustum.
1390
+ * @param source - The specified frustum
1391
+ * @returns This frustum
1392
+ */ _proto.copyFrom = function copyFrom(source) {
1393
+ this.near.copyFrom(source.near);
1394
+ this.far.copyFrom(source.far);
1395
+ this.left.copyFrom(source.left);
1396
+ this.right.copyFrom(source.right);
1397
+ this.bottom.copyFrom(source.bottom);
1398
+ this.top.copyFrom(source.top);
1399
+ return this;
1400
+ };
1401
+ return BoundingFrustum;
1402
+ }();
1403
+
1404
+ /**
1405
+ * Represents a 3x3 mathematical matrix.
1406
+ */ var Matrix3x3 = /*#__PURE__*/ function() {
1407
+ function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
1408
+ if (m11 === void 0) m11 = 1;
1409
+ if (m12 === void 0) m12 = 0;
1410
+ if (m13 === void 0) m13 = 0;
1411
+ if (m21 === void 0) m21 = 0;
1412
+ if (m22 === void 0) m22 = 1;
1413
+ if (m23 === void 0) m23 = 0;
1414
+ if (m31 === void 0) m31 = 0;
1415
+ if (m32 === void 0) m32 = 0;
1416
+ if (m33 === void 0) m33 = 1;
1417
+ /**
1418
+ * An array containing the elements of the matrix (column matrix).
1419
+ * @remarks
1420
+ * elements[0] first column and first row value m11
1421
+ * elements[1] first column and second row value m12
1422
+ * elements[2] first column and third row value m13
1423
+ * elements[3] second column and first row value m21
1424
+ * and so on
1425
+ */ this.elements = new Float32Array(9);
1426
+ var e = this.elements;
1427
+ e[0] = m11;
1428
+ e[1] = m12;
1429
+ e[2] = m13;
1430
+ e[3] = m21;
1431
+ e[4] = m22;
1432
+ e[5] = m23;
1433
+ e[6] = m31;
1434
+ e[7] = m32;
1435
+ e[8] = m33;
1436
+ }
1437
+ var _proto = Matrix3x3.prototype;
1438
+ /**
1439
+ * Set the value of this matrix, and return this matrix.
1440
+ * @param m11
1441
+ * @param m12
1442
+ * @param m13
1443
+ * @param m21
1444
+ * @param m22
1445
+ * @param m23
1446
+ * @param m31
1447
+ * @param m32
1448
+ * @param m33
1449
+ * @returns This matrix
1450
+ */ _proto.set = function set(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
1451
+ var e = this.elements;
1452
+ e[0] = m11;
1453
+ e[1] = m12;
1454
+ e[2] = m13;
1455
+ e[3] = m21;
1456
+ e[4] = m22;
1457
+ e[5] = m23;
1458
+ e[6] = m31;
1459
+ e[7] = m32;
1460
+ e[8] = m33;
1461
+ return this;
1462
+ };
1463
+ /**
1464
+ * Determines the sum of this matrix and the specified matrix.
1465
+ * @param right - The specified matrix
1466
+ * @returns This matrix that store the sum of the two matrices
1467
+ */ _proto.add = function add(right) {
1468
+ Matrix3x3.add(this, right, this);
1469
+ return this;
1470
+ };
1471
+ /**
1472
+ * Determines the difference between this matrix and the specified matrix.
1473
+ * @param right - The specified matrix
1474
+ * @returns This matrix that store the difference between the two matrices
1475
+ */ _proto.subtract = function subtract(right) {
1476
+ Matrix3x3.subtract(this, right, this);
1477
+ return this;
1478
+ };
1479
+ /**
1480
+ * Determines the product of this matrix and the specified matrix.
1481
+ * @param right - The specified matrix
1482
+ * @returns This matrix that store the product of the two matrices
1483
+ */ _proto.multiply = function multiply(right) {
1484
+ Matrix3x3.multiply(this, right, this);
1485
+ return this;
1486
+ };
1487
+ /**
1488
+ * Calculate a determinant of this matrix.
1489
+ * @returns The determinant of this matrix
1490
+ */ _proto.determinant = function determinant() {
1491
+ var e = this.elements;
1492
+ var a11 = e[0], a12 = e[1], a13 = e[2];
1493
+ var a21 = e[3], a22 = e[4], a23 = e[5];
1494
+ var a31 = e[6], a32 = e[7], a33 = e[8];
1495
+ var b12 = a33 * a22 - a23 * a32;
1496
+ var b22 = -a33 * a21 + a23 * a31;
1497
+ var b32 = a32 * a21 - a22 * a31;
1498
+ return a11 * b12 + a12 * b22 + a13 * b32;
1499
+ };
1500
+ /**
1501
+ * Identity this matrix.
1502
+ * @returns This matrix after identity
1503
+ */ _proto.identity = function identity() {
1504
+ var e = this.elements;
1505
+ e[0] = 1;
1506
+ e[1] = 0;
1507
+ e[2] = 0;
1508
+ e[3] = 0;
1509
+ e[4] = 1;
1510
+ e[5] = 0;
1511
+ e[6] = 0;
1512
+ e[7] = 0;
1513
+ e[8] = 1;
1514
+ return this;
1515
+ };
1516
+ /**
1517
+ * Invert the matrix.
1518
+ * @returns The matrix after invert
1519
+ */ _proto.invert = function invert() {
1520
+ Matrix3x3.invert(this, this);
1521
+ return this;
1522
+ };
1523
+ /**
1524
+ * This matrix rotates around an angle.
1525
+ * @param r - The rotation angle in radians
1526
+ * @returns This matrix after rotate
1527
+ */ _proto.rotate = function rotate(r) {
1528
+ Matrix3x3.rotate(this, r, this);
1529
+ return this;
1530
+ };
1531
+ /**
1532
+ * Scale this matrix by a given vector.
1533
+ * @param s - The given vector
1534
+ * @returns This matrix after scale
1535
+ */ _proto.scale = function scale(s) {
1536
+ Matrix3x3.scale(this, s, this);
1537
+ return this;
1538
+ };
1539
+ /**
1540
+ * Translate this matrix by a given vector.
1541
+ * @param translation - The given vector
1542
+ * @returns This matrix after translate
1543
+ */ _proto.translate = function translate(translation) {
1544
+ Matrix3x3.translate(this, translation, this);
1545
+ return this;
1546
+ };
1547
+ /**
1548
+ * Calculate the transpose of this matrix.
1549
+ * @returns This matrix after transpose
1550
+ */ _proto.transpose = function transpose() {
1551
+ Matrix3x3.transpose(this, this);
1552
+ return this;
1553
+ };
1554
+ /**
1555
+ * Creates a clone of this matrix.
1556
+ * @returns A clone of this matrix
1557
+ */ _proto.clone = function clone() {
1558
+ var e = this.elements;
1559
+ var ret = new Matrix3x3(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8]);
1560
+ return ret;
1561
+ };
1562
+ /**
1563
+ * Copy this matrix from the specified matrix.
1564
+ * @param source - The specified matrix
1565
+ * @returns This matrix
1566
+ */ _proto.copyFrom = function copyFrom(source) {
1567
+ var e = this.elements;
1568
+ var se = source.elements;
1569
+ e[0] = se[0];
1570
+ e[1] = se[1];
1571
+ e[2] = se[2];
1572
+ e[3] = se[3];
1573
+ e[4] = se[4];
1574
+ e[5] = se[5];
1575
+ e[6] = se[6];
1576
+ e[7] = se[7];
1577
+ e[8] = se[8];
1578
+ return this;
1579
+ };
1580
+ /**
1581
+ * Copy the value of this matrix from an array.
1582
+ * @param array - The array
1583
+ * @param offset - The start offset of the array
1584
+ * @returns This matrix
1585
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
1586
+ if (offset === void 0) offset = 0;
1587
+ var srce = this.elements;
1588
+ for(var i = 0; i < 12; i++){
1589
+ srce[i] = array[i + offset];
1590
+ }
1591
+ return this;
1592
+ };
1593
+ /**
1594
+ * Copy the value of this matrix to an array.
1595
+ * @param out - The array
1596
+ * @param outOffset - The start offset of the array
1597
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
1598
+ if (outOffset === void 0) outOffset = 0;
1599
+ var e = this.elements;
1600
+ out[outOffset] = e[0];
1601
+ out[outOffset + 1] = e[1];
1602
+ out[outOffset + 2] = e[2];
1603
+ out[outOffset + 3] = e[3];
1604
+ out[outOffset + 4] = e[4];
1605
+ out[outOffset + 5] = e[5];
1606
+ out[outOffset + 6] = e[6];
1607
+ out[outOffset + 7] = e[7];
1608
+ out[outOffset + 8] = e[8];
1609
+ };
1610
+ /**
1611
+ * Copy the value of this 3x3 matrix from the specified 4x4 matrix.
1612
+ * upper-left principle
1613
+ * @param source - The specified 4x4 matrix
1614
+ * @returns This 3x3 matrix
1615
+ */ _proto.copyFromMatrix = function copyFromMatrix(source) {
1616
+ var ae = source.elements;
1617
+ var e = this.elements;
1618
+ e[0] = ae[0];
1619
+ e[1] = ae[1];
1620
+ e[2] = ae[2];
1621
+ e[3] = ae[4];
1622
+ e[4] = ae[5];
1623
+ e[5] = ae[6];
1624
+ e[6] = ae[8];
1625
+ e[7] = ae[9];
1626
+ e[8] = ae[10];
1627
+ return this;
1628
+ };
1629
+ /**
1630
+ * Determines the sum of two matrices.
1631
+ * @param left - The first matrix to add
1632
+ * @param right - The second matrix to add
1633
+ * @param out - The sum of two matrices
1634
+ */ Matrix3x3.add = function add(left, right, out) {
1635
+ var le = left.elements;
1636
+ var re = right.elements;
1637
+ var oe = out.elements;
1638
+ oe[0] = le[0] + re[0];
1639
+ oe[1] = le[1] + re[1];
1640
+ oe[2] = le[2] + re[2];
1641
+ oe[3] = le[3] + re[3];
1642
+ oe[4] = le[4] + re[4];
1643
+ oe[5] = le[5] + re[5];
1644
+ oe[6] = le[6] + re[6];
1645
+ oe[7] = le[7] + re[7];
1646
+ oe[8] = le[8] + re[8];
1647
+ };
1648
+ /**
1649
+ * Determines the difference between two matrices.
1650
+ * @param left - The first matrix to subtract
1651
+ * @param right - The second matrix to subtract
1652
+ * @param out - The difference between two matrices
1653
+ */ Matrix3x3.subtract = function subtract(left, right, out) {
1654
+ var le = left.elements;
1655
+ var re = right.elements;
1656
+ var oe = out.elements;
1657
+ oe[0] = le[0] - re[0];
1658
+ oe[1] = le[1] - re[1];
1659
+ oe[2] = le[2] - re[2];
1660
+ oe[3] = le[3] - re[3];
1661
+ oe[4] = le[4] - re[4];
1662
+ oe[5] = le[5] - re[5];
1663
+ oe[6] = le[6] - re[6];
1664
+ oe[7] = le[7] - re[7];
1665
+ oe[8] = le[8] - re[8];
1666
+ };
1667
+ /**
1668
+ * Determines the product of two matrices.
1669
+ * @param left - The first matrix to multiply
1670
+ * @param right - The second matrix to multiply
1671
+ * @param out - The product of two matrices
1672
+ */ Matrix3x3.multiply = function multiply(left, right, out) {
1673
+ var le = left.elements;
1674
+ var re = right.elements;
1675
+ var oe = out.elements;
1676
+ var l11 = le[0], l12 = le[1], l13 = le[2];
1677
+ var l21 = le[3], l22 = le[4], l23 = le[5];
1678
+ var l31 = le[6], l32 = le[7], l33 = le[8];
1679
+ var r11 = re[0], r12 = re[1], r13 = re[2];
1680
+ var r21 = re[3], r22 = re[4], r23 = re[5];
1681
+ var r31 = re[6], r32 = re[7], r33 = re[8];
1682
+ oe[0] = l11 * r11 + l21 * r12 + l31 * r13;
1683
+ oe[1] = l12 * r11 + l22 * r12 + l32 * r13;
1684
+ oe[2] = l13 * r11 + l23 * r12 + l33 * r13;
1685
+ oe[3] = l11 * r21 + l21 * r22 + l31 * r23;
1686
+ oe[4] = l12 * r21 + l22 * r22 + l32 * r23;
1687
+ oe[5] = l13 * r21 + l23 * r22 + l33 * r23;
1688
+ oe[6] = l11 * r31 + l21 * r32 + l31 * r33;
1689
+ oe[7] = l12 * r31 + l22 * r32 + l32 * r33;
1690
+ oe[8] = l13 * r31 + l23 * r32 + l33 * r33;
1691
+ };
1692
+ /**
1693
+ * Determines whether the specified matrices are equals.
1694
+ * @param left - The first matrix to compare
1695
+ * @param right - The second matrix to compare
1696
+ * @returns True if the specified matrices are equals, false otherwise
1697
+ */ Matrix3x3.equals = function equals(left, right) {
1698
+ var le = left.elements;
1699
+ var re = right.elements;
1700
+ return MathUtil.equals(le[0], re[0]) && MathUtil.equals(le[1], re[1]) && MathUtil.equals(le[2], re[2]) && MathUtil.equals(le[3], re[3]) && MathUtil.equals(le[4], re[4]) && MathUtil.equals(le[5], re[5]) && MathUtil.equals(le[6], re[6]) && MathUtil.equals(le[7], re[7]) && MathUtil.equals(le[8], re[8]);
1701
+ };
1702
+ /**
1703
+ * Performs a linear interpolation between two matrices.
1704
+ * @param start - The first matrix
1705
+ * @param end - The second matrix
1706
+ * @param t - The blend amount where 0 returns start and 1 end
1707
+ * @param out - The result of linear blending between two matrices
1708
+ */ Matrix3x3.lerp = function lerp(start, end, t, out) {
1709
+ var se = start.elements;
1710
+ var ee = end.elements;
1711
+ var oe = out.elements;
1712
+ var inv = 1.0 - t;
1713
+ oe[0] = se[0] * inv + ee[0] * t;
1714
+ oe[1] = se[1] * inv + ee[1] * t;
1715
+ oe[2] = se[2] * inv + ee[2] * t;
1716
+ oe[3] = se[3] * inv + ee[3] * t;
1717
+ oe[4] = se[4] * inv + ee[4] * t;
1718
+ oe[5] = se[5] * inv + ee[5] * t;
1719
+ oe[6] = se[6] * inv + ee[6] * t;
1720
+ oe[7] = se[7] * inv + ee[7] * t;
1721
+ oe[8] = se[8] * inv + ee[8] * t;
1722
+ };
1723
+ /**
1724
+ * Calculate a rotation matrix from a quaternion.
1725
+ * @param quaternion - The quaternion used to calculate the matrix
1726
+ * @param out - The calculated rotation matrix
1727
+ */ Matrix3x3.rotationQuaternion = function rotationQuaternion(quaternion, out) {
1728
+ var oe = out.elements;
1729
+ var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
1730
+ var x2 = x + x;
1731
+ var y2 = y + y;
1732
+ var z2 = z + z;
1733
+ var xx = x * x2;
1734
+ var yx = y * x2;
1735
+ var yy = y * y2;
1736
+ var zx = z * x2;
1737
+ var zy = z * y2;
1738
+ var zz = z * z2;
1739
+ var wx = w * x2;
1740
+ var wy = w * y2;
1741
+ var wz = w * z2;
1742
+ oe[0] = 1 - yy - zz;
1743
+ oe[3] = yx - wz;
1744
+ oe[6] = zx + wy;
1745
+ oe[1] = yx + wz;
1746
+ oe[4] = 1 - xx - zz;
1747
+ oe[7] = zy - wx;
1748
+ oe[2] = zx - wy;
1749
+ oe[5] = zy + wx;
1750
+ oe[8] = 1 - xx - yy;
1751
+ };
1752
+ /**
1753
+ * Calculate a matrix from scale vector.
1754
+ * @param s - The scale vector
1755
+ * @param out - The calculated matrix
1756
+ */ Matrix3x3.scaling = function scaling(s, out) {
1757
+ var oe = out.elements;
1758
+ oe[0] = s._x;
1759
+ oe[1] = 0;
1760
+ oe[2] = 0;
1761
+ oe[3] = 0;
1762
+ oe[4] = s._y;
1763
+ oe[5] = 0;
1764
+ oe[6] = 0;
1765
+ oe[7] = 0;
1766
+ oe[8] = 1;
1767
+ };
1768
+ /**
1769
+ * Calculate a matrix from translation vector.
1770
+ * @param translation - The translation vector
1771
+ * @param out - The calculated matrix
1772
+ */ Matrix3x3.translation = function translation(translation, out) {
1773
+ var oe = out.elements;
1774
+ oe[0] = 1;
1775
+ oe[1] = 0;
1776
+ oe[2] = 0;
1777
+ oe[3] = 0;
1778
+ oe[4] = 1;
1779
+ oe[5] = 0;
1780
+ oe[6] = translation._x;
1781
+ oe[7] = translation._y;
1782
+ oe[8] = 1;
1783
+ };
1784
+ /**
1785
+ * Calculate the inverse of the specified matrix.
1786
+ * @param a - The matrix whose inverse is to be calculated
1787
+ * @param out - The inverse of the specified matrix
1788
+ */ Matrix3x3.invert = function invert(a, out) {
1789
+ var ae = a.elements;
1790
+ var oe = out.elements;
1791
+ var a11 = ae[0], a12 = ae[1], a13 = ae[2];
1792
+ var a21 = ae[3], a22 = ae[4], a23 = ae[5];
1793
+ var a31 = ae[6], a32 = ae[7], a33 = ae[8];
1794
+ var b12 = a33 * a22 - a23 * a32;
1795
+ var b22 = -a33 * a21 + a23 * a31;
1796
+ var b32 = a32 * a21 - a22 * a31;
1797
+ var det = a11 * b12 + a12 * b22 + a13 * b32;
1798
+ if (!det) {
1799
+ return;
1800
+ }
1801
+ det = 1.0 / det;
1802
+ oe[0] = b12 * det;
1803
+ oe[1] = (-a33 * a12 + a13 * a32) * det;
1804
+ oe[2] = (a23 * a12 - a13 * a22) * det;
1805
+ oe[3] = b22 * det;
1806
+ oe[4] = (a33 * a11 - a13 * a31) * det;
1807
+ oe[5] = (-a23 * a11 + a13 * a21) * det;
1808
+ oe[6] = b32 * det;
1809
+ oe[7] = (-a32 * a11 + a12 * a31) * det;
1810
+ oe[8] = (a22 * a11 - a12 * a21) * det;
1811
+ };
1812
+ /**
1813
+ * Calculate a 3x3 normal matrix from a 4x4 matrix.
1814
+ * @remarks The calculation process is the transpose matrix of the inverse matrix.
1815
+ * @param mat4 - The 4x4 matrix
1816
+ * @param out - THe 3x3 normal matrix
1817
+ */ Matrix3x3.normalMatrix = function normalMatrix(mat4, out) {
1818
+ var ae = mat4.elements;
1819
+ var oe = out.elements;
1820
+ var a11 = ae[0], a12 = ae[1], a13 = ae[2], a14 = ae[3];
1821
+ var a21 = ae[4], a22 = ae[5], a23 = ae[6], a24 = ae[7];
1822
+ var a31 = ae[8], a32 = ae[9], a33 = ae[10], a34 = ae[11];
1823
+ var a41 = ae[12], a42 = ae[13], a43 = ae[14], a44 = ae[15];
1824
+ var b00 = a11 * a22 - a12 * a21;
1825
+ var b01 = a11 * a23 - a13 * a21;
1826
+ var b02 = a11 * a24 - a14 * a21;
1827
+ var b03 = a12 * a23 - a13 * a22;
1828
+ var b04 = a12 * a24 - a14 * a22;
1829
+ var b05 = a13 * a24 - a14 * a23;
1830
+ var b06 = a31 * a42 - a32 * a41;
1831
+ var b07 = a31 * a43 - a33 * a41;
1832
+ var b08 = a31 * a44 - a34 * a41;
1833
+ var b09 = a32 * a43 - a33 * a42;
1834
+ var b10 = a32 * a44 - a34 * a42;
1835
+ var b11 = a33 * a44 - a34 * a43;
1836
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1837
+ if (!det) {
1838
+ return null;
1839
+ }
1840
+ det = 1.0 / det;
1841
+ oe[0] = (a22 * b11 - a23 * b10 + a24 * b09) * det;
1842
+ oe[1] = (a23 * b08 - a21 * b11 - a24 * b07) * det;
1843
+ oe[2] = (a21 * b10 - a22 * b08 + a24 * b06) * det;
1844
+ oe[3] = (a13 * b10 - a12 * b11 - a14 * b09) * det;
1845
+ oe[4] = (a11 * b11 - a13 * b08 + a14 * b07) * det;
1846
+ oe[5] = (a12 * b08 - a11 * b10 - a14 * b06) * det;
1847
+ oe[6] = (a42 * b05 - a43 * b04 + a44 * b03) * det;
1848
+ oe[7] = (a43 * b02 - a41 * b05 - a44 * b01) * det;
1849
+ oe[8] = (a41 * b04 - a42 * b02 + a44 * b00) * det;
1850
+ };
1851
+ /**
1852
+ * The specified matrix rotates around an angle.
1853
+ * @param a - The specified matrix
1854
+ * @param r - The rotation angle in radians
1855
+ * @param out - The rotated matrix
1856
+ */ Matrix3x3.rotate = function rotate(a, r, out) {
1857
+ var ae = a.elements;
1858
+ var oe = out.elements;
1859
+ var s = Math.sin(r);
1860
+ var c = Math.cos(r);
1861
+ var a11 = ae[0], a12 = ae[1], a13 = ae[2];
1862
+ var a21 = ae[3], a22 = ae[4], a23 = ae[5];
1863
+ var a31 = ae[6], a32 = ae[7], a33 = ae[8];
1864
+ oe[0] = c * a11 + s * a21;
1865
+ oe[1] = c * a12 + s * a22;
1866
+ oe[2] = c * a13 + s * a23;
1867
+ oe[3] = c * a21 - s * a11;
1868
+ oe[4] = c * a22 - s * a12;
1869
+ oe[5] = c * a23 - s * a13;
1870
+ oe[6] = a31;
1871
+ oe[7] = a32;
1872
+ oe[8] = a33;
1873
+ };
1874
+ /**
1875
+ * Scale a matrix by a given vector.
1876
+ * @param m - The matrix
1877
+ * @param s - The given vector
1878
+ * @param out - The scaled matrix
1879
+ */ Matrix3x3.scale = function scale(m, s, out) {
1880
+ var x = s._x, y = s._y;
1881
+ var ae = m.elements;
1882
+ var oe = out.elements;
1883
+ oe[0] = x * ae[0];
1884
+ oe[1] = x * ae[1];
1885
+ oe[2] = x * ae[2];
1886
+ oe[3] = y * ae[3];
1887
+ oe[4] = y * ae[4];
1888
+ oe[5] = y * ae[5];
1889
+ oe[6] = ae[6];
1890
+ oe[7] = ae[7];
1891
+ oe[8] = ae[8];
1892
+ };
1893
+ /**
1894
+ * Translate a matrix by a given vector.
1895
+ * @param m - The matrix
1896
+ * @param translation - The given vector
1897
+ * @param out - The translated matrix
1898
+ */ Matrix3x3.translate = function translate(m, translation, out) {
1899
+ var x = translation._x, y = translation._y;
1900
+ var ae = m.elements;
1901
+ var oe = out.elements;
1902
+ var a11 = ae[0], a12 = ae[1], a13 = ae[2];
1903
+ var a21 = ae[3], a22 = ae[4], a23 = ae[5];
1904
+ var a31 = ae[6], a32 = ae[7], a33 = ae[8];
1905
+ oe[0] = a11;
1906
+ oe[1] = a12;
1907
+ oe[2] = a13;
1908
+ oe[3] = a21;
1909
+ oe[4] = a22;
1910
+ oe[5] = a23;
1911
+ oe[6] = x * a11 + y * a21 + a31;
1912
+ oe[7] = x * a12 + y * a22 + a32;
1913
+ oe[8] = x * a13 + y * a23 + a33;
1914
+ };
1915
+ /**
1916
+ * Calculate the transpose of the specified matrix.
1917
+ * @param a - The specified matrix
1918
+ * @param out - The transpose of the specified matrix
1919
+ */ Matrix3x3.transpose = function transpose(a, out) {
1920
+ var ae = a.elements;
1921
+ var oe = out.elements;
1922
+ if (out === a) {
1923
+ var a12 = ae[1];
1924
+ var a13 = ae[2];
1925
+ var a23 = ae[5];
1926
+ oe[1] = ae[3];
1927
+ oe[2] = ae[6];
1928
+ oe[3] = a12;
1929
+ oe[5] = ae[7];
1930
+ oe[6] = a13;
1931
+ oe[7] = a23;
1932
+ } else {
1933
+ oe[0] = ae[0];
1934
+ oe[1] = ae[3];
1935
+ oe[2] = ae[6];
1936
+ oe[3] = ae[1];
1937
+ oe[4] = ae[4];
1938
+ oe[5] = ae[7];
1939
+ oe[6] = ae[2];
1940
+ oe[7] = ae[5];
1941
+ oe[8] = ae[8];
1942
+ }
1943
+ };
1944
+ return Matrix3x3;
1945
+ }();
1946
+
1947
+ /**
1948
+ * Represents a four dimensional mathematical quaternion.
1949
+ */ var Quaternion = /*#__PURE__*/ function() {
1950
+ function Quaternion(x, y, z, w) {
1951
+ if (x === void 0) x = 0;
1952
+ if (y === void 0) y = 0;
1953
+ if (z === void 0) z = 0;
1954
+ if (w === void 0) w = 1;
1955
+ /** @internal */ this._onValueChanged = null;
1956
+ this._x = x;
1957
+ this._y = y;
1958
+ this._z = z;
1959
+ this._w = w;
1960
+ }
1961
+ var _proto = Quaternion.prototype;
1962
+ /**
1963
+ * Set the value of this quaternion, and return this quaternion.
1964
+ * @param x - The x component of the quaternion
1965
+ * @param y - The y component of the quaternion
1966
+ * @param z - The z component of the quaternion
1967
+ * @param w - The w component of the quaternion
1968
+ * @returns This quaternion
1969
+ */ _proto.set = function set(x, y, z, w) {
1970
+ this._x = x;
1971
+ this._y = y;
1972
+ this._z = z;
1973
+ this._w = w;
1974
+ this._onValueChanged && this._onValueChanged();
1975
+ return this;
1976
+ };
1977
+ /**
1978
+ * Transforms this quaternion into its conjugated version.
1979
+ * @returns This quaternion
1980
+ */ _proto.conjugate = function conjugate() {
1981
+ this._x *= -1;
1982
+ this._y *= -1;
1983
+ this._z *= -1;
1984
+ this._onValueChanged && this._onValueChanged();
1985
+ return this;
1986
+ };
1987
+ /**
1988
+ * Get the rotation axis and rotation angle of the quaternion (unit: radians).
1989
+ * @param out - The axis as an output parameter
1990
+ * @returns The rotation angle (unit: radians)
1991
+ */ _proto.getAxisAngle = function getAxisAngle(out) {
1992
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z;
1993
+ var length = _x * _x + _y * _y + _z * _z;
1994
+ if (length < MathUtil.zeroTolerance) {
1995
+ out._x = 1;
1996
+ out._y = 0;
1997
+ out._z = 0;
1998
+ return 0;
1999
+ } else {
2000
+ var inv = 1.0 / length;
2001
+ out._x = this._x * inv;
2002
+ out._y = this._y * inv;
2003
+ out._z = this._z * inv;
2004
+ return Math.acos(this._w) * 2.0;
2005
+ }
2006
+ };
2007
+ /**
2008
+ * Identity this quaternion.
2009
+ * @returns This quaternion after identity
2010
+ */ _proto.identity = function identity() {
2011
+ this._x = 0;
2012
+ this._y = 0;
2013
+ this._z = 0;
2014
+ this._w = 1;
2015
+ this._onValueChanged && this._onValueChanged();
2016
+ return this;
2017
+ };
2018
+ /**
2019
+ * Calculate the length of this quaternion.
2020
+ * @returns The length of this quaternion
2021
+ */ _proto.length = function length() {
2022
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
2023
+ return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
2024
+ };
2025
+ /**
2026
+ * Calculates the squared length of this quaternion.
2027
+ * @returns The squared length of this quaternion
2028
+ */ _proto.lengthSquared = function lengthSquared() {
2029
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
2030
+ return _x * _x + _y * _y + _z * _z + _w * _w;
2031
+ };
2032
+ /**
2033
+ * Converts this quaternion into a unit quaternion.
2034
+ * @returns This quaternion
2035
+ */ _proto.normalize = function normalize() {
2036
+ Quaternion.normalize(this, this);
2037
+ return this;
2038
+ };
2039
+ /**
2040
+ * Get the euler of this quaternion.
2041
+ * @param out - The euler (in radians) as an output parameter
2042
+ * @returns Euler x->pitch y->yaw z->roll
2043
+ */ _proto.toEuler = function toEuler(out) {
2044
+ this._toYawPitchRoll(out);
2045
+ var t = out._x;
2046
+ out._x = out._y;
2047
+ out._y = t;
2048
+ out._onValueChanged && out._onValueChanged();
2049
+ return out;
2050
+ };
2051
+ /**
2052
+ * Get the euler of this quaternion.
2053
+ * @param out - The euler (in radians) as an output parameter
2054
+ * @returns Euler x->yaw y->pitch z->roll
2055
+ */ _proto.toYawPitchRoll = function toYawPitchRoll(out) {
2056
+ this._toYawPitchRoll(out);
2057
+ out._onValueChanged && out._onValueChanged();
2058
+ return out;
2059
+ };
2060
+ /**
2061
+ * Calculate this quaternion rotate around X axis.
2062
+ * @param rad - The rotation angle in radians
2063
+ * @returns This quaternion
2064
+ */ _proto.rotateX = function rotateX(rad) {
2065
+ Quaternion.rotateX(this, rad, this);
2066
+ return this;
2067
+ };
2068
+ /**
2069
+ * Calculate this quaternion rotate around Y axis.
2070
+ * @param rad - The rotation angle in radians
2071
+ * @returns This quaternion
2072
+ */ _proto.rotateY = function rotateY(rad) {
2073
+ Quaternion.rotateY(this, rad, this);
2074
+ return this;
2075
+ };
2076
+ /**
2077
+ * Calculate this quaternion rotate around Z axis.
2078
+ * @param rad - The rotation angle in radians
2079
+ * @returns This quaternion
2080
+ */ _proto.rotateZ = function rotateZ(rad) {
2081
+ Quaternion.rotateZ(this, rad, this);
2082
+ return this;
2083
+ };
2084
+ /**
2085
+ * Calculate this quaternion rotates around an arbitrary axis.
2086
+ * @param axis - The axis
2087
+ * @param rad - The rotation angle in radians
2088
+ * @returns This quaternion
2089
+ */ _proto.rotationAxisAngle = function rotationAxisAngle(axis, rad) {
2090
+ Quaternion.rotationAxisAngle(axis, rad, this);
2091
+ return this;
2092
+ };
2093
+ /**
2094
+ * Determines the product of this quaternion and the specified quaternion.
2095
+ * @param quat - The specified quaternion
2096
+ * @returns The product of the two quaternions
2097
+ */ _proto.multiply = function multiply(quat) {
2098
+ Quaternion.multiply(this, quat, this);
2099
+ return this;
2100
+ };
2101
+ /**
2102
+ * Invert this quaternion.
2103
+ * @returns This quaternion after invert
2104
+ */ _proto.invert = function invert() {
2105
+ Quaternion.invert(this, this);
2106
+ return this;
2107
+ };
2108
+ /**
2109
+ * Determines the dot product of this quaternion and the specified quaternion.
2110
+ * @param quat - The specified quaternion
2111
+ * @returns The dot product of two quaternions
2112
+ */ _proto.dot = function dot(quat) {
2113
+ return Quaternion.dot(this, quat);
2114
+ };
2115
+ /**
2116
+ * Performs a linear blend between this quaternion and the specified quaternion.
2117
+ * @param quat - The specified quaternion
2118
+ * @param t - The blend amount where 0 returns this and 1 quat
2119
+ * @returns - The result of linear blending between two quaternions
2120
+ */ _proto.lerp = function lerp(quat, t) {
2121
+ Quaternion.lerp(this, quat, t, this);
2122
+ return this;
2123
+ };
2124
+ /**
2125
+ * Calculate this quaternion rotation around an arbitrary axis.
2126
+ * @param axis - The axis
2127
+ * @param rad - The rotation angle in radians
2128
+ * @returns This quaternion
2129
+ */ _proto.rotateAxisAngle = function rotateAxisAngle(axis, rad) {
2130
+ Quaternion._tempQuat1.rotationAxisAngle(axis, rad);
2131
+ this.multiply(Quaternion._tempQuat1);
2132
+ return this;
2133
+ };
2134
+ /**
2135
+ * Creates a clone of this quaternion.
2136
+ * @returns A clone of this quaternion
2137
+ */ _proto.clone = function clone() {
2138
+ return new Quaternion(this._x, this._y, this._z, this._w);
2139
+ };
2140
+ /**
2141
+ * Copy this quaternion from the specified quaternion.
2142
+ * @param source - The specified quaternion
2143
+ * @returns This quaternion
2144
+ */ _proto.copyFrom = function copyFrom(source) {
2145
+ this._x = source.x;
2146
+ this._y = source.y;
2147
+ this._z = source.z;
2148
+ this._w = source.w;
2149
+ this._onValueChanged && this._onValueChanged();
2150
+ return this;
2151
+ };
2152
+ /**
2153
+ * Copy the value of this quaternion from an array.
2154
+ * @param array - The array
2155
+ * @param offset - The start offset of the array
2156
+ * @returns This quaternion
2157
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
2158
+ if (offset === void 0) offset = 0;
2159
+ this._x = array[offset];
2160
+ this._y = array[offset + 1];
2161
+ this._z = array[offset + 2];
2162
+ this._w = array[offset + 3];
2163
+ this._onValueChanged && this._onValueChanged();
2164
+ return this;
2165
+ };
2166
+ /**
2167
+ * Copy the value of this quaternion to an array.
2168
+ * @param out - The array
2169
+ * @param outOffset - The start offset of the array
2170
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
2171
+ if (outOffset === void 0) outOffset = 0;
2172
+ out[outOffset] = this._x;
2173
+ out[outOffset + 1] = this._y;
2174
+ out[outOffset + 2] = this._z;
2175
+ out[outOffset + 3] = this._w;
2176
+ };
2177
+ /**
2178
+ * Serialize this quaternion to a JSON representation.
2179
+ * @returns A JSON Object representation of this quaternion
2180
+ */ _proto.toJSON = function toJSON() {
2181
+ return {
2182
+ x: this._x,
2183
+ y: this._y,
2184
+ z: this._z,
2185
+ w: this._w
2186
+ };
2187
+ };
2188
+ _proto._toYawPitchRoll = function _toYawPitchRoll(out) {
2189
+ // https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
2190
+ var _this = this, x = _this._x, y = _this._y, z = _this._z, w = _this._w;
2191
+ var xx = x * x;
2192
+ var sinP = 2.0 * (x * w - y * z);
2193
+ // use 90 degrees if out of range
2194
+ out._y = Math.abs(sinP) >= 1 ? Math.sign(sinP) * (Math.PI / 2) : Math.asin(sinP);
2195
+ out._x = Math.atan2(2.0 * (z * x + y * w), 1.0 - 2.0 * (y * y + xx));
2196
+ out._z = Math.atan2(2.0 * (x * y + z * w), 1.0 - 2.0 * (z * z + xx));
2197
+ };
2198
+ /**
2199
+ * Determines the sum of two quaternions.
2200
+ * @param left - The first quaternion to add
2201
+ * @param right - The second quaternion to add
2202
+ * @param out - The sum of two quaternions
2203
+ */ Quaternion.add = function add(left, right, out) {
2204
+ out._x = left._x + right._x;
2205
+ out._y = left._y + right._y;
2206
+ out._z = left._z + right._z;
2207
+ out._w = left._w + right._w;
2208
+ out._onValueChanged && out._onValueChanged();
2209
+ };
2210
+ /**
2211
+ * Determines the product of two quaternions.
2212
+ * @param left - The first quaternion to multiply
2213
+ * @param right - The second quaternion to multiply
2214
+ * @param out - The product of two quaternions
2215
+ */ Quaternion.multiply = function multiply(left, right, out) {
2216
+ var ax = left._x, ay = left._y, az = left._z, aw = left._w;
2217
+ var bx = right._x, by = right._y, bz = right._z, bw = right._w;
2218
+ out._x = ax * bw + aw * bx + ay * bz - az * by;
2219
+ out._y = ay * bw + aw * by + az * bx - ax * bz;
2220
+ out._z = az * bw + aw * bz + ax * by - ay * bx;
2221
+ out._w = aw * bw - ax * bx - ay * by - az * bz;
2222
+ out._onValueChanged && out._onValueChanged();
2223
+ };
2224
+ /**
2225
+ * Calculate quaternion that contains conjugated version of the specified quaternion.
2226
+ * @param a - The specified quaternion
2227
+ * @param out - The conjugate version of the specified quaternion
2228
+ */ Quaternion.conjugate = function conjugate(a, out) {
2229
+ out._x = -a._x;
2230
+ out._y = -a._y;
2231
+ out._z = -a._z;
2232
+ out._w = a._w;
2233
+ out._onValueChanged && out._onValueChanged();
2234
+ };
2235
+ /**
2236
+ * Determines the dot product of two quaternions.
2237
+ * @param left - The first quaternion to dot
2238
+ * @param right - The second quaternion to dot
2239
+ * @returns The dot product of two quaternions
2240
+ */ Quaternion.dot = function dot(left, right) {
2241
+ return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
2242
+ };
2243
+ /**
2244
+ * Determines whether the specified quaternions are equals.
2245
+ * @param left - The first quaternion to compare
2246
+ * @param right - The second quaternion to compare
2247
+ * @returns True if the specified quaternions are equals, false otherwise
2248
+ */ Quaternion.equals = function equals(left, right) {
2249
+ return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y) && MathUtil.equals(left._z, right._z) && MathUtil.equals(left._w, right._w);
2250
+ };
2251
+ /**
2252
+ * Calculate a quaternion rotates around an arbitrary axis.
2253
+ * @param axis - The axis
2254
+ * @param rad - The rotation angle in radians
2255
+ * @param out - The quaternion after rotate
2256
+ */ Quaternion.rotationAxisAngle = function rotationAxisAngle(axis, rad, out) {
2257
+ var normalAxis = Quaternion._tempVector3;
2258
+ Vector3.normalize(axis, normalAxis);
2259
+ rad *= 0.5;
2260
+ var s = Math.sin(rad);
2261
+ out._x = normalAxis._x * s;
2262
+ out._y = normalAxis._y * s;
2263
+ out._z = normalAxis._z * s;
2264
+ out._w = Math.cos(rad);
2265
+ out._onValueChanged && out._onValueChanged();
2266
+ };
2267
+ /**
2268
+ * Calculate a quaternion rotates around x, y, z axis (pitch/yaw/roll).
2269
+ * @param x - The radian of rotation around X (pitch)
2270
+ * @param y - The radian of rotation around Y (yaw)
2271
+ * @param z - The radian of rotation around Z (roll)
2272
+ * @param out - The calculated quaternion
2273
+ */ Quaternion.rotationEuler = function rotationEuler(x, y, z, out) {
2274
+ Quaternion.rotationYawPitchRoll(y, x, z, out);
2275
+ };
2276
+ /**
2277
+ * Calculate a quaternion from the specified yaw, pitch and roll angles.
2278
+ * @param yaw - Yaw around the y axis in radians
2279
+ * @param pitch - Pitch around the x axis in radians
2280
+ * @param roll - Roll around the z axis in radians
2281
+ * @param out - The calculated quaternion
2282
+ */ Quaternion.rotationYawPitchRoll = function rotationYawPitchRoll(yaw, pitch, roll, out) {
2283
+ var halfRoll = roll * 0.5;
2284
+ var halfPitch = pitch * 0.5;
2285
+ var halfYaw = yaw * 0.5;
2286
+ var sinRoll = Math.sin(halfRoll);
2287
+ var cosRoll = Math.cos(halfRoll);
2288
+ var sinPitch = Math.sin(halfPitch);
2289
+ var cosPitch = Math.cos(halfPitch);
2290
+ var sinYaw = Math.sin(halfYaw);
2291
+ var cosYaw = Math.cos(halfYaw);
2292
+ var cosYawPitch = cosYaw * cosPitch;
2293
+ var sinYawPitch = sinYaw * sinPitch;
2294
+ out._x = cosYaw * sinPitch * cosRoll + sinYaw * cosPitch * sinRoll;
2295
+ out._y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
2296
+ out._z = cosYawPitch * sinRoll - sinYawPitch * cosRoll;
2297
+ out._w = cosYawPitch * cosRoll + sinYawPitch * sinRoll;
2298
+ out._onValueChanged && out._onValueChanged();
2299
+ };
2300
+ /**
2301
+ * Calculate a quaternion from the specified 3x3 matrix.
2302
+ * @param m - The specified 3x3 matrix
2303
+ * @param out - The calculated quaternion
2304
+ */ Quaternion.rotationMatrix3x3 = function rotationMatrix3x3(m, out) {
2305
+ var me = m.elements;
2306
+ var m11 = me[0], m12 = me[1], m13 = me[2];
2307
+ var m21 = me[3], m22 = me[4], m23 = me[5];
2308
+ var m31 = me[6], m32 = me[7], m33 = me[8];
2309
+ var scale = m11 + m22 + m33;
2310
+ var sqrt, half;
2311
+ if (scale > 0) {
2312
+ sqrt = Math.sqrt(scale + 1.0);
2313
+ out._w = sqrt * 0.5;
2314
+ sqrt = 0.5 / sqrt;
2315
+ out._x = (m23 - m32) * sqrt;
2316
+ out._y = (m31 - m13) * sqrt;
2317
+ out._z = (m12 - m21) * sqrt;
2318
+ } else if (m11 >= m22 && m11 >= m33) {
2319
+ sqrt = Math.sqrt(1.0 + m11 - m22 - m33);
2320
+ half = 0.5 / sqrt;
2321
+ out._x = 0.5 * sqrt;
2322
+ out._y = (m12 + m21) * half;
2323
+ out._z = (m13 + m31) * half;
2324
+ out._w = (m23 - m32) * half;
2325
+ } else if (m22 > m33) {
2326
+ sqrt = Math.sqrt(1.0 + m22 - m11 - m33);
2327
+ half = 0.5 / sqrt;
2328
+ out._x = (m21 + m12) * half;
2329
+ out._y = 0.5 * sqrt;
2330
+ out._z = (m32 + m23) * half;
2331
+ out._w = (m31 - m13) * half;
2332
+ } else {
2333
+ sqrt = Math.sqrt(1.0 + m33 - m11 - m22);
2334
+ half = 0.5 / sqrt;
2335
+ out._x = (m13 + m31) * half;
2336
+ out._y = (m23 + m32) * half;
2337
+ out._z = 0.5 * sqrt;
2338
+ out._w = (m12 - m21) * half;
2339
+ }
2340
+ out._onValueChanged && out._onValueChanged();
2341
+ };
2342
+ /**
2343
+ * Calculate the inverse of the specified quaternion.
2344
+ * @param a - The quaternion whose inverse is to be calculated
2345
+ * @param out - The inverse of the specified quaternion
2346
+ */ Quaternion.invert = function invert(a, out) {
2347
+ var x = a._x, y = a._y, z = a._z, w = a._w;
2348
+ var dot = x * x + y * y + z * z + w * w;
2349
+ if (dot > MathUtil.zeroTolerance) {
2350
+ var invDot = 1.0 / dot;
2351
+ out._x = -x * invDot;
2352
+ out._y = -y * invDot;
2353
+ out._z = -z * invDot;
2354
+ out._w = w * invDot;
2355
+ out._onValueChanged && out._onValueChanged();
2356
+ }
2357
+ };
2358
+ /**
2359
+ * Performs a linear blend between two quaternions.
2360
+ * @param start - The first quaternion
2361
+ * @param end - The second quaternion
2362
+ * @param t - The blend amount where 0 returns start and 1 end
2363
+ * @param out - The result of linear blending between two quaternions
2364
+ */ Quaternion.lerp = function lerp(start, end, t, out) {
2365
+ var inv = 1.0 - t;
2366
+ if (Quaternion.dot(start, end) >= 0) {
2367
+ out._x = start._x * inv + end._x * t;
2368
+ out._y = start._y * inv + end._y * t;
2369
+ out._z = start._z * inv + end._z * t;
2370
+ out._w = start._w * inv + end._w * t;
2371
+ } else {
2372
+ out._x = start._x * inv - end._x * t;
2373
+ out._y = start._y * inv - end._y * t;
2374
+ out._z = start._z * inv - end._z * t;
2375
+ out._w = start._w * inv - end._w * t;
2376
+ }
2377
+ out.normalize();
2378
+ };
2379
+ /**
2380
+ * Performs a spherical linear blend between two quaternions.
2381
+ * @param start - The first quaternion
2382
+ * @param end - The second quaternion
2383
+ * @param amount - The blend amount where 0 returns start and 1 end
2384
+ * @param out - The result of spherical linear blending between two quaternions
2385
+ */ Quaternion.slerp = function slerp(start, end, amount, out) {
2386
+ var opposite;
2387
+ var inverse;
2388
+ var dot = Quaternion.dot(start, end);
2389
+ if (Math.abs(dot) > 1.0 - MathUtil.zeroTolerance) {
2390
+ inverse = 1.0 - amount;
2391
+ opposite = amount * Math.sign(dot);
2392
+ } else {
2393
+ var acos = Math.acos(Math.abs(dot));
2394
+ var invSin = 1.0 / Math.sin(acos);
2395
+ inverse = Math.sin((1.0 - amount) * acos) * invSin;
2396
+ opposite = Math.sin(amount * acos) * invSin * Math.sign(dot);
2397
+ }
2398
+ out.x = inverse * start.x + opposite * end.x;
2399
+ out.y = inverse * start.y + opposite * end.y;
2400
+ out.z = inverse * start.z + opposite * end.z;
2401
+ out.w = inverse * start.w + opposite * end.w;
2402
+ out._onValueChanged && out._onValueChanged();
2403
+ };
2404
+ /**
2405
+ * Scales the specified quaternion magnitude to unit length.
2406
+ * @param a - The specified quaternion
2407
+ * @param out - The normalized quaternion
2408
+ */ Quaternion.normalize = function normalize(a, out) {
2409
+ var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
2410
+ var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
2411
+ if (len > MathUtil.zeroTolerance) {
2412
+ len = 1 / len;
2413
+ out._x = _x * len;
2414
+ out._y = _y * len;
2415
+ out._z = _z * len;
2416
+ out._w = _w * len;
2417
+ out._onValueChanged && out._onValueChanged();
2418
+ }
2419
+ };
2420
+ /**
2421
+ * Calculate a quaternion rotate around X axis.
2422
+ * @param rad - The rotation angle in radians
2423
+ * @param out - The calculated quaternion
2424
+ */ Quaternion.rotationX = function rotationX(rad, out) {
2425
+ rad *= 0.5;
2426
+ var s = Math.sin(rad);
2427
+ var c = Math.cos(rad);
2428
+ out._x = s;
2429
+ out._y = 0;
2430
+ out._z = 0;
2431
+ out._w = c;
2432
+ out._onValueChanged && out._onValueChanged();
2433
+ };
2434
+ /**
2435
+ * Calculate a quaternion rotate around Y axis.
2436
+ * @param rad - The rotation angle in radians
2437
+ * @param out - The calculated quaternion
2438
+ */ Quaternion.rotationY = function rotationY(rad, out) {
2439
+ rad *= 0.5;
2440
+ var s = Math.sin(rad);
2441
+ var c = Math.cos(rad);
2442
+ out._x = 0;
2443
+ out._y = s;
2444
+ out._z = 0;
2445
+ out._w = c;
2446
+ out._onValueChanged && out._onValueChanged();
2447
+ };
2448
+ /**
2449
+ * Calculate a quaternion rotate around Z axis.
2450
+ * @param rad - The rotation angle in radians
2451
+ * @param out - The calculated quaternion
2452
+ */ Quaternion.rotationZ = function rotationZ(rad, out) {
2453
+ rad *= 0.5;
2454
+ var s = Math.sin(rad);
2455
+ var c = Math.cos(rad);
2456
+ out._x = 0;
2457
+ out._y = 0;
2458
+ out._z = s;
2459
+ out._w = c;
2460
+ out._onValueChanged && out._onValueChanged();
2461
+ };
2462
+ /**
2463
+ * Calculate a quaternion that the specified quaternion rotate around X axis.
2464
+ * @param quaternion - The specified quaternion
2465
+ * @param rad - The rotation angle in radians
2466
+ * @param out - The calculated quaternion
2467
+ */ Quaternion.rotateX = function rotateX(quaternion, rad, out) {
2468
+ var _x = quaternion._x, _y = quaternion._y, _z = quaternion._z, _w = quaternion._w;
2469
+ rad *= 0.5;
2470
+ var bx = Math.sin(rad);
2471
+ var bw = Math.cos(rad);
2472
+ out._x = _x * bw + _w * bx;
2473
+ out._y = _y * bw + _z * bx;
2474
+ out._z = _z * bw - _y * bx;
2475
+ out._w = _w * bw - _x * bx;
2476
+ out._onValueChanged && out._onValueChanged();
2477
+ };
2478
+ /**
2479
+ * Calculate a quaternion that the specified quaternion rotate around Y axis.
2480
+ * @param quaternion - The specified quaternion
2481
+ * @param rad - The rotation angle in radians
2482
+ * @param out - The calculated quaternion
2483
+ */ Quaternion.rotateY = function rotateY(quaternion, rad, out) {
2484
+ var _x = quaternion._x, _y = quaternion._y, _z = quaternion._z, _w = quaternion._w;
2485
+ rad *= 0.5;
2486
+ var by = Math.sin(rad);
2487
+ var bw = Math.cos(rad);
2488
+ out._x = _x * bw - _z * by;
2489
+ out._y = _y * bw + _w * by;
2490
+ out._z = _z * bw + _x * by;
2491
+ out._w = _w * bw - _y * by;
2492
+ out._onValueChanged && out._onValueChanged();
2493
+ };
2494
+ /**
2495
+ * Calculate a quaternion that the specified quaternion rotate around Z axis.
2496
+ * @param quaternion - The specified quaternion
2497
+ * @param rad - The rotation angle in radians
2498
+ * @param out - The calculated quaternion
2499
+ */ Quaternion.rotateZ = function rotateZ(quaternion, rad, out) {
2500
+ var _x = quaternion._x, _y = quaternion._y, _z = quaternion._z, _w = quaternion._w;
2501
+ rad *= 0.5;
2502
+ var bz = Math.sin(rad);
2503
+ var bw = Math.cos(rad);
2504
+ out._x = _x * bw + _y * bz;
2505
+ out._y = _y * bw - _x * bz;
2506
+ out._z = _z * bw + _w * bz;
2507
+ out._w = _w * bw - _z * bz;
2508
+ out._onValueChanged && out._onValueChanged();
2509
+ };
2510
+ /**
2511
+ * Scale a quaternion by a given number.
2512
+ * @param a - The quaternion
2513
+ * @param s - The given number
2514
+ * @param out - The scaled quaternion
2515
+ */ Quaternion.scale = function scale(a, s, out) {
2516
+ out._x = a._x * s;
2517
+ out._y = a._y * s;
2518
+ out._z = a._z * s;
2519
+ out._w = a._w * s;
2520
+ out._onValueChanged && out._onValueChanged();
2521
+ };
2522
+ _create_class(Quaternion, [
2523
+ {
2524
+ key: "x",
2525
+ get: /**
2526
+ * The x component of the quaternion.
2527
+ */ function get() {
2528
+ return this._x;
2529
+ },
2530
+ set: function set(value) {
2531
+ this._x = value;
2532
+ this._onValueChanged && this._onValueChanged();
2533
+ }
2534
+ },
2535
+ {
2536
+ key: "y",
2537
+ get: /**
2538
+ * The y component of the quaternion.
2539
+ */ function get() {
2540
+ return this._y;
2541
+ },
2542
+ set: function set(value) {
2543
+ this._y = value;
2544
+ this._onValueChanged && this._onValueChanged();
2545
+ }
2546
+ },
2547
+ {
2548
+ key: "z",
2549
+ get: /**
2550
+ * The z component of the quaternion.
2551
+ */ function get() {
2552
+ return this._z;
2553
+ },
2554
+ set: function set(value) {
2555
+ this._z = value;
2556
+ this._onValueChanged && this._onValueChanged();
2557
+ }
2558
+ },
2559
+ {
2560
+ key: "normalized",
2561
+ get: /**
2562
+ * Indicting whether this instance is normalized.
2563
+ */ function get() {
2564
+ return Math.abs(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w - 1) < MathUtil.zeroTolerance;
2565
+ }
2566
+ },
2567
+ {
2568
+ key: "w",
2569
+ get: /**
2570
+ * The w component of the quaternion.
2571
+ */ function get() {
2572
+ return this._w;
2573
+ },
2574
+ set: function set(value) {
2575
+ this._w = value;
2576
+ this._onValueChanged && this._onValueChanged();
2577
+ }
2578
+ }
2579
+ ]);
2580
+ return Quaternion;
2581
+ }();
2582
+ (function() {
2583
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
2584
+ })();
2585
+ (function() {
2586
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2587
+ })();
2588
+
2589
+ /**
2590
+ * Represents a 4x4 mathematical matrix.
2591
+ */ var Matrix = /*#__PURE__*/ function() {
2592
+ function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
2593
+ if (m11 === void 0) m11 = 1;
2594
+ if (m12 === void 0) m12 = 0;
2595
+ if (m13 === void 0) m13 = 0;
2596
+ if (m14 === void 0) m14 = 0;
2597
+ if (m21 === void 0) m21 = 0;
2598
+ if (m22 === void 0) m22 = 1;
2599
+ if (m23 === void 0) m23 = 0;
2600
+ if (m24 === void 0) m24 = 0;
2601
+ if (m31 === void 0) m31 = 0;
2602
+ if (m32 === void 0) m32 = 0;
2603
+ if (m33 === void 0) m33 = 1;
2604
+ if (m34 === void 0) m34 = 0;
2605
+ if (m41 === void 0) m41 = 0;
2606
+ if (m42 === void 0) m42 = 0;
2607
+ if (m43 === void 0) m43 = 0;
2608
+ if (m44 === void 0) m44 = 1;
2609
+ /**
2610
+ * An array containing the elements of the matrix (column matrix).
2611
+ * @remarks
2612
+ * elements[0] first column and first row value m11
2613
+ * elements[1] first column and second row value m12
2614
+ * elements[2] first column and third row value m13
2615
+ * elements[3] first column and fourth row value m14
2616
+ * elements[4] second column and first row value m21
2617
+ * and so on
2618
+ */ this.elements = new Float32Array(16);
2619
+ var e = this.elements;
2620
+ e[0] = m11;
2621
+ e[1] = m12;
2622
+ e[2] = m13;
2623
+ e[3] = m14;
2624
+ e[4] = m21;
2625
+ e[5] = m22;
2626
+ e[6] = m23;
2627
+ e[7] = m24;
2628
+ e[8] = m31;
2629
+ e[9] = m32;
2630
+ e[10] = m33;
2631
+ e[11] = m34;
2632
+ e[12] = m41;
2633
+ e[13] = m42;
2634
+ e[14] = m43;
2635
+ e[15] = m44;
2636
+ }
2637
+ var _proto = Matrix.prototype;
2638
+ /**
2639
+ * Set the value of this matrix, and return this matrix.
2640
+ * @param m11 - column 1, row 1
2641
+ * @param m12 - column 1, row 2
2642
+ * @param m13 - column 1, row 3
2643
+ * @param m14 - column 1, row 4
2644
+ * @param m21 - column 2, row 1
2645
+ * @param m22 - column 2, row 2
2646
+ * @param m23 - column 2, row 3
2647
+ * @param m24 - column 2, row 4
2648
+ * @param m31 - column 3, row 1
2649
+ * @param m32 - column 3, row 2
2650
+ * @param m33 - column 3, row 3
2651
+ * @param m34 - column 3, row 4
2652
+ * @param m41 - column 4, row 1
2653
+ * @param m42 - column 4, row 2
2654
+ * @param m43 - column 4, row 3
2655
+ * @param m44 - column 4, row 4
2656
+ * @returns This matrix
2657
+ */ _proto.set = function set(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
2658
+ var e = this.elements;
2659
+ e[0] = m11;
2660
+ e[1] = m12;
2661
+ e[2] = m13;
2662
+ e[3] = m14;
2663
+ e[4] = m21;
2664
+ e[5] = m22;
2665
+ e[6] = m23;
2666
+ e[7] = m24;
2667
+ e[8] = m31;
2668
+ e[9] = m32;
2669
+ e[10] = m33;
2670
+ e[11] = m34;
2671
+ e[12] = m41;
2672
+ e[13] = m42;
2673
+ e[14] = m43;
2674
+ e[15] = m44;
2675
+ return this;
2676
+ };
2677
+ /**
2678
+ * Determines the product of this matrix and the specified matrix.
2679
+ * @param right - The specified matrix
2680
+ * @returns This matrix that store the product of the two matrices
2681
+ */ _proto.multiply = function multiply(right) {
2682
+ Matrix.multiply(this, right, this);
2683
+ return this;
2684
+ };
2685
+ /**
2686
+ * Calculate a determinant of this matrix.
2687
+ * @returns The determinant of this matrix
2688
+ */ _proto.determinant = function determinant() {
2689
+ var e = this.elements;
2690
+ var a11 = e[0], a12 = e[1], a13 = e[2], a14 = e[3];
2691
+ var a21 = e[4], a22 = e[5], a23 = e[6], a24 = e[7];
2692
+ var a31 = e[8], a32 = e[9], a33 = e[10], a34 = e[11];
2693
+ var a41 = e[12], a42 = e[13], a43 = e[14], a44 = e[15];
2694
+ var b00 = a11 * a22 - a12 * a21;
2695
+ var b01 = a11 * a23 - a13 * a21;
2696
+ var b02 = a11 * a24 - a14 * a21;
2697
+ var b03 = a12 * a23 - a13 * a22;
2698
+ var b04 = a12 * a24 - a14 * a22;
2699
+ var b05 = a13 * a24 - a14 * a23;
2700
+ var b06 = a31 * a42 - a32 * a41;
2701
+ var b07 = a31 * a43 - a33 * a41;
2702
+ var b08 = a31 * a44 - a34 * a41;
2703
+ var b09 = a32 * a43 - a33 * a42;
2704
+ var b10 = a32 * a44 - a34 * a42;
2705
+ var b11 = a33 * a44 - a34 * a43;
2706
+ // Calculate the determinant
2707
+ return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
2708
+ };
2709
+ /**
2710
+ * Decompose this matrix to translation, rotation and scale elements.
2711
+ * @param translation - Translation vector as an output parameter
2712
+ * @param rotation - Rotation quaternion as an output parameter
2713
+ * @param scale - Scale vector as an output parameter
2714
+ * @returns True if this matrix can be decomposed, false otherwise
2715
+ */ _proto.decompose = function decompose(translation, rotation, scale) {
2716
+ var rm = Matrix._tempMat30;
2717
+ var e = this.elements;
2718
+ var rme = rm.elements;
2719
+ var m11 = e[0];
2720
+ var m12 = e[1];
2721
+ var m13 = e[2];
2722
+ var m14 = e[3];
2723
+ var m21 = e[4];
2724
+ var m22 = e[5];
2725
+ var m23 = e[6];
2726
+ var m24 = e[7];
2727
+ var m31 = e[8];
2728
+ var m32 = e[9];
2729
+ var m33 = e[10];
2730
+ var m34 = e[11];
2731
+ translation.set(e[12], e[13], e[14]);
2732
+ var xs = Math.sign(m11 * m12 * m13 * m14) < 0 ? -1 : 1;
2733
+ var ys = Math.sign(m21 * m22 * m23 * m24) < 0 ? -1 : 1;
2734
+ var zs = Math.sign(m31 * m32 * m33 * m34) < 0 ? -1 : 1;
2735
+ var sx = xs * Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
2736
+ var sy = ys * Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
2737
+ var sz = zs * Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
2738
+ scale.set(sx, sy, sz);
2739
+ if (Math.abs(sx) < MathUtil.zeroTolerance || Math.abs(sy) < MathUtil.zeroTolerance || Math.abs(sz) < MathUtil.zeroTolerance) {
2740
+ rotation.identity();
2741
+ return false;
2742
+ } else {
2743
+ var invSX = 1 / sx;
2744
+ var invSY = 1 / sy;
2745
+ var invSZ = 1 / sz;
2746
+ rme[0] = m11 * invSX;
2747
+ rme[1] = m12 * invSX;
2748
+ rme[2] = m13 * invSX;
2749
+ rme[3] = m21 * invSY;
2750
+ rme[4] = m22 * invSY;
2751
+ rme[5] = m23 * invSY;
2752
+ rme[6] = m31 * invSZ;
2753
+ rme[7] = m32 * invSZ;
2754
+ rme[8] = m33 * invSZ;
2755
+ Quaternion.rotationMatrix3x3(rm, rotation);
2756
+ return true;
2757
+ }
2758
+ };
2759
+ /**
2760
+ * Get rotation from this matrix.
2761
+ * @param out - Rotation quaternion as an output parameter
2762
+ * @returns The out
2763
+ */ _proto.getRotation = function getRotation(out) {
2764
+ var e = this.elements;
2765
+ var trace = e[0] + e[5] + e[10];
2766
+ if (trace > MathUtil.zeroTolerance) {
2767
+ var s = Math.sqrt(trace + 1.0) * 2;
2768
+ out._w = 0.25 * s;
2769
+ out._x = (e[6] - e[9]) / s;
2770
+ out._y = (e[8] - e[2]) / s;
2771
+ out._z = (e[1] - e[4]) / s;
2772
+ } else if (e[0] > e[5] && e[0] > e[10]) {
2773
+ var s1 = Math.sqrt(1.0 + e[0] - e[5] - e[10]) * 2;
2774
+ out._w = (e[6] - e[9]) / s1;
2775
+ out._x = 0.25 * s1;
2776
+ out._y = (e[1] + e[4]) / s1;
2777
+ out._z = (e[8] + e[2]) / s1;
2778
+ } else if (e[5] > e[10]) {
2779
+ var s2 = Math.sqrt(1.0 + e[5] - e[0] - e[10]) * 2;
2780
+ out._w = (e[8] - e[2]) / s2;
2781
+ out._x = (e[1] + e[4]) / s2;
2782
+ out._y = 0.25 * s2;
2783
+ out._z = (e[6] + e[9]) / s2;
2784
+ } else {
2785
+ var s3 = Math.sqrt(1.0 + e[10] - e[0] - e[5]) * 2;
2786
+ out._w = (e[1] - e[4]) / s3;
2787
+ out._x = (e[8] + e[2]) / s3;
2788
+ out._y = (e[6] + e[9]) / s3;
2789
+ out._z = 0.25 * s3;
2790
+ }
2791
+ out._onValueChanged && out._onValueChanged();
2792
+ return out;
2793
+ };
2794
+ /**
2795
+ * Get scale from this matrix.
2796
+ * @param out - Scale vector as an output parameter
2797
+ * @returns The out
2798
+ */ _proto.getScaling = function getScaling(out) {
2799
+ //getScale()
2800
+ var e = this.elements;
2801
+ var m11 = e[0], m12 = e[1], m13 = e[2];
2802
+ var m21 = e[4], m22 = e[5], m23 = e[6];
2803
+ var m31 = e[8], m32 = e[9], m33 = e[10];
2804
+ out.set(Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13), Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23), Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33));
2805
+ return out;
2806
+ };
2807
+ /**
2808
+ * Get translation from this matrix.
2809
+ * @param out - Translation vector as an output parameter
2810
+ * @returns The out
2811
+ */ _proto.getTranslation = function getTranslation(out) {
2812
+ var e = this.elements;
2813
+ out.set(e[12], e[13], e[14]);
2814
+ return out;
2815
+ };
2816
+ /**
2817
+ * Identity this matrix.
2818
+ * @returns This matrix after identity
2819
+ */ _proto.identity = function identity() {
2820
+ var e = this.elements;
2821
+ e[0] = 1;
2822
+ e[1] = 0;
2823
+ e[2] = 0;
2824
+ e[3] = 0;
2825
+ e[4] = 0;
2826
+ e[5] = 1;
2827
+ e[6] = 0;
2828
+ e[7] = 0;
2829
+ e[8] = 0;
2830
+ e[9] = 0;
2831
+ e[10] = 1;
2832
+ e[11] = 0;
2833
+ e[12] = 0;
2834
+ e[13] = 0;
2835
+ e[14] = 0;
2836
+ e[15] = 1;
2837
+ return this;
2838
+ };
2839
+ /**
2840
+ * Invert the matrix.
2841
+ * @returns The matrix after invert
2842
+ */ _proto.invert = function invert() {
2843
+ Matrix.invert(this, this);
2844
+ return this;
2845
+ };
2846
+ /**
2847
+ * This matrix rotates around an arbitrary axis.
2848
+ * @param axis - The axis
2849
+ * @param r - The rotation angle in radians
2850
+ * @returns This matrix after rotate
2851
+ */ _proto.rotateAxisAngle = function rotateAxisAngle(axis, r) {
2852
+ Matrix.rotateAxisAngle(this, axis, r, this);
2853
+ return this;
2854
+ };
2855
+ /**
2856
+ * Scale this matrix by a given vector.
2857
+ * @param s - The given vector
2858
+ * @returns This matrix after scale
2859
+ */ _proto.scale = function scale(s) {
2860
+ Matrix.scale(this, s, this);
2861
+ return this;
2862
+ };
2863
+ /**
2864
+ * Translate this matrix by a given vector.
2865
+ * @param v - The given vector
2866
+ * @returns This matrix after translate
2867
+ */ _proto.translate = function translate(v) {
2868
+ Matrix.translate(this, v, this);
2869
+ return this;
2870
+ };
2871
+ /**
2872
+ * Calculate the transpose of this matrix.
2873
+ * @returns This matrix after transpose
2874
+ */ _proto.transpose = function transpose() {
2875
+ Matrix.transpose(this, this);
2876
+ return this;
2877
+ };
2878
+ /**
2879
+ * Creates a clone of this matrix.
2880
+ * @returns A clone of this matrix
2881
+ */ _proto.clone = function clone() {
2882
+ var e = this.elements;
2883
+ var ret = new Matrix(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9], e[10], e[11], e[12], e[13], e[14], e[15]);
2884
+ return ret;
2885
+ };
2886
+ /**
2887
+ * Copy this matrix from the specified matrix.
2888
+ * @param source - The specified matrix
2889
+ * @returns This matrix
2890
+ */ _proto.copyFrom = function copyFrom(source) {
2891
+ var e = this.elements;
2892
+ var se = source.elements;
2893
+ e[0] = se[0];
2894
+ e[1] = se[1];
2895
+ e[2] = se[2];
2896
+ e[3] = se[3];
2897
+ e[4] = se[4];
2898
+ e[5] = se[5];
2899
+ e[6] = se[6];
2900
+ e[7] = se[7];
2901
+ e[8] = se[8];
2902
+ e[9] = se[9];
2903
+ e[10] = se[10];
2904
+ e[11] = se[11];
2905
+ e[12] = se[12];
2906
+ e[13] = se[13];
2907
+ e[14] = se[14];
2908
+ e[15] = se[15];
2909
+ return this;
2910
+ };
2911
+ /**
2912
+ * Copy the value of this matrix from an array.
2913
+ * @param array - The array
2914
+ * @param offset - The start offset of the array
2915
+ * @returns This matrix
2916
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
2917
+ if (offset === void 0) offset = 0;
2918
+ var srce = this.elements;
2919
+ for(var i = 0; i < 16; i++){
2920
+ srce[i] = array[i + offset];
2921
+ }
2922
+ return this;
2923
+ };
2924
+ /**
2925
+ * Copy the value of this matrix to an array.
2926
+ * @param out - The array
2927
+ * @param outOffset - The start offset of the array
2928
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
2929
+ if (outOffset === void 0) outOffset = 0;
2930
+ var e = this.elements;
2931
+ out[outOffset] = e[0];
2932
+ out[outOffset + 1] = e[1];
2933
+ out[outOffset + 2] = e[2];
2934
+ out[outOffset + 3] = e[3];
2935
+ out[outOffset + 4] = e[4];
2936
+ out[outOffset + 5] = e[5];
2937
+ out[outOffset + 6] = e[6];
2938
+ out[outOffset + 7] = e[7];
2939
+ out[outOffset + 8] = e[8];
2940
+ out[outOffset + 9] = e[9];
2941
+ out[outOffset + 10] = e[10];
2942
+ out[outOffset + 11] = e[11];
2943
+ out[outOffset + 12] = e[12];
2944
+ out[outOffset + 13] = e[13];
2945
+ out[outOffset + 14] = e[14];
2946
+ out[outOffset + 15] = e[15];
2947
+ };
2948
+ /**
2949
+ * Determines the product of two matrices.
2950
+ * @param left - The first matrix to multiply
2951
+ * @param right - The second matrix to multiply
2952
+ * @param out - The product of the two matrices
2953
+ */ Matrix.multiply = function multiply(left, right, out) {
2954
+ var le = left.elements;
2955
+ var re = right.elements;
2956
+ var oe = out.elements;
2957
+ // prettier-ignore
2958
+ var l11 = le[0], l12 = le[1], l13 = le[2], l14 = le[3], l21 = le[4], l22 = le[5], l23 = le[6], l24 = le[7], l31 = le[8], l32 = le[9], l33 = le[10], l34 = le[11], l41 = le[12], l42 = le[13], l43 = le[14], l44 = le[15];
2959
+ // prettier-ignore
2960
+ var r11 = re[0], r12 = re[1], r13 = re[2], r14 = re[3], r21 = re[4], r22 = re[5], r23 = re[6], r24 = re[7], r31 = re[8], r32 = re[9], r33 = re[10], r34 = re[11], r41 = re[12], r42 = re[13], r43 = re[14], r44 = re[15];
2961
+ oe[0] = l11 * r11 + l21 * r12 + l31 * r13 + l41 * r14;
2962
+ oe[1] = l12 * r11 + l22 * r12 + l32 * r13 + l42 * r14;
2963
+ oe[2] = l13 * r11 + l23 * r12 + l33 * r13 + l43 * r14;
2964
+ oe[3] = l14 * r11 + l24 * r12 + l34 * r13 + l44 * r14;
2965
+ oe[4] = l11 * r21 + l21 * r22 + l31 * r23 + l41 * r24;
2966
+ oe[5] = l12 * r21 + l22 * r22 + l32 * r23 + l42 * r24;
2967
+ oe[6] = l13 * r21 + l23 * r22 + l33 * r23 + l43 * r24;
2968
+ oe[7] = l14 * r21 + l24 * r22 + l34 * r23 + l44 * r24;
2969
+ oe[8] = l11 * r31 + l21 * r32 + l31 * r33 + l41 * r34;
2970
+ oe[9] = l12 * r31 + l22 * r32 + l32 * r33 + l42 * r34;
2971
+ oe[10] = l13 * r31 + l23 * r32 + l33 * r33 + l43 * r34;
2972
+ oe[11] = l14 * r31 + l24 * r32 + l34 * r33 + l44 * r34;
2973
+ oe[12] = l11 * r41 + l21 * r42 + l31 * r43 + l41 * r44;
2974
+ oe[13] = l12 * r41 + l22 * r42 + l32 * r43 + l42 * r44;
2975
+ oe[14] = l13 * r41 + l23 * r42 + l33 * r43 + l43 * r44;
2976
+ oe[15] = l14 * r41 + l24 * r42 + l34 * r43 + l44 * r44;
2977
+ };
2978
+ /**
2979
+ * Determines whether the specified matrices are equals.
2980
+ * @param left - The first matrix to compare
2981
+ * @param right - The second matrix to compare
2982
+ * @returns True if the specified matrices are equals, false otherwise
2983
+ */ Matrix.equals = function equals(left, right) {
2984
+ var le = left.elements;
2985
+ var re = right.elements;
2986
+ return MathUtil.equals(le[0], re[0]) && MathUtil.equals(le[1], re[1]) && MathUtil.equals(le[2], re[2]) && MathUtil.equals(le[3], re[3]) && MathUtil.equals(le[4], re[4]) && MathUtil.equals(le[5], re[5]) && MathUtil.equals(le[6], re[6]) && MathUtil.equals(le[7], re[7]) && MathUtil.equals(le[8], re[8]) && MathUtil.equals(le[9], re[9]) && MathUtil.equals(le[10], re[10]) && MathUtil.equals(le[11], re[11]) && MathUtil.equals(le[12], re[12]) && MathUtil.equals(le[13], re[13]) && MathUtil.equals(le[14], re[14]) && MathUtil.equals(le[15], re[15]);
2987
+ };
2988
+ /**
2989
+ * Performs a linear interpolation between two matrices.
2990
+ * @param start - The first matrix
2991
+ * @param end - The second matrix
2992
+ * @param t - The blend amount where 0 returns start and 1 end
2993
+ * @param out - The result of linear blending between two matrices
2994
+ */ Matrix.lerp = function lerp(start, end, t, out) {
2995
+ var se = start.elements;
2996
+ var ee = end.elements;
2997
+ var oe = out.elements;
2998
+ var inv = 1.0 - t;
2999
+ oe[0] = se[0] * inv + ee[0] * t;
3000
+ oe[1] = se[1] * inv + ee[1] * t;
3001
+ oe[2] = se[2] * inv + ee[2] * t;
3002
+ oe[3] = se[3] * inv + ee[3] * t;
3003
+ oe[4] = se[4] * inv + ee[4] * t;
3004
+ oe[5] = se[5] * inv + ee[5] * t;
3005
+ oe[6] = se[6] * inv + ee[6] * t;
3006
+ oe[7] = se[7] * inv + ee[7] * t;
3007
+ oe[8] = se[8] * inv + ee[8] * t;
3008
+ oe[9] = se[9] * inv + ee[9] * t;
3009
+ oe[10] = se[10] * inv + ee[10] * t;
3010
+ oe[11] = se[11] * inv + ee[11] * t;
3011
+ oe[12] = se[12] * inv + ee[12] * t;
3012
+ oe[13] = se[13] * inv + ee[13] * t;
3013
+ oe[14] = se[14] * inv + ee[14] * t;
3014
+ oe[15] = se[15] * inv + ee[15] * t;
3015
+ };
3016
+ /**
3017
+ * Determines the sum of two matrices.
3018
+ * @param left - The first matrix to add
3019
+ * @param right - The second matrix to add
3020
+ * @param out - The sum of two matrices
3021
+ */ Matrix.add = function add(left, right, out) {
3022
+ var le = left.elements;
3023
+ var re = right.elements;
3024
+ var oe = out.elements;
3025
+ oe[0] = le[0] + re[0];
3026
+ oe[1] = le[1] + re[1];
3027
+ oe[2] = le[2] + re[2];
3028
+ oe[3] = le[3] + re[3];
3029
+ oe[4] = le[4] + re[4];
3030
+ oe[5] = le[5] + re[5];
3031
+ oe[6] = le[6] + re[6];
3032
+ oe[7] = le[7] + re[7];
3033
+ oe[8] = le[8] + re[8];
3034
+ oe[9] = le[9] + re[9];
3035
+ oe[10] = le[10] + re[10];
3036
+ oe[11] = le[11] + re[11];
3037
+ oe[12] = le[12] + re[12];
3038
+ oe[13] = le[13] + re[13];
3039
+ oe[14] = le[14] + re[14];
3040
+ oe[15] = le[15] + re[15];
3041
+ };
3042
+ /**
3043
+ * Multiplies a matrix by a scalar.
3044
+ * @param source - The matrix to multiply
3045
+ * @param scalar - The scalar to multiply
3046
+ * @param out - The result of multiplying a matrix by a scalar
3047
+ */ Matrix.multiplyScalar = function multiplyScalar(source, scalar, out) {
3048
+ var se = source.elements;
3049
+ var oe = out.elements;
3050
+ oe[0] = se[0] * scalar;
3051
+ oe[1] = se[1] * scalar;
3052
+ oe[2] = se[2] * scalar;
3053
+ oe[3] = se[3] * scalar;
3054
+ oe[4] = se[4] * scalar;
3055
+ oe[5] = se[5] * scalar;
3056
+ oe[6] = se[6] * scalar;
3057
+ oe[7] = se[7] * scalar;
3058
+ oe[8] = se[8] * scalar;
3059
+ oe[9] = se[9] * scalar;
3060
+ oe[10] = se[10] * scalar;
3061
+ oe[11] = se[11] * scalar;
3062
+ oe[12] = se[12] * scalar;
3063
+ oe[13] = se[13] * scalar;
3064
+ oe[14] = se[14] * scalar;
3065
+ oe[15] = se[15] * scalar;
3066
+ };
3067
+ /**
3068
+ * Calculate a rotation matrix from a quaternion.
3069
+ * @param quaternion - The quaternion used to calculate the matrix
3070
+ * @param out - The calculated rotation matrix
3071
+ */ Matrix.rotationQuaternion = function rotationQuaternion(quaternion, out) {
3072
+ var oe = out.elements;
3073
+ var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
3074
+ var x2 = x + x;
3075
+ var y2 = y + y;
3076
+ var z2 = z + z;
3077
+ var xx = x * x2;
3078
+ var yx = y * x2;
3079
+ var yy = y * y2;
3080
+ var zx = z * x2;
3081
+ var zy = z * y2;
3082
+ var zz = z * z2;
3083
+ var wx = w * x2;
3084
+ var wy = w * y2;
3085
+ var wz = w * z2;
3086
+ oe[0] = 1 - yy - zz;
3087
+ oe[1] = yx + wz;
3088
+ oe[2] = zx - wy;
3089
+ oe[3] = 0;
3090
+ oe[4] = yx - wz;
3091
+ oe[5] = 1 - xx - zz;
3092
+ oe[6] = zy + wx;
3093
+ oe[7] = 0;
3094
+ oe[8] = zx + wy;
3095
+ oe[9] = zy - wx;
3096
+ oe[10] = 1 - xx - yy;
3097
+ oe[11] = 0;
3098
+ oe[12] = 0;
3099
+ oe[13] = 0;
3100
+ oe[14] = 0;
3101
+ oe[15] = 1;
3102
+ };
3103
+ /**
3104
+ * Calculate a matrix rotates around an arbitrary axis.
3105
+ * @param axis - The axis
3106
+ * @param r - The rotation angle in radians
3107
+ * @param out - The matrix after rotate
3108
+ */ Matrix.rotationAxisAngle = function rotationAxisAngle(axis, r, out) {
3109
+ var oe = out.elements;
3110
+ var x = axis._x, y = axis._y, z = axis._z;
3111
+ var len = Math.sqrt(x * x + y * y + z * z);
3112
+ var s, c, t;
3113
+ if (Math.abs(len) < MathUtil.zeroTolerance) {
3114
+ return;
3115
+ }
3116
+ len = 1 / len;
3117
+ x *= len;
3118
+ y *= len;
3119
+ z *= len;
3120
+ s = Math.sin(r);
3121
+ c = Math.cos(r);
3122
+ t = 1 - c;
3123
+ // Perform rotation-specific matrix multiplication
3124
+ oe[0] = x * x * t + c;
3125
+ oe[1] = y * x * t + z * s;
3126
+ oe[2] = z * x * t - y * s;
3127
+ oe[3] = 0;
3128
+ oe[4] = x * y * t - z * s;
3129
+ oe[5] = y * y * t + c;
3130
+ oe[6] = z * y * t + x * s;
3131
+ oe[7] = 0;
3132
+ oe[8] = x * z * t + y * s;
3133
+ oe[9] = y * z * t - x * s;
3134
+ oe[10] = z * z * t + c;
3135
+ oe[11] = 0;
3136
+ oe[12] = 0;
3137
+ oe[13] = 0;
3138
+ oe[14] = 0;
3139
+ oe[15] = 1;
3140
+ };
3141
+ /**
3142
+ * Calculate a matrix from a quaternion and a translation.
3143
+ * @param quaternion - The quaternion used to calculate the matrix
3144
+ * @param translation - The translation used to calculate the matrix
3145
+ * @param out - The calculated matrix
3146
+ */ Matrix.rotationTranslation = function rotationTranslation(quaternion, translation, out) {
3147
+ Matrix.rotationQuaternion(quaternion, out);
3148
+ var oe = out.elements;
3149
+ oe[12] = translation._x;
3150
+ oe[13] = translation._y;
3151
+ oe[14] = translation._z;
3152
+ };
3153
+ /**
3154
+ * Calculate an affine matrix.
3155
+ * @param scale - The scale used to calculate matrix
3156
+ * @param rotation - The rotation used to calculate matrix
3157
+ * @param translation - The translation used to calculate matrix
3158
+ * @param out - The calculated matrix
3159
+ */ Matrix.affineTransformation = function affineTransformation(scale, rotation, translation, out) {
3160
+ var oe = out.elements;
3161
+ var x = rotation._x, y = rotation._y, z = rotation._z, w = rotation._w;
3162
+ var x2 = x + x;
3163
+ var y2 = y + y;
3164
+ var z2 = z + z;
3165
+ var xx = x * x2;
3166
+ var xy = x * y2;
3167
+ var xz = x * z2;
3168
+ var yy = y * y2;
3169
+ var yz = y * z2;
3170
+ var zz = z * z2;
3171
+ var wx = w * x2;
3172
+ var wy = w * y2;
3173
+ var wz = w * z2;
3174
+ var sx = scale._x;
3175
+ var sy = scale._y;
3176
+ var sz = scale._z;
3177
+ oe[0] = (1 - (yy + zz)) * sx;
3178
+ oe[1] = (xy + wz) * sx;
3179
+ oe[2] = (xz - wy) * sx;
3180
+ oe[3] = 0;
3181
+ oe[4] = (xy - wz) * sy;
3182
+ oe[5] = (1 - (xx + zz)) * sy;
3183
+ oe[6] = (yz + wx) * sy;
3184
+ oe[7] = 0;
3185
+ oe[8] = (xz + wy) * sz;
3186
+ oe[9] = (yz - wx) * sz;
3187
+ oe[10] = (1 - (xx + yy)) * sz;
3188
+ oe[11] = 0;
3189
+ oe[12] = translation._x;
3190
+ oe[13] = translation._y;
3191
+ oe[14] = translation._z;
3192
+ oe[15] = 1;
3193
+ };
3194
+ /**
3195
+ * Calculate a matrix from scale vector.
3196
+ * @param s - The scale vector
3197
+ * @param out - The calculated matrix
3198
+ */ Matrix.scaling = function scaling(s, out) {
3199
+ var oe = out.elements;
3200
+ oe[0] = s._x;
3201
+ oe[1] = 0;
3202
+ oe[2] = 0;
3203
+ oe[3] = 0;
3204
+ oe[4] = 0;
3205
+ oe[5] = s._y;
3206
+ oe[6] = 0;
3207
+ oe[7] = 0;
3208
+ oe[8] = 0;
3209
+ oe[9] = 0;
3210
+ oe[10] = s._z;
3211
+ oe[11] = 0;
3212
+ oe[12] = 0;
3213
+ oe[13] = 0;
3214
+ oe[14] = 0;
3215
+ oe[15] = 1;
3216
+ };
3217
+ /**
3218
+ * Calculate a matrix from translation vector.
3219
+ * @param translation - The translation vector
3220
+ * @param out - The calculated matrix
3221
+ */ Matrix.translation = function translation(translation, out) {
3222
+ var oe = out.elements;
3223
+ oe[0] = 1;
3224
+ oe[1] = 0;
3225
+ oe[2] = 0;
3226
+ oe[3] = 0;
3227
+ oe[4] = 0;
3228
+ oe[5] = 1;
3229
+ oe[6] = 0;
3230
+ oe[7] = 0;
3231
+ oe[8] = 0;
3232
+ oe[9] = 0;
3233
+ oe[10] = 1;
3234
+ oe[11] = 0;
3235
+ oe[12] = translation._x;
3236
+ oe[13] = translation._y;
3237
+ oe[14] = translation._z;
3238
+ oe[15] = 1;
3239
+ };
3240
+ /**
3241
+ * Calculate the inverse of the specified matrix.
3242
+ * @param a - The matrix whose inverse is to be calculated
3243
+ * @param out - The inverse of the specified matrix
3244
+ */ Matrix.invert = function invert(a, out) {
3245
+ var ae = a.elements;
3246
+ var oe = out.elements;
3247
+ var a11 = ae[0], a12 = ae[1], a13 = ae[2], a14 = ae[3];
3248
+ var a21 = ae[4], a22 = ae[5], a23 = ae[6], a24 = ae[7];
3249
+ var a31 = ae[8], a32 = ae[9], a33 = ae[10], a34 = ae[11];
3250
+ var a41 = ae[12], a42 = ae[13], a43 = ae[14], a44 = ae[15];
3251
+ var b00 = a11 * a22 - a12 * a21;
3252
+ var b01 = a11 * a23 - a13 * a21;
3253
+ var b02 = a11 * a24 - a14 * a21;
3254
+ var b03 = a12 * a23 - a13 * a22;
3255
+ var b04 = a12 * a24 - a14 * a22;
3256
+ var b05 = a13 * a24 - a14 * a23;
3257
+ var b06 = a31 * a42 - a32 * a41;
3258
+ var b07 = a31 * a43 - a33 * a41;
3259
+ var b08 = a31 * a44 - a34 * a41;
3260
+ var b09 = a32 * a43 - a33 * a42;
3261
+ var b10 = a32 * a44 - a34 * a42;
3262
+ var b11 = a33 * a44 - a34 * a43;
3263
+ var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
3264
+ if (!det) {
3265
+ return null;
3266
+ }
3267
+ det = 1.0 / det;
3268
+ oe[0] = (a22 * b11 - a23 * b10 + a24 * b09) * det;
3269
+ oe[1] = (a13 * b10 - a12 * b11 - a14 * b09) * det;
3270
+ oe[2] = (a42 * b05 - a43 * b04 + a44 * b03) * det;
3271
+ oe[3] = (a33 * b04 - a32 * b05 - a34 * b03) * det;
3272
+ oe[4] = (a23 * b08 - a21 * b11 - a24 * b07) * det;
3273
+ oe[5] = (a11 * b11 - a13 * b08 + a14 * b07) * det;
3274
+ oe[6] = (a43 * b02 - a41 * b05 - a44 * b01) * det;
3275
+ oe[7] = (a31 * b05 - a33 * b02 + a34 * b01) * det;
3276
+ oe[8] = (a21 * b10 - a22 * b08 + a24 * b06) * det;
3277
+ oe[9] = (a12 * b08 - a11 * b10 - a14 * b06) * det;
3278
+ oe[10] = (a41 * b04 - a42 * b02 + a44 * b00) * det;
3279
+ oe[11] = (a32 * b02 - a31 * b04 - a34 * b00) * det;
3280
+ oe[12] = (a22 * b07 - a21 * b09 - a23 * b06) * det;
3281
+ oe[13] = (a11 * b09 - a12 * b07 + a13 * b06) * det;
3282
+ oe[14] = (a42 * b01 - a41 * b03 - a43 * b00) * det;
3283
+ oe[15] = (a31 * b03 - a32 * b01 + a33 * b00) * det;
3284
+ };
3285
+ /**
3286
+ * Calculate a right-handed look-at matrix.
3287
+ * @param eye - The position of the viewer's eye
3288
+ * @param target - The camera look-at target
3289
+ * @param up - The camera's up vector
3290
+ * @param out - The calculated look-at matrix
3291
+ */ Matrix.lookAt = function lookAt(eye, target, up, out) {
3292
+ var oe = out.elements;
3293
+ var xAxis = Matrix._tempVec30;
3294
+ var yAxis = Matrix._tempVec31;
3295
+ var zAxis = Matrix._tempVec32;
3296
+ Vector3.subtract(eye, target, zAxis);
3297
+ zAxis.normalize();
3298
+ Vector3.cross(up, zAxis, xAxis);
3299
+ xAxis.normalize();
3300
+ Vector3.cross(zAxis, xAxis, yAxis);
3301
+ oe[0] = xAxis._x;
3302
+ oe[1] = yAxis._x;
3303
+ oe[2] = zAxis._x;
3304
+ oe[3] = 0;
3305
+ oe[4] = xAxis._y;
3306
+ oe[5] = yAxis._y;
3307
+ oe[6] = zAxis._y;
3308
+ oe[7] = 0;
3309
+ oe[8] = xAxis._z;
3310
+ oe[9] = yAxis._z;
3311
+ oe[10] = zAxis._z;
3312
+ oe[11] = 0;
3313
+ oe[12] = -Vector3.dot(xAxis, eye);
3314
+ oe[13] = -Vector3.dot(yAxis, eye);
3315
+ oe[14] = -Vector3.dot(zAxis, eye);
3316
+ oe[15] = 1;
3317
+ };
3318
+ /**
3319
+ * Calculate an orthographic projection matrix.
3320
+ * @param left - The left edge of the viewing
3321
+ * @param right - The right edge of the viewing
3322
+ * @param bottom - The bottom edge of the viewing
3323
+ * @param top - The top edge of the viewing
3324
+ * @param near - The depth of the near plane
3325
+ * @param far - The depth of the far plane
3326
+ * @param out - The calculated orthographic projection matrix
3327
+ */ Matrix.ortho = function ortho(left, right, bottom, top, near, far, out) {
3328
+ var oe = out.elements;
3329
+ var lr = 1 / (left - right);
3330
+ var bt = 1 / (bottom - top);
3331
+ var nf = 1 / (near - far);
3332
+ oe[0] = -2 * lr;
3333
+ oe[1] = 0;
3334
+ oe[2] = 0;
3335
+ oe[3] = 0;
3336
+ oe[4] = 0;
3337
+ oe[5] = -2 * bt;
3338
+ oe[6] = 0;
3339
+ oe[7] = 0;
3340
+ oe[8] = 0;
3341
+ oe[9] = 0;
3342
+ oe[10] = 2 * nf;
3343
+ oe[11] = 0;
3344
+ oe[12] = (left + right) * lr;
3345
+ oe[13] = (top + bottom) * bt;
3346
+ oe[14] = (far + near) * nf;
3347
+ oe[15] = 1;
3348
+ };
3349
+ /**
3350
+ * Calculate a perspective projection matrix.
3351
+ * @param fovY - Field of view in the y direction, in radians
3352
+ * @param aspect - Aspect ratio, defined as view space width divided by height
3353
+ * @param near - The depth of the near plane
3354
+ * @param far - The depth of the far plane
3355
+ * @param out - The calculated perspective projection matrix
3356
+ */ Matrix.perspective = function perspective(fovY, aspect, near, far, out) {
3357
+ var oe = out.elements;
3358
+ var f = 1.0 / Math.tan(fovY / 2);
3359
+ var nf = 1 / (near - far);
3360
+ oe[0] = f / aspect;
3361
+ oe[1] = 0;
3362
+ oe[2] = 0;
3363
+ oe[3] = 0;
3364
+ oe[4] = 0;
3365
+ oe[5] = f;
3366
+ oe[6] = 0;
3367
+ oe[7] = 0;
3368
+ oe[8] = 0;
3369
+ oe[9] = 0;
3370
+ oe[10] = (far + near) * nf;
3371
+ oe[11] = -1;
3372
+ oe[12] = 0;
3373
+ oe[13] = 0;
3374
+ oe[14] = 2 * far * near * nf;
3375
+ oe[15] = 0;
3376
+ };
3377
+ /**
3378
+ * The specified matrix rotates around an arbitrary axis.
3379
+ * @param m - The specified matrix
3380
+ * @param axis - The axis
3381
+ * @param r - The rotation angle in radians
3382
+ * @param out - The rotated matrix
3383
+ */ Matrix.rotateAxisAngle = function rotateAxisAngle(m, axis, r, out) {
3384
+ var x = axis._x, y = axis._y, z = axis._z;
3385
+ var len = Math.sqrt(x * x + y * y + z * z);
3386
+ if (Math.abs(len) < MathUtil.zeroTolerance) {
3387
+ return;
3388
+ }
3389
+ var me = m.elements;
3390
+ var oe = out.elements;
3391
+ var s, c, t;
3392
+ len = 1 / len;
3393
+ x *= len;
3394
+ y *= len;
3395
+ z *= len;
3396
+ s = Math.sin(r);
3397
+ c = Math.cos(r);
3398
+ t = 1 - c;
3399
+ var a11 = me[0], a12 = me[1], a13 = me[2], a14 = me[3];
3400
+ var a21 = me[4], a22 = me[5], a23 = me[6], a24 = me[7];
3401
+ var a31 = me[8], a32 = me[9], a33 = me[10], a34 = me[11];
3402
+ // Construct the elements of the rotation matrix
3403
+ var b11 = x * x * t + c;
3404
+ var b12 = y * x * t + z * s;
3405
+ var b13 = z * x * t - y * s;
3406
+ var b21 = x * y * t - z * s;
3407
+ var b22 = y * y * t + c;
3408
+ var b23 = z * y * t + x * s;
3409
+ var b31 = x * z * t + y * s;
3410
+ var b32 = y * z * t - x * s;
3411
+ var b33 = z * z * t + c;
3412
+ // Perform rotation-specific matrix multiplication
3413
+ oe[0] = a11 * b11 + a21 * b12 + a31 * b13;
3414
+ oe[1] = a12 * b11 + a22 * b12 + a32 * b13;
3415
+ oe[2] = a13 * b11 + a23 * b12 + a33 * b13;
3416
+ oe[3] = a14 * b11 + a24 * b12 + a34 * b13;
3417
+ oe[4] = a11 * b21 + a21 * b22 + a31 * b23;
3418
+ oe[5] = a12 * b21 + a22 * b22 + a32 * b23;
3419
+ oe[6] = a13 * b21 + a23 * b22 + a33 * b23;
3420
+ oe[7] = a14 * b21 + a24 * b22 + a34 * b23;
3421
+ oe[8] = a11 * b31 + a21 * b32 + a31 * b33;
3422
+ oe[9] = a12 * b31 + a22 * b32 + a32 * b33;
3423
+ oe[10] = a13 * b31 + a23 * b32 + a33 * b33;
3424
+ oe[11] = a14 * b31 + a24 * b32 + a34 * b33;
3425
+ if (m !== out) {
3426
+ // If the source and destination differ, copy the unchanged last row
3427
+ oe[12] = me[12];
3428
+ oe[13] = me[13];
3429
+ oe[14] = me[14];
3430
+ oe[15] = me[15];
3431
+ }
3432
+ };
3433
+ /**
3434
+ * Scale a matrix by a given vector.
3435
+ * @param m - The matrix
3436
+ * @param s - The given vector
3437
+ * @param out - The scaled matrix
3438
+ */ Matrix.scale = function scale(m, s, out) {
3439
+ var me = m.elements;
3440
+ var oe = out.elements;
3441
+ var x = s._x, y = s._y, z = s._z;
3442
+ oe[0] = me[0] * x;
3443
+ oe[1] = me[1] * x;
3444
+ oe[2] = me[2] * x;
3445
+ oe[3] = me[3] * x;
3446
+ oe[4] = me[4] * y;
3447
+ oe[5] = me[5] * y;
3448
+ oe[6] = me[6] * y;
3449
+ oe[7] = me[7] * y;
3450
+ oe[8] = me[8] * z;
3451
+ oe[9] = me[9] * z;
3452
+ oe[10] = me[10] * z;
3453
+ oe[11] = me[11] * z;
3454
+ oe[12] = me[12];
3455
+ oe[13] = me[13];
3456
+ oe[14] = me[14];
3457
+ oe[15] = me[15];
3458
+ };
3459
+ /**
3460
+ * Translate a matrix by a given vector.
3461
+ * @param m - The matrix
3462
+ * @param v - The given vector
3463
+ * @param out - The translated matrix
3464
+ */ Matrix.translate = function translate(m, v, out) {
3465
+ var me = m.elements;
3466
+ var oe = out.elements;
3467
+ var x = v._x, y = v._y, z = v._z;
3468
+ if (m === out) {
3469
+ oe[12] = me[0] * x + me[4] * y + me[8] * z + me[12];
3470
+ oe[13] = me[1] * x + me[5] * y + me[9] * z + me[13];
3471
+ oe[14] = me[2] * x + me[6] * y + me[10] * z + me[14];
3472
+ oe[15] = me[3] * x + me[7] * y + me[11] * z + me[15];
3473
+ } else {
3474
+ var a11 = me[0], a12 = me[1], a13 = me[2], a14 = me[3];
3475
+ var a21 = me[4], a22 = me[5], a23 = me[6], a24 = me[7];
3476
+ var a31 = me[8], a32 = me[9], a33 = me[10], a34 = me[11];
3477
+ oe[0] = a11, oe[1] = a12, oe[2] = a13, oe[3] = a14;
3478
+ oe[4] = a21, oe[5] = a22, oe[6] = a23, oe[7] = a24;
3479
+ oe[8] = a31, oe[9] = a32, oe[10] = a33, oe[11] = a34;
3480
+ oe[12] = a11 * x + a21 * y + a31 * z + me[12];
3481
+ oe[13] = a12 * x + a22 * y + a32 * z + me[13];
3482
+ oe[14] = a13 * x + a23 * y + a33 * z + me[14];
3483
+ oe[15] = a14 * x + a24 * y + a34 * z + me[15];
3484
+ }
3485
+ };
3486
+ /**
3487
+ * Calculate the transpose of the specified matrix.
3488
+ * @param a - The specified matrix
3489
+ * @param out - The transpose of the specified matrix
3490
+ */ Matrix.transpose = function transpose(a, out) {
3491
+ var ae = a.elements;
3492
+ var oe = out.elements;
3493
+ if (out === a) {
3494
+ var a12 = ae[1];
3495
+ var a13 = ae[2];
3496
+ var a14 = ae[3];
3497
+ var a23 = ae[6];
3498
+ var a24 = ae[7];
3499
+ var a34 = ae[11];
3500
+ oe[1] = ae[4];
3501
+ oe[2] = ae[8];
3502
+ oe[3] = ae[12];
3503
+ oe[4] = a12;
3504
+ oe[6] = ae[9];
3505
+ oe[7] = ae[13];
3506
+ oe[8] = a13;
3507
+ oe[9] = a23;
3508
+ oe[11] = ae[14];
3509
+ oe[12] = a14;
3510
+ oe[13] = a24;
3511
+ oe[14] = a34;
3512
+ } else {
3513
+ oe[0] = ae[0];
3514
+ oe[1] = ae[4];
3515
+ oe[2] = ae[8];
3516
+ oe[3] = ae[12];
3517
+ oe[4] = ae[1];
3518
+ oe[5] = ae[5];
3519
+ oe[6] = ae[9];
3520
+ oe[7] = ae[13];
3521
+ oe[8] = ae[2];
3522
+ oe[9] = ae[6];
3523
+ oe[10] = ae[10];
3524
+ oe[11] = ae[14];
3525
+ oe[12] = ae[3];
3526
+ oe[13] = ae[7];
3527
+ oe[14] = ae[11];
3528
+ oe[15] = ae[15];
3529
+ }
3530
+ };
3531
+ return Matrix;
3532
+ }();
3533
+ (function() {
3534
+ Matrix._tempVec30 = new Vector3();
3535
+ })();
3536
+ (function() {
3537
+ Matrix._tempVec31 = new Vector3();
3538
+ })();
3539
+ (function() {
3540
+ Matrix._tempVec32 = new Vector3();
3541
+ })();
3542
+ (function() {
3543
+ Matrix._tempMat30 = new Matrix3x3();
3544
+ })();
3545
+ (function() {
3546
+ /** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
3547
+ })();
3548
+
3549
+ /**
3550
+ * Represents a ray with an origin and a direction in 3D space.
3551
+ */ var Ray = /*#__PURE__*/ function() {
3552
+ function Ray(origin, direction) {
3553
+ if (origin === void 0) origin = null;
3554
+ if (direction === void 0) direction = null;
3555
+ /** The origin of the ray. */ this.origin = new Vector3();
3556
+ /** The normalized direction of the ray. */ this.direction = new Vector3();
3557
+ origin && this.origin.copyFrom(origin);
3558
+ direction && this.direction.copyFrom(direction);
3559
+ }
3560
+ var _proto = Ray.prototype;
3561
+ /**
3562
+ * Check if this ray intersects the specified plane.
3563
+ * @param plane - The specified plane
3564
+ * @returns The distance from this ray to the specified plane if intersecting, -1 otherwise
3565
+ */ _proto.intersectPlane = function intersectPlane(plane) {
3566
+ return CollisionUtil.intersectsRayAndPlane(this, plane);
3567
+ };
3568
+ /**
3569
+ * Check if this ray intersects the specified sphere.
3570
+ * @param sphere - The specified sphere
3571
+ * @returns The distance from this ray to the specified sphere if intersecting, -1 otherwise
3572
+ */ _proto.intersectSphere = function intersectSphere(sphere) {
3573
+ return CollisionUtil.intersectsRayAndSphere(this, sphere);
3574
+ };
3575
+ /**
3576
+ * Check if this ray intersects the specified box (AABB).
3577
+ * @param box - The specified box
3578
+ * @returns The distance from this ray to the specified box if intersecting, -1 otherwise
3579
+ */ _proto.intersectBox = function intersectBox(box) {
3580
+ return CollisionUtil.intersectsRayAndBox(this, box);
3581
+ };
3582
+ /**
3583
+ * The coordinates of the specified distance from the origin in the ray direction.
3584
+ * @param distance - The specified distance
3585
+ * @param out - The coordinates as an output parameter
3586
+ * @returns The out
3587
+ */ _proto.getPoint = function getPoint(distance, out) {
3588
+ Vector3.scale(this.direction, distance, out);
3589
+ return out.add(this.origin);
3590
+ };
3591
+ return Ray;
3592
+ }();
3593
+
3594
+ /**
3595
+ * Describes a 2D-vector.
3596
+ */ var Vector2 = /*#__PURE__*/ function() {
3597
+ function Vector2(x, y) {
3598
+ if (x === void 0) x = 0;
3599
+ if (y === void 0) y = 0;
3600
+ /** @internal */ this._onValueChanged = null;
3601
+ this._x = x;
3602
+ this._y = y;
3603
+ }
3604
+ var _proto = Vector2.prototype;
3605
+ /**
3606
+ * Set the value of this vector.
3607
+ * @param x - The x component of the vector
3608
+ * @param y - The y component of the vector
3609
+ * @returns This vector
3610
+ */ _proto.set = function set(x, y) {
3611
+ this._x = x;
3612
+ this._y = y;
3613
+ this._onValueChanged && this._onValueChanged();
3614
+ return this;
3615
+ };
3616
+ /**
3617
+ * Determines the sum of this vector and the specified vector.
3618
+ * @param right - The specified vector
3619
+ * @returns This vector
3620
+ */ _proto.add = function add(right) {
3621
+ this._x += right._x;
3622
+ this._y += right._y;
3623
+ this._onValueChanged && this._onValueChanged();
3624
+ return this;
3625
+ };
3626
+ /**
3627
+ * Determines the difference of this vector and the specified vector.
3628
+ * @param right - The specified vector
3629
+ * @returns This vector
3630
+ */ _proto.subtract = function subtract(right) {
3631
+ this._x -= right._x;
3632
+ this._y -= right._y;
3633
+ this._onValueChanged && this._onValueChanged();
3634
+ return this;
3635
+ };
3636
+ /**
3637
+ * Determines the product of this vector and the specified vector.
3638
+ * @param right - The specified vector
3639
+ * @returns This vector
3640
+ */ _proto.multiply = function multiply(right) {
3641
+ this._x *= right._x;
3642
+ this._y *= right._y;
3643
+ this._onValueChanged && this._onValueChanged();
3644
+ return this;
3645
+ };
3646
+ /**
3647
+ * Determines the divisor of this vector and the specified vector.
3648
+ * @param right - The specified vector
3649
+ * @returns This vector
3650
+ */ _proto.divide = function divide(right) {
3651
+ this._x /= right._x;
3652
+ this._y /= right._y;
3653
+ this._onValueChanged && this._onValueChanged();
3654
+ return this;
3655
+ };
3656
+ /**
3657
+ * Calculate the length of this vector.
3658
+ * @returns The length of this vector
3659
+ */ _proto.length = function length() {
3660
+ var _this = this, _x = _this._x, _y = _this._y;
3661
+ return Math.sqrt(_x * _x + _y * _y);
3662
+ };
3663
+ /**
3664
+ * Calculate the squared length of this vector.
3665
+ * @returns The squared length of this vector
3666
+ */ _proto.lengthSquared = function lengthSquared() {
3667
+ var _this = this, _x = _this._x, _y = _this._y;
3668
+ return _x * _x + _y * _y;
3669
+ };
3670
+ /**
3671
+ * Reverses the direction of this vector.
3672
+ * @returns This vector
3673
+ */ _proto.negate = function negate() {
3674
+ this._x = -this._x;
3675
+ this._y = -this._y;
3676
+ this._onValueChanged && this._onValueChanged();
3677
+ return this;
3678
+ };
3679
+ /**
3680
+ * Converts this vector into a unit vector.
3681
+ * @returns This vector
3682
+ */ _proto.normalize = function normalize() {
3683
+ Vector2.normalize(this, this);
3684
+ return this;
3685
+ };
3686
+ /**
3687
+ * Scale this vector by the given value.
3688
+ * @param s - The amount by which to scale the vector
3689
+ * @returns This vector
3690
+ */ _proto.scale = function scale(s) {
3691
+ this._x *= s;
3692
+ this._y *= s;
3693
+ this._onValueChanged && this._onValueChanged();
3694
+ return this;
3695
+ };
3696
+ /**
3697
+ * Creates a clone of this vector.
3698
+ * @returns A clone of this vector
3699
+ */ _proto.clone = function clone() {
3700
+ return new Vector2(this._x, this._y);
3701
+ };
3702
+ /**
3703
+ * Copy from vector2 like object.
3704
+ * @param source - Vector2 like object
3705
+ * @returns This vector
3706
+ */ _proto.copyFrom = function copyFrom(source) {
3707
+ this._x = source.x;
3708
+ this._y = source.y;
3709
+ this._onValueChanged && this._onValueChanged();
3710
+ return this;
3711
+ };
3712
+ /**
3713
+ * Copy the value of this vector from an array.
3714
+ * @param array - The array
3715
+ * @param offset - The start offset of the array
3716
+ * @returns This vector
3717
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
3718
+ if (offset === void 0) offset = 0;
3719
+ this._x = array[offset];
3720
+ this._y = array[offset + 1];
3721
+ this._onValueChanged && this._onValueChanged();
3722
+ return this;
3723
+ };
3724
+ /**
3725
+ * Copy the value of this vector to an array.
3726
+ * @param out - The array
3727
+ * @param outOffset - The start offset of the array
3728
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
3729
+ if (outOffset === void 0) outOffset = 0;
3730
+ out[outOffset] = this._x;
3731
+ out[outOffset + 1] = this._y;
3732
+ };
3733
+ /**
3734
+ * Serialize this vector to a JSON representation.
3735
+ * @returns A JSON representation of this vector
3736
+ */ _proto.toJSON = function toJSON() {
3737
+ return {
3738
+ x: this._x,
3739
+ y: this._y
3740
+ };
3741
+ };
3742
+ /**
3743
+ * Determines the sum of two vectors.
3744
+ * @param left - The first vector to add
3745
+ * @param right - The second vector to add
3746
+ * @param out - The sum of two vectors
3747
+ */ Vector2.add = function add(left, right, out) {
3748
+ out._x = left._x + right._x;
3749
+ out._y = left._y + right._y;
3750
+ out._onValueChanged && out._onValueChanged();
3751
+ };
3752
+ /**
3753
+ * Determines the difference between two vectors.
3754
+ * @param left - The first vector to subtract
3755
+ * @param right - The second vector to subtract
3756
+ * @param out - The difference between two vectors
3757
+ */ Vector2.subtract = function subtract(left, right, out) {
3758
+ out._x = left._x - right._x;
3759
+ out._y = left._y - right._y;
3760
+ out._onValueChanged && out._onValueChanged();
3761
+ };
3762
+ /**
3763
+ * Determines the product of two vectors.
3764
+ * @param left - The first vector to multiply
3765
+ * @param right - The second vector to multiply
3766
+ * @param out - The product of two vectors
3767
+ */ Vector2.multiply = function multiply(left, right, out) {
3768
+ out._x = left._x * right._x;
3769
+ out._y = left._y * right._y;
3770
+ out._onValueChanged && out._onValueChanged();
3771
+ };
3772
+ /**
3773
+ * Determines the divisor of two vectors.
3774
+ * @param left - The first vector to divide
3775
+ * @param right - The second vector to divide
3776
+ * @param out - The divisor of two vectors
3777
+ */ Vector2.divide = function divide(left, right, out) {
3778
+ out._x = left._x / right._x;
3779
+ out._y = left._y / right._y;
3780
+ out._onValueChanged && out._onValueChanged();
3781
+ };
3782
+ /**
3783
+ * Determines the dot product of two vectors.
3784
+ * @param left - The first vector to dot
3785
+ * @param right - The second vector to dot
3786
+ * @returns The dot product of two vectors
3787
+ */ Vector2.dot = function dot(left, right) {
3788
+ return left._x * right._x + left._y * right._y;
3789
+ };
3790
+ /**
3791
+ * Determines the distance of two vectors.
3792
+ * @param left - The first vector
3793
+ * @param right - The second vector
3794
+ * @returns The distance of two vectors
3795
+ */ Vector2.distance = function distance(left, right) {
3796
+ var x = right._x - left._x;
3797
+ var y = right._y - left._y;
3798
+ return Math.sqrt(x * x + y * y);
3799
+ };
3800
+ /**
3801
+ * Determines the squared distance of two vectors.
3802
+ * @param left - The first vector
3803
+ * @param right - The second vector
3804
+ * @returns The squared distance of two vectors
3805
+ */ Vector2.distanceSquared = function distanceSquared(left, right) {
3806
+ var x = right._x - left._x;
3807
+ var y = right._y - left._y;
3808
+ return x * x + y * y;
3809
+ };
3810
+ /**
3811
+ * Determines whether the specified vectors are equals.
3812
+ * @param left - The first vector to compare
3813
+ * @param right - The second vector to compare
3814
+ * @returns True if the specified vectors are equals, false otherwise
3815
+ */ Vector2.equals = function equals(left, right) {
3816
+ return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y);
3817
+ };
3818
+ /**
3819
+ * Performs a linear interpolation between two vectors.
3820
+ * @param left - The first vector
3821
+ * @param right - The second vector
3822
+ * @param t - The blend amount where 0 returns left and 1 right
3823
+ * @param out - The result of linear blending between two vectors
3824
+ */ Vector2.lerp = function lerp(left, right, t, out) {
3825
+ var _x = left._x, _y = left._y;
3826
+ out._x = _x + (right._x - _x) * t;
3827
+ out._y = _y + (right._y - _y) * t;
3828
+ out._onValueChanged && out._onValueChanged();
3829
+ };
3830
+ /**
3831
+ * Calculate a vector containing the largest components of the specified vectors.
3832
+ * @param left - The first vector
3833
+ * @param right - The second vector
3834
+ * @param out - The vector containing the largest components of the specified vectors
3835
+ */ Vector2.max = function max(left, right, out) {
3836
+ out._x = Math.max(left._x, right._x);
3837
+ out._y = Math.max(left._y, right._y);
3838
+ out._onValueChanged && out._onValueChanged();
3839
+ };
3840
+ /**
3841
+ * Calculate a vector containing the smallest components of the specified vectors.
3842
+ * @param left - The first vector
3843
+ * @param right - The second vector
3844
+ * @param out - The vector containing the smallest components of the specified vectors
3845
+ */ Vector2.min = function min(left, right, out) {
3846
+ out._x = Math.min(left._x, right._x);
3847
+ out._y = Math.min(left._y, right._y);
3848
+ out._onValueChanged && out._onValueChanged();
3849
+ };
3850
+ /**
3851
+ * Reverses the direction of a given vector.
3852
+ * @param left - The vector to negate
3853
+ * @param out - The vector facing in the opposite direction
3854
+ */ Vector2.negate = function negate(left, out) {
3855
+ out._x = -left._x;
3856
+ out._y = -left._y;
3857
+ out._onValueChanged && out._onValueChanged();
3858
+ };
3859
+ /**
3860
+ * Converts the vector into a unit vector.
3861
+ * @param left - The vector to normalize
3862
+ * @param out - The normalized vector
3863
+ */ Vector2.normalize = function normalize(left, out) {
3864
+ var _x = left._x, _y = left._y;
3865
+ var len = Math.sqrt(_x * _x + _y * _y);
3866
+ if (len > MathUtil.zeroTolerance) {
3867
+ len = 1 / len;
3868
+ out._x = _x * len;
3869
+ out._y = _y * len;
3870
+ out._onValueChanged && out._onValueChanged();
3871
+ }
3872
+ };
3873
+ /**
3874
+ * Scale a vector by the given value.
3875
+ * @param left - The vector to scale
3876
+ * @param s - The amount by which to scale the vector
3877
+ * @param out - The scaled vector
3878
+ */ Vector2.scale = function scale(left, s, out) {
3879
+ out._x = left._x * s;
3880
+ out._y = left._y * s;
3881
+ out._onValueChanged && out._onValueChanged();
3882
+ };
3883
+ _create_class(Vector2, [
3884
+ {
3885
+ key: "x",
3886
+ get: /**
3887
+ * The x component of the vector.
3888
+ */ function get() {
3889
+ return this._x;
3890
+ },
3891
+ set: function set(value) {
3892
+ this._x = value;
3893
+ this._onValueChanged && this._onValueChanged();
3894
+ }
3895
+ },
3896
+ {
3897
+ key: "y",
3898
+ get: /**
3899
+ * The y component of the vector.
3900
+ */ function get() {
3901
+ return this._y;
3902
+ },
3903
+ set: function set(value) {
3904
+ this._y = value;
3905
+ this._onValueChanged && this._onValueChanged();
3906
+ }
3907
+ }
3908
+ ]);
3909
+ return Vector2;
3910
+ }();
3911
+ (function() {
3912
+ /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3913
+ })();
3914
+ (function() {
3915
+ /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3916
+ })();
3917
+
3918
+ /**
3919
+ * Describes a 4D-vector.
3920
+ */ var Vector4 = /*#__PURE__*/ function() {
3921
+ function Vector4(x, y, z, w) {
3922
+ if (x === void 0) x = 0;
3923
+ if (y === void 0) y = 0;
3924
+ if (z === void 0) z = 0;
3925
+ if (w === void 0) w = 0;
3926
+ /** @internal */ this._onValueChanged = null;
3927
+ this._x = x;
3928
+ this._y = y;
3929
+ this._z = z;
3930
+ this._w = w;
3931
+ }
3932
+ var _proto = Vector4.prototype;
3933
+ /**
3934
+ * Set the value of this vector.
3935
+ * @param x - The x component of the vector
3936
+ * @param y - The y component of the vector
3937
+ * @param z - The z component of the vector
3938
+ * @param w - The w component of the vector
3939
+ * @returns This vector
3940
+ */ _proto.set = function set(x, y, z, w) {
3941
+ this._x = x;
3942
+ this._y = y;
3943
+ this._z = z;
3944
+ this._w = w;
3945
+ this._onValueChanged && this._onValueChanged();
3946
+ return this;
3947
+ };
3948
+ /**
3949
+ * Determines the sum of this vector and the specified vector.
3950
+ * @param right - The specified vector
3951
+ * @returns This vector
3952
+ */ _proto.add = function add(right) {
3953
+ this._x += right._x;
3954
+ this._y += right._y;
3955
+ this._z += right._z;
3956
+ this._w += right._w;
3957
+ this._onValueChanged && this._onValueChanged();
3958
+ return this;
3959
+ };
3960
+ /**
3961
+ * Determines the difference of this vector and the specified vector.
3962
+ * @param right - the specified vector
3963
+ * @returns This vector
3964
+ */ _proto.subtract = function subtract(right) {
3965
+ this._x -= right._x;
3966
+ this._y -= right._y;
3967
+ this._z -= right._z;
3968
+ this._w -= right._w;
3969
+ this._onValueChanged && this._onValueChanged();
3970
+ return this;
3971
+ };
3972
+ /**
3973
+ * Determines the product of this vector and the specified vector.
3974
+ * @param right - the specified vector
3975
+ * @returns This vector
3976
+ */ _proto.multiply = function multiply(right) {
3977
+ this._x *= right._x;
3978
+ this._y *= right._y;
3979
+ this._z *= right._z;
3980
+ this._w *= right._w;
3981
+ this._onValueChanged && this._onValueChanged();
3982
+ return this;
3983
+ };
3984
+ /**
3985
+ * Determines the divisor of this vector and the specified vector.
3986
+ * @param right - the specified vector
3987
+ * @returns This vector
3988
+ */ _proto.divide = function divide(right) {
3989
+ this._x /= right._x;
3990
+ this._y /= right._y;
3991
+ this._z /= right._z;
3992
+ this._w /= right._w;
3993
+ this._onValueChanged && this._onValueChanged();
3994
+ return this;
3995
+ };
3996
+ /**
3997
+ * Calculate the length of this vector.
3998
+ * @returns The length of this vector
3999
+ */ _proto.length = function length() {
4000
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
4001
+ return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
4002
+ };
4003
+ /**
4004
+ * Calculate the squared length of this vector.
4005
+ * @returns The squared length of this vector
4006
+ */ _proto.lengthSquared = function lengthSquared() {
4007
+ var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
4008
+ return _x * _x + _y * _y + _z * _z + _w * _w;
4009
+ };
4010
+ /**
4011
+ * Reverses the direction of this vector.
4012
+ * @returns This vector
4013
+ */ _proto.negate = function negate() {
4014
+ this._x = -this._x;
4015
+ this._y = -this._y;
4016
+ this._z = -this._z;
4017
+ this._w = -this._w;
4018
+ this._onValueChanged && this._onValueChanged();
4019
+ return this;
4020
+ };
4021
+ /**
4022
+ * Converts this vector into a unit vector.
4023
+ * @returns This vector
4024
+ */ _proto.normalize = function normalize() {
4025
+ Vector4.normalize(this, this);
4026
+ return this;
4027
+ };
4028
+ /**
4029
+ * Scale this vector by the given value.
4030
+ * @param s - The amount by which to scale the vector
4031
+ * @returns This vector
4032
+ */ _proto.scale = function scale(s) {
4033
+ this._x *= s;
4034
+ this._y *= s;
4035
+ this._z *= s;
4036
+ this._w *= s;
4037
+ this._onValueChanged && this._onValueChanged();
4038
+ return this;
4039
+ };
4040
+ /**
4041
+ * Creates a clone of this vector.
4042
+ * @returns A clone of this vector
4043
+ */ _proto.clone = function clone() {
4044
+ var ret = new Vector4(this._x, this._y, this._z, this._w);
4045
+ return ret;
4046
+ };
4047
+ /**
4048
+ * Copy from vector3 like object.
4049
+ * @param source - Vector3 like object.
4050
+ * @returns This vector
4051
+ */ _proto.copyFrom = function copyFrom(source) {
4052
+ this._x = source.x;
4053
+ this._y = source.y;
4054
+ this._z = source.z;
4055
+ this._w = source.w;
4056
+ this._onValueChanged && this._onValueChanged();
4057
+ return this;
4058
+ };
4059
+ /**
4060
+ * Copy the value of this vector by an array.
4061
+ * @param array - The array
4062
+ * @param offset - The start offset of the array
4063
+ * @returns This vector
4064
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
4065
+ if (offset === void 0) offset = 0;
4066
+ this._x = array[offset];
4067
+ this._y = array[offset + 1];
4068
+ this._z = array[offset + 2];
4069
+ this._w = array[offset + 3];
4070
+ this._onValueChanged && this._onValueChanged();
4071
+ return this;
4072
+ };
4073
+ /**
4074
+ * Copy the value of this vector to an array.
4075
+ * @param out - The array
4076
+ * @param outOffset - The start offset of the array
4077
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
4078
+ if (outOffset === void 0) outOffset = 0;
4079
+ out[outOffset] = this._x;
4080
+ out[outOffset + 1] = this._y;
4081
+ out[outOffset + 2] = this._z;
4082
+ out[outOffset + 3] = this._w;
4083
+ };
4084
+ /**
4085
+ * Serialize this vector to a JSON representation.
4086
+ * @returns A JSON representation of this vector
4087
+ */ _proto.toJSON = function toJSON() {
4088
+ return {
4089
+ x: this._x,
4090
+ y: this._y,
4091
+ z: this._z,
4092
+ w: this._w
4093
+ };
4094
+ };
4095
+ /**
4096
+ * Determines the sum of two vectors.
4097
+ * @param left - The first vector to add
4098
+ * @param right - The second vector to add
4099
+ * @param out - The sum of two vectors
4100
+ */ Vector4.add = function add(left, right, out) {
4101
+ out._x = left._x + right._x;
4102
+ out._y = left._y + right._y;
4103
+ out._z = left._z + right._z;
4104
+ out._w = left._w + right._w;
4105
+ out._onValueChanged && out._onValueChanged();
4106
+ };
4107
+ /**
4108
+ * Determines the difference between two vectors.
4109
+ * @param left - The first vector to subtract
4110
+ * @param right - The second vector to subtract
4111
+ * @param out - The difference between two vectors
4112
+ */ Vector4.subtract = function subtract(left, right, out) {
4113
+ out._x = left._x - right._x;
4114
+ out._y = left._y - right._y;
4115
+ out._z = left._z - right._z;
4116
+ out._w = left._w - right._w;
4117
+ out._onValueChanged && out._onValueChanged();
4118
+ };
4119
+ /**
4120
+ * Determines the product of two vectors.
4121
+ * @param left - The first vector to multiply
4122
+ * @param right - The second vector to multiply
4123
+ * @param out - The product of two vectors
4124
+ */ Vector4.multiply = function multiply(left, right, out) {
4125
+ out._x = left._x * right._x;
4126
+ out._y = left._y * right._y;
4127
+ out._z = left._z * right._z;
4128
+ out._w = left._w * right._w;
4129
+ out._onValueChanged && out._onValueChanged();
4130
+ };
4131
+ /**
4132
+ * Determines the divisor of two vectors.
4133
+ * @param left - The first vector to divide
4134
+ * @param right - The second vector to divide
4135
+ * @param out - The divisor of two vectors
4136
+ */ Vector4.divide = function divide(left, right, out) {
4137
+ out._x = left._x / right._x;
4138
+ out._y = left._y / right._y;
4139
+ out._z = left._z / right._z;
4140
+ out._w = left._w / right._w;
4141
+ out._onValueChanged && out._onValueChanged();
4142
+ };
4143
+ /**
4144
+ * Determines the dot product of two vectors.
4145
+ * @param left - The first vector to dot
4146
+ * @param right - The second vector to dot
4147
+ * @returns The dot product of two vectors
4148
+ */ Vector4.dot = function dot(left, right) {
4149
+ return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
4150
+ };
4151
+ /**
4152
+ * Determines the distance of two vectors.
4153
+ * @param a - The first vector
4154
+ * @param b - The second vector
4155
+ * @returns The distance of two vectors
4156
+ */ Vector4.distance = function distance(a, b) {
4157
+ var x = b._x - a._x;
4158
+ var y = b._y - a._y;
4159
+ var z = b._z - a._z;
4160
+ var w = b._w - a._w;
4161
+ return Math.sqrt(x * x + y * y + z * z + w * w);
4162
+ };
4163
+ /**
4164
+ * Determines the squared distance of two vectors.
4165
+ * @param a - The first vector
4166
+ * @param b - The second vector
4167
+ * @returns The squared distance of two vectors
4168
+ */ Vector4.distanceSquared = function distanceSquared(a, b) {
4169
+ var x = b._x - a._x;
4170
+ var y = b._y - a._y;
4171
+ var z = b._z - a._z;
4172
+ var w = b._w - a._w;
4173
+ return x * x + y * y + z * z + w * w;
4174
+ };
4175
+ /**
4176
+ * Determines whether the specified vectors are equals.
4177
+ * @param left - The first vector to compare
4178
+ * @param right - The second vector to compare
4179
+ * @returns True if the specified vectors are equals, false otherwise
4180
+ */ Vector4.equals = function equals(left, right) {
4181
+ return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y) && MathUtil.equals(left._z, right._z) && MathUtil.equals(left._w, right._w);
4182
+ };
4183
+ /**
4184
+ * Performs a linear interpolation between two vectors.
4185
+ * @param start - The first vector
4186
+ * @param end - The second vector
4187
+ * @param t - The blend amount where 0 returns start and 1 end
4188
+ * @param out - The result of linear blending between two vectors
4189
+ */ Vector4.lerp = function lerp(start, end, t, out) {
4190
+ var _x = start._x, _y = start._y, _z = start._z, _w = start._w;
4191
+ out._x = _x + (end._x - _x) * t;
4192
+ out._y = _y + (end._y - _y) * t;
4193
+ out._z = _z + (end._z - _z) * t;
4194
+ out._w = _w + (end._w - _w) * t;
4195
+ out._onValueChanged && out._onValueChanged();
4196
+ };
4197
+ /**
4198
+ * Calculate a vector containing the largest components of the specified vectors.
4199
+ * @param left - The first vector
4200
+ * @param right - The second vector
4201
+ * @param out - The vector containing the largest components of the specified vectors
4202
+ */ Vector4.max = function max(left, right, out) {
4203
+ out._x = Math.max(left._x, right._x);
4204
+ out._y = Math.max(left._y, right._y);
4205
+ out._z = Math.max(left._z, right._z);
4206
+ out._w = Math.max(left._w, right._w);
4207
+ out._onValueChanged && out._onValueChanged();
4208
+ };
4209
+ /**
4210
+ * Calculate a vector containing the smallest components of the specified vectors.
4211
+ * @param left - The first vector
4212
+ * @param right - The second vector
4213
+ * @param out - The vector containing the smallest components of the specified vectors
4214
+ */ Vector4.min = function min(left, right, out) {
4215
+ out._x = Math.min(left._x, right._x);
4216
+ out._y = Math.min(left._y, right._y);
4217
+ out._z = Math.min(left._z, right._z);
4218
+ out._w = Math.min(left._w, right._w);
4219
+ out._onValueChanged && out._onValueChanged();
4220
+ };
4221
+ /**
4222
+ * Reverses the direction of a given vector.
4223
+ * @param a - The vector to negate
4224
+ * @param out - The vector facing in the opposite direction
4225
+ */ Vector4.negate = function negate(a, out) {
4226
+ out._x = -a._x;
4227
+ out._y = -a._y;
4228
+ out._z = -a._z;
4229
+ out._w = -a._w;
4230
+ out._onValueChanged && out._onValueChanged();
4231
+ };
4232
+ /**
4233
+ * Converts the vector into a unit vector.
4234
+ * @param a - The vector to normalize
4235
+ * @param out - The normalized vector
4236
+ */ Vector4.normalize = function normalize(a, out) {
4237
+ var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
4238
+ var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
4239
+ if (len > MathUtil.zeroTolerance) {
4240
+ len = 1 / len;
4241
+ out._x = _x * len;
4242
+ out._y = _y * len;
4243
+ out._z = _z * len;
4244
+ out._w = _w * len;
4245
+ out._onValueChanged && out._onValueChanged();
4246
+ }
4247
+ };
4248
+ /**
4249
+ * Scale a vector by the given value.
4250
+ * @param a - The vector to scale
4251
+ * @param s - The amount by which to scale the vector
4252
+ * @param out - The scaled vector
4253
+ */ Vector4.scale = function scale(a, s, out) {
4254
+ out._x = a._x * s;
4255
+ out._y = a._y * s;
4256
+ out._z = a._z * s;
4257
+ out._w = a._w * s;
4258
+ out._onValueChanged && out._onValueChanged();
4259
+ };
4260
+ /**
4261
+ * Performs a transformation using the given 4x4 matrix.
4262
+ * @param v - The vector to transform
4263
+ * @param m - The transform matrix
4264
+ * @param out - The transformed vector3
4265
+ */ Vector4.transform = function transform(v, m, out) {
4266
+ var _x = v._x, _y = v._y, _z = v._z, _w = v._w;
4267
+ var e = m.elements;
4268
+ out._x = _x * e[0] + _y * e[4] + _z * e[8] + _w * e[12];
4269
+ out._y = _x * e[1] + _y * e[5] + _z * e[9] + _w * e[13];
4270
+ out._z = _x * e[2] + _y * e[6] + _z * e[10] + _w * e[14];
4271
+ out._w = _x * e[3] + _y * e[7] + _z * e[11] + _w * e[15];
4272
+ out._onValueChanged && out._onValueChanged();
4273
+ };
4274
+ /**
4275
+ * Performs a transformation using the given quaternion.
4276
+ * @param v - The vector to transform
4277
+ * @param q - The transform quaternion
4278
+ * @param out - The transformed vector
4279
+ */ Vector4.transformByQuat = function transformByQuat(v, q, out) {
4280
+ var x = v._x, y = v._y, z = v._z, w = v._w;
4281
+ var qx = q._x;
4282
+ var qy = q._y;
4283
+ var qz = q._z;
4284
+ var qw = q._w;
4285
+ // calculate quat * vec
4286
+ var ix = qw * x + qy * z - qz * y;
4287
+ var iy = qw * y + qz * x - qx * z;
4288
+ var iz = qw * z + qx * y - qy * x;
4289
+ var iw = -qx * x - qy * y - qz * z;
4290
+ // calculate result * inverse quat
4291
+ out._x = ix * qw - iw * qx - iy * qz + iz * qy;
4292
+ out._y = iy * qw - iw * qy - iz * qx + ix * qz;
4293
+ out._z = iz * qw - iw * qz - ix * qy + iy * qx;
4294
+ out._w = w;
4295
+ out._onValueChanged && out._onValueChanged();
4296
+ };
4297
+ _create_class(Vector4, [
4298
+ {
4299
+ key: "x",
4300
+ get: /**
4301
+ * The x component of the vector.
4302
+ */ function get() {
4303
+ return this._x;
4304
+ },
4305
+ set: function set(value) {
4306
+ this._x = value;
4307
+ this._onValueChanged && this._onValueChanged();
4308
+ }
4309
+ },
4310
+ {
4311
+ key: "y",
4312
+ get: /**
4313
+ * The y component of the vector.
4314
+ */ function get() {
4315
+ return this._y;
4316
+ },
4317
+ set: function set(value) {
4318
+ this._y = value;
4319
+ this._onValueChanged && this._onValueChanged();
4320
+ }
4321
+ },
4322
+ {
4323
+ key: "z",
4324
+ get: /**
4325
+ * The z component of the vector.
4326
+ */ function get() {
4327
+ return this._z;
4328
+ },
4329
+ set: function set(value) {
4330
+ this._z = value;
4331
+ this._onValueChanged && this._onValueChanged();
4332
+ }
4333
+ },
4334
+ {
4335
+ key: "w",
4336
+ get: /**
4337
+ * The w component of the vector.
4338
+ */ function get() {
4339
+ return this._w;
4340
+ },
4341
+ set: function set(value) {
4342
+ this._w = value;
4343
+ this._onValueChanged && this._onValueChanged();
4344
+ }
4345
+ }
4346
+ ]);
4347
+ return Vector4;
4348
+ }();
4349
+ (function() {
4350
+ /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4351
+ })();
4352
+ (function() {
4353
+ /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4354
+ })();
4355
+
4356
+ /**
4357
+ * Describes a color in the from of RGBA (in order: R, G, B, A).
4358
+ */ var Color = /*#__PURE__*/ function() {
4359
+ function Color(r, g, b, a) {
4360
+ if (r === void 0) r = 1;
4361
+ if (g === void 0) g = 1;
4362
+ if (b === void 0) b = 1;
4363
+ if (a === void 0) a = 1;
4364
+ /** @internal */ this._onValueChanged = null;
4365
+ this._r = r;
4366
+ this._g = g;
4367
+ this._b = b;
4368
+ this._a = a;
4369
+ }
4370
+ var _proto = Color.prototype;
4371
+ /**
4372
+ * Set the value of this color.
4373
+ * @param r - The red component of the color
4374
+ * @param g - The green component of the color
4375
+ * @param b - The blue component of the color
4376
+ * @param a - The alpha component of the color
4377
+ * @returns This color.
4378
+ */ _proto.set = function set(r, g, b, a) {
4379
+ this._r = r;
4380
+ this._g = g;
4381
+ this._b = b;
4382
+ this._a = a;
4383
+ this._onValueChanged && this._onValueChanged();
4384
+ return this;
4385
+ };
4386
+ /**
4387
+ * Determines the sum of this color and the specified color.
4388
+ * @param color - The specified color
4389
+ * @returns The added color
4390
+ */ _proto.add = function add(color) {
4391
+ this._r += color._r;
4392
+ this._g += color._g;
4393
+ this._b += color._b;
4394
+ this._a += color._a;
4395
+ this._onValueChanged && this._onValueChanged();
4396
+ return this;
4397
+ };
4398
+ /**
4399
+ * Scale this color by the given value.
4400
+ * @param s - The amount by which to scale the color
4401
+ * @returns The scaled color
4402
+ */ _proto.scale = function scale(s) {
4403
+ this._r *= s;
4404
+ this._g *= s;
4405
+ this._b *= s;
4406
+ this._a *= s;
4407
+ this._onValueChanged && this._onValueChanged();
4408
+ return this;
4409
+ };
4410
+ /**
4411
+ * Creates a clone of this color.
4412
+ * @returns A clone of this color
4413
+ */ _proto.clone = function clone() {
4414
+ var ret = new Color(this._r, this._g, this._b, this._a);
4415
+ return ret;
4416
+ };
4417
+ /**
4418
+ * Copy from color like object.
4419
+ * @param source - Color like object.
4420
+ * @returns This vector
4421
+ */ _proto.copyFrom = function copyFrom(source) {
4422
+ this._r = source.r;
4423
+ this._g = source.g;
4424
+ this._b = source.b;
4425
+ this._a = source.a;
4426
+ this._onValueChanged && this._onValueChanged();
4427
+ return this;
4428
+ };
4429
+ /**
4430
+ * Modify components (r, g, b) of this color from gamma space to linear space.
4431
+ * @param out - The color in linear space
4432
+ * @returns The color in linear space
4433
+ */ _proto.toLinear = function toLinear(out) {
4434
+ out._r = Color.gammaToLinearSpace(this._r);
4435
+ out._g = Color.gammaToLinearSpace(this._g);
4436
+ out._b = Color.gammaToLinearSpace(this._b);
4437
+ this._onValueChanged && this._onValueChanged();
4438
+ return out;
4439
+ };
4440
+ /**
4441
+ * Modify components (r, g, b) of this color from linear space to gamma space.
4442
+ * @param out - The color in gamma space
4443
+ * @returns The color in gamma space
4444
+ */ _proto.toGamma = function toGamma(out) {
4445
+ out._r = Color.linearToGammaSpace(this._r);
4446
+ out._g = Color.linearToGammaSpace(this._g);
4447
+ out._b = Color.linearToGammaSpace(this._b);
4448
+ this._onValueChanged && this._onValueChanged();
4449
+ return out;
4450
+ };
4451
+ /**
4452
+ * Gets the brightness.
4453
+ * @returns The Hue-Saturation-Brightness (HSB) saturation for this
4454
+ */ _proto.getBrightness = function getBrightness() {
4455
+ var r = this.r;
4456
+ var g = this.g;
4457
+ var b = this.b;
4458
+ var max = r;
4459
+ var min = r;
4460
+ if (g > max) max = g;
4461
+ if (b > max) max = b;
4462
+ if (g < min) min = g;
4463
+ if (b < min) min = b;
4464
+ return (max + min) / 2;
4465
+ };
4466
+ /**
4467
+ * Serialize this color to a JSON representation.
4468
+ * @return A JSON representation of this color
4469
+ */ _proto.toJSON = function toJSON() {
4470
+ return {
4471
+ r: this._r,
4472
+ g: this._g,
4473
+ b: this._b,
4474
+ a: this._a
4475
+ };
4476
+ };
4477
+ /**
4478
+ * Modify a value from the gamma space to the linear space.
4479
+ * @param value - The value in gamma space
4480
+ * @returns The value in linear space
4481
+ */ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
4482
+ // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
4483
+ // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
4484
+ if (value <= 0.0) return 0.0;
4485
+ else if (value <= 0.04045) return value / 12.92;
4486
+ else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
4487
+ else return Math.pow(value, 2.4);
4488
+ };
4489
+ /**
4490
+ * Modify a value from the linear space to the gamma space.
4491
+ * @param value - The value in linear space
4492
+ * @returns The value in gamma space
4493
+ */ Color.linearToGammaSpace = function linearToGammaSpace(value) {
4494
+ // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
4495
+ // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
4496
+ if (value <= 0.0) return 0.0;
4497
+ else if (value < 0.0031308) return 12.92 * value;
4498
+ else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
4499
+ else return Math.pow(value, 0.41666);
4500
+ };
4501
+ /**
4502
+ * Determines whether the specified colors are equals.
4503
+ * @param left - The first color to compare
4504
+ * @param right - The second color to compare
4505
+ * @returns True if the specified colors are equals, false otherwise
4506
+ */ Color.equals = function equals(left, right) {
4507
+ return MathUtil.equals(left._r, right._r) && MathUtil.equals(left._g, right._g) && MathUtil.equals(left._b, right._b) && MathUtil.equals(left._a, right._a);
4508
+ };
4509
+ /**
4510
+ * Determines the sum of two colors.
4511
+ * @param left - The first color to add
4512
+ * @param right - The second color to add
4513
+ * @param out - The sum of two colors
4514
+ * @returns The added color
4515
+ */ Color.add = function add(left, right, out) {
4516
+ out._r = left._r + right._r;
4517
+ out._g = left._g + right._g;
4518
+ out._b = left._b + right._b;
4519
+ out._a = left._a + right._a;
4520
+ out._onValueChanged && out._onValueChanged();
4521
+ return out;
4522
+ };
4523
+ /**
4524
+ * Determines the difference between two colors.
4525
+ * @param left - The first color to subtract
4526
+ * @param right - The second color to subtract
4527
+ * @param out - The difference between two colors
4528
+ */ Color.subtract = function subtract(left, right, out) {
4529
+ out._r = left._r - right._r;
4530
+ out._g = left._g - right._g;
4531
+ out._b = left._b - right._b;
4532
+ out._a = left._a - right._a;
4533
+ out._onValueChanged && out._onValueChanged();
4534
+ };
4535
+ /**
4536
+ * Scale a color by the given value.
4537
+ * @param left - The color to scale
4538
+ * @param s - The amount by which to scale the color
4539
+ * @param out - The scaled color
4540
+ * @returns The scaled color
4541
+ */ Color.scale = function scale(left, s, out) {
4542
+ out._r = left._r * s;
4543
+ out._g = left._g * s;
4544
+ out._b = left._b * s;
4545
+ out._a = left._a * s;
4546
+ out._onValueChanged && out._onValueChanged();
4547
+ return out;
4548
+ };
4549
+ /**
4550
+ * Performs a linear interpolation between two color.
4551
+ * @param start - The first color
4552
+ * @param end - The second color
4553
+ * @param t - The blend amount where 0 returns start and 1 end
4554
+ * @param out - The result of linear blending between two color
4555
+ */ Color.lerp = function lerp(start, end, t, out) {
4556
+ var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
4557
+ out._r = _r + (end._r - _r) * t;
4558
+ out._g = _g + (end._g - _g) * t;
4559
+ out._b = _b + (end._b - _b) * t;
4560
+ out._a = _a + (end._a - _a) * t;
4561
+ out._onValueChanged && out._onValueChanged();
4562
+ return out;
4563
+ };
4564
+ _create_class(Color, [
4565
+ {
4566
+ key: "r",
4567
+ get: /**
4568
+ * The red component of the color, 0~1.
4569
+ */ function get() {
4570
+ return this._r;
4571
+ },
4572
+ set: function set(value) {
4573
+ this._r = value;
4574
+ this._onValueChanged && this._onValueChanged();
4575
+ }
4576
+ },
4577
+ {
4578
+ key: "g",
4579
+ get: /**
4580
+ * The green component of the color, 0~1.
4581
+ */ function get() {
4582
+ return this._g;
4583
+ },
4584
+ set: function set(value) {
4585
+ this._g = value;
4586
+ this._onValueChanged && this._onValueChanged();
4587
+ }
4588
+ },
4589
+ {
4590
+ key: "b",
4591
+ get: /**
4592
+ * The blue component of the color, 0~1.
4593
+ */ function get() {
4594
+ return this._b;
4595
+ },
4596
+ set: function set(value) {
4597
+ this._b = value;
4598
+ this._onValueChanged && this._onValueChanged();
4599
+ }
4600
+ },
4601
+ {
4602
+ key: "a",
4603
+ get: /**
4604
+ * The alpha component of the color, 0~1.
4605
+ */ function get() {
4606
+ return this._a;
4607
+ },
4608
+ set: function set(value) {
4609
+ this._a = value;
4610
+ this._onValueChanged && this._onValueChanged();
4611
+ }
4612
+ }
4613
+ ]);
4614
+ return Color;
4615
+ }();
4616
+
4617
+ // A 2d rectangle defined by x and y position, width and height.
4618
+ var Rect = /*#__PURE__*/ function() {
4619
+ function Rect(x, y, width, height) {
4620
+ if (x === void 0) x = 0;
4621
+ if (y === void 0) y = 0;
4622
+ if (width === void 0) width = 0;
4623
+ if (height === void 0) height = 0;
4624
+ this.x = x;
4625
+ this.y = y;
4626
+ this.width = width;
4627
+ this.height = height;
4628
+ }
4629
+ var _proto = Rect.prototype;
4630
+ /**
4631
+ * Set the value of this rectangle.
4632
+ * @param x - The x coordinate of the rectangle
4633
+ * @param y - The y coordinate of the rectangle
4634
+ * @param width - The width of the rectangle, measured from the x position
4635
+ * @param height - The height of the rectangle, measured from the y position
4636
+ * @returns This rectangle
4637
+ */ _proto.set = function set(x, y, width, height) {
4638
+ this.x = x;
4639
+ this.y = y;
4640
+ this.width = width;
4641
+ this.height = height;
4642
+ return this;
4643
+ };
4644
+ /**
4645
+ * Creates a clone of this rect.
4646
+ * @returns A clone of this rect
4647
+ */ _proto.clone = function clone() {
4648
+ return new Rect(this.x, this.y, this.width, this.height);
4649
+ };
4650
+ /**
4651
+ * Copy this rect from the specified rect.
4652
+ * @param source - The specified rect
4653
+ * @returns This rect
4654
+ */ _proto.copyFrom = function copyFrom(source) {
4655
+ this.x = source.x;
4656
+ this.y = source.y;
4657
+ this.width = source.width;
4658
+ this.height = source.height;
4659
+ return this;
4660
+ };
4661
+ return Rect;
4662
+ }();
4663
+
4664
+ /**
4665
+ * Use SH3 to represent irradiance environment maps efficiently, allowing for interactive rendering of diffuse objects under distant illumination.
4666
+ * @remarks
4667
+ * https://graphics.stanford.edu/papers/envmap/envmap.pdf
4668
+ * http://www.ppsloan.org/publications/StupidSH36.pdf
4669
+ * https://google.github.io/filament/Filament.md.html#annex/sphericalharmonics
4670
+ */ var SphericalHarmonics3 = /*#__PURE__*/ function() {
4671
+ function SphericalHarmonics3() {
4672
+ /** The coefficients of SphericalHarmonics3. */ this.coefficients = new Float32Array(27);
4673
+ }
4674
+ var _proto = SphericalHarmonics3.prototype;
4675
+ /**
4676
+ * Add light to SphericalHarmonics3.
4677
+ * @param direction - Light direction
4678
+ * @param color - Light color
4679
+ * @param deltaSolidAngle - The delta solid angle of the light
4680
+ */ _proto.addLight = function addLight(direction, color, deltaSolidAngle) {
4681
+ /**
4682
+ * Implements `EvalSHBasis` from [Projection from Cube maps] in http://www.ppsloan.org/publications/StupidSH36.pdf.
4683
+ *
4684
+ * Basis constants
4685
+ * 0: Math.sqrt(1/(4 * Math.PI))
4686
+ *
4687
+ * 1: -Math.sqrt(3 / (4 * Math.PI))
4688
+ * 2: Math.sqrt(3 / (4 * Math.PI))
4689
+ * 3: -Math.sqrt(3 / (4 * Math.PI))
4690
+ *
4691
+ * 4: Math.sqrt(15 / (4 * Math.PI))
4692
+ * 5: -Math.sqrt(15 / (4 * Math.PI))
4693
+ * 6: Math.sqrt(5 / (16 * Math.PI))
4694
+ * 7: -Math.sqrt(15 / (4 * Math.PI))
4695
+ * 8: Math.sqrt(15 / (16 * Math.PI))
4696
+ */ color.scale(deltaSolidAngle);
4697
+ var coe = this.coefficients;
4698
+ var x = direction._x, y = direction._y, z = direction._z;
4699
+ var r = color.r, g = color.g, b = color.b;
4700
+ var bv0 = 0.282095; // basis0 = 0.886227
4701
+ var bv1 = -0.488603 * y; // basis1 = -0.488603
4702
+ var bv2 = 0.488603 * z; // basis2 = 0.488603
4703
+ var bv3 = -0.488603 * x; // basis3 = -0.488603
4704
+ var bv4 = 1.092548 * (x * y); // basis4 = 1.092548
4705
+ var bv5 = -1.092548 * (y * z); // basis5 = -1.092548
4706
+ var bv6 = 0.315392 * (3 * z * z - 1); // basis6 = 0.315392
4707
+ var bv7 = -1.092548 * (x * z); // basis7 = -1.092548
4708
+ var bv8 = 0.546274 * (x * x - y * y); // basis8 = 0.546274
4709
+ coe[0] += r * bv0, coe[1] += g * bv0, coe[2] += b * bv0;
4710
+ coe[3] += r * bv1, coe[4] += g * bv1, coe[5] += b * bv1;
4711
+ coe[6] += r * bv2, coe[7] += g * bv2, coe[8] += b * bv2;
4712
+ coe[9] += r * bv3, coe[10] += g * bv3, coe[11] += b * bv3;
4713
+ coe[12] += r * bv4, coe[13] += g * bv4, coe[14] += b * bv4;
4714
+ coe[15] += r * bv5, coe[16] += g * bv5, coe[17] += b * bv5;
4715
+ coe[18] += r * bv6, coe[19] += g * bv6, coe[20] += b * bv6;
4716
+ coe[21] += r * bv7, coe[22] += g * bv7, coe[23] += b * bv7;
4717
+ coe[24] += r * bv8, coe[25] += g * bv8, coe[26] += b * bv8;
4718
+ };
4719
+ /**
4720
+ * Evaluates the color for the specified direction.
4721
+ * @param direction - Specified direction
4722
+ * @param out - Out color
4723
+ */ _proto.evaluate = function evaluate(direction, out) {
4724
+ /**
4725
+ * Equations based on data from: http://ppsloan.org/publications/StupidSH36.pdf
4726
+ *
4727
+ *
4728
+ * Basis constants
4729
+ * 0: Math.sqrt(1/(4 * Math.PI))
4730
+ *
4731
+ * 1: -Math.sqrt(3 / (4 * Math.PI))
4732
+ * 2: Math.sqrt(3 / (4 * Math.PI))
4733
+ * 3: -Math.sqrt(3 / (4 * Math.PI))
4734
+ *
4735
+ * 4: Math.sqrt(15 / (4 * Math.PI))
4736
+ * 5: -Math.sqrt(15 / (4 * Math.PI))
4737
+ * 6: Math.sqrt(5 / (16 * Math.PI))
4738
+ * 7: -Math.sqrt(15 / (4 * Math.PI))
4739
+ * 8: Math.sqrt(15 / (16 * Math.PI))
4740
+ *
4741
+ *
4742
+ * Convolution kernel
4743
+ * 0: Math.PI
4744
+ * 1: (2 * Math.PI) / 3
4745
+ * 2: Math.PI / 4
4746
+ */ var coe = this.coefficients;
4747
+ var x = direction._x, y = direction._y, z = direction._z;
4748
+ var bv0 = 0.886227; // kernel0 * basis0 = 0.886227
4749
+ var bv1 = -1.023327 * y; // kernel1 * basis1 = -1.023327
4750
+ var bv2 = 1.023327 * z; // kernel1 * basis2 = 1.023327
4751
+ var bv3 = -1.023327 * x; // kernel1 * basis3 = -1.023327
4752
+ var bv4 = 0.858086 * y * x; // kernel2 * basis4 = 0.858086
4753
+ var bv5 = -0.858086 * y * z; // kernel2 * basis5 = -0.858086
4754
+ var bv6 = 0.247708 * (3 * z * z - 1); // kernel2 * basis6 = 0.247708
4755
+ var bv7 = -0.858086 * z * x; // kernel2 * basis7 = -0.858086
4756
+ var bv8 = 0.429042 * (x * x - y * y); // kernel2 * basis8 = 0.429042
4757
+ // l0
4758
+ var r = coe[0] * bv0;
4759
+ var g = coe[1] * bv0;
4760
+ var b = coe[2] * bv0;
4761
+ // l1
4762
+ r += coe[3] * bv1 + coe[6] * bv2 + coe[9] * bv3;
4763
+ g += coe[4] * bv1 + coe[7] * bv2 + coe[10] * bv3;
4764
+ b += coe[5] * bv1 + coe[8] * bv2 + coe[11] * bv3;
4765
+ // l2
4766
+ r += coe[12] * bv4 + coe[15] * bv5 + coe[18] * bv6 + coe[21] * bv7 + coe[24] * bv8;
4767
+ g += coe[13] * bv4 + coe[16] * bv5 + coe[19] * bv6 + coe[22] * bv7 + coe[25] * bv8;
4768
+ b += coe[14] * bv4 + coe[17] * bv5 + coe[20] * bv6 + coe[23] * bv7 + coe[26] * bv8;
4769
+ out.set(r, g, b, 1.0);
4770
+ return out;
4771
+ };
4772
+ /**
4773
+ * Scale the coefficients.
4774
+ * @param s - The amount by which to scale the SphericalHarmonics3
4775
+ */ _proto.scale = function scale(s) {
4776
+ var src = this.coefficients;
4777
+ src[0] *= s, src[1] *= s, src[2] *= s;
4778
+ src[3] *= s, src[4] *= s, src[5] *= s;
4779
+ src[6] *= s, src[7] *= s, src[8] *= s;
4780
+ src[9] *= s, src[10] *= s, src[11] *= s;
4781
+ src[12] *= s, src[13] *= s, src[14] *= s;
4782
+ src[15] *= s, src[16] *= s, src[17] *= s;
4783
+ src[18] *= s, src[19] *= s, src[20] *= s;
4784
+ src[21] *= s, src[22] *= s, src[23] *= s;
4785
+ src[24] *= s, src[25] *= s, src[26] *= s;
4786
+ };
4787
+ /**
4788
+ * Creates a clone of this SphericalHarmonics3.
4789
+ * @returns A clone of this SphericalHarmonics3
4790
+ */ _proto.clone = function clone() {
4791
+ var sh = new SphericalHarmonics3();
4792
+ sh.copyFrom(this);
4793
+ return sh;
4794
+ };
4795
+ /**
4796
+ * Copy this SphericalHarmonics3 from the specified SphericalHarmonics3.
4797
+ * @param source - The specified SphericalHarmonics3
4798
+ * @returns This SphericalHarmonics3
4799
+ */ _proto.copyFrom = function copyFrom(source) {
4800
+ source.copyToArray(this.coefficients);
4801
+ return this;
4802
+ };
4803
+ /**
4804
+ * Copy the value of this spherical harmonics from an array.
4805
+ * @param array - The array
4806
+ * @param offset - The start offset of the array
4807
+ */ _proto.copyFromArray = function copyFromArray(array, offset) {
4808
+ if (offset === void 0) offset = 0;
4809
+ var s = this.coefficients;
4810
+ s[0] = array[offset], s[1] = array[1 + offset], s[2] = array[2 + offset];
4811
+ s[3] = array[3 + offset], s[4] = array[4 + offset], s[5] = array[5 + offset];
4812
+ s[6] = array[6 + offset], s[7] = array[7 + offset], s[8] = array[8 + offset];
4813
+ s[9] = array[9 + offset], s[10] = array[10 + offset], s[11] = array[11 + offset];
4814
+ s[12] = array[12 + offset], s[13] = array[13 + offset], s[14] = array[14 + offset];
4815
+ s[15] = array[15 + offset], s[16] = array[16 + offset], s[17] = array[17 + offset];
4816
+ s[18] = array[18 + offset], s[19] = array[19 + offset], s[20] = array[20 + offset];
4817
+ s[21] = array[21 + offset], s[22] = array[22 + offset], s[23] = array[23 + offset];
4818
+ s[24] = array[24 + offset], s[25] = array[25 + offset], s[26] = array[26 + offset];
4819
+ };
4820
+ /**
4821
+ * Copy the value of this spherical harmonics to an array.
4822
+ * @param out - The array
4823
+ * @param outOffset - The start offset of the array
4824
+ */ _proto.copyToArray = function copyToArray(out, outOffset) {
4825
+ if (outOffset === void 0) outOffset = 0;
4826
+ var s = this.coefficients;
4827
+ out[0 + outOffset] = s[0], out[1 + outOffset] = s[1], out[2 + outOffset] = s[2];
4828
+ out[3 + outOffset] = s[3], out[4 + outOffset] = s[4], out[5 + outOffset] = s[5];
4829
+ out[6 + outOffset] = s[6], out[7 + outOffset] = s[7], out[8 + outOffset] = s[8];
4830
+ out[9 + outOffset] = s[9], out[10 + outOffset] = s[10], out[11 + outOffset] = s[11];
4831
+ out[12 + outOffset] = s[12], out[13 + outOffset] = s[13], out[14 + outOffset] = s[14];
4832
+ out[15 + outOffset] = s[15], out[16 + outOffset] = s[16], out[17 + outOffset] = s[17];
4833
+ out[18 + outOffset] = s[18], out[19 + outOffset] = s[19], out[20 + outOffset] = s[20];
4834
+ out[21 + outOffset] = s[21], out[22 + outOffset] = s[22], out[23 + outOffset] = s[23];
4835
+ out[24 + outOffset] = s[24], out[25 + outOffset] = s[25], out[26 + outOffset] = s[26];
4836
+ };
4837
+ return SphericalHarmonics3;
4838
+ }();
4839
+
4840
+ export { BoundingBox, BoundingFrustum, BoundingSphere, CollisionUtil, Color, ContainmentType, FrustumFace, MathUtil, Matrix, Matrix3x3, Plane, PlaneIntersectionType, Quaternion, Ray, Rect, SphericalHarmonics3, Vector2, Vector3, Vector4 };
4841
+ //# sourceMappingURL=module.js.map