@galacean/engine 0.0.0-experimental-2.0-game.1 → 0.0.0-experimental-2.0-game.3

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
@@ -9513,7 +9513,7 @@
9513
9513
  sprite.name === name && outSprites.push(sprite);
9514
9514
  }
9515
9515
  } else {
9516
- console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");
9516
+ console.warn("There is no sprite named " + name + " in the atlas.");
9517
9517
  }
9518
9518
  return outSprites;
9519
9519
  };
@@ -28706,13 +28706,6 @@
28706
28706
  if (!splits.length) {
28707
28707
  return this;
28708
28708
  }
28709
- // Some imported animation clips are normalized to include the single scene root
28710
- // name (for example "mixamorig:Hips/..."), while the Animator may already sit on
28711
- // that root entity. Accept a self-name prefix so wrapped model roots and
28712
- // standalone single-root clips resolve through the same path convention.
28713
- if (splits[0] === this.name) {
28714
- return splits.length === 1 ? this : Entity._findChildByName(this, 0, splits, 1);
28715
- }
28716
28709
  return Entity._findChildByName(this, 0, splits, 0);
28717
28710
  };
28718
28711
  /**
@@ -28733,11 +28726,17 @@
28733
28726
  for(var i = children.length - 1; i >= 0; i--){
28734
28727
  var child = children[i];
28735
28728
  child._parent = null;
28729
+ child._siblingIndex = -1;
28730
+ // Dispatch `Child` to the old parent before `_processInActive` (which unregisters
28731
+ // UI listeners via `cleanRootCanvas`), so subscribers such as UICanvas can react
28732
+ // to the hierarchy change while still attached.
28733
+ this._dispatchModify(EntityModifyFlags.Child, this);
28736
28734
  var activeChangeFlag = ActiveChangeFlag.None;
28737
28735
  child._isActiveInHierarchy && (activeChangeFlag |= ActiveChangeFlag.Hierarchy);
28738
28736
  child._isActiveInScene && (activeChangeFlag |= ActiveChangeFlag.Scene);
28739
28737
  activeChangeFlag && child._processInActive(activeChangeFlag);
28740
28738
  Entity._traverseSetOwnerScene(child, null); // Must after child._processInActive().
28739
+ child._setParentChange();
28741
28740
  }
28742
28741
  children.length = 0;
28743
28742
  };
@@ -29826,7 +29825,20 @@
29826
29825
  */ _proto.loadScene = function loadScene(url, destroyOldScene) {
29827
29826
  var _this = this;
29828
29827
  if (destroyOldScene === void 0) destroyOldScene = true;
29829
- var scenePromise = this.engine.resourceManager.load({
29828
+ var resourceManager = this.engine.resourceManager;
29829
+ // Evict the Scene asset cache for managed scenes about to be destroyed, so a fresh Scene
29830
+ // instance is created by the loader instead of returning the same instance we're about to
29831
+ // destroy (self-destroy would leave the active scene in a zombie state).
29832
+ if (destroyOldScene) {
29833
+ var _resourceManager__virtualPathResourceMap_url;
29834
+ var _resourceManager__virtualPathResourceMap_url_path;
29835
+ var realPath = (_resourceManager__virtualPathResourceMap_url_path = (_resourceManager__virtualPathResourceMap_url = resourceManager._virtualPathResourceMap[url]) == null ? void 0 : _resourceManager__virtualPathResourceMap_url.path) != null ? _resourceManager__virtualPathResourceMap_url_path : url;
29836
+ var cached = resourceManager.getFromCache(realPath);
29837
+ if (cached && this._scenes.indexOf(cached) !== -1) {
29838
+ resourceManager._deleteAsset(cached);
29839
+ }
29840
+ }
29841
+ var scenePromise = resourceManager.load({
29830
29842
  url: url,
29831
29843
  type: AssetType.Scene
29832
29844
  });
@@ -44382,27 +44394,37 @@
44382
44394
  * Suspend the audio context.
44383
44395
  * @returns A promise that resolves when the audio context is suspended
44384
44396
  */ AudioManager.suspend = function suspend() {
44385
- return AudioManager._context.suspend();
44397
+ var _AudioManager__context;
44398
+ var _AudioManager__context_suspend;
44399
+ return (_AudioManager__context_suspend = (_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.suspend()) != null ? _AudioManager__context_suspend : Promise.resolve();
44386
44400
  };
44387
44401
  /**
44388
44402
  * Resume the audio context.
44389
44403
  * @remarks On iOS Safari, calling this within a user gesture (e.g., click/touch event handler) can pre-unlock audio and reduce playback delay.
44390
44404
  * @returns A promise that resolves when the audio context is resumed
44391
44405
  */ AudioManager.resume = function resume() {
44392
- var _AudioManager;
44393
- var __resumePromise;
44394
- return (__resumePromise = (_AudioManager = AudioManager)._resumePromise) != null ? __resumePromise : _AudioManager._resumePromise = AudioManager._context.resume().then(function() {
44406
+ var context = AudioManager._context;
44407
+ if (!context || context.state === "running") {
44408
+ return Promise.resolve();
44409
+ }
44410
+ return context.resume().then(function() {
44395
44411
  AudioManager._needsUserGestureResume = false;
44396
- }).finally(function() {
44397
- AudioManager._resumePromise = null;
44412
+ AudioManager._resumePendingSources();
44398
44413
  });
44399
44414
  };
44415
+ /** @internal */ AudioManager._registerPendingSource = function _registerPendingSource(source) {
44416
+ AudioManager._pendingSources.add(source);
44417
+ };
44418
+ /** @internal */ AudioManager._unregisterPendingSource = function _unregisterPendingSource(source) {
44419
+ AudioManager._pendingSources.delete(source);
44420
+ };
44400
44421
  /**
44401
44422
  * @internal
44402
44423
  */ AudioManager.getContext = function getContext() {
44403
44424
  var context = AudioManager._context;
44404
44425
  if (!context) {
44405
44426
  AudioManager._context = context = new window.AudioContext();
44427
+ context.onstatechange = AudioManager._onContextStateChange;
44406
44428
  document.addEventListener("visibilitychange", AudioManager._onVisibilityChange);
44407
44429
  // iOS Safari requires user gesture to resume AudioContext
44408
44430
  document.addEventListener("touchstart", AudioManager._resumeAfterInterruption, {
@@ -44431,28 +44453,58 @@
44431
44453
  */ AudioManager.isAudioContextRunning = function isAudioContextRunning() {
44432
44454
  return AudioManager.getContext().state === "running";
44433
44455
  };
44456
+ AudioManager._onContextStateChange = function _onContextStateChange() {
44457
+ var _AudioManager__context;
44458
+ if (((_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.state) === "running") {
44459
+ AudioManager._needsUserGestureResume = false;
44460
+ AudioManager._resumePendingSources();
44461
+ }
44462
+ };
44463
+ AudioManager._resumePendingSources = function _resumePendingSources() {
44464
+ if (!AudioManager._pendingSources.size || !AudioManager.isAudioContextRunning()) {
44465
+ return;
44466
+ }
44467
+ var pendingSources = Array.from(AudioManager._pendingSources);
44468
+ AudioManager._pendingSources.clear();
44469
+ for(var i = 0, n = pendingSources.length; i < n; i++){
44470
+ pendingSources[i]._resumePendingPlayback();
44471
+ }
44472
+ };
44434
44473
  AudioManager._onVisibilityChange = function _onVisibilityChange() {
44435
- if (!document.hidden && AudioManager._playingCount > 0 && !AudioManager.isAudioContextRunning()) {
44436
- // iOS WKWebView WebKit bug(Triggered in LingGuang App): AudioContext may be in a "zombie" state where
44437
- // state reports "suspended" but resume() alone won't restart audio rendering.
44438
- // Calling suspend() first forces a clean internal state reset before user gesture triggers resume.
44439
- // Related: https://bugs.webkit.org/show_bug.cgi?id=263627
44440
- AudioManager.suspend();
44441
- AudioManager._needsUserGestureResume = true;
44474
+ var context = AudioManager._context;
44475
+ if (document.hidden || !context || AudioManager._playingCount === 0 && AudioManager._pendingSources.size === 0 || context.state === "running") {
44476
+ return;
44442
44477
  }
44478
+ AudioManager.resume().then(function() {
44479
+ var _AudioManager__context;
44480
+ if (((_AudioManager__context = AudioManager._context) == null ? void 0 : _AudioManager__context.state) !== "running") {
44481
+ return AudioManager._prepareGestureResume();
44482
+ }
44483
+ }).catch(function() {
44484
+ return AudioManager._prepareGestureResume();
44485
+ });
44443
44486
  };
44444
44487
  AudioManager._resumeAfterInterruption = function _resumeAfterInterruption() {
44445
- if (AudioManager._needsUserGestureResume) {
44488
+ if (AudioManager._needsUserGestureResume || AudioManager._pendingSources.size > 0) {
44446
44489
  AudioManager.resume().catch(function(e) {
44447
44490
  console.warn("Failed to resume AudioContext:", e);
44448
44491
  });
44449
44492
  }
44450
44493
  };
44494
+ AudioManager._prepareGestureResume = function _prepareGestureResume() {
44495
+ // iOS WKWebView WebKit bug(Triggered in LingGuang App): AudioContext may be in a "zombie" state where
44496
+ // state reports "suspended" but resume() alone won't restart audio rendering.
44497
+ // Calling suspend() first forces a clean internal state reset before user gesture triggers resume.
44498
+ // Related: https://bugs.webkit.org/show_bug.cgi?id=263627
44499
+ return AudioManager.suspend().catch(function() {}).then(function() {
44500
+ AudioManager._needsUserGestureResume = true;
44501
+ });
44502
+ };
44451
44503
  return AudioManager;
44452
44504
  }();
44453
44505
  /** @internal */ AudioManager._playingCount = 0;
44454
- AudioManager._resumePromise = null;
44455
44506
  AudioManager._needsUserGestureResume = false;
44507
+ AudioManager._pendingSources = new Set();
44456
44508
  /**
44457
44509
  * Audio Source Component.
44458
44510
  */ var AudioSource = /*#__PURE__*/ function(Component) {
@@ -44469,7 +44521,6 @@
44469
44521
  /**
44470
44522
  * Play the clip.
44471
44523
  */ _proto.play = function play() {
44472
- var _this = this;
44473
44524
  var _this__clip;
44474
44525
  if (!((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource()) || this._isPlaying || this._pendingPlay) {
44475
44526
  return;
@@ -44477,22 +44528,9 @@
44477
44528
  if (AudioManager.isAudioContextRunning()) {
44478
44529
  this._startPlayback();
44479
44530
  } else {
44480
- // iOS Safari requires resume() to be called within the same user gesture callback that triggers playback.
44481
- // Document-level events won't work - must call resume() directly here in play().
44482
44531
  this._pendingPlay = true;
44483
- AudioManager.resume().then(function() {
44484
- // Check if cancelled by stop()/pause()
44485
- if (!_this._pendingPlay) {
44486
- return;
44487
- }
44488
- _this._pendingPlay = false;
44489
- // Check if still valid to play after async resume
44490
- if (_this._destroyed || !_this.enabled || !_this._clip) {
44491
- return;
44492
- }
44493
- _this._startPlayback();
44494
- }, function(e) {
44495
- _this._pendingPlay = false;
44532
+ AudioManager._registerPendingSource(this);
44533
+ AudioManager.resume().catch(function(e) {
44496
44534
  console.warn("Failed to resume AudioContext:", e);
44497
44535
  });
44498
44536
  }
@@ -44500,7 +44538,7 @@
44500
44538
  /**
44501
44539
  * Stops playing the clip.
44502
44540
  */ _proto.stop = function stop() {
44503
- this._pendingPlay = false;
44541
+ this._cancelPendingPlayback();
44504
44542
  if (this._isPlaying) {
44505
44543
  this._clearSourceNode();
44506
44544
  this._isPlaying = false;
@@ -44512,7 +44550,7 @@
44512
44550
  /**
44513
44551
  * Pauses playing the clip.
44514
44552
  */ _proto.pause = function pause() {
44515
- this._pendingPlay = false;
44553
+ this._cancelPendingPlayback();
44516
44554
  if (this._isPlaying) {
44517
44555
  this._clearSourceNode();
44518
44556
  this._pausedTime = AudioManager.getContext().currentTime;
@@ -44547,6 +44585,17 @@
44547
44585
  _proto._onPlayEnd = function _onPlayEnd() {
44548
44586
  this.stop();
44549
44587
  };
44588
+ /** @internal */ _proto._resumePendingPlayback = function _resumePendingPlayback() {
44589
+ var _this__clip;
44590
+ if (!this._pendingPlay) {
44591
+ return;
44592
+ }
44593
+ this._pendingPlay = false;
44594
+ if (this._destroyed || !this.enabled || !((_this__clip = this._clip) == null ? void 0 : _this__clip._getAudioSource())) {
44595
+ return;
44596
+ }
44597
+ this._startPlayback();
44598
+ };
44550
44599
  _proto._startPlayback = function _startPlayback() {
44551
44600
  var startTime = this._pausedTime > 0 ? this._pausedTime - this._playTime : 0;
44552
44601
  this._initSourceNode(startTime);
@@ -44572,6 +44621,13 @@
44572
44621
  this._sourceNode.onended = null;
44573
44622
  this._sourceNode = null;
44574
44623
  };
44624
+ _proto._cancelPendingPlayback = function _cancelPendingPlayback() {
44625
+ if (!this._pendingPlay) {
44626
+ return;
44627
+ }
44628
+ this._pendingPlay = false;
44629
+ AudioManager._unregisterPendingSource(this);
44630
+ };
44575
44631
  _create_class$2(AudioSource, [
44576
44632
  {
44577
44633
  key: "clip",
@@ -54896,7 +54952,7 @@
54896
54952
  ], EXT_texture_webp);
54897
54953
 
54898
54954
  //@ts-ignore
54899
- var version = "0.0.0-experimental-2.0-game.1";
54955
+ var version = "0.0.0-experimental-2.0-game.3";
54900
54956
  console.log("Galacean Engine Version: " + version);
54901
54957
  for(var key in CoreObjects){
54902
54958
  Loader.registerClass(key, CoreObjects[key]);