@galacean/engine-xr-webxr 0.0.0-experimental-1.3-xr.10 → 0.0.0-experimental-1.4-small-language.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -66,17 +66,18 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
66
66
  };
67
67
 
68
68
  function _is_native_reflect_construct() {
69
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
70
- if (Reflect.construct.sham) return false;
71
- if (typeof Proxy === "function") return true;
72
-
69
+ // Since Reflect.construct can't be properly polyfilled, some
70
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
71
+ // Those polyfills don't allow us to subclass built-ins, so we need to
72
+ // use our fallback implementation.
73
73
  try {
74
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
75
-
76
- return true;
77
- } catch (e) {
78
- return false;
79
- }
74
+ // If the internal slots aren't set, this throws an error similar to
75
+ // TypeError: this is not a Boolean object.
76
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
77
+ } catch (_) {}
78
+ return (_is_native_reflect_construct = function() {
79
+ return !!result;
80
+ })();
80
81
  }
81
82
 
82
83
  function _construct(Parent, args, Class) {
@@ -145,33 +146,6 @@ function viewToCamera(type) {
145
146
  }
146
147
  }
147
148
 
148
- /**
149
- * Defines how the bounding volumes intersects or contain one another.
150
- */ var ContainmentType;
151
- (function(ContainmentType) {
152
- ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
153
- ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
154
- ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
155
- })(ContainmentType || (ContainmentType = {}));
156
- /**
157
- * Defines the intersection between a plane and a bounding volume.
158
- */ var PlaneIntersectionType;
159
- (function(PlaneIntersectionType) {
160
- PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
161
- PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
162
- PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
163
- })(PlaneIntersectionType || (PlaneIntersectionType = {}));
164
- /**
165
- * Frustum face
166
- */ var FrustumFace;
167
- (function(FrustumFace) {
168
- FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
169
- FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
170
- FrustumFace[FrustumFace[/** Left face */ "Left"] = 2] = "Left";
171
- FrustumFace[FrustumFace[/** Right face */ "Right"] = 3] = "Right";
172
- FrustumFace[FrustumFace[/** Bottom face */ "Bottom"] = 4] = "Bottom";
173
- FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
174
- })(FrustumFace || (FrustumFace = {}));
175
149
  function _defineProperties(target, props) {
176
150
  for(var i = 0; i < props.length; i++){
177
151
  var descriptor = props[i];
@@ -189,7 +163,7 @@ function _create_class(Constructor, protoProps, staticProps) {
189
163
  /**
190
164
  * Common utility methods for math operations.
191
165
  */ var MathUtil = /*#__PURE__*/ function() {
192
- var MathUtil = function MathUtil() {};
166
+ function MathUtil() {}
193
167
  /**
194
168
  * Clamps the specified value.
195
169
  * @param v - The specified value
@@ -240,19 +214,13 @@ function _create_class(Constructor, protoProps, staticProps) {
240
214
  };
241
215
  return MathUtil;
242
216
  }();
243
- (function() {
244
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
245
- })();
246
- (function() {
247
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
248
- })();
249
- (function() {
250
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
251
- })();
217
+ /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
218
+ /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
219
+ /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
252
220
  /**
253
221
  * Describes a 3D-vector.
254
222
  */ var Vector3 = /*#__PURE__*/ function() {
255
- var Vector3 = function Vector3(x, y, z) {
223
+ function Vector3(x, y, z) {
256
224
  if (x === void 0) x = 0;
257
225
  if (y === void 0) y = 0;
258
226
  if (z === void 0) z = 0;
@@ -260,7 +228,7 @@ function _create_class(Constructor, protoProps, staticProps) {
260
228
  this._x = x;
261
229
  this._y = y;
262
230
  this._z = z;
263
- };
231
+ }
264
232
  var _proto = Vector3.prototype;
265
233
  /**
266
234
  * Set the value of this vector.
@@ -272,7 +240,7 @@ function _create_class(Constructor, protoProps, staticProps) {
272
240
  this._x = x;
273
241
  this._y = y;
274
242
  this._z = z;
275
- this._onValueChanged && this._onValueChanged();
243
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
276
244
  return this;
277
245
  };
278
246
  /**
@@ -283,7 +251,7 @@ function _create_class(Constructor, protoProps, staticProps) {
283
251
  this._x += right._x;
284
252
  this._y += right._y;
285
253
  this._z += right._z;
286
- this._onValueChanged && this._onValueChanged();
254
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
287
255
  return this;
288
256
  };
289
257
  /**
@@ -294,7 +262,7 @@ function _create_class(Constructor, protoProps, staticProps) {
294
262
  this._x -= right._x;
295
263
  this._y -= right._y;
296
264
  this._z -= right._z;
297
- this._onValueChanged && this._onValueChanged();
265
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
298
266
  return this;
299
267
  };
300
268
  /**
@@ -305,7 +273,7 @@ function _create_class(Constructor, protoProps, staticProps) {
305
273
  this._x *= right._x;
306
274
  this._y *= right._y;
307
275
  this._z *= right._z;
308
- this._onValueChanged && this._onValueChanged();
276
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
309
277
  return this;
310
278
  };
311
279
  /**
@@ -316,7 +284,7 @@ function _create_class(Constructor, protoProps, staticProps) {
316
284
  this._x /= right._x;
317
285
  this._y /= right._y;
318
286
  this._z /= right._z;
319
- this._onValueChanged && this._onValueChanged();
287
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
320
288
  return this;
321
289
  };
322
290
  /**
@@ -340,7 +308,7 @@ function _create_class(Constructor, protoProps, staticProps) {
340
308
  this._x = -this._x;
341
309
  this._y = -this._y;
342
310
  this._z = -this._z;
343
- this._onValueChanged && this._onValueChanged();
311
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
344
312
  return this;
345
313
  };
346
314
  /**
@@ -358,7 +326,7 @@ function _create_class(Constructor, protoProps, staticProps) {
358
326
  this._x *= s;
359
327
  this._y *= s;
360
328
  this._z *= s;
361
- this._onValueChanged && this._onValueChanged();
329
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
362
330
  return this;
363
331
  };
364
332
  /**
@@ -419,10 +387,20 @@ function _create_class(Constructor, protoProps, staticProps) {
419
387
  this._x = source.x;
420
388
  this._y = source.y;
421
389
  this._z = source.z;
422
- this._onValueChanged && this._onValueChanged();
390
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
423
391
  return this;
424
392
  };
425
393
  /**
394
+ * Copy to vector3 like object.
395
+ * @param target - Vector3 like object
396
+ * @returns This Vector3 like object
397
+ */ _proto.copyTo = function copyTo(target) {
398
+ target.x = this._x;
399
+ target.y = this._y;
400
+ target.z = this._z;
401
+ return target;
402
+ };
403
+ /**
426
404
  * Copy the value of this vector from an array.
427
405
  * @param array - The array
428
406
  * @param offset - The start offset of the array
@@ -432,7 +410,7 @@ function _create_class(Constructor, protoProps, staticProps) {
432
410
  this._x = array[offset];
433
411
  this._y = array[offset + 1];
434
412
  this._z = array[offset + 2];
435
- this._onValueChanged && this._onValueChanged();
413
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
436
414
  return this;
437
415
  };
438
416
  /**
@@ -464,7 +442,7 @@ function _create_class(Constructor, protoProps, staticProps) {
464
442
  out._x = left._x + right._x;
465
443
  out._y = left._y + right._y;
466
444
  out._z = left._z + right._z;
467
- out._onValueChanged && out._onValueChanged();
445
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
468
446
  };
469
447
  /**
470
448
  * Determines the difference between two vectors.
@@ -475,7 +453,7 @@ function _create_class(Constructor, protoProps, staticProps) {
475
453
  out._x = left._x - right._x;
476
454
  out._y = left._y - right._y;
477
455
  out._z = left._z - right._z;
478
- out._onValueChanged && out._onValueChanged();
456
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
479
457
  };
480
458
  /**
481
459
  * Determines the product of two vectors.
@@ -486,7 +464,7 @@ function _create_class(Constructor, protoProps, staticProps) {
486
464
  out._x = left._x * right._x;
487
465
  out._y = left._y * right._y;
488
466
  out._z = left._z * right._z;
489
- out._onValueChanged && out._onValueChanged();
467
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
490
468
  };
491
469
  /**
492
470
  * Determines the divisor of two vectors.
@@ -497,7 +475,7 @@ function _create_class(Constructor, protoProps, staticProps) {
497
475
  out._x = left._x / right._x;
498
476
  out._y = left._y / right._y;
499
477
  out._z = left._z / right._z;
500
- out._onValueChanged && out._onValueChanged();
478
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
501
479
  };
502
480
  /**
503
481
  * Determines the dot product of two vectors.
@@ -562,7 +540,7 @@ function _create_class(Constructor, protoProps, staticProps) {
562
540
  out._x = _x + (end._x - _x) * t;
563
541
  out._y = _y + (end._y - _y) * t;
564
542
  out._z = _z + (end._z - _z) * t;
565
- out._onValueChanged && out._onValueChanged();
543
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
566
544
  };
567
545
  /**
568
546
  * Calculate a vector containing the largest components of the specified vectors.
@@ -573,7 +551,7 @@ function _create_class(Constructor, protoProps, staticProps) {
573
551
  out._x = Math.max(left._x, right._x);
574
552
  out._y = Math.max(left._y, right._y);
575
553
  out._z = Math.max(left._z, right._z);
576
- out._onValueChanged && out._onValueChanged();
554
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
577
555
  };
578
556
  /**
579
557
  * Calculate a vector containing the smallest components of the specified vectors.
@@ -584,7 +562,7 @@ function _create_class(Constructor, protoProps, staticProps) {
584
562
  out._x = Math.min(left._x, right._x);
585
563
  out._y = Math.min(left._y, right._y);
586
564
  out._z = Math.min(left._z, right._z);
587
- out._onValueChanged && out._onValueChanged();
565
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
588
566
  };
589
567
  /**
590
568
  * Reverses the direction of a given vector.
@@ -594,7 +572,7 @@ function _create_class(Constructor, protoProps, staticProps) {
594
572
  out._x = -a._x;
595
573
  out._y = -a._y;
596
574
  out._z = -a._z;
597
- out._onValueChanged && out._onValueChanged();
575
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
598
576
  };
599
577
  /**
600
578
  * Converts the vector into a unit vector.
@@ -617,7 +595,7 @@ function _create_class(Constructor, protoProps, staticProps) {
617
595
  out._x = a._x * s;
618
596
  out._y = a._y * s;
619
597
  out._z = a._z * s;
620
- out._onValueChanged && out._onValueChanged();
598
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
621
599
  };
622
600
  /**
623
601
  * Performs a normal transformation using the given 4x4 matrix.
@@ -636,7 +614,7 @@ function _create_class(Constructor, protoProps, staticProps) {
636
614
  out._x = _x * e[0] + _y * e[4] + _z * e[8];
637
615
  out._y = _x * e[1] + _y * e[5] + _z * e[9];
638
616
  out._z = _x * e[2] + _y * e[6] + _z * e[10];
639
- out._onValueChanged && out._onValueChanged();
617
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
640
618
  };
641
619
  /**
642
620
  * Performs a transformation using the given 4x4 matrix.
@@ -649,7 +627,7 @@ function _create_class(Constructor, protoProps, staticProps) {
649
627
  out._x = _x * e[0] + _y * e[4] + _z * e[8] + e[12];
650
628
  out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
651
629
  out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
652
- out._onValueChanged && out._onValueChanged();
630
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
653
631
  };
654
632
  /**
655
633
  * Performs a transformation from vector3 to vector4 using the given 4x4 matrix.
@@ -663,7 +641,7 @@ function _create_class(Constructor, protoProps, staticProps) {
663
641
  out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
664
642
  out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
665
643
  out._w = _x * e[3] + _y * e[7] + _z * e[11] + e[15];
666
- out._onValueChanged && out._onValueChanged();
644
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
667
645
  };
668
646
  /**
669
647
  * Performs a coordinate transformation using the given 4x4 matrix.
@@ -685,7 +663,7 @@ function _create_class(Constructor, protoProps, staticProps) {
685
663
  out._x = (_x * e[0] + _y * e[4] + _z * e[8] + e[12]) * w;
686
664
  out._y = (_x * e[1] + _y * e[5] + _z * e[9] + e[13]) * w;
687
665
  out._z = (_x * e[2] + _y * e[6] + _z * e[10] + e[14]) * w;
688
- out._onValueChanged && out._onValueChanged();
666
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
689
667
  };
690
668
  /**
691
669
  * Performs a transformation using the given quaternion.
@@ -704,7 +682,7 @@ function _create_class(Constructor, protoProps, staticProps) {
704
682
  out._x = ix * qw - iw * qx - iy * qz + iz * qy;
705
683
  out._y = iy * qw - iw * qy - iz * qx + ix * qz;
706
684
  out._z = iz * qw - iw * qz - ix * qy + iy * qx;
707
- out._onValueChanged && out._onValueChanged();
685
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
708
686
  };
709
687
  _create_class(Vector3, [
710
688
  {
@@ -716,7 +694,7 @@ function _create_class(Constructor, protoProps, staticProps) {
716
694
  },
717
695
  set: function set(value) {
718
696
  this._x = value;
719
- this._onValueChanged && this._onValueChanged();
697
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
720
698
  }
721
699
  },
722
700
  {
@@ -728,7 +706,7 @@ function _create_class(Constructor, protoProps, staticProps) {
728
706
  },
729
707
  set: function set(value) {
730
708
  this._y = value;
731
- this._onValueChanged && this._onValueChanged();
709
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
732
710
  }
733
711
  },
734
712
  {
@@ -740,661 +718,24 @@ function _create_class(Constructor, protoProps, staticProps) {
740
718
  },
741
719
  set: function set(value) {
742
720
  this._z = value;
743
- this._onValueChanged && this._onValueChanged();
721
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
744
722
  }
745
723
  }
746
724
  ]);
747
725
  return Vector3;
748
726
  }();
749
- (function() {
750
- /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
751
- })();
752
- (function() {
753
- /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
754
- })();
755
- /**
756
- * A bounding sphere.
757
- * */ var BoundingSphere = /*#__PURE__*/ function() {
758
- var BoundingSphere = function BoundingSphere(center, radius) {
759
- if (center === void 0) center = null;
760
- if (radius === void 0) radius = 0;
761
- /** The center point of the sphere. */ this.center = new Vector3();
762
- /** The radius of the sphere. */ this.radius = 0;
763
- center && this.center.copyFrom(center);
764
- this.radius = radius;
765
- };
766
- var _proto = BoundingSphere.prototype;
767
- /**
768
- * Creates a clone of this sphere.
769
- * @returns A clone of this sphere
770
- */ _proto.clone = function clone() {
771
- return new BoundingSphere(this.center, this.radius);
772
- };
773
- /**
774
- * Copy this sphere from the specified sphere.
775
- * @param source - The specified sphere
776
- * @returns This sphere
777
- */ _proto.copyFrom = function copyFrom(source) {
778
- this.center.copyFrom(source.center);
779
- this.radius = source.radius;
780
- return this;
781
- };
782
- /**
783
- * Calculate a bounding sphere that fully contains the given points.
784
- * @param points - The given points
785
- * @param out - The calculated bounding sphere
786
- */ BoundingSphere.fromPoints = function fromPoints(points, out) {
787
- if (!points || points.length === 0) {
788
- throw new Error("points must be array and length must > 0");
789
- }
790
- var len = points.length;
791
- var center = BoundingSphere._tempVec30;
792
- center.x = center.y = center.z = 0;
793
- // Calculate the center of the sphere.
794
- for(var i = 0; i < len; ++i){
795
- Vector3.add(points[i], center, center);
796
- }
797
- // The center of the sphere.
798
- Vector3.scale(center, 1 / len, out.center);
799
- // Calculate the radius of the sphere.
800
- var radius = 0.0;
801
- for(var i1 = 0; i1 < len; ++i1){
802
- var distance = Vector3.distanceSquared(center, points[i1]);
803
- distance > radius && (radius = distance);
804
- }
805
- // The radius of the sphere.
806
- out.radius = Math.sqrt(radius);
807
- };
808
- /**
809
- * Calculate a bounding sphere from a given box.
810
- * @param box - The given box
811
- * @param out - The calculated bounding sphere
812
- */ BoundingSphere.fromBox = function fromBox(box, out) {
813
- var center = out.center;
814
- var min = box.min, max = box.max;
815
- center.x = (min.x + max.x) * 0.5;
816
- center.y = (min.y + max.y) * 0.5;
817
- center.z = (min.z + max.z) * 0.5;
818
- out.radius = Vector3.distance(center, max);
819
- };
820
- return BoundingSphere;
821
- }();
822
- (function() {
823
- BoundingSphere._tempVec30 = new Vector3();
824
- })();
825
- /**
826
- * Axis Aligned Bound Box (AABB).
827
- */ var BoundingBox = /*#__PURE__*/ function() {
828
- var BoundingBox = function BoundingBox(min, max) {
829
- if (min === void 0) min = null;
830
- if (max === void 0) max = null;
831
- /** The minimum point of the box. */ this.min = new Vector3();
832
- /** The maximum point of the box. */ this.max = new Vector3();
833
- min && this.min.copyFrom(min);
834
- max && this.max.copyFrom(max);
835
- };
836
- var _proto = BoundingBox.prototype;
837
- /**
838
- * Get the center point of this bounding box.
839
- * @param out - The center point of this bounding box
840
- * @returns The center point of this bounding box
841
- */ _proto.getCenter = function getCenter(out) {
842
- var _this = this, min = _this.min, max = _this.max;
843
- var centerX = max._x + min._x;
844
- var centerY = max._y + min._y;
845
- var centerZ = max._z + min._z;
846
- out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
847
- return out;
848
- };
849
- /**
850
- * Get the extent of this bounding box.
851
- * @param out - The extent of this bounding box
852
- * @returns The extent of this bounding box
853
- */ _proto.getExtent = function getExtent(out) {
854
- var _this = this, min = _this.min, max = _this.max;
855
- var extentX = max._x - min._x;
856
- var extentY = max._y - min._y;
857
- var extentZ = max._z - min._z;
858
- out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
859
- return out;
860
- };
861
- /**
862
- * Get the eight corners of this bounding box.
863
- * @param out - An array of points representing the eight corners of this bounding box
864
- * @returns An array of points representing the eight corners of this bounding box
865
- */ _proto.getCorners = function getCorners(out) {
866
- if (out === void 0) out = [];
867
- var _this = this, min = _this.min, max = _this.max;
868
- var minX = min.x;
869
- var minY = min.y;
870
- var minZ = min.z;
871
- var maxX = max.x;
872
- var maxY = max.y;
873
- var maxZ = max.z;
874
- var len = out.length;
875
- // The array length is less than 8 to make up
876
- if (len < 8) {
877
- for(var i = 0, l = 8 - len; i < l; ++i){
878
- out[len + i] = new Vector3();
879
- }
880
- }
881
- out[0].set(minX, maxY, maxZ);
882
- out[1].set(maxX, maxY, maxZ);
883
- out[2].set(maxX, minY, maxZ);
884
- out[3].set(minX, minY, maxZ);
885
- out[4].set(minX, maxY, minZ);
886
- out[5].set(maxX, maxY, minZ);
887
- out[6].set(maxX, minY, minZ);
888
- out[7].set(minX, minY, minZ);
889
- return out;
890
- };
891
- /**
892
- * Transform a bounding box.
893
- * @param matrix - The transform to apply to the bounding box
894
- * @returns The transformed bounding box
895
- */ _proto.transform = function transform(matrix) {
896
- BoundingBox.transform(this, matrix, this);
897
- return this;
898
- };
899
- /**
900
- * Creates a clone of this box.
901
- * @returns A clone of this box
902
- */ _proto.clone = function clone() {
903
- return new BoundingBox(this.min, this.max);
904
- };
905
- /**
906
- * Copy this bounding box from the specified box.
907
- * @param source - The specified box
908
- * @returns This bounding box
909
- */ _proto.copyFrom = function copyFrom(source) {
910
- this.min.copyFrom(source.min);
911
- this.max.copyFrom(source.max);
912
- return this;
913
- };
914
- /**
915
- * Calculate a bounding box from the center point and the extent of the bounding box.
916
- * @param center - The center point
917
- * @param extent - The extent of the bounding box
918
- * @param out - The calculated bounding box
919
- */ BoundingBox.fromCenterAndExtent = function fromCenterAndExtent(center, extent, out) {
920
- Vector3.subtract(center, extent, out.min);
921
- Vector3.add(center, extent, out.max);
922
- };
923
- /**
924
- * Calculate a bounding box that fully contains the given points.
925
- * @param points - The given points
926
- * @param out - The calculated bounding box
927
- */ BoundingBox.fromPoints = function fromPoints(points, out) {
928
- if (!points || points.length === 0) {
929
- throw new Error("points must be array and length must > 0");
930
- }
931
- var min = out.min, max = out.max;
932
- min.x = min.y = min.z = Number.MAX_VALUE;
933
- max.x = max.y = max.z = -Number.MAX_VALUE;
934
- for(var i = 0, l = points.length; i < l; ++i){
935
- var point = points[i];
936
- Vector3.min(min, point, min);
937
- Vector3.max(max, point, max);
938
- }
939
- };
940
- /**
941
- * Calculate a bounding box from a given sphere.
942
- * @param sphere - The given sphere
943
- * @param out - The calculated bounding box
944
- */ BoundingBox.fromSphere = function fromSphere(sphere, out) {
945
- var center = sphere.center, radius = sphere.radius;
946
- var min = out.min, max = out.max;
947
- min.x = center.x - radius;
948
- min.y = center.y - radius;
949
- min.z = center.z - radius;
950
- max.x = center.x + radius;
951
- max.y = center.y + radius;
952
- max.z = center.z + radius;
953
- };
954
- /**
955
- * Transform a bounding box.
956
- * @param source - The original bounding box
957
- * @param matrix - The transform to apply to the bounding box
958
- * @param out - The transformed bounding box
959
- */ BoundingBox.transform = function transform(source, matrix, out) {
960
- // https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
961
- var center = BoundingBox._tempVec30;
962
- var extent = BoundingBox._tempVec31;
963
- source.getCenter(center);
964
- source.getExtent(extent);
965
- Vector3.transformCoordinate(center, matrix, center);
966
- var x = extent.x, y = extent.y, z = extent.z;
967
- var e = matrix.elements;
968
- // prettier-ignore
969
- 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];
970
- 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)));
971
- // set min、max
972
- Vector3.subtract(center, extent, out.min);
973
- Vector3.add(center, extent, out.max);
974
- };
975
- /**
976
- * Calculate a bounding box that is as large as the total combined area of the two specified boxes.
977
- * @param box1 - The first box to merge
978
- * @param box2 - The second box to merge
979
- * @param out - The merged bounding box
980
- * @returns The merged bounding box
981
- */ BoundingBox.merge = function merge(box1, box2, out) {
982
- Vector3.min(box1.min, box2.min, out.min);
983
- Vector3.max(box1.max, box2.max, out.max);
984
- return out;
985
- };
986
- return BoundingBox;
987
- }();
988
- (function() {
989
- BoundingBox._tempVec30 = new Vector3();
990
- })();
991
- (function() {
992
- BoundingBox._tempVec31 = new Vector3();
993
- })();
994
- /**
995
- * Contains static methods to help in determining intersections, containment, etc.
996
- */ var CollisionUtil = /*#__PURE__*/ function() {
997
- var CollisionUtil = function CollisionUtil() {};
998
- /**
999
- * Calculate the intersection point of three plane.
1000
- * @param p1 - Plane 1
1001
- * @param p2 - Plane 2
1002
- * @param p3 - Plane 3
1003
- * @param out - intersection point
1004
- */ CollisionUtil.intersectionPointThreePlanes = function intersectionPointThreePlanes(p1, p2, p3, out) {
1005
- var p1Nor = p1.normal;
1006
- var p2Nor = p2.normal;
1007
- var p3Nor = p3.normal;
1008
- Vector3.cross(p2Nor, p3Nor, CollisionUtil._tempVec30);
1009
- Vector3.cross(p3Nor, p1Nor, CollisionUtil._tempVec31);
1010
- Vector3.cross(p1Nor, p2Nor, CollisionUtil._tempVec32);
1011
- var a = -Vector3.dot(p1Nor, CollisionUtil._tempVec30);
1012
- var b = -Vector3.dot(p2Nor, CollisionUtil._tempVec31);
1013
- var c = -Vector3.dot(p3Nor, CollisionUtil._tempVec32);
1014
- Vector3.scale(CollisionUtil._tempVec30, p1.distance / a, CollisionUtil._tempVec30);
1015
- Vector3.scale(CollisionUtil._tempVec31, p2.distance / b, CollisionUtil._tempVec31);
1016
- Vector3.scale(CollisionUtil._tempVec32, p3.distance / c, CollisionUtil._tempVec32);
1017
- Vector3.add(CollisionUtil._tempVec30, CollisionUtil._tempVec31, out);
1018
- Vector3.add(out, CollisionUtil._tempVec32, out);
1019
- };
1020
- /**
1021
- * Calculate the distance from a point to a plane.
1022
- * @param plane - The plane
1023
- * @param point - The point
1024
- * @returns The distance from a point to a plane
1025
- */ CollisionUtil.distancePlaneAndPoint = function distancePlaneAndPoint(plane, point) {
1026
- return Vector3.dot(plane.normal, point) + plane.distance;
1027
- };
1028
- /**
1029
- * Get the intersection type between a plane and a point.
1030
- * @param plane - The plane
1031
- * @param point - The point
1032
- * @returns The intersection type
1033
- */ CollisionUtil.intersectsPlaneAndPoint = function intersectsPlaneAndPoint(plane, point) {
1034
- var distance = CollisionUtil.distancePlaneAndPoint(plane, point);
1035
- if (distance > 0) {
1036
- return PlaneIntersectionType.Front;
1037
- }
1038
- if (distance < 0) {
1039
- return PlaneIntersectionType.Back;
1040
- }
1041
- return PlaneIntersectionType.Intersecting;
1042
- };
1043
- /**
1044
- * Get the intersection type between a plane and a box (AABB).
1045
- * @param plane - The plane
1046
- * @param box - The box
1047
- * @returns The intersection type
1048
- */ CollisionUtil.intersectsPlaneAndBox = function intersectsPlaneAndBox(plane, box) {
1049
- var min = box.min, max = box.max;
1050
- var normal = plane.normal;
1051
- var front = CollisionUtil._tempVec30;
1052
- var back = CollisionUtil._tempVec31;
1053
- if (normal.x >= 0) {
1054
- front.x = max.x;
1055
- back.x = min.x;
1056
- } else {
1057
- front.x = min.x;
1058
- back.x = max.x;
1059
- }
1060
- if (normal.y >= 0) {
1061
- front.y = max.y;
1062
- back.y = min.y;
1063
- } else {
1064
- front.y = min.y;
1065
- back.y = max.y;
1066
- }
1067
- if (normal.z >= 0) {
1068
- front.z = max.z;
1069
- back.z = min.z;
1070
- } else {
1071
- front.z = min.z;
1072
- back.z = max.z;
1073
- }
1074
- if (CollisionUtil.distancePlaneAndPoint(plane, front) < 0) {
1075
- return PlaneIntersectionType.Back;
1076
- }
1077
- if (CollisionUtil.distancePlaneAndPoint(plane, back) > 0) {
1078
- return PlaneIntersectionType.Front;
1079
- }
1080
- return PlaneIntersectionType.Intersecting;
1081
- };
1082
- /**
1083
- * Get the intersection type between a plane and a sphere.
1084
- * @param plane - The plane
1085
- * @param sphere - The sphere
1086
- * @returns The intersection type
1087
- */ CollisionUtil.intersectsPlaneAndSphere = function intersectsPlaneAndSphere(plane, sphere) {
1088
- var center = sphere.center, radius = sphere.radius;
1089
- var distance = CollisionUtil.distancePlaneAndPoint(plane, center);
1090
- if (distance > radius) {
1091
- return PlaneIntersectionType.Front;
1092
- }
1093
- if (distance < -radius) {
1094
- return PlaneIntersectionType.Back;
1095
- }
1096
- return PlaneIntersectionType.Intersecting;
1097
- };
1098
- /**
1099
- * Get the intersection type between a ray and a plane.
1100
- * @param ray - The ray
1101
- * @param plane - The plane
1102
- * @returns The distance from ray to plane if intersecting, -1 otherwise
1103
- */ CollisionUtil.intersectsRayAndPlane = function intersectsRayAndPlane(ray, plane) {
1104
- var normal = plane.normal;
1105
- var zeroTolerance = MathUtil.zeroTolerance;
1106
- var dir = Vector3.dot(normal, ray.direction);
1107
- // Parallel
1108
- if (Math.abs(dir) < zeroTolerance) {
1109
- return -1;
1110
- }
1111
- var position = Vector3.dot(normal, ray.origin);
1112
- var distance = (-plane.distance - position) / dir;
1113
- if (distance < 0) {
1114
- if (distance < -zeroTolerance) {
1115
- return -1;
1116
- }
1117
- distance = 0;
1118
- }
1119
- return distance;
1120
- };
1121
- /**
1122
- * Get the intersection type between a ray and a box (AABB).
1123
- * @param ray - The ray
1124
- * @param box - The box
1125
- * @returns The distance from ray to box if intersecting, -1 otherwise
1126
- */ CollisionUtil.intersectsRayAndBox = function intersectsRayAndBox(ray, box) {
1127
- var zeroTolerance = MathUtil.zeroTolerance;
1128
- var origin = ray.origin, direction = ray.direction;
1129
- var min = box.min, max = box.max;
1130
- var dirX = direction.x;
1131
- var dirY = direction.y;
1132
- var dirZ = direction.z;
1133
- var oriX = origin.x;
1134
- var oriY = origin.y;
1135
- var oriZ = origin.z;
1136
- var distance = 0;
1137
- var tmax = Number.MAX_VALUE;
1138
- if (Math.abs(dirX) < zeroTolerance) {
1139
- if (oriX < min.x || oriX > max.x) {
1140
- return -1;
1141
- }
1142
- } else {
1143
- var inverse = 1.0 / dirX;
1144
- var t1 = (min.x - oriX) * inverse;
1145
- var t2 = (max.x - oriX) * inverse;
1146
- if (t1 > t2) {
1147
- var temp = t1;
1148
- t1 = t2;
1149
- t2 = temp;
1150
- }
1151
- distance = Math.max(t1, distance);
1152
- tmax = Math.min(t2, tmax);
1153
- if (distance > tmax) {
1154
- return -1;
1155
- }
1156
- }
1157
- if (Math.abs(dirY) < zeroTolerance) {
1158
- if (oriY < min.y || oriY > max.y) {
1159
- return -1;
1160
- }
1161
- } else {
1162
- var inverse1 = 1.0 / dirY;
1163
- var t11 = (min.y - oriY) * inverse1;
1164
- var t21 = (max.y - oriY) * inverse1;
1165
- if (t11 > t21) {
1166
- var temp1 = t11;
1167
- t11 = t21;
1168
- t21 = temp1;
1169
- }
1170
- distance = Math.max(t11, distance);
1171
- tmax = Math.min(t21, tmax);
1172
- if (distance > tmax) {
1173
- return -1;
1174
- }
1175
- }
1176
- if (Math.abs(dirZ) < zeroTolerance) {
1177
- if (oriZ < min.z || oriZ > max.z) {
1178
- return -1;
1179
- }
1180
- } else {
1181
- var inverse2 = 1.0 / dirZ;
1182
- var t12 = (min.z - oriZ) * inverse2;
1183
- var t22 = (max.z - oriZ) * inverse2;
1184
- if (t12 > t22) {
1185
- var temp2 = t12;
1186
- t12 = t22;
1187
- t22 = temp2;
1188
- }
1189
- distance = Math.max(t12, distance);
1190
- tmax = Math.min(t22, tmax);
1191
- if (distance > tmax) {
1192
- return -1;
1193
- }
1194
- }
1195
- return distance;
1196
- };
1197
- /**
1198
- * Get the intersection type between a ray and a sphere.
1199
- * @param ray - The ray
1200
- * @param sphere - The sphere
1201
- * @returns The distance from ray to sphere if intersecting, -1 otherwise
1202
- */ CollisionUtil.intersectsRayAndSphere = function intersectsRayAndSphere(ray, sphere) {
1203
- var origin = ray.origin, direction = ray.direction;
1204
- var center = sphere.center, radius = sphere.radius;
1205
- var m = CollisionUtil._tempVec30;
1206
- Vector3.subtract(origin, center, m);
1207
- var b = Vector3.dot(m, direction);
1208
- var c = Vector3.dot(m, m) - radius * radius;
1209
- if (b > 0 && c > 0) {
1210
- return -1;
1211
- }
1212
- var discriminant = b * b - c;
1213
- if (discriminant < 0) {
1214
- return -1;
1215
- }
1216
- var distance = -b - Math.sqrt(discriminant);
1217
- if (distance < 0) {
1218
- distance = 0;
1219
- }
1220
- return distance;
1221
- };
1222
- /**
1223
- * Check whether the boxes intersect.
1224
- * @param boxA - The first box to check
1225
- * @param boxB - The second box to check
1226
- * @returns True if the boxes intersect, false otherwise
1227
- */ CollisionUtil.intersectsBoxAndBox = function intersectsBoxAndBox(boxA, boxB) {
1228
- if (boxA.min.x > boxB.max.x || boxB.min.x > boxA.max.x) {
1229
- return false;
1230
- }
1231
- if (boxA.min.y > boxB.max.y || boxB.min.y > boxA.max.y) {
1232
- return false;
1233
- }
1234
- return !(boxA.min.z > boxB.max.z || boxB.min.z > boxA.max.z);
1235
- };
1236
- /**
1237
- * Check whether the spheres intersect.
1238
- * @param sphereA - The first sphere to check
1239
- * @param sphereB - The second sphere to check
1240
- * @returns True if the spheres intersect, false otherwise
1241
- */ CollisionUtil.intersectsSphereAndSphere = function intersectsSphereAndSphere(sphereA, sphereB) {
1242
- var radiisum = sphereA.radius + sphereB.radius;
1243
- return Vector3.distanceSquared(sphereA.center, sphereB.center) < radiisum * radiisum;
1244
- };
1245
- /**
1246
- * Check whether the sphere and the box intersect.
1247
- * @param sphere - The sphere to check
1248
- * @param box - The box to check
1249
- * @returns True if the sphere and the box intersect, false otherwise
1250
- */ CollisionUtil.intersectsSphereAndBox = function intersectsSphereAndBox(sphere, box) {
1251
- var center = sphere.center;
1252
- var max = box.max;
1253
- var min = box.min;
1254
- var closestPoint = CollisionUtil._tempVec30;
1255
- 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)));
1256
- var distance = Vector3.distanceSquared(center, closestPoint);
1257
- return distance <= sphere.radius * sphere.radius;
1258
- };
1259
- /**
1260
- * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
1261
- * @param frustum - The frustum
1262
- * @param box - The box
1263
- * @returns True if bounding box intersects with this frustum, false otherwise
1264
- */ CollisionUtil.intersectsFrustumAndBox = function intersectsFrustumAndBox(frustum, box) {
1265
- var min = box.min, max = box.max;
1266
- var p = CollisionUtil._tempVec30;
1267
- for(var i = 0; i < 6; ++i){
1268
- var plane = frustum.getPlane(i);
1269
- var normal = plane.normal;
1270
- p.set(normal.x >= 0 ? max.x : min.x, normal.y >= 0 ? max.y : min.y, normal.z >= 0 ? max.z : min.z);
1271
- if (Vector3.dot(normal, p) < -plane.distance) {
1272
- return false;
1273
- }
1274
- }
1275
- return true;
1276
- };
1277
- /**
1278
- * Get the containment type between a frustum and a point.
1279
- * @param frustum - The frustum
1280
- * @param point - The point
1281
- * @returns The containment type
1282
- */ CollisionUtil.frustumContainsPoint = function frustumContainsPoint(frustum, point) {
1283
- var distance = CollisionUtil.distancePlaneAndPoint(frustum.near, point);
1284
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1285
- return ContainmentType.Intersects;
1286
- } else if (distance < 0) {
1287
- return ContainmentType.Disjoint;
1288
- }
1289
- distance = CollisionUtil.distancePlaneAndPoint(frustum.far, point);
1290
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1291
- return ContainmentType.Intersects;
1292
- } else if (distance < 0) {
1293
- return ContainmentType.Disjoint;
1294
- }
1295
- distance = CollisionUtil.distancePlaneAndPoint(frustum.left, point);
1296
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1297
- return ContainmentType.Intersects;
1298
- } else if (distance < 0) {
1299
- return ContainmentType.Disjoint;
1300
- }
1301
- distance = CollisionUtil.distancePlaneAndPoint(frustum.right, point);
1302
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1303
- return ContainmentType.Intersects;
1304
- } else if (distance < 0) {
1305
- return ContainmentType.Disjoint;
1306
- }
1307
- distance = CollisionUtil.distancePlaneAndPoint(frustum.top, point);
1308
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1309
- return ContainmentType.Intersects;
1310
- } else if (distance < 0) {
1311
- return ContainmentType.Disjoint;
1312
- }
1313
- distance = CollisionUtil.distancePlaneAndPoint(frustum.bottom, point);
1314
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
1315
- return ContainmentType.Intersects;
1316
- } else if (distance < 0) {
1317
- return ContainmentType.Disjoint;
1318
- }
1319
- return ContainmentType.Contains;
1320
- };
1321
- /**
1322
- * Get the containment type between a frustum and a box (AABB).
1323
- * @param frustum - The frustum
1324
- * @param box - The box
1325
- * @returns The containment type
1326
- */ CollisionUtil.frustumContainsBox = function frustumContainsBox(frustum, box) {
1327
- var min = box.min, max = box.max;
1328
- var p = CollisionUtil._tempVec30;
1329
- var n = CollisionUtil._tempVec31;
1330
- var result = ContainmentType.Contains;
1331
- for(var i = 0; i < 6; ++i){
1332
- var plane = frustum.getPlane(i);
1333
- var normal = plane.normal;
1334
- if (normal.x >= 0) {
1335
- p.x = max.x;
1336
- n.x = min.x;
1337
- } else {
1338
- p.x = min.x;
1339
- n.x = max.x;
1340
- }
1341
- if (normal.y >= 0) {
1342
- p.y = max.y;
1343
- n.y = min.y;
1344
- } else {
1345
- p.y = min.y;
1346
- n.y = max.y;
1347
- }
1348
- if (normal.z >= 0) {
1349
- p.z = max.z;
1350
- n.z = min.z;
1351
- } else {
1352
- p.z = min.z;
1353
- n.z = max.z;
1354
- }
1355
- if (CollisionUtil.intersectsPlaneAndPoint(plane, p) === PlaneIntersectionType.Back) {
1356
- return ContainmentType.Disjoint;
1357
- }
1358
- if (CollisionUtil.intersectsPlaneAndPoint(plane, n) === PlaneIntersectionType.Back) {
1359
- result = ContainmentType.Intersects;
1360
- }
1361
- }
1362
- return result;
1363
- };
1364
- /**
1365
- * Get the containment type between a frustum and a sphere.
1366
- * @param frustum - The frustum
1367
- * @param sphere - The sphere
1368
- * @returns The containment type
1369
- */ CollisionUtil.frustumContainsSphere = function frustumContainsSphere(frustum, sphere) {
1370
- var result = ContainmentType.Contains;
1371
- for(var i = 0; i < 6; ++i){
1372
- var plane = frustum.getPlane(i);
1373
- var intersectionType = CollisionUtil.intersectsPlaneAndSphere(plane, sphere);
1374
- if (intersectionType === PlaneIntersectionType.Back) {
1375
- return ContainmentType.Disjoint;
1376
- } else if (intersectionType === PlaneIntersectionType.Intersecting) {
1377
- result = ContainmentType.Intersects;
1378
- break;
1379
- }
1380
- }
1381
- return result;
1382
- };
1383
- return CollisionUtil;
1384
- }();
1385
- (function() {
1386
- CollisionUtil._tempVec30 = new Vector3();
1387
- })();
1388
- (function() {
1389
- CollisionUtil._tempVec31 = new Vector3();
1390
- })();
1391
- (function() {
1392
- CollisionUtil._tempVec32 = new Vector3();
1393
- })();
727
+ /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
728
+ /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
729
+ new Vector3();
730
+ new Vector3();
731
+ new Vector3();
732
+ new Vector3();
733
+ new Vector3();
734
+ new Vector3();
1394
735
  /**
1395
736
  * Represents a 3x3 mathematical matrix.
1396
737
  */ var Matrix3x3 = /*#__PURE__*/ function() {
1397
- var Matrix3x3 = function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
738
+ function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
1398
739
  if (m11 === void 0) m11 = 1;
1399
740
  if (m12 === void 0) m12 = 0;
1400
741
  if (m13 === void 0) m13 = 0;
@@ -1423,7 +764,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1423
764
  e[6] = m31;
1424
765
  e[7] = m32;
1425
766
  e[8] = m33;
1426
- };
767
+ }
1427
768
  var _proto = Matrix3x3.prototype;
1428
769
  /**
1429
770
  * Set the value of this matrix, and return this matrix.
@@ -1936,7 +1277,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1936
1277
  /**
1937
1278
  * Represents a four dimensional mathematical quaternion.
1938
1279
  */ var Quaternion = /*#__PURE__*/ function() {
1939
- var Quaternion = function Quaternion(x, y, z, w) {
1280
+ function Quaternion(x, y, z, w) {
1940
1281
  if (x === void 0) x = 0;
1941
1282
  if (y === void 0) y = 0;
1942
1283
  if (z === void 0) z = 0;
@@ -1946,7 +1287,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1946
1287
  this._y = y;
1947
1288
  this._z = z;
1948
1289
  this._w = w;
1949
- };
1290
+ }
1950
1291
  var _proto = Quaternion.prototype;
1951
1292
  /**
1952
1293
  * Set the value of this quaternion, and return this quaternion.
@@ -1960,7 +1301,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1960
1301
  this._y = y;
1961
1302
  this._z = z;
1962
1303
  this._w = w;
1963
- this._onValueChanged && this._onValueChanged();
1304
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1964
1305
  return this;
1965
1306
  };
1966
1307
  /**
@@ -1970,7 +1311,7 @@ function _create_class(Constructor, protoProps, staticProps) {
1970
1311
  this._x *= -1;
1971
1312
  this._y *= -1;
1972
1313
  this._z *= -1;
1973
- this._onValueChanged && this._onValueChanged();
1314
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1974
1315
  return this;
1975
1316
  };
1976
1317
  /**
@@ -2001,7 +1342,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2001
1342
  this._y = 0;
2002
1343
  this._z = 0;
2003
1344
  this._w = 1;
2004
- this._onValueChanged && this._onValueChanged();
1345
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2005
1346
  return this;
2006
1347
  };
2007
1348
  /**
@@ -2034,7 +1375,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2034
1375
  var t = out._x;
2035
1376
  out._x = out._y;
2036
1377
  out._y = t;
2037
- out._onValueChanged && out._onValueChanged();
1378
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2038
1379
  return out;
2039
1380
  };
2040
1381
  /**
@@ -2043,7 +1384,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2043
1384
  * @returns Euler x->yaw y->pitch z->roll
2044
1385
  */ _proto.toYawPitchRoll = function toYawPitchRoll(out) {
2045
1386
  this._toYawPitchRoll(out);
2046
- out._onValueChanged && out._onValueChanged();
1387
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2047
1388
  return out;
2048
1389
  };
2049
1390
  /**
@@ -2135,10 +1476,21 @@ function _create_class(Constructor, protoProps, staticProps) {
2135
1476
  this._y = source.y;
2136
1477
  this._z = source.z;
2137
1478
  this._w = source.w;
2138
- this._onValueChanged && this._onValueChanged();
1479
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2139
1480
  return this;
2140
1481
  };
2141
1482
  /**
1483
+ * Copy this quaternion to the specified quaternion.
1484
+ * @param target - The specified quaternion
1485
+ * @returns This specified quaternion
1486
+ */ _proto.copyTo = function copyTo(target) {
1487
+ target.x = this._x;
1488
+ target.y = this._y;
1489
+ target.z = this._z;
1490
+ target.w = this._w;
1491
+ return target;
1492
+ };
1493
+ /**
2142
1494
  * Copy the value of this quaternion from an array.
2143
1495
  * @param array - The array
2144
1496
  * @param offset - The start offset of the array
@@ -2149,7 +1501,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2149
1501
  this._y = array[offset + 1];
2150
1502
  this._z = array[offset + 2];
2151
1503
  this._w = array[offset + 3];
2152
- this._onValueChanged && this._onValueChanged();
1504
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2153
1505
  return this;
2154
1506
  };
2155
1507
  /**
@@ -2207,7 +1559,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2207
1559
  out._y = left._y + right._y;
2208
1560
  out._z = left._z + right._z;
2209
1561
  out._w = left._w + right._w;
2210
- out._onValueChanged && out._onValueChanged();
1562
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2211
1563
  };
2212
1564
  /**
2213
1565
  * Determines the product of two quaternions.
@@ -2221,7 +1573,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2221
1573
  out._y = ay * bw + aw * by + az * bx - ax * bz;
2222
1574
  out._z = az * bw + aw * bz + ax * by - ay * bx;
2223
1575
  out._w = aw * bw - ax * bx - ay * by - az * bz;
2224
- out._onValueChanged && out._onValueChanged();
1576
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2225
1577
  };
2226
1578
  /**
2227
1579
  * Calculate quaternion that contains conjugated version of the specified quaternion.
@@ -2232,7 +1584,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2232
1584
  out._y = -a._y;
2233
1585
  out._z = -a._z;
2234
1586
  out._w = a._w;
2235
- out._onValueChanged && out._onValueChanged();
1587
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2236
1588
  };
2237
1589
  /**
2238
1590
  * Determines the dot product of two quaternions.
@@ -2264,7 +1616,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2264
1616
  out._y = normalAxis._y * s;
2265
1617
  out._z = normalAxis._z * s;
2266
1618
  out._w = Math.cos(rad);
2267
- out._onValueChanged && out._onValueChanged();
1619
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2268
1620
  };
2269
1621
  /**
2270
1622
  * Calculate a quaternion rotates around x, y, z axis (pitch/yaw/roll).
@@ -2297,7 +1649,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2297
1649
  out._y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
2298
1650
  out._z = cosYawPitch * sinRoll - sinYawPitch * cosRoll;
2299
1651
  out._w = cosYawPitch * cosRoll + sinYawPitch * sinRoll;
2300
- out._onValueChanged && out._onValueChanged();
1652
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2301
1653
  };
2302
1654
  /**
2303
1655
  * Calculate a quaternion from the specified 3x3 matrix.
@@ -2339,7 +1691,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2339
1691
  out._z = 0.5 * sqrt;
2340
1692
  out._w = (m12 - m21) * half;
2341
1693
  }
2342
- out._onValueChanged && out._onValueChanged();
1694
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2343
1695
  };
2344
1696
  /**
2345
1697
  * Calculate the inverse of the specified quaternion.
@@ -2354,7 +1706,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2354
1706
  out._y = -y * invDot;
2355
1707
  out._z = -z * invDot;
2356
1708
  out._w = w * invDot;
2357
- out._onValueChanged && out._onValueChanged();
1709
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2358
1710
  }
2359
1711
  };
2360
1712
  /**
@@ -2401,7 +1753,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2401
1753
  out.y = inverse * start.y + opposite * end.y;
2402
1754
  out.z = inverse * start.z + opposite * end.z;
2403
1755
  out.w = inverse * start.w + opposite * end.w;
2404
- out._onValueChanged && out._onValueChanged();
1756
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2405
1757
  };
2406
1758
  /**
2407
1759
  * Scales the specified quaternion magnitude to unit length.
@@ -2416,7 +1768,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2416
1768
  out._y = _y * len;
2417
1769
  out._z = _z * len;
2418
1770
  out._w = _w * len;
2419
- out._onValueChanged && out._onValueChanged();
1771
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2420
1772
  }
2421
1773
  };
2422
1774
  /**
@@ -2431,7 +1783,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2431
1783
  out._y = 0;
2432
1784
  out._z = 0;
2433
1785
  out._w = c;
2434
- out._onValueChanged && out._onValueChanged();
1786
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2435
1787
  };
2436
1788
  /**
2437
1789
  * Calculate a quaternion rotate around Y axis.
@@ -2445,7 +1797,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2445
1797
  out._y = s;
2446
1798
  out._z = 0;
2447
1799
  out._w = c;
2448
- out._onValueChanged && out._onValueChanged();
1800
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2449
1801
  };
2450
1802
  /**
2451
1803
  * Calculate a quaternion rotate around Z axis.
@@ -2459,7 +1811,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2459
1811
  out._y = 0;
2460
1812
  out._z = s;
2461
1813
  out._w = c;
2462
- out._onValueChanged && out._onValueChanged();
1814
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2463
1815
  };
2464
1816
  /**
2465
1817
  * Calculate a quaternion that the specified quaternion rotate around X axis.
@@ -2475,7 +1827,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2475
1827
  out._y = _y * bw + _z * bx;
2476
1828
  out._z = _z * bw - _y * bx;
2477
1829
  out._w = _w * bw - _x * bx;
2478
- out._onValueChanged && out._onValueChanged();
1830
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2479
1831
  };
2480
1832
  /**
2481
1833
  * Calculate a quaternion that the specified quaternion rotate around Y axis.
@@ -2491,7 +1843,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2491
1843
  out._y = _y * bw + _w * by;
2492
1844
  out._z = _z * bw + _x * by;
2493
1845
  out._w = _w * bw - _y * by;
2494
- out._onValueChanged && out._onValueChanged();
1846
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2495
1847
  };
2496
1848
  /**
2497
1849
  * Calculate a quaternion that the specified quaternion rotate around Z axis.
@@ -2507,7 +1859,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2507
1859
  out._y = _y * bw - _x * bz;
2508
1860
  out._z = _z * bw + _w * bz;
2509
1861
  out._w = _w * bw - _z * bz;
2510
- out._onValueChanged && out._onValueChanged();
1862
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2511
1863
  };
2512
1864
  /**
2513
1865
  * Scale a quaternion by a given number.
@@ -2519,7 +1871,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2519
1871
  out._y = a._y * s;
2520
1872
  out._z = a._z * s;
2521
1873
  out._w = a._w * s;
2522
- out._onValueChanged && out._onValueChanged();
1874
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2523
1875
  };
2524
1876
  _create_class(Quaternion, [
2525
1877
  {
@@ -2531,7 +1883,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2531
1883
  },
2532
1884
  set: function set(value) {
2533
1885
  this._x = value;
2534
- this._onValueChanged && this._onValueChanged();
1886
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2535
1887
  }
2536
1888
  },
2537
1889
  {
@@ -2543,7 +1895,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2543
1895
  },
2544
1896
  set: function set(value) {
2545
1897
  this._y = value;
2546
- this._onValueChanged && this._onValueChanged();
1898
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2547
1899
  }
2548
1900
  },
2549
1901
  {
@@ -2555,7 +1907,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2555
1907
  },
2556
1908
  set: function set(value) {
2557
1909
  this._z = value;
2558
- this._onValueChanged && this._onValueChanged();
1910
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2559
1911
  }
2560
1912
  },
2561
1913
  {
@@ -2575,22 +1927,18 @@ function _create_class(Constructor, protoProps, staticProps) {
2575
1927
  },
2576
1928
  set: function set(value) {
2577
1929
  this._w = value;
2578
- this._onValueChanged && this._onValueChanged();
1930
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2579
1931
  }
2580
1932
  }
2581
1933
  ]);
2582
1934
  return Quaternion;
2583
1935
  }();
2584
- (function() {
2585
- /** @internal */ Quaternion._tempVector3 = new Vector3();
2586
- })();
2587
- (function() {
2588
- /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2589
- })();
1936
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
1937
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
2590
1938
  /**
2591
1939
  * Represents a 4x4 mathematical matrix.
2592
1940
  */ var Matrix = /*#__PURE__*/ function() {
2593
- var Matrix = function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
1941
+ function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
2594
1942
  if (m11 === void 0) m11 = 1;
2595
1943
  if (m12 === void 0) m12 = 0;
2596
1944
  if (m13 === void 0) m13 = 0;
@@ -2634,7 +1982,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2634
1982
  e[13] = m42;
2635
1983
  e[14] = m43;
2636
1984
  e[15] = m44;
2637
- };
1985
+ }
2638
1986
  var _proto = Matrix.prototype;
2639
1987
  /**
2640
1988
  * Set the value of this matrix, and return this matrix.
@@ -2784,7 +2132,7 @@ function _create_class(Constructor, protoProps, staticProps) {
2784
2132
  out._y = (e[6] + e[9]) / s3;
2785
2133
  out._z = 0.25 * s3;
2786
2134
  }
2787
- out._onValueChanged && out._onValueChanged();
2135
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2788
2136
  return out;
2789
2137
  };
2790
2138
  /**
@@ -3526,877 +2874,107 @@ function _create_class(Constructor, protoProps, staticProps) {
3526
2874
  };
3527
2875
  return Matrix;
3528
2876
  }();
3529
- (function() {
3530
- Matrix._tempVec30 = new Vector3();
3531
- })();
3532
- (function() {
3533
- Matrix._tempVec31 = new Vector3();
3534
- })();
3535
- (function() {
3536
- Matrix._tempVec32 = new Vector3();
3537
- })();
3538
- (function() {
3539
- Matrix._tempMat30 = new Matrix3x3();
3540
- })();
3541
- (function() {
3542
- /** @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);
3543
- })();
3544
- /**
3545
- * Describes a 2D-vector.
3546
- */ var Vector2 = /*#__PURE__*/ function() {
3547
- var Vector2 = function Vector2(x, y) {
3548
- if (x === void 0) x = 0;
3549
- if (y === void 0) y = 0;
3550
- /** @internal */ this._onValueChanged = null;
3551
- this._x = x;
3552
- this._y = y;
3553
- };
3554
- var _proto = Vector2.prototype;
3555
- /**
3556
- * Set the value of this vector.
3557
- * @param x - The x component of the vector
3558
- * @param y - The y component of the vector
3559
- * @returns This vector
3560
- */ _proto.set = function set(x, y) {
3561
- this._x = x;
3562
- this._y = y;
3563
- this._onValueChanged && this._onValueChanged();
3564
- return this;
2877
+ Matrix._tempVec30 = new Vector3();
2878
+ Matrix._tempVec31 = new Vector3();
2879
+ Matrix._tempVec32 = new Vector3();
2880
+ Matrix._tempMat30 = new Matrix3x3();
2881
+ /** @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);
2882
+
2883
+ var WebXRFrame = /*#__PURE__*/ function() {
2884
+ function WebXRFrame(session) {
2885
+ this._session = session;
2886
+ }
2887
+ var _proto = WebXRFrame.prototype;
2888
+ _proto.updateInputs = function updateInputs(inputs) {
2889
+ if (!this._platformFrame) return;
2890
+ this._updateController(inputs);
2891
+ this._updateCamera(inputs);
3565
2892
  };
3566
- /**
3567
- * Determines the sum of this vector and the specified vector.
3568
- * @param right - The specified vector
3569
- * @returns This vector
3570
- */ _proto.add = function add(right) {
3571
- this._x += right._x;
3572
- this._y += right._y;
3573
- this._onValueChanged && this._onValueChanged();
3574
- return this;
2893
+ _proto._updateController = function _updateController(inputs) {
2894
+ var _this = this, frame = _this._platformFrame;
2895
+ var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
2896
+ var inputSources = session.inputSources;
2897
+ for(var i = 0, n = inputSources.length; i < n; i++){
2898
+ var inputSource = inputSources[i];
2899
+ var type = getInputSource(inputSource);
2900
+ var input = inputs[type];
2901
+ switch(inputSource.targetRayMode){
2902
+ case "screen":
2903
+ case "tracked-pointer":
2904
+ var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
2905
+ if (gripSpace) {
2906
+ var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
2907
+ if (transform) {
2908
+ var gripPose = input.gripPose;
2909
+ gripPose.matrix.copyFromArray(transform.matrix);
2910
+ gripPose.position.copyFrom(transform.position);
2911
+ gripPose.rotation.copyFrom(transform.orientation);
2912
+ }
2913
+ input.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
2914
+ }
2915
+ if (targetRaySpace) {
2916
+ var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
2917
+ if (transform1) {
2918
+ var targetRayPose = input.targetRayPose;
2919
+ targetRayPose.matrix.copyFromArray(transform1.matrix);
2920
+ targetRayPose.position.copyFrom(transform1.position);
2921
+ targetRayPose.rotation.copyFrom(transform1.orientation);
2922
+ input.trackingState = emulatedPosition1 ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
2923
+ }
2924
+ }
2925
+ break;
2926
+ }
2927
+ }
3575
2928
  };
3576
- /**
3577
- * Determines the difference of this vector and the specified vector.
3578
- * @param right - The specified vector
3579
- * @returns This vector
3580
- */ _proto.subtract = function subtract(right) {
3581
- this._x -= right._x;
3582
- this._y -= right._y;
3583
- this._onValueChanged && this._onValueChanged();
3584
- return this;
3585
- };
3586
- /**
3587
- * Determines the product of this vector and the specified vector.
3588
- * @param right - The specified vector
3589
- * @returns This vector
3590
- */ _proto.multiply = function multiply(right) {
3591
- this._x *= right._x;
3592
- this._y *= right._y;
3593
- this._onValueChanged && this._onValueChanged();
3594
- return this;
3595
- };
3596
- /**
3597
- * Determines the divisor of this vector and the specified vector.
3598
- * @param right - The specified vector
3599
- * @returns This vector
3600
- */ _proto.divide = function divide(right) {
3601
- this._x /= right._x;
3602
- this._y /= right._y;
3603
- this._onValueChanged && this._onValueChanged();
3604
- return this;
3605
- };
3606
- /**
3607
- * Calculate the length of this vector.
3608
- * @returns The length of this vector
3609
- */ _proto.length = function length() {
3610
- var _this = this, _x = _this._x, _y = _this._y;
3611
- return Math.sqrt(_x * _x + _y * _y);
3612
- };
3613
- /**
3614
- * Calculate the squared length of this vector.
3615
- * @returns The squared length of this vector
3616
- */ _proto.lengthSquared = function lengthSquared() {
3617
- var _this = this, _x = _this._x, _y = _this._y;
3618
- return _x * _x + _y * _y;
3619
- };
3620
- /**
3621
- * Reverses the direction of this vector.
3622
- * @returns This vector
3623
- */ _proto.negate = function negate() {
3624
- this._x = -this._x;
3625
- this._y = -this._y;
3626
- this._onValueChanged && this._onValueChanged();
3627
- return this;
3628
- };
3629
- /**
3630
- * Converts this vector into a unit vector.
3631
- * @returns This vector
3632
- */ _proto.normalize = function normalize() {
3633
- Vector2.normalize(this, this);
3634
- return this;
3635
- };
3636
- /**
3637
- * Scale this vector by the given value.
3638
- * @param s - The amount by which to scale the vector
3639
- * @returns This vector
3640
- */ _proto.scale = function scale(s) {
3641
- this._x *= s;
3642
- this._y *= s;
3643
- this._onValueChanged && this._onValueChanged();
3644
- return this;
3645
- };
3646
- /**
3647
- * Creates a clone of this vector.
3648
- * @returns A clone of this vector
3649
- */ _proto.clone = function clone() {
3650
- return new Vector2(this._x, this._y);
3651
- };
3652
- /**
3653
- * Copy from vector2 like object.
3654
- * @param source - Vector2 like object
3655
- * @returns This vector
3656
- */ _proto.copyFrom = function copyFrom(source) {
3657
- this._x = source.x;
3658
- this._y = source.y;
3659
- this._onValueChanged && this._onValueChanged();
3660
- return this;
3661
- };
3662
- /**
3663
- * Copy the value of this vector from an array.
3664
- * @param array - The array
3665
- * @param offset - The start offset of the array
3666
- * @returns This vector
3667
- */ _proto.copyFromArray = function copyFromArray(array, offset) {
3668
- if (offset === void 0) offset = 0;
3669
- this._x = array[offset];
3670
- this._y = array[offset + 1];
3671
- this._onValueChanged && this._onValueChanged();
3672
- return this;
3673
- };
3674
- /**
3675
- * Copy the value of this vector to an array.
3676
- * @param out - The array
3677
- * @param outOffset - The start offset of the array
3678
- */ _proto.copyToArray = function copyToArray(out, outOffset) {
3679
- if (outOffset === void 0) outOffset = 0;
3680
- out[outOffset] = this._x;
3681
- out[outOffset + 1] = this._y;
3682
- };
3683
- /**
3684
- * Serialize this vector to a JSON representation.
3685
- * @returns A JSON representation of this vector
3686
- */ _proto.toJSON = function toJSON() {
3687
- return {
3688
- x: this._x,
3689
- y: this._y
3690
- };
3691
- };
3692
- /**
3693
- * Determines the sum of two vectors.
3694
- * @param left - The first vector to add
3695
- * @param right - The second vector to add
3696
- * @param out - The sum of two vectors
3697
- */ Vector2.add = function add(left, right, out) {
3698
- out._x = left._x + right._x;
3699
- out._y = left._y + right._y;
3700
- out._onValueChanged && out._onValueChanged();
3701
- };
3702
- /**
3703
- * Determines the difference between two vectors.
3704
- * @param left - The first vector to subtract
3705
- * @param right - The second vector to subtract
3706
- * @param out - The difference between two vectors
3707
- */ Vector2.subtract = function subtract(left, right, out) {
3708
- out._x = left._x - right._x;
3709
- out._y = left._y - right._y;
3710
- out._onValueChanged && out._onValueChanged();
3711
- };
3712
- /**
3713
- * Determines the product of two vectors.
3714
- * @param left - The first vector to multiply
3715
- * @param right - The second vector to multiply
3716
- * @param out - The product of two vectors
3717
- */ Vector2.multiply = function multiply(left, right, out) {
3718
- out._x = left._x * right._x;
3719
- out._y = left._y * right._y;
3720
- out._onValueChanged && out._onValueChanged();
3721
- };
3722
- /**
3723
- * Determines the divisor of two vectors.
3724
- * @param left - The first vector to divide
3725
- * @param right - The second vector to divide
3726
- * @param out - The divisor of two vectors
3727
- */ Vector2.divide = function divide(left, right, out) {
3728
- out._x = left._x / right._x;
3729
- out._y = left._y / right._y;
3730
- out._onValueChanged && out._onValueChanged();
3731
- };
3732
- /**
3733
- * Determines the dot product of two vectors.
3734
- * @param left - The first vector to dot
3735
- * @param right - The second vector to dot
3736
- * @returns The dot product of two vectors
3737
- */ Vector2.dot = function dot(left, right) {
3738
- return left._x * right._x + left._y * right._y;
3739
- };
3740
- /**
3741
- * Determines the distance of two vectors.
3742
- * @param left - The first vector
3743
- * @param right - The second vector
3744
- * @returns The distance of two vectors
3745
- */ Vector2.distance = function distance(left, right) {
3746
- var x = right._x - left._x;
3747
- var y = right._y - left._y;
3748
- return Math.sqrt(x * x + y * y);
3749
- };
3750
- /**
3751
- * Determines the squared distance of two vectors.
3752
- * @param left - The first vector
3753
- * @param right - The second vector
3754
- * @returns The squared distance of two vectors
3755
- */ Vector2.distanceSquared = function distanceSquared(left, right) {
3756
- var x = right._x - left._x;
3757
- var y = right._y - left._y;
3758
- return x * x + y * y;
3759
- };
3760
- /**
3761
- * Determines whether the specified vectors are equals.
3762
- * @param left - The first vector to compare
3763
- * @param right - The second vector to compare
3764
- * @returns True if the specified vectors are equals, false otherwise
3765
- */ Vector2.equals = function equals(left, right) {
3766
- return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y);
3767
- };
3768
- /**
3769
- * Performs a linear interpolation between two vectors.
3770
- * @param left - The first vector
3771
- * @param right - The second vector
3772
- * @param t - The blend amount where 0 returns left and 1 right
3773
- * @param out - The result of linear blending between two vectors
3774
- */ Vector2.lerp = function lerp(left, right, t, out) {
3775
- var _x = left._x, _y = left._y;
3776
- out._x = _x + (right._x - _x) * t;
3777
- out._y = _y + (right._y - _y) * t;
3778
- out._onValueChanged && out._onValueChanged();
3779
- };
3780
- /**
3781
- * Calculate a vector containing the largest components of the specified vectors.
3782
- * @param left - The first vector
3783
- * @param right - The second vector
3784
- * @param out - The vector containing the largest components of the specified vectors
3785
- */ Vector2.max = function max(left, right, out) {
3786
- out._x = Math.max(left._x, right._x);
3787
- out._y = Math.max(left._y, right._y);
3788
- out._onValueChanged && out._onValueChanged();
3789
- };
3790
- /**
3791
- * Calculate a vector containing the smallest components of the specified vectors.
3792
- * @param left - The first vector
3793
- * @param right - The second vector
3794
- * @param out - The vector containing the smallest components of the specified vectors
3795
- */ Vector2.min = function min(left, right, out) {
3796
- out._x = Math.min(left._x, right._x);
3797
- out._y = Math.min(left._y, right._y);
3798
- out._onValueChanged && out._onValueChanged();
3799
- };
3800
- /**
3801
- * Reverses the direction of a given vector.
3802
- * @param left - The vector to negate
3803
- * @param out - The vector facing in the opposite direction
3804
- */ Vector2.negate = function negate(left, out) {
3805
- out._x = -left._x;
3806
- out._y = -left._y;
3807
- out._onValueChanged && out._onValueChanged();
3808
- };
3809
- /**
3810
- * Converts the vector into a unit vector.
3811
- * @param left - The vector to normalize
3812
- * @param out - The normalized vector
3813
- */ Vector2.normalize = function normalize(left, out) {
3814
- var _x = left._x, _y = left._y;
3815
- var len = Math.sqrt(_x * _x + _y * _y);
3816
- if (len > MathUtil.zeroTolerance) {
3817
- len = 1 / len;
3818
- out._x = _x * len;
3819
- out._y = _y * len;
3820
- out._onValueChanged && out._onValueChanged();
3821
- }
3822
- };
3823
- /**
3824
- * Scale a vector by the given value.
3825
- * @param left - The vector to scale
3826
- * @param s - The amount by which to scale the vector
3827
- * @param out - The scaled vector
3828
- */ Vector2.scale = function scale(left, s, out) {
3829
- out._x = left._x * s;
3830
- out._y = left._y * s;
3831
- out._onValueChanged && out._onValueChanged();
3832
- };
3833
- _create_class(Vector2, [
3834
- {
3835
- key: "x",
3836
- get: /**
3837
- * The x component of the vector.
3838
- */ function get() {
3839
- return this._x;
3840
- },
3841
- set: function set(value) {
3842
- this._x = value;
3843
- this._onValueChanged && this._onValueChanged();
3844
- }
3845
- },
3846
- {
3847
- key: "y",
3848
- get: /**
3849
- * The y component of the vector.
3850
- */ function get() {
3851
- return this._y;
3852
- },
3853
- set: function set(value) {
3854
- this._y = value;
3855
- this._onValueChanged && this._onValueChanged();
3856
- }
3857
- }
3858
- ]);
3859
- return Vector2;
3860
- }();
3861
- (function() {
3862
- /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
3863
- })();
3864
- (function() {
3865
- /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
3866
- })();
3867
- /**
3868
- * Describes a 4D-vector.
3869
- */ var Vector4 = /*#__PURE__*/ function() {
3870
- var Vector4 = function Vector4(x, y, z, w) {
3871
- if (x === void 0) x = 0;
3872
- if (y === void 0) y = 0;
3873
- if (z === void 0) z = 0;
3874
- if (w === void 0) w = 0;
3875
- /** @internal */ this._onValueChanged = null;
3876
- this._x = x;
3877
- this._y = y;
3878
- this._z = z;
3879
- this._w = w;
3880
- };
3881
- var _proto = Vector4.prototype;
3882
- /**
3883
- * Set the value of this vector.
3884
- * @param x - The x component of the vector
3885
- * @param y - The y component of the vector
3886
- * @param z - The z component of the vector
3887
- * @param w - The w component of the vector
3888
- * @returns This vector
3889
- */ _proto.set = function set(x, y, z, w) {
3890
- this._x = x;
3891
- this._y = y;
3892
- this._z = z;
3893
- this._w = w;
3894
- this._onValueChanged && this._onValueChanged();
3895
- return this;
3896
- };
3897
- /**
3898
- * Determines the sum of this vector and the specified vector.
3899
- * @param right - The specified vector
3900
- * @returns This vector
3901
- */ _proto.add = function add(right) {
3902
- this._x += right._x;
3903
- this._y += right._y;
3904
- this._z += right._z;
3905
- this._w += right._w;
3906
- this._onValueChanged && this._onValueChanged();
3907
- return this;
3908
- };
3909
- /**
3910
- * Determines the difference of this vector and the specified vector.
3911
- * @param right - the specified vector
3912
- * @returns This vector
3913
- */ _proto.subtract = function subtract(right) {
3914
- this._x -= right._x;
3915
- this._y -= right._y;
3916
- this._z -= right._z;
3917
- this._w -= right._w;
3918
- this._onValueChanged && this._onValueChanged();
3919
- return this;
3920
- };
3921
- /**
3922
- * Determines the product of this vector and the specified vector.
3923
- * @param right - the specified vector
3924
- * @returns This vector
3925
- */ _proto.multiply = function multiply(right) {
3926
- this._x *= right._x;
3927
- this._y *= right._y;
3928
- this._z *= right._z;
3929
- this._w *= right._w;
3930
- this._onValueChanged && this._onValueChanged();
3931
- return this;
3932
- };
3933
- /**
3934
- * Determines the divisor of this vector and the specified vector.
3935
- * @param right - the specified vector
3936
- * @returns This vector
3937
- */ _proto.divide = function divide(right) {
3938
- this._x /= right._x;
3939
- this._y /= right._y;
3940
- this._z /= right._z;
3941
- this._w /= right._w;
3942
- this._onValueChanged && this._onValueChanged();
3943
- return this;
3944
- };
3945
- /**
3946
- * Calculate the length of this vector.
3947
- * @returns The length of this vector
3948
- */ _proto.length = function length() {
3949
- var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
3950
- return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
3951
- };
3952
- /**
3953
- * Calculate the squared length of this vector.
3954
- * @returns The squared length of this vector
3955
- */ _proto.lengthSquared = function lengthSquared() {
3956
- var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
3957
- return _x * _x + _y * _y + _z * _z + _w * _w;
3958
- };
3959
- /**
3960
- * Reverses the direction of this vector.
3961
- * @returns This vector
3962
- */ _proto.negate = function negate() {
3963
- this._x = -this._x;
3964
- this._y = -this._y;
3965
- this._z = -this._z;
3966
- this._w = -this._w;
3967
- this._onValueChanged && this._onValueChanged();
3968
- return this;
3969
- };
3970
- /**
3971
- * Converts this vector into a unit vector.
3972
- * @returns This vector
3973
- */ _proto.normalize = function normalize() {
3974
- Vector4.normalize(this, this);
3975
- return this;
3976
- };
3977
- /**
3978
- * Scale this vector by the given value.
3979
- * @param s - The amount by which to scale the vector
3980
- * @returns This vector
3981
- */ _proto.scale = function scale(s) {
3982
- this._x *= s;
3983
- this._y *= s;
3984
- this._z *= s;
3985
- this._w *= s;
3986
- this._onValueChanged && this._onValueChanged();
3987
- return this;
3988
- };
3989
- /**
3990
- * Creates a clone of this vector.
3991
- * @returns A clone of this vector
3992
- */ _proto.clone = function clone() {
3993
- var ret = new Vector4(this._x, this._y, this._z, this._w);
3994
- return ret;
3995
- };
3996
- /**
3997
- * Copy from vector3 like object.
3998
- * @param source - Vector3 like object.
3999
- * @returns This vector
4000
- */ _proto.copyFrom = function copyFrom(source) {
4001
- this._x = source.x;
4002
- this._y = source.y;
4003
- this._z = source.z;
4004
- this._w = source.w;
4005
- this._onValueChanged && this._onValueChanged();
4006
- return this;
4007
- };
4008
- /**
4009
- * Copy the value of this vector by an array.
4010
- * @param array - The array
4011
- * @param offset - The start offset of the array
4012
- * @returns This vector
4013
- */ _proto.copyFromArray = function copyFromArray(array, offset) {
4014
- if (offset === void 0) offset = 0;
4015
- this._x = array[offset];
4016
- this._y = array[offset + 1];
4017
- this._z = array[offset + 2];
4018
- this._w = array[offset + 3];
4019
- this._onValueChanged && this._onValueChanged();
4020
- return this;
4021
- };
4022
- /**
4023
- * Copy the value of this vector to an array.
4024
- * @param out - The array
4025
- * @param outOffset - The start offset of the array
4026
- */ _proto.copyToArray = function copyToArray(out, outOffset) {
4027
- if (outOffset === void 0) outOffset = 0;
4028
- out[outOffset] = this._x;
4029
- out[outOffset + 1] = this._y;
4030
- out[outOffset + 2] = this._z;
4031
- out[outOffset + 3] = this._w;
4032
- };
4033
- /**
4034
- * Serialize this vector to a JSON representation.
4035
- * @returns A JSON representation of this vector
4036
- */ _proto.toJSON = function toJSON() {
4037
- return {
4038
- x: this._x,
4039
- y: this._y,
4040
- z: this._z,
4041
- w: this._w
4042
- };
4043
- };
4044
- /**
4045
- * Determines the sum of two vectors.
4046
- * @param left - The first vector to add
4047
- * @param right - The second vector to add
4048
- * @param out - The sum of two vectors
4049
- */ Vector4.add = function add(left, right, out) {
4050
- out._x = left._x + right._x;
4051
- out._y = left._y + right._y;
4052
- out._z = left._z + right._z;
4053
- out._w = left._w + right._w;
4054
- out._onValueChanged && out._onValueChanged();
4055
- };
4056
- /**
4057
- * Determines the difference between two vectors.
4058
- * @param left - The first vector to subtract
4059
- * @param right - The second vector to subtract
4060
- * @param out - The difference between two vectors
4061
- */ Vector4.subtract = function subtract(left, right, out) {
4062
- out._x = left._x - right._x;
4063
- out._y = left._y - right._y;
4064
- out._z = left._z - right._z;
4065
- out._w = left._w - right._w;
4066
- out._onValueChanged && out._onValueChanged();
4067
- };
4068
- /**
4069
- * Determines the product of two vectors.
4070
- * @param left - The first vector to multiply
4071
- * @param right - The second vector to multiply
4072
- * @param out - The product of two vectors
4073
- */ Vector4.multiply = function multiply(left, right, out) {
4074
- out._x = left._x * right._x;
4075
- out._y = left._y * right._y;
4076
- out._z = left._z * right._z;
4077
- out._w = left._w * right._w;
4078
- out._onValueChanged && out._onValueChanged();
4079
- };
4080
- /**
4081
- * Determines the divisor of two vectors.
4082
- * @param left - The first vector to divide
4083
- * @param right - The second vector to divide
4084
- * @param out - The divisor of two vectors
4085
- */ Vector4.divide = function divide(left, right, out) {
4086
- out._x = left._x / right._x;
4087
- out._y = left._y / right._y;
4088
- out._z = left._z / right._z;
4089
- out._w = left._w / right._w;
4090
- out._onValueChanged && out._onValueChanged();
4091
- };
4092
- /**
4093
- * Determines the dot product of two vectors.
4094
- * @param left - The first vector to dot
4095
- * @param right - The second vector to dot
4096
- * @returns The dot product of two vectors
4097
- */ Vector4.dot = function dot(left, right) {
4098
- return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
4099
- };
4100
- /**
4101
- * Determines the distance of two vectors.
4102
- * @param a - The first vector
4103
- * @param b - The second vector
4104
- * @returns The distance of two vectors
4105
- */ Vector4.distance = function distance(a, b) {
4106
- var x = b._x - a._x;
4107
- var y = b._y - a._y;
4108
- var z = b._z - a._z;
4109
- var w = b._w - a._w;
4110
- return Math.sqrt(x * x + y * y + z * z + w * w);
4111
- };
4112
- /**
4113
- * Determines the squared distance of two vectors.
4114
- * @param a - The first vector
4115
- * @param b - The second vector
4116
- * @returns The squared distance of two vectors
4117
- */ Vector4.distanceSquared = function distanceSquared(a, b) {
4118
- var x = b._x - a._x;
4119
- var y = b._y - a._y;
4120
- var z = b._z - a._z;
4121
- var w = b._w - a._w;
4122
- return x * x + y * y + z * z + w * w;
4123
- };
4124
- /**
4125
- * Determines whether the specified vectors are equals.
4126
- * @param left - The first vector to compare
4127
- * @param right - The second vector to compare
4128
- * @returns True if the specified vectors are equals, false otherwise
4129
- */ Vector4.equals = function equals(left, right) {
4130
- 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);
4131
- };
4132
- /**
4133
- * Performs a linear interpolation between two vectors.
4134
- * @param start - The first vector
4135
- * @param end - The second vector
4136
- * @param t - The blend amount where 0 returns start and 1 end
4137
- * @param out - The result of linear blending between two vectors
4138
- */ Vector4.lerp = function lerp(start, end, t, out) {
4139
- var _x = start._x, _y = start._y, _z = start._z, _w = start._w;
4140
- out._x = _x + (end._x - _x) * t;
4141
- out._y = _y + (end._y - _y) * t;
4142
- out._z = _z + (end._z - _z) * t;
4143
- out._w = _w + (end._w - _w) * t;
4144
- out._onValueChanged && out._onValueChanged();
4145
- };
4146
- /**
4147
- * Calculate a vector containing the largest components of the specified vectors.
4148
- * @param left - The first vector
4149
- * @param right - The second vector
4150
- * @param out - The vector containing the largest components of the specified vectors
4151
- */ Vector4.max = function max(left, right, out) {
4152
- out._x = Math.max(left._x, right._x);
4153
- out._y = Math.max(left._y, right._y);
4154
- out._z = Math.max(left._z, right._z);
4155
- out._w = Math.max(left._w, right._w);
4156
- out._onValueChanged && out._onValueChanged();
4157
- };
4158
- /**
4159
- * Calculate a vector containing the smallest components of the specified vectors.
4160
- * @param left - The first vector
4161
- * @param right - The second vector
4162
- * @param out - The vector containing the smallest components of the specified vectors
4163
- */ Vector4.min = function min(left, right, out) {
4164
- out._x = Math.min(left._x, right._x);
4165
- out._y = Math.min(left._y, right._y);
4166
- out._z = Math.min(left._z, right._z);
4167
- out._w = Math.min(left._w, right._w);
4168
- out._onValueChanged && out._onValueChanged();
4169
- };
4170
- /**
4171
- * Reverses the direction of a given vector.
4172
- * @param a - The vector to negate
4173
- * @param out - The vector facing in the opposite direction
4174
- */ Vector4.negate = function negate(a, out) {
4175
- out._x = -a._x;
4176
- out._y = -a._y;
4177
- out._z = -a._z;
4178
- out._w = -a._w;
4179
- out._onValueChanged && out._onValueChanged();
4180
- };
4181
- /**
4182
- * Converts the vector into a unit vector.
4183
- * @param a - The vector to normalize
4184
- * @param out - The normalized vector
4185
- */ Vector4.normalize = function normalize(a, out) {
4186
- var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
4187
- var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
4188
- if (len > MathUtil.zeroTolerance) {
4189
- len = 1 / len;
4190
- out._x = _x * len;
4191
- out._y = _y * len;
4192
- out._z = _z * len;
4193
- out._w = _w * len;
4194
- out._onValueChanged && out._onValueChanged();
4195
- }
4196
- };
4197
- /**
4198
- * Scale a vector by the given value.
4199
- * @param a - The vector to scale
4200
- * @param s - The amount by which to scale the vector
4201
- * @param out - The scaled vector
4202
- */ Vector4.scale = function scale(a, s, out) {
4203
- out._x = a._x * s;
4204
- out._y = a._y * s;
4205
- out._z = a._z * s;
4206
- out._w = a._w * s;
4207
- out._onValueChanged && out._onValueChanged();
4208
- };
4209
- /**
4210
- * Performs a transformation using the given 4x4 matrix.
4211
- * @param v - The vector to transform
4212
- * @param m - The transform matrix
4213
- * @param out - The transformed vector3
4214
- */ Vector4.transform = function transform(v, m, out) {
4215
- var _x = v._x, _y = v._y, _z = v._z, _w = v._w;
4216
- var e = m.elements;
4217
- out._x = _x * e[0] + _y * e[4] + _z * e[8] + _w * e[12];
4218
- out._y = _x * e[1] + _y * e[5] + _z * e[9] + _w * e[13];
4219
- out._z = _x * e[2] + _y * e[6] + _z * e[10] + _w * e[14];
4220
- out._w = _x * e[3] + _y * e[7] + _z * e[11] + _w * e[15];
4221
- out._onValueChanged && out._onValueChanged();
4222
- };
4223
- /**
4224
- * Performs a transformation using the given quaternion.
4225
- * @param v - The vector to transform
4226
- * @param q - The transform quaternion
4227
- * @param out - The transformed vector
4228
- */ Vector4.transformByQuat = function transformByQuat(v, q, out) {
4229
- var x = v._x, y = v._y, z = v._z, w = v._w;
4230
- var qx = q._x;
4231
- var qy = q._y;
4232
- var qz = q._z;
4233
- var qw = q._w;
4234
- // calculate quat * vec
4235
- var ix = qw * x + qy * z - qz * y;
4236
- var iy = qw * y + qz * x - qx * z;
4237
- var iz = qw * z + qx * y - qy * x;
4238
- var iw = -qx * x - qy * y - qz * z;
4239
- // calculate result * inverse quat
4240
- out._x = ix * qw - iw * qx - iy * qz + iz * qy;
4241
- out._y = iy * qw - iw * qy - iz * qx + ix * qz;
4242
- out._z = iz * qw - iw * qz - ix * qy + iy * qx;
4243
- out._w = w;
4244
- out._onValueChanged && out._onValueChanged();
4245
- };
4246
- _create_class(Vector4, [
4247
- {
4248
- key: "x",
4249
- get: /**
4250
- * The x component of the vector.
4251
- */ function get() {
4252
- return this._x;
4253
- },
4254
- set: function set(value) {
4255
- this._x = value;
4256
- this._onValueChanged && this._onValueChanged();
4257
- }
4258
- },
4259
- {
4260
- key: "y",
4261
- get: /**
4262
- * The y component of the vector.
4263
- */ function get() {
4264
- return this._y;
4265
- },
4266
- set: function set(value) {
4267
- this._y = value;
4268
- this._onValueChanged && this._onValueChanged();
4269
- }
4270
- },
4271
- {
4272
- key: "z",
4273
- get: /**
4274
- * The z component of the vector.
4275
- */ function get() {
4276
- return this._z;
4277
- },
4278
- set: function set(value) {
4279
- this._z = value;
4280
- this._onValueChanged && this._onValueChanged();
4281
- }
4282
- },
4283
- {
4284
- key: "w",
4285
- get: /**
4286
- * The w component of the vector.
4287
- */ function get() {
4288
- return this._w;
4289
- },
4290
- set: function set(value) {
4291
- this._w = value;
4292
- this._onValueChanged && this._onValueChanged();
4293
- }
4294
- }
4295
- ]);
4296
- return Vector4;
4297
- }();
4298
- (function() {
4299
- /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
4300
- })();
4301
- (function() {
4302
- /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
4303
- })();
4304
-
4305
- var WebXRFrame = /*#__PURE__*/ function() {
4306
- function WebXRFrame(session) {
4307
- this._session = session;
4308
- }
4309
- var _proto = WebXRFrame.prototype;
4310
- _proto.updateInputs = function updateInputs(inputs) {
4311
- if (!this._platformFrame) return;
4312
- this._updateController(inputs);
4313
- this._updateCamera(inputs);
4314
- };
4315
- _proto._updateController = function _updateController(inputs) {
4316
- var _this = this, frame = _this._platformFrame;
4317
- var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
4318
- var inputSources = session.inputSources;
4319
- for(var i = 0, n = inputSources.length; i < n; i++){
4320
- var inputSource = inputSources[i];
4321
- var type = getInputSource(inputSource);
4322
- var input = inputs[type];
4323
- switch(inputSource.targetRayMode){
4324
- case "screen":
4325
- case "tracked-pointer":
4326
- var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
4327
- if (gripSpace) {
4328
- var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
4329
- if (transform) {
4330
- var gripPose = input.gripPose;
4331
- gripPose.matrix.copyFromArray(transform.matrix);
4332
- gripPose.position.copyFrom(transform.position);
4333
- gripPose.rotation.copyFrom(transform.orientation);
4334
- }
4335
- input.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4336
- }
4337
- if (targetRaySpace) {
4338
- var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
4339
- if (transform1) {
4340
- var targetRayPose = input.targetRayPose;
4341
- targetRayPose.matrix.copyFromArray(transform1.matrix);
4342
- targetRayPose.position.copyFrom(transform1.position);
4343
- targetRayPose.rotation.copyFrom(transform1.orientation);
4344
- input.trackingState = emulatedPosition1 ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4345
- }
4346
- }
4347
- break;
4348
- }
4349
- }
4350
- };
4351
- _proto._updateCamera = function _updateCamera(inputs) {
4352
- var _this = this, frame = _this._platformFrame;
4353
- var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
4354
- var viewerPose = frame.getViewerPose(referenceSpace);
4355
- if (viewerPose) {
4356
- var hadUpdateCenterViewer = false;
4357
- var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
4358
- for(var i = 0, n = views.length; i < n; i++){
4359
- var view = views[i];
4360
- var type = viewToCamera(view.eye);
4361
- var transform = views[i].transform;
4362
- if (type === XRTrackedInputDevice.Camera) {
4363
- hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
4364
- }
4365
- var xrCamera = inputs[type];
4366
- var pose = xrCamera.pose;
4367
- pose.matrix.copyFromArray(transform.matrix);
4368
- pose.position.copyFrom(transform.position);
4369
- pose.rotation.copyFrom(transform.orientation);
4370
- xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
4371
- xrCamera.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4372
- var xrViewport = layer.getViewport(view);
4373
- var width = xrViewport.width / framebufferWidth;
4374
- var height = xrViewport.height / framebufferHeight;
4375
- var x = xrViewport.x / framebufferWidth;
4376
- var y = 1 - xrViewport.y / framebufferHeight - height;
4377
- xrCamera.viewport.set(x, y, width, height);
4378
- }
4379
- if (!hadUpdateCenterViewer) {
4380
- var leftCameraDevice = inputs[XRTrackedInputDevice.LeftCamera];
4381
- var rightCameraDevice = inputs[XRTrackedInputDevice.RightCamera];
4382
- var cameraDevice = inputs[XRTrackedInputDevice.Camera];
4383
- var leftCameraPose = leftCameraDevice.pose;
4384
- var rightCameraPose = rightCameraDevice.pose;
4385
- var cameraPose = cameraDevice.pose;
4386
- cameraPose.rotation.copyFrom(leftCameraPose.rotation);
4387
- var position = cameraPose.position, matrix = cameraPose.matrix;
4388
- Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
4389
- position.scale(0.5);
4390
- matrix.copyFrom(leftCameraPose.matrix);
4391
- var elements = matrix.elements;
4392
- elements[12] = position.x;
4393
- elements[13] = position.y;
4394
- elements[14] = position.z;
4395
- cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
4396
- cameraDevice.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4397
- cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
4398
- }
4399
- }
2929
+ _proto._updateCamera = function _updateCamera(inputs) {
2930
+ var _this = this, frame = _this._platformFrame;
2931
+ var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
2932
+ var viewerPose = frame.getViewerPose(referenceSpace);
2933
+ if (viewerPose) {
2934
+ var hadUpdateCenterViewer = false;
2935
+ var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
2936
+ for(var i = 0, n = views.length; i < n; i++){
2937
+ var view = views[i];
2938
+ var type = viewToCamera(view.eye);
2939
+ var transform = views[i].transform;
2940
+ if (type === XRTrackedInputDevice.Camera) {
2941
+ hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
2942
+ }
2943
+ var xrCamera = inputs[type];
2944
+ var pose = xrCamera.pose;
2945
+ pose.matrix.copyFromArray(transform.matrix);
2946
+ pose.position.copyFrom(transform.position);
2947
+ pose.rotation.copyFrom(transform.orientation);
2948
+ xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
2949
+ xrCamera.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
2950
+ var xrViewport = layer.getViewport(view);
2951
+ var width = xrViewport.width / framebufferWidth;
2952
+ var height = xrViewport.height / framebufferHeight;
2953
+ var x = xrViewport.x / framebufferWidth;
2954
+ var y = 1 - xrViewport.y / framebufferHeight - height;
2955
+ xrCamera.viewport.set(x, y, width, height);
2956
+ }
2957
+ if (!hadUpdateCenterViewer) {
2958
+ var leftCameraDevice = inputs[XRTrackedInputDevice.LeftCamera];
2959
+ var rightCameraDevice = inputs[XRTrackedInputDevice.RightCamera];
2960
+ var cameraDevice = inputs[XRTrackedInputDevice.Camera];
2961
+ var leftCameraPose = leftCameraDevice.pose;
2962
+ var rightCameraPose = rightCameraDevice.pose;
2963
+ var cameraPose = cameraDevice.pose;
2964
+ cameraPose.rotation.copyFrom(leftCameraPose.rotation);
2965
+ var position = cameraPose.position, matrix = cameraPose.matrix;
2966
+ Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
2967
+ position.scale(0.5);
2968
+ matrix.copyFrom(leftCameraPose.matrix);
2969
+ var elements = matrix.elements;
2970
+ elements[12] = position.x;
2971
+ elements[13] = position.y;
2972
+ elements[14] = position.z;
2973
+ cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
2974
+ cameraDevice.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
2975
+ cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
2976
+ }
2977
+ }
4400
2978
  };
4401
2979
  return WebXRFrame;
4402
2980
  }();
@@ -4686,9 +3264,7 @@ var WebXRDevice = /*#__PURE__*/ function() {
4686
3264
  };
4687
3265
  return WebXRDevice;
4688
3266
  }();
4689
- (function() {
4690
- /** @internal */ WebXRDevice._platformFeatureMap = [];
4691
- })();
3267
+ /** @internal */ WebXRDevice._platformFeatureMap = [];
4692
3268
  function registerXRPlatformFeature(type) {
4693
3269
  return function(platformFeatureConstructor) {
4694
3270
  WebXRDevice._platformFeatureMap[type] = platformFeatureConstructor;
@@ -4702,10 +3278,10 @@ function registerXRPlatformFeature(type) {
4702
3278
 
4703
3279
  /**
4704
3280
  * @internal
4705
- */ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature1) {
4706
- _inherits(WebXRTrackableFeature, WebXRFeature1);
3281
+ */ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature) {
3282
+ _inherits(WebXRTrackableFeature, WebXRFeature);
4707
3283
  function WebXRTrackableFeature() {
4708
- return WebXRFeature1.apply(this, arguments);
3284
+ return WebXRFeature.apply(this, arguments) || this;
4709
3285
  }
4710
3286
  var _proto = WebXRTrackableFeature.prototype;
4711
3287
  _proto.onAddRequestTracking = function onAddRequestTracking(requestTracking) {};
@@ -4723,10 +3299,10 @@ function registerXRPlatformFeature(type) {
4723
3299
  return WebXRTrackableFeature;
4724
3300
  }(WebXRFeature);
4725
3301
 
4726
- var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
4727
- _inherits(WebXRAnchorTracking, WebXRTrackableFeature1);
3302
+ var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
3303
+ _inherits(WebXRAnchorTracking, WebXRTrackableFeature);
4728
3304
  function WebXRAnchorTracking() {
4729
- return WebXRTrackableFeature1.apply(this, arguments);
3305
+ return WebXRTrackableFeature.apply(this, arguments) || this;
4730
3306
  }
4731
3307
  var _proto = WebXRAnchorTracking.prototype;
4732
3308
  _proto.checkAvailable = function checkAvailable(session, frame, requestTrackings) {
@@ -4837,14 +3413,11 @@ WebXRAnchorTracking = __decorate([
4837
3413
  registerXRPlatformFeature(XRFeatureType.AnchorTracking)
4838
3414
  ], WebXRAnchorTracking);
4839
3415
 
4840
- var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
4841
- _inherits(WebXRImageTracking, WebXRTrackableFeature1);
3416
+ var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
3417
+ _inherits(WebXRImageTracking, WebXRTrackableFeature);
4842
3418
  function WebXRImageTracking(images) {
4843
3419
  var _this;
4844
- _this = WebXRTrackableFeature1.call(this) || this;
4845
- _this._trackingScoreStatus = 0;
4846
- _this._tempIdx = 0;
4847
- _this._tempArr = [];
3420
+ _this = WebXRTrackableFeature.call(this) || this, _this._trackingScoreStatus = 0, _this._tempIdx = 0, _this._tempArr = [];
4848
3421
  _this._images = images;
4849
3422
  return _this;
4850
3423
  }
@@ -4961,17 +3534,12 @@ var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
4961
3534
  WebXRImageTracking = __decorate([
4962
3535
  registerXRPlatformFeature(XRFeatureType.ImageTracking)
4963
3536
  ], WebXRImageTracking);
4964
- var ImageTrackingScoreStatus;
4965
- (function(ImageTrackingScoreStatus) {
4966
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["NotReceived"] = 0] = "NotReceived";
4967
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["Waiting"] = 1] = "Waiting";
4968
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["Received"] = 2] = "Received";
4969
- })(ImageTrackingScoreStatus || (ImageTrackingScoreStatus = {}));
4970
3537
 
4971
- var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
4972
- _inherits(WebXRPlaneTracking, WebXRTrackableFeature1);
3538
+ var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
3539
+ _inherits(WebXRPlaneTracking, WebXRTrackableFeature);
4973
3540
  function WebXRPlaneTracking(detectedMode) {
4974
- var _this = WebXRTrackableFeature1.call(this);
3541
+ var _this;
3542
+ _this = WebXRTrackableFeature.call(this) || this;
4975
3543
  if (detectedMode !== XRPlaneMode.EveryThing) {
4976
3544
  console.warn("WebXR only support XRPlaneMode.EveryThing");
4977
3545
  }
@@ -5000,8 +3568,7 @@ var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
5000
3568
  }
5001
3569
  var _this1 = this, lastDetectedPlanes = _this1._lastDetectedPlanes;
5002
3570
  detectedPlanes.forEach(function(xrPlane) {
5003
- var _lastDetectedPlanes;
5004
- if (!((_lastDetectedPlanes = lastDetectedPlanes) == null ? void 0 : _lastDetectedPlanes.has(xrPlane))) {
3571
+ if (!(lastDetectedPlanes == null ? void 0 : lastDetectedPlanes.has(xrPlane))) {
5005
3572
  var plane = generateTracked();
5006
3573
  plane.xrPlane = xrPlane;
5007
3574
  plane.lastChangedTime = -1;