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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -75,16 +75,25 @@
75
75
  } else return left instanceof right;
76
76
  }
77
77
 
78
+ function _type_of(obj) {
79
+ "@swc/helpers - typeof";
80
+
81
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
82
+ }
83
+
78
84
  function _is_native_reflect_construct$1() {
79
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
80
- if (Reflect.construct.sham) return false;
81
- if (typeof Proxy === "function") return true;
85
+ // Since Reflect.construct can't be properly polyfilled, some
86
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
87
+ // Those polyfills don't allow us to subclass built-ins, so we need to
88
+ // use our fallback implementation.
82
89
  try {
83
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
84
- return true;
85
- } catch (e) {
86
- return false;
87
- }
90
+ // If the internal slots aren't set, this throws an error similar to
91
+ // TypeError: this is not a Boolean object.
92
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
93
+ } catch (_) {}
94
+ return (_is_native_reflect_construct$1 = function _is_native_reflect_construct() {
95
+ return !!result;
96
+ })();
88
97
  }
89
98
  function _set_prototype_of(o, p) {
90
99
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -143,33 +152,33 @@
143
152
  }
144
153
  /**
145
154
  * Enumerates some input devices that can be tracked.(including status, posture and other information)
146
- */ var XRTrackedInputDevice;
147
- (function(XRTrackedInputDevice) {
148
- XRTrackedInputDevice[XRTrackedInputDevice[/** Controller */ "Controller"] = 0] = "Controller";
149
- XRTrackedInputDevice[XRTrackedInputDevice[/** Left controller */ "LeftController"] = 1] = "LeftController";
150
- XRTrackedInputDevice[XRTrackedInputDevice[/** Right controller */ "RightController"] = 2] = "RightController";
151
- XRTrackedInputDevice[XRTrackedInputDevice[/** Camera */ "Camera"] = 3] = "Camera";
152
- XRTrackedInputDevice[XRTrackedInputDevice[/** Left camera */ "LeftCamera"] = 4] = "LeftCamera";
153
- XRTrackedInputDevice[XRTrackedInputDevice[/** Right camera */ "RightCamera"] = 5] = "RightCamera";
154
- XRTrackedInputDevice[XRTrackedInputDevice[/** Head */ "LeftHand"] = 6] = "LeftHand";
155
- XRTrackedInputDevice[XRTrackedInputDevice[/** Right hand */ "RightHand"] = 7] = "RightHand";
156
- })(XRTrackedInputDevice || (XRTrackedInputDevice = {}));
155
+ */ var XRTrackedInputDevice = /*#__PURE__*/ function(XRTrackedInputDevice) {
156
+ /** Controller */ XRTrackedInputDevice[XRTrackedInputDevice["Controller"] = 0] = "Controller";
157
+ /** Left controller */ XRTrackedInputDevice[XRTrackedInputDevice["LeftController"] = 1] = "LeftController";
158
+ /** Right controller */ XRTrackedInputDevice[XRTrackedInputDevice["RightController"] = 2] = "RightController";
159
+ /** Camera */ XRTrackedInputDevice[XRTrackedInputDevice["Camera"] = 3] = "Camera";
160
+ /** Left camera */ XRTrackedInputDevice[XRTrackedInputDevice["LeftCamera"] = 4] = "LeftCamera";
161
+ /** Right camera */ XRTrackedInputDevice[XRTrackedInputDevice["RightCamera"] = 5] = "RightCamera";
162
+ /** Head */ XRTrackedInputDevice[XRTrackedInputDevice["LeftHand"] = 6] = "LeftHand";
163
+ /** Right hand */ XRTrackedInputDevice[XRTrackedInputDevice["RightHand"] = 7] = "RightHand";
164
+ return XRTrackedInputDevice;
165
+ }({});
157
166
  /**
158
167
  * The state of an XRSession.
159
- */ var XRSessionState;
160
- (function(XRSessionState) {
161
- XRSessionState[XRSessionState[/** Not initialized. */ "None"] = 0] = "None";
162
- XRSessionState[XRSessionState[/** Initializing session. */ "Initializing"] = 1] = "Initializing";
163
- XRSessionState[XRSessionState[/** Initialized but not started. */ "Initialized"] = 2] = "Initialized";
164
- XRSessionState[XRSessionState[/** Running. */ "Running"] = 3] = "Running";
165
- XRSessionState[XRSessionState[/** Paused. */ "Paused"] = 4] = "Paused";
166
- })(XRSessionState || (XRSessionState = {}));
168
+ */ var XRSessionState = /*#__PURE__*/ function(XRSessionState) {
169
+ /** Not initialized. */ XRSessionState[XRSessionState["None"] = 0] = "None";
170
+ /** Initializing session. */ XRSessionState[XRSessionState["Initializing"] = 1] = "Initializing";
171
+ /** Initialized but not started. */ XRSessionState[XRSessionState["Initialized"] = 2] = "Initialized";
172
+ /** Running. */ XRSessionState[XRSessionState["Running"] = 3] = "Running";
173
+ /** Paused. */ XRSessionState[XRSessionState["Paused"] = 4] = "Paused";
174
+ return XRSessionState;
175
+ }({});
167
176
  /**
168
177
  * The manager of XR camera.
169
178
  */ var XRCameraManager = /*#__PURE__*/ function() {
170
- var XRCameraManager = function XRCameraManager(_xrManager) {
179
+ function XRCameraManager(_xrManager) {
171
180
  this._xrManager = _xrManager;
172
- };
181
+ }
173
182
  var _proto = XRCameraManager.prototype;
174
183
  /**
175
184
  * Attach the camera to the specified input type(Camera, LeftCamera or RightCamera).
@@ -293,56 +302,48 @@
293
302
  };
294
303
  /**
295
304
  * Enum for XR tracking state.
296
- */ var XRTrackingState;
297
- (function(XRTrackingState) {
298
- XRTrackingState[XRTrackingState[/** Not tracking */ "NotTracking"] = 0] = "NotTracking";
299
- XRTrackingState[XRTrackingState[/** Tracking */ "Tracking"] = 1] = "Tracking";
300
- XRTrackingState[XRTrackingState[/** Lost track */ "TrackingLost"] = 2] = "TrackingLost";
301
- })(XRTrackingState || (XRTrackingState = {}));
305
+ */ var XRTrackingState = /*#__PURE__*/ function(XRTrackingState) {
306
+ /** Not tracking */ XRTrackingState[XRTrackingState["NotTracking"] = 0] = "NotTracking";
307
+ /** Tracking */ XRTrackingState[XRTrackingState["Tracking"] = 1] = "Tracking";
308
+ /** Lost track */ XRTrackingState[XRTrackingState["TrackingLost"] = 2] = "TrackingLost";
309
+ return XRTrackingState;
310
+ }({});
302
311
  var XRInput = function XRInput(type) {
303
312
  this.type = type;
304
313
  this./** The tracking state of xr input. */ trackingState = XRTrackingState.NotTracking;
305
314
  };
306
315
  /**
307
316
  * The XR camera.
308
- */ var XRCamera = /*#__PURE__*/ function(XRInput1) {
309
- var XRCamera = function XRCamera() {
317
+ */ var XRCamera = /*#__PURE__*/ function(XRInput) {
318
+ _inherits(XRCamera, XRInput);
319
+ function XRCamera() {
310
320
  var _this;
311
- _this = XRInput1.apply(this, arguments) || this;
312
- /** The pose of the camera in XR space. */ _this.pose = new XRPose();
313
- /** The viewport of the camera. */ _this.viewport = new engine.Rect();
314
- /** The projection matrix of the camera. */ _this.projectionMatrix = new engine.Matrix();
321
+ _this = XRInput.apply(this, arguments) || this, /** The pose of the camera in XR space. */ _this.pose = new XRPose(), /** The viewport of the camera. */ _this.viewport = new engine.Rect(), /** The projection matrix of the camera. */ _this.projectionMatrix = new engine.Matrix();
315
322
  return _this;
316
- };
317
- _inherits(XRCamera, XRInput1);
323
+ }
318
324
  return XRCamera;
319
325
  }(XRInput);
320
326
  /**
321
327
  * Enum for XR input button.
322
- */ var XRInputButton;
323
- (function(XRInputButton) {
324
- XRInputButton[XRInputButton[/** None */ "None"] = 0x0] = "None";
325
- XRInputButton[XRInputButton[/** Select */ "Select"] = 0x1] = "Select";
326
- XRInputButton[XRInputButton[/** Select */ "Trigger"] = 0x1] = "Trigger";
327
- XRInputButton[XRInputButton[/** Squeeze */ "Squeeze"] = 0x2] = "Squeeze";
328
- XRInputButton[XRInputButton[/** TouchPad */ "TouchPad"] = 0x4] = "TouchPad";
329
- XRInputButton[XRInputButton[/** A */ "AButton"] = 0x8] = "AButton";
330
- XRInputButton[XRInputButton[/** B */ "BButton"] = 0x10] = "BButton";
331
- })(XRInputButton || (XRInputButton = {}));
328
+ */ var XRInputButton = /*#__PURE__*/ function(XRInputButton) {
329
+ /** None */ XRInputButton[XRInputButton["None"] = 0] = "None";
330
+ /** Select */ XRInputButton[XRInputButton["Select"] = 1] = "Select";
331
+ /** Select */ XRInputButton[XRInputButton["Trigger"] = 1] = "Trigger";
332
+ /** Squeeze */ XRInputButton[XRInputButton["Squeeze"] = 2] = "Squeeze";
333
+ /** TouchPad */ XRInputButton[XRInputButton["TouchPad"] = 4] = "TouchPad";
334
+ /** A */ XRInputButton[XRInputButton["AButton"] = 8] = "AButton";
335
+ /** B */ XRInputButton[XRInputButton["BButton"] = 16] = "BButton";
336
+ return XRInputButton;
337
+ }({});
332
338
  /**
333
339
  * The XR controller.
334
- */ var XRController = /*#__PURE__*/ function(XRInput1) {
335
- var XRController = function XRController() {
340
+ */ var XRController = /*#__PURE__*/ function(XRInput) {
341
+ _inherits(XRController, XRInput);
342
+ function XRController() {
336
343
  var _this;
337
- _this = XRInput1.apply(this, arguments) || this;
338
- /** The grip space pose of the controller in XR space. */ _this.gripPose = new XRPose();
339
- /** The target ray space pose of the controller in XR space. */ _this.targetRayPose = new XRPose();
340
- /** The currently pressed buttons of this controller. */ _this.pressedButtons = XRInputButton.None;
341
- /** Record button lifted. */ _this.down = XRInputButton.None;
342
- /** Record button pressed. */ _this.up = XRInputButton.None;
344
+ _this = XRInput.apply(this, arguments) || this, /** The grip space pose of the controller in XR space. */ _this.gripPose = new XRPose(), /** The target ray space pose of the controller in XR space. */ _this.targetRayPose = new XRPose(), /** The currently pressed buttons of this controller. */ _this.pressedButtons = XRInputButton.None, /** Record button lifted. */ _this.down = XRInputButton.None, /** Record button pressed. */ _this.up = XRInputButton.None;
343
345
  return _this;
344
- };
345
- _inherits(XRController, XRInput1);
346
+ }
346
347
  var _proto = XRController.prototype;
347
348
  /**
348
349
  *
@@ -368,25 +369,25 @@
368
369
  };
369
370
  return XRController;
370
371
  }(XRInput);
371
- var XRInputEventType;
372
- (function(XRInputEventType) {
372
+ var XRInputEventType = /*#__PURE__*/ function(XRInputEventType) {
373
373
  XRInputEventType[XRInputEventType["SelectStart"] = 0] = "SelectStart";
374
374
  XRInputEventType[XRInputEventType["Select"] = 1] = "Select";
375
375
  XRInputEventType[XRInputEventType["SelectEnd"] = 2] = "SelectEnd";
376
376
  XRInputEventType[XRInputEventType["SqueezeStart"] = 3] = "SqueezeStart";
377
377
  XRInputEventType[XRInputEventType["Squeeze"] = 4] = "Squeeze";
378
378
  XRInputEventType[XRInputEventType["SqueezeEnd"] = 5] = "SqueezeEnd";
379
- })(XRInputEventType || (XRInputEventType = {}));
380
- var XRTargetRayMode;
381
- (function(XRTargetRayMode) {
379
+ return XRInputEventType;
380
+ }({});
381
+ var XRTargetRayMode = /*#__PURE__*/ function(XRTargetRayMode) {
382
382
  XRTargetRayMode[XRTargetRayMode["Gaze"] = 0] = "Gaze";
383
383
  XRTargetRayMode[XRTargetRayMode["TrackedPointer"] = 1] = "TrackedPointer";
384
384
  XRTargetRayMode[XRTargetRayMode["Screen"] = 2] = "Screen";
385
- })(XRTargetRayMode || (XRTargetRayMode = {}));
385
+ return XRTargetRayMode;
386
+ }({});
386
387
  /**
387
388
  * The manager of XR input.
388
389
  */ var XRInputManager = /*#__PURE__*/ function() {
389
- var XRInputManager = function XRInputManager(_xrManager, _engine) {
390
+ function XRInputManager(_xrManager, _engine) {
390
391
  this._xrManager = _xrManager;
391
392
  this._engine = _engine;
392
393
  this./** @internal */ _cameras = [];
@@ -412,7 +413,7 @@
412
413
  }
413
414
  }
414
415
  this._statusSnapshot.fill(XRTrackingState.NotTracking, 0, trackedDevices.length);
415
- };
416
+ }
416
417
  var _proto = XRInputManager.prototype;
417
418
  /**
418
419
  * Returns the tracked device instance.
@@ -565,16 +566,16 @@
565
566
  }();
566
567
  /**
567
568
  * The type of XR session.
568
- */ var XRSessionMode;
569
- (function(XRSessionMode) {
569
+ */ var XRSessionMode = /*#__PURE__*/ function(XRSessionMode) {
570
570
  XRSessionMode[XRSessionMode["None"] = 0] = "None";
571
571
  XRSessionMode[XRSessionMode["AR"] = 1] = "AR";
572
572
  XRSessionMode[XRSessionMode["VR"] = 2] = "VR";
573
- })(XRSessionMode || (XRSessionMode = {}));
573
+ return XRSessionMode;
574
+ }({});
574
575
  /**
575
576
  * XRSessionManager manages the life cycle of XR sessions.
576
577
  */ var XRSessionManager = /*#__PURE__*/ function() {
577
- var XRSessionManager = function XRSessionManager(_xrManager, _engine) {
578
+ function XRSessionManager(_xrManager, _engine) {
578
579
  this._xrManager = _xrManager;
579
580
  this._engine = _engine;
580
581
  this._mode = XRSessionMode.None;
@@ -585,7 +586,7 @@
585
586
  this._raf = requestAnimationFrame.bind(window);
586
587
  this._caf = cancelAnimationFrame.bind(window);
587
588
  this._onSessionExit = this._onSessionExit.bind(this);
588
- };
589
+ }
589
590
  var _proto = XRSessionManager.prototype;
590
591
  /**
591
592
  * Check if the specified mode is supported.
@@ -772,11 +773,11 @@
772
773
  }();
773
774
  /**
774
775
  * @internal
775
- */ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
776
- var XRManagerExtended = function XRManagerExtended() {
777
- return XRManager1.apply(this, arguments);
778
- };
779
- _inherits(XRManagerExtended, XRManager1);
776
+ */ var XRManagerExtended = /*#__PURE__*/ function(XRManager) {
777
+ _inherits(XRManagerExtended, XRManager);
778
+ function XRManagerExtended() {
779
+ return XRManager.apply(this, arguments) || this;
780
+ }
780
781
  var _proto = XRManagerExtended.prototype;
781
782
  _proto.isSupportedFeature = function isSupportedFeature(feature) {
782
783
  return this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(feature));
@@ -795,7 +796,9 @@
795
796
  for(var i = 0, n = features.length; i < n; i++){
796
797
  if (_instanceof1(features[i], type)) throw new Error("The feature has been added");
797
798
  }
798
- var feature = _construct$1(type, [].concat(this, args));
799
+ var feature = _construct$1(type, [].concat([
800
+ this
801
+ ], args));
799
802
  features.push(feature);
800
803
  return feature;
801
804
  };
@@ -809,8 +812,8 @@
809
812
  }
810
813
  };
811
814
  _proto.enterXR = function enterXR(sessionMode, autoRun) {
812
- if (autoRun === void 0) autoRun = true;
813
815
  var _this = this;
816
+ if (autoRun === void 0) autoRun = true;
814
817
  var sessionManager = this.sessionManager;
815
818
  if (sessionManager._platformSession) {
816
819
  throw new Error("Please exit XR immersive mode first.");
@@ -942,9 +945,7 @@
942
945
  ]);
943
946
  return XRManagerExtended;
944
947
  }(engine.XRManager);
945
- (function() {
946
- /** @internal */ XRManagerExtended._featureMap = new Map();
947
- })();
948
+ /** @internal */ XRManagerExtended._featureMap = new Map();
948
949
  /**
949
950
  * @internal
950
951
  */ function registerXRFeature(type) {
@@ -966,7 +967,7 @@
966
967
  /**
967
968
  * The base class of XR feature manager.
968
969
  */ var XRFeature = /*#__PURE__*/ function() {
969
- var XRFeature = function XRFeature(_xrManager, _type) {
970
+ function XRFeature(_xrManager, _type) {
970
971
  for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
971
972
  args[_key - 2] = arguments[_key];
972
973
  }
@@ -974,9 +975,11 @@
974
975
  this._xrManager = _xrManager;
975
976
  this._type = _type;
976
977
  this._enabled = true;
977
- this._platformFeature = (_xrManager__platformDevice = _xrManager._platformDevice).createPlatformFeature.apply(_xrManager__platformDevice, [].concat(_type, args));
978
+ this._platformFeature = (_xrManager__platformDevice = _xrManager._platformDevice).createPlatformFeature.apply(_xrManager__platformDevice, [].concat([
979
+ _type
980
+ ], args));
978
981
  this._onEnable();
979
- };
982
+ }
980
983
  var _proto = XRFeature.prototype;
981
984
  /**
982
985
  * @internal
@@ -1020,38 +1023,31 @@
1020
1023
  ]);
1021
1024
  return XRFeature;
1022
1025
  }();
1023
- var XRFeatureType;
1024
- (function(XRFeatureType) {
1026
+ var XRFeatureType = /*#__PURE__*/ function(XRFeatureType) {
1025
1027
  XRFeatureType[XRFeatureType["AnchorTracking"] = 0] = "AnchorTracking";
1026
1028
  XRFeatureType[XRFeatureType["ImageTracking"] = 1] = "ImageTracking";
1027
1029
  XRFeatureType[XRFeatureType["PlaneTracking"] = 2] = "PlaneTracking";
1028
1030
  XRFeatureType[XRFeatureType["HitTest"] = 3] = "HitTest";
1029
- })(XRFeatureType || (XRFeatureType = {}));
1030
- var XRRequestTrackingState;
1031
- (function(XRRequestTrackingState) {
1031
+ return XRFeatureType;
1032
+ }({});
1033
+ var XRRequestTrackingState = /*#__PURE__*/ function(XRRequestTrackingState) {
1032
1034
  XRRequestTrackingState[XRRequestTrackingState["None"] = 0] = "None";
1033
1035
  XRRequestTrackingState[XRRequestTrackingState["Submitted"] = 1] = "Submitted";
1034
1036
  XRRequestTrackingState[XRRequestTrackingState["Resolved"] = 2] = "Resolved";
1035
1037
  XRRequestTrackingState[XRRequestTrackingState["Rejected"] = 3] = "Rejected";
1036
1038
  XRRequestTrackingState[XRRequestTrackingState["Destroyed"] = 4] = "Destroyed";
1037
1039
  XRRequestTrackingState[XRRequestTrackingState["WaitingDestroy"] = 5] = "WaitingDestroy";
1038
- })(XRRequestTrackingState || (XRRequestTrackingState = {}));
1040
+ return XRRequestTrackingState;
1041
+ }({});
1039
1042
  /**
1040
1043
  * The base class of XR trackable manager.
1041
- */ var XRTrackableFeature = /*#__PURE__*/ function(XRFeature1) {
1042
- var XRTrackableFeature = function XRTrackableFeature() {
1044
+ */ var XRTrackableFeature = /*#__PURE__*/ function(XRFeature) {
1045
+ _inherits(XRTrackableFeature, XRFeature);
1046
+ function XRTrackableFeature() {
1043
1047
  var _this;
1044
- _this = XRFeature1.apply(this, arguments) || this;
1045
- _this._requestTrackings = [];
1046
- _this._tracked = [];
1047
- _this._added = [];
1048
- _this._updated = [];
1049
- _this._removed = [];
1050
- _this._statusSnapshot = {};
1051
- _this._listeners = new engine.SafeLoopArray();
1048
+ _this = XRFeature.apply(this, arguments) || this, _this._requestTrackings = [], _this._tracked = [], _this._added = [], _this._updated = [], _this._removed = [], _this._statusSnapshot = {}, _this._listeners = new engine.SafeLoopArray();
1052
1049
  return _this;
1053
- };
1054
- _inherits(XRTrackableFeature, XRFeature1);
1050
+ }
1055
1051
  var _proto = XRTrackableFeature.prototype;
1056
1052
  /**
1057
1053
  * Add a listening function for tracked object changes.
@@ -1168,9 +1164,7 @@
1168
1164
  };
1169
1165
  return XRTrackableFeature;
1170
1166
  }(XRFeature);
1171
- (function() {
1172
- XRTrackableFeature._uuid = 0;
1173
- })();
1167
+ XRTrackableFeature._uuid = 0;
1174
1168
  /**
1175
1169
  * The base class of XR tracked object.
1176
1170
  */ var XRTracked = function XRTracked() {
@@ -1180,11 +1174,11 @@
1180
1174
  /**
1181
1175
  * Enum for the types of hit test that can be performed.
1182
1176
  * Note: currently only supports plane.
1183
- */ var TrackableType;
1184
- (function(TrackableType) {
1185
- TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
1186
- TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
1187
- })(TrackableType || (TrackableType = {}));
1177
+ */ var TrackableType = /*#__PURE__*/ function(TrackableType) {
1178
+ /** Tracked plane. */ TrackableType[TrackableType["Plane"] = 1] = "Plane";
1179
+ /** All tracked objects. */ TrackableType[TrackableType["All"] = 1] = "All";
1180
+ return TrackableType;
1181
+ }({});
1188
1182
  /**
1189
1183
  * XR hit result.
1190
1184
  * It is the detection result returned by using XR HitTest feature.
@@ -1207,7 +1201,7 @@
1207
1201
  PERFORMANCE OF THIS SOFTWARE.
1208
1202
  ***************************************************************************** */ function __decorate(decorators, target, key, desc) {
1209
1203
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1210
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1204
+ if ((typeof Reflect === "undefined" ? "undefined" : _type_of(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1211
1205
  else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1212
1206
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1213
1207
  }
@@ -1217,13 +1211,13 @@
1217
1211
  };
1218
1212
  /**
1219
1213
  * Enumerates modes of plane in XR.
1220
- */ var XRPlaneMode;
1221
- (function(XRPlaneMode) {
1222
- XRPlaneMode[XRPlaneMode[/** None. */ "None"] = 0] = "None";
1223
- XRPlaneMode[XRPlaneMode[/** Horizontal */ "Horizontal"] = 1] = "Horizontal";
1224
- XRPlaneMode[XRPlaneMode[/** Vertical */ "Vertical"] = 2] = "Vertical";
1225
- XRPlaneMode[XRPlaneMode[/** Includes horizontal and vertical. */ "EveryThing"] = 3] = "EveryThing";
1226
- })(XRPlaneMode || (XRPlaneMode = {}));
1214
+ */ var XRPlaneMode = /*#__PURE__*/ function(XRPlaneMode) {
1215
+ /** None. */ XRPlaneMode[XRPlaneMode["None"] = 0] = "None";
1216
+ /** Horizontal */ XRPlaneMode[XRPlaneMode["Horizontal"] = 1] = "Horizontal";
1217
+ /** Vertical */ XRPlaneMode[XRPlaneMode["Vertical"] = 2] = "Vertical";
1218
+ /** Includes horizontal and vertical. */ XRPlaneMode[XRPlaneMode["EveryThing"] = 3] = "EveryThing";
1219
+ return XRPlaneMode;
1220
+ }({});
1227
1221
  /**
1228
1222
  * @internal
1229
1223
  */ var XRRequestTracking = function XRRequestTracking() {
@@ -1232,44 +1226,41 @@
1232
1226
  };
1233
1227
  /**
1234
1228
  * The request plane in XR space.
1235
- */ var XRRequestPlane = /*#__PURE__*/ function(XRRequestTracking1) {
1236
- var XRRequestPlane = function XRRequestPlane(detectionMode) {
1229
+ */ var XRRequestPlane = /*#__PURE__*/ function(XRRequestTracking) {
1230
+ _inherits(XRRequestPlane, XRRequestTracking);
1231
+ function XRRequestPlane(detectionMode) {
1237
1232
  var _this;
1238
- _this = XRRequestTracking1.call(this) || this;
1239
- _this.detectionMode = detectionMode;
1233
+ _this = XRRequestTracking.call(this) || this, _this.detectionMode = detectionMode;
1240
1234
  return _this;
1241
- };
1242
- _inherits(XRRequestPlane, XRRequestTracking1);
1235
+ }
1243
1236
  return XRRequestPlane;
1244
1237
  }(XRRequestTracking);
1245
1238
  /**
1246
1239
  * The tracked plane in XR space.
1247
- */ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked1) {
1248
- var XRTrackedPlane = function XRTrackedPlane() {
1240
+ */ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked) {
1241
+ _inherits(XRTrackedPlane, XRTracked);
1242
+ function XRTrackedPlane() {
1249
1243
  var _this;
1250
- _this = XRTracked1.apply(this, arguments) || this;
1251
- /** The points that make up this plane.
1244
+ _this = XRTracked.apply(this, arguments) || this, /** The points that make up this plane.
1252
1245
  * Note: These points are in the plane coordinate system,
1253
1246
  * and their Y coordinates are all zero.
1254
- */ _this.polygon = [];
1255
- /**
1247
+ */ _this.polygon = [], /**
1256
1248
  * Whether this frame changes the attributes of the plane.
1257
1249
  * Note: Includes `polygon` but no `pose`.
1258
1250
  */ _this.attributesDirty = false;
1259
1251
  return _this;
1260
- };
1261
- _inherits(XRTrackedPlane, XRTracked1);
1252
+ }
1262
1253
  return XRTrackedPlane;
1263
1254
  }(XRTracked);
1264
1255
  var XRPlaneTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1265
- var XRPlaneTracking = function XRPlaneTracking(xrManager, detectionMode) {
1256
+ _inherits(XRPlaneTracking, XRTrackableFeature1);
1257
+ function XRPlaneTracking(xrManager, detectionMode) {
1266
1258
  if (detectionMode === void 0) detectionMode = XRPlaneMode.EveryThing;
1267
1259
  var _this;
1268
1260
  _this = XRTrackableFeature1.call(this, xrManager, XRFeatureType.PlaneTracking, detectionMode) || this;
1269
1261
  _this._addRequestTracking(new XRRequestPlane(detectionMode));
1270
1262
  return _this;
1271
- };
1272
- _inherits(XRPlaneTracking, XRTrackableFeature1);
1263
+ }
1273
1264
  var _proto = XRPlaneTracking.prototype;
1274
1265
  _proto._generateTracked = function _generateTracked() {
1275
1266
  var plane = new XRTrackedPlane();
@@ -1299,22 +1290,13 @@
1299
1290
  XRPlaneTracking = __decorate([
1300
1291
  registerXRFeature(XRFeatureType.PlaneTracking)
1301
1292
  ], XRPlaneTracking);
1302
- var XRHitTest = /*#__PURE__*/ function(XRFeature1) {
1303
- var XRHitTest = function XRHitTest(xrManager) {
1293
+ var XRHitTest = /*#__PURE__*/ function(XRFeature) {
1294
+ _inherits(XRHitTest, XRFeature);
1295
+ function XRHitTest(xrManager) {
1304
1296
  var _this;
1305
- _this = XRFeature1.call(this, xrManager, XRFeatureType.HitTest) || this;
1306
- _this._tempRay = new engine.Ray();
1307
- _this._tempPlane = new engine.Plane();
1308
- _this._tempVec2 = new engine.Vector2();
1309
- _this._tempVec30 = new engine.Vector3();
1310
- _this._tempVec31 = new engine.Vector3();
1311
- _this._tempVec32 = new engine.Vector3();
1312
- _this._tempVec33 = new engine.Vector3();
1313
- _this._tempVec34 = new engine.Vector3();
1314
- _this._tempVec35 = new engine.Vector3();
1297
+ _this = XRFeature.call(this, xrManager, XRFeatureType.HitTest) || this, _this._tempRay = new engine.Ray(), _this._tempPlane = new engine.Plane(), _this._tempVec2 = new engine.Vector2(), _this._tempVec30 = new engine.Vector3(), _this._tempVec31 = new engine.Vector3(), _this._tempVec32 = new engine.Vector3(), _this._tempVec33 = new engine.Vector3(), _this._tempVec34 = new engine.Vector3(), _this._tempVec35 = new engine.Vector3();
1315
1298
  return _this;
1316
- };
1317
- _inherits(XRHitTest, XRFeature1);
1299
+ }
1318
1300
  var _proto = XRHitTest.prototype;
1319
1301
  /**
1320
1302
  * Hit test.
@@ -1409,34 +1391,31 @@
1409
1391
  ], XRHitTest);
1410
1392
  /**
1411
1393
  * The anchor in XR space.
1412
- */ var XRAnchor$1 = /*#__PURE__*/ function(XRTracked1) {
1413
- var XRAnchor = function XRAnchor() {
1414
- return XRTracked1.apply(this, arguments);
1415
- };
1416
- _inherits(XRAnchor, XRTracked1);
1394
+ */ var XRAnchor$1 = /*#__PURE__*/ function(XRTracked) {
1395
+ _inherits(XRAnchor, XRTracked);
1396
+ function XRAnchor() {
1397
+ return XRTracked.apply(this, arguments) || this;
1398
+ }
1417
1399
  return XRAnchor;
1418
1400
  }(XRTracked);
1419
1401
  /**
1420
1402
  * The request anchor in XR space.
1421
- */ var XRRequestAnchor = /*#__PURE__*/ function(XRRequestTracking1) {
1422
- var XRRequestAnchor = function XRRequestAnchor(position, rotation) {
1403
+ */ var XRRequestAnchor = /*#__PURE__*/ function(XRRequestTracking) {
1404
+ _inherits(XRRequestAnchor, XRRequestTracking);
1405
+ function XRRequestAnchor(position, rotation) {
1423
1406
  var _this;
1424
- _this = XRRequestTracking1.call(this) || this;
1425
- _this.position = position;
1426
- _this.rotation = rotation;
1407
+ _this = XRRequestTracking.call(this) || this, _this.position = position, _this.rotation = rotation;
1427
1408
  return _this;
1428
- };
1429
- _inherits(XRRequestAnchor, XRRequestTracking1);
1409
+ }
1430
1410
  return XRRequestAnchor;
1431
1411
  }(XRRequestTracking);
1432
1412
  var XRAnchorTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1433
- var XRAnchorTracking = function XRAnchorTracking(xrManager) {
1413
+ _inherits(XRAnchorTracking, XRTrackableFeature1);
1414
+ function XRAnchorTracking(xrManager) {
1434
1415
  var _this;
1435
- _this = XRTrackableFeature1.call(this, xrManager, XRFeatureType.AnchorTracking) || this;
1436
- _this._anchors = [];
1416
+ _this = XRTrackableFeature1.call(this, xrManager, XRFeatureType.AnchorTracking) || this, _this._anchors = [];
1437
1417
  return _this;
1438
- };
1439
- _inherits(XRAnchorTracking, XRTrackableFeature1);
1418
+ }
1440
1419
  var _proto = XRAnchorTracking.prototype;
1441
1420
  /**
1442
1421
  * Add a anchor in XR space.
@@ -1508,27 +1487,27 @@
1508
1487
  ], XRAnchorTracking);
1509
1488
  /**
1510
1489
  * The request image in XR space.
1511
- */ var XRRequestImage = /*#__PURE__*/ function(XRRequestTracking1) {
1512
- var XRRequestImage = function XRRequestImage(image) {
1490
+ */ var XRRequestImage = /*#__PURE__*/ function(XRRequestTracking) {
1491
+ _inherits(XRRequestImage, XRRequestTracking);
1492
+ function XRRequestImage(image) {
1513
1493
  var _this;
1514
- _this = XRRequestTracking1.call(this) || this;
1515
- _this.image = image;
1494
+ _this = XRRequestTracking.call(this) || this, _this.image = image;
1516
1495
  return _this;
1517
- };
1518
- _inherits(XRRequestImage, XRRequestTracking1);
1496
+ }
1519
1497
  return XRRequestImage;
1520
1498
  }(XRRequestTracking);
1521
1499
  /**
1522
1500
  * A tracked image in XR space.
1523
- */ var XRTrackedImage = /*#__PURE__*/ function(XRTracked1) {
1524
- var XRTrackedImage = function XRTrackedImage() {
1525
- return XRTracked1.apply(this, arguments);
1526
- };
1527
- _inherits(XRTrackedImage, XRTracked1);
1501
+ */ var XRTrackedImage = /*#__PURE__*/ function(XRTracked) {
1502
+ _inherits(XRTrackedImage, XRTracked);
1503
+ function XRTrackedImage() {
1504
+ return XRTracked.apply(this, arguments) || this;
1505
+ }
1528
1506
  return XRTrackedImage;
1529
1507
  }(XRTracked);
1530
1508
  var XRImageTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1531
- var XRImageTracking = function XRImageTracking(xrManager, trackingImages) {
1509
+ _inherits(XRImageTracking, XRTrackableFeature1);
1510
+ function XRImageTracking(xrManager, trackingImages) {
1532
1511
  var _this;
1533
1512
  _this = XRTrackableFeature1.call(this, xrManager, XRFeatureType.ImageTracking, trackingImages) || this;
1534
1513
  _this._trackingImages = trackingImages;
@@ -1541,8 +1520,7 @@
1541
1520
  console.warn("No image to be tracked.");
1542
1521
  }
1543
1522
  return _this;
1544
- };
1545
- _inherits(XRImageTracking, XRTrackableFeature1);
1523
+ }
1546
1524
  var _proto = XRImageTracking.prototype;
1547
1525
  _proto._generateTracked = function _generateTracked() {
1548
1526
  var image = new XRTrackedImage();
@@ -1580,9 +1558,9 @@
1580
1558
  this.physicalWidth = physicalWidth;
1581
1559
  };
1582
1560
  var XRReferenceImageDecoder = /*#__PURE__*/ function() {
1583
- var XRReferenceImageDecoder = function XRReferenceImageDecoder() {};
1584
- XRReferenceImageDecoder.decode = function decode(engine, bufferReader) {
1585
- return new Promise(function(resolve, reject) {
1561
+ function XRReferenceImageDecoder() {}
1562
+ XRReferenceImageDecoder.decode = function decode(engine$1, bufferReader) {
1563
+ return new engine.AssetPromise(function(resolve, reject) {
1586
1564
  var physicalWidth = bufferReader.nextFloat32();
1587
1565
  bufferReader.nextUint8();
1588
1566
  var img = new Image();
@@ -1609,16 +1587,16 @@
1609
1587
  };
1610
1588
  return _extends.apply(this, arguments);
1611
1589
  }
1612
- var XRReferenceImageLoader = /*#__PURE__*/ function(Loader1) {
1613
- var XRReferenceImageLoader = function XRReferenceImageLoader() {
1614
- return Loader1.apply(this, arguments);
1615
- };
1616
- _inherits(XRReferenceImageLoader, Loader1);
1590
+ var XRReferenceImageLoader = /*#__PURE__*/ function(Loader) {
1591
+ _inherits(XRReferenceImageLoader, Loader);
1592
+ function XRReferenceImageLoader() {
1593
+ return Loader.apply(this, arguments) || this;
1594
+ }
1617
1595
  var _proto = XRReferenceImageLoader.prototype;
1618
1596
  _proto.load = function load(item, resourceManager) {
1619
- var _this = this;
1620
1597
  return new engine.AssetPromise(function(resolve, reject) {
1621
- _this.request(item.url, _extends({}, item, {
1598
+ resourceManager // @ts-ignore
1599
+ ._request(item.url, _extends({}, item, {
1622
1600
  type: "arraybuffer"
1623
1601
  })).then(function(data) {
1624
1602
  engine.decode(data, resourceManager.engine).then(function(referenceImage) {
@@ -1634,17 +1612,18 @@
1634
1612
  ], XRReferenceImageLoader);
1635
1613
 
1636
1614
  function _is_native_reflect_construct() {
1637
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1638
- if (Reflect.construct.sham) return false;
1639
- if (typeof Proxy === "function") return true;
1640
-
1615
+ // Since Reflect.construct can't be properly polyfilled, some
1616
+ // implementations (e.g. core-js@2) don't set the correct internal slots.
1617
+ // Those polyfills don't allow us to subclass built-ins, so we need to
1618
+ // use our fallback implementation.
1641
1619
  try {
1642
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1643
-
1644
- return true;
1645
- } catch (e) {
1646
- return false;
1647
- }
1620
+ // If the internal slots aren't set, this throws an error similar to
1621
+ // TypeError: this is not a Boolean object.
1622
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
1623
+ } catch (_) {}
1624
+ return (_is_native_reflect_construct = function() {
1625
+ return !!result;
1626
+ })();
1648
1627
  }
1649
1628
 
1650
1629
  function _construct(Parent, args, Class) {
@@ -1713,33 +1692,6 @@
1713
1692
  }
1714
1693
  }
1715
1694
 
1716
- /**
1717
- * Defines how the bounding volumes intersects or contain one another.
1718
- */ var ContainmentType;
1719
- (function(ContainmentType) {
1720
- ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
1721
- ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
1722
- ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
1723
- })(ContainmentType || (ContainmentType = {}));
1724
- /**
1725
- * Defines the intersection between a plane and a bounding volume.
1726
- */ var PlaneIntersectionType;
1727
- (function(PlaneIntersectionType) {
1728
- PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
1729
- PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
1730
- PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
1731
- })(PlaneIntersectionType || (PlaneIntersectionType = {}));
1732
- /**
1733
- * Frustum face
1734
- */ var FrustumFace;
1735
- (function(FrustumFace) {
1736
- FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
1737
- FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
1738
- FrustumFace[FrustumFace[/** Left face */ "Left"] = 2] = "Left";
1739
- FrustumFace[FrustumFace[/** Right face */ "Right"] = 3] = "Right";
1740
- FrustumFace[FrustumFace[/** Bottom face */ "Bottom"] = 4] = "Bottom";
1741
- FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
1742
- })(FrustumFace || (FrustumFace = {}));
1743
1695
  function _defineProperties(target, props) {
1744
1696
  for(var i = 0; i < props.length; i++){
1745
1697
  var descriptor = props[i];
@@ -1757,7 +1709,7 @@
1757
1709
  /**
1758
1710
  * Common utility methods for math operations.
1759
1711
  */ var MathUtil = /*#__PURE__*/ function() {
1760
- var MathUtil = function MathUtil() {};
1712
+ function MathUtil() {}
1761
1713
  /**
1762
1714
  * Clamps the specified value.
1763
1715
  * @param v - The specified value
@@ -1808,19 +1760,13 @@
1808
1760
  };
1809
1761
  return MathUtil;
1810
1762
  }();
1811
- (function() {
1812
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
1813
- })();
1814
- (function() {
1815
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
1816
- })();
1817
- (function() {
1818
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
1819
- })();
1763
+ /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
1764
+ /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
1765
+ /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
1820
1766
  /**
1821
1767
  * Describes a 3D-vector.
1822
1768
  */ var Vector3 = /*#__PURE__*/ function() {
1823
- var Vector3 = function Vector3(x, y, z) {
1769
+ function Vector3(x, y, z) {
1824
1770
  if (x === void 0) x = 0;
1825
1771
  if (y === void 0) y = 0;
1826
1772
  if (z === void 0) z = 0;
@@ -1828,7 +1774,7 @@
1828
1774
  this._x = x;
1829
1775
  this._y = y;
1830
1776
  this._z = z;
1831
- };
1777
+ }
1832
1778
  var _proto = Vector3.prototype;
1833
1779
  /**
1834
1780
  * Set the value of this vector.
@@ -1840,7 +1786,7 @@
1840
1786
  this._x = x;
1841
1787
  this._y = y;
1842
1788
  this._z = z;
1843
- this._onValueChanged && this._onValueChanged();
1789
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1844
1790
  return this;
1845
1791
  };
1846
1792
  /**
@@ -1851,7 +1797,7 @@
1851
1797
  this._x += right._x;
1852
1798
  this._y += right._y;
1853
1799
  this._z += right._z;
1854
- this._onValueChanged && this._onValueChanged();
1800
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1855
1801
  return this;
1856
1802
  };
1857
1803
  /**
@@ -1862,7 +1808,7 @@
1862
1808
  this._x -= right._x;
1863
1809
  this._y -= right._y;
1864
1810
  this._z -= right._z;
1865
- this._onValueChanged && this._onValueChanged();
1811
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1866
1812
  return this;
1867
1813
  };
1868
1814
  /**
@@ -1873,7 +1819,7 @@
1873
1819
  this._x *= right._x;
1874
1820
  this._y *= right._y;
1875
1821
  this._z *= right._z;
1876
- this._onValueChanged && this._onValueChanged();
1822
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1877
1823
  return this;
1878
1824
  };
1879
1825
  /**
@@ -1884,7 +1830,7 @@
1884
1830
  this._x /= right._x;
1885
1831
  this._y /= right._y;
1886
1832
  this._z /= right._z;
1887
- this._onValueChanged && this._onValueChanged();
1833
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1888
1834
  return this;
1889
1835
  };
1890
1836
  /**
@@ -1908,7 +1854,7 @@
1908
1854
  this._x = -this._x;
1909
1855
  this._y = -this._y;
1910
1856
  this._z = -this._z;
1911
- this._onValueChanged && this._onValueChanged();
1857
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1912
1858
  return this;
1913
1859
  };
1914
1860
  /**
@@ -1926,7 +1872,7 @@
1926
1872
  this._x *= s;
1927
1873
  this._y *= s;
1928
1874
  this._z *= s;
1929
- this._onValueChanged && this._onValueChanged();
1875
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1930
1876
  return this;
1931
1877
  };
1932
1878
  /**
@@ -1987,10 +1933,20 @@
1987
1933
  this._x = source.x;
1988
1934
  this._y = source.y;
1989
1935
  this._z = source.z;
1990
- this._onValueChanged && this._onValueChanged();
1936
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
1991
1937
  return this;
1992
1938
  };
1993
1939
  /**
1940
+ * Copy to vector3 like object.
1941
+ * @param target - Vector3 like object
1942
+ * @returns This Vector3 like object
1943
+ */ _proto.copyTo = function copyTo(target) {
1944
+ target.x = this._x;
1945
+ target.y = this._y;
1946
+ target.z = this._z;
1947
+ return target;
1948
+ };
1949
+ /**
1994
1950
  * Copy the value of this vector from an array.
1995
1951
  * @param array - The array
1996
1952
  * @param offset - The start offset of the array
@@ -2000,7 +1956,7 @@
2000
1956
  this._x = array[offset];
2001
1957
  this._y = array[offset + 1];
2002
1958
  this._z = array[offset + 2];
2003
- this._onValueChanged && this._onValueChanged();
1959
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2004
1960
  return this;
2005
1961
  };
2006
1962
  /**
@@ -2032,7 +1988,7 @@
2032
1988
  out._x = left._x + right._x;
2033
1989
  out._y = left._y + right._y;
2034
1990
  out._z = left._z + right._z;
2035
- out._onValueChanged && out._onValueChanged();
1991
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2036
1992
  };
2037
1993
  /**
2038
1994
  * Determines the difference between two vectors.
@@ -2043,7 +1999,7 @@
2043
1999
  out._x = left._x - right._x;
2044
2000
  out._y = left._y - right._y;
2045
2001
  out._z = left._z - right._z;
2046
- out._onValueChanged && out._onValueChanged();
2002
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2047
2003
  };
2048
2004
  /**
2049
2005
  * Determines the product of two vectors.
@@ -2054,7 +2010,7 @@
2054
2010
  out._x = left._x * right._x;
2055
2011
  out._y = left._y * right._y;
2056
2012
  out._z = left._z * right._z;
2057
- out._onValueChanged && out._onValueChanged();
2013
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2058
2014
  };
2059
2015
  /**
2060
2016
  * Determines the divisor of two vectors.
@@ -2065,7 +2021,7 @@
2065
2021
  out._x = left._x / right._x;
2066
2022
  out._y = left._y / right._y;
2067
2023
  out._z = left._z / right._z;
2068
- out._onValueChanged && out._onValueChanged();
2024
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2069
2025
  };
2070
2026
  /**
2071
2027
  * Determines the dot product of two vectors.
@@ -2130,7 +2086,7 @@
2130
2086
  out._x = _x + (end._x - _x) * t;
2131
2087
  out._y = _y + (end._y - _y) * t;
2132
2088
  out._z = _z + (end._z - _z) * t;
2133
- out._onValueChanged && out._onValueChanged();
2089
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2134
2090
  };
2135
2091
  /**
2136
2092
  * Calculate a vector containing the largest components of the specified vectors.
@@ -2141,7 +2097,7 @@
2141
2097
  out._x = Math.max(left._x, right._x);
2142
2098
  out._y = Math.max(left._y, right._y);
2143
2099
  out._z = Math.max(left._z, right._z);
2144
- out._onValueChanged && out._onValueChanged();
2100
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2145
2101
  };
2146
2102
  /**
2147
2103
  * Calculate a vector containing the smallest components of the specified vectors.
@@ -2152,7 +2108,7 @@
2152
2108
  out._x = Math.min(left._x, right._x);
2153
2109
  out._y = Math.min(left._y, right._y);
2154
2110
  out._z = Math.min(left._z, right._z);
2155
- out._onValueChanged && out._onValueChanged();
2111
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2156
2112
  };
2157
2113
  /**
2158
2114
  * Reverses the direction of a given vector.
@@ -2162,7 +2118,7 @@
2162
2118
  out._x = -a._x;
2163
2119
  out._y = -a._y;
2164
2120
  out._z = -a._z;
2165
- out._onValueChanged && out._onValueChanged();
2121
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2166
2122
  };
2167
2123
  /**
2168
2124
  * Converts the vector into a unit vector.
@@ -2185,7 +2141,7 @@
2185
2141
  out._x = a._x * s;
2186
2142
  out._y = a._y * s;
2187
2143
  out._z = a._z * s;
2188
- out._onValueChanged && out._onValueChanged();
2144
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2189
2145
  };
2190
2146
  /**
2191
2147
  * Performs a normal transformation using the given 4x4 matrix.
@@ -2204,7 +2160,7 @@
2204
2160
  out._x = _x * e[0] + _y * e[4] + _z * e[8];
2205
2161
  out._y = _x * e[1] + _y * e[5] + _z * e[9];
2206
2162
  out._z = _x * e[2] + _y * e[6] + _z * e[10];
2207
- out._onValueChanged && out._onValueChanged();
2163
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2208
2164
  };
2209
2165
  /**
2210
2166
  * Performs a transformation using the given 4x4 matrix.
@@ -2217,7 +2173,7 @@
2217
2173
  out._x = _x * e[0] + _y * e[4] + _z * e[8] + e[12];
2218
2174
  out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
2219
2175
  out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
2220
- out._onValueChanged && out._onValueChanged();
2176
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2221
2177
  };
2222
2178
  /**
2223
2179
  * Performs a transformation from vector3 to vector4 using the given 4x4 matrix.
@@ -2231,7 +2187,7 @@
2231
2187
  out._y = _x * e[1] + _y * e[5] + _z * e[9] + e[13];
2232
2188
  out._z = _x * e[2] + _y * e[6] + _z * e[10] + e[14];
2233
2189
  out._w = _x * e[3] + _y * e[7] + _z * e[11] + e[15];
2234
- out._onValueChanged && out._onValueChanged();
2190
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2235
2191
  };
2236
2192
  /**
2237
2193
  * Performs a coordinate transformation using the given 4x4 matrix.
@@ -2253,7 +2209,7 @@
2253
2209
  out._x = (_x * e[0] + _y * e[4] + _z * e[8] + e[12]) * w;
2254
2210
  out._y = (_x * e[1] + _y * e[5] + _z * e[9] + e[13]) * w;
2255
2211
  out._z = (_x * e[2] + _y * e[6] + _z * e[10] + e[14]) * w;
2256
- out._onValueChanged && out._onValueChanged();
2212
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2257
2213
  };
2258
2214
  /**
2259
2215
  * Performs a transformation using the given quaternion.
@@ -2272,7 +2228,7 @@
2272
2228
  out._x = ix * qw - iw * qx - iy * qz + iz * qy;
2273
2229
  out._y = iy * qw - iw * qy - iz * qx + ix * qz;
2274
2230
  out._z = iz * qw - iw * qz - ix * qy + iy * qx;
2275
- out._onValueChanged && out._onValueChanged();
2231
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
2276
2232
  };
2277
2233
  _create_class(Vector3, [
2278
2234
  {
@@ -2284,7 +2240,7 @@
2284
2240
  },
2285
2241
  set: function set(value) {
2286
2242
  this._x = value;
2287
- this._onValueChanged && this._onValueChanged();
2243
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2288
2244
  }
2289
2245
  },
2290
2246
  {
@@ -2296,7 +2252,7 @@
2296
2252
  },
2297
2253
  set: function set(value) {
2298
2254
  this._y = value;
2299
- this._onValueChanged && this._onValueChanged();
2255
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2300
2256
  }
2301
2257
  },
2302
2258
  {
@@ -2308,661 +2264,24 @@
2308
2264
  },
2309
2265
  set: function set(value) {
2310
2266
  this._z = value;
2311
- this._onValueChanged && this._onValueChanged();
2267
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
2312
2268
  }
2313
2269
  }
2314
2270
  ]);
2315
2271
  return Vector3;
2316
2272
  }();
2317
- (function() {
2318
- /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
2319
- })();
2320
- (function() {
2321
- /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
2322
- })();
2323
- /**
2324
- * A bounding sphere.
2325
- * */ var BoundingSphere = /*#__PURE__*/ function() {
2326
- var BoundingSphere = function BoundingSphere(center, radius) {
2327
- if (center === void 0) center = null;
2328
- if (radius === void 0) radius = 0;
2329
- /** The center point of the sphere. */ this.center = new Vector3();
2330
- /** The radius of the sphere. */ this.radius = 0;
2331
- center && this.center.copyFrom(center);
2332
- this.radius = radius;
2333
- };
2334
- var _proto = BoundingSphere.prototype;
2335
- /**
2336
- * Creates a clone of this sphere.
2337
- * @returns A clone of this sphere
2338
- */ _proto.clone = function clone() {
2339
- return new BoundingSphere(this.center, this.radius);
2340
- };
2341
- /**
2342
- * Copy this sphere from the specified sphere.
2343
- * @param source - The specified sphere
2344
- * @returns This sphere
2345
- */ _proto.copyFrom = function copyFrom(source) {
2346
- this.center.copyFrom(source.center);
2347
- this.radius = source.radius;
2348
- return this;
2349
- };
2350
- /**
2351
- * Calculate a bounding sphere that fully contains the given points.
2352
- * @param points - The given points
2353
- * @param out - The calculated bounding sphere
2354
- */ BoundingSphere.fromPoints = function fromPoints(points, out) {
2355
- if (!points || points.length === 0) {
2356
- throw new Error("points must be array and length must > 0");
2357
- }
2358
- var len = points.length;
2359
- var center = BoundingSphere._tempVec30;
2360
- center.x = center.y = center.z = 0;
2361
- // Calculate the center of the sphere.
2362
- for(var i = 0; i < len; ++i){
2363
- Vector3.add(points[i], center, center);
2364
- }
2365
- // The center of the sphere.
2366
- Vector3.scale(center, 1 / len, out.center);
2367
- // Calculate the radius of the sphere.
2368
- var radius = 0.0;
2369
- for(var i1 = 0; i1 < len; ++i1){
2370
- var distance = Vector3.distanceSquared(center, points[i1]);
2371
- distance > radius && (radius = distance);
2372
- }
2373
- // The radius of the sphere.
2374
- out.radius = Math.sqrt(radius);
2375
- };
2376
- /**
2377
- * Calculate a bounding sphere from a given box.
2378
- * @param box - The given box
2379
- * @param out - The calculated bounding sphere
2380
- */ BoundingSphere.fromBox = function fromBox(box, out) {
2381
- var center = out.center;
2382
- var min = box.min, max = box.max;
2383
- center.x = (min.x + max.x) * 0.5;
2384
- center.y = (min.y + max.y) * 0.5;
2385
- center.z = (min.z + max.z) * 0.5;
2386
- out.radius = Vector3.distance(center, max);
2387
- };
2388
- return BoundingSphere;
2389
- }();
2390
- (function() {
2391
- BoundingSphere._tempVec30 = new Vector3();
2392
- })();
2393
- /**
2394
- * Axis Aligned Bound Box (AABB).
2395
- */ var BoundingBox = /*#__PURE__*/ function() {
2396
- var BoundingBox = function BoundingBox(min, max) {
2397
- if (min === void 0) min = null;
2398
- if (max === void 0) max = null;
2399
- /** The minimum point of the box. */ this.min = new Vector3();
2400
- /** The maximum point of the box. */ this.max = new Vector3();
2401
- min && this.min.copyFrom(min);
2402
- max && this.max.copyFrom(max);
2403
- };
2404
- var _proto = BoundingBox.prototype;
2405
- /**
2406
- * Get the center point of this bounding box.
2407
- * @param out - The center point of this bounding box
2408
- * @returns The center point of this bounding box
2409
- */ _proto.getCenter = function getCenter(out) {
2410
- var _this = this, min = _this.min, max = _this.max;
2411
- var centerX = max._x + min._x;
2412
- var centerY = max._y + min._y;
2413
- var centerZ = max._z + min._z;
2414
- out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
2415
- return out;
2416
- };
2417
- /**
2418
- * Get the extent of this bounding box.
2419
- * @param out - The extent of this bounding box
2420
- * @returns The extent of this bounding box
2421
- */ _proto.getExtent = function getExtent(out) {
2422
- var _this = this, min = _this.min, max = _this.max;
2423
- var extentX = max._x - min._x;
2424
- var extentY = max._y - min._y;
2425
- var extentZ = max._z - min._z;
2426
- out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
2427
- return out;
2428
- };
2429
- /**
2430
- * Get the eight corners of this bounding box.
2431
- * @param out - An array of points representing the eight corners of this bounding box
2432
- * @returns An array of points representing the eight corners of this bounding box
2433
- */ _proto.getCorners = function getCorners(out) {
2434
- if (out === void 0) out = [];
2435
- var _this = this, min = _this.min, max = _this.max;
2436
- var minX = min.x;
2437
- var minY = min.y;
2438
- var minZ = min.z;
2439
- var maxX = max.x;
2440
- var maxY = max.y;
2441
- var maxZ = max.z;
2442
- var len = out.length;
2443
- // The array length is less than 8 to make up
2444
- if (len < 8) {
2445
- for(var i = 0, l = 8 - len; i < l; ++i){
2446
- out[len + i] = new Vector3();
2447
- }
2448
- }
2449
- out[0].set(minX, maxY, maxZ);
2450
- out[1].set(maxX, maxY, maxZ);
2451
- out[2].set(maxX, minY, maxZ);
2452
- out[3].set(minX, minY, maxZ);
2453
- out[4].set(minX, maxY, minZ);
2454
- out[5].set(maxX, maxY, minZ);
2455
- out[6].set(maxX, minY, minZ);
2456
- out[7].set(minX, minY, minZ);
2457
- return out;
2458
- };
2459
- /**
2460
- * Transform a bounding box.
2461
- * @param matrix - The transform to apply to the bounding box
2462
- * @returns The transformed bounding box
2463
- */ _proto.transform = function transform(matrix) {
2464
- BoundingBox.transform(this, matrix, this);
2465
- return this;
2466
- };
2467
- /**
2468
- * Creates a clone of this box.
2469
- * @returns A clone of this box
2470
- */ _proto.clone = function clone() {
2471
- return new BoundingBox(this.min, this.max);
2472
- };
2473
- /**
2474
- * Copy this bounding box from the specified box.
2475
- * @param source - The specified box
2476
- * @returns This bounding box
2477
- */ _proto.copyFrom = function copyFrom(source) {
2478
- this.min.copyFrom(source.min);
2479
- this.max.copyFrom(source.max);
2480
- return this;
2481
- };
2482
- /**
2483
- * Calculate a bounding box from the center point and the extent of the bounding box.
2484
- * @param center - The center point
2485
- * @param extent - The extent of the bounding box
2486
- * @param out - The calculated bounding box
2487
- */ BoundingBox.fromCenterAndExtent = function fromCenterAndExtent(center, extent, out) {
2488
- Vector3.subtract(center, extent, out.min);
2489
- Vector3.add(center, extent, out.max);
2490
- };
2491
- /**
2492
- * Calculate a bounding box that fully contains the given points.
2493
- * @param points - The given points
2494
- * @param out - The calculated bounding box
2495
- */ BoundingBox.fromPoints = function fromPoints(points, out) {
2496
- if (!points || points.length === 0) {
2497
- throw new Error("points must be array and length must > 0");
2498
- }
2499
- var min = out.min, max = out.max;
2500
- min.x = min.y = min.z = Number.MAX_VALUE;
2501
- max.x = max.y = max.z = -Number.MAX_VALUE;
2502
- for(var i = 0, l = points.length; i < l; ++i){
2503
- var point = points[i];
2504
- Vector3.min(min, point, min);
2505
- Vector3.max(max, point, max);
2506
- }
2507
- };
2508
- /**
2509
- * Calculate a bounding box from a given sphere.
2510
- * @param sphere - The given sphere
2511
- * @param out - The calculated bounding box
2512
- */ BoundingBox.fromSphere = function fromSphere(sphere, out) {
2513
- var center = sphere.center, radius = sphere.radius;
2514
- var min = out.min, max = out.max;
2515
- min.x = center.x - radius;
2516
- min.y = center.y - radius;
2517
- min.z = center.z - radius;
2518
- max.x = center.x + radius;
2519
- max.y = center.y + radius;
2520
- max.z = center.z + radius;
2521
- };
2522
- /**
2523
- * Transform a bounding box.
2524
- * @param source - The original bounding box
2525
- * @param matrix - The transform to apply to the bounding box
2526
- * @param out - The transformed bounding box
2527
- */ BoundingBox.transform = function transform(source, matrix, out) {
2528
- // https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
2529
- var center = BoundingBox._tempVec30;
2530
- var extent = BoundingBox._tempVec31;
2531
- source.getCenter(center);
2532
- source.getExtent(extent);
2533
- Vector3.transformCoordinate(center, matrix, center);
2534
- var x = extent.x, y = extent.y, z = extent.z;
2535
- var e = matrix.elements;
2536
- // prettier-ignore
2537
- 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];
2538
- 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)));
2539
- // set min、max
2540
- Vector3.subtract(center, extent, out.min);
2541
- Vector3.add(center, extent, out.max);
2542
- };
2543
- /**
2544
- * Calculate a bounding box that is as large as the total combined area of the two specified boxes.
2545
- * @param box1 - The first box to merge
2546
- * @param box2 - The second box to merge
2547
- * @param out - The merged bounding box
2548
- * @returns The merged bounding box
2549
- */ BoundingBox.merge = function merge(box1, box2, out) {
2550
- Vector3.min(box1.min, box2.min, out.min);
2551
- Vector3.max(box1.max, box2.max, out.max);
2552
- return out;
2553
- };
2554
- return BoundingBox;
2555
- }();
2556
- (function() {
2557
- BoundingBox._tempVec30 = new Vector3();
2558
- })();
2559
- (function() {
2560
- BoundingBox._tempVec31 = new Vector3();
2561
- })();
2562
- /**
2563
- * Contains static methods to help in determining intersections, containment, etc.
2564
- */ var CollisionUtil = /*#__PURE__*/ function() {
2565
- var CollisionUtil = function CollisionUtil() {};
2566
- /**
2567
- * Calculate the intersection point of three plane.
2568
- * @param p1 - Plane 1
2569
- * @param p2 - Plane 2
2570
- * @param p3 - Plane 3
2571
- * @param out - intersection point
2572
- */ CollisionUtil.intersectionPointThreePlanes = function intersectionPointThreePlanes(p1, p2, p3, out) {
2573
- var p1Nor = p1.normal;
2574
- var p2Nor = p2.normal;
2575
- var p3Nor = p3.normal;
2576
- Vector3.cross(p2Nor, p3Nor, CollisionUtil._tempVec30);
2577
- Vector3.cross(p3Nor, p1Nor, CollisionUtil._tempVec31);
2578
- Vector3.cross(p1Nor, p2Nor, CollisionUtil._tempVec32);
2579
- var a = -Vector3.dot(p1Nor, CollisionUtil._tempVec30);
2580
- var b = -Vector3.dot(p2Nor, CollisionUtil._tempVec31);
2581
- var c = -Vector3.dot(p3Nor, CollisionUtil._tempVec32);
2582
- Vector3.scale(CollisionUtil._tempVec30, p1.distance / a, CollisionUtil._tempVec30);
2583
- Vector3.scale(CollisionUtil._tempVec31, p2.distance / b, CollisionUtil._tempVec31);
2584
- Vector3.scale(CollisionUtil._tempVec32, p3.distance / c, CollisionUtil._tempVec32);
2585
- Vector3.add(CollisionUtil._tempVec30, CollisionUtil._tempVec31, out);
2586
- Vector3.add(out, CollisionUtil._tempVec32, out);
2587
- };
2588
- /**
2589
- * Calculate the distance from a point to a plane.
2590
- * @param plane - The plane
2591
- * @param point - The point
2592
- * @returns The distance from a point to a plane
2593
- */ CollisionUtil.distancePlaneAndPoint = function distancePlaneAndPoint(plane, point) {
2594
- return Vector3.dot(plane.normal, point) + plane.distance;
2595
- };
2596
- /**
2597
- * Get the intersection type between a plane and a point.
2598
- * @param plane - The plane
2599
- * @param point - The point
2600
- * @returns The intersection type
2601
- */ CollisionUtil.intersectsPlaneAndPoint = function intersectsPlaneAndPoint(plane, point) {
2602
- var distance = CollisionUtil.distancePlaneAndPoint(plane, point);
2603
- if (distance > 0) {
2604
- return PlaneIntersectionType.Front;
2605
- }
2606
- if (distance < 0) {
2607
- return PlaneIntersectionType.Back;
2608
- }
2609
- return PlaneIntersectionType.Intersecting;
2610
- };
2611
- /**
2612
- * Get the intersection type between a plane and a box (AABB).
2613
- * @param plane - The plane
2614
- * @param box - The box
2615
- * @returns The intersection type
2616
- */ CollisionUtil.intersectsPlaneAndBox = function intersectsPlaneAndBox(plane, box) {
2617
- var min = box.min, max = box.max;
2618
- var normal = plane.normal;
2619
- var front = CollisionUtil._tempVec30;
2620
- var back = CollisionUtil._tempVec31;
2621
- if (normal.x >= 0) {
2622
- front.x = max.x;
2623
- back.x = min.x;
2624
- } else {
2625
- front.x = min.x;
2626
- back.x = max.x;
2627
- }
2628
- if (normal.y >= 0) {
2629
- front.y = max.y;
2630
- back.y = min.y;
2631
- } else {
2632
- front.y = min.y;
2633
- back.y = max.y;
2634
- }
2635
- if (normal.z >= 0) {
2636
- front.z = max.z;
2637
- back.z = min.z;
2638
- } else {
2639
- front.z = min.z;
2640
- back.z = max.z;
2641
- }
2642
- if (CollisionUtil.distancePlaneAndPoint(plane, front) < 0) {
2643
- return PlaneIntersectionType.Back;
2644
- }
2645
- if (CollisionUtil.distancePlaneAndPoint(plane, back) > 0) {
2646
- return PlaneIntersectionType.Front;
2647
- }
2648
- return PlaneIntersectionType.Intersecting;
2649
- };
2650
- /**
2651
- * Get the intersection type between a plane and a sphere.
2652
- * @param plane - The plane
2653
- * @param sphere - The sphere
2654
- * @returns The intersection type
2655
- */ CollisionUtil.intersectsPlaneAndSphere = function intersectsPlaneAndSphere(plane, sphere) {
2656
- var center = sphere.center, radius = sphere.radius;
2657
- var distance = CollisionUtil.distancePlaneAndPoint(plane, center);
2658
- if (distance > radius) {
2659
- return PlaneIntersectionType.Front;
2660
- }
2661
- if (distance < -radius) {
2662
- return PlaneIntersectionType.Back;
2663
- }
2664
- return PlaneIntersectionType.Intersecting;
2665
- };
2666
- /**
2667
- * Get the intersection type between a ray and a plane.
2668
- * @param ray - The ray
2669
- * @param plane - The plane
2670
- * @returns The distance from ray to plane if intersecting, -1 otherwise
2671
- */ CollisionUtil.intersectsRayAndPlane = function intersectsRayAndPlane(ray, plane) {
2672
- var normal = plane.normal;
2673
- var zeroTolerance = MathUtil.zeroTolerance;
2674
- var dir = Vector3.dot(normal, ray.direction);
2675
- // Parallel
2676
- if (Math.abs(dir) < zeroTolerance) {
2677
- return -1;
2678
- }
2679
- var position = Vector3.dot(normal, ray.origin);
2680
- var distance = (-plane.distance - position) / dir;
2681
- if (distance < 0) {
2682
- if (distance < -zeroTolerance) {
2683
- return -1;
2684
- }
2685
- distance = 0;
2686
- }
2687
- return distance;
2688
- };
2689
- /**
2690
- * Get the intersection type between a ray and a box (AABB).
2691
- * @param ray - The ray
2692
- * @param box - The box
2693
- * @returns The distance from ray to box if intersecting, -1 otherwise
2694
- */ CollisionUtil.intersectsRayAndBox = function intersectsRayAndBox(ray, box) {
2695
- var zeroTolerance = MathUtil.zeroTolerance;
2696
- var origin = ray.origin, direction = ray.direction;
2697
- var min = box.min, max = box.max;
2698
- var dirX = direction.x;
2699
- var dirY = direction.y;
2700
- var dirZ = direction.z;
2701
- var oriX = origin.x;
2702
- var oriY = origin.y;
2703
- var oriZ = origin.z;
2704
- var distance = 0;
2705
- var tmax = Number.MAX_VALUE;
2706
- if (Math.abs(dirX) < zeroTolerance) {
2707
- if (oriX < min.x || oriX > max.x) {
2708
- return -1;
2709
- }
2710
- } else {
2711
- var inverse = 1.0 / dirX;
2712
- var t1 = (min.x - oriX) * inverse;
2713
- var t2 = (max.x - oriX) * inverse;
2714
- if (t1 > t2) {
2715
- var temp = t1;
2716
- t1 = t2;
2717
- t2 = temp;
2718
- }
2719
- distance = Math.max(t1, distance);
2720
- tmax = Math.min(t2, tmax);
2721
- if (distance > tmax) {
2722
- return -1;
2723
- }
2724
- }
2725
- if (Math.abs(dirY) < zeroTolerance) {
2726
- if (oriY < min.y || oriY > max.y) {
2727
- return -1;
2728
- }
2729
- } else {
2730
- var inverse1 = 1.0 / dirY;
2731
- var t11 = (min.y - oriY) * inverse1;
2732
- var t21 = (max.y - oriY) * inverse1;
2733
- if (t11 > t21) {
2734
- var temp1 = t11;
2735
- t11 = t21;
2736
- t21 = temp1;
2737
- }
2738
- distance = Math.max(t11, distance);
2739
- tmax = Math.min(t21, tmax);
2740
- if (distance > tmax) {
2741
- return -1;
2742
- }
2743
- }
2744
- if (Math.abs(dirZ) < zeroTolerance) {
2745
- if (oriZ < min.z || oriZ > max.z) {
2746
- return -1;
2747
- }
2748
- } else {
2749
- var inverse2 = 1.0 / dirZ;
2750
- var t12 = (min.z - oriZ) * inverse2;
2751
- var t22 = (max.z - oriZ) * inverse2;
2752
- if (t12 > t22) {
2753
- var temp2 = t12;
2754
- t12 = t22;
2755
- t22 = temp2;
2756
- }
2757
- distance = Math.max(t12, distance);
2758
- tmax = Math.min(t22, tmax);
2759
- if (distance > tmax) {
2760
- return -1;
2761
- }
2762
- }
2763
- return distance;
2764
- };
2765
- /**
2766
- * Get the intersection type between a ray and a sphere.
2767
- * @param ray - The ray
2768
- * @param sphere - The sphere
2769
- * @returns The distance from ray to sphere if intersecting, -1 otherwise
2770
- */ CollisionUtil.intersectsRayAndSphere = function intersectsRayAndSphere(ray, sphere) {
2771
- var origin = ray.origin, direction = ray.direction;
2772
- var center = sphere.center, radius = sphere.radius;
2773
- var m = CollisionUtil._tempVec30;
2774
- Vector3.subtract(origin, center, m);
2775
- var b = Vector3.dot(m, direction);
2776
- var c = Vector3.dot(m, m) - radius * radius;
2777
- if (b > 0 && c > 0) {
2778
- return -1;
2779
- }
2780
- var discriminant = b * b - c;
2781
- if (discriminant < 0) {
2782
- return -1;
2783
- }
2784
- var distance = -b - Math.sqrt(discriminant);
2785
- if (distance < 0) {
2786
- distance = 0;
2787
- }
2788
- return distance;
2789
- };
2790
- /**
2791
- * Check whether the boxes intersect.
2792
- * @param boxA - The first box to check
2793
- * @param boxB - The second box to check
2794
- * @returns True if the boxes intersect, false otherwise
2795
- */ CollisionUtil.intersectsBoxAndBox = function intersectsBoxAndBox(boxA, boxB) {
2796
- if (boxA.min.x > boxB.max.x || boxB.min.x > boxA.max.x) {
2797
- return false;
2798
- }
2799
- if (boxA.min.y > boxB.max.y || boxB.min.y > boxA.max.y) {
2800
- return false;
2801
- }
2802
- return !(boxA.min.z > boxB.max.z || boxB.min.z > boxA.max.z);
2803
- };
2804
- /**
2805
- * Check whether the spheres intersect.
2806
- * @param sphereA - The first sphere to check
2807
- * @param sphereB - The second sphere to check
2808
- * @returns True if the spheres intersect, false otherwise
2809
- */ CollisionUtil.intersectsSphereAndSphere = function intersectsSphereAndSphere(sphereA, sphereB) {
2810
- var radiisum = sphereA.radius + sphereB.radius;
2811
- return Vector3.distanceSquared(sphereA.center, sphereB.center) < radiisum * radiisum;
2812
- };
2813
- /**
2814
- * Check whether the sphere and the box intersect.
2815
- * @param sphere - The sphere to check
2816
- * @param box - The box to check
2817
- * @returns True if the sphere and the box intersect, false otherwise
2818
- */ CollisionUtil.intersectsSphereAndBox = function intersectsSphereAndBox(sphere, box) {
2819
- var center = sphere.center;
2820
- var max = box.max;
2821
- var min = box.min;
2822
- var closestPoint = CollisionUtil._tempVec30;
2823
- 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)));
2824
- var distance = Vector3.distanceSquared(center, closestPoint);
2825
- return distance <= sphere.radius * sphere.radius;
2826
- };
2827
- /**
2828
- * Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
2829
- * @param frustum - The frustum
2830
- * @param box - The box
2831
- * @returns True if bounding box intersects with this frustum, false otherwise
2832
- */ CollisionUtil.intersectsFrustumAndBox = function intersectsFrustumAndBox(frustum, box) {
2833
- var min = box.min, max = box.max;
2834
- var p = CollisionUtil._tempVec30;
2835
- for(var i = 0; i < 6; ++i){
2836
- var plane = frustum.getPlane(i);
2837
- var normal = plane.normal;
2838
- p.set(normal.x >= 0 ? max.x : min.x, normal.y >= 0 ? max.y : min.y, normal.z >= 0 ? max.z : min.z);
2839
- if (Vector3.dot(normal, p) < -plane.distance) {
2840
- return false;
2841
- }
2842
- }
2843
- return true;
2844
- };
2845
- /**
2846
- * Get the containment type between a frustum and a point.
2847
- * @param frustum - The frustum
2848
- * @param point - The point
2849
- * @returns The containment type
2850
- */ CollisionUtil.frustumContainsPoint = function frustumContainsPoint(frustum, point) {
2851
- var distance = CollisionUtil.distancePlaneAndPoint(frustum.near, point);
2852
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2853
- return ContainmentType.Intersects;
2854
- } else if (distance < 0) {
2855
- return ContainmentType.Disjoint;
2856
- }
2857
- distance = CollisionUtil.distancePlaneAndPoint(frustum.far, point);
2858
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2859
- return ContainmentType.Intersects;
2860
- } else if (distance < 0) {
2861
- return ContainmentType.Disjoint;
2862
- }
2863
- distance = CollisionUtil.distancePlaneAndPoint(frustum.left, point);
2864
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2865
- return ContainmentType.Intersects;
2866
- } else if (distance < 0) {
2867
- return ContainmentType.Disjoint;
2868
- }
2869
- distance = CollisionUtil.distancePlaneAndPoint(frustum.right, point);
2870
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2871
- return ContainmentType.Intersects;
2872
- } else if (distance < 0) {
2873
- return ContainmentType.Disjoint;
2874
- }
2875
- distance = CollisionUtil.distancePlaneAndPoint(frustum.top, point);
2876
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2877
- return ContainmentType.Intersects;
2878
- } else if (distance < 0) {
2879
- return ContainmentType.Disjoint;
2880
- }
2881
- distance = CollisionUtil.distancePlaneAndPoint(frustum.bottom, point);
2882
- if (Math.abs(distance) < MathUtil.zeroTolerance) {
2883
- return ContainmentType.Intersects;
2884
- } else if (distance < 0) {
2885
- return ContainmentType.Disjoint;
2886
- }
2887
- return ContainmentType.Contains;
2888
- };
2889
- /**
2890
- * Get the containment type between a frustum and a box (AABB).
2891
- * @param frustum - The frustum
2892
- * @param box - The box
2893
- * @returns The containment type
2894
- */ CollisionUtil.frustumContainsBox = function frustumContainsBox(frustum, box) {
2895
- var min = box.min, max = box.max;
2896
- var p = CollisionUtil._tempVec30;
2897
- var n = CollisionUtil._tempVec31;
2898
- var result = ContainmentType.Contains;
2899
- for(var i = 0; i < 6; ++i){
2900
- var plane = frustum.getPlane(i);
2901
- var normal = plane.normal;
2902
- if (normal.x >= 0) {
2903
- p.x = max.x;
2904
- n.x = min.x;
2905
- } else {
2906
- p.x = min.x;
2907
- n.x = max.x;
2908
- }
2909
- if (normal.y >= 0) {
2910
- p.y = max.y;
2911
- n.y = min.y;
2912
- } else {
2913
- p.y = min.y;
2914
- n.y = max.y;
2915
- }
2916
- if (normal.z >= 0) {
2917
- p.z = max.z;
2918
- n.z = min.z;
2919
- } else {
2920
- p.z = min.z;
2921
- n.z = max.z;
2922
- }
2923
- if (CollisionUtil.intersectsPlaneAndPoint(plane, p) === PlaneIntersectionType.Back) {
2924
- return ContainmentType.Disjoint;
2925
- }
2926
- if (CollisionUtil.intersectsPlaneAndPoint(plane, n) === PlaneIntersectionType.Back) {
2927
- result = ContainmentType.Intersects;
2928
- }
2929
- }
2930
- return result;
2931
- };
2932
- /**
2933
- * Get the containment type between a frustum and a sphere.
2934
- * @param frustum - The frustum
2935
- * @param sphere - The sphere
2936
- * @returns The containment type
2937
- */ CollisionUtil.frustumContainsSphere = function frustumContainsSphere(frustum, sphere) {
2938
- var result = ContainmentType.Contains;
2939
- for(var i = 0; i < 6; ++i){
2940
- var plane = frustum.getPlane(i);
2941
- var intersectionType = CollisionUtil.intersectsPlaneAndSphere(plane, sphere);
2942
- if (intersectionType === PlaneIntersectionType.Back) {
2943
- return ContainmentType.Disjoint;
2944
- } else if (intersectionType === PlaneIntersectionType.Intersecting) {
2945
- result = ContainmentType.Intersects;
2946
- break;
2947
- }
2948
- }
2949
- return result;
2950
- };
2951
- return CollisionUtil;
2952
- }();
2953
- (function() {
2954
- CollisionUtil._tempVec30 = new Vector3();
2955
- })();
2956
- (function() {
2957
- CollisionUtil._tempVec31 = new Vector3();
2958
- })();
2959
- (function() {
2960
- CollisionUtil._tempVec32 = new Vector3();
2961
- })();
2273
+ /** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
2274
+ /** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
2275
+ new Vector3();
2276
+ new Vector3();
2277
+ new Vector3();
2278
+ new Vector3();
2279
+ new Vector3();
2280
+ new Vector3();
2962
2281
  /**
2963
2282
  * Represents a 3x3 mathematical matrix.
2964
2283
  */ var Matrix3x3 = /*#__PURE__*/ function() {
2965
- var Matrix3x3 = function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
2284
+ function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
2966
2285
  if (m11 === void 0) m11 = 1;
2967
2286
  if (m12 === void 0) m12 = 0;
2968
2287
  if (m13 === void 0) m13 = 0;
@@ -2991,7 +2310,7 @@
2991
2310
  e[6] = m31;
2992
2311
  e[7] = m32;
2993
2312
  e[8] = m33;
2994
- };
2313
+ }
2995
2314
  var _proto = Matrix3x3.prototype;
2996
2315
  /**
2997
2316
  * Set the value of this matrix, and return this matrix.
@@ -3504,7 +2823,7 @@
3504
2823
  /**
3505
2824
  * Represents a four dimensional mathematical quaternion.
3506
2825
  */ var Quaternion = /*#__PURE__*/ function() {
3507
- var Quaternion = function Quaternion(x, y, z, w) {
2826
+ function Quaternion(x, y, z, w) {
3508
2827
  if (x === void 0) x = 0;
3509
2828
  if (y === void 0) y = 0;
3510
2829
  if (z === void 0) z = 0;
@@ -3514,7 +2833,7 @@
3514
2833
  this._y = y;
3515
2834
  this._z = z;
3516
2835
  this._w = w;
3517
- };
2836
+ }
3518
2837
  var _proto = Quaternion.prototype;
3519
2838
  /**
3520
2839
  * Set the value of this quaternion, and return this quaternion.
@@ -3528,7 +2847,7 @@
3528
2847
  this._y = y;
3529
2848
  this._z = z;
3530
2849
  this._w = w;
3531
- this._onValueChanged && this._onValueChanged();
2850
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
3532
2851
  return this;
3533
2852
  };
3534
2853
  /**
@@ -3538,7 +2857,7 @@
3538
2857
  this._x *= -1;
3539
2858
  this._y *= -1;
3540
2859
  this._z *= -1;
3541
- this._onValueChanged && this._onValueChanged();
2860
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
3542
2861
  return this;
3543
2862
  };
3544
2863
  /**
@@ -3569,7 +2888,7 @@
3569
2888
  this._y = 0;
3570
2889
  this._z = 0;
3571
2890
  this._w = 1;
3572
- this._onValueChanged && this._onValueChanged();
2891
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
3573
2892
  return this;
3574
2893
  };
3575
2894
  /**
@@ -3602,7 +2921,7 @@
3602
2921
  var t = out._x;
3603
2922
  out._x = out._y;
3604
2923
  out._y = t;
3605
- out._onValueChanged && out._onValueChanged();
2924
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3606
2925
  return out;
3607
2926
  };
3608
2927
  /**
@@ -3611,7 +2930,7 @@
3611
2930
  * @returns Euler x->yaw y->pitch z->roll
3612
2931
  */ _proto.toYawPitchRoll = function toYawPitchRoll(out) {
3613
2932
  this._toYawPitchRoll(out);
3614
- out._onValueChanged && out._onValueChanged();
2933
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3615
2934
  return out;
3616
2935
  };
3617
2936
  /**
@@ -3703,10 +3022,21 @@
3703
3022
  this._y = source.y;
3704
3023
  this._z = source.z;
3705
3024
  this._w = source.w;
3706
- this._onValueChanged && this._onValueChanged();
3025
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
3707
3026
  return this;
3708
3027
  };
3709
3028
  /**
3029
+ * Copy this quaternion to the specified quaternion.
3030
+ * @param target - The specified quaternion
3031
+ * @returns This specified quaternion
3032
+ */ _proto.copyTo = function copyTo(target) {
3033
+ target.x = this._x;
3034
+ target.y = this._y;
3035
+ target.z = this._z;
3036
+ target.w = this._w;
3037
+ return target;
3038
+ };
3039
+ /**
3710
3040
  * Copy the value of this quaternion from an array.
3711
3041
  * @param array - The array
3712
3042
  * @param offset - The start offset of the array
@@ -3717,7 +3047,7 @@
3717
3047
  this._y = array[offset + 1];
3718
3048
  this._z = array[offset + 2];
3719
3049
  this._w = array[offset + 3];
3720
- this._onValueChanged && this._onValueChanged();
3050
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
3721
3051
  return this;
3722
3052
  };
3723
3053
  /**
@@ -3775,7 +3105,7 @@
3775
3105
  out._y = left._y + right._y;
3776
3106
  out._z = left._z + right._z;
3777
3107
  out._w = left._w + right._w;
3778
- out._onValueChanged && out._onValueChanged();
3108
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3779
3109
  };
3780
3110
  /**
3781
3111
  * Determines the product of two quaternions.
@@ -3789,7 +3119,7 @@
3789
3119
  out._y = ay * bw + aw * by + az * bx - ax * bz;
3790
3120
  out._z = az * bw + aw * bz + ax * by - ay * bx;
3791
3121
  out._w = aw * bw - ax * bx - ay * by - az * bz;
3792
- out._onValueChanged && out._onValueChanged();
3122
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3793
3123
  };
3794
3124
  /**
3795
3125
  * Calculate quaternion that contains conjugated version of the specified quaternion.
@@ -3800,7 +3130,7 @@
3800
3130
  out._y = -a._y;
3801
3131
  out._z = -a._z;
3802
3132
  out._w = a._w;
3803
- out._onValueChanged && out._onValueChanged();
3133
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3804
3134
  };
3805
3135
  /**
3806
3136
  * Determines the dot product of two quaternions.
@@ -3832,7 +3162,7 @@
3832
3162
  out._y = normalAxis._y * s;
3833
3163
  out._z = normalAxis._z * s;
3834
3164
  out._w = Math.cos(rad);
3835
- out._onValueChanged && out._onValueChanged();
3165
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3836
3166
  };
3837
3167
  /**
3838
3168
  * Calculate a quaternion rotates around x, y, z axis (pitch/yaw/roll).
@@ -3865,7 +3195,7 @@
3865
3195
  out._y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
3866
3196
  out._z = cosYawPitch * sinRoll - sinYawPitch * cosRoll;
3867
3197
  out._w = cosYawPitch * cosRoll + sinYawPitch * sinRoll;
3868
- out._onValueChanged && out._onValueChanged();
3198
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3869
3199
  };
3870
3200
  /**
3871
3201
  * Calculate a quaternion from the specified 3x3 matrix.
@@ -3907,7 +3237,7 @@
3907
3237
  out._z = 0.5 * sqrt;
3908
3238
  out._w = (m12 - m21) * half;
3909
3239
  }
3910
- out._onValueChanged && out._onValueChanged();
3240
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3911
3241
  };
3912
3242
  /**
3913
3243
  * Calculate the inverse of the specified quaternion.
@@ -3922,7 +3252,7 @@
3922
3252
  out._y = -y * invDot;
3923
3253
  out._z = -z * invDot;
3924
3254
  out._w = w * invDot;
3925
- out._onValueChanged && out._onValueChanged();
3255
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3926
3256
  }
3927
3257
  };
3928
3258
  /**
@@ -3969,7 +3299,7 @@
3969
3299
  out.y = inverse * start.y + opposite * end.y;
3970
3300
  out.z = inverse * start.z + opposite * end.z;
3971
3301
  out.w = inverse * start.w + opposite * end.w;
3972
- out._onValueChanged && out._onValueChanged();
3302
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3973
3303
  };
3974
3304
  /**
3975
3305
  * Scales the specified quaternion magnitude to unit length.
@@ -3984,7 +3314,7 @@
3984
3314
  out._y = _y * len;
3985
3315
  out._z = _z * len;
3986
3316
  out._w = _w * len;
3987
- out._onValueChanged && out._onValueChanged();
3317
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
3988
3318
  }
3989
3319
  };
3990
3320
  /**
@@ -3999,7 +3329,7 @@
3999
3329
  out._y = 0;
4000
3330
  out._z = 0;
4001
3331
  out._w = c;
4002
- out._onValueChanged && out._onValueChanged();
3332
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4003
3333
  };
4004
3334
  /**
4005
3335
  * Calculate a quaternion rotate around Y axis.
@@ -4013,7 +3343,7 @@
4013
3343
  out._y = s;
4014
3344
  out._z = 0;
4015
3345
  out._w = c;
4016
- out._onValueChanged && out._onValueChanged();
3346
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4017
3347
  };
4018
3348
  /**
4019
3349
  * Calculate a quaternion rotate around Z axis.
@@ -4027,7 +3357,7 @@
4027
3357
  out._y = 0;
4028
3358
  out._z = s;
4029
3359
  out._w = c;
4030
- out._onValueChanged && out._onValueChanged();
3360
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4031
3361
  };
4032
3362
  /**
4033
3363
  * Calculate a quaternion that the specified quaternion rotate around X axis.
@@ -4043,7 +3373,7 @@
4043
3373
  out._y = _y * bw + _z * bx;
4044
3374
  out._z = _z * bw - _y * bx;
4045
3375
  out._w = _w * bw - _x * bx;
4046
- out._onValueChanged && out._onValueChanged();
3376
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4047
3377
  };
4048
3378
  /**
4049
3379
  * Calculate a quaternion that the specified quaternion rotate around Y axis.
@@ -4059,7 +3389,7 @@
4059
3389
  out._y = _y * bw + _w * by;
4060
3390
  out._z = _z * bw + _x * by;
4061
3391
  out._w = _w * bw - _y * by;
4062
- out._onValueChanged && out._onValueChanged();
3392
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4063
3393
  };
4064
3394
  /**
4065
3395
  * Calculate a quaternion that the specified quaternion rotate around Z axis.
@@ -4075,7 +3405,7 @@
4075
3405
  out._y = _y * bw - _x * bz;
4076
3406
  out._z = _z * bw + _w * bz;
4077
3407
  out._w = _w * bw - _z * bz;
4078
- out._onValueChanged && out._onValueChanged();
3408
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4079
3409
  };
4080
3410
  /**
4081
3411
  * Scale a quaternion by a given number.
@@ -4087,7 +3417,7 @@
4087
3417
  out._y = a._y * s;
4088
3418
  out._z = a._z * s;
4089
3419
  out._w = a._w * s;
4090
- out._onValueChanged && out._onValueChanged();
3420
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4091
3421
  };
4092
3422
  _create_class(Quaternion, [
4093
3423
  {
@@ -4099,7 +3429,7 @@
4099
3429
  },
4100
3430
  set: function set(value) {
4101
3431
  this._x = value;
4102
- this._onValueChanged && this._onValueChanged();
3432
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
4103
3433
  }
4104
3434
  },
4105
3435
  {
@@ -4111,7 +3441,7 @@
4111
3441
  },
4112
3442
  set: function set(value) {
4113
3443
  this._y = value;
4114
- this._onValueChanged && this._onValueChanged();
3444
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
4115
3445
  }
4116
3446
  },
4117
3447
  {
@@ -4123,7 +3453,7 @@
4123
3453
  },
4124
3454
  set: function set(value) {
4125
3455
  this._z = value;
4126
- this._onValueChanged && this._onValueChanged();
3456
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
4127
3457
  }
4128
3458
  },
4129
3459
  {
@@ -4143,22 +3473,18 @@
4143
3473
  },
4144
3474
  set: function set(value) {
4145
3475
  this._w = value;
4146
- this._onValueChanged && this._onValueChanged();
3476
+ this._onValueChanged == null ? void 0 : this._onValueChanged.call(this);
4147
3477
  }
4148
3478
  }
4149
3479
  ]);
4150
3480
  return Quaternion;
4151
3481
  }();
4152
- (function() {
4153
- /** @internal */ Quaternion._tempVector3 = new Vector3();
4154
- })();
4155
- (function() {
4156
- /** @internal */ Quaternion._tempQuat1 = new Quaternion();
4157
- })();
3482
+ /** @internal */ Quaternion._tempVector3 = new Vector3();
3483
+ /** @internal */ Quaternion._tempQuat1 = new Quaternion();
4158
3484
  /**
4159
3485
  * Represents a 4x4 mathematical matrix.
4160
3486
  */ var Matrix = /*#__PURE__*/ function() {
4161
- var Matrix = function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
3487
+ function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
4162
3488
  if (m11 === void 0) m11 = 1;
4163
3489
  if (m12 === void 0) m12 = 0;
4164
3490
  if (m13 === void 0) m13 = 0;
@@ -4202,7 +3528,7 @@
4202
3528
  e[13] = m42;
4203
3529
  e[14] = m43;
4204
3530
  e[15] = m44;
4205
- };
3531
+ }
4206
3532
  var _proto = Matrix.prototype;
4207
3533
  /**
4208
3534
  * Set the value of this matrix, and return this matrix.
@@ -4352,7 +3678,7 @@
4352
3678
  out._y = (e[6] + e[9]) / s3;
4353
3679
  out._z = 0.25 * s3;
4354
3680
  }
4355
- out._onValueChanged && out._onValueChanged();
3681
+ out._onValueChanged == null ? void 0 : out._onValueChanged.call(out);
4356
3682
  return out;
4357
3683
  };
4358
3684
  /**
@@ -5094,827 +4420,57 @@
5094
4420
  };
5095
4421
  return Matrix;
5096
4422
  }();
5097
- (function() {
5098
- Matrix._tempVec30 = new Vector3();
5099
- })();
5100
- (function() {
5101
- Matrix._tempVec31 = new Vector3();
5102
- })();
5103
- (function() {
5104
- Matrix._tempVec32 = new Vector3();
5105
- })();
5106
- (function() {
5107
- Matrix._tempMat30 = new Matrix3x3();
5108
- })();
5109
- (function() {
5110
- /** @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);
5111
- })();
5112
- /**
5113
- * Describes a 2D-vector.
5114
- */ var Vector2 = /*#__PURE__*/ function() {
5115
- var Vector2 = function Vector2(x, y) {
5116
- if (x === void 0) x = 0;
5117
- if (y === void 0) y = 0;
5118
- /** @internal */ this._onValueChanged = null;
5119
- this._x = x;
5120
- this._y = y;
4423
+ Matrix._tempVec30 = new Vector3();
4424
+ Matrix._tempVec31 = new Vector3();
4425
+ Matrix._tempVec32 = new Vector3();
4426
+ Matrix._tempMat30 = new Matrix3x3();
4427
+ /** @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);
4428
+
4429
+ var WebXRFrame = /*#__PURE__*/ function() {
4430
+ function WebXRFrame(session) {
4431
+ this._session = session;
4432
+ }
4433
+ var _proto = WebXRFrame.prototype;
4434
+ _proto.updateInputs = function updateInputs(inputs) {
4435
+ if (!this._platformFrame) return;
4436
+ this._updateController(inputs);
4437
+ this._updateCamera(inputs);
5121
4438
  };
5122
- var _proto = Vector2.prototype;
5123
- /**
5124
- * Set the value of this vector.
5125
- * @param x - The x component of the vector
5126
- * @param y - The y component of the vector
5127
- * @returns This vector
5128
- */ _proto.set = function set(x, y) {
5129
- this._x = x;
5130
- this._y = y;
5131
- this._onValueChanged && this._onValueChanged();
5132
- return this;
5133
- };
5134
- /**
5135
- * Determines the sum of this vector and the specified vector.
5136
- * @param right - The specified vector
5137
- * @returns This vector
5138
- */ _proto.add = function add(right) {
5139
- this._x += right._x;
5140
- this._y += right._y;
5141
- this._onValueChanged && this._onValueChanged();
5142
- return this;
5143
- };
5144
- /**
5145
- * Determines the difference of this vector and the specified vector.
5146
- * @param right - The specified vector
5147
- * @returns This vector
5148
- */ _proto.subtract = function subtract(right) {
5149
- this._x -= right._x;
5150
- this._y -= right._y;
5151
- this._onValueChanged && this._onValueChanged();
5152
- return this;
5153
- };
5154
- /**
5155
- * Determines the product of this vector and the specified vector.
5156
- * @param right - The specified vector
5157
- * @returns This vector
5158
- */ _proto.multiply = function multiply(right) {
5159
- this._x *= right._x;
5160
- this._y *= right._y;
5161
- this._onValueChanged && this._onValueChanged();
5162
- return this;
5163
- };
5164
- /**
5165
- * Determines the divisor of this vector and the specified vector.
5166
- * @param right - The specified vector
5167
- * @returns This vector
5168
- */ _proto.divide = function divide(right) {
5169
- this._x /= right._x;
5170
- this._y /= right._y;
5171
- this._onValueChanged && this._onValueChanged();
5172
- return this;
5173
- };
5174
- /**
5175
- * Calculate the length of this vector.
5176
- * @returns The length of this vector
5177
- */ _proto.length = function length() {
5178
- var _this = this, _x = _this._x, _y = _this._y;
5179
- return Math.sqrt(_x * _x + _y * _y);
5180
- };
5181
- /**
5182
- * Calculate the squared length of this vector.
5183
- * @returns The squared length of this vector
5184
- */ _proto.lengthSquared = function lengthSquared() {
5185
- var _this = this, _x = _this._x, _y = _this._y;
5186
- return _x * _x + _y * _y;
5187
- };
5188
- /**
5189
- * Reverses the direction of this vector.
5190
- * @returns This vector
5191
- */ _proto.negate = function negate() {
5192
- this._x = -this._x;
5193
- this._y = -this._y;
5194
- this._onValueChanged && this._onValueChanged();
5195
- return this;
5196
- };
5197
- /**
5198
- * Converts this vector into a unit vector.
5199
- * @returns This vector
5200
- */ _proto.normalize = function normalize() {
5201
- Vector2.normalize(this, this);
5202
- return this;
5203
- };
5204
- /**
5205
- * Scale this vector by the given value.
5206
- * @param s - The amount by which to scale the vector
5207
- * @returns This vector
5208
- */ _proto.scale = function scale(s) {
5209
- this._x *= s;
5210
- this._y *= s;
5211
- this._onValueChanged && this._onValueChanged();
5212
- return this;
5213
- };
5214
- /**
5215
- * Creates a clone of this vector.
5216
- * @returns A clone of this vector
5217
- */ _proto.clone = function clone() {
5218
- return new Vector2(this._x, this._y);
5219
- };
5220
- /**
5221
- * Copy from vector2 like object.
5222
- * @param source - Vector2 like object
5223
- * @returns This vector
5224
- */ _proto.copyFrom = function copyFrom(source) {
5225
- this._x = source.x;
5226
- this._y = source.y;
5227
- this._onValueChanged && this._onValueChanged();
5228
- return this;
5229
- };
5230
- /**
5231
- * Copy the value of this vector from an array.
5232
- * @param array - The array
5233
- * @param offset - The start offset of the array
5234
- * @returns This vector
5235
- */ _proto.copyFromArray = function copyFromArray(array, offset) {
5236
- if (offset === void 0) offset = 0;
5237
- this._x = array[offset];
5238
- this._y = array[offset + 1];
5239
- this._onValueChanged && this._onValueChanged();
5240
- return this;
5241
- };
5242
- /**
5243
- * Copy the value of this vector to an array.
5244
- * @param out - The array
5245
- * @param outOffset - The start offset of the array
5246
- */ _proto.copyToArray = function copyToArray(out, outOffset) {
5247
- if (outOffset === void 0) outOffset = 0;
5248
- out[outOffset] = this._x;
5249
- out[outOffset + 1] = this._y;
5250
- };
5251
- /**
5252
- * Serialize this vector to a JSON representation.
5253
- * @returns A JSON representation of this vector
5254
- */ _proto.toJSON = function toJSON() {
5255
- return {
5256
- x: this._x,
5257
- y: this._y
5258
- };
5259
- };
5260
- /**
5261
- * Determines the sum of two vectors.
5262
- * @param left - The first vector to add
5263
- * @param right - The second vector to add
5264
- * @param out - The sum of two vectors
5265
- */ Vector2.add = function add(left, right, out) {
5266
- out._x = left._x + right._x;
5267
- out._y = left._y + right._y;
5268
- out._onValueChanged && out._onValueChanged();
5269
- };
5270
- /**
5271
- * Determines the difference between two vectors.
5272
- * @param left - The first vector to subtract
5273
- * @param right - The second vector to subtract
5274
- * @param out - The difference between two vectors
5275
- */ Vector2.subtract = function subtract(left, right, out) {
5276
- out._x = left._x - right._x;
5277
- out._y = left._y - right._y;
5278
- out._onValueChanged && out._onValueChanged();
5279
- };
5280
- /**
5281
- * Determines the product of two vectors.
5282
- * @param left - The first vector to multiply
5283
- * @param right - The second vector to multiply
5284
- * @param out - The product of two vectors
5285
- */ Vector2.multiply = function multiply(left, right, out) {
5286
- out._x = left._x * right._x;
5287
- out._y = left._y * right._y;
5288
- out._onValueChanged && out._onValueChanged();
5289
- };
5290
- /**
5291
- * Determines the divisor of two vectors.
5292
- * @param left - The first vector to divide
5293
- * @param right - The second vector to divide
5294
- * @param out - The divisor of two vectors
5295
- */ Vector2.divide = function divide(left, right, out) {
5296
- out._x = left._x / right._x;
5297
- out._y = left._y / right._y;
5298
- out._onValueChanged && out._onValueChanged();
5299
- };
5300
- /**
5301
- * Determines the dot product of two vectors.
5302
- * @param left - The first vector to dot
5303
- * @param right - The second vector to dot
5304
- * @returns The dot product of two vectors
5305
- */ Vector2.dot = function dot(left, right) {
5306
- return left._x * right._x + left._y * right._y;
5307
- };
5308
- /**
5309
- * Determines the distance of two vectors.
5310
- * @param left - The first vector
5311
- * @param right - The second vector
5312
- * @returns The distance of two vectors
5313
- */ Vector2.distance = function distance(left, right) {
5314
- var x = right._x - left._x;
5315
- var y = right._y - left._y;
5316
- return Math.sqrt(x * x + y * y);
5317
- };
5318
- /**
5319
- * Determines the squared distance of two vectors.
5320
- * @param left - The first vector
5321
- * @param right - The second vector
5322
- * @returns The squared distance of two vectors
5323
- */ Vector2.distanceSquared = function distanceSquared(left, right) {
5324
- var x = right._x - left._x;
5325
- var y = right._y - left._y;
5326
- return x * x + y * y;
5327
- };
5328
- /**
5329
- * Determines whether the specified vectors are equals.
5330
- * @param left - The first vector to compare
5331
- * @param right - The second vector to compare
5332
- * @returns True if the specified vectors are equals, false otherwise
5333
- */ Vector2.equals = function equals(left, right) {
5334
- return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y);
5335
- };
5336
- /**
5337
- * Performs a linear interpolation between two vectors.
5338
- * @param left - The first vector
5339
- * @param right - The second vector
5340
- * @param t - The blend amount where 0 returns left and 1 right
5341
- * @param out - The result of linear blending between two vectors
5342
- */ Vector2.lerp = function lerp(left, right, t, out) {
5343
- var _x = left._x, _y = left._y;
5344
- out._x = _x + (right._x - _x) * t;
5345
- out._y = _y + (right._y - _y) * t;
5346
- out._onValueChanged && out._onValueChanged();
5347
- };
5348
- /**
5349
- * Calculate a vector containing the largest components of the specified vectors.
5350
- * @param left - The first vector
5351
- * @param right - The second vector
5352
- * @param out - The vector containing the largest components of the specified vectors
5353
- */ Vector2.max = function max(left, right, out) {
5354
- out._x = Math.max(left._x, right._x);
5355
- out._y = Math.max(left._y, right._y);
5356
- out._onValueChanged && out._onValueChanged();
5357
- };
5358
- /**
5359
- * Calculate a vector containing the smallest components of the specified vectors.
5360
- * @param left - The first vector
5361
- * @param right - The second vector
5362
- * @param out - The vector containing the smallest components of the specified vectors
5363
- */ Vector2.min = function min(left, right, out) {
5364
- out._x = Math.min(left._x, right._x);
5365
- out._y = Math.min(left._y, right._y);
5366
- out._onValueChanged && out._onValueChanged();
5367
- };
5368
- /**
5369
- * Reverses the direction of a given vector.
5370
- * @param left - The vector to negate
5371
- * @param out - The vector facing in the opposite direction
5372
- */ Vector2.negate = function negate(left, out) {
5373
- out._x = -left._x;
5374
- out._y = -left._y;
5375
- out._onValueChanged && out._onValueChanged();
5376
- };
5377
- /**
5378
- * Converts the vector into a unit vector.
5379
- * @param left - The vector to normalize
5380
- * @param out - The normalized vector
5381
- */ Vector2.normalize = function normalize(left, out) {
5382
- var _x = left._x, _y = left._y;
5383
- var len = Math.sqrt(_x * _x + _y * _y);
5384
- if (len > MathUtil.zeroTolerance) {
5385
- len = 1 / len;
5386
- out._x = _x * len;
5387
- out._y = _y * len;
5388
- out._onValueChanged && out._onValueChanged();
5389
- }
5390
- };
5391
- /**
5392
- * Scale a vector by the given value.
5393
- * @param left - The vector to scale
5394
- * @param s - The amount by which to scale the vector
5395
- * @param out - The scaled vector
5396
- */ Vector2.scale = function scale(left, s, out) {
5397
- out._x = left._x * s;
5398
- out._y = left._y * s;
5399
- out._onValueChanged && out._onValueChanged();
5400
- };
5401
- _create_class(Vector2, [
5402
- {
5403
- key: "x",
5404
- get: /**
5405
- * The x component of the vector.
5406
- */ function get() {
5407
- return this._x;
5408
- },
5409
- set: function set(value) {
5410
- this._x = value;
5411
- this._onValueChanged && this._onValueChanged();
5412
- }
5413
- },
5414
- {
5415
- key: "y",
5416
- get: /**
5417
- * The y component of the vector.
5418
- */ function get() {
5419
- return this._y;
5420
- },
5421
- set: function set(value) {
5422
- this._y = value;
5423
- this._onValueChanged && this._onValueChanged();
5424
- }
5425
- }
5426
- ]);
5427
- return Vector2;
5428
- }();
5429
- (function() {
5430
- /** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
5431
- })();
5432
- (function() {
5433
- /** @internal */ Vector2._one = new Vector2(1.0, 1.0);
5434
- })();
5435
- /**
5436
- * Describes a 4D-vector.
5437
- */ var Vector4 = /*#__PURE__*/ function() {
5438
- var Vector4 = function Vector4(x, y, z, w) {
5439
- if (x === void 0) x = 0;
5440
- if (y === void 0) y = 0;
5441
- if (z === void 0) z = 0;
5442
- if (w === void 0) w = 0;
5443
- /** @internal */ this._onValueChanged = null;
5444
- this._x = x;
5445
- this._y = y;
5446
- this._z = z;
5447
- this._w = w;
5448
- };
5449
- var _proto = Vector4.prototype;
5450
- /**
5451
- * Set the value of this vector.
5452
- * @param x - The x component of the vector
5453
- * @param y - The y component of the vector
5454
- * @param z - The z component of the vector
5455
- * @param w - The w component of the vector
5456
- * @returns This vector
5457
- */ _proto.set = function set(x, y, z, w) {
5458
- this._x = x;
5459
- this._y = y;
5460
- this._z = z;
5461
- this._w = w;
5462
- this._onValueChanged && this._onValueChanged();
5463
- return this;
5464
- };
5465
- /**
5466
- * Determines the sum of this vector and the specified vector.
5467
- * @param right - The specified vector
5468
- * @returns This vector
5469
- */ _proto.add = function add(right) {
5470
- this._x += right._x;
5471
- this._y += right._y;
5472
- this._z += right._z;
5473
- this._w += right._w;
5474
- this._onValueChanged && this._onValueChanged();
5475
- return this;
5476
- };
5477
- /**
5478
- * Determines the difference of this vector and the specified vector.
5479
- * @param right - the specified vector
5480
- * @returns This vector
5481
- */ _proto.subtract = function subtract(right) {
5482
- this._x -= right._x;
5483
- this._y -= right._y;
5484
- this._z -= right._z;
5485
- this._w -= right._w;
5486
- this._onValueChanged && this._onValueChanged();
5487
- return this;
5488
- };
5489
- /**
5490
- * Determines the product of this vector and the specified vector.
5491
- * @param right - the specified vector
5492
- * @returns This vector
5493
- */ _proto.multiply = function multiply(right) {
5494
- this._x *= right._x;
5495
- this._y *= right._y;
5496
- this._z *= right._z;
5497
- this._w *= right._w;
5498
- this._onValueChanged && this._onValueChanged();
5499
- return this;
5500
- };
5501
- /**
5502
- * Determines the divisor of this vector and the specified vector.
5503
- * @param right - the specified vector
5504
- * @returns This vector
5505
- */ _proto.divide = function divide(right) {
5506
- this._x /= right._x;
5507
- this._y /= right._y;
5508
- this._z /= right._z;
5509
- this._w /= right._w;
5510
- this._onValueChanged && this._onValueChanged();
5511
- return this;
5512
- };
5513
- /**
5514
- * Calculate the length of this vector.
5515
- * @returns The length of this vector
5516
- */ _proto.length = function length() {
5517
- var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
5518
- return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
5519
- };
5520
- /**
5521
- * Calculate the squared length of this vector.
5522
- * @returns The squared length of this vector
5523
- */ _proto.lengthSquared = function lengthSquared() {
5524
- var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
5525
- return _x * _x + _y * _y + _z * _z + _w * _w;
5526
- };
5527
- /**
5528
- * Reverses the direction of this vector.
5529
- * @returns This vector
5530
- */ _proto.negate = function negate() {
5531
- this._x = -this._x;
5532
- this._y = -this._y;
5533
- this._z = -this._z;
5534
- this._w = -this._w;
5535
- this._onValueChanged && this._onValueChanged();
5536
- return this;
5537
- };
5538
- /**
5539
- * Converts this vector into a unit vector.
5540
- * @returns This vector
5541
- */ _proto.normalize = function normalize() {
5542
- Vector4.normalize(this, this);
5543
- return this;
5544
- };
5545
- /**
5546
- * Scale this vector by the given value.
5547
- * @param s - The amount by which to scale the vector
5548
- * @returns This vector
5549
- */ _proto.scale = function scale(s) {
5550
- this._x *= s;
5551
- this._y *= s;
5552
- this._z *= s;
5553
- this._w *= s;
5554
- this._onValueChanged && this._onValueChanged();
5555
- return this;
5556
- };
5557
- /**
5558
- * Creates a clone of this vector.
5559
- * @returns A clone of this vector
5560
- */ _proto.clone = function clone() {
5561
- var ret = new Vector4(this._x, this._y, this._z, this._w);
5562
- return ret;
5563
- };
5564
- /**
5565
- * Copy from vector3 like object.
5566
- * @param source - Vector3 like object.
5567
- * @returns This vector
5568
- */ _proto.copyFrom = function copyFrom(source) {
5569
- this._x = source.x;
5570
- this._y = source.y;
5571
- this._z = source.z;
5572
- this._w = source.w;
5573
- this._onValueChanged && this._onValueChanged();
5574
- return this;
5575
- };
5576
- /**
5577
- * Copy the value of this vector by an array.
5578
- * @param array - The array
5579
- * @param offset - The start offset of the array
5580
- * @returns This vector
5581
- */ _proto.copyFromArray = function copyFromArray(array, offset) {
5582
- if (offset === void 0) offset = 0;
5583
- this._x = array[offset];
5584
- this._y = array[offset + 1];
5585
- this._z = array[offset + 2];
5586
- this._w = array[offset + 3];
5587
- this._onValueChanged && this._onValueChanged();
5588
- return this;
5589
- };
5590
- /**
5591
- * Copy the value of this vector to an array.
5592
- * @param out - The array
5593
- * @param outOffset - The start offset of the array
5594
- */ _proto.copyToArray = function copyToArray(out, outOffset) {
5595
- if (outOffset === void 0) outOffset = 0;
5596
- out[outOffset] = this._x;
5597
- out[outOffset + 1] = this._y;
5598
- out[outOffset + 2] = this._z;
5599
- out[outOffset + 3] = this._w;
5600
- };
5601
- /**
5602
- * Serialize this vector to a JSON representation.
5603
- * @returns A JSON representation of this vector
5604
- */ _proto.toJSON = function toJSON() {
5605
- return {
5606
- x: this._x,
5607
- y: this._y,
5608
- z: this._z,
5609
- w: this._w
5610
- };
5611
- };
5612
- /**
5613
- * Determines the sum of two vectors.
5614
- * @param left - The first vector to add
5615
- * @param right - The second vector to add
5616
- * @param out - The sum of two vectors
5617
- */ Vector4.add = function add(left, right, out) {
5618
- out._x = left._x + right._x;
5619
- out._y = left._y + right._y;
5620
- out._z = left._z + right._z;
5621
- out._w = left._w + right._w;
5622
- out._onValueChanged && out._onValueChanged();
5623
- };
5624
- /**
5625
- * Determines the difference between two vectors.
5626
- * @param left - The first vector to subtract
5627
- * @param right - The second vector to subtract
5628
- * @param out - The difference between two vectors
5629
- */ Vector4.subtract = function subtract(left, right, out) {
5630
- out._x = left._x - right._x;
5631
- out._y = left._y - right._y;
5632
- out._z = left._z - right._z;
5633
- out._w = left._w - right._w;
5634
- out._onValueChanged && out._onValueChanged();
5635
- };
5636
- /**
5637
- * Determines the product of two vectors.
5638
- * @param left - The first vector to multiply
5639
- * @param right - The second vector to multiply
5640
- * @param out - The product of two vectors
5641
- */ Vector4.multiply = function multiply(left, right, out) {
5642
- out._x = left._x * right._x;
5643
- out._y = left._y * right._y;
5644
- out._z = left._z * right._z;
5645
- out._w = left._w * right._w;
5646
- out._onValueChanged && out._onValueChanged();
5647
- };
5648
- /**
5649
- * Determines the divisor of two vectors.
5650
- * @param left - The first vector to divide
5651
- * @param right - The second vector to divide
5652
- * @param out - The divisor of two vectors
5653
- */ Vector4.divide = function divide(left, right, out) {
5654
- out._x = left._x / right._x;
5655
- out._y = left._y / right._y;
5656
- out._z = left._z / right._z;
5657
- out._w = left._w / right._w;
5658
- out._onValueChanged && out._onValueChanged();
5659
- };
5660
- /**
5661
- * Determines the dot product of two vectors.
5662
- * @param left - The first vector to dot
5663
- * @param right - The second vector to dot
5664
- * @returns The dot product of two vectors
5665
- */ Vector4.dot = function dot(left, right) {
5666
- return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
5667
- };
5668
- /**
5669
- * Determines the distance of two vectors.
5670
- * @param a - The first vector
5671
- * @param b - The second vector
5672
- * @returns The distance of two vectors
5673
- */ Vector4.distance = function distance(a, b) {
5674
- var x = b._x - a._x;
5675
- var y = b._y - a._y;
5676
- var z = b._z - a._z;
5677
- var w = b._w - a._w;
5678
- return Math.sqrt(x * x + y * y + z * z + w * w);
5679
- };
5680
- /**
5681
- * Determines the squared distance of two vectors.
5682
- * @param a - The first vector
5683
- * @param b - The second vector
5684
- * @returns The squared distance of two vectors
5685
- */ Vector4.distanceSquared = function distanceSquared(a, b) {
5686
- var x = b._x - a._x;
5687
- var y = b._y - a._y;
5688
- var z = b._z - a._z;
5689
- var w = b._w - a._w;
5690
- return x * x + y * y + z * z + w * w;
5691
- };
5692
- /**
5693
- * Determines whether the specified vectors are equals.
5694
- * @param left - The first vector to compare
5695
- * @param right - The second vector to compare
5696
- * @returns True if the specified vectors are equals, false otherwise
5697
- */ Vector4.equals = function equals(left, right) {
5698
- 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);
5699
- };
5700
- /**
5701
- * Performs a linear interpolation between two vectors.
5702
- * @param start - The first vector
5703
- * @param end - The second vector
5704
- * @param t - The blend amount where 0 returns start and 1 end
5705
- * @param out - The result of linear blending between two vectors
5706
- */ Vector4.lerp = function lerp(start, end, t, out) {
5707
- var _x = start._x, _y = start._y, _z = start._z, _w = start._w;
5708
- out._x = _x + (end._x - _x) * t;
5709
- out._y = _y + (end._y - _y) * t;
5710
- out._z = _z + (end._z - _z) * t;
5711
- out._w = _w + (end._w - _w) * t;
5712
- out._onValueChanged && out._onValueChanged();
5713
- };
5714
- /**
5715
- * Calculate a vector containing the largest components of the specified vectors.
5716
- * @param left - The first vector
5717
- * @param right - The second vector
5718
- * @param out - The vector containing the largest components of the specified vectors
5719
- */ Vector4.max = function max(left, right, out) {
5720
- out._x = Math.max(left._x, right._x);
5721
- out._y = Math.max(left._y, right._y);
5722
- out._z = Math.max(left._z, right._z);
5723
- out._w = Math.max(left._w, right._w);
5724
- out._onValueChanged && out._onValueChanged();
5725
- };
5726
- /**
5727
- * Calculate a vector containing the smallest components of the specified vectors.
5728
- * @param left - The first vector
5729
- * @param right - The second vector
5730
- * @param out - The vector containing the smallest components of the specified vectors
5731
- */ Vector4.min = function min(left, right, out) {
5732
- out._x = Math.min(left._x, right._x);
5733
- out._y = Math.min(left._y, right._y);
5734
- out._z = Math.min(left._z, right._z);
5735
- out._w = Math.min(left._w, right._w);
5736
- out._onValueChanged && out._onValueChanged();
5737
- };
5738
- /**
5739
- * Reverses the direction of a given vector.
5740
- * @param a - The vector to negate
5741
- * @param out - The vector facing in the opposite direction
5742
- */ Vector4.negate = function negate(a, out) {
5743
- out._x = -a._x;
5744
- out._y = -a._y;
5745
- out._z = -a._z;
5746
- out._w = -a._w;
5747
- out._onValueChanged && out._onValueChanged();
5748
- };
5749
- /**
5750
- * Converts the vector into a unit vector.
5751
- * @param a - The vector to normalize
5752
- * @param out - The normalized vector
5753
- */ Vector4.normalize = function normalize(a, out) {
5754
- var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
5755
- var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
5756
- if (len > MathUtil.zeroTolerance) {
5757
- len = 1 / len;
5758
- out._x = _x * len;
5759
- out._y = _y * len;
5760
- out._z = _z * len;
5761
- out._w = _w * len;
5762
- out._onValueChanged && out._onValueChanged();
5763
- }
5764
- };
5765
- /**
5766
- * Scale a vector by the given value.
5767
- * @param a - The vector to scale
5768
- * @param s - The amount by which to scale the vector
5769
- * @param out - The scaled vector
5770
- */ Vector4.scale = function scale(a, s, out) {
5771
- out._x = a._x * s;
5772
- out._y = a._y * s;
5773
- out._z = a._z * s;
5774
- out._w = a._w * s;
5775
- out._onValueChanged && out._onValueChanged();
5776
- };
5777
- /**
5778
- * Performs a transformation using the given 4x4 matrix.
5779
- * @param v - The vector to transform
5780
- * @param m - The transform matrix
5781
- * @param out - The transformed vector3
5782
- */ Vector4.transform = function transform(v, m, out) {
5783
- var _x = v._x, _y = v._y, _z = v._z, _w = v._w;
5784
- var e = m.elements;
5785
- out._x = _x * e[0] + _y * e[4] + _z * e[8] + _w * e[12];
5786
- out._y = _x * e[1] + _y * e[5] + _z * e[9] + _w * e[13];
5787
- out._z = _x * e[2] + _y * e[6] + _z * e[10] + _w * e[14];
5788
- out._w = _x * e[3] + _y * e[7] + _z * e[11] + _w * e[15];
5789
- out._onValueChanged && out._onValueChanged();
5790
- };
5791
- /**
5792
- * Performs a transformation using the given quaternion.
5793
- * @param v - The vector to transform
5794
- * @param q - The transform quaternion
5795
- * @param out - The transformed vector
5796
- */ Vector4.transformByQuat = function transformByQuat(v, q, out) {
5797
- var x = v._x, y = v._y, z = v._z, w = v._w;
5798
- var qx = q._x;
5799
- var qy = q._y;
5800
- var qz = q._z;
5801
- var qw = q._w;
5802
- // calculate quat * vec
5803
- var ix = qw * x + qy * z - qz * y;
5804
- var iy = qw * y + qz * x - qx * z;
5805
- var iz = qw * z + qx * y - qy * x;
5806
- var iw = -qx * x - qy * y - qz * z;
5807
- // calculate result * inverse quat
5808
- out._x = ix * qw - iw * qx - iy * qz + iz * qy;
5809
- out._y = iy * qw - iw * qy - iz * qx + ix * qz;
5810
- out._z = iz * qw - iw * qz - ix * qy + iy * qx;
5811
- out._w = w;
5812
- out._onValueChanged && out._onValueChanged();
5813
- };
5814
- _create_class(Vector4, [
5815
- {
5816
- key: "x",
5817
- get: /**
5818
- * The x component of the vector.
5819
- */ function get() {
5820
- return this._x;
5821
- },
5822
- set: function set(value) {
5823
- this._x = value;
5824
- this._onValueChanged && this._onValueChanged();
5825
- }
5826
- },
5827
- {
5828
- key: "y",
5829
- get: /**
5830
- * The y component of the vector.
5831
- */ function get() {
5832
- return this._y;
5833
- },
5834
- set: function set(value) {
5835
- this._y = value;
5836
- this._onValueChanged && this._onValueChanged();
5837
- }
5838
- },
5839
- {
5840
- key: "z",
5841
- get: /**
5842
- * The z component of the vector.
5843
- */ function get() {
5844
- return this._z;
5845
- },
5846
- set: function set(value) {
5847
- this._z = value;
5848
- this._onValueChanged && this._onValueChanged();
5849
- }
5850
- },
5851
- {
5852
- key: "w",
5853
- get: /**
5854
- * The w component of the vector.
5855
- */ function get() {
5856
- return this._w;
5857
- },
5858
- set: function set(value) {
5859
- this._w = value;
5860
- this._onValueChanged && this._onValueChanged();
5861
- }
5862
- }
5863
- ]);
5864
- return Vector4;
5865
- }();
5866
- (function() {
5867
- /** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
5868
- })();
5869
- (function() {
5870
- /** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
5871
- })();
5872
-
5873
- var WebXRFrame = /*#__PURE__*/ function() {
5874
- function WebXRFrame(session) {
5875
- this._session = session;
5876
- }
5877
- var _proto = WebXRFrame.prototype;
5878
- _proto.updateInputs = function updateInputs(inputs) {
5879
- if (!this._platformFrame) return;
5880
- this._updateController(inputs);
5881
- this._updateCamera(inputs);
5882
- };
5883
- _proto._updateController = function _updateController(inputs) {
5884
- var _this = this, frame = _this._platformFrame;
5885
- var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
5886
- var inputSources = session.inputSources;
5887
- for(var i = 0, n = inputSources.length; i < n; i++){
5888
- var inputSource = inputSources[i];
5889
- var type = getInputSource(inputSource);
5890
- var input = inputs[type];
5891
- switch(inputSource.targetRayMode){
5892
- case "screen":
5893
- case "tracked-pointer":
5894
- var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
5895
- if (gripSpace) {
5896
- var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
5897
- if (transform) {
5898
- var gripPose = input.gripPose;
5899
- gripPose.matrix.copyFromArray(transform.matrix);
5900
- gripPose.position.copyFrom(transform.position);
5901
- gripPose.rotation.copyFrom(transform.orientation);
5902
- }
5903
- input.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
5904
- }
5905
- if (targetRaySpace) {
5906
- var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
5907
- if (transform1) {
5908
- var targetRayPose = input.targetRayPose;
5909
- targetRayPose.matrix.copyFromArray(transform1.matrix);
5910
- targetRayPose.position.copyFrom(transform1.position);
5911
- targetRayPose.rotation.copyFrom(transform1.orientation);
5912
- input.trackingState = emulatedPosition1 ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
5913
- }
5914
- }
5915
- break;
5916
- }
5917
- }
4439
+ _proto._updateController = function _updateController(inputs) {
4440
+ var _this = this, frame = _this._platformFrame;
4441
+ var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
4442
+ var inputSources = session.inputSources;
4443
+ for(var i = 0, n = inputSources.length; i < n; i++){
4444
+ var inputSource = inputSources[i];
4445
+ var type = getInputSource(inputSource);
4446
+ var input = inputs[type];
4447
+ switch(inputSource.targetRayMode){
4448
+ case "screen":
4449
+ case "tracked-pointer":
4450
+ var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
4451
+ if (gripSpace) {
4452
+ var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
4453
+ if (transform) {
4454
+ var gripPose = input.gripPose;
4455
+ gripPose.matrix.copyFromArray(transform.matrix);
4456
+ gripPose.position.copyFrom(transform.position);
4457
+ gripPose.rotation.copyFrom(transform.orientation);
4458
+ }
4459
+ input.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4460
+ }
4461
+ if (targetRaySpace) {
4462
+ var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
4463
+ if (transform1) {
4464
+ var targetRayPose = input.targetRayPose;
4465
+ targetRayPose.matrix.copyFromArray(transform1.matrix);
4466
+ targetRayPose.position.copyFrom(transform1.position);
4467
+ targetRayPose.rotation.copyFrom(transform1.orientation);
4468
+ input.trackingState = emulatedPosition1 ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
4469
+ }
4470
+ }
4471
+ break;
4472
+ }
4473
+ }
5918
4474
  };
5919
4475
  _proto._updateCamera = function _updateCamera(inputs) {
5920
4476
  var _this = this, frame = _this._platformFrame;
@@ -6254,9 +4810,7 @@
6254
4810
  };
6255
4811
  return WebXRDevice;
6256
4812
  }();
6257
- (function() {
6258
- /** @internal */ WebXRDevice._platformFeatureMap = [];
6259
- })();
4813
+ /** @internal */ WebXRDevice._platformFeatureMap = [];
6260
4814
  function registerXRPlatformFeature(type) {
6261
4815
  return function(platformFeatureConstructor) {
6262
4816
  WebXRDevice._platformFeatureMap[type] = platformFeatureConstructor;
@@ -6270,10 +4824,10 @@
6270
4824
 
6271
4825
  /**
6272
4826
  * @internal
6273
- */ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature1) {
6274
- _inherits$1(WebXRTrackableFeature, WebXRFeature1);
4827
+ */ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature) {
4828
+ _inherits$1(WebXRTrackableFeature, WebXRFeature);
6275
4829
  function WebXRTrackableFeature() {
6276
- return WebXRFeature1.apply(this, arguments);
4830
+ return WebXRFeature.apply(this, arguments) || this;
6277
4831
  }
6278
4832
  var _proto = WebXRTrackableFeature.prototype;
6279
4833
  _proto.onAddRequestTracking = function onAddRequestTracking(requestTracking) {};
@@ -6291,10 +4845,10 @@
6291
4845
  return WebXRTrackableFeature;
6292
4846
  }(WebXRFeature);
6293
4847
 
6294
- var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
6295
- _inherits$1(WebXRAnchorTracking, WebXRTrackableFeature1);
4848
+ var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
4849
+ _inherits$1(WebXRAnchorTracking, WebXRTrackableFeature);
6296
4850
  function WebXRAnchorTracking() {
6297
- return WebXRTrackableFeature1.apply(this, arguments);
4851
+ return WebXRTrackableFeature.apply(this, arguments) || this;
6298
4852
  }
6299
4853
  var _proto = WebXRAnchorTracking.prototype;
6300
4854
  _proto.checkAvailable = function checkAvailable(session, frame, requestTrackings) {
@@ -6405,14 +4959,11 @@
6405
4959
  registerXRPlatformFeature(XRFeatureType.AnchorTracking)
6406
4960
  ], WebXRAnchorTracking);
6407
4961
 
6408
- var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
6409
- _inherits$1(WebXRImageTracking, WebXRTrackableFeature1);
4962
+ var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
4963
+ _inherits$1(WebXRImageTracking, WebXRTrackableFeature);
6410
4964
  function WebXRImageTracking(images) {
6411
4965
  var _this;
6412
- _this = WebXRTrackableFeature1.call(this) || this;
6413
- _this._trackingScoreStatus = 0;
6414
- _this._tempIdx = 0;
6415
- _this._tempArr = [];
4966
+ _this = WebXRTrackableFeature.call(this) || this, _this._trackingScoreStatus = 0, _this._tempIdx = 0, _this._tempArr = [];
6416
4967
  _this._images = images;
6417
4968
  return _this;
6418
4969
  }
@@ -6529,17 +5080,12 @@
6529
5080
  WebXRImageTracking = __decorate$1([
6530
5081
  registerXRPlatformFeature(XRFeatureType.ImageTracking)
6531
5082
  ], WebXRImageTracking);
6532
- var ImageTrackingScoreStatus;
6533
- (function(ImageTrackingScoreStatus) {
6534
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["NotReceived"] = 0] = "NotReceived";
6535
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["Waiting"] = 1] = "Waiting";
6536
- ImageTrackingScoreStatus[ImageTrackingScoreStatus["Received"] = 2] = "Received";
6537
- })(ImageTrackingScoreStatus || (ImageTrackingScoreStatus = {}));
6538
5083
 
6539
- var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
6540
- _inherits$1(WebXRPlaneTracking, WebXRTrackableFeature1);
5084
+ var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
5085
+ _inherits$1(WebXRPlaneTracking, WebXRTrackableFeature);
6541
5086
  function WebXRPlaneTracking(detectedMode) {
6542
- var _this = WebXRTrackableFeature1.call(this);
5087
+ var _this;
5088
+ _this = WebXRTrackableFeature.call(this) || this;
6543
5089
  if (detectedMode !== XRPlaneMode.EveryThing) {
6544
5090
  console.warn("WebXR only support XRPlaneMode.EveryThing");
6545
5091
  }
@@ -6568,8 +5114,7 @@
6568
5114
  }
6569
5115
  var _this1 = this, lastDetectedPlanes = _this1._lastDetectedPlanes;
6570
5116
  detectedPlanes.forEach(function(xrPlane) {
6571
- var _lastDetectedPlanes;
6572
- if (!((_lastDetectedPlanes = lastDetectedPlanes) == null ? void 0 : _lastDetectedPlanes.has(xrPlane))) {
5117
+ if (!(lastDetectedPlanes == null ? void 0 : lastDetectedPlanes.has(xrPlane))) {
6573
5118
  var plane = generateTracked();
6574
5119
  plane.xrPlane = xrPlane;
6575
5120
  plane.lastChangedTime = -1;