@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/main.js +72 -67
- package/dist/main.js.map +1 -1
- package/dist/module.js +72 -67
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Canvas.d.ts +23 -7
- package/types/asset/ResourceManager.d.ts +16 -0
- package/types/index.d.ts +1 -1
package/dist/main.js
CHANGED
|
@@ -18619,7 +18619,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18619
18619
|
this._graphicResourcePool = Object.create(null);
|
|
18620
18620
|
this._contentRestorerPool = Object.create(null);
|
|
18621
18621
|
this._subAssetPromiseCallbacks = {};
|
|
18622
|
-
this
|
|
18622
|
+
this.// Virtual resource mapping
|
|
18623
18623
|
/** @internal */ _objectPool = Object.create(null);
|
|
18624
18624
|
this./** @internal */ _virtualPathResourceMap = Object.create(null);
|
|
18625
18625
|
}
|
|
@@ -18733,21 +18733,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18733
18733
|
};
|
|
18734
18734
|
/**
|
|
18735
18735
|
* @internal
|
|
18736
|
-
*/ _proto._onSubAssetFail = function _onSubAssetFail(assetBaseURL, assetSubPath, value) {
|
|
18737
|
-
var _this__subAssetPromiseCallbacks_assetBaseURL;
|
|
18738
|
-
var subPromiseCallback = (_this__subAssetPromiseCallbacks_assetBaseURL = this._subAssetPromiseCallbacks[assetBaseURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_assetBaseURL[assetSubPath];
|
|
18739
|
-
if (subPromiseCallback) {
|
|
18740
|
-
subPromiseCallback.reject(value);
|
|
18741
|
-
} else {
|
|
18742
|
-
var // Pending
|
|
18743
|
-
_this__subAssetPromiseCallbacks, _assetBaseURL;
|
|
18744
|
-
((_this__subAssetPromiseCallbacks = this._subAssetPromiseCallbacks)[_assetBaseURL = assetBaseURL] || (_this__subAssetPromiseCallbacks[_assetBaseURL] = {}))[assetSubPath] = {
|
|
18745
|
-
rejectedValue: value
|
|
18746
|
-
};
|
|
18747
|
-
}
|
|
18748
|
-
};
|
|
18749
|
-
/**
|
|
18750
|
-
* @internal
|
|
18751
18736
|
*/ _proto._addAsset = function _addAsset(path, asset) {
|
|
18752
18737
|
this._assetPool[asset.instanceId] = path;
|
|
18753
18738
|
this._assetUrlPool[path] = asset;
|
|
@@ -18898,10 +18883,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18898
18883
|
if (queryPath) {
|
|
18899
18884
|
// Check whether load main asset
|
|
18900
18885
|
var mainPromise = loadingPromises[remoteAssetBaseURL] || this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
|
|
18901
|
-
|
|
18902
|
-
_this._onSubAssetFail(remoteAssetBaseURL, queryPath, e);
|
|
18903
|
-
});
|
|
18904
|
-
return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath);
|
|
18886
|
+
return this._createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, queryPath, mainPromise);
|
|
18905
18887
|
}
|
|
18906
18888
|
return this._loadSubpackageAndMainAsset(loader, item, remoteAssetBaseURL, subpackageName);
|
|
18907
18889
|
};
|
|
@@ -18926,30 +18908,33 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18926
18908
|
});
|
|
18927
18909
|
return promise;
|
|
18928
18910
|
};
|
|
18929
|
-
_proto._createSubAssetPromiseCallback = function _createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, assetSubPath) {
|
|
18911
|
+
_proto._createSubAssetPromiseCallback = function _createSubAssetPromiseCallback(remoteAssetBaseURL, remoteAssetURL, assetSubPath, mainPromise) {
|
|
18930
18912
|
var _this = this;
|
|
18931
18913
|
var _this__subAssetPromiseCallbacks_remoteAssetBaseURL;
|
|
18932
18914
|
var loadingPromises = this._loadingPromises;
|
|
18933
18915
|
var subPromiseCallback = (_this__subAssetPromiseCallbacks_remoteAssetBaseURL = this._subAssetPromiseCallbacks[remoteAssetBaseURL]) == null ? void 0 : _this__subAssetPromiseCallbacks_remoteAssetBaseURL[assetSubPath];
|
|
18934
18916
|
var resolvedValue = subPromiseCallback == null ? void 0 : subPromiseCallback.resolvedValue;
|
|
18935
|
-
|
|
18936
|
-
|
|
18937
|
-
|
|
18938
|
-
return new AssetPromise(function(resolve, reject) {
|
|
18939
|
-
if (resolvedValue) {
|
|
18940
|
-
resolve(resolvedValue);
|
|
18941
|
-
} else if (rejectedValue) {
|
|
18942
|
-
reject(rejectedValue);
|
|
18943
|
-
}
|
|
18944
|
-
});
|
|
18917
|
+
// Already resolved
|
|
18918
|
+
if (resolvedValue) {
|
|
18919
|
+
return AssetPromise.resolve(resolvedValue);
|
|
18945
18920
|
}
|
|
18946
18921
|
// Pending
|
|
18947
|
-
var promise = new AssetPromise(function(resolve, reject) {
|
|
18922
|
+
var promise = new AssetPromise(function(resolve, reject, setTaskCompleteProgress, setTaskDetailProgress) {
|
|
18948
18923
|
var _this__subAssetPromiseCallbacks, _remoteAssetBaseURL;
|
|
18949
18924
|
((_this__subAssetPromiseCallbacks = _this._subAssetPromiseCallbacks)[_remoteAssetBaseURL = remoteAssetBaseURL] || (_this__subAssetPromiseCallbacks[_remoteAssetBaseURL] = {}))[assetSubPath] = {
|
|
18950
18925
|
resolve: resolve,
|
|
18951
18926
|
reject: reject
|
|
18952
18927
|
};
|
|
18928
|
+
// A loader may finish the main asset before its eager sub-asset notification reaches this callback.
|
|
18929
|
+
// Always resolve from the completed main asset as the authoritative fallback so callback cleanup cannot
|
|
18930
|
+
// strand a sub-asset request.
|
|
18931
|
+
mainPromise.onProgress(setTaskCompleteProgress, setTaskDetailProgress).then(function(resource) {
|
|
18932
|
+
try {
|
|
18933
|
+
resolve(_this._getResolveResource(resource, _this._parseQueryPath(assetSubPath)));
|
|
18934
|
+
} catch (error) {
|
|
18935
|
+
reject(error);
|
|
18936
|
+
}
|
|
18937
|
+
}, reject);
|
|
18953
18938
|
});
|
|
18954
18939
|
loadingPromises[remoteAssetURL] = promise;
|
|
18955
18940
|
promise.then(function() {
|
|
@@ -18973,7 +18958,10 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
18973
18958
|
if (paths) {
|
|
18974
18959
|
for(var i = 0, n = paths.length; i < n; i++){
|
|
18975
18960
|
var path = paths[i];
|
|
18976
|
-
subResource = subResource[path];
|
|
18961
|
+
subResource = subResource == null ? void 0 : subResource[path];
|
|
18962
|
+
if (subResource === undefined) {
|
|
18963
|
+
throw new Error("Sub-asset path does not exist: " + paths.join("."));
|
|
18964
|
+
}
|
|
18977
18965
|
}
|
|
18978
18966
|
}
|
|
18979
18967
|
return subResource;
|
|
@@ -19019,6 +19007,16 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
19019
19007
|
delete this._subAssetPromiseCallbacks[assetBaseURL];
|
|
19020
19008
|
};
|
|
19021
19009
|
/**
|
|
19010
|
+
* Register virtual asset paths and their load descriptors.
|
|
19011
|
+
* @remarks References inside runtime scenes and Prefabs can keep stable virtual paths while the backing URLs
|
|
19012
|
+
* are generated dynamically, such as object URLs created from a resource package.
|
|
19013
|
+
*/ _proto.registerVirtualResources = function registerVirtualResources(resources) {
|
|
19014
|
+
var _this = this;
|
|
19015
|
+
resources.forEach(function(resource) {
|
|
19016
|
+
_this._virtualPathResourceMap[resource.virtualPath] = resource;
|
|
19017
|
+
});
|
|
19018
|
+
};
|
|
19019
|
+
/**
|
|
19022
19020
|
* @internal
|
|
19023
19021
|
* @beta Just for internal editor, not recommended for developers.
|
|
19024
19022
|
*/ _proto.getResourceByRef = function getResourceByRef(ref) {
|
|
@@ -19047,18 +19045,6 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
19047
19045
|
};
|
|
19048
19046
|
/**
|
|
19049
19047
|
* @internal
|
|
19050
|
-
* @beta Just for internal editor, not recommended for developers.
|
|
19051
|
-
*/ _proto.initVirtualResources = function initVirtualResources(config) {
|
|
19052
|
-
var _this = this;
|
|
19053
|
-
config.forEach(function(element) {
|
|
19054
|
-
_this._virtualPathResourceMap[element.virtualPath] = element;
|
|
19055
|
-
if (element.dependentAssetMap) {
|
|
19056
|
-
_this._virtualPathResourceMap[element.virtualPath].dependentAssetMap = element.dependentAssetMap;
|
|
19057
|
-
}
|
|
19058
|
-
});
|
|
19059
|
-
};
|
|
19060
|
-
/**
|
|
19061
|
-
* @internal
|
|
19062
19048
|
*/ ResourceManager._addLoader = function _addLoader(type, loader, extNames) {
|
|
19063
19049
|
this._loaders[type] = loader;
|
|
19064
19050
|
for(var i = 0, len = extNames.length; i < len; i++){
|
|
@@ -27181,7 +27167,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27181
27167
|
_inherits(Engine, EventDispatcher);
|
|
27182
27168
|
function Engine(canvas, hardwareRenderer, configuration) {
|
|
27183
27169
|
var _this;
|
|
27184
|
-
_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,
|
|
27170
|
+
_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() {
|
|
27185
27171
|
return _this._renderTargetPool.gc();
|
|
27186
27172
|
}, _this._animate = function() {
|
|
27187
27173
|
if (_this._vSyncCount) {
|
|
@@ -27262,6 +27248,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27262
27248
|
* Update the engine loop manually. If you call engine.run(), you generally don't need to call this function.
|
|
27263
27249
|
*/ _proto.update = function update() {
|
|
27264
27250
|
var _this_xrManager;
|
|
27251
|
+
this._canvas._pumpPendingResolution();
|
|
27265
27252
|
var time = this._time;
|
|
27266
27253
|
time._update();
|
|
27267
27254
|
var deltaTime = time.deltaTime;
|
|
@@ -27409,6 +27396,7 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27409
27396
|
this._destroyed = true;
|
|
27410
27397
|
this._waitingDestroy = false;
|
|
27411
27398
|
this._canvas._sizeUpdateFlagManager.removeListener(this._onCanvasResize);
|
|
27399
|
+
this._canvas._destroy();
|
|
27412
27400
|
this._sceneManager._destroyAllScene();
|
|
27413
27401
|
this._resourceManager._destroy();
|
|
27414
27402
|
this.inputManager._destroy();
|
|
@@ -27705,40 +27693,57 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27705
27693
|
/** @internal */ Engine._physicalObjectsMap = {};
|
|
27706
27694
|
|
|
27707
27695
|
/**
|
|
27708
|
-
*
|
|
27696
|
+
* The canvas the engine renders to; owns the render-buffer resolution.
|
|
27709
27697
|
*/ var Canvas = /*#__PURE__*/ function() {
|
|
27710
27698
|
function Canvas() {
|
|
27711
|
-
|
|
27699
|
+
/**
|
|
27700
|
+
* @internal
|
|
27701
|
+
*/ this._sizeUpdateFlagManager = new UpdateFlagManager();
|
|
27702
|
+
this._width = 0;
|
|
27703
|
+
this._height = 0;
|
|
27712
27704
|
}
|
|
27705
|
+
var _proto = Canvas.prototype;
|
|
27706
|
+
/**
|
|
27707
|
+
* Lock the render buffer to an explicit resolution and stop following the display size.
|
|
27708
|
+
* @param width - Render buffer width in pixels
|
|
27709
|
+
* @param height - Render buffer height in pixels
|
|
27710
|
+
*
|
|
27711
|
+
* @throws
|
|
27712
|
+
* Throw an error if width or height is not a positive finite number.
|
|
27713
|
+
*/ _proto.setResolution = function setResolution(width, height) {
|
|
27714
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
27715
|
+
throw new Error("Canvas.setResolution: invalid size " + width + "x" + height);
|
|
27716
|
+
}
|
|
27717
|
+
this._exitAutoResolution();
|
|
27718
|
+
this._setResolution(Math.round(width), Math.round(height));
|
|
27719
|
+
};
|
|
27720
|
+
_proto._setResolution = function _setResolution(width, height) {
|
|
27721
|
+
if (this._width !== width || this._height !== height) {
|
|
27722
|
+
this._width = width;
|
|
27723
|
+
this._height = height;
|
|
27724
|
+
this._onResolutionChanged(width, height);
|
|
27725
|
+
this._sizeUpdateFlagManager.dispatch();
|
|
27726
|
+
}
|
|
27727
|
+
};
|
|
27728
|
+
/**
|
|
27729
|
+
* @internal
|
|
27730
|
+
*/ _proto._pumpPendingResolution = function _pumpPendingResolution() {};
|
|
27731
|
+
_proto._exitAutoResolution = function _exitAutoResolution() {};
|
|
27713
27732
|
_create_class(Canvas, [
|
|
27714
27733
|
{
|
|
27715
27734
|
key: "width",
|
|
27716
27735
|
get: /**
|
|
27717
|
-
* The width of the canvas.
|
|
27736
|
+
* The width component of the canvas resolution, in pixels.
|
|
27718
27737
|
*/ function get() {
|
|
27719
27738
|
return this._width;
|
|
27720
|
-
},
|
|
27721
|
-
set: function set(value) {
|
|
27722
|
-
if (this._width !== value) {
|
|
27723
|
-
this._width = value;
|
|
27724
|
-
this._onWidthChanged(value);
|
|
27725
|
-
this._sizeUpdateFlagManager.dispatch();
|
|
27726
|
-
}
|
|
27727
27739
|
}
|
|
27728
27740
|
},
|
|
27729
27741
|
{
|
|
27730
27742
|
key: "height",
|
|
27731
27743
|
get: /**
|
|
27732
|
-
*The height of the canvas.
|
|
27744
|
+
* The height component of the canvas resolution, in pixels.
|
|
27733
27745
|
*/ function get() {
|
|
27734
27746
|
return this._height;
|
|
27735
|
-
},
|
|
27736
|
-
set: function set(value) {
|
|
27737
|
-
if (this._height !== value) {
|
|
27738
|
-
this._height = value;
|
|
27739
|
-
this._onHeightChange(value);
|
|
27740
|
-
this._sizeUpdateFlagManager.dispatch();
|
|
27741
|
-
}
|
|
27742
27747
|
}
|
|
27743
27748
|
}
|
|
27744
27749
|
]);
|
|
@@ -27749,11 +27754,11 @@ var OverlayCamera = function OverlayCamera() {
|
|
|
27749
27754
|
* The manager of the components.
|
|
27750
27755
|
*/ var ComponentsManager = /*#__PURE__*/ function() {
|
|
27751
27756
|
function ComponentsManager() {
|
|
27752
|
-
|
|
27757
|
+
/** @internal */ this._cameraNeedSorting = false;
|
|
27753
27758
|
/** @internal */ this._activeCameras = new DisorderedArray();
|
|
27754
27759
|
/** @internal */ this._renderers = new DisorderedArray();
|
|
27755
27760
|
/** @internal */ this._overlayCanvases = new DisorderedArray();
|
|
27756
|
-
|
|
27761
|
+
/** @internal */ this._overlayCanvasesSortingDirty = false;
|
|
27757
27762
|
/** @internal */ this._canvases = new DisorderedArray();
|
|
27758
27763
|
// Script
|
|
27759
27764
|
this._onStartScripts = new DisorderedArray();
|
|
@@ -28972,7 +28977,7 @@ AmbientOcclusion._enableMacro = ShaderMacro.getByName("SCENE_ENABLE_AMBIENT_OCCL
|
|
|
28972
28977
|
* @remarks
|
|
28973
28978
|
* Darkens areas where objects are close together to simulate natural light blocking,
|
|
28974
28979
|
* such as corners, crevices, and contact points between surfaces.
|
|
28975
|
-
*/ _this.ambientOcclusion = new AmbientOcclusion(_this),
|
|
28980
|
+
*/ _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 engineMath.Color(0.21404114048223255, 0.21404114048223255, 0.21404114048223255, 1.0), _this._fogStart = 0, _this._fogEnd = 300, _this._fogDensity = 0.01, _this._fogParams = new engineMath.Vector4(), _this._isActive = true, _this._enableTransparentShadow = false;
|
|
28976
28981
|
_this.name = name || "";
|
|
28977
28982
|
var shaderData = _this.shaderData;
|
|
28978
28983
|
shaderData._addReferCount(1);
|