@galacean/engine-xr-webxr 0.0.0-experimental-1.3-xr.9 → 0.0.0-experimental-1.3-xr.10

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
@@ -244,7 +244,7 @@
244
244
  */ _proto._onSessionExit = function _onSessionExit() {};
245
245
  /**
246
246
  * @internal
247
- */ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(cameraType) {
247
+ */ _proto._getIgnoreClearFlags = function _getIgnoreClearFlags(cameraType) {
248
248
  if (cameraType === engine.CameraType.XRCenterCamera) {
249
249
  if (this._xrManager.sessionManager.state === XRSessionState.Running) {
250
250
  return engine.CameraClearFlags.Color;
@@ -395,7 +395,7 @@
395
395
  this._removed = [];
396
396
  this._trackedDevices = [];
397
397
  this._statusSnapshot = [];
398
- this._listeners = [];
398
+ this._listeners = new engine.SafeLoopArray();
399
399
  var _this = this, trackedDevices = _this._trackedDevices, controllers = _this._controllers, cameras = _this._cameras;
400
400
  for(var i = 0; i < 6; i++){
401
401
  switch(i){
@@ -425,22 +425,22 @@
425
425
  * Add a listener for tracked device changes.
426
426
  * @param listener - The listener to add
427
427
  */ _proto.addTrackedDeviceChangedListener = function addTrackedDeviceChangedListener(listener) {
428
- this._listeners.push(listener);
428
+ this._listeners.push({
429
+ fn: listener
430
+ });
429
431
  };
430
432
  /**
431
433
  * Remove a listener of tracked device changes.
432
434
  * @param listener - The listener to remove
433
435
  */ _proto.removeTrackedDeviceChangedListener = function removeTrackedDeviceChangedListener(listener) {
434
- var _this = this, listeners = _this._listeners;
435
- var index = listeners.indexOf(listener);
436
- if (index >= 0) {
437
- listeners.splice(index, 1);
438
- }
436
+ this._listeners.findAndRemove(function(value) {
437
+ return value.fn === listener ? value.destroyed = true : false;
438
+ });
439
439
  };
440
440
  /**
441
441
  * @internal
442
442
  */ _proto._onUpdate = function _onUpdate() {
443
- var _this = this, added = _this._added, removed = _this._removed, listeners = _this._listeners, statusSnapshot = _this._statusSnapshot;
443
+ var _this = this, added = _this._added, removed = _this._removed, statusSnapshot = _this._statusSnapshot;
444
444
  var _this1 = this, trackedDevices = _this1._trackedDevices, controllers = _this1._controllers;
445
445
  // Reset data
446
446
  added.length = removed.length = 0;
@@ -473,15 +473,19 @@
473
473
  }
474
474
  // Dispatch change event
475
475
  if (added.length > 0 || removed.length > 0) {
476
+ var listeners = this._listeners.getLoopArray();
476
477
  for(var i3 = 0, n3 = listeners.length; i3 < n3; i3++){
477
- listeners[i3](added, removed);
478
+ var listener = listeners[i3];
479
+ !listener.destroyed && listener.fn(added, removed);
478
480
  }
479
481
  }
480
482
  };
481
483
  /**
482
484
  * @internal
483
485
  */ _proto._onDestroy = function _onDestroy() {
484
- this._listeners.length = 0;
486
+ this._listeners.findAndRemove(function(value) {
487
+ return value.destroyed = true;
488
+ });
485
489
  };
486
490
  _proto._handleEvent = function _handleEvent(event) {
487
491
  var input = this._trackedDevices[event.input];
@@ -770,10 +774,7 @@
770
774
  * @internal
771
775
  */ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
772
776
  var XRManagerExtended = function XRManagerExtended() {
773
- var _this;
774
- _this = XRManager1.apply(this, arguments) || this;
775
- _this.features = [];
776
- return _this;
777
+ return XRManager1.apply(this, arguments);
777
778
  };
778
779
  _inherits(XRManagerExtended, XRManager1);
779
780
  var _proto = XRManagerExtended.prototype;
@@ -838,6 +839,7 @@
838
839
  });
839
840
  };
840
841
  _proto._initialize = function _initialize(engine, xrDevice) {
842
+ this._features = [];
841
843
  this._platformDevice = xrDevice;
842
844
  this.sessionManager = new XRSessionManager(this, engine);
843
845
  this.inputManager = new XRInputManager(this, engine);
@@ -875,8 +877,8 @@
875
877
  _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
876
878
  return this.sessionManager._getCancelAnimationFrame();
877
879
  };
878
- _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
879
- return this.cameraManager._getCameraClearFlagsMask(type);
880
+ _proto._getCameraIgnoreClearFlags = function _getCameraIgnoreClearFlags(type) {
881
+ return this.cameraManager._getIgnoreClearFlags(type);
880
882
  };
881
883
  /**
882
884
  * @internal
@@ -919,6 +921,12 @@
919
921
  features.length = 0;
920
922
  };
921
923
  _create_class$1(XRManagerExtended, [
924
+ {
925
+ key: "features",
926
+ get: function get() {
927
+ return this._features;
928
+ }
929
+ },
922
930
  {
923
931
  key: "origin",
924
932
  get: function get() {