@galacean/engine-xr 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
@@ -185,7 +185,7 @@
185
185
  */ _proto._onSessionExit = function _onSessionExit() {};
186
186
  /**
187
187
  * @internal
188
- */ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(cameraType) {
188
+ */ _proto._getIgnoreClearFlags = function _getIgnoreClearFlags(cameraType) {
189
189
  if (cameraType === engine.CameraType.XRCenterCamera) {
190
190
  if (this._xrManager.sessionManager.state === exports.XRSessionState.Running) {
191
191
  return engine.CameraClearFlags.Color;
@@ -345,7 +345,7 @@
345
345
  this._removed = [];
346
346
  this._trackedDevices = [];
347
347
  this._statusSnapshot = [];
348
- this._listeners = [];
348
+ this._listeners = new engine.SafeLoopArray();
349
349
  var _this = this, trackedDevices = _this._trackedDevices, controllers = _this._controllers, cameras = _this._cameras;
350
350
  for(var i = 0; i < 6; i++){
351
351
  switch(i){
@@ -375,22 +375,22 @@
375
375
  * Add a listener for tracked device changes.
376
376
  * @param listener - The listener to add
377
377
  */ _proto.addTrackedDeviceChangedListener = function addTrackedDeviceChangedListener(listener) {
378
- this._listeners.push(listener);
378
+ this._listeners.push({
379
+ fn: listener
380
+ });
379
381
  };
380
382
  /**
381
383
  * Remove a listener of tracked device changes.
382
384
  * @param listener - The listener to remove
383
385
  */ _proto.removeTrackedDeviceChangedListener = function removeTrackedDeviceChangedListener(listener) {
384
- var _this = this, listeners = _this._listeners;
385
- var index = listeners.indexOf(listener);
386
- if (index >= 0) {
387
- listeners.splice(index, 1);
388
- }
386
+ this._listeners.findAndRemove(function(value) {
387
+ return value.fn === listener ? value.destroyed = true : false;
388
+ });
389
389
  };
390
390
  /**
391
391
  * @internal
392
392
  */ _proto._onUpdate = function _onUpdate() {
393
- var _this = this, added = _this._added, removed = _this._removed, listeners = _this._listeners, statusSnapshot = _this._statusSnapshot;
393
+ var _this = this, added = _this._added, removed = _this._removed, statusSnapshot = _this._statusSnapshot;
394
394
  var _this1 = this, trackedDevices = _this1._trackedDevices, controllers = _this1._controllers;
395
395
  // Reset data
396
396
  added.length = removed.length = 0;
@@ -423,15 +423,19 @@
423
423
  }
424
424
  // Dispatch change event
425
425
  if (added.length > 0 || removed.length > 0) {
426
+ var listeners = this._listeners.getLoopArray();
426
427
  for(var i3 = 0, n3 = listeners.length; i3 < n3; i3++){
427
- listeners[i3](added, removed);
428
+ var listener = listeners[i3];
429
+ !listener.destroyed && listener.fn(added, removed);
428
430
  }
429
431
  }
430
432
  };
431
433
  /**
432
434
  * @internal
433
435
  */ _proto._onDestroy = function _onDestroy() {
434
- this._listeners.length = 0;
436
+ this._listeners.findAndRemove(function(value) {
437
+ return value.destroyed = true;
438
+ });
435
439
  };
436
440
  _proto._handleEvent = function _handleEvent(event) {
437
441
  var input = this._trackedDevices[event.input];
@@ -724,10 +728,7 @@
724
728
  */ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
725
729
  _inherits(XRManagerExtended, XRManager1);
726
730
  function XRManagerExtended() {
727
- var _this;
728
- _this = XRManager1.apply(this, arguments) || this;
729
- _this.features = [];
730
- return _this;
731
+ return XRManager1.apply(this, arguments);
731
732
  }
732
733
  var _proto = XRManagerExtended.prototype;
733
734
  _proto.isSupportedFeature = function isSupportedFeature(feature) {
@@ -791,6 +792,7 @@
791
792
  });
792
793
  };
793
794
  _proto._initialize = function _initialize(engine, xrDevice) {
795
+ this._features = [];
794
796
  this._platformDevice = xrDevice;
795
797
  this.sessionManager = new XRSessionManager(this, engine);
796
798
  this.inputManager = new XRInputManager(this, engine);
@@ -828,8 +830,8 @@
828
830
  _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
829
831
  return this.sessionManager._getCancelAnimationFrame();
830
832
  };
831
- _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
832
- return this.cameraManager._getCameraClearFlagsMask(type);
833
+ _proto._getCameraIgnoreClearFlags = function _getCameraIgnoreClearFlags(type) {
834
+ return this.cameraManager._getIgnoreClearFlags(type);
833
835
  };
834
836
  /**
835
837
  * @internal
@@ -872,6 +874,12 @@
872
874
  features.length = 0;
873
875
  };
874
876
  _create_class(XRManagerExtended, [
877
+ {
878
+ key: "features",
879
+ get: function get() {
880
+ return this._features;
881
+ }
882
+ },
875
883
  {
876
884
  key: "origin",
877
885
  get: function get() {