@galacean/engine-core 2.0.0-alpha.38 → 2.0.0-alpha.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -18615,7 +18615,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
18615
18615
  this._graphicResourcePool = Object.create(null);
18616
18616
  this._contentRestorerPool = Object.create(null);
18617
18617
  this._subAssetPromiseCallbacks = {};
18618
- this.//-----------------Editor temp solution-----------------
18618
+ this.// Virtual resource mapping
18619
18619
  /** @internal */ _objectPool = Object.create(null);
18620
18620
  this./** @internal */ _virtualPathResourceMap = Object.create(null);
18621
18621
  }
@@ -18729,21 +18729,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
18729
18729
  };
18730
18730
  /**
18731
18731
  * @internal
18732
- */ _proto._onSubAssetFail = function _onSubAssetFail(assetBaseURL, assetSubPath, value) {
18733
- var _this__subAssetPromiseCallbacks_assetBaseURL;
18734
- var subPromiseCallback = (_this__subAssetPromiseCallbacks_assetBaseURL = this._subAssetPromiseCallbacks[assetBaseURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetBaseURL[assetSubPath];
18735
- if (subPromiseCallback) {
18736
- subPromiseCallback.reject(value);
18737
- } else {
18738
- var // Pending
18739
- _this__subAssetPromiseCallbacks, _assetBaseURL;
18740
- ((_this__subAssetPromiseCallbacks = this._subAssetPromiseCallbacks)[_assetBaseURL = assetBaseURL] || (_this__subAssetPromiseCallbacks[_assetBaseURL] = {}))[assetSubPath] = {
18741
- rejectedValue: value
18742
- };
18743
- }
18744
- };
18745
- /**
18746
- * @internal
18747
18732
  */ _proto._addAsset = function _addAsset(path, asset) {
18748
18733
  this._assetPool[asset.instanceId] = path;
18749
18734
  this._assetUrlPool[path] = asset;
@@ -18894,10 +18879,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
18894
18879
  if (queryPath) {
18895
18880
  // Check whether load main asset
18896
18881
  var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
18897
- mainPromise.catch(function(e) {
18898
- _this._onSubAssetFail(remoteAssetBaseURL, queryPath, e);
18899
- });
18900
- return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath);
18882
+ return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath, mainPromise);
18901
18883
  }
18902
18884
  return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
18903
18885
  };
@@ -18922,30 +18904,33 @@ var MultiExecutor = /*#__PURE__*/ function() {
18922
18904
  });
18923
18905
  return promise;
18924
18906
  };
18925
- _proto._createSubAssetPromiseCallback = function _createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, assetSubPath) {
18907
+ _proto._createSubAssetPromiseCallback = function _createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, assetSubPath, mainPromise) {
18926
18908
  var _this = this;
18927
18909
  var _this__subAssetPromiseCallbacks_remoteAssetBaseURL;
18928
18910
  var loadingPromises = this._loadingPromises;
18929
18911
  var subPromiseCallback = (_this__subAssetPromiseCallbacks_remoteAssetBaseURL = this._subAssetPromiseCallbacks[remoteAssetBaseURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_remoteAssetBaseURL[assetSubPath];
18930
18912
  var resolvedValue = subPromiseCallback == null ? void 0 : subPromiseCallback.resolvedValue;
18931
- var rejectedValue = subPromiseCallback == null ? void 0 : subPromiseCallback.rejectedValue;
18932
- // Already resolved or rejected
18933
- if (resolvedValue || rejectedValue) {
18934
- return new AssetPromise(function(resolve, reject) {
18935
- if (resolvedValue) {
18936
- resolve(resolvedValue);
18937
- } else if (rejectedValue) {
18938
- reject(rejectedValue);
18939
- }
18940
- });
18913
+ // Already resolved
18914
+ if (resolvedValue) {
18915
+ return AssetPromise.resolve(resolvedValue);
18941
18916
  }
18942
18917
  // Pending
18943
- var promise = new AssetPromise(function(resolve, reject) {
18918
+ var promise = new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
18944
18919
  var _this__subAssetPromiseCallbacks, _remoteAssetBaseURL;
18945
18920
  ((_this__subAssetPromiseCallbacks = _this._subAssetPromiseCallbacks)[_remoteAssetBaseURL = remoteAssetBaseURL] || (_this__subAssetPromiseCallbacks[_remoteAssetBaseURL] = {}))[assetSubPath] = {
18946
18921
  resolve: resolve,
18947
18922
  reject: reject
18948
18923
  };
18924
+ // A loader may finish the main asset before its eager sub-asset notification reaches this callback.
18925
+ // Always resolve from the completed main asset as the authoritative fallback so callback cleanup cannot
18926
+ // strand a sub-asset request.
18927
+ mainPromise.onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(resource) {
18928
+ try {
18929
+ resolve(_this._getResolveResource(resource, _this._parseQueryPath(assetSubPath)));
18930
+ } catch (error) {
18931
+ reject(error);
18932
+ }
18933
+ }, reject);
18949
18934
  });
18950
18935
  loadingPromises[remoteAssetURL] = promise;
18951
18936
  promise.then(function() {
@@ -18969,7 +18954,10 @@ var MultiExecutor = /*#__PURE__*/ function() {
18969
18954
  if (paths) {
18970
18955
  for(var i = 0, n = paths.length; i < n; i++){
18971
18956
  var path = paths[i];
18972
- subResource = subResource[path];
18957
+ subResource = subResource == null ? void 0 : subResource[path];
18958
+ if (subResource === undefined) {
18959
+ throw new Error("Sub-asset path does not exist: " + paths.join("."));
18960
+ }
18973
18961
  }
18974
18962
  }
18975
18963
  return subResource;
@@ -19015,6 +19003,16 @@ var MultiExecutor = /*#__PURE__*/ function() {
19015
19003
  delete this._subAssetPromiseCallbacks[assetBaseURL];
19016
19004
  };
19017
19005
  /**
19006
+ * Register virtual asset paths and their load descriptors.
19007
+ * @remarks References inside runtime scenes and Prefabs can keep stable virtual paths while the backing URLs
19008
+ * are generated dynamically, such as object URLs created from a resource package.
19009
+ */ _proto.registerVirtualResources = function registerVirtualResources(resources) {
19010
+ var _this = this;
19011
+ resources.forEach(function(resource) {
19012
+ _this._virtualPathResourceMap[resource.virtualPath] = resource;
19013
+ });
19014
+ };
19015
+ /**
19018
19016
  * @internal
19019
19017
  * @beta Just for internal editor, not recommended for developers.
19020
19018
  */ _proto.getResourceByRef = function getResourceByRef(ref) {
@@ -19043,18 +19041,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
19043
19041
  };
19044
19042
  /**
19045
19043
  * @internal
19046
- * @beta Just for internal editor, not recommended for developers.
19047
- */ _proto.initVirtualResources = function initVirtualResources(config) {
19048
- var _this = this;
19049
- config.forEach(function(element) {
19050
- _this._virtualPathResourceMap[element.virtualPath] = element;
19051
- if (element.dependentAssetMap) {
19052
- _this._virtualPathResourceMap[element.virtualPath].dependentAssetMap = element.dependentAssetMap;
19053
- }
19054
- });
19055
- };
19056
- /**
19057
- * @internal
19058
19044
  */ ResourceManager._addLoader = function _addLoader(type, loader, extNames) {
19059
19045
  this._loaders[type] = loader;
19060
19046
  for(var i = 0, len = extNames.length; i < len; i++){
@@ -27177,7 +27163,7 @@ var OverlayCamera = function OverlayCamera() {
27177
27163
  _inherits(Engine, EventDispatcher);
27178
27164
  function Engine(canvas, hardwareRenderer, configuration) {
27179
27165
  var _this;
27180
- _this = EventDispatcher.call(this) || this, /** @internal */ _this._renderingStatistics = new RenderingStatistics(), /** @internal */ _this._isDeviceLost = false, /** @internal */ _this._frameInProcess = false, /** @internal */ _this._pendingDestroyObjects = [], /** @internal */ _this._processingPendingDestroys = false, /** @internal */ _this._physicsInitialized = false, /* @internal */ _this._lastRenderState = new RenderState(), /* @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._textRenderElementPool = new ClearableObjectPool(RenderElement), /* @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /* @internal */ _this._renderContext = new RenderContext(), /* @internal */ _this._renderCount = 0, /* @internal */ _this._shaderProgramMaps = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._waitingDestroy = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._onCanvasResize = function() {
27166
+ _this = EventDispatcher.call(this) || this, /** @internal */ _this._renderingStatistics = new RenderingStatistics(), /** @internal */ _this._isDeviceLost = false, /** @internal */ _this._frameInProcess = false, /** @internal */ _this._pendingDestroyObjects = [], /** @internal */ _this._processingPendingDestroys = false, /** @internal */ _this._physicsInitialized = false, /** @internal */ _this._lastRenderState = new RenderState(), /** @internal */ _this._renderElementPool = new ClearableObjectPool(RenderElement), /** @internal */ _this._textRenderElementPool = new ClearableObjectPool(RenderElement), /** @internal */ _this._charRenderInfoPool = new ReturnableObjectPool(CharRenderInfo, 50), /** @internal */ _this._renderContext = new RenderContext(), /** @internal */ _this._renderCount = 0, /** @internal */ _this._shaderProgramMaps = [], /** @internal */ _this._fontMap = {}, /** @internal */ _this._macroCollection = new ShaderMacroCollection(), /** @internal */ _this._postProcessPassNeedRefresh = false, _this._settings = {}, _this._resourceManager = new ResourceManager(_this), _this._sceneManager = new SceneManager(_this), _this._vSyncCount = 1, _this._targetFrameRate = 60, _this._time = new Time(), _this._isPaused = true, _this._vSyncCounter = 1, _this._targetFrameInterval = 1000 / 60, _this._destroyed = false, _this._waitingDestroy = false, _this._waitingGC = false, _this._postProcessPasses = new Array(), _this._activePostProcessPasses = new Array(), _this._onCanvasResize = function() {
27181
27167
  return _this._renderTargetPool.gc();
27182
27168
  }, _this._animate = function() {
27183
27169
  if (_this._vSyncCount) {
@@ -27258,6 +27244,7 @@ var OverlayCamera = function OverlayCamera() {
27258
27244
  * Update the engine loop manually. If you call engine.run(), you generally don't need to call this function.
27259
27245
  */ _proto.update = function update() {
27260
27246
  var _this_xrManager;
27247
+ this._canvas._pumpPendingResolution();
27261
27248
  var time = this._time;
27262
27249
  time._update();
27263
27250
  var deltaTime = time.deltaTime;
@@ -27405,6 +27392,7 @@ var OverlayCamera = function OverlayCamera() {
27405
27392
  this._destroyed = true;
27406
27393
  this._waitingDestroy = false;
27407
27394
  this._canvas._sizeUpdateFlagManager.removeListener(this._onCanvasResize);
27395
+ this._canvas._destroy();
27408
27396
  this._sceneManager._destroyAllScene();
27409
27397
  this._resourceManager._destroy();
27410
27398
  this.inputManager._destroy();
@@ -27701,40 +27689,57 @@ var OverlayCamera = function OverlayCamera() {
27701
27689
  /** @internal */ Engine._physicalObjectsMap = {};
27702
27690
 
27703
27691
  /**
27704
- * Canvas.
27692
+ * The canvas the engine renders to; owns the render-buffer resolution.
27705
27693
  */ var Canvas = /*#__PURE__*/ function() {
27706
27694
  function Canvas() {
27707
- /* @internal */ this._sizeUpdateFlagManager = new UpdateFlagManager();
27695
+ /**
27696
+ * @internal
27697
+ */ this._sizeUpdateFlagManager = new UpdateFlagManager();
27698
+ this._width = 0;
27699
+ this._height = 0;
27708
27700
  }
27701
+ var _proto = Canvas.prototype;
27702
+ /**
27703
+ * Lock the render buffer to an explicit resolution and stop following the display size.
27704
+ * @param width - Render buffer width in pixels
27705
+ * @param height - Render buffer height in pixels
27706
+ *
27707
+ * @throws
27708
+ * Throw an error if width or height is not a positive finite number.
27709
+ */ _proto.setResolution = function setResolution(width, height) {
27710
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
27711
+ throw new Error("Canvas.setResolution: invalid size " + width + "x" + height);
27712
+ }
27713
+ this._exitAutoResolution();
27714
+ this._setResolution(Math.round(width), Math.round(height));
27715
+ };
27716
+ _proto._setResolution = function _setResolution(width, height) {
27717
+ if (this._width !== width || this._height !== height) {
27718
+ this._width = width;
27719
+ this._height = height;
27720
+ this._onResolutionChanged(width, height);
27721
+ this._sizeUpdateFlagManager.dispatch();
27722
+ }
27723
+ };
27724
+ /**
27725
+ * @internal
27726
+ */ _proto._pumpPendingResolution = function _pumpPendingResolution() {};
27727
+ _proto._exitAutoResolution = function _exitAutoResolution() {};
27709
27728
  _create_class(Canvas, [
27710
27729
  {
27711
27730
  key: "width",
27712
27731
  get: /**
27713
- * The width of the canvas.
27732
+ * The width component of the canvas resolution, in pixels.
27714
27733
  */ function get() {
27715
27734
  return this._width;
27716
- },
27717
- set: function set(value) {
27718
- if (this._width !== value) {
27719
- this._width = value;
27720
- this._onWidthChanged(value);
27721
- this._sizeUpdateFlagManager.dispatch();
27722
- }
27723
27735
  }
27724
27736
  },
27725
27737
  {
27726
27738
  key: "height",
27727
27739
  get: /**
27728
- *The height of the canvas.
27740
+ * The height component of the canvas resolution, in pixels.
27729
27741
  */ function get() {
27730
27742
  return this._height;
27731
- },
27732
- set: function set(value) {
27733
- if (this._height !== value) {
27734
- this._height = value;
27735
- this._onHeightChange(value);
27736
- this._sizeUpdateFlagManager.dispatch();
27737
- }
27738
27743
  }
27739
27744
  }
27740
27745
  ]);
@@ -27745,11 +27750,11 @@ var OverlayCamera = function OverlayCamera() {
27745
27750
  * The manager of the components.
27746
27751
  */ var ComponentsManager = /*#__PURE__*/ function() {
27747
27752
  function ComponentsManager() {
27748
- /* @internal */ this._cameraNeedSorting = false;
27753
+ /** @internal */ this._cameraNeedSorting = false;
27749
27754
  /** @internal */ this._activeCameras = new DisorderedArray();
27750
27755
  /** @internal */ this._renderers = new DisorderedArray();
27751
27756
  /** @internal */ this._overlayCanvases = new DisorderedArray();
27752
- /* @internal */ this._overlayCanvasesSortingDirty = false;
27757
+ /** @internal */ this._overlayCanvasesSortingDirty = false;
27753
27758
  /** @internal */ this._canvases = new DisorderedArray();
27754
27759
  // Script
27755
27760
  this._onStartScripts = new DisorderedArray();
@@ -28968,7 +28973,7 @@ AmbientOcclusion._enableMacro = ShaderMacro.getByName("SCENE_ENABLE_AMBIENT_OCCL
28968
28973
  * @remarks
28969
28974
  * Darkens areas where objects are close together to simulate natural light blocking,
28970
28975
  * such as corners, crevices, and contact points between surfaces.
28971
- */ _this.ambientOcclusion = new AmbientOcclusion(_this), /* @internal */ _this._lightManager = new LightManager(), /* @internal */ _this._componentsManager = new ComponentsManager(), /** @internal */ _this._maskManager = new MaskManager(), /** @internal */ _this._isActiveInEngine = false, /** @internal */ _this._rootEntities = [], _this._background = new Background(_this._engine), _this._shaderData = new ShaderData(ShaderDataGroup.Scene), _this._shadowCascades = ShadowCascadesMode.NoCascades, _this._fogMode = FogMode.None, _this._fogColor = new Color(0.21404114048223255, 0.21404114048223255, 0.21404114048223255, 1.0), _this._fogStart = 0, _this._fogEnd = 300, _this._fogDensity = 0.01, _this._fogParams = new Vector4(), _this._isActive = true, _this._enableTransparentShadow = false;
28976
+ */ _this.ambientOcclusion = new AmbientOcclusion(_this), /** @internal */ _this._lightManager = new LightManager(), /** @internal */ _this._componentsManager = new ComponentsManager(), /** @internal */ _this._maskManager = new MaskManager(), /** @internal */ _this._isActiveInEngine = false, /** @internal */ _this._rootEntities = [], _this._background = new Background(_this._engine), _this._shaderData = new ShaderData(ShaderDataGroup.Scene), _this._shadowCascades = ShadowCascadesMode.NoCascades, _this._fogMode = FogMode.None, _this._fogColor = new Color(0.21404114048223255, 0.21404114048223255, 0.21404114048223255, 1.0), _this._fogStart = 0, _this._fogEnd = 300, _this._fogDensity = 0.01, _this._fogParams = new Vector4(), _this._isActive = true, _this._enableTransparentShadow = false;
28972
28977
  _this.name = name || "";
28973
28978
  var shaderData = _this.shaderData;
28974
28979
  shaderData._addReferCount(1);