@galacean/engine-xr-webxr 0.0.0-experimental-1.3-xr.10 → 0.0.0-experimental-1.4-small-language.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +346 -1801
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +222 -1655
- package/dist/main.js.map +1 -1
- package/dist/module.js +222 -1655
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/Util.d.ts +0 -1
- package/types/WebXRSession.d.ts +0 -1
- package/types/feature/WebXRAnchorTracking.d.ts +0 -1
- package/types/feature/WebXRPlaneTracking.d.ts +0 -1
- package/dist/miniprogram.js +0 -5925
package/dist/main.js
CHANGED
|
@@ -70,17 +70,18 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
function _is_native_reflect_construct() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
// Since Reflect.construct can't be properly polyfilled, some
|
|
74
|
+
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
|
75
|
+
// Those polyfills don't allow us to subclass built-ins, so we need to
|
|
76
|
+
// use our fallback implementation.
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
// If the internal slots aren't set, this throws an error similar to
|
|
79
|
+
// TypeError: this is not a Boolean object.
|
|
80
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
81
|
+
} catch (_) {}
|
|
82
|
+
return (_is_native_reflect_construct = function() {
|
|
83
|
+
return !!result;
|
|
84
|
+
})();
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function _construct(Parent, args, Class) {
|
|
@@ -149,33 +150,6 @@ function viewToCamera(type) {
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
/**
|
|
153
|
-
* Defines how the bounding volumes intersects or contain one another.
|
|
154
|
-
*/ var ContainmentType;
|
|
155
|
-
(function(ContainmentType) {
|
|
156
|
-
ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
|
|
157
|
-
ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
|
|
158
|
-
ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
|
|
159
|
-
})(ContainmentType || (ContainmentType = {}));
|
|
160
|
-
/**
|
|
161
|
-
* Defines the intersection between a plane and a bounding volume.
|
|
162
|
-
*/ var PlaneIntersectionType;
|
|
163
|
-
(function(PlaneIntersectionType) {
|
|
164
|
-
PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
|
|
165
|
-
PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
|
|
166
|
-
PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
|
|
167
|
-
})(PlaneIntersectionType || (PlaneIntersectionType = {}));
|
|
168
|
-
/**
|
|
169
|
-
* Frustum face
|
|
170
|
-
*/ var FrustumFace;
|
|
171
|
-
(function(FrustumFace) {
|
|
172
|
-
FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
|
|
173
|
-
FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
|
|
174
|
-
FrustumFace[FrustumFace[/** Left face */ "Left"] = 2] = "Left";
|
|
175
|
-
FrustumFace[FrustumFace[/** Right face */ "Right"] = 3] = "Right";
|
|
176
|
-
FrustumFace[FrustumFace[/** Bottom face */ "Bottom"] = 4] = "Bottom";
|
|
177
|
-
FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
|
|
178
|
-
})(FrustumFace || (FrustumFace = {}));
|
|
179
153
|
function _defineProperties(target, props) {
|
|
180
154
|
for(var i = 0; i < props.length; i++){
|
|
181
155
|
var descriptor = props[i];
|
|
@@ -193,7 +167,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
193
167
|
/**
|
|
194
168
|
* Common utility methods for math operations.
|
|
195
169
|
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
196
|
-
|
|
170
|
+
function MathUtil() {}
|
|
197
171
|
/**
|
|
198
172
|
* Clamps the specified value.
|
|
199
173
|
* @param v - The specified value
|
|
@@ -244,19 +218,13 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
244
218
|
};
|
|
245
219
|
return MathUtil;
|
|
246
220
|
}();
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(function() {
|
|
251
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
252
|
-
})();
|
|
253
|
-
(function() {
|
|
254
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
255
|
-
})();
|
|
221
|
+
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
222
|
+
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
223
|
+
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
256
224
|
/**
|
|
257
225
|
* Describes a 3D-vector.
|
|
258
226
|
*/ var Vector3 = /*#__PURE__*/ function() {
|
|
259
|
-
|
|
227
|
+
function Vector3(x, y, z) {
|
|
260
228
|
if (x === void 0) x = 0;
|
|
261
229
|
if (y === void 0) y = 0;
|
|
262
230
|
if (z === void 0) z = 0;
|
|
@@ -264,7 +232,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
264
232
|
this._x = x;
|
|
265
233
|
this._y = y;
|
|
266
234
|
this._z = z;
|
|
267
|
-
}
|
|
235
|
+
}
|
|
268
236
|
var _proto = Vector3.prototype;
|
|
269
237
|
/**
|
|
270
238
|
* Set the value of this vector.
|
|
@@ -276,7 +244,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
276
244
|
this._x = x;
|
|
277
245
|
this._y = y;
|
|
278
246
|
this._z = z;
|
|
279
|
-
this._onValueChanged
|
|
247
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
280
248
|
return this;
|
|
281
249
|
};
|
|
282
250
|
/**
|
|
@@ -287,7 +255,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
287
255
|
this._x += right._x;
|
|
288
256
|
this._y += right._y;
|
|
289
257
|
this._z += right._z;
|
|
290
|
-
this._onValueChanged
|
|
258
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
291
259
|
return this;
|
|
292
260
|
};
|
|
293
261
|
/**
|
|
@@ -298,7 +266,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
298
266
|
this._x -= right._x;
|
|
299
267
|
this._y -= right._y;
|
|
300
268
|
this._z -= right._z;
|
|
301
|
-
this._onValueChanged
|
|
269
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
302
270
|
return this;
|
|
303
271
|
};
|
|
304
272
|
/**
|
|
@@ -309,7 +277,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
309
277
|
this._x *= right._x;
|
|
310
278
|
this._y *= right._y;
|
|
311
279
|
this._z *= right._z;
|
|
312
|
-
this._onValueChanged
|
|
280
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
313
281
|
return this;
|
|
314
282
|
};
|
|
315
283
|
/**
|
|
@@ -320,7 +288,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
320
288
|
this._x /= right._x;
|
|
321
289
|
this._y /= right._y;
|
|
322
290
|
this._z /= right._z;
|
|
323
|
-
this._onValueChanged
|
|
291
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
324
292
|
return this;
|
|
325
293
|
};
|
|
326
294
|
/**
|
|
@@ -344,7 +312,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
344
312
|
this._x = -this._x;
|
|
345
313
|
this._y = -this._y;
|
|
346
314
|
this._z = -this._z;
|
|
347
|
-
this._onValueChanged
|
|
315
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
348
316
|
return this;
|
|
349
317
|
};
|
|
350
318
|
/**
|
|
@@ -362,7 +330,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
362
330
|
this._x *= s;
|
|
363
331
|
this._y *= s;
|
|
364
332
|
this._z *= s;
|
|
365
|
-
this._onValueChanged
|
|
333
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
366
334
|
return this;
|
|
367
335
|
};
|
|
368
336
|
/**
|
|
@@ -423,10 +391,20 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
423
391
|
this._x = source.x;
|
|
424
392
|
this._y = source.y;
|
|
425
393
|
this._z = source.z;
|
|
426
|
-
this._onValueChanged
|
|
394
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
427
395
|
return this;
|
|
428
396
|
};
|
|
429
397
|
/**
|
|
398
|
+
* Copy to vector3 like object.
|
|
399
|
+
* @param target - Vector3 like object
|
|
400
|
+
* @returns This Vector3 like object
|
|
401
|
+
*/ _proto.copyTo = function copyTo(target) {
|
|
402
|
+
target.x = this._x;
|
|
403
|
+
target.y = this._y;
|
|
404
|
+
target.z = this._z;
|
|
405
|
+
return target;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
430
408
|
* Copy the value of this vector from an array.
|
|
431
409
|
* @param array - The array
|
|
432
410
|
* @param offset - The start offset of the array
|
|
@@ -436,7 +414,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
436
414
|
this._x = array[offset];
|
|
437
415
|
this._y = array[offset + 1];
|
|
438
416
|
this._z = array[offset + 2];
|
|
439
|
-
this._onValueChanged
|
|
417
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
440
418
|
return this;
|
|
441
419
|
};
|
|
442
420
|
/**
|
|
@@ -468,7 +446,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
468
446
|
out._x = left._x + right._x;
|
|
469
447
|
out._y = left._y + right._y;
|
|
470
448
|
out._z = left._z + right._z;
|
|
471
|
-
out._onValueChanged
|
|
449
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
472
450
|
};
|
|
473
451
|
/**
|
|
474
452
|
* Determines the difference between two vectors.
|
|
@@ -479,7 +457,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
479
457
|
out._x = left._x - right._x;
|
|
480
458
|
out._y = left._y - right._y;
|
|
481
459
|
out._z = left._z - right._z;
|
|
482
|
-
out._onValueChanged
|
|
460
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
483
461
|
};
|
|
484
462
|
/**
|
|
485
463
|
* Determines the product of two vectors.
|
|
@@ -490,7 +468,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
490
468
|
out._x = left._x * right._x;
|
|
491
469
|
out._y = left._y * right._y;
|
|
492
470
|
out._z = left._z * right._z;
|
|
493
|
-
out._onValueChanged
|
|
471
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
494
472
|
};
|
|
495
473
|
/**
|
|
496
474
|
* Determines the divisor of two vectors.
|
|
@@ -501,7 +479,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
501
479
|
out._x = left._x / right._x;
|
|
502
480
|
out._y = left._y / right._y;
|
|
503
481
|
out._z = left._z / right._z;
|
|
504
|
-
out._onValueChanged
|
|
482
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
505
483
|
};
|
|
506
484
|
/**
|
|
507
485
|
* Determines the dot product of two vectors.
|
|
@@ -566,7 +544,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
566
544
|
out._x = _x + (end._x - _x) * t;
|
|
567
545
|
out._y = _y + (end._y - _y) * t;
|
|
568
546
|
out._z = _z + (end._z - _z) * t;
|
|
569
|
-
out._onValueChanged
|
|
547
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
570
548
|
};
|
|
571
549
|
/**
|
|
572
550
|
* Calculate a vector containing the largest components of the specified vectors.
|
|
@@ -577,7 +555,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
577
555
|
out._x = Math.max(left._x, right._x);
|
|
578
556
|
out._y = Math.max(left._y, right._y);
|
|
579
557
|
out._z = Math.max(left._z, right._z);
|
|
580
|
-
out._onValueChanged
|
|
558
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
581
559
|
};
|
|
582
560
|
/**
|
|
583
561
|
* Calculate a vector containing the smallest components of the specified vectors.
|
|
@@ -588,7 +566,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
588
566
|
out._x = Math.min(left._x, right._x);
|
|
589
567
|
out._y = Math.min(left._y, right._y);
|
|
590
568
|
out._z = Math.min(left._z, right._z);
|
|
591
|
-
out._onValueChanged
|
|
569
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
592
570
|
};
|
|
593
571
|
/**
|
|
594
572
|
* Reverses the direction of a given vector.
|
|
@@ -598,7 +576,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
598
576
|
out._x = -a._x;
|
|
599
577
|
out._y = -a._y;
|
|
600
578
|
out._z = -a._z;
|
|
601
|
-
out._onValueChanged
|
|
579
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
602
580
|
};
|
|
603
581
|
/**
|
|
604
582
|
* Converts the vector into a unit vector.
|
|
@@ -621,7 +599,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
621
599
|
out._x = a._x * s;
|
|
622
600
|
out._y = a._y * s;
|
|
623
601
|
out._z = a._z * s;
|
|
624
|
-
out._onValueChanged
|
|
602
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
625
603
|
};
|
|
626
604
|
/**
|
|
627
605
|
* Performs a normal transformation using the given 4x4 matrix.
|
|
@@ -640,7 +618,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
640
618
|
out._x = _x * e[0] + _y * e[4] + _z * e[8];
|
|
641
619
|
out._y = _x * e[1] + _y * e[5] + _z * e[9];
|
|
642
620
|
out._z = _x * e[2] + _y * e[6] + _z * e[10];
|
|
643
|
-
out._onValueChanged
|
|
621
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
644
622
|
};
|
|
645
623
|
/**
|
|
646
624
|
* Performs a transformation using the given 4x4 matrix.
|
|
@@ -653,7 +631,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
653
631
|
out._x = _x * e[0] + _y * e[4] + _z * e[8] + e[12];
|
|
654
632
|
out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
|
|
655
633
|
out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
|
|
656
|
-
out._onValueChanged
|
|
634
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
657
635
|
};
|
|
658
636
|
/**
|
|
659
637
|
* Performs a transformation from vector3 to vector4 using the given 4x4 matrix.
|
|
@@ -667,7 +645,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
667
645
|
out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
|
|
668
646
|
out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
|
|
669
647
|
out._w = _x * e[3] + _y * e[7] + _z * e[11] + e[15];
|
|
670
|
-
out._onValueChanged
|
|
648
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
671
649
|
};
|
|
672
650
|
/**
|
|
673
651
|
* Performs a coordinate transformation using the given 4x4 matrix.
|
|
@@ -689,7 +667,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
689
667
|
out._x = (_x * e[0] + _y * e[4] + _z * e[8] + e[12]) * w;
|
|
690
668
|
out._y = (_x * e[1] + _y * e[5] + _z * e[9] + e[13]) * w;
|
|
691
669
|
out._z = (_x * e[2] + _y * e[6] + _z * e[10] + e[14]) * w;
|
|
692
|
-
out._onValueChanged
|
|
670
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
693
671
|
};
|
|
694
672
|
/**
|
|
695
673
|
* Performs a transformation using the given quaternion.
|
|
@@ -708,7 +686,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
708
686
|
out._x = ix * qw - iw * qx - iy * qz + iz * qy;
|
|
709
687
|
out._y = iy * qw - iw * qy - iz * qx + ix * qz;
|
|
710
688
|
out._z = iz * qw - iw * qz - ix * qy + iy * qx;
|
|
711
|
-
out._onValueChanged
|
|
689
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
712
690
|
};
|
|
713
691
|
_create_class(Vector3, [
|
|
714
692
|
{
|
|
@@ -720,7 +698,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
720
698
|
},
|
|
721
699
|
set: function set(value) {
|
|
722
700
|
this._x = value;
|
|
723
|
-
this._onValueChanged
|
|
701
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
724
702
|
}
|
|
725
703
|
},
|
|
726
704
|
{
|
|
@@ -732,7 +710,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
732
710
|
},
|
|
733
711
|
set: function set(value) {
|
|
734
712
|
this._y = value;
|
|
735
|
-
this._onValueChanged
|
|
713
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
736
714
|
}
|
|
737
715
|
},
|
|
738
716
|
{
|
|
@@ -744,661 +722,24 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
744
722
|
},
|
|
745
723
|
set: function set(value) {
|
|
746
724
|
this._z = value;
|
|
747
|
-
this._onValueChanged
|
|
725
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
748
726
|
}
|
|
749
727
|
}
|
|
750
728
|
]);
|
|
751
729
|
return Vector3;
|
|
752
730
|
}();
|
|
753
|
-
(
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
* */ var BoundingSphere = /*#__PURE__*/ function() {
|
|
762
|
-
var BoundingSphere = function BoundingSphere(center, radius) {
|
|
763
|
-
if (center === void 0) center = null;
|
|
764
|
-
if (radius === void 0) radius = 0;
|
|
765
|
-
/** The center point of the sphere. */ this.center = new Vector3();
|
|
766
|
-
/** The radius of the sphere. */ this.radius = 0;
|
|
767
|
-
center && this.center.copyFrom(center);
|
|
768
|
-
this.radius = radius;
|
|
769
|
-
};
|
|
770
|
-
var _proto = BoundingSphere.prototype;
|
|
771
|
-
/**
|
|
772
|
-
* Creates a clone of this sphere.
|
|
773
|
-
* @returns A clone of this sphere
|
|
774
|
-
*/ _proto.clone = function clone() {
|
|
775
|
-
return new BoundingSphere(this.center, this.radius);
|
|
776
|
-
};
|
|
777
|
-
/**
|
|
778
|
-
* Copy this sphere from the specified sphere.
|
|
779
|
-
* @param source - The specified sphere
|
|
780
|
-
* @returns This sphere
|
|
781
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
782
|
-
this.center.copyFrom(source.center);
|
|
783
|
-
this.radius = source.radius;
|
|
784
|
-
return this;
|
|
785
|
-
};
|
|
786
|
-
/**
|
|
787
|
-
* Calculate a bounding sphere that fully contains the given points.
|
|
788
|
-
* @param points - The given points
|
|
789
|
-
* @param out - The calculated bounding sphere
|
|
790
|
-
*/ BoundingSphere.fromPoints = function fromPoints(points, out) {
|
|
791
|
-
if (!points || points.length === 0) {
|
|
792
|
-
throw new Error("points must be array and length must > 0");
|
|
793
|
-
}
|
|
794
|
-
var len = points.length;
|
|
795
|
-
var center = BoundingSphere._tempVec30;
|
|
796
|
-
center.x = center.y = center.z = 0;
|
|
797
|
-
// Calculate the center of the sphere.
|
|
798
|
-
for(var i = 0; i < len; ++i){
|
|
799
|
-
Vector3.add(points[i], center, center);
|
|
800
|
-
}
|
|
801
|
-
// The center of the sphere.
|
|
802
|
-
Vector3.scale(center, 1 / len, out.center);
|
|
803
|
-
// Calculate the radius of the sphere.
|
|
804
|
-
var radius = 0.0;
|
|
805
|
-
for(var i1 = 0; i1 < len; ++i1){
|
|
806
|
-
var distance = Vector3.distanceSquared(center, points[i1]);
|
|
807
|
-
distance > radius && (radius = distance);
|
|
808
|
-
}
|
|
809
|
-
// The radius of the sphere.
|
|
810
|
-
out.radius = Math.sqrt(radius);
|
|
811
|
-
};
|
|
812
|
-
/**
|
|
813
|
-
* Calculate a bounding sphere from a given box.
|
|
814
|
-
* @param box - The given box
|
|
815
|
-
* @param out - The calculated bounding sphere
|
|
816
|
-
*/ BoundingSphere.fromBox = function fromBox(box, out) {
|
|
817
|
-
var center = out.center;
|
|
818
|
-
var min = box.min, max = box.max;
|
|
819
|
-
center.x = (min.x + max.x) * 0.5;
|
|
820
|
-
center.y = (min.y + max.y) * 0.5;
|
|
821
|
-
center.z = (min.z + max.z) * 0.5;
|
|
822
|
-
out.radius = Vector3.distance(center, max);
|
|
823
|
-
};
|
|
824
|
-
return BoundingSphere;
|
|
825
|
-
}();
|
|
826
|
-
(function() {
|
|
827
|
-
BoundingSphere._tempVec30 = new Vector3();
|
|
828
|
-
})();
|
|
829
|
-
/**
|
|
830
|
-
* Axis Aligned Bound Box (AABB).
|
|
831
|
-
*/ var BoundingBox = /*#__PURE__*/ function() {
|
|
832
|
-
var BoundingBox = function BoundingBox(min, max) {
|
|
833
|
-
if (min === void 0) min = null;
|
|
834
|
-
if (max === void 0) max = null;
|
|
835
|
-
/** The minimum point of the box. */ this.min = new Vector3();
|
|
836
|
-
/** The maximum point of the box. */ this.max = new Vector3();
|
|
837
|
-
min && this.min.copyFrom(min);
|
|
838
|
-
max && this.max.copyFrom(max);
|
|
839
|
-
};
|
|
840
|
-
var _proto = BoundingBox.prototype;
|
|
841
|
-
/**
|
|
842
|
-
* Get the center point of this bounding box.
|
|
843
|
-
* @param out - The center point of this bounding box
|
|
844
|
-
* @returns The center point of this bounding box
|
|
845
|
-
*/ _proto.getCenter = function getCenter(out) {
|
|
846
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
847
|
-
var centerX = max._x + min._x;
|
|
848
|
-
var centerY = max._y + min._y;
|
|
849
|
-
var centerZ = max._z + min._z;
|
|
850
|
-
out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
|
|
851
|
-
return out;
|
|
852
|
-
};
|
|
853
|
-
/**
|
|
854
|
-
* Get the extent of this bounding box.
|
|
855
|
-
* @param out - The extent of this bounding box
|
|
856
|
-
* @returns The extent of this bounding box
|
|
857
|
-
*/ _proto.getExtent = function getExtent(out) {
|
|
858
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
859
|
-
var extentX = max._x - min._x;
|
|
860
|
-
var extentY = max._y - min._y;
|
|
861
|
-
var extentZ = max._z - min._z;
|
|
862
|
-
out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
|
|
863
|
-
return out;
|
|
864
|
-
};
|
|
865
|
-
/**
|
|
866
|
-
* Get the eight corners of this bounding box.
|
|
867
|
-
* @param out - An array of points representing the eight corners of this bounding box
|
|
868
|
-
* @returns An array of points representing the eight corners of this bounding box
|
|
869
|
-
*/ _proto.getCorners = function getCorners(out) {
|
|
870
|
-
if (out === void 0) out = [];
|
|
871
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
872
|
-
var minX = min.x;
|
|
873
|
-
var minY = min.y;
|
|
874
|
-
var minZ = min.z;
|
|
875
|
-
var maxX = max.x;
|
|
876
|
-
var maxY = max.y;
|
|
877
|
-
var maxZ = max.z;
|
|
878
|
-
var len = out.length;
|
|
879
|
-
// The array length is less than 8 to make up
|
|
880
|
-
if (len < 8) {
|
|
881
|
-
for(var i = 0, l = 8 - len; i < l; ++i){
|
|
882
|
-
out[len + i] = new Vector3();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
out[0].set(minX, maxY, maxZ);
|
|
886
|
-
out[1].set(maxX, maxY, maxZ);
|
|
887
|
-
out[2].set(maxX, minY, maxZ);
|
|
888
|
-
out[3].set(minX, minY, maxZ);
|
|
889
|
-
out[4].set(minX, maxY, minZ);
|
|
890
|
-
out[5].set(maxX, maxY, minZ);
|
|
891
|
-
out[6].set(maxX, minY, minZ);
|
|
892
|
-
out[7].set(minX, minY, minZ);
|
|
893
|
-
return out;
|
|
894
|
-
};
|
|
895
|
-
/**
|
|
896
|
-
* Transform a bounding box.
|
|
897
|
-
* @param matrix - The transform to apply to the bounding box
|
|
898
|
-
* @returns The transformed bounding box
|
|
899
|
-
*/ _proto.transform = function transform(matrix) {
|
|
900
|
-
BoundingBox.transform(this, matrix, this);
|
|
901
|
-
return this;
|
|
902
|
-
};
|
|
903
|
-
/**
|
|
904
|
-
* Creates a clone of this box.
|
|
905
|
-
* @returns A clone of this box
|
|
906
|
-
*/ _proto.clone = function clone() {
|
|
907
|
-
return new BoundingBox(this.min, this.max);
|
|
908
|
-
};
|
|
909
|
-
/**
|
|
910
|
-
* Copy this bounding box from the specified box.
|
|
911
|
-
* @param source - The specified box
|
|
912
|
-
* @returns This bounding box
|
|
913
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
914
|
-
this.min.copyFrom(source.min);
|
|
915
|
-
this.max.copyFrom(source.max);
|
|
916
|
-
return this;
|
|
917
|
-
};
|
|
918
|
-
/**
|
|
919
|
-
* Calculate a bounding box from the center point and the extent of the bounding box.
|
|
920
|
-
* @param center - The center point
|
|
921
|
-
* @param extent - The extent of the bounding box
|
|
922
|
-
* @param out - The calculated bounding box
|
|
923
|
-
*/ BoundingBox.fromCenterAndExtent = function fromCenterAndExtent(center, extent, out) {
|
|
924
|
-
Vector3.subtract(center, extent, out.min);
|
|
925
|
-
Vector3.add(center, extent, out.max);
|
|
926
|
-
};
|
|
927
|
-
/**
|
|
928
|
-
* Calculate a bounding box that fully contains the given points.
|
|
929
|
-
* @param points - The given points
|
|
930
|
-
* @param out - The calculated bounding box
|
|
931
|
-
*/ BoundingBox.fromPoints = function fromPoints(points, out) {
|
|
932
|
-
if (!points || points.length === 0) {
|
|
933
|
-
throw new Error("points must be array and length must > 0");
|
|
934
|
-
}
|
|
935
|
-
var min = out.min, max = out.max;
|
|
936
|
-
min.x = min.y = min.z = Number.MAX_VALUE;
|
|
937
|
-
max.x = max.y = max.z = -Number.MAX_VALUE;
|
|
938
|
-
for(var i = 0, l = points.length; i < l; ++i){
|
|
939
|
-
var point = points[i];
|
|
940
|
-
Vector3.min(min, point, min);
|
|
941
|
-
Vector3.max(max, point, max);
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
/**
|
|
945
|
-
* Calculate a bounding box from a given sphere.
|
|
946
|
-
* @param sphere - The given sphere
|
|
947
|
-
* @param out - The calculated bounding box
|
|
948
|
-
*/ BoundingBox.fromSphere = function fromSphere(sphere, out) {
|
|
949
|
-
var center = sphere.center, radius = sphere.radius;
|
|
950
|
-
var min = out.min, max = out.max;
|
|
951
|
-
min.x = center.x - radius;
|
|
952
|
-
min.y = center.y - radius;
|
|
953
|
-
min.z = center.z - radius;
|
|
954
|
-
max.x = center.x + radius;
|
|
955
|
-
max.y = center.y + radius;
|
|
956
|
-
max.z = center.z + radius;
|
|
957
|
-
};
|
|
958
|
-
/**
|
|
959
|
-
* Transform a bounding box.
|
|
960
|
-
* @param source - The original bounding box
|
|
961
|
-
* @param matrix - The transform to apply to the bounding box
|
|
962
|
-
* @param out - The transformed bounding box
|
|
963
|
-
*/ BoundingBox.transform = function transform(source, matrix, out) {
|
|
964
|
-
// https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
|
|
965
|
-
var center = BoundingBox._tempVec30;
|
|
966
|
-
var extent = BoundingBox._tempVec31;
|
|
967
|
-
source.getCenter(center);
|
|
968
|
-
source.getExtent(extent);
|
|
969
|
-
Vector3.transformCoordinate(center, matrix, center);
|
|
970
|
-
var x = extent.x, y = extent.y, z = extent.z;
|
|
971
|
-
var e = matrix.elements;
|
|
972
|
-
// prettier-ignore
|
|
973
|
-
var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e8 = e[8], e9 = e[9], e10 = e[10];
|
|
974
|
-
extent.set((e0 === 0 ? 0 : Math.abs(x * e0)) + (e4 === 0 ? 0 : Math.abs(y * e4)) + (e8 === 0 ? 0 : Math.abs(z * e8)), (e1 === 0 ? 0 : Math.abs(x * e1)) + (e5 === 0 ? 0 : Math.abs(y * e5)) + (e9 === 0 ? 0 : Math.abs(z * e9)), (e2 === 0 ? 0 : Math.abs(x * e2)) + (e6 === 0 ? 0 : Math.abs(y * e6)) + (e10 === 0 ? 0 : Math.abs(z * e10)));
|
|
975
|
-
// set min、max
|
|
976
|
-
Vector3.subtract(center, extent, out.min);
|
|
977
|
-
Vector3.add(center, extent, out.max);
|
|
978
|
-
};
|
|
979
|
-
/**
|
|
980
|
-
* Calculate a bounding box that is as large as the total combined area of the two specified boxes.
|
|
981
|
-
* @param box1 - The first box to merge
|
|
982
|
-
* @param box2 - The second box to merge
|
|
983
|
-
* @param out - The merged bounding box
|
|
984
|
-
* @returns The merged bounding box
|
|
985
|
-
*/ BoundingBox.merge = function merge(box1, box2, out) {
|
|
986
|
-
Vector3.min(box1.min, box2.min, out.min);
|
|
987
|
-
Vector3.max(box1.max, box2.max, out.max);
|
|
988
|
-
return out;
|
|
989
|
-
};
|
|
990
|
-
return BoundingBox;
|
|
991
|
-
}();
|
|
992
|
-
(function() {
|
|
993
|
-
BoundingBox._tempVec30 = new Vector3();
|
|
994
|
-
})();
|
|
995
|
-
(function() {
|
|
996
|
-
BoundingBox._tempVec31 = new Vector3();
|
|
997
|
-
})();
|
|
998
|
-
/**
|
|
999
|
-
* Contains static methods to help in determining intersections, containment, etc.
|
|
1000
|
-
*/ var CollisionUtil = /*#__PURE__*/ function() {
|
|
1001
|
-
var CollisionUtil = function CollisionUtil() {};
|
|
1002
|
-
/**
|
|
1003
|
-
* Calculate the intersection point of three plane.
|
|
1004
|
-
* @param p1 - Plane 1
|
|
1005
|
-
* @param p2 - Plane 2
|
|
1006
|
-
* @param p3 - Plane 3
|
|
1007
|
-
* @param out - intersection point
|
|
1008
|
-
*/ CollisionUtil.intersectionPointThreePlanes = function intersectionPointThreePlanes(p1, p2, p3, out) {
|
|
1009
|
-
var p1Nor = p1.normal;
|
|
1010
|
-
var p2Nor = p2.normal;
|
|
1011
|
-
var p3Nor = p3.normal;
|
|
1012
|
-
Vector3.cross(p2Nor, p3Nor, CollisionUtil._tempVec30);
|
|
1013
|
-
Vector3.cross(p3Nor, p1Nor, CollisionUtil._tempVec31);
|
|
1014
|
-
Vector3.cross(p1Nor, p2Nor, CollisionUtil._tempVec32);
|
|
1015
|
-
var a = -Vector3.dot(p1Nor, CollisionUtil._tempVec30);
|
|
1016
|
-
var b = -Vector3.dot(p2Nor, CollisionUtil._tempVec31);
|
|
1017
|
-
var c = -Vector3.dot(p3Nor, CollisionUtil._tempVec32);
|
|
1018
|
-
Vector3.scale(CollisionUtil._tempVec30, p1.distance / a, CollisionUtil._tempVec30);
|
|
1019
|
-
Vector3.scale(CollisionUtil._tempVec31, p2.distance / b, CollisionUtil._tempVec31);
|
|
1020
|
-
Vector3.scale(CollisionUtil._tempVec32, p3.distance / c, CollisionUtil._tempVec32);
|
|
1021
|
-
Vector3.add(CollisionUtil._tempVec30, CollisionUtil._tempVec31, out);
|
|
1022
|
-
Vector3.add(out, CollisionUtil._tempVec32, out);
|
|
1023
|
-
};
|
|
1024
|
-
/**
|
|
1025
|
-
* Calculate the distance from a point to a plane.
|
|
1026
|
-
* @param plane - The plane
|
|
1027
|
-
* @param point - The point
|
|
1028
|
-
* @returns The distance from a point to a plane
|
|
1029
|
-
*/ CollisionUtil.distancePlaneAndPoint = function distancePlaneAndPoint(plane, point) {
|
|
1030
|
-
return Vector3.dot(plane.normal, point) + plane.distance;
|
|
1031
|
-
};
|
|
1032
|
-
/**
|
|
1033
|
-
* Get the intersection type between a plane and a point.
|
|
1034
|
-
* @param plane - The plane
|
|
1035
|
-
* @param point - The point
|
|
1036
|
-
* @returns The intersection type
|
|
1037
|
-
*/ CollisionUtil.intersectsPlaneAndPoint = function intersectsPlaneAndPoint(plane, point) {
|
|
1038
|
-
var distance = CollisionUtil.distancePlaneAndPoint(plane, point);
|
|
1039
|
-
if (distance > 0) {
|
|
1040
|
-
return PlaneIntersectionType.Front;
|
|
1041
|
-
}
|
|
1042
|
-
if (distance < 0) {
|
|
1043
|
-
return PlaneIntersectionType.Back;
|
|
1044
|
-
}
|
|
1045
|
-
return PlaneIntersectionType.Intersecting;
|
|
1046
|
-
};
|
|
1047
|
-
/**
|
|
1048
|
-
* Get the intersection type between a plane and a box (AABB).
|
|
1049
|
-
* @param plane - The plane
|
|
1050
|
-
* @param box - The box
|
|
1051
|
-
* @returns The intersection type
|
|
1052
|
-
*/ CollisionUtil.intersectsPlaneAndBox = function intersectsPlaneAndBox(plane, box) {
|
|
1053
|
-
var min = box.min, max = box.max;
|
|
1054
|
-
var normal = plane.normal;
|
|
1055
|
-
var front = CollisionUtil._tempVec30;
|
|
1056
|
-
var back = CollisionUtil._tempVec31;
|
|
1057
|
-
if (normal.x >= 0) {
|
|
1058
|
-
front.x = max.x;
|
|
1059
|
-
back.x = min.x;
|
|
1060
|
-
} else {
|
|
1061
|
-
front.x = min.x;
|
|
1062
|
-
back.x = max.x;
|
|
1063
|
-
}
|
|
1064
|
-
if (normal.y >= 0) {
|
|
1065
|
-
front.y = max.y;
|
|
1066
|
-
back.y = min.y;
|
|
1067
|
-
} else {
|
|
1068
|
-
front.y = min.y;
|
|
1069
|
-
back.y = max.y;
|
|
1070
|
-
}
|
|
1071
|
-
if (normal.z >= 0) {
|
|
1072
|
-
front.z = max.z;
|
|
1073
|
-
back.z = min.z;
|
|
1074
|
-
} else {
|
|
1075
|
-
front.z = min.z;
|
|
1076
|
-
back.z = max.z;
|
|
1077
|
-
}
|
|
1078
|
-
if (CollisionUtil.distancePlaneAndPoint(plane, front) < 0) {
|
|
1079
|
-
return PlaneIntersectionType.Back;
|
|
1080
|
-
}
|
|
1081
|
-
if (CollisionUtil.distancePlaneAndPoint(plane, back) > 0) {
|
|
1082
|
-
return PlaneIntersectionType.Front;
|
|
1083
|
-
}
|
|
1084
|
-
return PlaneIntersectionType.Intersecting;
|
|
1085
|
-
};
|
|
1086
|
-
/**
|
|
1087
|
-
* Get the intersection type between a plane and a sphere.
|
|
1088
|
-
* @param plane - The plane
|
|
1089
|
-
* @param sphere - The sphere
|
|
1090
|
-
* @returns The intersection type
|
|
1091
|
-
*/ CollisionUtil.intersectsPlaneAndSphere = function intersectsPlaneAndSphere(plane, sphere) {
|
|
1092
|
-
var center = sphere.center, radius = sphere.radius;
|
|
1093
|
-
var distance = CollisionUtil.distancePlaneAndPoint(plane, center);
|
|
1094
|
-
if (distance > radius) {
|
|
1095
|
-
return PlaneIntersectionType.Front;
|
|
1096
|
-
}
|
|
1097
|
-
if (distance < -radius) {
|
|
1098
|
-
return PlaneIntersectionType.Back;
|
|
1099
|
-
}
|
|
1100
|
-
return PlaneIntersectionType.Intersecting;
|
|
1101
|
-
};
|
|
1102
|
-
/**
|
|
1103
|
-
* Get the intersection type between a ray and a plane.
|
|
1104
|
-
* @param ray - The ray
|
|
1105
|
-
* @param plane - The plane
|
|
1106
|
-
* @returns The distance from ray to plane if intersecting, -1 otherwise
|
|
1107
|
-
*/ CollisionUtil.intersectsRayAndPlane = function intersectsRayAndPlane(ray, plane) {
|
|
1108
|
-
var normal = plane.normal;
|
|
1109
|
-
var zeroTolerance = MathUtil.zeroTolerance;
|
|
1110
|
-
var dir = Vector3.dot(normal, ray.direction);
|
|
1111
|
-
// Parallel
|
|
1112
|
-
if (Math.abs(dir) < zeroTolerance) {
|
|
1113
|
-
return -1;
|
|
1114
|
-
}
|
|
1115
|
-
var position = Vector3.dot(normal, ray.origin);
|
|
1116
|
-
var distance = (-plane.distance - position) / dir;
|
|
1117
|
-
if (distance < 0) {
|
|
1118
|
-
if (distance < -zeroTolerance) {
|
|
1119
|
-
return -1;
|
|
1120
|
-
}
|
|
1121
|
-
distance = 0;
|
|
1122
|
-
}
|
|
1123
|
-
return distance;
|
|
1124
|
-
};
|
|
1125
|
-
/**
|
|
1126
|
-
* Get the intersection type between a ray and a box (AABB).
|
|
1127
|
-
* @param ray - The ray
|
|
1128
|
-
* @param box - The box
|
|
1129
|
-
* @returns The distance from ray to box if intersecting, -1 otherwise
|
|
1130
|
-
*/ CollisionUtil.intersectsRayAndBox = function intersectsRayAndBox(ray, box) {
|
|
1131
|
-
var zeroTolerance = MathUtil.zeroTolerance;
|
|
1132
|
-
var origin = ray.origin, direction = ray.direction;
|
|
1133
|
-
var min = box.min, max = box.max;
|
|
1134
|
-
var dirX = direction.x;
|
|
1135
|
-
var dirY = direction.y;
|
|
1136
|
-
var dirZ = direction.z;
|
|
1137
|
-
var oriX = origin.x;
|
|
1138
|
-
var oriY = origin.y;
|
|
1139
|
-
var oriZ = origin.z;
|
|
1140
|
-
var distance = 0;
|
|
1141
|
-
var tmax = Number.MAX_VALUE;
|
|
1142
|
-
if (Math.abs(dirX) < zeroTolerance) {
|
|
1143
|
-
if (oriX < min.x || oriX > max.x) {
|
|
1144
|
-
return -1;
|
|
1145
|
-
}
|
|
1146
|
-
} else {
|
|
1147
|
-
var inverse = 1.0 / dirX;
|
|
1148
|
-
var t1 = (min.x - oriX) * inverse;
|
|
1149
|
-
var t2 = (max.x - oriX) * inverse;
|
|
1150
|
-
if (t1 > t2) {
|
|
1151
|
-
var temp = t1;
|
|
1152
|
-
t1 = t2;
|
|
1153
|
-
t2 = temp;
|
|
1154
|
-
}
|
|
1155
|
-
distance = Math.max(t1, distance);
|
|
1156
|
-
tmax = Math.min(t2, tmax);
|
|
1157
|
-
if (distance > tmax) {
|
|
1158
|
-
return -1;
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
if (Math.abs(dirY) < zeroTolerance) {
|
|
1162
|
-
if (oriY < min.y || oriY > max.y) {
|
|
1163
|
-
return -1;
|
|
1164
|
-
}
|
|
1165
|
-
} else {
|
|
1166
|
-
var inverse1 = 1.0 / dirY;
|
|
1167
|
-
var t11 = (min.y - oriY) * inverse1;
|
|
1168
|
-
var t21 = (max.y - oriY) * inverse1;
|
|
1169
|
-
if (t11 > t21) {
|
|
1170
|
-
var temp1 = t11;
|
|
1171
|
-
t11 = t21;
|
|
1172
|
-
t21 = temp1;
|
|
1173
|
-
}
|
|
1174
|
-
distance = Math.max(t11, distance);
|
|
1175
|
-
tmax = Math.min(t21, tmax);
|
|
1176
|
-
if (distance > tmax) {
|
|
1177
|
-
return -1;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
if (Math.abs(dirZ) < zeroTolerance) {
|
|
1181
|
-
if (oriZ < min.z || oriZ > max.z) {
|
|
1182
|
-
return -1;
|
|
1183
|
-
}
|
|
1184
|
-
} else {
|
|
1185
|
-
var inverse2 = 1.0 / dirZ;
|
|
1186
|
-
var t12 = (min.z - oriZ) * inverse2;
|
|
1187
|
-
var t22 = (max.z - oriZ) * inverse2;
|
|
1188
|
-
if (t12 > t22) {
|
|
1189
|
-
var temp2 = t12;
|
|
1190
|
-
t12 = t22;
|
|
1191
|
-
t22 = temp2;
|
|
1192
|
-
}
|
|
1193
|
-
distance = Math.max(t12, distance);
|
|
1194
|
-
tmax = Math.min(t22, tmax);
|
|
1195
|
-
if (distance > tmax) {
|
|
1196
|
-
return -1;
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
return distance;
|
|
1200
|
-
};
|
|
1201
|
-
/**
|
|
1202
|
-
* Get the intersection type between a ray and a sphere.
|
|
1203
|
-
* @param ray - The ray
|
|
1204
|
-
* @param sphere - The sphere
|
|
1205
|
-
* @returns The distance from ray to sphere if intersecting, -1 otherwise
|
|
1206
|
-
*/ CollisionUtil.intersectsRayAndSphere = function intersectsRayAndSphere(ray, sphere) {
|
|
1207
|
-
var origin = ray.origin, direction = ray.direction;
|
|
1208
|
-
var center = sphere.center, radius = sphere.radius;
|
|
1209
|
-
var m = CollisionUtil._tempVec30;
|
|
1210
|
-
Vector3.subtract(origin, center, m);
|
|
1211
|
-
var b = Vector3.dot(m, direction);
|
|
1212
|
-
var c = Vector3.dot(m, m) - radius * radius;
|
|
1213
|
-
if (b > 0 && c > 0) {
|
|
1214
|
-
return -1;
|
|
1215
|
-
}
|
|
1216
|
-
var discriminant = b * b - c;
|
|
1217
|
-
if (discriminant < 0) {
|
|
1218
|
-
return -1;
|
|
1219
|
-
}
|
|
1220
|
-
var distance = -b - Math.sqrt(discriminant);
|
|
1221
|
-
if (distance < 0) {
|
|
1222
|
-
distance = 0;
|
|
1223
|
-
}
|
|
1224
|
-
return distance;
|
|
1225
|
-
};
|
|
1226
|
-
/**
|
|
1227
|
-
* Check whether the boxes intersect.
|
|
1228
|
-
* @param boxA - The first box to check
|
|
1229
|
-
* @param boxB - The second box to check
|
|
1230
|
-
* @returns True if the boxes intersect, false otherwise
|
|
1231
|
-
*/ CollisionUtil.intersectsBoxAndBox = function intersectsBoxAndBox(boxA, boxB) {
|
|
1232
|
-
if (boxA.min.x > boxB.max.x || boxB.min.x > boxA.max.x) {
|
|
1233
|
-
return false;
|
|
1234
|
-
}
|
|
1235
|
-
if (boxA.min.y > boxB.max.y || boxB.min.y > boxA.max.y) {
|
|
1236
|
-
return false;
|
|
1237
|
-
}
|
|
1238
|
-
return !(boxA.min.z > boxB.max.z || boxB.min.z > boxA.max.z);
|
|
1239
|
-
};
|
|
1240
|
-
/**
|
|
1241
|
-
* Check whether the spheres intersect.
|
|
1242
|
-
* @param sphereA - The first sphere to check
|
|
1243
|
-
* @param sphereB - The second sphere to check
|
|
1244
|
-
* @returns True if the spheres intersect, false otherwise
|
|
1245
|
-
*/ CollisionUtil.intersectsSphereAndSphere = function intersectsSphereAndSphere(sphereA, sphereB) {
|
|
1246
|
-
var radiisum = sphereA.radius + sphereB.radius;
|
|
1247
|
-
return Vector3.distanceSquared(sphereA.center, sphereB.center) < radiisum * radiisum;
|
|
1248
|
-
};
|
|
1249
|
-
/**
|
|
1250
|
-
* Check whether the sphere and the box intersect.
|
|
1251
|
-
* @param sphere - The sphere to check
|
|
1252
|
-
* @param box - The box to check
|
|
1253
|
-
* @returns True if the sphere and the box intersect, false otherwise
|
|
1254
|
-
*/ CollisionUtil.intersectsSphereAndBox = function intersectsSphereAndBox(sphere, box) {
|
|
1255
|
-
var center = sphere.center;
|
|
1256
|
-
var max = box.max;
|
|
1257
|
-
var min = box.min;
|
|
1258
|
-
var closestPoint = CollisionUtil._tempVec30;
|
|
1259
|
-
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)));
|
|
1260
|
-
var distance = Vector3.distanceSquared(center, closestPoint);
|
|
1261
|
-
return distance <= sphere.radius * sphere.radius;
|
|
1262
|
-
};
|
|
1263
|
-
/**
|
|
1264
|
-
* Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
|
|
1265
|
-
* @param frustum - The frustum
|
|
1266
|
-
* @param box - The box
|
|
1267
|
-
* @returns True if bounding box intersects with this frustum, false otherwise
|
|
1268
|
-
*/ CollisionUtil.intersectsFrustumAndBox = function intersectsFrustumAndBox(frustum, box) {
|
|
1269
|
-
var min = box.min, max = box.max;
|
|
1270
|
-
var p = CollisionUtil._tempVec30;
|
|
1271
|
-
for(var i = 0; i < 6; ++i){
|
|
1272
|
-
var plane = frustum.getPlane(i);
|
|
1273
|
-
var normal = plane.normal;
|
|
1274
|
-
p.set(normal.x >= 0 ? max.x : min.x, normal.y >= 0 ? max.y : min.y, normal.z >= 0 ? max.z : min.z);
|
|
1275
|
-
if (Vector3.dot(normal, p) < -plane.distance) {
|
|
1276
|
-
return false;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
return true;
|
|
1280
|
-
};
|
|
1281
|
-
/**
|
|
1282
|
-
* Get the containment type between a frustum and a point.
|
|
1283
|
-
* @param frustum - The frustum
|
|
1284
|
-
* @param point - The point
|
|
1285
|
-
* @returns The containment type
|
|
1286
|
-
*/ CollisionUtil.frustumContainsPoint = function frustumContainsPoint(frustum, point) {
|
|
1287
|
-
var distance = CollisionUtil.distancePlaneAndPoint(frustum.near, point);
|
|
1288
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1289
|
-
return ContainmentType.Intersects;
|
|
1290
|
-
} else if (distance < 0) {
|
|
1291
|
-
return ContainmentType.Disjoint;
|
|
1292
|
-
}
|
|
1293
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.far, point);
|
|
1294
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1295
|
-
return ContainmentType.Intersects;
|
|
1296
|
-
} else if (distance < 0) {
|
|
1297
|
-
return ContainmentType.Disjoint;
|
|
1298
|
-
}
|
|
1299
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.left, point);
|
|
1300
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1301
|
-
return ContainmentType.Intersects;
|
|
1302
|
-
} else if (distance < 0) {
|
|
1303
|
-
return ContainmentType.Disjoint;
|
|
1304
|
-
}
|
|
1305
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.right, point);
|
|
1306
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1307
|
-
return ContainmentType.Intersects;
|
|
1308
|
-
} else if (distance < 0) {
|
|
1309
|
-
return ContainmentType.Disjoint;
|
|
1310
|
-
}
|
|
1311
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.top, point);
|
|
1312
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1313
|
-
return ContainmentType.Intersects;
|
|
1314
|
-
} else if (distance < 0) {
|
|
1315
|
-
return ContainmentType.Disjoint;
|
|
1316
|
-
}
|
|
1317
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.bottom, point);
|
|
1318
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1319
|
-
return ContainmentType.Intersects;
|
|
1320
|
-
} else if (distance < 0) {
|
|
1321
|
-
return ContainmentType.Disjoint;
|
|
1322
|
-
}
|
|
1323
|
-
return ContainmentType.Contains;
|
|
1324
|
-
};
|
|
1325
|
-
/**
|
|
1326
|
-
* Get the containment type between a frustum and a box (AABB).
|
|
1327
|
-
* @param frustum - The frustum
|
|
1328
|
-
* @param box - The box
|
|
1329
|
-
* @returns The containment type
|
|
1330
|
-
*/ CollisionUtil.frustumContainsBox = function frustumContainsBox(frustum, box) {
|
|
1331
|
-
var min = box.min, max = box.max;
|
|
1332
|
-
var p = CollisionUtil._tempVec30;
|
|
1333
|
-
var n = CollisionUtil._tempVec31;
|
|
1334
|
-
var result = ContainmentType.Contains;
|
|
1335
|
-
for(var i = 0; i < 6; ++i){
|
|
1336
|
-
var plane = frustum.getPlane(i);
|
|
1337
|
-
var normal = plane.normal;
|
|
1338
|
-
if (normal.x >= 0) {
|
|
1339
|
-
p.x = max.x;
|
|
1340
|
-
n.x = min.x;
|
|
1341
|
-
} else {
|
|
1342
|
-
p.x = min.x;
|
|
1343
|
-
n.x = max.x;
|
|
1344
|
-
}
|
|
1345
|
-
if (normal.y >= 0) {
|
|
1346
|
-
p.y = max.y;
|
|
1347
|
-
n.y = min.y;
|
|
1348
|
-
} else {
|
|
1349
|
-
p.y = min.y;
|
|
1350
|
-
n.y = max.y;
|
|
1351
|
-
}
|
|
1352
|
-
if (normal.z >= 0) {
|
|
1353
|
-
p.z = max.z;
|
|
1354
|
-
n.z = min.z;
|
|
1355
|
-
} else {
|
|
1356
|
-
p.z = min.z;
|
|
1357
|
-
n.z = max.z;
|
|
1358
|
-
}
|
|
1359
|
-
if (CollisionUtil.intersectsPlaneAndPoint(plane, p) === PlaneIntersectionType.Back) {
|
|
1360
|
-
return ContainmentType.Disjoint;
|
|
1361
|
-
}
|
|
1362
|
-
if (CollisionUtil.intersectsPlaneAndPoint(plane, n) === PlaneIntersectionType.Back) {
|
|
1363
|
-
result = ContainmentType.Intersects;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
return result;
|
|
1367
|
-
};
|
|
1368
|
-
/**
|
|
1369
|
-
* Get the containment type between a frustum and a sphere.
|
|
1370
|
-
* @param frustum - The frustum
|
|
1371
|
-
* @param sphere - The sphere
|
|
1372
|
-
* @returns The containment type
|
|
1373
|
-
*/ CollisionUtil.frustumContainsSphere = function frustumContainsSphere(frustum, sphere) {
|
|
1374
|
-
var result = ContainmentType.Contains;
|
|
1375
|
-
for(var i = 0; i < 6; ++i){
|
|
1376
|
-
var plane = frustum.getPlane(i);
|
|
1377
|
-
var intersectionType = CollisionUtil.intersectsPlaneAndSphere(plane, sphere);
|
|
1378
|
-
if (intersectionType === PlaneIntersectionType.Back) {
|
|
1379
|
-
return ContainmentType.Disjoint;
|
|
1380
|
-
} else if (intersectionType === PlaneIntersectionType.Intersecting) {
|
|
1381
|
-
result = ContainmentType.Intersects;
|
|
1382
|
-
break;
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
return result;
|
|
1386
|
-
};
|
|
1387
|
-
return CollisionUtil;
|
|
1388
|
-
}();
|
|
1389
|
-
(function() {
|
|
1390
|
-
CollisionUtil._tempVec30 = new Vector3();
|
|
1391
|
-
})();
|
|
1392
|
-
(function() {
|
|
1393
|
-
CollisionUtil._tempVec31 = new Vector3();
|
|
1394
|
-
})();
|
|
1395
|
-
(function() {
|
|
1396
|
-
CollisionUtil._tempVec32 = new Vector3();
|
|
1397
|
-
})();
|
|
731
|
+
/** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
|
|
732
|
+
/** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
|
|
733
|
+
new Vector3();
|
|
734
|
+
new Vector3();
|
|
735
|
+
new Vector3();
|
|
736
|
+
new Vector3();
|
|
737
|
+
new Vector3();
|
|
738
|
+
new Vector3();
|
|
1398
739
|
/**
|
|
1399
740
|
* Represents a 3x3 mathematical matrix.
|
|
1400
741
|
*/ var Matrix3x3 = /*#__PURE__*/ function() {
|
|
1401
|
-
|
|
742
|
+
function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
|
|
1402
743
|
if (m11 === void 0) m11 = 1;
|
|
1403
744
|
if (m12 === void 0) m12 = 0;
|
|
1404
745
|
if (m13 === void 0) m13 = 0;
|
|
@@ -1427,7 +768,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1427
768
|
e[6] = m31;
|
|
1428
769
|
e[7] = m32;
|
|
1429
770
|
e[8] = m33;
|
|
1430
|
-
}
|
|
771
|
+
}
|
|
1431
772
|
var _proto = Matrix3x3.prototype;
|
|
1432
773
|
/**
|
|
1433
774
|
* Set the value of this matrix, and return this matrix.
|
|
@@ -1940,7 +1281,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1940
1281
|
/**
|
|
1941
1282
|
* Represents a four dimensional mathematical quaternion.
|
|
1942
1283
|
*/ var Quaternion = /*#__PURE__*/ function() {
|
|
1943
|
-
|
|
1284
|
+
function Quaternion(x, y, z, w) {
|
|
1944
1285
|
if (x === void 0) x = 0;
|
|
1945
1286
|
if (y === void 0) y = 0;
|
|
1946
1287
|
if (z === void 0) z = 0;
|
|
@@ -1950,7 +1291,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1950
1291
|
this._y = y;
|
|
1951
1292
|
this._z = z;
|
|
1952
1293
|
this._w = w;
|
|
1953
|
-
}
|
|
1294
|
+
}
|
|
1954
1295
|
var _proto = Quaternion.prototype;
|
|
1955
1296
|
/**
|
|
1956
1297
|
* Set the value of this quaternion, and return this quaternion.
|
|
@@ -1964,7 +1305,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1964
1305
|
this._y = y;
|
|
1965
1306
|
this._z = z;
|
|
1966
1307
|
this._w = w;
|
|
1967
|
-
this._onValueChanged
|
|
1308
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
1968
1309
|
return this;
|
|
1969
1310
|
};
|
|
1970
1311
|
/**
|
|
@@ -1974,7 +1315,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1974
1315
|
this._x *= -1;
|
|
1975
1316
|
this._y *= -1;
|
|
1976
1317
|
this._z *= -1;
|
|
1977
|
-
this._onValueChanged
|
|
1318
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
1978
1319
|
return this;
|
|
1979
1320
|
};
|
|
1980
1321
|
/**
|
|
@@ -2005,7 +1346,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2005
1346
|
this._y = 0;
|
|
2006
1347
|
this._z = 0;
|
|
2007
1348
|
this._w = 1;
|
|
2008
|
-
this._onValueChanged
|
|
1349
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2009
1350
|
return this;
|
|
2010
1351
|
};
|
|
2011
1352
|
/**
|
|
@@ -2038,7 +1379,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2038
1379
|
var t = out._x;
|
|
2039
1380
|
out._x = out._y;
|
|
2040
1381
|
out._y = t;
|
|
2041
|
-
out._onValueChanged
|
|
1382
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2042
1383
|
return out;
|
|
2043
1384
|
};
|
|
2044
1385
|
/**
|
|
@@ -2047,7 +1388,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2047
1388
|
* @returns Euler x->yaw y->pitch z->roll
|
|
2048
1389
|
*/ _proto.toYawPitchRoll = function toYawPitchRoll(out) {
|
|
2049
1390
|
this._toYawPitchRoll(out);
|
|
2050
|
-
out._onValueChanged
|
|
1391
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2051
1392
|
return out;
|
|
2052
1393
|
};
|
|
2053
1394
|
/**
|
|
@@ -2139,10 +1480,21 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2139
1480
|
this._y = source.y;
|
|
2140
1481
|
this._z = source.z;
|
|
2141
1482
|
this._w = source.w;
|
|
2142
|
-
this._onValueChanged
|
|
1483
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2143
1484
|
return this;
|
|
2144
1485
|
};
|
|
2145
1486
|
/**
|
|
1487
|
+
* Copy this quaternion to the specified quaternion.
|
|
1488
|
+
* @param target - The specified quaternion
|
|
1489
|
+
* @returns This specified quaternion
|
|
1490
|
+
*/ _proto.copyTo = function copyTo(target) {
|
|
1491
|
+
target.x = this._x;
|
|
1492
|
+
target.y = this._y;
|
|
1493
|
+
target.z = this._z;
|
|
1494
|
+
target.w = this._w;
|
|
1495
|
+
return target;
|
|
1496
|
+
};
|
|
1497
|
+
/**
|
|
2146
1498
|
* Copy the value of this quaternion from an array.
|
|
2147
1499
|
* @param array - The array
|
|
2148
1500
|
* @param offset - The start offset of the array
|
|
@@ -2153,7 +1505,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2153
1505
|
this._y = array[offset + 1];
|
|
2154
1506
|
this._z = array[offset + 2];
|
|
2155
1507
|
this._w = array[offset + 3];
|
|
2156
|
-
this._onValueChanged
|
|
1508
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2157
1509
|
return this;
|
|
2158
1510
|
};
|
|
2159
1511
|
/**
|
|
@@ -2211,7 +1563,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2211
1563
|
out._y = left._y + right._y;
|
|
2212
1564
|
out._z = left._z + right._z;
|
|
2213
1565
|
out._w = left._w + right._w;
|
|
2214
|
-
out._onValueChanged
|
|
1566
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2215
1567
|
};
|
|
2216
1568
|
/**
|
|
2217
1569
|
* Determines the product of two quaternions.
|
|
@@ -2225,7 +1577,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2225
1577
|
out._y = ay * bw + aw * by + az * bx - ax * bz;
|
|
2226
1578
|
out._z = az * bw + aw * bz + ax * by - ay * bx;
|
|
2227
1579
|
out._w = aw * bw - ax * bx - ay * by - az * bz;
|
|
2228
|
-
out._onValueChanged
|
|
1580
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2229
1581
|
};
|
|
2230
1582
|
/**
|
|
2231
1583
|
* Calculate quaternion that contains conjugated version of the specified quaternion.
|
|
@@ -2236,7 +1588,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2236
1588
|
out._y = -a._y;
|
|
2237
1589
|
out._z = -a._z;
|
|
2238
1590
|
out._w = a._w;
|
|
2239
|
-
out._onValueChanged
|
|
1591
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2240
1592
|
};
|
|
2241
1593
|
/**
|
|
2242
1594
|
* Determines the dot product of two quaternions.
|
|
@@ -2268,7 +1620,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2268
1620
|
out._y = normalAxis._y * s;
|
|
2269
1621
|
out._z = normalAxis._z * s;
|
|
2270
1622
|
out._w = Math.cos(rad);
|
|
2271
|
-
out._onValueChanged
|
|
1623
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2272
1624
|
};
|
|
2273
1625
|
/**
|
|
2274
1626
|
* Calculate a quaternion rotates around x, y, z axis (pitch/yaw/roll).
|
|
@@ -2301,7 +1653,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2301
1653
|
out._y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
|
|
2302
1654
|
out._z = cosYawPitch * sinRoll - sinYawPitch * cosRoll;
|
|
2303
1655
|
out._w = cosYawPitch * cosRoll + sinYawPitch * sinRoll;
|
|
2304
|
-
out._onValueChanged
|
|
1656
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2305
1657
|
};
|
|
2306
1658
|
/**
|
|
2307
1659
|
* Calculate a quaternion from the specified 3x3 matrix.
|
|
@@ -2343,7 +1695,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2343
1695
|
out._z = 0.5 * sqrt;
|
|
2344
1696
|
out._w = (m12 - m21) * half;
|
|
2345
1697
|
}
|
|
2346
|
-
out._onValueChanged
|
|
1698
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2347
1699
|
};
|
|
2348
1700
|
/**
|
|
2349
1701
|
* Calculate the inverse of the specified quaternion.
|
|
@@ -2358,7 +1710,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2358
1710
|
out._y = -y * invDot;
|
|
2359
1711
|
out._z = -z * invDot;
|
|
2360
1712
|
out._w = w * invDot;
|
|
2361
|
-
out._onValueChanged
|
|
1713
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2362
1714
|
}
|
|
2363
1715
|
};
|
|
2364
1716
|
/**
|
|
@@ -2405,7 +1757,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2405
1757
|
out.y = inverse * start.y + opposite * end.y;
|
|
2406
1758
|
out.z = inverse * start.z + opposite * end.z;
|
|
2407
1759
|
out.w = inverse * start.w + opposite * end.w;
|
|
2408
|
-
out._onValueChanged
|
|
1760
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2409
1761
|
};
|
|
2410
1762
|
/**
|
|
2411
1763
|
* Scales the specified quaternion magnitude to unit length.
|
|
@@ -2420,7 +1772,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2420
1772
|
out._y = _y * len;
|
|
2421
1773
|
out._z = _z * len;
|
|
2422
1774
|
out._w = _w * len;
|
|
2423
|
-
out._onValueChanged
|
|
1775
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2424
1776
|
}
|
|
2425
1777
|
};
|
|
2426
1778
|
/**
|
|
@@ -2435,7 +1787,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2435
1787
|
out._y = 0;
|
|
2436
1788
|
out._z = 0;
|
|
2437
1789
|
out._w = c;
|
|
2438
|
-
out._onValueChanged
|
|
1790
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2439
1791
|
};
|
|
2440
1792
|
/**
|
|
2441
1793
|
* Calculate a quaternion rotate around Y axis.
|
|
@@ -2449,7 +1801,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2449
1801
|
out._y = s;
|
|
2450
1802
|
out._z = 0;
|
|
2451
1803
|
out._w = c;
|
|
2452
|
-
out._onValueChanged
|
|
1804
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2453
1805
|
};
|
|
2454
1806
|
/**
|
|
2455
1807
|
* Calculate a quaternion rotate around Z axis.
|
|
@@ -2463,7 +1815,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2463
1815
|
out._y = 0;
|
|
2464
1816
|
out._z = s;
|
|
2465
1817
|
out._w = c;
|
|
2466
|
-
out._onValueChanged
|
|
1818
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2467
1819
|
};
|
|
2468
1820
|
/**
|
|
2469
1821
|
* Calculate a quaternion that the specified quaternion rotate around X axis.
|
|
@@ -2479,7 +1831,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2479
1831
|
out._y = _y * bw + _z * bx;
|
|
2480
1832
|
out._z = _z * bw - _y * bx;
|
|
2481
1833
|
out._w = _w * bw - _x * bx;
|
|
2482
|
-
out._onValueChanged
|
|
1834
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2483
1835
|
};
|
|
2484
1836
|
/**
|
|
2485
1837
|
* Calculate a quaternion that the specified quaternion rotate around Y axis.
|
|
@@ -2495,7 +1847,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2495
1847
|
out._y = _y * bw + _w * by;
|
|
2496
1848
|
out._z = _z * bw + _x * by;
|
|
2497
1849
|
out._w = _w * bw - _y * by;
|
|
2498
|
-
out._onValueChanged
|
|
1850
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2499
1851
|
};
|
|
2500
1852
|
/**
|
|
2501
1853
|
* Calculate a quaternion that the specified quaternion rotate around Z axis.
|
|
@@ -2511,7 +1863,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2511
1863
|
out._y = _y * bw - _x * bz;
|
|
2512
1864
|
out._z = _z * bw + _w * bz;
|
|
2513
1865
|
out._w = _w * bw - _z * bz;
|
|
2514
|
-
out._onValueChanged
|
|
1866
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2515
1867
|
};
|
|
2516
1868
|
/**
|
|
2517
1869
|
* Scale a quaternion by a given number.
|
|
@@ -2523,7 +1875,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2523
1875
|
out._y = a._y * s;
|
|
2524
1876
|
out._z = a._z * s;
|
|
2525
1877
|
out._w = a._w * s;
|
|
2526
|
-
out._onValueChanged
|
|
1878
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2527
1879
|
};
|
|
2528
1880
|
_create_class(Quaternion, [
|
|
2529
1881
|
{
|
|
@@ -2535,7 +1887,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2535
1887
|
},
|
|
2536
1888
|
set: function set(value) {
|
|
2537
1889
|
this._x = value;
|
|
2538
|
-
this._onValueChanged
|
|
1890
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2539
1891
|
}
|
|
2540
1892
|
},
|
|
2541
1893
|
{
|
|
@@ -2547,7 +1899,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2547
1899
|
},
|
|
2548
1900
|
set: function set(value) {
|
|
2549
1901
|
this._y = value;
|
|
2550
|
-
this._onValueChanged
|
|
1902
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2551
1903
|
}
|
|
2552
1904
|
},
|
|
2553
1905
|
{
|
|
@@ -2559,7 +1911,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2559
1911
|
},
|
|
2560
1912
|
set: function set(value) {
|
|
2561
1913
|
this._z = value;
|
|
2562
|
-
this._onValueChanged
|
|
1914
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2563
1915
|
}
|
|
2564
1916
|
},
|
|
2565
1917
|
{
|
|
@@ -2579,22 +1931,18 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2579
1931
|
},
|
|
2580
1932
|
set: function set(value) {
|
|
2581
1933
|
this._w = value;
|
|
2582
|
-
this._onValueChanged
|
|
1934
|
+
this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
|
|
2583
1935
|
}
|
|
2584
1936
|
}
|
|
2585
1937
|
]);
|
|
2586
1938
|
return Quaternion;
|
|
2587
1939
|
}();
|
|
2588
|
-
(
|
|
2589
|
-
|
|
2590
|
-
})();
|
|
2591
|
-
(function() {
|
|
2592
|
-
/** @internal */ Quaternion._tempQuat1 = new Quaternion();
|
|
2593
|
-
})();
|
|
1940
|
+
/** @internal */ Quaternion._tempVector3 = new Vector3();
|
|
1941
|
+
/** @internal */ Quaternion._tempQuat1 = new Quaternion();
|
|
2594
1942
|
/**
|
|
2595
1943
|
* Represents a 4x4 mathematical matrix.
|
|
2596
1944
|
*/ var Matrix = /*#__PURE__*/ function() {
|
|
2597
|
-
|
|
1945
|
+
function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
|
|
2598
1946
|
if (m11 === void 0) m11 = 1;
|
|
2599
1947
|
if (m12 === void 0) m12 = 0;
|
|
2600
1948
|
if (m13 === void 0) m13 = 0;
|
|
@@ -2638,7 +1986,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2638
1986
|
e[13] = m42;
|
|
2639
1987
|
e[14] = m43;
|
|
2640
1988
|
e[15] = m44;
|
|
2641
|
-
}
|
|
1989
|
+
}
|
|
2642
1990
|
var _proto = Matrix.prototype;
|
|
2643
1991
|
/**
|
|
2644
1992
|
* Set the value of this matrix, and return this matrix.
|
|
@@ -2788,7 +2136,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2788
2136
|
out._y = (e[6] + e[9]) / s3;
|
|
2789
2137
|
out._z = 0.25 * s3;
|
|
2790
2138
|
}
|
|
2791
|
-
out._onValueChanged
|
|
2139
|
+
out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
|
|
2792
2140
|
return out;
|
|
2793
2141
|
};
|
|
2794
2142
|
/**
|
|
@@ -3530,877 +2878,107 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3530
2878
|
};
|
|
3531
2879
|
return Matrix;
|
|
3532
2880
|
}();
|
|
3533
|
-
(
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
(
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
(
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
/**
|
|
3549
|
-
* Describes a 2D-vector.
|
|
3550
|
-
*/ var Vector2 = /*#__PURE__*/ function() {
|
|
3551
|
-
var Vector2 = function Vector2(x, y) {
|
|
3552
|
-
if (x === void 0) x = 0;
|
|
3553
|
-
if (y === void 0) y = 0;
|
|
3554
|
-
/** @internal */ this._onValueChanged = null;
|
|
3555
|
-
this._x = x;
|
|
3556
|
-
this._y = y;
|
|
3557
|
-
};
|
|
3558
|
-
var _proto = Vector2.prototype;
|
|
3559
|
-
/**
|
|
3560
|
-
* Set the value of this vector.
|
|
3561
|
-
* @param x - The x component of the vector
|
|
3562
|
-
* @param y - The y component of the vector
|
|
3563
|
-
* @returns This vector
|
|
3564
|
-
*/ _proto.set = function set(x, y) {
|
|
3565
|
-
this._x = x;
|
|
3566
|
-
this._y = y;
|
|
3567
|
-
this._onValueChanged && this._onValueChanged();
|
|
3568
|
-
return this;
|
|
2881
|
+
Matrix._tempVec30 = new Vector3();
|
|
2882
|
+
Matrix._tempVec31 = new Vector3();
|
|
2883
|
+
Matrix._tempVec32 = new Vector3();
|
|
2884
|
+
Matrix._tempMat30 = new Matrix3x3();
|
|
2885
|
+
/** @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);
|
|
2886
|
+
|
|
2887
|
+
var WebXRFrame = /*#__PURE__*/ function() {
|
|
2888
|
+
function WebXRFrame(session) {
|
|
2889
|
+
this._session = session;
|
|
2890
|
+
}
|
|
2891
|
+
var _proto = WebXRFrame.prototype;
|
|
2892
|
+
_proto.updateInputs = function updateInputs(inputs) {
|
|
2893
|
+
if (!this._platformFrame) return;
|
|
2894
|
+
this._updateController(inputs);
|
|
2895
|
+
this._updateCamera(inputs);
|
|
3569
2896
|
};
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
2897
|
+
_proto._updateController = function _updateController(inputs) {
|
|
2898
|
+
var _this = this, frame = _this._platformFrame;
|
|
2899
|
+
var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
|
|
2900
|
+
var inputSources = session.inputSources;
|
|
2901
|
+
for(var i = 0, n = inputSources.length; i < n; i++){
|
|
2902
|
+
var inputSource = inputSources[i];
|
|
2903
|
+
var type = getInputSource(inputSource);
|
|
2904
|
+
var input = inputs[type];
|
|
2905
|
+
switch(inputSource.targetRayMode){
|
|
2906
|
+
case "screen":
|
|
2907
|
+
case "tracked-pointer":
|
|
2908
|
+
var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
|
|
2909
|
+
if (gripSpace) {
|
|
2910
|
+
var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
|
|
2911
|
+
if (transform) {
|
|
2912
|
+
var gripPose = input.gripPose;
|
|
2913
|
+
gripPose.matrix.copyFromArray(transform.matrix);
|
|
2914
|
+
gripPose.position.copyFrom(transform.position);
|
|
2915
|
+
gripPose.rotation.copyFrom(transform.orientation);
|
|
2916
|
+
}
|
|
2917
|
+
input.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2918
|
+
}
|
|
2919
|
+
if (targetRaySpace) {
|
|
2920
|
+
var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
|
|
2921
|
+
if (transform1) {
|
|
2922
|
+
var targetRayPose = input.targetRayPose;
|
|
2923
|
+
targetRayPose.matrix.copyFromArray(transform1.matrix);
|
|
2924
|
+
targetRayPose.position.copyFrom(transform1.position);
|
|
2925
|
+
targetRayPose.rotation.copyFrom(transform1.orientation);
|
|
2926
|
+
input.trackingState = emulatedPosition1 ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
break;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
3579
2932
|
};
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
this._y = -this._y;
|
|
3630
|
-
this._onValueChanged && this._onValueChanged();
|
|
3631
|
-
return this;
|
|
3632
|
-
};
|
|
3633
|
-
/**
|
|
3634
|
-
* Converts this vector into a unit vector.
|
|
3635
|
-
* @returns This vector
|
|
3636
|
-
*/ _proto.normalize = function normalize() {
|
|
3637
|
-
Vector2.normalize(this, this);
|
|
3638
|
-
return this;
|
|
3639
|
-
};
|
|
3640
|
-
/**
|
|
3641
|
-
* Scale this vector by the given value.
|
|
3642
|
-
* @param s - The amount by which to scale the vector
|
|
3643
|
-
* @returns This vector
|
|
3644
|
-
*/ _proto.scale = function scale(s) {
|
|
3645
|
-
this._x *= s;
|
|
3646
|
-
this._y *= s;
|
|
3647
|
-
this._onValueChanged && this._onValueChanged();
|
|
3648
|
-
return this;
|
|
3649
|
-
};
|
|
3650
|
-
/**
|
|
3651
|
-
* Creates a clone of this vector.
|
|
3652
|
-
* @returns A clone of this vector
|
|
3653
|
-
*/ _proto.clone = function clone() {
|
|
3654
|
-
return new Vector2(this._x, this._y);
|
|
3655
|
-
};
|
|
3656
|
-
/**
|
|
3657
|
-
* Copy from vector2 like object.
|
|
3658
|
-
* @param source - Vector2 like object
|
|
3659
|
-
* @returns This vector
|
|
3660
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
3661
|
-
this._x = source.x;
|
|
3662
|
-
this._y = source.y;
|
|
3663
|
-
this._onValueChanged && this._onValueChanged();
|
|
3664
|
-
return this;
|
|
3665
|
-
};
|
|
3666
|
-
/**
|
|
3667
|
-
* Copy the value of this vector from an array.
|
|
3668
|
-
* @param array - The array
|
|
3669
|
-
* @param offset - The start offset of the array
|
|
3670
|
-
* @returns This vector
|
|
3671
|
-
*/ _proto.copyFromArray = function copyFromArray(array, offset) {
|
|
3672
|
-
if (offset === void 0) offset = 0;
|
|
3673
|
-
this._x = array[offset];
|
|
3674
|
-
this._y = array[offset + 1];
|
|
3675
|
-
this._onValueChanged && this._onValueChanged();
|
|
3676
|
-
return this;
|
|
3677
|
-
};
|
|
3678
|
-
/**
|
|
3679
|
-
* Copy the value of this vector to an array.
|
|
3680
|
-
* @param out - The array
|
|
3681
|
-
* @param outOffset - The start offset of the array
|
|
3682
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
3683
|
-
if (outOffset === void 0) outOffset = 0;
|
|
3684
|
-
out[outOffset] = this._x;
|
|
3685
|
-
out[outOffset + 1] = this._y;
|
|
3686
|
-
};
|
|
3687
|
-
/**
|
|
3688
|
-
* Serialize this vector to a JSON representation.
|
|
3689
|
-
* @returns A JSON representation of this vector
|
|
3690
|
-
*/ _proto.toJSON = function toJSON() {
|
|
3691
|
-
return {
|
|
3692
|
-
x: this._x,
|
|
3693
|
-
y: this._y
|
|
3694
|
-
};
|
|
3695
|
-
};
|
|
3696
|
-
/**
|
|
3697
|
-
* Determines the sum of two vectors.
|
|
3698
|
-
* @param left - The first vector to add
|
|
3699
|
-
* @param right - The second vector to add
|
|
3700
|
-
* @param out - The sum of two vectors
|
|
3701
|
-
*/ Vector2.add = function add(left, right, out) {
|
|
3702
|
-
out._x = left._x + right._x;
|
|
3703
|
-
out._y = left._y + right._y;
|
|
3704
|
-
out._onValueChanged && out._onValueChanged();
|
|
3705
|
-
};
|
|
3706
|
-
/**
|
|
3707
|
-
* Determines the difference between two vectors.
|
|
3708
|
-
* @param left - The first vector to subtract
|
|
3709
|
-
* @param right - The second vector to subtract
|
|
3710
|
-
* @param out - The difference between two vectors
|
|
3711
|
-
*/ Vector2.subtract = function subtract(left, right, out) {
|
|
3712
|
-
out._x = left._x - right._x;
|
|
3713
|
-
out._y = left._y - right._y;
|
|
3714
|
-
out._onValueChanged && out._onValueChanged();
|
|
3715
|
-
};
|
|
3716
|
-
/**
|
|
3717
|
-
* Determines the product of two vectors.
|
|
3718
|
-
* @param left - The first vector to multiply
|
|
3719
|
-
* @param right - The second vector to multiply
|
|
3720
|
-
* @param out - The product of two vectors
|
|
3721
|
-
*/ Vector2.multiply = function multiply(left, right, out) {
|
|
3722
|
-
out._x = left._x * right._x;
|
|
3723
|
-
out._y = left._y * right._y;
|
|
3724
|
-
out._onValueChanged && out._onValueChanged();
|
|
3725
|
-
};
|
|
3726
|
-
/**
|
|
3727
|
-
* Determines the divisor of two vectors.
|
|
3728
|
-
* @param left - The first vector to divide
|
|
3729
|
-
* @param right - The second vector to divide
|
|
3730
|
-
* @param out - The divisor of two vectors
|
|
3731
|
-
*/ Vector2.divide = function divide(left, right, out) {
|
|
3732
|
-
out._x = left._x / right._x;
|
|
3733
|
-
out._y = left._y / right._y;
|
|
3734
|
-
out._onValueChanged && out._onValueChanged();
|
|
3735
|
-
};
|
|
3736
|
-
/**
|
|
3737
|
-
* Determines the dot product of two vectors.
|
|
3738
|
-
* @param left - The first vector to dot
|
|
3739
|
-
* @param right - The second vector to dot
|
|
3740
|
-
* @returns The dot product of two vectors
|
|
3741
|
-
*/ Vector2.dot = function dot(left, right) {
|
|
3742
|
-
return left._x * right._x + left._y * right._y;
|
|
3743
|
-
};
|
|
3744
|
-
/**
|
|
3745
|
-
* Determines the distance of two vectors.
|
|
3746
|
-
* @param left - The first vector
|
|
3747
|
-
* @param right - The second vector
|
|
3748
|
-
* @returns The distance of two vectors
|
|
3749
|
-
*/ Vector2.distance = function distance(left, right) {
|
|
3750
|
-
var x = right._x - left._x;
|
|
3751
|
-
var y = right._y - left._y;
|
|
3752
|
-
return Math.sqrt(x * x + y * y);
|
|
3753
|
-
};
|
|
3754
|
-
/**
|
|
3755
|
-
* Determines the squared distance of two vectors.
|
|
3756
|
-
* @param left - The first vector
|
|
3757
|
-
* @param right - The second vector
|
|
3758
|
-
* @returns The squared distance of two vectors
|
|
3759
|
-
*/ Vector2.distanceSquared = function distanceSquared(left, right) {
|
|
3760
|
-
var x = right._x - left._x;
|
|
3761
|
-
var y = right._y - left._y;
|
|
3762
|
-
return x * x + y * y;
|
|
3763
|
-
};
|
|
3764
|
-
/**
|
|
3765
|
-
* Determines whether the specified vectors are equals.
|
|
3766
|
-
* @param left - The first vector to compare
|
|
3767
|
-
* @param right - The second vector to compare
|
|
3768
|
-
* @returns True if the specified vectors are equals, false otherwise
|
|
3769
|
-
*/ Vector2.equals = function equals(left, right) {
|
|
3770
|
-
return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y);
|
|
3771
|
-
};
|
|
3772
|
-
/**
|
|
3773
|
-
* Performs a linear interpolation between two vectors.
|
|
3774
|
-
* @param left - The first vector
|
|
3775
|
-
* @param right - The second vector
|
|
3776
|
-
* @param t - The blend amount where 0 returns left and 1 right
|
|
3777
|
-
* @param out - The result of linear blending between two vectors
|
|
3778
|
-
*/ Vector2.lerp = function lerp(left, right, t, out) {
|
|
3779
|
-
var _x = left._x, _y = left._y;
|
|
3780
|
-
out._x = _x + (right._x - _x) * t;
|
|
3781
|
-
out._y = _y + (right._y - _y) * t;
|
|
3782
|
-
out._onValueChanged && out._onValueChanged();
|
|
3783
|
-
};
|
|
3784
|
-
/**
|
|
3785
|
-
* Calculate a vector containing the largest components of the specified vectors.
|
|
3786
|
-
* @param left - The first vector
|
|
3787
|
-
* @param right - The second vector
|
|
3788
|
-
* @param out - The vector containing the largest components of the specified vectors
|
|
3789
|
-
*/ Vector2.max = function max(left, right, out) {
|
|
3790
|
-
out._x = Math.max(left._x, right._x);
|
|
3791
|
-
out._y = Math.max(left._y, right._y);
|
|
3792
|
-
out._onValueChanged && out._onValueChanged();
|
|
3793
|
-
};
|
|
3794
|
-
/**
|
|
3795
|
-
* Calculate a vector containing the smallest components of the specified vectors.
|
|
3796
|
-
* @param left - The first vector
|
|
3797
|
-
* @param right - The second vector
|
|
3798
|
-
* @param out - The vector containing the smallest components of the specified vectors
|
|
3799
|
-
*/ Vector2.min = function min(left, right, out) {
|
|
3800
|
-
out._x = Math.min(left._x, right._x);
|
|
3801
|
-
out._y = Math.min(left._y, right._y);
|
|
3802
|
-
out._onValueChanged && out._onValueChanged();
|
|
3803
|
-
};
|
|
3804
|
-
/**
|
|
3805
|
-
* Reverses the direction of a given vector.
|
|
3806
|
-
* @param left - The vector to negate
|
|
3807
|
-
* @param out - The vector facing in the opposite direction
|
|
3808
|
-
*/ Vector2.negate = function negate(left, out) {
|
|
3809
|
-
out._x = -left._x;
|
|
3810
|
-
out._y = -left._y;
|
|
3811
|
-
out._onValueChanged && out._onValueChanged();
|
|
3812
|
-
};
|
|
3813
|
-
/**
|
|
3814
|
-
* Converts the vector into a unit vector.
|
|
3815
|
-
* @param left - The vector to normalize
|
|
3816
|
-
* @param out - The normalized vector
|
|
3817
|
-
*/ Vector2.normalize = function normalize(left, out) {
|
|
3818
|
-
var _x = left._x, _y = left._y;
|
|
3819
|
-
var len = Math.sqrt(_x * _x + _y * _y);
|
|
3820
|
-
if (len > MathUtil.zeroTolerance) {
|
|
3821
|
-
len = 1 / len;
|
|
3822
|
-
out._x = _x * len;
|
|
3823
|
-
out._y = _y * len;
|
|
3824
|
-
out._onValueChanged && out._onValueChanged();
|
|
3825
|
-
}
|
|
3826
|
-
};
|
|
3827
|
-
/**
|
|
3828
|
-
* Scale a vector by the given value.
|
|
3829
|
-
* @param left - The vector to scale
|
|
3830
|
-
* @param s - The amount by which to scale the vector
|
|
3831
|
-
* @param out - The scaled vector
|
|
3832
|
-
*/ Vector2.scale = function scale(left, s, out) {
|
|
3833
|
-
out._x = left._x * s;
|
|
3834
|
-
out._y = left._y * s;
|
|
3835
|
-
out._onValueChanged && out._onValueChanged();
|
|
3836
|
-
};
|
|
3837
|
-
_create_class(Vector2, [
|
|
3838
|
-
{
|
|
3839
|
-
key: "x",
|
|
3840
|
-
get: /**
|
|
3841
|
-
* The x component of the vector.
|
|
3842
|
-
*/ function get() {
|
|
3843
|
-
return this._x;
|
|
3844
|
-
},
|
|
3845
|
-
set: function set(value) {
|
|
3846
|
-
this._x = value;
|
|
3847
|
-
this._onValueChanged && this._onValueChanged();
|
|
3848
|
-
}
|
|
3849
|
-
},
|
|
3850
|
-
{
|
|
3851
|
-
key: "y",
|
|
3852
|
-
get: /**
|
|
3853
|
-
* The y component of the vector.
|
|
3854
|
-
*/ function get() {
|
|
3855
|
-
return this._y;
|
|
3856
|
-
},
|
|
3857
|
-
set: function set(value) {
|
|
3858
|
-
this._y = value;
|
|
3859
|
-
this._onValueChanged && this._onValueChanged();
|
|
3860
|
-
}
|
|
3861
|
-
}
|
|
3862
|
-
]);
|
|
3863
|
-
return Vector2;
|
|
3864
|
-
}();
|
|
3865
|
-
(function() {
|
|
3866
|
-
/** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
|
|
3867
|
-
})();
|
|
3868
|
-
(function() {
|
|
3869
|
-
/** @internal */ Vector2._one = new Vector2(1.0, 1.0);
|
|
3870
|
-
})();
|
|
3871
|
-
/**
|
|
3872
|
-
* Describes a 4D-vector.
|
|
3873
|
-
*/ var Vector4 = /*#__PURE__*/ function() {
|
|
3874
|
-
var Vector4 = function Vector4(x, y, z, w) {
|
|
3875
|
-
if (x === void 0) x = 0;
|
|
3876
|
-
if (y === void 0) y = 0;
|
|
3877
|
-
if (z === void 0) z = 0;
|
|
3878
|
-
if (w === void 0) w = 0;
|
|
3879
|
-
/** @internal */ this._onValueChanged = null;
|
|
3880
|
-
this._x = x;
|
|
3881
|
-
this._y = y;
|
|
3882
|
-
this._z = z;
|
|
3883
|
-
this._w = w;
|
|
3884
|
-
};
|
|
3885
|
-
var _proto = Vector4.prototype;
|
|
3886
|
-
/**
|
|
3887
|
-
* Set the value of this vector.
|
|
3888
|
-
* @param x - The x component of the vector
|
|
3889
|
-
* @param y - The y component of the vector
|
|
3890
|
-
* @param z - The z component of the vector
|
|
3891
|
-
* @param w - The w component of the vector
|
|
3892
|
-
* @returns This vector
|
|
3893
|
-
*/ _proto.set = function set(x, y, z, w) {
|
|
3894
|
-
this._x = x;
|
|
3895
|
-
this._y = y;
|
|
3896
|
-
this._z = z;
|
|
3897
|
-
this._w = w;
|
|
3898
|
-
this._onValueChanged && this._onValueChanged();
|
|
3899
|
-
return this;
|
|
3900
|
-
};
|
|
3901
|
-
/**
|
|
3902
|
-
* Determines the sum of this vector and the specified vector.
|
|
3903
|
-
* @param right - The specified vector
|
|
3904
|
-
* @returns This vector
|
|
3905
|
-
*/ _proto.add = function add(right) {
|
|
3906
|
-
this._x += right._x;
|
|
3907
|
-
this._y += right._y;
|
|
3908
|
-
this._z += right._z;
|
|
3909
|
-
this._w += right._w;
|
|
3910
|
-
this._onValueChanged && this._onValueChanged();
|
|
3911
|
-
return this;
|
|
3912
|
-
};
|
|
3913
|
-
/**
|
|
3914
|
-
* Determines the difference of this vector and the specified vector.
|
|
3915
|
-
* @param right - the specified vector
|
|
3916
|
-
* @returns This vector
|
|
3917
|
-
*/ _proto.subtract = function subtract(right) {
|
|
3918
|
-
this._x -= right._x;
|
|
3919
|
-
this._y -= right._y;
|
|
3920
|
-
this._z -= right._z;
|
|
3921
|
-
this._w -= right._w;
|
|
3922
|
-
this._onValueChanged && this._onValueChanged();
|
|
3923
|
-
return this;
|
|
3924
|
-
};
|
|
3925
|
-
/**
|
|
3926
|
-
* Determines the product of this vector and the specified vector.
|
|
3927
|
-
* @param right - the specified vector
|
|
3928
|
-
* @returns This vector
|
|
3929
|
-
*/ _proto.multiply = function multiply(right) {
|
|
3930
|
-
this._x *= right._x;
|
|
3931
|
-
this._y *= right._y;
|
|
3932
|
-
this._z *= right._z;
|
|
3933
|
-
this._w *= right._w;
|
|
3934
|
-
this._onValueChanged && this._onValueChanged();
|
|
3935
|
-
return this;
|
|
3936
|
-
};
|
|
3937
|
-
/**
|
|
3938
|
-
* Determines the divisor of this vector and the specified vector.
|
|
3939
|
-
* @param right - the specified vector
|
|
3940
|
-
* @returns This vector
|
|
3941
|
-
*/ _proto.divide = function divide(right) {
|
|
3942
|
-
this._x /= right._x;
|
|
3943
|
-
this._y /= right._y;
|
|
3944
|
-
this._z /= right._z;
|
|
3945
|
-
this._w /= right._w;
|
|
3946
|
-
this._onValueChanged && this._onValueChanged();
|
|
3947
|
-
return this;
|
|
3948
|
-
};
|
|
3949
|
-
/**
|
|
3950
|
-
* Calculate the length of this vector.
|
|
3951
|
-
* @returns The length of this vector
|
|
3952
|
-
*/ _proto.length = function length() {
|
|
3953
|
-
var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
|
|
3954
|
-
return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
|
|
3955
|
-
};
|
|
3956
|
-
/**
|
|
3957
|
-
* Calculate the squared length of this vector.
|
|
3958
|
-
* @returns The squared length of this vector
|
|
3959
|
-
*/ _proto.lengthSquared = function lengthSquared() {
|
|
3960
|
-
var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
|
|
3961
|
-
return _x * _x + _y * _y + _z * _z + _w * _w;
|
|
3962
|
-
};
|
|
3963
|
-
/**
|
|
3964
|
-
* Reverses the direction of this vector.
|
|
3965
|
-
* @returns This vector
|
|
3966
|
-
*/ _proto.negate = function negate() {
|
|
3967
|
-
this._x = -this._x;
|
|
3968
|
-
this._y = -this._y;
|
|
3969
|
-
this._z = -this._z;
|
|
3970
|
-
this._w = -this._w;
|
|
3971
|
-
this._onValueChanged && this._onValueChanged();
|
|
3972
|
-
return this;
|
|
3973
|
-
};
|
|
3974
|
-
/**
|
|
3975
|
-
* Converts this vector into a unit vector.
|
|
3976
|
-
* @returns This vector
|
|
3977
|
-
*/ _proto.normalize = function normalize() {
|
|
3978
|
-
Vector4.normalize(this, this);
|
|
3979
|
-
return this;
|
|
3980
|
-
};
|
|
3981
|
-
/**
|
|
3982
|
-
* Scale this vector by the given value.
|
|
3983
|
-
* @param s - The amount by which to scale the vector
|
|
3984
|
-
* @returns This vector
|
|
3985
|
-
*/ _proto.scale = function scale(s) {
|
|
3986
|
-
this._x *= s;
|
|
3987
|
-
this._y *= s;
|
|
3988
|
-
this._z *= s;
|
|
3989
|
-
this._w *= s;
|
|
3990
|
-
this._onValueChanged && this._onValueChanged();
|
|
3991
|
-
return this;
|
|
3992
|
-
};
|
|
3993
|
-
/**
|
|
3994
|
-
* Creates a clone of this vector.
|
|
3995
|
-
* @returns A clone of this vector
|
|
3996
|
-
*/ _proto.clone = function clone() {
|
|
3997
|
-
var ret = new Vector4(this._x, this._y, this._z, this._w);
|
|
3998
|
-
return ret;
|
|
3999
|
-
};
|
|
4000
|
-
/**
|
|
4001
|
-
* Copy from vector3 like object.
|
|
4002
|
-
* @param source - Vector3 like object.
|
|
4003
|
-
* @returns This vector
|
|
4004
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
4005
|
-
this._x = source.x;
|
|
4006
|
-
this._y = source.y;
|
|
4007
|
-
this._z = source.z;
|
|
4008
|
-
this._w = source.w;
|
|
4009
|
-
this._onValueChanged && this._onValueChanged();
|
|
4010
|
-
return this;
|
|
4011
|
-
};
|
|
4012
|
-
/**
|
|
4013
|
-
* Copy the value of this vector by an array.
|
|
4014
|
-
* @param array - The array
|
|
4015
|
-
* @param offset - The start offset of the array
|
|
4016
|
-
* @returns This vector
|
|
4017
|
-
*/ _proto.copyFromArray = function copyFromArray(array, offset) {
|
|
4018
|
-
if (offset === void 0) offset = 0;
|
|
4019
|
-
this._x = array[offset];
|
|
4020
|
-
this._y = array[offset + 1];
|
|
4021
|
-
this._z = array[offset + 2];
|
|
4022
|
-
this._w = array[offset + 3];
|
|
4023
|
-
this._onValueChanged && this._onValueChanged();
|
|
4024
|
-
return this;
|
|
4025
|
-
};
|
|
4026
|
-
/**
|
|
4027
|
-
* Copy the value of this vector to an array.
|
|
4028
|
-
* @param out - The array
|
|
4029
|
-
* @param outOffset - The start offset of the array
|
|
4030
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
4031
|
-
if (outOffset === void 0) outOffset = 0;
|
|
4032
|
-
out[outOffset] = this._x;
|
|
4033
|
-
out[outOffset + 1] = this._y;
|
|
4034
|
-
out[outOffset + 2] = this._z;
|
|
4035
|
-
out[outOffset + 3] = this._w;
|
|
4036
|
-
};
|
|
4037
|
-
/**
|
|
4038
|
-
* Serialize this vector to a JSON representation.
|
|
4039
|
-
* @returns A JSON representation of this vector
|
|
4040
|
-
*/ _proto.toJSON = function toJSON() {
|
|
4041
|
-
return {
|
|
4042
|
-
x: this._x,
|
|
4043
|
-
y: this._y,
|
|
4044
|
-
z: this._z,
|
|
4045
|
-
w: this._w
|
|
4046
|
-
};
|
|
4047
|
-
};
|
|
4048
|
-
/**
|
|
4049
|
-
* Determines the sum of two vectors.
|
|
4050
|
-
* @param left - The first vector to add
|
|
4051
|
-
* @param right - The second vector to add
|
|
4052
|
-
* @param out - The sum of two vectors
|
|
4053
|
-
*/ Vector4.add = function add(left, right, out) {
|
|
4054
|
-
out._x = left._x + right._x;
|
|
4055
|
-
out._y = left._y + right._y;
|
|
4056
|
-
out._z = left._z + right._z;
|
|
4057
|
-
out._w = left._w + right._w;
|
|
4058
|
-
out._onValueChanged && out._onValueChanged();
|
|
4059
|
-
};
|
|
4060
|
-
/**
|
|
4061
|
-
* Determines the difference between two vectors.
|
|
4062
|
-
* @param left - The first vector to subtract
|
|
4063
|
-
* @param right - The second vector to subtract
|
|
4064
|
-
* @param out - The difference between two vectors
|
|
4065
|
-
*/ Vector4.subtract = function subtract(left, right, out) {
|
|
4066
|
-
out._x = left._x - right._x;
|
|
4067
|
-
out._y = left._y - right._y;
|
|
4068
|
-
out._z = left._z - right._z;
|
|
4069
|
-
out._w = left._w - right._w;
|
|
4070
|
-
out._onValueChanged && out._onValueChanged();
|
|
4071
|
-
};
|
|
4072
|
-
/**
|
|
4073
|
-
* Determines the product of two vectors.
|
|
4074
|
-
* @param left - The first vector to multiply
|
|
4075
|
-
* @param right - The second vector to multiply
|
|
4076
|
-
* @param out - The product of two vectors
|
|
4077
|
-
*/ Vector4.multiply = function multiply(left, right, out) {
|
|
4078
|
-
out._x = left._x * right._x;
|
|
4079
|
-
out._y = left._y * right._y;
|
|
4080
|
-
out._z = left._z * right._z;
|
|
4081
|
-
out._w = left._w * right._w;
|
|
4082
|
-
out._onValueChanged && out._onValueChanged();
|
|
4083
|
-
};
|
|
4084
|
-
/**
|
|
4085
|
-
* Determines the divisor of two vectors.
|
|
4086
|
-
* @param left - The first vector to divide
|
|
4087
|
-
* @param right - The second vector to divide
|
|
4088
|
-
* @param out - The divisor of two vectors
|
|
4089
|
-
*/ Vector4.divide = function divide(left, right, out) {
|
|
4090
|
-
out._x = left._x / right._x;
|
|
4091
|
-
out._y = left._y / right._y;
|
|
4092
|
-
out._z = left._z / right._z;
|
|
4093
|
-
out._w = left._w / right._w;
|
|
4094
|
-
out._onValueChanged && out._onValueChanged();
|
|
4095
|
-
};
|
|
4096
|
-
/**
|
|
4097
|
-
* Determines the dot product of two vectors.
|
|
4098
|
-
* @param left - The first vector to dot
|
|
4099
|
-
* @param right - The second vector to dot
|
|
4100
|
-
* @returns The dot product of two vectors
|
|
4101
|
-
*/ Vector4.dot = function dot(left, right) {
|
|
4102
|
-
return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
|
|
4103
|
-
};
|
|
4104
|
-
/**
|
|
4105
|
-
* Determines the distance of two vectors.
|
|
4106
|
-
* @param a - The first vector
|
|
4107
|
-
* @param b - The second vector
|
|
4108
|
-
* @returns The distance of two vectors
|
|
4109
|
-
*/ Vector4.distance = function distance(a, b) {
|
|
4110
|
-
var x = b._x - a._x;
|
|
4111
|
-
var y = b._y - a._y;
|
|
4112
|
-
var z = b._z - a._z;
|
|
4113
|
-
var w = b._w - a._w;
|
|
4114
|
-
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
4115
|
-
};
|
|
4116
|
-
/**
|
|
4117
|
-
* Determines the squared distance of two vectors.
|
|
4118
|
-
* @param a - The first vector
|
|
4119
|
-
* @param b - The second vector
|
|
4120
|
-
* @returns The squared distance of two vectors
|
|
4121
|
-
*/ Vector4.distanceSquared = function distanceSquared(a, b) {
|
|
4122
|
-
var x = b._x - a._x;
|
|
4123
|
-
var y = b._y - a._y;
|
|
4124
|
-
var z = b._z - a._z;
|
|
4125
|
-
var w = b._w - a._w;
|
|
4126
|
-
return x * x + y * y + z * z + w * w;
|
|
4127
|
-
};
|
|
4128
|
-
/**
|
|
4129
|
-
* Determines whether the specified vectors are equals.
|
|
4130
|
-
* @param left - The first vector to compare
|
|
4131
|
-
* @param right - The second vector to compare
|
|
4132
|
-
* @returns True if the specified vectors are equals, false otherwise
|
|
4133
|
-
*/ Vector4.equals = function equals(left, right) {
|
|
4134
|
-
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);
|
|
4135
|
-
};
|
|
4136
|
-
/**
|
|
4137
|
-
* Performs a linear interpolation between two vectors.
|
|
4138
|
-
* @param start - The first vector
|
|
4139
|
-
* @param end - The second vector
|
|
4140
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
4141
|
-
* @param out - The result of linear blending between two vectors
|
|
4142
|
-
*/ Vector4.lerp = function lerp(start, end, t, out) {
|
|
4143
|
-
var _x = start._x, _y = start._y, _z = start._z, _w = start._w;
|
|
4144
|
-
out._x = _x + (end._x - _x) * t;
|
|
4145
|
-
out._y = _y + (end._y - _y) * t;
|
|
4146
|
-
out._z = _z + (end._z - _z) * t;
|
|
4147
|
-
out._w = _w + (end._w - _w) * t;
|
|
4148
|
-
out._onValueChanged && out._onValueChanged();
|
|
4149
|
-
};
|
|
4150
|
-
/**
|
|
4151
|
-
* Calculate a vector containing the largest components of the specified vectors.
|
|
4152
|
-
* @param left - The first vector
|
|
4153
|
-
* @param right - The second vector
|
|
4154
|
-
* @param out - The vector containing the largest components of the specified vectors
|
|
4155
|
-
*/ Vector4.max = function max(left, right, out) {
|
|
4156
|
-
out._x = Math.max(left._x, right._x);
|
|
4157
|
-
out._y = Math.max(left._y, right._y);
|
|
4158
|
-
out._z = Math.max(left._z, right._z);
|
|
4159
|
-
out._w = Math.max(left._w, right._w);
|
|
4160
|
-
out._onValueChanged && out._onValueChanged();
|
|
4161
|
-
};
|
|
4162
|
-
/**
|
|
4163
|
-
* Calculate a vector containing the smallest components of the specified vectors.
|
|
4164
|
-
* @param left - The first vector
|
|
4165
|
-
* @param right - The second vector
|
|
4166
|
-
* @param out - The vector containing the smallest components of the specified vectors
|
|
4167
|
-
*/ Vector4.min = function min(left, right, out) {
|
|
4168
|
-
out._x = Math.min(left._x, right._x);
|
|
4169
|
-
out._y = Math.min(left._y, right._y);
|
|
4170
|
-
out._z = Math.min(left._z, right._z);
|
|
4171
|
-
out._w = Math.min(left._w, right._w);
|
|
4172
|
-
out._onValueChanged && out._onValueChanged();
|
|
4173
|
-
};
|
|
4174
|
-
/**
|
|
4175
|
-
* Reverses the direction of a given vector.
|
|
4176
|
-
* @param a - The vector to negate
|
|
4177
|
-
* @param out - The vector facing in the opposite direction
|
|
4178
|
-
*/ Vector4.negate = function negate(a, out) {
|
|
4179
|
-
out._x = -a._x;
|
|
4180
|
-
out._y = -a._y;
|
|
4181
|
-
out._z = -a._z;
|
|
4182
|
-
out._w = -a._w;
|
|
4183
|
-
out._onValueChanged && out._onValueChanged();
|
|
4184
|
-
};
|
|
4185
|
-
/**
|
|
4186
|
-
* Converts the vector into a unit vector.
|
|
4187
|
-
* @param a - The vector to normalize
|
|
4188
|
-
* @param out - The normalized vector
|
|
4189
|
-
*/ Vector4.normalize = function normalize(a, out) {
|
|
4190
|
-
var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
|
|
4191
|
-
var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
|
|
4192
|
-
if (len > MathUtil.zeroTolerance) {
|
|
4193
|
-
len = 1 / len;
|
|
4194
|
-
out._x = _x * len;
|
|
4195
|
-
out._y = _y * len;
|
|
4196
|
-
out._z = _z * len;
|
|
4197
|
-
out._w = _w * len;
|
|
4198
|
-
out._onValueChanged && out._onValueChanged();
|
|
4199
|
-
}
|
|
4200
|
-
};
|
|
4201
|
-
/**
|
|
4202
|
-
* Scale a vector by the given value.
|
|
4203
|
-
* @param a - The vector to scale
|
|
4204
|
-
* @param s - The amount by which to scale the vector
|
|
4205
|
-
* @param out - The scaled vector
|
|
4206
|
-
*/ Vector4.scale = function scale(a, s, out) {
|
|
4207
|
-
out._x = a._x * s;
|
|
4208
|
-
out._y = a._y * s;
|
|
4209
|
-
out._z = a._z * s;
|
|
4210
|
-
out._w = a._w * s;
|
|
4211
|
-
out._onValueChanged && out._onValueChanged();
|
|
4212
|
-
};
|
|
4213
|
-
/**
|
|
4214
|
-
* Performs a transformation using the given 4x4 matrix.
|
|
4215
|
-
* @param v - The vector to transform
|
|
4216
|
-
* @param m - The transform matrix
|
|
4217
|
-
* @param out - The transformed vector3
|
|
4218
|
-
*/ Vector4.transform = function transform(v, m, out) {
|
|
4219
|
-
var _x = v._x, _y = v._y, _z = v._z, _w = v._w;
|
|
4220
|
-
var e = m.elements;
|
|
4221
|
-
out._x = _x * e[0] + _y * e[4] + _z * e[8] + _w * e[12];
|
|
4222
|
-
out._y = _x * e[1] + _y * e[5] + _z * e[9] + _w * e[13];
|
|
4223
|
-
out._z = _x * e[2] + _y * e[6] + _z * e[10] + _w * e[14];
|
|
4224
|
-
out._w = _x * e[3] + _y * e[7] + _z * e[11] + _w * e[15];
|
|
4225
|
-
out._onValueChanged && out._onValueChanged();
|
|
4226
|
-
};
|
|
4227
|
-
/**
|
|
4228
|
-
* Performs a transformation using the given quaternion.
|
|
4229
|
-
* @param v - The vector to transform
|
|
4230
|
-
* @param q - The transform quaternion
|
|
4231
|
-
* @param out - The transformed vector
|
|
4232
|
-
*/ Vector4.transformByQuat = function transformByQuat(v, q, out) {
|
|
4233
|
-
var x = v._x, y = v._y, z = v._z, w = v._w;
|
|
4234
|
-
var qx = q._x;
|
|
4235
|
-
var qy = q._y;
|
|
4236
|
-
var qz = q._z;
|
|
4237
|
-
var qw = q._w;
|
|
4238
|
-
// calculate quat * vec
|
|
4239
|
-
var ix = qw * x + qy * z - qz * y;
|
|
4240
|
-
var iy = qw * y + qz * x - qx * z;
|
|
4241
|
-
var iz = qw * z + qx * y - qy * x;
|
|
4242
|
-
var iw = -qx * x - qy * y - qz * z;
|
|
4243
|
-
// calculate result * inverse quat
|
|
4244
|
-
out._x = ix * qw - iw * qx - iy * qz + iz * qy;
|
|
4245
|
-
out._y = iy * qw - iw * qy - iz * qx + ix * qz;
|
|
4246
|
-
out._z = iz * qw - iw * qz - ix * qy + iy * qx;
|
|
4247
|
-
out._w = w;
|
|
4248
|
-
out._onValueChanged && out._onValueChanged();
|
|
4249
|
-
};
|
|
4250
|
-
_create_class(Vector4, [
|
|
4251
|
-
{
|
|
4252
|
-
key: "x",
|
|
4253
|
-
get: /**
|
|
4254
|
-
* The x component of the vector.
|
|
4255
|
-
*/ function get() {
|
|
4256
|
-
return this._x;
|
|
4257
|
-
},
|
|
4258
|
-
set: function set(value) {
|
|
4259
|
-
this._x = value;
|
|
4260
|
-
this._onValueChanged && this._onValueChanged();
|
|
4261
|
-
}
|
|
4262
|
-
},
|
|
4263
|
-
{
|
|
4264
|
-
key: "y",
|
|
4265
|
-
get: /**
|
|
4266
|
-
* The y component of the vector.
|
|
4267
|
-
*/ function get() {
|
|
4268
|
-
return this._y;
|
|
4269
|
-
},
|
|
4270
|
-
set: function set(value) {
|
|
4271
|
-
this._y = value;
|
|
4272
|
-
this._onValueChanged && this._onValueChanged();
|
|
4273
|
-
}
|
|
4274
|
-
},
|
|
4275
|
-
{
|
|
4276
|
-
key: "z",
|
|
4277
|
-
get: /**
|
|
4278
|
-
* The z component of the vector.
|
|
4279
|
-
*/ function get() {
|
|
4280
|
-
return this._z;
|
|
4281
|
-
},
|
|
4282
|
-
set: function set(value) {
|
|
4283
|
-
this._z = value;
|
|
4284
|
-
this._onValueChanged && this._onValueChanged();
|
|
4285
|
-
}
|
|
4286
|
-
},
|
|
4287
|
-
{
|
|
4288
|
-
key: "w",
|
|
4289
|
-
get: /**
|
|
4290
|
-
* The w component of the vector.
|
|
4291
|
-
*/ function get() {
|
|
4292
|
-
return this._w;
|
|
4293
|
-
},
|
|
4294
|
-
set: function set(value) {
|
|
4295
|
-
this._w = value;
|
|
4296
|
-
this._onValueChanged && this._onValueChanged();
|
|
4297
|
-
}
|
|
4298
|
-
}
|
|
4299
|
-
]);
|
|
4300
|
-
return Vector4;
|
|
4301
|
-
}();
|
|
4302
|
-
(function() {
|
|
4303
|
-
/** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
4304
|
-
})();
|
|
4305
|
-
(function() {
|
|
4306
|
-
/** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
|
|
4307
|
-
})();
|
|
4308
|
-
|
|
4309
|
-
var WebXRFrame = /*#__PURE__*/ function() {
|
|
4310
|
-
function WebXRFrame(session) {
|
|
4311
|
-
this._session = session;
|
|
4312
|
-
}
|
|
4313
|
-
var _proto = WebXRFrame.prototype;
|
|
4314
|
-
_proto.updateInputs = function updateInputs(inputs) {
|
|
4315
|
-
if (!this._platformFrame) return;
|
|
4316
|
-
this._updateController(inputs);
|
|
4317
|
-
this._updateCamera(inputs);
|
|
4318
|
-
};
|
|
4319
|
-
_proto._updateController = function _updateController(inputs) {
|
|
4320
|
-
var _this = this, frame = _this._platformFrame;
|
|
4321
|
-
var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
|
|
4322
|
-
var inputSources = session.inputSources;
|
|
4323
|
-
for(var i = 0, n = inputSources.length; i < n; i++){
|
|
4324
|
-
var inputSource = inputSources[i];
|
|
4325
|
-
var type = getInputSource(inputSource);
|
|
4326
|
-
var input = inputs[type];
|
|
4327
|
-
switch(inputSource.targetRayMode){
|
|
4328
|
-
case "screen":
|
|
4329
|
-
case "tracked-pointer":
|
|
4330
|
-
var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
|
|
4331
|
-
if (gripSpace) {
|
|
4332
|
-
var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
|
|
4333
|
-
if (transform) {
|
|
4334
|
-
var gripPose = input.gripPose;
|
|
4335
|
-
gripPose.matrix.copyFromArray(transform.matrix);
|
|
4336
|
-
gripPose.position.copyFrom(transform.position);
|
|
4337
|
-
gripPose.rotation.copyFrom(transform.orientation);
|
|
4338
|
-
}
|
|
4339
|
-
input.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4340
|
-
}
|
|
4341
|
-
if (targetRaySpace) {
|
|
4342
|
-
var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
|
|
4343
|
-
if (transform1) {
|
|
4344
|
-
var targetRayPose = input.targetRayPose;
|
|
4345
|
-
targetRayPose.matrix.copyFromArray(transform1.matrix);
|
|
4346
|
-
targetRayPose.position.copyFrom(transform1.position);
|
|
4347
|
-
targetRayPose.rotation.copyFrom(transform1.orientation);
|
|
4348
|
-
input.trackingState = emulatedPosition1 ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4349
|
-
}
|
|
4350
|
-
}
|
|
4351
|
-
break;
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
};
|
|
4355
|
-
_proto._updateCamera = function _updateCamera(inputs) {
|
|
4356
|
-
var _this = this, frame = _this._platformFrame;
|
|
4357
|
-
var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
|
|
4358
|
-
var viewerPose = frame.getViewerPose(referenceSpace);
|
|
4359
|
-
if (viewerPose) {
|
|
4360
|
-
var hadUpdateCenterViewer = false;
|
|
4361
|
-
var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
|
|
4362
|
-
for(var i = 0, n = views.length; i < n; i++){
|
|
4363
|
-
var view = views[i];
|
|
4364
|
-
var type = viewToCamera(view.eye);
|
|
4365
|
-
var transform = views[i].transform;
|
|
4366
|
-
if (type === engineXr.XRTrackedInputDevice.Camera) {
|
|
4367
|
-
hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
|
|
4368
|
-
}
|
|
4369
|
-
var xrCamera = inputs[type];
|
|
4370
|
-
var pose = xrCamera.pose;
|
|
4371
|
-
pose.matrix.copyFromArray(transform.matrix);
|
|
4372
|
-
pose.position.copyFrom(transform.position);
|
|
4373
|
-
pose.rotation.copyFrom(transform.orientation);
|
|
4374
|
-
xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
|
|
4375
|
-
xrCamera.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4376
|
-
var xrViewport = layer.getViewport(view);
|
|
4377
|
-
var width = xrViewport.width / framebufferWidth;
|
|
4378
|
-
var height = xrViewport.height / framebufferHeight;
|
|
4379
|
-
var x = xrViewport.x / framebufferWidth;
|
|
4380
|
-
var y = 1 - xrViewport.y / framebufferHeight - height;
|
|
4381
|
-
xrCamera.viewport.set(x, y, width, height);
|
|
4382
|
-
}
|
|
4383
|
-
if (!hadUpdateCenterViewer) {
|
|
4384
|
-
var leftCameraDevice = inputs[engineXr.XRTrackedInputDevice.LeftCamera];
|
|
4385
|
-
var rightCameraDevice = inputs[engineXr.XRTrackedInputDevice.RightCamera];
|
|
4386
|
-
var cameraDevice = inputs[engineXr.XRTrackedInputDevice.Camera];
|
|
4387
|
-
var leftCameraPose = leftCameraDevice.pose;
|
|
4388
|
-
var rightCameraPose = rightCameraDevice.pose;
|
|
4389
|
-
var cameraPose = cameraDevice.pose;
|
|
4390
|
-
cameraPose.rotation.copyFrom(leftCameraPose.rotation);
|
|
4391
|
-
var position = cameraPose.position, matrix = cameraPose.matrix;
|
|
4392
|
-
Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
|
|
4393
|
-
position.scale(0.5);
|
|
4394
|
-
matrix.copyFrom(leftCameraPose.matrix);
|
|
4395
|
-
var elements = matrix.elements;
|
|
4396
|
-
elements[12] = position.x;
|
|
4397
|
-
elements[13] = position.y;
|
|
4398
|
-
elements[14] = position.z;
|
|
4399
|
-
cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
|
|
4400
|
-
cameraDevice.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4401
|
-
cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
2933
|
+
_proto._updateCamera = function _updateCamera(inputs) {
|
|
2934
|
+
var _this = this, frame = _this._platformFrame;
|
|
2935
|
+
var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
|
|
2936
|
+
var viewerPose = frame.getViewerPose(referenceSpace);
|
|
2937
|
+
if (viewerPose) {
|
|
2938
|
+
var hadUpdateCenterViewer = false;
|
|
2939
|
+
var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
|
|
2940
|
+
for(var i = 0, n = views.length; i < n; i++){
|
|
2941
|
+
var view = views[i];
|
|
2942
|
+
var type = viewToCamera(view.eye);
|
|
2943
|
+
var transform = views[i].transform;
|
|
2944
|
+
if (type === engineXr.XRTrackedInputDevice.Camera) {
|
|
2945
|
+
hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
|
|
2946
|
+
}
|
|
2947
|
+
var xrCamera = inputs[type];
|
|
2948
|
+
var pose = xrCamera.pose;
|
|
2949
|
+
pose.matrix.copyFromArray(transform.matrix);
|
|
2950
|
+
pose.position.copyFrom(transform.position);
|
|
2951
|
+
pose.rotation.copyFrom(transform.orientation);
|
|
2952
|
+
xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
|
|
2953
|
+
xrCamera.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2954
|
+
var xrViewport = layer.getViewport(view);
|
|
2955
|
+
var width = xrViewport.width / framebufferWidth;
|
|
2956
|
+
var height = xrViewport.height / framebufferHeight;
|
|
2957
|
+
var x = xrViewport.x / framebufferWidth;
|
|
2958
|
+
var y = 1 - xrViewport.y / framebufferHeight - height;
|
|
2959
|
+
xrCamera.viewport.set(x, y, width, height);
|
|
2960
|
+
}
|
|
2961
|
+
if (!hadUpdateCenterViewer) {
|
|
2962
|
+
var leftCameraDevice = inputs[engineXr.XRTrackedInputDevice.LeftCamera];
|
|
2963
|
+
var rightCameraDevice = inputs[engineXr.XRTrackedInputDevice.RightCamera];
|
|
2964
|
+
var cameraDevice = inputs[engineXr.XRTrackedInputDevice.Camera];
|
|
2965
|
+
var leftCameraPose = leftCameraDevice.pose;
|
|
2966
|
+
var rightCameraPose = rightCameraDevice.pose;
|
|
2967
|
+
var cameraPose = cameraDevice.pose;
|
|
2968
|
+
cameraPose.rotation.copyFrom(leftCameraPose.rotation);
|
|
2969
|
+
var position = cameraPose.position, matrix = cameraPose.matrix;
|
|
2970
|
+
Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
|
|
2971
|
+
position.scale(0.5);
|
|
2972
|
+
matrix.copyFrom(leftCameraPose.matrix);
|
|
2973
|
+
var elements = matrix.elements;
|
|
2974
|
+
elements[12] = position.x;
|
|
2975
|
+
elements[13] = position.y;
|
|
2976
|
+
elements[14] = position.z;
|
|
2977
|
+
cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
|
|
2978
|
+
cameraDevice.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2979
|
+
cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
4404
2982
|
};
|
|
4405
2983
|
return WebXRFrame;
|
|
4406
2984
|
}();
|
|
@@ -4690,9 +3268,7 @@ var WebXRDevice = /*#__PURE__*/ function() {
|
|
|
4690
3268
|
};
|
|
4691
3269
|
return WebXRDevice;
|
|
4692
3270
|
}();
|
|
4693
|
-
|
|
4694
|
-
/** @internal */ WebXRDevice._platformFeatureMap = [];
|
|
4695
|
-
})();
|
|
3271
|
+
/** @internal */ WebXRDevice._platformFeatureMap = [];
|
|
4696
3272
|
function registerXRPlatformFeature(type) {
|
|
4697
3273
|
return function(platformFeatureConstructor) {
|
|
4698
3274
|
WebXRDevice._platformFeatureMap[type] = platformFeatureConstructor;
|
|
@@ -4706,10 +3282,10 @@ function registerXRPlatformFeature(type) {
|
|
|
4706
3282
|
|
|
4707
3283
|
/**
|
|
4708
3284
|
* @internal
|
|
4709
|
-
*/ var WebXRTrackableFeature = /*#__PURE__*/ function(
|
|
4710
|
-
_inherits(WebXRTrackableFeature,
|
|
3285
|
+
*/ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature) {
|
|
3286
|
+
_inherits(WebXRTrackableFeature, WebXRFeature);
|
|
4711
3287
|
function WebXRTrackableFeature() {
|
|
4712
|
-
return
|
|
3288
|
+
return WebXRFeature.apply(this, arguments) || this;
|
|
4713
3289
|
}
|
|
4714
3290
|
var _proto = WebXRTrackableFeature.prototype;
|
|
4715
3291
|
_proto.onAddRequestTracking = function onAddRequestTracking(requestTracking) {};
|
|
@@ -4727,10 +3303,10 @@ function registerXRPlatformFeature(type) {
|
|
|
4727
3303
|
return WebXRTrackableFeature;
|
|
4728
3304
|
}(WebXRFeature);
|
|
4729
3305
|
|
|
4730
|
-
var WebXRAnchorTracking = /*#__PURE__*/ function(
|
|
4731
|
-
_inherits(WebXRAnchorTracking,
|
|
3306
|
+
var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3307
|
+
_inherits(WebXRAnchorTracking, WebXRTrackableFeature);
|
|
4732
3308
|
function WebXRAnchorTracking() {
|
|
4733
|
-
return
|
|
3309
|
+
return WebXRTrackableFeature.apply(this, arguments) || this;
|
|
4734
3310
|
}
|
|
4735
3311
|
var _proto = WebXRAnchorTracking.prototype;
|
|
4736
3312
|
_proto.checkAvailable = function checkAvailable(session, frame, requestTrackings) {
|
|
@@ -4841,14 +3417,11 @@ WebXRAnchorTracking = __decorate([
|
|
|
4841
3417
|
registerXRPlatformFeature(engineXr.XRFeatureType.AnchorTracking)
|
|
4842
3418
|
], WebXRAnchorTracking);
|
|
4843
3419
|
|
|
4844
|
-
var WebXRImageTracking = /*#__PURE__*/ function(
|
|
4845
|
-
_inherits(WebXRImageTracking,
|
|
3420
|
+
var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3421
|
+
_inherits(WebXRImageTracking, WebXRTrackableFeature);
|
|
4846
3422
|
function WebXRImageTracking(images) {
|
|
4847
3423
|
var _this;
|
|
4848
|
-
_this =
|
|
4849
|
-
_this._trackingScoreStatus = 0;
|
|
4850
|
-
_this._tempIdx = 0;
|
|
4851
|
-
_this._tempArr = [];
|
|
3424
|
+
_this = WebXRTrackableFeature.call(this) || this, _this._trackingScoreStatus = 0, _this._tempIdx = 0, _this._tempArr = [];
|
|
4852
3425
|
_this._images = images;
|
|
4853
3426
|
return _this;
|
|
4854
3427
|
}
|
|
@@ -4965,17 +3538,12 @@ var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
|
|
|
4965
3538
|
WebXRImageTracking = __decorate([
|
|
4966
3539
|
registerXRPlatformFeature(engineXr.XRFeatureType.ImageTracking)
|
|
4967
3540
|
], WebXRImageTracking);
|
|
4968
|
-
var ImageTrackingScoreStatus;
|
|
4969
|
-
(function(ImageTrackingScoreStatus) {
|
|
4970
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["NotReceived"] = 0] = "NotReceived";
|
|
4971
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["Waiting"] = 1] = "Waiting";
|
|
4972
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["Received"] = 2] = "Received";
|
|
4973
|
-
})(ImageTrackingScoreStatus || (ImageTrackingScoreStatus = {}));
|
|
4974
3541
|
|
|
4975
|
-
var WebXRPlaneTracking = /*#__PURE__*/ function(
|
|
4976
|
-
_inherits(WebXRPlaneTracking,
|
|
3542
|
+
var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3543
|
+
_inherits(WebXRPlaneTracking, WebXRTrackableFeature);
|
|
4977
3544
|
function WebXRPlaneTracking(detectedMode) {
|
|
4978
|
-
var _this
|
|
3545
|
+
var _this;
|
|
3546
|
+
_this = WebXRTrackableFeature.call(this) || this;
|
|
4979
3547
|
if (detectedMode !== engineXr.XRPlaneMode.EveryThing) {
|
|
4980
3548
|
console.warn("WebXR only support XRPlaneMode.EveryThing");
|
|
4981
3549
|
}
|
|
@@ -5004,8 +3572,7 @@ var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
|
|
|
5004
3572
|
}
|
|
5005
3573
|
var _this1 = this, lastDetectedPlanes = _this1._lastDetectedPlanes;
|
|
5006
3574
|
detectedPlanes.forEach(function(xrPlane) {
|
|
5007
|
-
|
|
5008
|
-
if (!((_lastDetectedPlanes = lastDetectedPlanes) == null ? void 0 : _lastDetectedPlanes.has(xrPlane))) {
|
|
3575
|
+
if (!(lastDetectedPlanes == null ? void 0 : lastDetectedPlanes.has(xrPlane))) {
|
|
5009
3576
|
var plane = generateTracked();
|
|
5010
3577
|
plane.xrPlane = xrPlane;
|
|
5011
3578
|
plane.lastChangedTime = -1;
|