@galacean/effects-core 2.8.0-alpha.1 → 2.8.0-alpha.2
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/asset-manager.d.ts +1 -3
- package/dist/composition.d.ts +0 -14
- package/dist/index.js +612 -941
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +611 -938
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-system.d.ts +12 -20
- package/dist/plugins/plugin.d.ts +8 -64
- package/dist/render/create-copy-shader.d.ts +0 -2
- package/dist/render/draw-object-pass.d.ts +5 -4
- package/dist/render/index.d.ts +1 -0
- package/dist/render/post-process-pass.d.ts +7 -11
- package/dist/render/render-frame.d.ts +9 -118
- package/dist/render/render-pass.d.ts +7 -56
- package/dist/render/render-target-pool.d.ts +22 -0
- package/dist/render/renderer.d.ts +8 -5
- package/dist/scene.d.ts +1 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -37,41 +37,6 @@ function _async_to_generator(fn) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function _array_like_to_array(arr, len) {
|
|
41
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
42
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
43
|
-
return arr2;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
47
|
-
if (!o) return;
|
|
48
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
49
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
50
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
51
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
52
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
56
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
57
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
58
|
-
// Fallback for engines without symbol support
|
|
59
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
60
|
-
if (it) o = it;
|
|
61
|
-
var i = 0;
|
|
62
|
-
return function() {
|
|
63
|
-
if (i >= o.length) return {
|
|
64
|
-
done: true
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
done: false,
|
|
68
|
-
value: o[i++]
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
40
|
function _instanceof1(left, right) {
|
|
76
41
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
77
42
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -2904,134 +2869,68 @@ function applyMixins(derivedCtrl, baseCtrls) {
|
|
|
2904
2869
|
}
|
|
2905
2870
|
|
|
2906
2871
|
var pluginLoaderMap = {};
|
|
2907
|
-
var
|
|
2908
|
-
var pluginCtrlMap = {};
|
|
2872
|
+
var plugins = [];
|
|
2909
2873
|
/**
|
|
2910
2874
|
* 注册 plugin
|
|
2911
2875
|
* @param name
|
|
2912
2876
|
* @param pluginClass class of plugin
|
|
2913
2877
|
* @param itemClass class of item
|
|
2914
2878
|
* @param isDefault load
|
|
2915
|
-
*/ function registerPlugin(name, pluginClass
|
|
2916
|
-
if (
|
|
2879
|
+
*/ function registerPlugin(name, pluginClass) {
|
|
2880
|
+
if (pluginLoaderMap[name]) {
|
|
2917
2881
|
logger.error("Duplicate registration for plugin " + name + ".");
|
|
2918
2882
|
}
|
|
2919
|
-
pluginCtrlMap[name] = itemClass;
|
|
2920
2883
|
pluginLoaderMap[name] = pluginClass;
|
|
2921
|
-
|
|
2884
|
+
var pluginInstance = new pluginClass();
|
|
2885
|
+
pluginInstance.name = name;
|
|
2886
|
+
pluginInstance.initialize();
|
|
2887
|
+
plugins.push(pluginInstance);
|
|
2888
|
+
plugins.sort(function(a, b) {
|
|
2889
|
+
return a.order - b.order;
|
|
2890
|
+
});
|
|
2922
2891
|
}
|
|
2923
|
-
|
|
2924
|
-
|
|
2892
|
+
/**
|
|
2893
|
+
* 注销 plugin
|
|
2894
|
+
*/ function unregisterPlugin(name) {
|
|
2925
2895
|
delete pluginLoaderMap[name];
|
|
2926
|
-
|
|
2896
|
+
var pluginIndex = plugins.findIndex(function(plugin) {
|
|
2897
|
+
return plugin.name === name;
|
|
2898
|
+
});
|
|
2899
|
+
if (pluginIndex !== -1) {
|
|
2900
|
+
plugins.splice(pluginIndex, 1);
|
|
2901
|
+
}
|
|
2927
2902
|
}
|
|
2928
2903
|
var PluginSystem = /*#__PURE__*/ function() {
|
|
2929
|
-
function PluginSystem(
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
loaded.push(loader);
|
|
2936
|
-
loaders[name] = loader;
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
2939
|
-
defaultPlugins.forEach(addLoader);
|
|
2940
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(pluginNames), _step; !(_step = _iterator()).done;){
|
|
2941
|
-
var customPluginName = _step.value;
|
|
2942
|
-
if (!pluginLoaderMap[customPluginName]) {
|
|
2943
|
-
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
this.plugins = Object.keys(loaders).map(function(name) {
|
|
2947
|
-
var pluginConstructor = pluginLoaderMap[name];
|
|
2948
|
-
var loader = new pluginConstructor();
|
|
2949
|
-
loader.name = name;
|
|
2950
|
-
return loader;
|
|
2951
|
-
}).sort(function(a, b) {
|
|
2952
|
-
return a.order - b.order;
|
|
2953
|
-
});
|
|
2954
|
-
}
|
|
2955
|
-
var _proto = PluginSystem.prototype;
|
|
2956
|
-
_proto.initializeComposition = function initializeComposition(composition, scene) {
|
|
2957
|
-
this.plugins.forEach(function(loader) {
|
|
2904
|
+
function PluginSystem() {}
|
|
2905
|
+
PluginSystem.getPlugins = function getPlugins() {
|
|
2906
|
+
return plugins;
|
|
2907
|
+
};
|
|
2908
|
+
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2909
|
+
plugins.forEach(function(loader) {
|
|
2958
2910
|
return loader.onCompositionConstructed(composition, scene);
|
|
2959
2911
|
});
|
|
2960
2912
|
};
|
|
2961
|
-
|
|
2962
|
-
|
|
2913
|
+
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2914
|
+
plugins.forEach(function(loader) {
|
|
2963
2915
|
return loader.onCompositionDestroyed(comp);
|
|
2964
2916
|
});
|
|
2965
2917
|
};
|
|
2966
|
-
|
|
2967
|
-
this.plugins.forEach(function(loader) {
|
|
2968
|
-
return loader.onCompositionReset(comp, renderFrame);
|
|
2969
|
-
});
|
|
2970
|
-
};
|
|
2971
|
-
_proto.processRawJSON = function processRawJSON(json, options) {
|
|
2972
|
-
var _this = this;
|
|
2918
|
+
PluginSystem.processAssets = function processAssets(scene, options) {
|
|
2973
2919
|
return _async_to_generator(function() {
|
|
2974
2920
|
return __generator(this, function(_state) {
|
|
2975
2921
|
return [
|
|
2976
2922
|
2,
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
})();
|
|
2981
|
-
};
|
|
2982
|
-
_proto.processAssets = function processAssets(json, options) {
|
|
2983
|
-
var _this = this;
|
|
2984
|
-
return _async_to_generator(function() {
|
|
2985
|
-
return __generator(this, function(_state) {
|
|
2986
|
-
return [
|
|
2987
|
-
2,
|
|
2988
|
-
_this.callStatic("processAssets", json, options)
|
|
2989
|
-
];
|
|
2990
|
-
});
|
|
2991
|
-
})();
|
|
2992
|
-
};
|
|
2993
|
-
_proto.precompile = function precompile(compositions, renderer) {
|
|
2994
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
|
|
2995
|
-
var plugin = _step.value;
|
|
2996
|
-
plugin.precompile(compositions, renderer);
|
|
2997
|
-
}
|
|
2998
|
-
};
|
|
2999
|
-
_proto.loadResources = function loadResources(scene, options) {
|
|
3000
|
-
var _this = this;
|
|
3001
|
-
return _async_to_generator(function() {
|
|
3002
|
-
return __generator(this, function(_state) {
|
|
3003
|
-
return [
|
|
3004
|
-
2,
|
|
3005
|
-
_this.callStatic("prepareResource", scene, options)
|
|
2923
|
+
Promise.all(plugins.map(function(plugin) {
|
|
2924
|
+
return plugin.processAssets(scene, options);
|
|
2925
|
+
}))
|
|
3006
2926
|
];
|
|
3007
2927
|
});
|
|
3008
2928
|
})();
|
|
3009
2929
|
};
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
}
|
|
3014
|
-
var _this = this;
|
|
3015
|
-
return _async_to_generator(function() {
|
|
3016
|
-
var pendings, plugins, i, plugin, ctrl, _ctrl_name, _ctrl_name1;
|
|
3017
|
-
return __generator(this, function(_state) {
|
|
3018
|
-
pendings = [];
|
|
3019
|
-
plugins = _this.plugins;
|
|
3020
|
-
for(i = 0; i < plugins.length; i++){
|
|
3021
|
-
plugin = plugins[i];
|
|
3022
|
-
ctrl = pluginLoaderMap[plugin.name];
|
|
3023
|
-
if (name in ctrl) {
|
|
3024
|
-
pendings.push(Promise.resolve((_ctrl_name1 = ctrl[name]) == null ? void 0 : (_ctrl_name = _ctrl_name1).call.apply(_ctrl_name, [].concat([
|
|
3025
|
-
ctrl
|
|
3026
|
-
], args))));
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
return [
|
|
3030
|
-
2,
|
|
3031
|
-
Promise.all(pendings)
|
|
3032
|
-
];
|
|
3033
|
-
});
|
|
3034
|
-
})();
|
|
2930
|
+
PluginSystem.loadResources = function loadResources(scene, options, engine) {
|
|
2931
|
+
plugins.forEach(function(loader) {
|
|
2932
|
+
return loader.prepareResource(scene, options, engine);
|
|
2933
|
+
});
|
|
3035
2934
|
};
|
|
3036
2935
|
return PluginSystem;
|
|
3037
2936
|
}();
|
|
@@ -3039,6 +2938,8 @@ var pluginInfoMap = {
|
|
|
3039
2938
|
"alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
|
|
3040
2939
|
"downgrade": "@galacean/effects-plugin-downgrade",
|
|
3041
2940
|
"editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
|
|
2941
|
+
"ffd": "@galacean/effects-plugin-ffd",
|
|
2942
|
+
"ktx2": "@galacean/effects-plugin-ktx2",
|
|
3042
2943
|
"model": "@galacean/effects-plugin-model",
|
|
3043
2944
|
"video": "@galacean/effects-plugin-multimedia",
|
|
3044
2945
|
"audio": "@galacean/effects-plugin-multimedia",
|
|
@@ -3064,15 +2965,33 @@ function getPluginUsageInfo(name) {
|
|
|
3064
2965
|
this.name = "";
|
|
3065
2966
|
}
|
|
3066
2967
|
var _proto = AbstractPlugin.prototype;
|
|
2968
|
+
_proto.initialize = function initialize() {};
|
|
3067
2969
|
/**
|
|
3068
|
-
*
|
|
3069
|
-
*
|
|
3070
|
-
* @param
|
|
3071
|
-
|
|
2970
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
2971
|
+
* 此阶段可以加载插件所需类型资源,并返回原始资源和加载后的资源。
|
|
2972
|
+
* @param scene
|
|
2973
|
+
* @param options
|
|
2974
|
+
* @returns
|
|
2975
|
+
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2976
|
+
return _async_to_generator(function() {
|
|
2977
|
+
return __generator(this, function(_state) {
|
|
2978
|
+
return [
|
|
2979
|
+
2
|
|
2980
|
+
];
|
|
2981
|
+
});
|
|
2982
|
+
})();
|
|
2983
|
+
};
|
|
2984
|
+
/**
|
|
2985
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
2986
|
+
* 此阶段时,json 中的图片和二进制已经被加载完成,可以对加载好的资源做进一步处理,
|
|
2987
|
+
* 如果 promise 被 reject, loadScene 函数同样会被 reject,表示场景加载失败。
|
|
2988
|
+
* 请记住,整个 load 阶段都不要创建 GL 相关的对象,只创建 JS 对象
|
|
2989
|
+
* 此阶段晚于 processAssets
|
|
2990
|
+
* @param {Scene} scene
|
|
2991
|
+
* @param {SceneLoadOptions} options
|
|
2992
|
+
*/ _proto.prepareResource = function prepareResource(scene, options, engine) {};
|
|
3072
2993
|
_proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {};
|
|
3073
|
-
_proto.onCompositionReset = function onCompositionReset(composition, frame) {};
|
|
3074
2994
|
_proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {};
|
|
3075
|
-
_proto.onCompositionUpdate = function onCompositionUpdate(composition, dt) {};
|
|
3076
2995
|
return AbstractPlugin;
|
|
3077
2996
|
}();
|
|
3078
2997
|
|
|
@@ -4057,6 +3976,41 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
4057
3976
|
get VertexBufferSemantic () { return VertexBufferSemantic; }
|
|
4058
3977
|
});
|
|
4059
3978
|
|
|
3979
|
+
function _array_like_to_array(arr, len) {
|
|
3980
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3981
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
3982
|
+
return arr2;
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3985
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
3986
|
+
if (!o) return;
|
|
3987
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
3988
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3989
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3990
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
3991
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
3995
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3996
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3997
|
+
// Fallback for engines without symbol support
|
|
3998
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3999
|
+
if (it) o = it;
|
|
4000
|
+
var i = 0;
|
|
4001
|
+
return function() {
|
|
4002
|
+
if (i >= o.length) return {
|
|
4003
|
+
done: true
|
|
4004
|
+
};
|
|
4005
|
+
return {
|
|
4006
|
+
done: false,
|
|
4007
|
+
value: o[i++]
|
|
4008
|
+
};
|
|
4009
|
+
};
|
|
4010
|
+
}
|
|
4011
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4060
4014
|
var decoratorInitialStore = new Map();
|
|
4061
4015
|
var mergedStore = new Map();
|
|
4062
4016
|
var effectsClassStore = {};
|
|
@@ -10355,175 +10309,72 @@ var MaskProcessor = /*#__PURE__*/ function() {
|
|
|
10355
10309
|
return MaskProcessor;
|
|
10356
10310
|
}();
|
|
10357
10311
|
|
|
10358
|
-
exports.ShaderCompileResultStatus = void 0;
|
|
10359
|
-
(function(ShaderCompileResultStatus) {
|
|
10360
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10361
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10362
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10363
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10364
|
-
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10365
|
-
exports.GLSLVersion = void 0;
|
|
10366
|
-
(function(GLSLVersion) {
|
|
10367
|
-
GLSLVersion["GLSL1"] = "100";
|
|
10368
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
10369
|
-
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10370
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10371
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
10372
|
-
function ShaderVariant(engine, source) {
|
|
10373
|
-
var _this;
|
|
10374
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
10375
|
-
_this.source = source;
|
|
10376
|
-
return _this;
|
|
10377
|
-
}
|
|
10378
|
-
return ShaderVariant;
|
|
10379
|
-
}(EffectsObject);
|
|
10380
|
-
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10381
|
-
_inherits(Shader, EffectsObject);
|
|
10382
|
-
function Shader() {
|
|
10383
|
-
return EffectsObject.apply(this, arguments);
|
|
10384
|
-
}
|
|
10385
|
-
var _proto = Shader.prototype;
|
|
10386
|
-
_proto.createVariant = function createVariant(macros) {
|
|
10387
|
-
var shaderMacros = [];
|
|
10388
|
-
if (macros) {
|
|
10389
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10390
|
-
var key = _step.value;
|
|
10391
|
-
shaderMacros.push([
|
|
10392
|
-
key,
|
|
10393
|
-
macros[key]
|
|
10394
|
-
]);
|
|
10395
|
-
}
|
|
10396
|
-
}
|
|
10397
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10398
|
-
shaderVariant.shader = this;
|
|
10399
|
-
return shaderVariant;
|
|
10400
|
-
};
|
|
10401
|
-
_proto.fromData = function fromData(data) {
|
|
10402
|
-
EffectsObject.prototype.fromData.call(this, data);
|
|
10403
|
-
this.shaderData = data;
|
|
10404
|
-
};
|
|
10405
|
-
return Shader;
|
|
10406
|
-
}(EffectsObject);
|
|
10407
|
-
exports.Shader = __decorate([
|
|
10408
|
-
effectsClass(DataType.Shader)
|
|
10409
|
-
], exports.Shader);
|
|
10410
|
-
|
|
10411
10312
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10412
10313
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10413
10314
|
var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
|
|
10414
10315
|
var COPY_FRAGMENT_SHADER = "precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";
|
|
10415
|
-
function createCopyShader(level, writeDepth) {
|
|
10416
|
-
var webgl2 = level === 2;
|
|
10417
|
-
return {
|
|
10418
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
10419
|
-
vertex: COPY_VERTEX_SHADER,
|
|
10420
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
10421
|
-
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
10422
|
-
macros: [
|
|
10423
|
-
[
|
|
10424
|
-
"DEPTH_TEXTURE",
|
|
10425
|
-
!!writeDepth
|
|
10426
|
-
]
|
|
10427
|
-
],
|
|
10428
|
-
// @ts-expect-error
|
|
10429
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
10430
|
-
};
|
|
10431
|
-
}
|
|
10432
10316
|
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
var _this = this;
|
|
10451
|
-
var width = request.width, height = request.height, name = request.name;
|
|
10452
|
-
var options = {
|
|
10453
|
-
sourceType: exports.TextureSourceType.framebuffer,
|
|
10454
|
-
data: {
|
|
10455
|
-
width: width,
|
|
10456
|
-
height: height
|
|
10457
|
-
},
|
|
10458
|
-
name: name
|
|
10459
|
-
};
|
|
10460
|
-
var keys = [
|
|
10461
|
-
name
|
|
10462
|
-
];
|
|
10463
|
-
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
10464
|
-
var _request_name;
|
|
10465
|
-
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
10466
|
-
options[name] = value;
|
|
10467
|
-
keys.push(name, value);
|
|
10468
|
-
});
|
|
10469
|
-
var cacheId = keys.join(":");
|
|
10470
|
-
var tex = this.textureCache[cacheId];
|
|
10471
|
-
if (tex) {
|
|
10472
|
-
this.textureRef[cacheId]++;
|
|
10473
|
-
} else {
|
|
10474
|
-
var engine = this.engine;
|
|
10475
|
-
assertExist(engine);
|
|
10476
|
-
tex = Texture.create(engine, options);
|
|
10477
|
-
this.textureCache[cacheId] = tex;
|
|
10478
|
-
this.textureRef[cacheId] = 1;
|
|
10479
|
-
// @ts-expect-error
|
|
10480
|
-
tex[disposeSymbol] = tex.dispose;
|
|
10481
|
-
tex.dispose = function() {
|
|
10482
|
-
return _this.removeTexture(cacheId);
|
|
10483
|
-
};
|
|
10484
|
-
}
|
|
10485
|
-
return tex;
|
|
10317
|
+
exports.FilterMode = void 0;
|
|
10318
|
+
(function(FilterMode) {
|
|
10319
|
+
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
10320
|
+
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
10321
|
+
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
10322
|
+
exports.RenderTextureFormat = void 0;
|
|
10323
|
+
(function(RenderTextureFormat) {
|
|
10324
|
+
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
10325
|
+
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
10326
|
+
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
10327
|
+
/**
|
|
10328
|
+
*
|
|
10329
|
+
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
10330
|
+
function Framebuffer() {}
|
|
10331
|
+
var _proto = Framebuffer.prototype;
|
|
10332
|
+
_proto.resize = function resize(x, y, width, height) {
|
|
10333
|
+
// OVERRIDE
|
|
10486
10334
|
};
|
|
10487
|
-
_proto.
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10335
|
+
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
10336
|
+
// OVERRIDE
|
|
10337
|
+
};
|
|
10338
|
+
_proto.unbind = function unbind() {
|
|
10339
|
+
// OVERRIDE
|
|
10340
|
+
};
|
|
10341
|
+
_proto.bind = function bind() {
|
|
10342
|
+
// OVERRIDE
|
|
10343
|
+
};
|
|
10344
|
+
_proto.getDepthTexture = function getDepthTexture() {
|
|
10345
|
+
// OVERRIDE
|
|
10346
|
+
return undefined;
|
|
10347
|
+
};
|
|
10348
|
+
_proto.getStencilTexture = function getStencilTexture() {
|
|
10349
|
+
// OVERRIDE
|
|
10350
|
+
return undefined;
|
|
10351
|
+
};
|
|
10352
|
+
_proto.getColorTextures = function getColorTextures() {
|
|
10353
|
+
// OVERRIDE
|
|
10354
|
+
return [];
|
|
10355
|
+
};
|
|
10356
|
+
_proto.dispose = function dispose(options) {
|
|
10357
|
+
// OVERRIDE
|
|
10358
|
+
};
|
|
10359
|
+
_create_class(Framebuffer, [
|
|
10360
|
+
{
|
|
10361
|
+
key: "stencilStorage",
|
|
10362
|
+
get: function get() {
|
|
10363
|
+
// OVERRIDE
|
|
10364
|
+
return undefined;
|
|
10492
10365
|
}
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
//
|
|
10498
|
-
|
|
10366
|
+
},
|
|
10367
|
+
{
|
|
10368
|
+
key: "depthStorage",
|
|
10369
|
+
get: function get() {
|
|
10370
|
+
// OVERRIDE
|
|
10371
|
+
return undefined;
|
|
10499
10372
|
}
|
|
10500
|
-
delete this.textureCache[id];
|
|
10501
|
-
delete this.textureRef[id];
|
|
10502
|
-
} else {
|
|
10503
|
-
this.textureRef[id] = refCount - 1;
|
|
10504
10373
|
}
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
var _this = this;
|
|
10508
|
-
Object.keys(this.textureCache).forEach(function(key) {
|
|
10509
|
-
var texture = _this.textureCache[key];
|
|
10510
|
-
// @ts-expect-error
|
|
10511
|
-
texture[disposeSymbol]();
|
|
10512
|
-
// @ts-expect-error
|
|
10513
|
-
texture.dispose = texture[disposeSymbol];
|
|
10514
|
-
});
|
|
10515
|
-
this.textureCache = {};
|
|
10516
|
-
this.textureRef = {};
|
|
10517
|
-
this.engine = undefined;
|
|
10518
|
-
};
|
|
10519
|
-
return PassTextureCache;
|
|
10374
|
+
]);
|
|
10375
|
+
return Framebuffer;
|
|
10520
10376
|
}();
|
|
10521
10377
|
|
|
10522
|
-
function _assert_this_initialized(self) {
|
|
10523
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10524
|
-
return self;
|
|
10525
|
-
}
|
|
10526
|
-
|
|
10527
10378
|
var RenderPassPriorityPrepare = 0;
|
|
10528
10379
|
var RenderPassPriorityNormal = 1000;
|
|
10529
10380
|
var RenderPassPriorityPostprocess = 3000;
|
|
@@ -10533,7 +10384,7 @@ exports.RenderPassAttachmentStorageType = void 0;
|
|
|
10533
10384
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
|
|
10534
10385
|
//stencil 8 render buffer
|
|
10535
10386
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
|
|
10536
|
-
//
|
|
10387
|
+
//depth 16 render buffer
|
|
10537
10388
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
|
|
10538
10389
|
//depth 16 & stencil 8 render buffer
|
|
10539
10390
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
|
|
@@ -10652,61 +10503,31 @@ var seed$7 = 1;
|
|
|
10652
10503
|
/**
|
|
10653
10504
|
* RenderPass 抽象类
|
|
10654
10505
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
10655
|
-
function RenderPass(renderer
|
|
10506
|
+
function RenderPass(renderer) {
|
|
10656
10507
|
/**
|
|
10657
10508
|
* 优先级
|
|
10658
10509
|
*/ this.priority = 0;
|
|
10659
10510
|
/**
|
|
10660
|
-
* ColorAttachment 数组
|
|
10661
|
-
*/ this.attachments = [];
|
|
10662
|
-
/**
|
|
10663
10511
|
* 名称
|
|
10664
10512
|
*/ this.name = "RenderPass" + seed$7++;
|
|
10665
10513
|
/**
|
|
10666
10514
|
* 包含的 Mesh 列表
|
|
10667
10515
|
*/ this.meshes = [];
|
|
10668
|
-
/**
|
|
10669
|
-
* Mesh 渲染顺序,按照优先级升序或降序
|
|
10670
|
-
*/ this.meshOrder = exports.OrderType.ascending;
|
|
10671
10516
|
this.disposed = false;
|
|
10672
|
-
this.
|
|
10673
|
-
var depthStencilAttachment = options.depthStencilAttachment;
|
|
10517
|
+
this.framebuffer = null;
|
|
10674
10518
|
this.renderer = renderer;
|
|
10675
|
-
this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
|
|
10676
|
-
this.storeAction = {
|
|
10677
|
-
colorAction: 0,
|
|
10678
|
-
depthAction: 0,
|
|
10679
|
-
stencilAction: 0
|
|
10680
|
-
};
|
|
10681
|
-
this.options = options;
|
|
10682
10519
|
}
|
|
10683
10520
|
var _proto = RenderPass.prototype;
|
|
10684
10521
|
_proto.addMesh = function addMesh(mesh) {
|
|
10685
|
-
addByOrder(this.meshes, mesh
|
|
10522
|
+
addByOrder(this.meshes, mesh);
|
|
10686
10523
|
};
|
|
10687
10524
|
_proto.removeMesh = function removeMesh(mesh) {
|
|
10688
10525
|
removeItem(this.meshes, mesh);
|
|
10689
10526
|
};
|
|
10690
|
-
_proto.setMeshes = function setMeshes(meshes) {
|
|
10691
|
-
var _this_meshes;
|
|
10692
|
-
this.meshes.length = 0;
|
|
10693
|
-
(_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
|
|
10694
|
-
0,
|
|
10695
|
-
0
|
|
10696
|
-
], meshes));
|
|
10697
|
-
sortByOrder(this.meshes, this.meshOrder);
|
|
10698
|
-
return this.meshes;
|
|
10699
|
-
};
|
|
10700
|
-
// TODO 所有pass在子类配置
|
|
10701
10527
|
/**
|
|
10702
10528
|
* 配置当前pass的RT,在每帧渲染前调用
|
|
10703
10529
|
*/ _proto.configure = function configure(renderer) {
|
|
10704
|
-
|
|
10705
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
10706
|
-
} else {
|
|
10707
|
-
var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
|
|
10708
|
-
renderer.setViewport(x, y, width, height);
|
|
10709
|
-
}
|
|
10530
|
+
// OVERRIDE
|
|
10710
10531
|
};
|
|
10711
10532
|
/**
|
|
10712
10533
|
* 执行当前pass,每帧调用一次
|
|
@@ -10714,66 +10535,10 @@ var seed$7 = 1;
|
|
|
10714
10535
|
// OVERRIDE
|
|
10715
10536
|
};
|
|
10716
10537
|
/**
|
|
10717
|
-
* 每帧所有的pass
|
|
10718
|
-
*/ _proto.
|
|
10538
|
+
* 每帧所有的pass渲染完后调用,用于清空临时的RT资源
|
|
10539
|
+
*/ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10719
10540
|
// OVERRIDE
|
|
10720
10541
|
};
|
|
10721
|
-
_proto._resetAttachments = function _resetAttachments() {
|
|
10722
|
-
var _this = this;
|
|
10723
|
-
var _options_attachments;
|
|
10724
|
-
var renderer = this.renderer;
|
|
10725
|
-
var options = this.options;
|
|
10726
|
-
if (this.attachments.length) {
|
|
10727
|
-
var _this_framebuffer;
|
|
10728
|
-
this.attachments.forEach(function(att) {
|
|
10729
|
-
return !att.externalTexture && att.dispose();
|
|
10730
|
-
});
|
|
10731
|
-
this.attachments.length = 0;
|
|
10732
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
|
|
10733
|
-
depthStencilAttachment: 2
|
|
10734
|
-
});
|
|
10735
|
-
this.framebuffer = null;
|
|
10736
|
-
}
|
|
10737
|
-
// renderpass 的 viewport 相关参数都需要动态的修改
|
|
10738
|
-
var viewport = [
|
|
10739
|
-
0,
|
|
10740
|
-
0,
|
|
10741
|
-
renderer.getWidth(),
|
|
10742
|
-
renderer.getHeight()
|
|
10743
|
-
];
|
|
10744
|
-
var size = [
|
|
10745
|
-
viewport[2],
|
|
10746
|
-
viewport[3]
|
|
10747
|
-
];
|
|
10748
|
-
var name = this.name;
|
|
10749
|
-
if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
|
|
10750
|
-
var attachments = options.attachments.map(function(attr, index) {
|
|
10751
|
-
var _attr_texture;
|
|
10752
|
-
var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
|
|
10753
|
-
size: size,
|
|
10754
|
-
name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
|
|
10755
|
-
}, attr));
|
|
10756
|
-
return attachment;
|
|
10757
|
-
});
|
|
10758
|
-
this.attachments = attachments;
|
|
10759
|
-
var framebuffer = Framebuffer.create({
|
|
10760
|
-
storeAction: this.storeAction,
|
|
10761
|
-
name: name,
|
|
10762
|
-
viewport: viewport,
|
|
10763
|
-
attachments: attachments.map(function(att) {
|
|
10764
|
-
return att.texture;
|
|
10765
|
-
}),
|
|
10766
|
-
depthStencilAttachment: options.depthStencilAttachment || {
|
|
10767
|
-
storageType: 0
|
|
10768
|
-
}
|
|
10769
|
-
}, renderer);
|
|
10770
|
-
framebuffer.bind();
|
|
10771
|
-
framebuffer.unbind();
|
|
10772
|
-
this.framebuffer = framebuffer;
|
|
10773
|
-
} else {
|
|
10774
|
-
this.attachments.length = 0;
|
|
10775
|
-
}
|
|
10776
|
-
};
|
|
10777
10542
|
/**
|
|
10778
10543
|
* 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
|
|
10779
10544
|
*/ _proto.getViewport = function getViewport() {
|
|
@@ -10796,68 +10561,6 @@ var seed$7 = 1;
|
|
|
10796
10561
|
];
|
|
10797
10562
|
};
|
|
10798
10563
|
/**
|
|
10799
|
-
* 获取深度 Attachment,可能没有
|
|
10800
|
-
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
10801
|
-
var framebuffer = this.framebuffer;
|
|
10802
|
-
if (framebuffer) {
|
|
10803
|
-
var depthTexture = framebuffer.getDepthTexture();
|
|
10804
|
-
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
10805
|
-
return {
|
|
10806
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10807
|
-
storage: framebuffer.depthStorage,
|
|
10808
|
-
texture: texture
|
|
10809
|
-
};
|
|
10810
|
-
}
|
|
10811
|
-
};
|
|
10812
|
-
/**
|
|
10813
|
-
* 获取蒙版 Attachment,可能没有
|
|
10814
|
-
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
10815
|
-
var framebuffer = this.framebuffer;
|
|
10816
|
-
if (framebuffer) {
|
|
10817
|
-
var stencilTexture = framebuffer.getStencilTexture();
|
|
10818
|
-
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
10819
|
-
return {
|
|
10820
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10821
|
-
storage: framebuffer.stencilStorage,
|
|
10822
|
-
texture: texture
|
|
10823
|
-
};
|
|
10824
|
-
}
|
|
10825
|
-
};
|
|
10826
|
-
_proto.getDepthTexture = function getDepthTexture(texture, external) {
|
|
10827
|
-
if (!this.depthTexture) {
|
|
10828
|
-
var _this_options_depthStencilAttachment;
|
|
10829
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10830
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10831
|
-
// TODO 为什么要initialize?
|
|
10832
|
-
//tex.initialize(this.renderer.engine);
|
|
10833
|
-
if (!external) {
|
|
10834
|
-
this.depthTexture = tex;
|
|
10835
|
-
}
|
|
10836
|
-
return tex;
|
|
10837
|
-
}
|
|
10838
|
-
return this.depthTexture;
|
|
10839
|
-
};
|
|
10840
|
-
_proto.getStencilTexture = function getStencilTexture(texture, external) {
|
|
10841
|
-
if (!this.stencilTexture) {
|
|
10842
|
-
var _this_options_depthStencilAttachment;
|
|
10843
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10844
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10845
|
-
if (!external) {
|
|
10846
|
-
this.stencilTexture = tex;
|
|
10847
|
-
}
|
|
10848
|
-
return tex;
|
|
10849
|
-
}
|
|
10850
|
-
return this.stencilTexture;
|
|
10851
|
-
};
|
|
10852
|
-
// 生成并初始化帧缓冲
|
|
10853
|
-
_proto.initialize = function initialize(renderer) {
|
|
10854
|
-
if (!this.initialized) {
|
|
10855
|
-
this._resetAttachments();
|
|
10856
|
-
this.initialized = true;
|
|
10857
|
-
}
|
|
10858
|
-
return this;
|
|
10859
|
-
};
|
|
10860
|
-
/**
|
|
10861
10564
|
* 销毁 RenderPass
|
|
10862
10565
|
* @param options - 有选择销毁内部对象
|
|
10863
10566
|
*/ _proto.dispose = function dispose(options) {
|
|
@@ -10871,35 +10574,11 @@ var seed$7 = 1;
|
|
|
10871
10574
|
});
|
|
10872
10575
|
}
|
|
10873
10576
|
this.meshes.length = 0;
|
|
10874
|
-
var colorOpt = (options == null ? void 0 : options.colorAttachment) ? options.colorAttachment : 0;
|
|
10875
|
-
this.attachments.forEach(function(att) {
|
|
10876
|
-
var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
|
|
10877
|
-
if (!keep) {
|
|
10878
|
-
att.dispose();
|
|
10879
|
-
}
|
|
10880
|
-
});
|
|
10881
|
-
this.attachments.length = 0;
|
|
10882
10577
|
this.disposed = true;
|
|
10883
|
-
var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
|
|
10884
|
-
var fbo = this.framebuffer;
|
|
10885
|
-
if (fbo) {
|
|
10886
|
-
fbo.dispose({
|
|
10887
|
-
depthStencilAttachment: depthStencilOpt
|
|
10888
|
-
});
|
|
10889
|
-
var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
|
|
10890
|
-
if (!keep) {
|
|
10891
|
-
var _this_stencilTexture, _this_depthTexture;
|
|
10892
|
-
(_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
|
|
10893
|
-
(_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
|
|
10894
|
-
}
|
|
10895
|
-
}
|
|
10896
|
-
// @ts-expect-error safe to assign
|
|
10897
|
-
this.options = null;
|
|
10898
|
-
this.initialize = throwDestroyedError;
|
|
10899
10578
|
};
|
|
10900
10579
|
_create_class(RenderPass, [
|
|
10901
10580
|
{
|
|
10902
|
-
key: "
|
|
10581
|
+
key: "isDisposed",
|
|
10903
10582
|
get: function get() {
|
|
10904
10583
|
return this.disposed;
|
|
10905
10584
|
}
|
|
@@ -10909,18 +10588,6 @@ var seed$7 = 1;
|
|
|
10909
10588
|
get: function get() {
|
|
10910
10589
|
return this.getViewport();
|
|
10911
10590
|
}
|
|
10912
|
-
},
|
|
10913
|
-
{
|
|
10914
|
-
key: "stencilAttachment",
|
|
10915
|
-
get: function get() {
|
|
10916
|
-
return this.getStencilAttachment();
|
|
10917
|
-
}
|
|
10918
|
-
},
|
|
10919
|
-
{
|
|
10920
|
-
key: "depthAttachment",
|
|
10921
|
-
get: function get() {
|
|
10922
|
-
return this.getDepthAttachment();
|
|
10923
|
-
}
|
|
10924
10591
|
}
|
|
10925
10592
|
]);
|
|
10926
10593
|
return RenderPass;
|
|
@@ -10928,38 +10595,95 @@ var seed$7 = 1;
|
|
|
10928
10595
|
|
|
10929
10596
|
var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
10930
10597
|
_inherits(DrawObjectPass, RenderPass);
|
|
10931
|
-
function DrawObjectPass(renderer
|
|
10598
|
+
function DrawObjectPass(renderer) {
|
|
10932
10599
|
var _this;
|
|
10933
|
-
_this = RenderPass.call(this, renderer
|
|
10600
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
10601
|
+
_this.useRenderTarget = false;
|
|
10934
10602
|
_this.priority = RenderPassPriorityNormal;
|
|
10935
10603
|
_this.name = "DrawObjectPass";
|
|
10936
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
10937
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
10938
10604
|
return _this;
|
|
10939
10605
|
}
|
|
10940
10606
|
var _proto = DrawObjectPass.prototype;
|
|
10607
|
+
_proto.setup = function setup(useRenderTarget) {
|
|
10608
|
+
this.useRenderTarget = useRenderTarget;
|
|
10609
|
+
};
|
|
10610
|
+
_proto.configure = function configure(renderer) {
|
|
10611
|
+
if (this.useRenderTarget) {
|
|
10612
|
+
this.framebuffer = renderer.getTemporaryRT("DrawObjectPass", renderer.getWidth(), renderer.getHeight(), 16, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
10613
|
+
renderer.setFramebuffer(this.framebuffer);
|
|
10614
|
+
}
|
|
10615
|
+
};
|
|
10941
10616
|
_proto.execute = function execute(renderer) {
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10617
|
+
if (this.useRenderTarget) {
|
|
10618
|
+
renderer.clear({
|
|
10619
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
10620
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
10621
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
10622
|
+
});
|
|
10623
|
+
}
|
|
10947
10624
|
renderer.renderMeshes(this.meshes);
|
|
10948
|
-
renderer.clear(this.storeAction);
|
|
10949
|
-
};
|
|
10950
|
-
_proto.onResize = function onResize() {
|
|
10951
|
-
var _this_framebuffer;
|
|
10952
|
-
var width = this.renderer.getWidth();
|
|
10953
|
-
var height = this.renderer.getHeight();
|
|
10954
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
10955
10625
|
};
|
|
10956
|
-
_proto.
|
|
10957
|
-
this.
|
|
10958
|
-
|
|
10626
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10627
|
+
if (this.useRenderTarget && this.framebuffer) {
|
|
10628
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
10629
|
+
}
|
|
10959
10630
|
};
|
|
10960
10631
|
return DrawObjectPass;
|
|
10961
10632
|
}(RenderPass);
|
|
10962
10633
|
|
|
10634
|
+
exports.ShaderCompileResultStatus = void 0;
|
|
10635
|
+
(function(ShaderCompileResultStatus) {
|
|
10636
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10637
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10638
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10639
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10640
|
+
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10641
|
+
exports.GLSLVersion = void 0;
|
|
10642
|
+
(function(GLSLVersion) {
|
|
10643
|
+
GLSLVersion["GLSL1"] = "100";
|
|
10644
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
10645
|
+
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10646
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10647
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
10648
|
+
function ShaderVariant(engine, source) {
|
|
10649
|
+
var _this;
|
|
10650
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
10651
|
+
_this.source = source;
|
|
10652
|
+
return _this;
|
|
10653
|
+
}
|
|
10654
|
+
return ShaderVariant;
|
|
10655
|
+
}(EffectsObject);
|
|
10656
|
+
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10657
|
+
_inherits(Shader, EffectsObject);
|
|
10658
|
+
function Shader() {
|
|
10659
|
+
return EffectsObject.apply(this, arguments);
|
|
10660
|
+
}
|
|
10661
|
+
var _proto = Shader.prototype;
|
|
10662
|
+
_proto.createVariant = function createVariant(macros) {
|
|
10663
|
+
var shaderMacros = [];
|
|
10664
|
+
if (macros) {
|
|
10665
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10666
|
+
var key = _step.value;
|
|
10667
|
+
shaderMacros.push([
|
|
10668
|
+
key,
|
|
10669
|
+
macros[key]
|
|
10670
|
+
]);
|
|
10671
|
+
}
|
|
10672
|
+
}
|
|
10673
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10674
|
+
shaderVariant.shader = this;
|
|
10675
|
+
return shaderVariant;
|
|
10676
|
+
};
|
|
10677
|
+
_proto.fromData = function fromData(data) {
|
|
10678
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
10679
|
+
this.shaderData = data;
|
|
10680
|
+
};
|
|
10681
|
+
return Shader;
|
|
10682
|
+
}(EffectsObject);
|
|
10683
|
+
exports.Shader = __decorate([
|
|
10684
|
+
effectsClass(DataType.Shader)
|
|
10685
|
+
], exports.Shader);
|
|
10686
|
+
|
|
10963
10687
|
var _obj$5;
|
|
10964
10688
|
var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT, _obj$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT, _obj$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT, _obj$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT, _obj$5);
|
|
10965
10689
|
/**
|
|
@@ -13001,9 +12725,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
13001
12725
|
// Bloom 阈值 Pass
|
|
13002
12726
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
13003
12727
|
_inherits(BloomThresholdPass, RenderPass);
|
|
13004
|
-
function BloomThresholdPass(renderer
|
|
12728
|
+
function BloomThresholdPass(renderer) {
|
|
13005
12729
|
var _this;
|
|
13006
|
-
_this = RenderPass.call(this, renderer
|
|
12730
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13007
12731
|
var engine = _this.renderer.engine;
|
|
13008
12732
|
var geometry = Geometry.create(engine, {
|
|
13009
12733
|
mode: glContext.TRIANGLE_STRIP,
|
|
@@ -13042,12 +12766,11 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13042
12766
|
});
|
|
13043
12767
|
_this.priority = 5000;
|
|
13044
12768
|
_this.name = "BloomThresholdPass";
|
|
13045
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13046
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13047
12769
|
return _this;
|
|
13048
12770
|
}
|
|
13049
12771
|
var _proto = BloomThresholdPass.prototype;
|
|
13050
12772
|
_proto.configure = function configure(renderer) {
|
|
12773
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, renderer.getWidth(), renderer.getHeight(), 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13051
12774
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13052
12775
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
13053
12776
|
renderer.setFramebuffer(this.framebuffer);
|
|
@@ -13055,9 +12778,9 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13055
12778
|
_proto.execute = function execute(renderer) {
|
|
13056
12779
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
13057
12780
|
renderer.clear({
|
|
13058
|
-
colorAction: exports.
|
|
13059
|
-
depthAction: exports.
|
|
13060
|
-
stencilAction: exports.
|
|
12781
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12782
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12783
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13061
12784
|
});
|
|
13062
12785
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13063
12786
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
@@ -13067,23 +12790,21 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13067
12790
|
this.screenMesh
|
|
13068
12791
|
]);
|
|
13069
12792
|
};
|
|
13070
|
-
_proto.
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
12793
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12794
|
+
if (this.framebuffer) {
|
|
12795
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12796
|
+
}
|
|
13075
12797
|
};
|
|
13076
12798
|
_proto.dispose = function dispose(options) {
|
|
13077
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13078
12799
|
RenderPass.prototype.dispose.call(this, options);
|
|
13079
12800
|
};
|
|
13080
12801
|
return BloomThresholdPass;
|
|
13081
12802
|
}(RenderPass);
|
|
13082
12803
|
var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13083
12804
|
_inherits(HQGaussianDownSamplePass, RenderPass);
|
|
13084
|
-
function HQGaussianDownSamplePass(renderer, type, level
|
|
12805
|
+
function HQGaussianDownSamplePass(renderer, type, level) {
|
|
13085
12806
|
var _this;
|
|
13086
|
-
_this = RenderPass.call(this, renderer
|
|
12807
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13087
12808
|
_this.type = type;
|
|
13088
12809
|
_this.level = level;
|
|
13089
12810
|
var engine = _this.renderer.engine;
|
|
@@ -13130,25 +12851,21 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13130
12851
|
});
|
|
13131
12852
|
_this.priority = 5000;
|
|
13132
12853
|
_this.name = "GaussianDownPass" + type + level;
|
|
13133
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13134
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13135
12854
|
return _this;
|
|
13136
12855
|
}
|
|
13137
12856
|
var _proto = HQGaussianDownSamplePass.prototype;
|
|
13138
|
-
_proto.initialize = function initialize(renderer) {
|
|
13139
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13140
|
-
this.onResize();
|
|
13141
|
-
return this;
|
|
13142
|
-
};
|
|
13143
12857
|
_proto.configure = function configure(renderer) {
|
|
12858
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
|
|
12859
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
|
|
12860
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13144
12861
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13145
12862
|
renderer.setFramebuffer(this.framebuffer);
|
|
13146
12863
|
};
|
|
13147
12864
|
_proto.execute = function execute(renderer) {
|
|
13148
12865
|
renderer.clear({
|
|
13149
|
-
colorAction: exports.
|
|
13150
|
-
depthAction: exports.
|
|
13151
|
-
stencilAction: exports.
|
|
12866
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12867
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12868
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13152
12869
|
});
|
|
13153
12870
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13154
12871
|
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
@@ -13159,23 +12876,18 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13159
12876
|
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13160
12877
|
}
|
|
13161
12878
|
};
|
|
13162
|
-
_proto.
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13167
|
-
};
|
|
13168
|
-
_proto.dispose = function dispose(options) {
|
|
13169
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13170
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12879
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12880
|
+
if (this.framebuffer) {
|
|
12881
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12882
|
+
}
|
|
13171
12883
|
};
|
|
13172
12884
|
return HQGaussianDownSamplePass;
|
|
13173
12885
|
}(RenderPass);
|
|
13174
12886
|
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13175
12887
|
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
13176
|
-
function HQGaussianUpSamplePass(renderer, level
|
|
12888
|
+
function HQGaussianUpSamplePass(renderer, level) {
|
|
13177
12889
|
var _this;
|
|
13178
|
-
_this = RenderPass.call(this, renderer
|
|
12890
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13179
12891
|
_this.level = level;
|
|
13180
12892
|
var name = "PostProcess";
|
|
13181
12893
|
var engine = _this.renderer.engine;
|
|
@@ -13219,25 +12931,21 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13219
12931
|
});
|
|
13220
12932
|
_this.priority = 5000;
|
|
13221
12933
|
_this.name = "GaussianUpPass" + level;
|
|
13222
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13223
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13224
12934
|
return _this;
|
|
13225
12935
|
}
|
|
13226
12936
|
var _proto = HQGaussianUpSamplePass.prototype;
|
|
13227
|
-
_proto.initialize = function initialize(renderer) {
|
|
13228
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13229
|
-
this.onResize();
|
|
13230
|
-
return this;
|
|
13231
|
-
};
|
|
13232
12937
|
_proto.configure = function configure(renderer) {
|
|
12938
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
|
|
12939
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
|
|
12940
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13233
12941
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13234
12942
|
renderer.setFramebuffer(this.framebuffer);
|
|
13235
12943
|
};
|
|
13236
12944
|
_proto.execute = function execute(renderer) {
|
|
13237
12945
|
renderer.clear({
|
|
13238
|
-
colorAction: exports.
|
|
13239
|
-
depthAction: exports.
|
|
13240
|
-
stencilAction: exports.
|
|
12946
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12947
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12948
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13241
12949
|
});
|
|
13242
12950
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13243
12951
|
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
@@ -13246,15 +12954,10 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13246
12954
|
this.screenMesh
|
|
13247
12955
|
]);
|
|
13248
12956
|
};
|
|
13249
|
-
_proto.
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13254
|
-
};
|
|
13255
|
-
_proto.dispose = function dispose(options) {
|
|
13256
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13257
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12957
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12958
|
+
if (this.framebuffer) {
|
|
12959
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12960
|
+
}
|
|
13258
12961
|
};
|
|
13259
12962
|
return HQGaussianUpSamplePass;
|
|
13260
12963
|
}(RenderPass);
|
|
@@ -13263,7 +12966,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13263
12966
|
_inherits(ToneMappingPass, RenderPass);
|
|
13264
12967
|
function ToneMappingPass(renderer, sceneTextureHandle) {
|
|
13265
12968
|
var _this;
|
|
13266
|
-
_this = RenderPass.call(this, renderer
|
|
12969
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13267
12970
|
var name = "PostProcess";
|
|
13268
12971
|
var engine = _this.renderer.engine;
|
|
13269
12972
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
@@ -13319,9 +13022,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13319
13022
|
};
|
|
13320
13023
|
_proto.execute = function execute(renderer) {
|
|
13321
13024
|
renderer.clear({
|
|
13322
|
-
colorAction: exports.
|
|
13323
|
-
depthAction: exports.
|
|
13324
|
-
stencilAction: exports.
|
|
13025
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
13026
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
13027
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13325
13028
|
});
|
|
13326
13029
|
var globalVolume = renderer.renderingData.currentFrame.globalVolume;
|
|
13327
13030
|
var bloom = _extends({
|
|
@@ -13368,95 +13071,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13368
13071
|
return ToneMappingPass;
|
|
13369
13072
|
}(RenderPass);
|
|
13370
13073
|
|
|
13371
|
-
var SemanticMap = /*#__PURE__*/ function() {
|
|
13372
|
-
function SemanticMap(semantics) {
|
|
13373
|
-
if (semantics === void 0) semantics = {};
|
|
13374
|
-
this.semantics = _extends({}, semantics);
|
|
13375
|
-
}
|
|
13376
|
-
var _proto = SemanticMap.prototype;
|
|
13377
|
-
_proto.toObject = function toObject() {
|
|
13378
|
-
return _extends({}, this.semantics);
|
|
13379
|
-
};
|
|
13380
|
-
_proto.setSemantic = function setSemantic(name, value) {
|
|
13381
|
-
if (value === undefined) {
|
|
13382
|
-
delete this.semantics[name];
|
|
13383
|
-
} else {
|
|
13384
|
-
this.semantics[name] = value;
|
|
13385
|
-
}
|
|
13386
|
-
};
|
|
13387
|
-
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13388
|
-
var ret = this.semantics[name];
|
|
13389
|
-
if (isFunction(ret)) {
|
|
13390
|
-
return ret(state);
|
|
13391
|
-
}
|
|
13392
|
-
return ret;
|
|
13393
|
-
};
|
|
13394
|
-
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13395
|
-
return name in this.semantics;
|
|
13396
|
-
};
|
|
13397
|
-
_proto.dispose = function dispose() {
|
|
13398
|
-
var _this = this;
|
|
13399
|
-
Object.keys(this.semantics).forEach(function(name) {
|
|
13400
|
-
delete _this.semantics[name];
|
|
13401
|
-
});
|
|
13402
|
-
};
|
|
13403
|
-
return SemanticMap;
|
|
13404
|
-
}();
|
|
13405
|
-
|
|
13406
|
-
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
13407
13074
|
var seed$5 = 1;
|
|
13408
13075
|
/**
|
|
13409
13076
|
* RenderFrame 抽象类
|
|
13410
13077
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
13411
13078
|
function RenderFrame(options) {
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
this.
|
|
13415
|
-
|
|
13416
|
-
this.renderPassInfoMap = new WeakMap();
|
|
13417
|
-
var camera = options.camera, keepColorBuffer = options.keepColorBuffer, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13079
|
+
this.disposed = false;
|
|
13080
|
+
this.postProcessingEnabled = false;
|
|
13081
|
+
this.enableHDR = true;
|
|
13082
|
+
var camera = options.camera, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13418
13083
|
1,
|
|
13419
13084
|
1,
|
|
13420
13085
|
0,
|
|
13421
13086
|
0
|
|
13422
|
-
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled
|
|
13423
|
-
colorAction: exports.TextureLoadAction.whatever,
|
|
13424
|
-
stencilAction: exports.TextureLoadAction.clear,
|
|
13425
|
-
depthAction: exports.TextureLoadAction.whatever
|
|
13426
|
-
} : _options_clearAction;
|
|
13087
|
+
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
|
|
13427
13088
|
var engine = renderer.engine;
|
|
13428
13089
|
if (globalVolume) {
|
|
13429
13090
|
this.globalVolume = globalVolume;
|
|
13430
13091
|
}
|
|
13092
|
+
this.postProcessingEnabled = postProcessingEnabled;
|
|
13431
13093
|
this.globalUniforms = new GlobalUniforms();
|
|
13432
|
-
var attachments = []; //渲染场景物体Pass的RT
|
|
13433
|
-
var depthStencilAttachment;
|
|
13434
13094
|
this.renderer = renderer;
|
|
13435
|
-
if (postProcessingEnabled) {
|
|
13436
|
-
|
|
13437
|
-
if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13438
|
-
throw new Error("Half float texture is not supported.");
|
|
13439
|
-
}
|
|
13440
|
-
// 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
|
|
13441
|
-
var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13442
|
-
attachments = [
|
|
13443
|
-
{
|
|
13444
|
-
texture: {
|
|
13445
|
-
format: glContext.RGBA,
|
|
13446
|
-
type: textureType,
|
|
13447
|
-
magFilter: glContext.LINEAR,
|
|
13448
|
-
minFilter: glContext.LINEAR
|
|
13449
|
-
}
|
|
13450
|
-
}
|
|
13451
|
-
];
|
|
13452
|
-
depthStencilAttachment = {
|
|
13453
|
-
storageType: exports.RenderPassAttachmentStorageType.depth_stencil_opaque
|
|
13454
|
-
};
|
|
13095
|
+
if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13096
|
+
throw new Error("Half float texture is not supported.");
|
|
13455
13097
|
}
|
|
13456
|
-
this.drawObjectPass = new DrawObjectPass(renderer
|
|
13457
|
-
depthStencilAttachment: depthStencilAttachment,
|
|
13458
|
-
attachments: attachments
|
|
13459
|
-
});
|
|
13098
|
+
this.drawObjectPass = new DrawObjectPass(renderer);
|
|
13460
13099
|
var renderPasses = [
|
|
13461
13100
|
this.drawObjectPass
|
|
13462
13101
|
];
|
|
@@ -13471,48 +13110,13 @@ var seed$5 = 1;
|
|
|
13471
13110
|
this.renderer.getHeight() / 2
|
|
13472
13111
|
];
|
|
13473
13112
|
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13474
|
-
var
|
|
13475
|
-
var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13476
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer, {
|
|
13477
|
-
attachments: [
|
|
13478
|
-
{
|
|
13479
|
-
texture: {
|
|
13480
|
-
format: glContext.RGBA,
|
|
13481
|
-
type: textureType1,
|
|
13482
|
-
minFilter: glContext.LINEAR,
|
|
13483
|
-
magFilter: glContext.LINEAR
|
|
13484
|
-
}
|
|
13485
|
-
}
|
|
13486
|
-
]
|
|
13487
|
-
});
|
|
13113
|
+
var bloomThresholdPass = new BloomThresholdPass(renderer);
|
|
13488
13114
|
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13489
13115
|
this.addRenderPass(bloomThresholdPass);
|
|
13490
13116
|
for(var i = 0; i < gaussianStep; i++){
|
|
13491
13117
|
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13492
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i
|
|
13493
|
-
|
|
13494
|
-
{
|
|
13495
|
-
texture: {
|
|
13496
|
-
format: glContext.RGBA,
|
|
13497
|
-
type: textureType1,
|
|
13498
|
-
minFilter: glContext.LINEAR,
|
|
13499
|
-
magFilter: glContext.LINEAR
|
|
13500
|
-
}
|
|
13501
|
-
}
|
|
13502
|
-
]
|
|
13503
|
-
});
|
|
13504
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
|
|
13505
|
-
attachments: [
|
|
13506
|
-
{
|
|
13507
|
-
texture: {
|
|
13508
|
-
format: glContext.RGBA,
|
|
13509
|
-
type: textureType1,
|
|
13510
|
-
minFilter: glContext.LINEAR,
|
|
13511
|
-
magFilter: glContext.LINEAR
|
|
13512
|
-
}
|
|
13513
|
-
}
|
|
13514
|
-
]
|
|
13515
|
-
});
|
|
13118
|
+
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i);
|
|
13119
|
+
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i);
|
|
13516
13120
|
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13517
13121
|
this.addRenderPass(gaussianDownHPass);
|
|
13518
13122
|
this.addRenderPass(gaussianDownVPass);
|
|
@@ -13523,18 +13127,7 @@ var seed$5 = 1;
|
|
|
13523
13127
|
viewport[2] *= 4;
|
|
13524
13128
|
viewport[3] *= 4;
|
|
13525
13129
|
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13526
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1
|
|
13527
|
-
attachments: [
|
|
13528
|
-
{
|
|
13529
|
-
texture: {
|
|
13530
|
-
format: glContext.RGBA,
|
|
13531
|
-
type: textureType1,
|
|
13532
|
-
minFilter: glContext.LINEAR,
|
|
13533
|
-
magFilter: glContext.LINEAR
|
|
13534
|
-
}
|
|
13535
|
-
}
|
|
13536
|
-
]
|
|
13537
|
-
});
|
|
13130
|
+
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1);
|
|
13538
13131
|
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13539
13132
|
this.addRenderPass(gaussianUpPass);
|
|
13540
13133
|
viewport[2] *= 2;
|
|
@@ -13543,31 +13136,17 @@ var seed$5 = 1;
|
|
|
13543
13136
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13544
13137
|
this.addRenderPass(postProcessPass);
|
|
13545
13138
|
}
|
|
13546
|
-
this.semantics = new SemanticMap(options.semantics);
|
|
13547
|
-
this.clearAction = clearAction;
|
|
13548
13139
|
this.name = "RenderFrame" + seed$5++;
|
|
13549
|
-
var firstRP = renderPasses[0];
|
|
13550
13140
|
this.camera = camera;
|
|
13551
|
-
this.keepColorBuffer = keepColorBuffer;
|
|
13552
|
-
this.renderPassInfoMap.set(firstRP, {
|
|
13553
|
-
listStart: 0,
|
|
13554
|
-
listEnd: 0,
|
|
13555
|
-
renderPass: firstRP,
|
|
13556
|
-
intermedia: false
|
|
13557
|
-
});
|
|
13558
13141
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
13559
|
-
if (!options.clearAction) {
|
|
13560
|
-
this.resetClearActions();
|
|
13561
|
-
}
|
|
13562
|
-
this.passTextureCache = new PassTextureCache(engine);
|
|
13563
|
-
// FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
|
|
13564
|
-
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
13565
|
-
var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
|
|
13566
|
-
var shader = createCopyShader(level, writeDepth);
|
|
13567
|
-
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
13568
13142
|
}
|
|
13569
13143
|
var _proto = RenderFrame.prototype;
|
|
13570
13144
|
/**
|
|
13145
|
+
* 设置 RenderPasses 参数,此函数每帧调用一次
|
|
13146
|
+
*/ _proto.setup = function setup() {
|
|
13147
|
+
this.drawObjectPass.setup(this.postProcessingEnabled);
|
|
13148
|
+
};
|
|
13149
|
+
/**
|
|
13571
13150
|
* 根据 Mesh 优先级添加到 RenderPass
|
|
13572
13151
|
* @param mesh - 要添加的 Mesh 对象
|
|
13573
13152
|
*/ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
|
|
@@ -13584,78 +13163,25 @@ var seed$5 = 1;
|
|
|
13584
13163
|
* 销毁 RenderFrame
|
|
13585
13164
|
* @param options - 可以有选择销毁一些对象
|
|
13586
13165
|
*/ _proto.dispose = function dispose(options) {
|
|
13587
|
-
if ((options == null ? void 0 : options.semantics) !== exports.DestroyOptions.keep) {
|
|
13588
|
-
this.semantics.dispose();
|
|
13589
|
-
}
|
|
13590
13166
|
var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
|
|
13591
13167
|
if (pass !== exports.DestroyOptions.keep) {
|
|
13592
13168
|
this._renderPasses.forEach(function(renderPass) {
|
|
13593
13169
|
renderPass.dispose(pass);
|
|
13594
13170
|
});
|
|
13595
13171
|
}
|
|
13596
|
-
this.passTextureCache.dispose();
|
|
13597
13172
|
this._renderPasses.length = 0;
|
|
13598
|
-
this.
|
|
13599
|
-
};
|
|
13600
|
-
/**
|
|
13601
|
-
* 查找 Mesh 所在的 RenderPass 索引,没找到是-1
|
|
13602
|
-
* @param mesh - 需要查找的 Mesh
|
|
13603
|
-
*/ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
|
|
13604
|
-
var index = -1;
|
|
13605
|
-
this.renderPasses.every(function(rp, idx) {
|
|
13606
|
-
if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
|
|
13607
|
-
index = idx;
|
|
13608
|
-
return false;
|
|
13609
|
-
}
|
|
13610
|
-
return true;
|
|
13611
|
-
});
|
|
13612
|
-
return index;
|
|
13613
|
-
};
|
|
13614
|
-
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
13615
|
-
var info = this.renderPassInfoMap.get(renderPass);
|
|
13616
|
-
var priority = mesh.priority;
|
|
13617
|
-
if (!info) {
|
|
13618
|
-
return;
|
|
13619
|
-
}
|
|
13620
|
-
if (renderPass.meshes.length === 0) {
|
|
13621
|
-
info.listStart = info.listEnd = priority;
|
|
13622
|
-
} else {
|
|
13623
|
-
if (priority < info.listStart) {
|
|
13624
|
-
info.listStart = priority;
|
|
13625
|
-
} else if (priority > info.listEnd) {
|
|
13626
|
-
info.listEnd = priority;
|
|
13627
|
-
}
|
|
13628
|
-
}
|
|
13629
|
-
renderPass.addMesh(mesh);
|
|
13630
|
-
};
|
|
13631
|
-
_proto.resetClearActions = function resetClearActions() {
|
|
13632
|
-
var action = this.renderPasses.length > 1 ? exports.TextureLoadAction.clear : exports.TextureLoadAction.whatever;
|
|
13633
|
-
this.clearAction.stencilAction = action;
|
|
13634
|
-
this.clearAction.depthAction = action;
|
|
13635
|
-
this.clearAction.colorAction = action;
|
|
13636
|
-
if (this.keepColorBuffer) {
|
|
13637
|
-
this.clearAction.colorAction = exports.TextureLoadAction.whatever;
|
|
13638
|
-
}
|
|
13173
|
+
this.disposed = true;
|
|
13639
13174
|
};
|
|
13640
13175
|
/**
|
|
13641
13176
|
* 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
|
|
13642
13177
|
* @param passes - RenderPass 数组
|
|
13643
13178
|
*/ _proto.setRenderPasses = function setRenderPasses(passes) {
|
|
13644
|
-
var _this = this;
|
|
13645
|
-
if (this.renderer !== undefined) {
|
|
13646
|
-
passes.forEach(function(pass) {
|
|
13647
|
-
return pass.initialize(_this.renderer);
|
|
13648
|
-
});
|
|
13649
|
-
}
|
|
13650
13179
|
this._renderPasses = passes.slice();
|
|
13651
13180
|
};
|
|
13652
13181
|
/**
|
|
13653
13182
|
* 添加 RenderPass
|
|
13654
13183
|
* @param pass - 需要添加的 RenderPass
|
|
13655
13184
|
*/ _proto.addRenderPass = function addRenderPass(pass) {
|
|
13656
|
-
if (this.renderer !== undefined) {
|
|
13657
|
-
pass.initialize(this.renderer);
|
|
13658
|
-
}
|
|
13659
13185
|
this._renderPasses.push(pass);
|
|
13660
13186
|
};
|
|
13661
13187
|
/**
|
|
@@ -13672,9 +13198,9 @@ var seed$5 = 1;
|
|
|
13672
13198
|
}
|
|
13673
13199
|
},
|
|
13674
13200
|
{
|
|
13675
|
-
key: "
|
|
13201
|
+
key: "isDisposed",
|
|
13676
13202
|
get: function get() {
|
|
13677
|
-
return this.
|
|
13203
|
+
return this.disposed;
|
|
13678
13204
|
}
|
|
13679
13205
|
}
|
|
13680
13206
|
]);
|
|
@@ -13683,10 +13209,6 @@ var seed$5 = 1;
|
|
|
13683
13209
|
function getTextureSize(tex) {
|
|
13684
13210
|
return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
|
|
13685
13211
|
}
|
|
13686
|
-
function findPreviousRenderPass(renderPasses, renderPass) {
|
|
13687
|
-
var index = renderPasses.indexOf(renderPass);
|
|
13688
|
-
return renderPasses[index - 1];
|
|
13689
|
-
}
|
|
13690
13212
|
var GlobalUniforms = function GlobalUniforms() {
|
|
13691
13213
|
this.floats = {};
|
|
13692
13214
|
this.ints = {};
|
|
@@ -13724,6 +13246,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
|
|
|
13724
13246
|
return Renderbuffer;
|
|
13725
13247
|
}();
|
|
13726
13248
|
|
|
13249
|
+
var RenderTargetPool = /*#__PURE__*/ function() {
|
|
13250
|
+
function RenderTargetPool(engine) {
|
|
13251
|
+
this.engine = engine;
|
|
13252
|
+
this.temporaryRTs = [];
|
|
13253
|
+
this.currentFrame = 0;
|
|
13254
|
+
this.maxUnusedFrames = 4;
|
|
13255
|
+
}
|
|
13256
|
+
var _proto = RenderTargetPool.prototype;
|
|
13257
|
+
/**
|
|
13258
|
+
* 清理 RenderTarget 池
|
|
13259
|
+
* @param force - 是否强制清理所有未占用的 RT
|
|
13260
|
+
* @param framesOffset - 自定义未使用帧数阈值,-1 表示使用默认值
|
|
13261
|
+
*/ _proto.flush = function flush(force, framesOffset) {
|
|
13262
|
+
if (force === void 0) force = false;
|
|
13263
|
+
if (framesOffset === void 0) framesOffset = -1;
|
|
13264
|
+
this.currentFrame++;
|
|
13265
|
+
var threshold = framesOffset >= 0 ? framesOffset : this.maxUnusedFrames;
|
|
13266
|
+
for(var i = 0; i < this.temporaryRTs.length; i++){
|
|
13267
|
+
var entry = this.temporaryRTs[i];
|
|
13268
|
+
// 强制清理所有未占用的 RT,或清理超过阈值帧数未使用的 RT
|
|
13269
|
+
if (!entry.isOccupied && (force || this.currentFrame - entry.lastFrameReleased > threshold)) {
|
|
13270
|
+
entry.RT.dispose();
|
|
13271
|
+
this.temporaryRTs.splice(i--, 1);
|
|
13272
|
+
}
|
|
13273
|
+
}
|
|
13274
|
+
};
|
|
13275
|
+
_proto.get = function get(name, width, height, depthBuffer, filter, format) {
|
|
13276
|
+
if (depthBuffer === void 0) depthBuffer = 0;
|
|
13277
|
+
if (filter === void 0) filter = exports.FilterMode.Linear;
|
|
13278
|
+
if (format === void 0) format = exports.RenderTextureFormat.RGBA32;
|
|
13279
|
+
// 使用参数计算 hash 值作为缓存 key
|
|
13280
|
+
var hash = width + "_" + height + "_" + depthBuffer + "_" + filter + "_" + format;
|
|
13281
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13282
|
+
var entry = _step.value;
|
|
13283
|
+
if (!entry.isOccupied && entry.descriptionHash === hash) {
|
|
13284
|
+
entry.isOccupied = true;
|
|
13285
|
+
entry.RT.name = name;
|
|
13286
|
+
return entry.RT;
|
|
13287
|
+
}
|
|
13288
|
+
}
|
|
13289
|
+
var textureFilter;
|
|
13290
|
+
var textureType;
|
|
13291
|
+
var depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13292
|
+
// TODO 建立Map映射
|
|
13293
|
+
if (filter === exports.FilterMode.Linear) {
|
|
13294
|
+
textureFilter = glContext.LINEAR;
|
|
13295
|
+
} else if (filter === exports.FilterMode.Nearest) {
|
|
13296
|
+
textureFilter = glContext.NEAREST;
|
|
13297
|
+
}
|
|
13298
|
+
if (format === exports.RenderTextureFormat.RGBA32) {
|
|
13299
|
+
textureType = glContext.UNSIGNED_BYTE;
|
|
13300
|
+
} else if (format === exports.RenderTextureFormat.RGBAHalf) {
|
|
13301
|
+
textureType = glContext.HALF_FLOAT;
|
|
13302
|
+
}
|
|
13303
|
+
if (depthBuffer === 0) {
|
|
13304
|
+
depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13305
|
+
} else if (depthBuffer === 16) {
|
|
13306
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_stencil_opaque;
|
|
13307
|
+
} else if (depthBuffer === 24) {
|
|
13308
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_24_stencil_8_texture;
|
|
13309
|
+
}
|
|
13310
|
+
var colorAttachment = Texture.create(this.engine, {
|
|
13311
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
13312
|
+
minFilter: textureFilter,
|
|
13313
|
+
magFilter: textureFilter,
|
|
13314
|
+
internalFormat: glContext.RGBA,
|
|
13315
|
+
format: glContext.RGBA,
|
|
13316
|
+
type: textureType
|
|
13317
|
+
});
|
|
13318
|
+
var newFramebuffer = Framebuffer.create({
|
|
13319
|
+
name: name,
|
|
13320
|
+
storeAction: {},
|
|
13321
|
+
viewport: [
|
|
13322
|
+
0,
|
|
13323
|
+
0,
|
|
13324
|
+
width,
|
|
13325
|
+
height
|
|
13326
|
+
],
|
|
13327
|
+
attachments: [
|
|
13328
|
+
colorAttachment
|
|
13329
|
+
],
|
|
13330
|
+
depthStencilAttachment: {
|
|
13331
|
+
storageType: depthType
|
|
13332
|
+
}
|
|
13333
|
+
}, this.engine.renderer);
|
|
13334
|
+
var entry1 = {
|
|
13335
|
+
RT: newFramebuffer,
|
|
13336
|
+
lastFrameReleased: 0,
|
|
13337
|
+
descriptionHash: hash,
|
|
13338
|
+
isOccupied: true
|
|
13339
|
+
};
|
|
13340
|
+
this.temporaryRTs.push(entry1);
|
|
13341
|
+
return entry1.RT;
|
|
13342
|
+
};
|
|
13343
|
+
/**
|
|
13344
|
+
* 释放 RenderTarget,使其可以被复用
|
|
13345
|
+
* @param rt - 要释放的 Framebuffer
|
|
13346
|
+
*/ _proto.release = function release(rt) {
|
|
13347
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13348
|
+
var entry = _step.value;
|
|
13349
|
+
if (entry.RT === rt) {
|
|
13350
|
+
entry.isOccupied = false;
|
|
13351
|
+
entry.lastFrameReleased = this.currentFrame;
|
|
13352
|
+
break;
|
|
13353
|
+
}
|
|
13354
|
+
}
|
|
13355
|
+
};
|
|
13356
|
+
_proto.dispose = function dispose() {
|
|
13357
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13358
|
+
var entry = _step.value;
|
|
13359
|
+
entry.RT.dispose();
|
|
13360
|
+
}
|
|
13361
|
+
};
|
|
13362
|
+
return RenderTargetPool;
|
|
13363
|
+
}();
|
|
13364
|
+
|
|
13727
13365
|
var isWebGL2Available = typeof WebGL2RenderingContext === "function";
|
|
13728
13366
|
var GPUCapability = /*#__PURE__*/ function() {
|
|
13729
13367
|
function GPUCapability(gl) {
|
|
@@ -13909,70 +13547,11 @@ exports.CompressTextureCapabilityType = void 0;
|
|
|
13909
13547
|
return !!hasCompressedTextureSupport;
|
|
13910
13548
|
}
|
|
13911
13549
|
|
|
13912
|
-
exports.FilterMode = void 0;
|
|
13913
|
-
(function(FilterMode) {
|
|
13914
|
-
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
13915
|
-
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
13916
|
-
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
13917
|
-
exports.RenderTextureFormat = void 0;
|
|
13918
|
-
(function(RenderTextureFormat) {
|
|
13919
|
-
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
13920
|
-
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
13921
|
-
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
13922
|
-
/**
|
|
13923
|
-
*
|
|
13924
|
-
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
13925
|
-
function Framebuffer() {}
|
|
13926
|
-
var _proto = Framebuffer.prototype;
|
|
13927
|
-
_proto.resize = function resize(x, y, width, height) {
|
|
13928
|
-
// OVERRIDE
|
|
13929
|
-
};
|
|
13930
|
-
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
13931
|
-
// OVERRIDE
|
|
13932
|
-
};
|
|
13933
|
-
_proto.unbind = function unbind() {
|
|
13934
|
-
// OVERRIDE
|
|
13935
|
-
};
|
|
13936
|
-
_proto.bind = function bind() {
|
|
13937
|
-
// OVERRIDE
|
|
13938
|
-
};
|
|
13939
|
-
_proto.getDepthTexture = function getDepthTexture() {
|
|
13940
|
-
// OVERRIDE
|
|
13941
|
-
return undefined;
|
|
13942
|
-
};
|
|
13943
|
-
_proto.getStencilTexture = function getStencilTexture() {
|
|
13944
|
-
// OVERRIDE
|
|
13945
|
-
return undefined;
|
|
13946
|
-
};
|
|
13947
|
-
_proto.getColorTextures = function getColorTextures() {
|
|
13948
|
-
// OVERRIDE
|
|
13949
|
-
return [];
|
|
13950
|
-
};
|
|
13951
|
-
_proto.dispose = function dispose(options) {
|
|
13952
|
-
// OVERRIDE
|
|
13953
|
-
};
|
|
13954
|
-
_create_class(Framebuffer, [
|
|
13955
|
-
{
|
|
13956
|
-
key: "stencilStorage",
|
|
13957
|
-
get: function get() {
|
|
13958
|
-
// OVERRIDE
|
|
13959
|
-
return undefined;
|
|
13960
|
-
}
|
|
13961
|
-
},
|
|
13962
|
-
{
|
|
13963
|
-
key: "depthStorage",
|
|
13964
|
-
get: function get() {
|
|
13965
|
-
// OVERRIDE
|
|
13966
|
-
return undefined;
|
|
13967
|
-
}
|
|
13968
|
-
}
|
|
13969
|
-
]);
|
|
13970
|
-
return Framebuffer;
|
|
13971
|
-
}();
|
|
13972
|
-
|
|
13973
13550
|
var Renderer = /*#__PURE__*/ function() {
|
|
13974
13551
|
function Renderer(engine) {
|
|
13975
13552
|
this.engine = engine;
|
|
13553
|
+
this.currentFramebuffer = null;
|
|
13554
|
+
this.renderTargetPool = new RenderTargetPool(engine);
|
|
13976
13555
|
}
|
|
13977
13556
|
var _proto = Renderer.prototype;
|
|
13978
13557
|
_proto.setGlobalFloat = function setGlobalFloat(name, value) {
|
|
@@ -14042,8 +13621,10 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14042
13621
|
// OVERRIDE
|
|
14043
13622
|
};
|
|
14044
13623
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
14045
|
-
|
|
14046
|
-
|
|
13624
|
+
return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
13625
|
+
};
|
|
13626
|
+
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13627
|
+
this.renderTargetPool.release(rt);
|
|
14047
13628
|
};
|
|
14048
13629
|
_proto.dispose = function dispose() {
|
|
14049
13630
|
// OVERRIDE
|
|
@@ -14051,6 +13632,41 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14051
13632
|
return Renderer;
|
|
14052
13633
|
}();
|
|
14053
13634
|
|
|
13635
|
+
var SemanticMap = /*#__PURE__*/ function() {
|
|
13636
|
+
function SemanticMap(semantics) {
|
|
13637
|
+
if (semantics === void 0) semantics = {};
|
|
13638
|
+
this.semantics = _extends({}, semantics);
|
|
13639
|
+
}
|
|
13640
|
+
var _proto = SemanticMap.prototype;
|
|
13641
|
+
_proto.toObject = function toObject() {
|
|
13642
|
+
return _extends({}, this.semantics);
|
|
13643
|
+
};
|
|
13644
|
+
_proto.setSemantic = function setSemantic(name, value) {
|
|
13645
|
+
if (value === undefined) {
|
|
13646
|
+
delete this.semantics[name];
|
|
13647
|
+
} else {
|
|
13648
|
+
this.semantics[name] = value;
|
|
13649
|
+
}
|
|
13650
|
+
};
|
|
13651
|
+
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13652
|
+
var ret = this.semantics[name];
|
|
13653
|
+
if (isFunction(ret)) {
|
|
13654
|
+
return ret(state);
|
|
13655
|
+
}
|
|
13656
|
+
return ret;
|
|
13657
|
+
};
|
|
13658
|
+
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13659
|
+
return name in this.semantics;
|
|
13660
|
+
};
|
|
13661
|
+
_proto.dispose = function dispose() {
|
|
13662
|
+
var _this = this;
|
|
13663
|
+
Object.keys(this.semantics).forEach(function(name) {
|
|
13664
|
+
delete _this.semantics[name];
|
|
13665
|
+
});
|
|
13666
|
+
};
|
|
13667
|
+
return SemanticMap;
|
|
13668
|
+
}();
|
|
13669
|
+
|
|
14054
13670
|
/**
|
|
14055
13671
|
* @since 2.7.0
|
|
14056
13672
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -18081,6 +17697,11 @@ exports.PlayState = void 0;
|
|
|
18081
17697
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
18082
17698
|
})(exports.PlayState || (exports.PlayState = {}));
|
|
18083
17699
|
|
|
17700
|
+
function _assert_this_initialized(self) {
|
|
17701
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17702
|
+
return self;
|
|
17703
|
+
}
|
|
17704
|
+
|
|
18084
17705
|
var tempQuat$1 = new Quaternion();
|
|
18085
17706
|
var tempVector3 = new Vector3();
|
|
18086
17707
|
var tempVector3Second = new Vector3();
|
|
@@ -24458,8 +24079,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24458
24079
|
_this.reusable = reusable;
|
|
24459
24080
|
_this.speed = speed;
|
|
24460
24081
|
_this.name = sourceContent.name;
|
|
24461
|
-
_this
|
|
24462
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24082
|
+
PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24463
24083
|
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24464
24084
|
aspect: width / height,
|
|
24465
24085
|
pixelWidth: width,
|
|
@@ -24473,7 +24093,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24473
24093
|
_this.createRenderFrame();
|
|
24474
24094
|
Composition.buildItemTree(_this.rootItem);
|
|
24475
24095
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
24476
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24477
24096
|
return _this;
|
|
24478
24097
|
}
|
|
24479
24098
|
var _proto = Composition.prototype;
|
|
@@ -24583,12 +24202,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24583
24202
|
this.renderFrame = new RenderFrame({
|
|
24584
24203
|
camera: this.camera,
|
|
24585
24204
|
renderer: this.renderer,
|
|
24586
|
-
keepColorBuffer: this.keepColorBuffer,
|
|
24587
24205
|
globalVolume: this.globalVolume,
|
|
24588
24206
|
postProcessingEnabled: this.postProcessingEnabled
|
|
24589
24207
|
});
|
|
24590
|
-
// TODO 考虑放到构造函数
|
|
24591
|
-
this.renderFrame.cachedTextures = this.textures;
|
|
24592
24208
|
};
|
|
24593
24209
|
/**
|
|
24594
24210
|
* 跳到指定时间点(不做任何播放行为)
|
|
@@ -24639,7 +24255,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24639
24255
|
this.isEnded = false;
|
|
24640
24256
|
this.isEndCalled = false;
|
|
24641
24257
|
this.rootComposition.time = 0;
|
|
24642
|
-
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24643
24258
|
};
|
|
24644
24259
|
_proto.prepareRender = function prepareRender() {};
|
|
24645
24260
|
/**
|
|
@@ -24657,8 +24272,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24657
24272
|
var previousCompositionTime = this.time;
|
|
24658
24273
|
this.updateCompositionTime(deltaTime * this.speed / 1000);
|
|
24659
24274
|
var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
|
|
24660
|
-
// 更新 model-tree-plugin
|
|
24661
|
-
this.updatePluginLoaders(deltaTimeInMs);
|
|
24662
24275
|
this.sceneTicking.update.tick(deltaTimeInMs);
|
|
24663
24276
|
this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
|
|
24664
24277
|
this.updateCamera();
|
|
@@ -24683,15 +24296,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24683
24296
|
this.camera.updateMatrix();
|
|
24684
24297
|
};
|
|
24685
24298
|
/**
|
|
24686
|
-
* 插件更新,来自 CompVFXItem 的更新调用
|
|
24687
|
-
* @param deltaTime - 更新的时间步长
|
|
24688
|
-
*/ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
|
|
24689
|
-
var _this = this;
|
|
24690
|
-
this.pluginSystem.plugins.forEach(function(loader) {
|
|
24691
|
-
return loader.onCompositionUpdate(_this, deltaTime);
|
|
24692
|
-
});
|
|
24693
|
-
};
|
|
24694
|
-
/**
|
|
24695
24299
|
* 更新主合成组件
|
|
24696
24300
|
*/ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
|
|
24697
24301
|
if (this.rootComposition.state === exports.PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
|
|
@@ -24850,7 +24454,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24850
24454
|
* 合成对象销毁
|
|
24851
24455
|
*/ _proto.dispose = function dispose() {
|
|
24852
24456
|
var _this = this;
|
|
24853
|
-
var _this_pluginSystem;
|
|
24854
24457
|
if (this.destroyed) {
|
|
24855
24458
|
return;
|
|
24856
24459
|
}
|
|
@@ -24870,13 +24473,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24870
24473
|
this.rootItem.dispose();
|
|
24871
24474
|
// FIXME: 注意这里增加了renderFrame销毁
|
|
24872
24475
|
this.renderFrame.dispose();
|
|
24873
|
-
|
|
24476
|
+
PluginSystem.destroyComposition(this);
|
|
24874
24477
|
this.update = function() {
|
|
24875
24478
|
{
|
|
24876
24479
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
24877
24480
|
}
|
|
24878
24481
|
};
|
|
24879
24482
|
this.dispose = noop;
|
|
24483
|
+
this.renderer.engine.removeComposition(this);
|
|
24880
24484
|
if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
24881
24485
|
return;
|
|
24882
24486
|
}
|
|
@@ -24893,7 +24497,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24893
24497
|
0
|
|
24894
24498
|
]
|
|
24895
24499
|
});
|
|
24896
|
-
this.renderer.engine.removeComposition(this);
|
|
24897
24500
|
};
|
|
24898
24501
|
/**
|
|
24899
24502
|
* 编辑器使用的 transform 修改方法
|
|
@@ -31868,7 +31471,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31868
31471
|
return ret;
|
|
31869
31472
|
}
|
|
31870
31473
|
|
|
31871
|
-
var version$1 = "2.8.0-alpha.
|
|
31474
|
+
var version$1 = "2.8.0-alpha.2";
|
|
31872
31475
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31873
31476
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31874
31477
|
var reverseParticle = false;
|
|
@@ -32383,7 +31986,7 @@ var seed = 1;
|
|
|
32383
31986
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
32384
31987
|
* @param options - 扩展参数
|
|
32385
31988
|
* @returns
|
|
32386
|
-
*/ _proto.loadScene = function loadScene(url, renderer
|
|
31989
|
+
*/ _proto.loadScene = function loadScene(url, renderer) {
|
|
32387
31990
|
var _this = this;
|
|
32388
31991
|
return _async_to_generator(function() {
|
|
32389
31992
|
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
@@ -32444,7 +32047,7 @@ var seed = 1;
|
|
|
32444
32047
|
});
|
|
32445
32048
|
});
|
|
32446
32049
|
loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
|
|
32447
|
-
var scene, link,
|
|
32050
|
+
var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
|
|
32448
32051
|
return __generator(this, function(_state) {
|
|
32449
32052
|
switch(_state.label){
|
|
32450
32053
|
case 0:
|
|
@@ -32494,7 +32097,26 @@ var seed = 1;
|
|
|
32494
32097
|
})
|
|
32495
32098
|
];
|
|
32496
32099
|
case 5:
|
|
32497
|
-
|
|
32100
|
+
jsonScene = _state.sent().jsonScene;
|
|
32101
|
+
scene = {
|
|
32102
|
+
timeInfos: timeInfos,
|
|
32103
|
+
url: url,
|
|
32104
|
+
storage: {},
|
|
32105
|
+
jsonScene: jsonScene,
|
|
32106
|
+
bins: [],
|
|
32107
|
+
textureOptions: [],
|
|
32108
|
+
textures: [],
|
|
32109
|
+
images: [],
|
|
32110
|
+
assets: _this.assets
|
|
32111
|
+
};
|
|
32112
|
+
return [
|
|
32113
|
+
4,
|
|
32114
|
+
hookTimeInfo("plugin:processAssets", function() {
|
|
32115
|
+
return _this.processPluginAssets(scene);
|
|
32116
|
+
})
|
|
32117
|
+
];
|
|
32118
|
+
case 6:
|
|
32119
|
+
_state.sent();
|
|
32498
32120
|
_jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
|
|
32499
32121
|
return [
|
|
32500
32122
|
4,
|
|
@@ -32505,46 +32127,26 @@ var seed = 1;
|
|
|
32505
32127
|
hookTimeInfo("processImages", function() {
|
|
32506
32128
|
return _this.processImages(images, isKTX2Supported);
|
|
32507
32129
|
}),
|
|
32508
|
-
hookTimeInfo("plugin:processAssets", function() {
|
|
32509
|
-
return _this.processPluginAssets(jsonScene, pluginSystem, options);
|
|
32510
|
-
}),
|
|
32511
32130
|
hookTimeInfo("processFontURL", function() {
|
|
32512
32131
|
return _this.processFontURL(fonts);
|
|
32513
32132
|
})
|
|
32514
32133
|
])
|
|
32515
32134
|
];
|
|
32516
|
-
case
|
|
32517
|
-
|
|
32135
|
+
case 7:
|
|
32136
|
+
_ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
|
|
32518
32137
|
return [
|
|
32519
32138
|
4,
|
|
32520
32139
|
hookTimeInfo("processTextures", function() {
|
|
32521
32140
|
return _this.processTextures(loadedImages, loadedBins, jsonScene);
|
|
32522
32141
|
})
|
|
32523
32142
|
];
|
|
32524
|
-
case 7:
|
|
32525
|
-
loadedTextures = _state.sent();
|
|
32526
|
-
scene = {
|
|
32527
|
-
timeInfos: timeInfos,
|
|
32528
|
-
url: url,
|
|
32529
|
-
renderLevel: _this.options.renderLevel,
|
|
32530
|
-
storage: {},
|
|
32531
|
-
pluginSystem: pluginSystem,
|
|
32532
|
-
jsonScene: jsonScene,
|
|
32533
|
-
bins: loadedBins,
|
|
32534
|
-
textureOptions: loadedTextures,
|
|
32535
|
-
textures: [],
|
|
32536
|
-
images: loadedImages,
|
|
32537
|
-
assets: _this.assets
|
|
32538
|
-
};
|
|
32539
|
-
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
32540
|
-
return [
|
|
32541
|
-
4,
|
|
32542
|
-
hookTimeInfo("plugin:prepareResource", function() {
|
|
32543
|
-
return pluginSystem.loadResources(scene, _this.options);
|
|
32544
|
-
})
|
|
32545
|
-
];
|
|
32546
32143
|
case 8:
|
|
32547
|
-
_state.sent();
|
|
32144
|
+
loadedTextures = _state.sent();
|
|
32145
|
+
(_scene_bins = scene.bins).push.apply(_scene_bins, [].concat(loadedBins));
|
|
32146
|
+
(_scene_textureOptions = scene.textureOptions).push.apply(_scene_textureOptions, [].concat(loadedTextures));
|
|
32147
|
+
(_scene_images = scene.images).push.apply(_scene_images, [].concat(loadedImages));
|
|
32148
|
+
// 降级插件会修改 this.options.renderLevel, 在 processPluginAssets 后赋值
|
|
32149
|
+
scene.renderLevel = _this.options.renderLevel;
|
|
32548
32150
|
_state.label = 9;
|
|
32549
32151
|
case 9:
|
|
32550
32152
|
totalTime = performance.now() - startTime;
|
|
@@ -32576,29 +32178,23 @@ var seed = 1;
|
|
|
32576
32178
|
return this.assets;
|
|
32577
32179
|
};
|
|
32578
32180
|
_proto.processJSON = function processJSON(json) {
|
|
32579
|
-
var _this = this;
|
|
32580
32181
|
return _async_to_generator(function() {
|
|
32581
|
-
var jsonScene, _jsonScene_plugins, plugins,
|
|
32182
|
+
var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
|
|
32582
32183
|
return __generator(this, function(_state) {
|
|
32583
|
-
|
|
32584
|
-
|
|
32585
|
-
|
|
32586
|
-
|
|
32587
|
-
|
|
32588
|
-
|
|
32589
|
-
|
|
32590
|
-
pluginSystem.processRawJSON(jsonScene, _this.options)
|
|
32591
|
-
];
|
|
32592
|
-
case 1:
|
|
32593
|
-
_state.sent();
|
|
32594
|
-
return [
|
|
32595
|
-
2,
|
|
32596
|
-
{
|
|
32597
|
-
jsonScene: jsonScene,
|
|
32598
|
-
pluginSystem: pluginSystem
|
|
32599
|
-
}
|
|
32600
|
-
];
|
|
32184
|
+
jsonScene = getStandardJSON(json);
|
|
32185
|
+
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
|
|
32186
|
+
for(_iterator = _create_for_of_iterator_helper_loose(plugins); !(_step = _iterator()).done;){
|
|
32187
|
+
customPluginName = _step.value;
|
|
32188
|
+
if (!pluginLoaderMap[customPluginName]) {
|
|
32189
|
+
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
32190
|
+
}
|
|
32601
32191
|
}
|
|
32192
|
+
return [
|
|
32193
|
+
2,
|
|
32194
|
+
{
|
|
32195
|
+
jsonScene: jsonScene
|
|
32196
|
+
}
|
|
32197
|
+
];
|
|
32602
32198
|
});
|
|
32603
32199
|
})();
|
|
32604
32200
|
};
|
|
@@ -32804,30 +32400,18 @@ var seed = 1;
|
|
|
32804
32400
|
});
|
|
32805
32401
|
})();
|
|
32806
32402
|
};
|
|
32807
|
-
_proto.processPluginAssets = function processPluginAssets(
|
|
32403
|
+
_proto.processPluginAssets = function processPluginAssets(scene) {
|
|
32808
32404
|
var _this = this;
|
|
32809
32405
|
return _async_to_generator(function() {
|
|
32810
|
-
var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
|
|
32811
32406
|
return __generator(this, function(_state) {
|
|
32812
32407
|
switch(_state.label){
|
|
32813
32408
|
case 0:
|
|
32814
32409
|
return [
|
|
32815
32410
|
4,
|
|
32816
|
-
|
|
32411
|
+
PluginSystem.processAssets(scene, _this.options)
|
|
32817
32412
|
];
|
|
32818
32413
|
case 1:
|
|
32819
|
-
|
|
32820
|
-
_pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
|
|
32821
|
-
acc.assets = acc.assets.concat(cur.assets);
|
|
32822
|
-
acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
|
|
32823
|
-
return acc;
|
|
32824
|
-
}, {
|
|
32825
|
-
assets: [],
|
|
32826
|
-
loadedAssets: []
|
|
32827
|
-
}), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
|
|
32828
|
-
for(i = 0; i < assets.length; i++){
|
|
32829
|
-
_this.assets[assets[i].id] = loadedAssets[i];
|
|
32830
|
-
}
|
|
32414
|
+
_state.sent();
|
|
32831
32415
|
return [
|
|
32832
32416
|
2
|
|
32833
32417
|
];
|
|
@@ -33254,7 +32838,6 @@ function _createTextureOptionsBySource() {
|
|
|
33254
32838
|
}
|
|
33255
32839
|
};
|
|
33256
32840
|
_proto.prepareAssets = function prepareAssets(scene, assets) {
|
|
33257
|
-
this.engine.clearResources();
|
|
33258
32841
|
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
|
|
33259
32842
|
var assetId = _step.value;
|
|
33260
32843
|
var asset = assets[assetId];
|
|
@@ -35166,8 +34749,9 @@ var DEFAULT_FPS = 60;
|
|
|
35166
34749
|
]
|
|
35167
34750
|
});
|
|
35168
34751
|
for(var i1 = 0; i1 < comps.length; i1++){
|
|
35169
|
-
!comps[i1].renderFrame.
|
|
34752
|
+
!comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
|
|
35170
34753
|
}
|
|
34754
|
+
this.renderer.renderTargetPool.flush();
|
|
35171
34755
|
};
|
|
35172
34756
|
/**
|
|
35173
34757
|
* 将渲染器重新和父容器大小对齐
|
|
@@ -35413,6 +34997,95 @@ var DEFAULT_FPS = 60;
|
|
|
35413
34997
|
return Engine;
|
|
35414
34998
|
}(EventEmitter);
|
|
35415
34999
|
|
|
35000
|
+
var def = {
|
|
35001
|
+
format: glContext.RGBA,
|
|
35002
|
+
type: glContext.UNSIGNED_BYTE,
|
|
35003
|
+
minFilter: glContext.LINEAR,
|
|
35004
|
+
magFilter: glContext.LINEAR,
|
|
35005
|
+
wrapS: glContext.CLAMP_TO_EDGE,
|
|
35006
|
+
wrapT: glContext.CLAMP_TO_EDGE
|
|
35007
|
+
};
|
|
35008
|
+
var disposeSymbol = Symbol("dispose");
|
|
35009
|
+
var PassTextureCache = /*#__PURE__*/ function() {
|
|
35010
|
+
function PassTextureCache(engine) {
|
|
35011
|
+
this.textureCache = {};
|
|
35012
|
+
this.textureRef = {};
|
|
35013
|
+
this.engine = engine;
|
|
35014
|
+
}
|
|
35015
|
+
var _proto = PassTextureCache.prototype;
|
|
35016
|
+
_proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
|
|
35017
|
+
var _this = this;
|
|
35018
|
+
var width = request.width, height = request.height, name = request.name;
|
|
35019
|
+
var options = {
|
|
35020
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
35021
|
+
data: {
|
|
35022
|
+
width: width,
|
|
35023
|
+
height: height
|
|
35024
|
+
},
|
|
35025
|
+
name: name
|
|
35026
|
+
};
|
|
35027
|
+
var keys = [
|
|
35028
|
+
name
|
|
35029
|
+
];
|
|
35030
|
+
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
35031
|
+
var _request_name;
|
|
35032
|
+
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
35033
|
+
options[name] = value;
|
|
35034
|
+
keys.push(name, value);
|
|
35035
|
+
});
|
|
35036
|
+
var cacheId = keys.join(":");
|
|
35037
|
+
var tex = this.textureCache[cacheId];
|
|
35038
|
+
if (tex) {
|
|
35039
|
+
this.textureRef[cacheId]++;
|
|
35040
|
+
} else {
|
|
35041
|
+
var engine = this.engine;
|
|
35042
|
+
assertExist(engine);
|
|
35043
|
+
tex = Texture.create(engine, options);
|
|
35044
|
+
this.textureCache[cacheId] = tex;
|
|
35045
|
+
this.textureRef[cacheId] = 1;
|
|
35046
|
+
// @ts-expect-error
|
|
35047
|
+
tex[disposeSymbol] = tex.dispose;
|
|
35048
|
+
tex.dispose = function() {
|
|
35049
|
+
return _this.removeTexture(cacheId);
|
|
35050
|
+
};
|
|
35051
|
+
}
|
|
35052
|
+
return tex;
|
|
35053
|
+
};
|
|
35054
|
+
_proto.removeTexture = function removeTexture(id) {
|
|
35055
|
+
var refCount = this.textureRef[id];
|
|
35056
|
+
if (refCount <= 1) {
|
|
35057
|
+
if (refCount < 0) {
|
|
35058
|
+
console.error("Ref count < 0.");
|
|
35059
|
+
}
|
|
35060
|
+
var tex = this.textureCache[id];
|
|
35061
|
+
if (tex) {
|
|
35062
|
+
// @ts-expect-error
|
|
35063
|
+
tex[disposeSymbol]();
|
|
35064
|
+
// @ts-expect-error
|
|
35065
|
+
tex.dispose = tex[disposeSymbol];
|
|
35066
|
+
}
|
|
35067
|
+
delete this.textureCache[id];
|
|
35068
|
+
delete this.textureRef[id];
|
|
35069
|
+
} else {
|
|
35070
|
+
this.textureRef[id] = refCount - 1;
|
|
35071
|
+
}
|
|
35072
|
+
};
|
|
35073
|
+
_proto.dispose = function dispose() {
|
|
35074
|
+
var _this = this;
|
|
35075
|
+
Object.keys(this.textureCache).forEach(function(key) {
|
|
35076
|
+
var texture = _this.textureCache[key];
|
|
35077
|
+
// @ts-expect-error
|
|
35078
|
+
texture[disposeSymbol]();
|
|
35079
|
+
// @ts-expect-error
|
|
35080
|
+
texture.dispose = texture[disposeSymbol];
|
|
35081
|
+
});
|
|
35082
|
+
this.textureCache = {};
|
|
35083
|
+
this.textureRef = {};
|
|
35084
|
+
this.engine = undefined;
|
|
35085
|
+
};
|
|
35086
|
+
return PassTextureCache;
|
|
35087
|
+
}();
|
|
35088
|
+
|
|
35416
35089
|
var SceneLoader = /*#__PURE__*/ function() {
|
|
35417
35090
|
function SceneLoader() {}
|
|
35418
35091
|
SceneLoader.load = function load(scene, engine, options) {
|
|
@@ -35431,16 +35104,16 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35431
35104
|
engine.assetManagers.push(assetManager);
|
|
35432
35105
|
return [
|
|
35433
35106
|
4,
|
|
35434
|
-
assetManager.loadScene(scene, engine.renderer
|
|
35435
|
-
env: engine.env
|
|
35436
|
-
})
|
|
35107
|
+
assetManager.loadScene(scene, engine.renderer)
|
|
35437
35108
|
];
|
|
35438
35109
|
case 1:
|
|
35439
35110
|
loadedScene = _state.sent();
|
|
35111
|
+
engine.clearResources();
|
|
35112
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
35113
|
+
PluginSystem.loadResources(loadedScene, assetManager.options, engine);
|
|
35440
35114
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35441
35115
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35442
35116
|
engine.assetService.initializeTexture(loadedScene);
|
|
35443
|
-
loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
|
|
35444
35117
|
composition = _this.createComposition(loadedScene, engine, options);
|
|
35445
35118
|
composition.setIndex(compositionIndex);
|
|
35446
35119
|
compileStart = performance.now();
|
|
@@ -35493,13 +35166,13 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35493
35166
|
return SceneLoader;
|
|
35494
35167
|
}();
|
|
35495
35168
|
|
|
35496
|
-
registerPlugin("camera", CameraVFXItemLoader
|
|
35497
|
-
registerPlugin("text", TextLoader
|
|
35498
|
-
registerPlugin("sprite", SpriteLoader
|
|
35499
|
-
registerPlugin("particle", ParticleLoader
|
|
35500
|
-
registerPlugin("cal", CalculateLoader
|
|
35501
|
-
registerPlugin("interact", InteractLoader
|
|
35502
|
-
var version = "2.8.0-alpha.
|
|
35169
|
+
registerPlugin("camera", CameraVFXItemLoader);
|
|
35170
|
+
registerPlugin("text", TextLoader);
|
|
35171
|
+
registerPlugin("sprite", SpriteLoader);
|
|
35172
|
+
registerPlugin("particle", ParticleLoader);
|
|
35173
|
+
registerPlugin("cal", CalculateLoader);
|
|
35174
|
+
registerPlugin("interact", InteractLoader);
|
|
35175
|
+
var version = "2.8.0-alpha.2";
|
|
35503
35176
|
logger.info("Core version: " + version + ".");
|
|
35504
35177
|
|
|
35505
35178
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -35610,7 +35283,6 @@ exports.Pose = Pose;
|
|
|
35610
35283
|
exports.PoseNode = PoseNode;
|
|
35611
35284
|
exports.PropertyClipPlayable = PropertyClipPlayable;
|
|
35612
35285
|
exports.PropertyTrack = PropertyTrack;
|
|
35613
|
-
exports.RENDER_PASS_NAME_PREFIX = RENDER_PASS_NAME_PREFIX;
|
|
35614
35286
|
exports.RENDER_PREFER_LOOKUP_TEXTURE = RENDER_PREFER_LOOKUP_TEXTURE;
|
|
35615
35287
|
exports.RUNTIME_ENV = RUNTIME_ENV;
|
|
35616
35288
|
exports.RandomSetValue = RandomSetValue;
|
|
@@ -35623,6 +35295,7 @@ exports.RenderPassPriorityNormal = RenderPassPriorityNormal;
|
|
|
35623
35295
|
exports.RenderPassPriorityPostprocess = RenderPassPriorityPostprocess;
|
|
35624
35296
|
exports.RenderPassPriorityPrepare = RenderPassPriorityPrepare;
|
|
35625
35297
|
exports.RenderTargetHandle = RenderTargetHandle;
|
|
35298
|
+
exports.RenderTargetPool = RenderTargetPool;
|
|
35626
35299
|
exports.Renderbuffer = Renderbuffer;
|
|
35627
35300
|
exports.Renderer = Renderer;
|
|
35628
35301
|
exports.RendererComponent = RendererComponent;
|
|
@@ -35685,14 +35358,12 @@ exports.colorGradingFrag = colorGradingFrag;
|
|
|
35685
35358
|
exports.colorStopsFromGradient = colorStopsFromGradient;
|
|
35686
35359
|
exports.colorToArr = colorToArr$1;
|
|
35687
35360
|
exports.combineImageTemplate = combineImageTemplate;
|
|
35688
|
-
exports.createCopyShader = createCopyShader;
|
|
35689
35361
|
exports.createGLContext = createGLContext;
|
|
35690
35362
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
35691
35363
|
exports.createShape = createShape;
|
|
35692
35364
|
exports.createValueGetter = createValueGetter;
|
|
35693
35365
|
exports.curveEps = curveEps;
|
|
35694
35366
|
exports.decimalEqual = decimalEqual;
|
|
35695
|
-
exports.defaultPlugins = defaultPlugins;
|
|
35696
35367
|
exports.deserializeMipmapTexture = deserializeMipmapTexture;
|
|
35697
35368
|
exports.earcut = earcut;
|
|
35698
35369
|
exports.effectsClass = effectsClass;
|
|
@@ -35700,7 +35371,6 @@ exports.effectsClassStore = effectsClassStore;
|
|
|
35700
35371
|
exports.enlargeBuffer = enlargeBuffer;
|
|
35701
35372
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
35702
35373
|
exports.ensureVec3 = ensureVec3;
|
|
35703
|
-
exports.findPreviousRenderPass = findPreviousRenderPass;
|
|
35704
35374
|
exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
35705
35375
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
35706
35376
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
@@ -35721,6 +35391,7 @@ exports.getMergedStore = getMergedStore;
|
|
|
35721
35391
|
exports.getNodeDataClass = getNodeDataClass;
|
|
35722
35392
|
exports.getParticleMeshShader = getParticleMeshShader;
|
|
35723
35393
|
exports.getPixelRatio = getPixelRatio;
|
|
35394
|
+
exports.getPluginUsageInfo = getPluginUsageInfo;
|
|
35724
35395
|
exports.getPreMultiAlpha = getPreMultiAlpha;
|
|
35725
35396
|
exports.getStandardComposition = getStandardComposition;
|
|
35726
35397
|
exports.getStandardImage = getStandardImage;
|