@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.mjs
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
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -33,41 +33,6 @@ function _async_to_generator(fn) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function _array_like_to_array(arr, len) {
|
|
37
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
38
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
39
|
-
return arr2;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
43
|
-
if (!o) return;
|
|
44
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
45
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
46
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
47
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
48
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
52
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
53
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
54
|
-
// Fallback for engines without symbol support
|
|
55
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
56
|
-
if (it) o = it;
|
|
57
|
-
var i = 0;
|
|
58
|
-
return function() {
|
|
59
|
-
if (i >= o.length) return {
|
|
60
|
-
done: true
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
done: false,
|
|
64
|
-
value: o[i++]
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
36
|
function _instanceof1(left, right) {
|
|
72
37
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
73
38
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -2900,134 +2865,68 @@ function applyMixins(derivedCtrl, baseCtrls) {
|
|
|
2900
2865
|
}
|
|
2901
2866
|
|
|
2902
2867
|
var pluginLoaderMap = {};
|
|
2903
|
-
var
|
|
2904
|
-
var pluginCtrlMap = {};
|
|
2868
|
+
var plugins = [];
|
|
2905
2869
|
/**
|
|
2906
2870
|
* 注册 plugin
|
|
2907
2871
|
* @param name
|
|
2908
2872
|
* @param pluginClass class of plugin
|
|
2909
2873
|
* @param itemClass class of item
|
|
2910
2874
|
* @param isDefault load
|
|
2911
|
-
*/ function registerPlugin(name, pluginClass
|
|
2912
|
-
if (
|
|
2875
|
+
*/ function registerPlugin(name, pluginClass) {
|
|
2876
|
+
if (pluginLoaderMap[name]) {
|
|
2913
2877
|
logger.error("Duplicate registration for plugin " + name + ".");
|
|
2914
2878
|
}
|
|
2915
|
-
pluginCtrlMap[name] = itemClass;
|
|
2916
2879
|
pluginLoaderMap[name] = pluginClass;
|
|
2917
|
-
|
|
2880
|
+
var pluginInstance = new pluginClass();
|
|
2881
|
+
pluginInstance.name = name;
|
|
2882
|
+
pluginInstance.initialize();
|
|
2883
|
+
plugins.push(pluginInstance);
|
|
2884
|
+
plugins.sort(function(a, b) {
|
|
2885
|
+
return a.order - b.order;
|
|
2886
|
+
});
|
|
2918
2887
|
}
|
|
2919
|
-
|
|
2920
|
-
|
|
2888
|
+
/**
|
|
2889
|
+
* 注销 plugin
|
|
2890
|
+
*/ function unregisterPlugin(name) {
|
|
2921
2891
|
delete pluginLoaderMap[name];
|
|
2922
|
-
|
|
2892
|
+
var pluginIndex = plugins.findIndex(function(plugin) {
|
|
2893
|
+
return plugin.name === name;
|
|
2894
|
+
});
|
|
2895
|
+
if (pluginIndex !== -1) {
|
|
2896
|
+
plugins.splice(pluginIndex, 1);
|
|
2897
|
+
}
|
|
2923
2898
|
}
|
|
2924
2899
|
var PluginSystem = /*#__PURE__*/ function() {
|
|
2925
|
-
function PluginSystem(
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
loaded.push(loader);
|
|
2932
|
-
loaders[name] = loader;
|
|
2933
|
-
}
|
|
2934
|
-
};
|
|
2935
|
-
defaultPlugins.forEach(addLoader);
|
|
2936
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(pluginNames), _step; !(_step = _iterator()).done;){
|
|
2937
|
-
var customPluginName = _step.value;
|
|
2938
|
-
if (!pluginLoaderMap[customPluginName]) {
|
|
2939
|
-
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
this.plugins = Object.keys(loaders).map(function(name) {
|
|
2943
|
-
var pluginConstructor = pluginLoaderMap[name];
|
|
2944
|
-
var loader = new pluginConstructor();
|
|
2945
|
-
loader.name = name;
|
|
2946
|
-
return loader;
|
|
2947
|
-
}).sort(function(a, b) {
|
|
2948
|
-
return a.order - b.order;
|
|
2949
|
-
});
|
|
2950
|
-
}
|
|
2951
|
-
var _proto = PluginSystem.prototype;
|
|
2952
|
-
_proto.initializeComposition = function initializeComposition(composition, scene) {
|
|
2953
|
-
this.plugins.forEach(function(loader) {
|
|
2900
|
+
function PluginSystem() {}
|
|
2901
|
+
PluginSystem.getPlugins = function getPlugins() {
|
|
2902
|
+
return plugins;
|
|
2903
|
+
};
|
|
2904
|
+
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2905
|
+
plugins.forEach(function(loader) {
|
|
2954
2906
|
return loader.onCompositionConstructed(composition, scene);
|
|
2955
2907
|
});
|
|
2956
2908
|
};
|
|
2957
|
-
|
|
2958
|
-
|
|
2909
|
+
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2910
|
+
plugins.forEach(function(loader) {
|
|
2959
2911
|
return loader.onCompositionDestroyed(comp);
|
|
2960
2912
|
});
|
|
2961
2913
|
};
|
|
2962
|
-
|
|
2963
|
-
this.plugins.forEach(function(loader) {
|
|
2964
|
-
return loader.onCompositionReset(comp, renderFrame);
|
|
2965
|
-
});
|
|
2966
|
-
};
|
|
2967
|
-
_proto.processRawJSON = function processRawJSON(json, options) {
|
|
2968
|
-
var _this = this;
|
|
2914
|
+
PluginSystem.processAssets = function processAssets(scene, options) {
|
|
2969
2915
|
return _async_to_generator(function() {
|
|
2970
2916
|
return __generator(this, function(_state) {
|
|
2971
2917
|
return [
|
|
2972
2918
|
2,
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
})();
|
|
2977
|
-
};
|
|
2978
|
-
_proto.processAssets = function processAssets(json, options) {
|
|
2979
|
-
var _this = this;
|
|
2980
|
-
return _async_to_generator(function() {
|
|
2981
|
-
return __generator(this, function(_state) {
|
|
2982
|
-
return [
|
|
2983
|
-
2,
|
|
2984
|
-
_this.callStatic("processAssets", json, options)
|
|
2985
|
-
];
|
|
2986
|
-
});
|
|
2987
|
-
})();
|
|
2988
|
-
};
|
|
2989
|
-
_proto.precompile = function precompile(compositions, renderer) {
|
|
2990
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
|
|
2991
|
-
var plugin = _step.value;
|
|
2992
|
-
plugin.precompile(compositions, renderer);
|
|
2993
|
-
}
|
|
2994
|
-
};
|
|
2995
|
-
_proto.loadResources = function loadResources(scene, options) {
|
|
2996
|
-
var _this = this;
|
|
2997
|
-
return _async_to_generator(function() {
|
|
2998
|
-
return __generator(this, function(_state) {
|
|
2999
|
-
return [
|
|
3000
|
-
2,
|
|
3001
|
-
_this.callStatic("prepareResource", scene, options)
|
|
2919
|
+
Promise.all(plugins.map(function(plugin) {
|
|
2920
|
+
return plugin.processAssets(scene, options);
|
|
2921
|
+
}))
|
|
3002
2922
|
];
|
|
3003
2923
|
});
|
|
3004
2924
|
})();
|
|
3005
2925
|
};
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
}
|
|
3010
|
-
var _this = this;
|
|
3011
|
-
return _async_to_generator(function() {
|
|
3012
|
-
var pendings, plugins, i, plugin, ctrl, _ctrl_name, _ctrl_name1;
|
|
3013
|
-
return __generator(this, function(_state) {
|
|
3014
|
-
pendings = [];
|
|
3015
|
-
plugins = _this.plugins;
|
|
3016
|
-
for(i = 0; i < plugins.length; i++){
|
|
3017
|
-
plugin = plugins[i];
|
|
3018
|
-
ctrl = pluginLoaderMap[plugin.name];
|
|
3019
|
-
if (name in ctrl) {
|
|
3020
|
-
pendings.push(Promise.resolve((_ctrl_name1 = ctrl[name]) == null ? void 0 : (_ctrl_name = _ctrl_name1).call.apply(_ctrl_name, [].concat([
|
|
3021
|
-
ctrl
|
|
3022
|
-
], args))));
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
return [
|
|
3026
|
-
2,
|
|
3027
|
-
Promise.all(pendings)
|
|
3028
|
-
];
|
|
3029
|
-
});
|
|
3030
|
-
})();
|
|
2926
|
+
PluginSystem.loadResources = function loadResources(scene, options, engine) {
|
|
2927
|
+
plugins.forEach(function(loader) {
|
|
2928
|
+
return loader.prepareResource(scene, options, engine);
|
|
2929
|
+
});
|
|
3031
2930
|
};
|
|
3032
2931
|
return PluginSystem;
|
|
3033
2932
|
}();
|
|
@@ -3035,6 +2934,8 @@ var pluginInfoMap = {
|
|
|
3035
2934
|
"alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
|
|
3036
2935
|
"downgrade": "@galacean/effects-plugin-downgrade",
|
|
3037
2936
|
"editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
|
|
2937
|
+
"ffd": "@galacean/effects-plugin-ffd",
|
|
2938
|
+
"ktx2": "@galacean/effects-plugin-ktx2",
|
|
3038
2939
|
"model": "@galacean/effects-plugin-model",
|
|
3039
2940
|
"video": "@galacean/effects-plugin-multimedia",
|
|
3040
2941
|
"audio": "@galacean/effects-plugin-multimedia",
|
|
@@ -3060,15 +2961,33 @@ function getPluginUsageInfo(name) {
|
|
|
3060
2961
|
this.name = "";
|
|
3061
2962
|
}
|
|
3062
2963
|
var _proto = AbstractPlugin.prototype;
|
|
2964
|
+
_proto.initialize = function initialize() {};
|
|
3063
2965
|
/**
|
|
3064
|
-
*
|
|
3065
|
-
*
|
|
3066
|
-
* @param
|
|
3067
|
-
|
|
2966
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
2967
|
+
* 此阶段可以加载插件所需类型资源,并返回原始资源和加载后的资源。
|
|
2968
|
+
* @param scene
|
|
2969
|
+
* @param options
|
|
2970
|
+
* @returns
|
|
2971
|
+
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2972
|
+
return _async_to_generator(function() {
|
|
2973
|
+
return __generator(this, function(_state) {
|
|
2974
|
+
return [
|
|
2975
|
+
2
|
|
2976
|
+
];
|
|
2977
|
+
});
|
|
2978
|
+
})();
|
|
2979
|
+
};
|
|
2980
|
+
/**
|
|
2981
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
2982
|
+
* 此阶段时,json 中的图片和二进制已经被加载完成,可以对加载好的资源做进一步处理,
|
|
2983
|
+
* 如果 promise 被 reject, loadScene 函数同样会被 reject,表示场景加载失败。
|
|
2984
|
+
* 请记住,整个 load 阶段都不要创建 GL 相关的对象,只创建 JS 对象
|
|
2985
|
+
* 此阶段晚于 processAssets
|
|
2986
|
+
* @param {Scene} scene
|
|
2987
|
+
* @param {SceneLoadOptions} options
|
|
2988
|
+
*/ _proto.prepareResource = function prepareResource(scene, options, engine) {};
|
|
3068
2989
|
_proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {};
|
|
3069
|
-
_proto.onCompositionReset = function onCompositionReset(composition, frame) {};
|
|
3070
2990
|
_proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {};
|
|
3071
|
-
_proto.onCompositionUpdate = function onCompositionUpdate(composition, dt) {};
|
|
3072
2991
|
return AbstractPlugin;
|
|
3073
2992
|
}();
|
|
3074
2993
|
|
|
@@ -4053,6 +3972,41 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
4053
3972
|
get VertexBufferSemantic () { return VertexBufferSemantic; }
|
|
4054
3973
|
});
|
|
4055
3974
|
|
|
3975
|
+
function _array_like_to_array(arr, len) {
|
|
3976
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3977
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
3978
|
+
return arr2;
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
3982
|
+
if (!o) return;
|
|
3983
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
3984
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3985
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
3986
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
3987
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
3988
|
+
}
|
|
3989
|
+
|
|
3990
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
3991
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3992
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
3993
|
+
// Fallback for engines without symbol support
|
|
3994
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
3995
|
+
if (it) o = it;
|
|
3996
|
+
var i = 0;
|
|
3997
|
+
return function() {
|
|
3998
|
+
if (i >= o.length) return {
|
|
3999
|
+
done: true
|
|
4000
|
+
};
|
|
4001
|
+
return {
|
|
4002
|
+
done: false,
|
|
4003
|
+
value: o[i++]
|
|
4004
|
+
};
|
|
4005
|
+
};
|
|
4006
|
+
}
|
|
4007
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4056
4010
|
var decoratorInitialStore = new Map();
|
|
4057
4011
|
var mergedStore = new Map();
|
|
4058
4012
|
var effectsClassStore = {};
|
|
@@ -10351,175 +10305,72 @@ var MaskProcessor = /*#__PURE__*/ function() {
|
|
|
10351
10305
|
return MaskProcessor;
|
|
10352
10306
|
}();
|
|
10353
10307
|
|
|
10354
|
-
var ShaderCompileResultStatus;
|
|
10355
|
-
(function(ShaderCompileResultStatus) {
|
|
10356
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10357
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10358
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10359
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10360
|
-
})(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
|
|
10361
|
-
var GLSLVersion;
|
|
10362
|
-
(function(GLSLVersion) {
|
|
10363
|
-
GLSLVersion["GLSL1"] = "100";
|
|
10364
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
10365
|
-
})(GLSLVersion || (GLSLVersion = {}));
|
|
10366
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10367
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
10368
|
-
function ShaderVariant(engine, source) {
|
|
10369
|
-
var _this;
|
|
10370
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
10371
|
-
_this.source = source;
|
|
10372
|
-
return _this;
|
|
10373
|
-
}
|
|
10374
|
-
return ShaderVariant;
|
|
10375
|
-
}(EffectsObject);
|
|
10376
|
-
var Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10377
|
-
_inherits(Shader, EffectsObject);
|
|
10378
|
-
function Shader() {
|
|
10379
|
-
return EffectsObject.apply(this, arguments);
|
|
10380
|
-
}
|
|
10381
|
-
var _proto = Shader.prototype;
|
|
10382
|
-
_proto.createVariant = function createVariant(macros) {
|
|
10383
|
-
var shaderMacros = [];
|
|
10384
|
-
if (macros) {
|
|
10385
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10386
|
-
var key = _step.value;
|
|
10387
|
-
shaderMacros.push([
|
|
10388
|
-
key,
|
|
10389
|
-
macros[key]
|
|
10390
|
-
]);
|
|
10391
|
-
}
|
|
10392
|
-
}
|
|
10393
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10394
|
-
shaderVariant.shader = this;
|
|
10395
|
-
return shaderVariant;
|
|
10396
|
-
};
|
|
10397
|
-
_proto.fromData = function fromData(data) {
|
|
10398
|
-
EffectsObject.prototype.fromData.call(this, data);
|
|
10399
|
-
this.shaderData = data;
|
|
10400
|
-
};
|
|
10401
|
-
return Shader;
|
|
10402
|
-
}(EffectsObject);
|
|
10403
|
-
Shader = __decorate([
|
|
10404
|
-
effectsClass(DataType.Shader)
|
|
10405
|
-
], Shader);
|
|
10406
|
-
|
|
10407
10308
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10408
10309
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10409
10310
|
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}";
|
|
10410
10311
|
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";
|
|
10411
|
-
function createCopyShader(level, writeDepth) {
|
|
10412
|
-
var webgl2 = level === 2;
|
|
10413
|
-
return {
|
|
10414
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
10415
|
-
vertex: COPY_VERTEX_SHADER,
|
|
10416
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
10417
|
-
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
10418
|
-
macros: [
|
|
10419
|
-
[
|
|
10420
|
-
"DEPTH_TEXTURE",
|
|
10421
|
-
!!writeDepth
|
|
10422
|
-
]
|
|
10423
|
-
],
|
|
10424
|
-
// @ts-expect-error
|
|
10425
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
10426
|
-
};
|
|
10427
|
-
}
|
|
10428
10312
|
|
|
10429
|
-
var
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
var _this = this;
|
|
10447
|
-
var width = request.width, height = request.height, name = request.name;
|
|
10448
|
-
var options = {
|
|
10449
|
-
sourceType: TextureSourceType.framebuffer,
|
|
10450
|
-
data: {
|
|
10451
|
-
width: width,
|
|
10452
|
-
height: height
|
|
10453
|
-
},
|
|
10454
|
-
name: name
|
|
10455
|
-
};
|
|
10456
|
-
var keys = [
|
|
10457
|
-
name
|
|
10458
|
-
];
|
|
10459
|
-
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
10460
|
-
var _request_name;
|
|
10461
|
-
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
10462
|
-
options[name] = value;
|
|
10463
|
-
keys.push(name, value);
|
|
10464
|
-
});
|
|
10465
|
-
var cacheId = keys.join(":");
|
|
10466
|
-
var tex = this.textureCache[cacheId];
|
|
10467
|
-
if (tex) {
|
|
10468
|
-
this.textureRef[cacheId]++;
|
|
10469
|
-
} else {
|
|
10470
|
-
var engine = this.engine;
|
|
10471
|
-
assertExist(engine);
|
|
10472
|
-
tex = Texture.create(engine, options);
|
|
10473
|
-
this.textureCache[cacheId] = tex;
|
|
10474
|
-
this.textureRef[cacheId] = 1;
|
|
10475
|
-
// @ts-expect-error
|
|
10476
|
-
tex[disposeSymbol] = tex.dispose;
|
|
10477
|
-
tex.dispose = function() {
|
|
10478
|
-
return _this.removeTexture(cacheId);
|
|
10479
|
-
};
|
|
10480
|
-
}
|
|
10481
|
-
return tex;
|
|
10313
|
+
var FilterMode;
|
|
10314
|
+
(function(FilterMode) {
|
|
10315
|
+
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
10316
|
+
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
10317
|
+
})(FilterMode || (FilterMode = {}));
|
|
10318
|
+
var RenderTextureFormat;
|
|
10319
|
+
(function(RenderTextureFormat) {
|
|
10320
|
+
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
10321
|
+
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
10322
|
+
})(RenderTextureFormat || (RenderTextureFormat = {}));
|
|
10323
|
+
/**
|
|
10324
|
+
*
|
|
10325
|
+
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
10326
|
+
function Framebuffer() {}
|
|
10327
|
+
var _proto = Framebuffer.prototype;
|
|
10328
|
+
_proto.resize = function resize(x, y, width, height) {
|
|
10329
|
+
// OVERRIDE
|
|
10482
10330
|
};
|
|
10483
|
-
_proto.
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10331
|
+
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
10332
|
+
// OVERRIDE
|
|
10333
|
+
};
|
|
10334
|
+
_proto.unbind = function unbind() {
|
|
10335
|
+
// OVERRIDE
|
|
10336
|
+
};
|
|
10337
|
+
_proto.bind = function bind() {
|
|
10338
|
+
// OVERRIDE
|
|
10339
|
+
};
|
|
10340
|
+
_proto.getDepthTexture = function getDepthTexture() {
|
|
10341
|
+
// OVERRIDE
|
|
10342
|
+
return undefined;
|
|
10343
|
+
};
|
|
10344
|
+
_proto.getStencilTexture = function getStencilTexture() {
|
|
10345
|
+
// OVERRIDE
|
|
10346
|
+
return undefined;
|
|
10347
|
+
};
|
|
10348
|
+
_proto.getColorTextures = function getColorTextures() {
|
|
10349
|
+
// OVERRIDE
|
|
10350
|
+
return [];
|
|
10351
|
+
};
|
|
10352
|
+
_proto.dispose = function dispose(options) {
|
|
10353
|
+
// OVERRIDE
|
|
10354
|
+
};
|
|
10355
|
+
_create_class(Framebuffer, [
|
|
10356
|
+
{
|
|
10357
|
+
key: "stencilStorage",
|
|
10358
|
+
get: function get() {
|
|
10359
|
+
// OVERRIDE
|
|
10360
|
+
return undefined;
|
|
10488
10361
|
}
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
//
|
|
10494
|
-
|
|
10362
|
+
},
|
|
10363
|
+
{
|
|
10364
|
+
key: "depthStorage",
|
|
10365
|
+
get: function get() {
|
|
10366
|
+
// OVERRIDE
|
|
10367
|
+
return undefined;
|
|
10495
10368
|
}
|
|
10496
|
-
delete this.textureCache[id];
|
|
10497
|
-
delete this.textureRef[id];
|
|
10498
|
-
} else {
|
|
10499
|
-
this.textureRef[id] = refCount - 1;
|
|
10500
10369
|
}
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
var _this = this;
|
|
10504
|
-
Object.keys(this.textureCache).forEach(function(key) {
|
|
10505
|
-
var texture = _this.textureCache[key];
|
|
10506
|
-
// @ts-expect-error
|
|
10507
|
-
texture[disposeSymbol]();
|
|
10508
|
-
// @ts-expect-error
|
|
10509
|
-
texture.dispose = texture[disposeSymbol];
|
|
10510
|
-
});
|
|
10511
|
-
this.textureCache = {};
|
|
10512
|
-
this.textureRef = {};
|
|
10513
|
-
this.engine = undefined;
|
|
10514
|
-
};
|
|
10515
|
-
return PassTextureCache;
|
|
10370
|
+
]);
|
|
10371
|
+
return Framebuffer;
|
|
10516
10372
|
}();
|
|
10517
10373
|
|
|
10518
|
-
function _assert_this_initialized(self) {
|
|
10519
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10520
|
-
return self;
|
|
10521
|
-
}
|
|
10522
|
-
|
|
10523
10374
|
var RenderPassPriorityPrepare = 0;
|
|
10524
10375
|
var RenderPassPriorityNormal = 1000;
|
|
10525
10376
|
var RenderPassPriorityPostprocess = 3000;
|
|
@@ -10529,7 +10380,7 @@ var RenderPassAttachmentStorageType;
|
|
|
10529
10380
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
|
|
10530
10381
|
//stencil 8 render buffer
|
|
10531
10382
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
|
|
10532
|
-
//
|
|
10383
|
+
//depth 16 render buffer
|
|
10533
10384
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
|
|
10534
10385
|
//depth 16 & stencil 8 render buffer
|
|
10535
10386
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
|
|
@@ -10648,61 +10499,31 @@ var seed$7 = 1;
|
|
|
10648
10499
|
/**
|
|
10649
10500
|
* RenderPass 抽象类
|
|
10650
10501
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
10651
|
-
function RenderPass(renderer
|
|
10502
|
+
function RenderPass(renderer) {
|
|
10652
10503
|
/**
|
|
10653
10504
|
* 优先级
|
|
10654
10505
|
*/ this.priority = 0;
|
|
10655
10506
|
/**
|
|
10656
|
-
* ColorAttachment 数组
|
|
10657
|
-
*/ this.attachments = [];
|
|
10658
|
-
/**
|
|
10659
10507
|
* 名称
|
|
10660
10508
|
*/ this.name = "RenderPass" + seed$7++;
|
|
10661
10509
|
/**
|
|
10662
10510
|
* 包含的 Mesh 列表
|
|
10663
10511
|
*/ this.meshes = [];
|
|
10664
|
-
/**
|
|
10665
|
-
* Mesh 渲染顺序,按照优先级升序或降序
|
|
10666
|
-
*/ this.meshOrder = OrderType.ascending;
|
|
10667
10512
|
this.disposed = false;
|
|
10668
|
-
this.
|
|
10669
|
-
var depthStencilAttachment = options.depthStencilAttachment;
|
|
10513
|
+
this.framebuffer = null;
|
|
10670
10514
|
this.renderer = renderer;
|
|
10671
|
-
this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
|
|
10672
|
-
this.storeAction = {
|
|
10673
|
-
colorAction: 0,
|
|
10674
|
-
depthAction: 0,
|
|
10675
|
-
stencilAction: 0
|
|
10676
|
-
};
|
|
10677
|
-
this.options = options;
|
|
10678
10515
|
}
|
|
10679
10516
|
var _proto = RenderPass.prototype;
|
|
10680
10517
|
_proto.addMesh = function addMesh(mesh) {
|
|
10681
|
-
addByOrder(this.meshes, mesh
|
|
10518
|
+
addByOrder(this.meshes, mesh);
|
|
10682
10519
|
};
|
|
10683
10520
|
_proto.removeMesh = function removeMesh(mesh) {
|
|
10684
10521
|
removeItem(this.meshes, mesh);
|
|
10685
10522
|
};
|
|
10686
|
-
_proto.setMeshes = function setMeshes(meshes) {
|
|
10687
|
-
var _this_meshes;
|
|
10688
|
-
this.meshes.length = 0;
|
|
10689
|
-
(_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
|
|
10690
|
-
0,
|
|
10691
|
-
0
|
|
10692
|
-
], meshes));
|
|
10693
|
-
sortByOrder(this.meshes, this.meshOrder);
|
|
10694
|
-
return this.meshes;
|
|
10695
|
-
};
|
|
10696
|
-
// TODO 所有pass在子类配置
|
|
10697
10523
|
/**
|
|
10698
10524
|
* 配置当前pass的RT,在每帧渲染前调用
|
|
10699
10525
|
*/ _proto.configure = function configure(renderer) {
|
|
10700
|
-
|
|
10701
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
10702
|
-
} else {
|
|
10703
|
-
var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
|
|
10704
|
-
renderer.setViewport(x, y, width, height);
|
|
10705
|
-
}
|
|
10526
|
+
// OVERRIDE
|
|
10706
10527
|
};
|
|
10707
10528
|
/**
|
|
10708
10529
|
* 执行当前pass,每帧调用一次
|
|
@@ -10710,66 +10531,10 @@ var seed$7 = 1;
|
|
|
10710
10531
|
// OVERRIDE
|
|
10711
10532
|
};
|
|
10712
10533
|
/**
|
|
10713
|
-
* 每帧所有的pass
|
|
10714
|
-
*/ _proto.
|
|
10534
|
+
* 每帧所有的pass渲染完后调用,用于清空临时的RT资源
|
|
10535
|
+
*/ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10715
10536
|
// OVERRIDE
|
|
10716
10537
|
};
|
|
10717
|
-
_proto._resetAttachments = function _resetAttachments() {
|
|
10718
|
-
var _this = this;
|
|
10719
|
-
var _options_attachments;
|
|
10720
|
-
var renderer = this.renderer;
|
|
10721
|
-
var options = this.options;
|
|
10722
|
-
if (this.attachments.length) {
|
|
10723
|
-
var _this_framebuffer;
|
|
10724
|
-
this.attachments.forEach(function(att) {
|
|
10725
|
-
return !att.externalTexture && att.dispose();
|
|
10726
|
-
});
|
|
10727
|
-
this.attachments.length = 0;
|
|
10728
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
|
|
10729
|
-
depthStencilAttachment: 2
|
|
10730
|
-
});
|
|
10731
|
-
this.framebuffer = null;
|
|
10732
|
-
}
|
|
10733
|
-
// renderpass 的 viewport 相关参数都需要动态的修改
|
|
10734
|
-
var viewport = [
|
|
10735
|
-
0,
|
|
10736
|
-
0,
|
|
10737
|
-
renderer.getWidth(),
|
|
10738
|
-
renderer.getHeight()
|
|
10739
|
-
];
|
|
10740
|
-
var size = [
|
|
10741
|
-
viewport[2],
|
|
10742
|
-
viewport[3]
|
|
10743
|
-
];
|
|
10744
|
-
var name = this.name;
|
|
10745
|
-
if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
|
|
10746
|
-
var attachments = options.attachments.map(function(attr, index) {
|
|
10747
|
-
var _attr_texture;
|
|
10748
|
-
var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
|
|
10749
|
-
size: size,
|
|
10750
|
-
name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
|
|
10751
|
-
}, attr));
|
|
10752
|
-
return attachment;
|
|
10753
|
-
});
|
|
10754
|
-
this.attachments = attachments;
|
|
10755
|
-
var framebuffer = Framebuffer.create({
|
|
10756
|
-
storeAction: this.storeAction,
|
|
10757
|
-
name: name,
|
|
10758
|
-
viewport: viewport,
|
|
10759
|
-
attachments: attachments.map(function(att) {
|
|
10760
|
-
return att.texture;
|
|
10761
|
-
}),
|
|
10762
|
-
depthStencilAttachment: options.depthStencilAttachment || {
|
|
10763
|
-
storageType: 0
|
|
10764
|
-
}
|
|
10765
|
-
}, renderer);
|
|
10766
|
-
framebuffer.bind();
|
|
10767
|
-
framebuffer.unbind();
|
|
10768
|
-
this.framebuffer = framebuffer;
|
|
10769
|
-
} else {
|
|
10770
|
-
this.attachments.length = 0;
|
|
10771
|
-
}
|
|
10772
|
-
};
|
|
10773
10538
|
/**
|
|
10774
10539
|
* 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
|
|
10775
10540
|
*/ _proto.getViewport = function getViewport() {
|
|
@@ -10792,68 +10557,6 @@ var seed$7 = 1;
|
|
|
10792
10557
|
];
|
|
10793
10558
|
};
|
|
10794
10559
|
/**
|
|
10795
|
-
* 获取深度 Attachment,可能没有
|
|
10796
|
-
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
10797
|
-
var framebuffer = this.framebuffer;
|
|
10798
|
-
if (framebuffer) {
|
|
10799
|
-
var depthTexture = framebuffer.getDepthTexture();
|
|
10800
|
-
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
10801
|
-
return {
|
|
10802
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10803
|
-
storage: framebuffer.depthStorage,
|
|
10804
|
-
texture: texture
|
|
10805
|
-
};
|
|
10806
|
-
}
|
|
10807
|
-
};
|
|
10808
|
-
/**
|
|
10809
|
-
* 获取蒙版 Attachment,可能没有
|
|
10810
|
-
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
10811
|
-
var framebuffer = this.framebuffer;
|
|
10812
|
-
if (framebuffer) {
|
|
10813
|
-
var stencilTexture = framebuffer.getStencilTexture();
|
|
10814
|
-
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
10815
|
-
return {
|
|
10816
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10817
|
-
storage: framebuffer.stencilStorage,
|
|
10818
|
-
texture: texture
|
|
10819
|
-
};
|
|
10820
|
-
}
|
|
10821
|
-
};
|
|
10822
|
-
_proto.getDepthTexture = function getDepthTexture(texture, external) {
|
|
10823
|
-
if (!this.depthTexture) {
|
|
10824
|
-
var _this_options_depthStencilAttachment;
|
|
10825
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10826
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10827
|
-
// TODO 为什么要initialize?
|
|
10828
|
-
//tex.initialize(this.renderer.engine);
|
|
10829
|
-
if (!external) {
|
|
10830
|
-
this.depthTexture = tex;
|
|
10831
|
-
}
|
|
10832
|
-
return tex;
|
|
10833
|
-
}
|
|
10834
|
-
return this.depthTexture;
|
|
10835
|
-
};
|
|
10836
|
-
_proto.getStencilTexture = function getStencilTexture(texture, external) {
|
|
10837
|
-
if (!this.stencilTexture) {
|
|
10838
|
-
var _this_options_depthStencilAttachment;
|
|
10839
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10840
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10841
|
-
if (!external) {
|
|
10842
|
-
this.stencilTexture = tex;
|
|
10843
|
-
}
|
|
10844
|
-
return tex;
|
|
10845
|
-
}
|
|
10846
|
-
return this.stencilTexture;
|
|
10847
|
-
};
|
|
10848
|
-
// 生成并初始化帧缓冲
|
|
10849
|
-
_proto.initialize = function initialize(renderer) {
|
|
10850
|
-
if (!this.initialized) {
|
|
10851
|
-
this._resetAttachments();
|
|
10852
|
-
this.initialized = true;
|
|
10853
|
-
}
|
|
10854
|
-
return this;
|
|
10855
|
-
};
|
|
10856
|
-
/**
|
|
10857
10560
|
* 销毁 RenderPass
|
|
10858
10561
|
* @param options - 有选择销毁内部对象
|
|
10859
10562
|
*/ _proto.dispose = function dispose(options) {
|
|
@@ -10867,35 +10570,11 @@ var seed$7 = 1;
|
|
|
10867
10570
|
});
|
|
10868
10571
|
}
|
|
10869
10572
|
this.meshes.length = 0;
|
|
10870
|
-
var colorOpt = (options == null ? void 0 : options.colorAttachment) ? options.colorAttachment : 0;
|
|
10871
|
-
this.attachments.forEach(function(att) {
|
|
10872
|
-
var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
|
|
10873
|
-
if (!keep) {
|
|
10874
|
-
att.dispose();
|
|
10875
|
-
}
|
|
10876
|
-
});
|
|
10877
|
-
this.attachments.length = 0;
|
|
10878
10573
|
this.disposed = true;
|
|
10879
|
-
var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
|
|
10880
|
-
var fbo = this.framebuffer;
|
|
10881
|
-
if (fbo) {
|
|
10882
|
-
fbo.dispose({
|
|
10883
|
-
depthStencilAttachment: depthStencilOpt
|
|
10884
|
-
});
|
|
10885
|
-
var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
|
|
10886
|
-
if (!keep) {
|
|
10887
|
-
var _this_stencilTexture, _this_depthTexture;
|
|
10888
|
-
(_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
|
|
10889
|
-
(_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
|
|
10890
|
-
}
|
|
10891
|
-
}
|
|
10892
|
-
// @ts-expect-error safe to assign
|
|
10893
|
-
this.options = null;
|
|
10894
|
-
this.initialize = throwDestroyedError;
|
|
10895
10574
|
};
|
|
10896
10575
|
_create_class(RenderPass, [
|
|
10897
10576
|
{
|
|
10898
|
-
key: "
|
|
10577
|
+
key: "isDisposed",
|
|
10899
10578
|
get: function get() {
|
|
10900
10579
|
return this.disposed;
|
|
10901
10580
|
}
|
|
@@ -10905,18 +10584,6 @@ var seed$7 = 1;
|
|
|
10905
10584
|
get: function get() {
|
|
10906
10585
|
return this.getViewport();
|
|
10907
10586
|
}
|
|
10908
|
-
},
|
|
10909
|
-
{
|
|
10910
|
-
key: "stencilAttachment",
|
|
10911
|
-
get: function get() {
|
|
10912
|
-
return this.getStencilAttachment();
|
|
10913
|
-
}
|
|
10914
|
-
},
|
|
10915
|
-
{
|
|
10916
|
-
key: "depthAttachment",
|
|
10917
|
-
get: function get() {
|
|
10918
|
-
return this.getDepthAttachment();
|
|
10919
|
-
}
|
|
10920
10587
|
}
|
|
10921
10588
|
]);
|
|
10922
10589
|
return RenderPass;
|
|
@@ -10924,38 +10591,95 @@ var seed$7 = 1;
|
|
|
10924
10591
|
|
|
10925
10592
|
var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
10926
10593
|
_inherits(DrawObjectPass, RenderPass);
|
|
10927
|
-
function DrawObjectPass(renderer
|
|
10594
|
+
function DrawObjectPass(renderer) {
|
|
10928
10595
|
var _this;
|
|
10929
|
-
_this = RenderPass.call(this, renderer
|
|
10596
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
10597
|
+
_this.useRenderTarget = false;
|
|
10930
10598
|
_this.priority = RenderPassPriorityNormal;
|
|
10931
10599
|
_this.name = "DrawObjectPass";
|
|
10932
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
10933
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
10934
10600
|
return _this;
|
|
10935
10601
|
}
|
|
10936
10602
|
var _proto = DrawObjectPass.prototype;
|
|
10603
|
+
_proto.setup = function setup(useRenderTarget) {
|
|
10604
|
+
this.useRenderTarget = useRenderTarget;
|
|
10605
|
+
};
|
|
10606
|
+
_proto.configure = function configure(renderer) {
|
|
10607
|
+
if (this.useRenderTarget) {
|
|
10608
|
+
this.framebuffer = renderer.getTemporaryRT("DrawObjectPass", renderer.getWidth(), renderer.getHeight(), 16, FilterMode.Linear, RenderTextureFormat.RGBAHalf);
|
|
10609
|
+
renderer.setFramebuffer(this.framebuffer);
|
|
10610
|
+
}
|
|
10611
|
+
};
|
|
10937
10612
|
_proto.execute = function execute(renderer) {
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10613
|
+
if (this.useRenderTarget) {
|
|
10614
|
+
renderer.clear({
|
|
10615
|
+
colorAction: TextureLoadAction.clear,
|
|
10616
|
+
depthAction: TextureLoadAction.clear,
|
|
10617
|
+
stencilAction: TextureLoadAction.clear
|
|
10618
|
+
});
|
|
10619
|
+
}
|
|
10943
10620
|
renderer.renderMeshes(this.meshes);
|
|
10944
|
-
renderer.clear(this.storeAction);
|
|
10945
|
-
};
|
|
10946
|
-
_proto.onResize = function onResize() {
|
|
10947
|
-
var _this_framebuffer;
|
|
10948
|
-
var width = this.renderer.getWidth();
|
|
10949
|
-
var height = this.renderer.getHeight();
|
|
10950
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
10951
10621
|
};
|
|
10952
|
-
_proto.
|
|
10953
|
-
this.
|
|
10954
|
-
|
|
10622
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10623
|
+
if (this.useRenderTarget && this.framebuffer) {
|
|
10624
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
10625
|
+
}
|
|
10955
10626
|
};
|
|
10956
10627
|
return DrawObjectPass;
|
|
10957
10628
|
}(RenderPass);
|
|
10958
10629
|
|
|
10630
|
+
var ShaderCompileResultStatus;
|
|
10631
|
+
(function(ShaderCompileResultStatus) {
|
|
10632
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10633
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10634
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10635
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10636
|
+
})(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
|
|
10637
|
+
var GLSLVersion;
|
|
10638
|
+
(function(GLSLVersion) {
|
|
10639
|
+
GLSLVersion["GLSL1"] = "100";
|
|
10640
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
10641
|
+
})(GLSLVersion || (GLSLVersion = {}));
|
|
10642
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10643
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
10644
|
+
function ShaderVariant(engine, source) {
|
|
10645
|
+
var _this;
|
|
10646
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
10647
|
+
_this.source = source;
|
|
10648
|
+
return _this;
|
|
10649
|
+
}
|
|
10650
|
+
return ShaderVariant;
|
|
10651
|
+
}(EffectsObject);
|
|
10652
|
+
var Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10653
|
+
_inherits(Shader, EffectsObject);
|
|
10654
|
+
function Shader() {
|
|
10655
|
+
return EffectsObject.apply(this, arguments);
|
|
10656
|
+
}
|
|
10657
|
+
var _proto = Shader.prototype;
|
|
10658
|
+
_proto.createVariant = function createVariant(macros) {
|
|
10659
|
+
var shaderMacros = [];
|
|
10660
|
+
if (macros) {
|
|
10661
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10662
|
+
var key = _step.value;
|
|
10663
|
+
shaderMacros.push([
|
|
10664
|
+
key,
|
|
10665
|
+
macros[key]
|
|
10666
|
+
]);
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10670
|
+
shaderVariant.shader = this;
|
|
10671
|
+
return shaderVariant;
|
|
10672
|
+
};
|
|
10673
|
+
_proto.fromData = function fromData(data) {
|
|
10674
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
10675
|
+
this.shaderData = data;
|
|
10676
|
+
};
|
|
10677
|
+
return Shader;
|
|
10678
|
+
}(EffectsObject);
|
|
10679
|
+
Shader = __decorate([
|
|
10680
|
+
effectsClass(DataType.Shader)
|
|
10681
|
+
], Shader);
|
|
10682
|
+
|
|
10959
10683
|
var _obj$5;
|
|
10960
10684
|
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);
|
|
10961
10685
|
/**
|
|
@@ -12997,9 +12721,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
12997
12721
|
// Bloom 阈值 Pass
|
|
12998
12722
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
12999
12723
|
_inherits(BloomThresholdPass, RenderPass);
|
|
13000
|
-
function BloomThresholdPass(renderer
|
|
12724
|
+
function BloomThresholdPass(renderer) {
|
|
13001
12725
|
var _this;
|
|
13002
|
-
_this = RenderPass.call(this, renderer
|
|
12726
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13003
12727
|
var engine = _this.renderer.engine;
|
|
13004
12728
|
var geometry = Geometry.create(engine, {
|
|
13005
12729
|
mode: glContext.TRIANGLE_STRIP,
|
|
@@ -13038,12 +12762,11 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13038
12762
|
});
|
|
13039
12763
|
_this.priority = 5000;
|
|
13040
12764
|
_this.name = "BloomThresholdPass";
|
|
13041
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13042
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13043
12765
|
return _this;
|
|
13044
12766
|
}
|
|
13045
12767
|
var _proto = BloomThresholdPass.prototype;
|
|
13046
12768
|
_proto.configure = function configure(renderer) {
|
|
12769
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, renderer.getWidth(), renderer.getHeight(), 0, FilterMode.Linear, RenderTextureFormat.RGBAHalf);
|
|
13047
12770
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13048
12771
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
13049
12772
|
renderer.setFramebuffer(this.framebuffer);
|
|
@@ -13051,9 +12774,9 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13051
12774
|
_proto.execute = function execute(renderer) {
|
|
13052
12775
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
13053
12776
|
renderer.clear({
|
|
13054
|
-
colorAction:
|
|
13055
|
-
depthAction:
|
|
13056
|
-
stencilAction:
|
|
12777
|
+
colorAction: TextureLoadAction.clear,
|
|
12778
|
+
depthAction: TextureLoadAction.clear,
|
|
12779
|
+
stencilAction: TextureLoadAction.clear
|
|
13057
12780
|
});
|
|
13058
12781
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13059
12782
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
@@ -13063,23 +12786,21 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13063
12786
|
this.screenMesh
|
|
13064
12787
|
]);
|
|
13065
12788
|
};
|
|
13066
|
-
_proto.
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
12789
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12790
|
+
if (this.framebuffer) {
|
|
12791
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12792
|
+
}
|
|
13071
12793
|
};
|
|
13072
12794
|
_proto.dispose = function dispose(options) {
|
|
13073
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13074
12795
|
RenderPass.prototype.dispose.call(this, options);
|
|
13075
12796
|
};
|
|
13076
12797
|
return BloomThresholdPass;
|
|
13077
12798
|
}(RenderPass);
|
|
13078
12799
|
var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13079
12800
|
_inherits(HQGaussianDownSamplePass, RenderPass);
|
|
13080
|
-
function HQGaussianDownSamplePass(renderer, type, level
|
|
12801
|
+
function HQGaussianDownSamplePass(renderer, type, level) {
|
|
13081
12802
|
var _this;
|
|
13082
|
-
_this = RenderPass.call(this, renderer
|
|
12803
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13083
12804
|
_this.type = type;
|
|
13084
12805
|
_this.level = level;
|
|
13085
12806
|
var engine = _this.renderer.engine;
|
|
@@ -13126,25 +12847,21 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13126
12847
|
});
|
|
13127
12848
|
_this.priority = 5000;
|
|
13128
12849
|
_this.name = "GaussianDownPass" + type + level;
|
|
13129
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13130
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13131
12850
|
return _this;
|
|
13132
12851
|
}
|
|
13133
12852
|
var _proto = HQGaussianDownSamplePass.prototype;
|
|
13134
|
-
_proto.initialize = function initialize(renderer) {
|
|
13135
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13136
|
-
this.onResize();
|
|
13137
|
-
return this;
|
|
13138
|
-
};
|
|
13139
12853
|
_proto.configure = function configure(renderer) {
|
|
12854
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
|
|
12855
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
|
|
12856
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, FilterMode.Linear, RenderTextureFormat.RGBAHalf);
|
|
13140
12857
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13141
12858
|
renderer.setFramebuffer(this.framebuffer);
|
|
13142
12859
|
};
|
|
13143
12860
|
_proto.execute = function execute(renderer) {
|
|
13144
12861
|
renderer.clear({
|
|
13145
|
-
colorAction:
|
|
13146
|
-
depthAction:
|
|
13147
|
-
stencilAction:
|
|
12862
|
+
colorAction: TextureLoadAction.clear,
|
|
12863
|
+
depthAction: TextureLoadAction.clear,
|
|
12864
|
+
stencilAction: TextureLoadAction.clear
|
|
13148
12865
|
});
|
|
13149
12866
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13150
12867
|
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
@@ -13155,23 +12872,18 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13155
12872
|
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13156
12873
|
}
|
|
13157
12874
|
};
|
|
13158
|
-
_proto.
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13163
|
-
};
|
|
13164
|
-
_proto.dispose = function dispose(options) {
|
|
13165
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13166
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12875
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12876
|
+
if (this.framebuffer) {
|
|
12877
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12878
|
+
}
|
|
13167
12879
|
};
|
|
13168
12880
|
return HQGaussianDownSamplePass;
|
|
13169
12881
|
}(RenderPass);
|
|
13170
12882
|
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13171
12883
|
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
13172
|
-
function HQGaussianUpSamplePass(renderer, level
|
|
12884
|
+
function HQGaussianUpSamplePass(renderer, level) {
|
|
13173
12885
|
var _this;
|
|
13174
|
-
_this = RenderPass.call(this, renderer
|
|
12886
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13175
12887
|
_this.level = level;
|
|
13176
12888
|
var name = "PostProcess";
|
|
13177
12889
|
var engine = _this.renderer.engine;
|
|
@@ -13215,25 +12927,21 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13215
12927
|
});
|
|
13216
12928
|
_this.priority = 5000;
|
|
13217
12929
|
_this.name = "GaussianUpPass" + level;
|
|
13218
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13219
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13220
12930
|
return _this;
|
|
13221
12931
|
}
|
|
13222
12932
|
var _proto = HQGaussianUpSamplePass.prototype;
|
|
13223
|
-
_proto.initialize = function initialize(renderer) {
|
|
13224
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13225
|
-
this.onResize();
|
|
13226
|
-
return this;
|
|
13227
|
-
};
|
|
13228
12933
|
_proto.configure = function configure(renderer) {
|
|
12934
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
|
|
12935
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
|
|
12936
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, FilterMode.Linear, RenderTextureFormat.RGBAHalf);
|
|
13229
12937
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13230
12938
|
renderer.setFramebuffer(this.framebuffer);
|
|
13231
12939
|
};
|
|
13232
12940
|
_proto.execute = function execute(renderer) {
|
|
13233
12941
|
renderer.clear({
|
|
13234
|
-
colorAction:
|
|
13235
|
-
depthAction:
|
|
13236
|
-
stencilAction:
|
|
12942
|
+
colorAction: TextureLoadAction.clear,
|
|
12943
|
+
depthAction: TextureLoadAction.clear,
|
|
12944
|
+
stencilAction: TextureLoadAction.clear
|
|
13237
12945
|
});
|
|
13238
12946
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13239
12947
|
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
@@ -13242,15 +12950,10 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13242
12950
|
this.screenMesh
|
|
13243
12951
|
]);
|
|
13244
12952
|
};
|
|
13245
|
-
_proto.
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13250
|
-
};
|
|
13251
|
-
_proto.dispose = function dispose(options) {
|
|
13252
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13253
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12953
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12954
|
+
if (this.framebuffer) {
|
|
12955
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12956
|
+
}
|
|
13254
12957
|
};
|
|
13255
12958
|
return HQGaussianUpSamplePass;
|
|
13256
12959
|
}(RenderPass);
|
|
@@ -13259,7 +12962,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13259
12962
|
_inherits(ToneMappingPass, RenderPass);
|
|
13260
12963
|
function ToneMappingPass(renderer, sceneTextureHandle) {
|
|
13261
12964
|
var _this;
|
|
13262
|
-
_this = RenderPass.call(this, renderer
|
|
12965
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13263
12966
|
var name = "PostProcess";
|
|
13264
12967
|
var engine = _this.renderer.engine;
|
|
13265
12968
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
@@ -13315,9 +13018,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13315
13018
|
};
|
|
13316
13019
|
_proto.execute = function execute(renderer) {
|
|
13317
13020
|
renderer.clear({
|
|
13318
|
-
colorAction:
|
|
13319
|
-
depthAction:
|
|
13320
|
-
stencilAction:
|
|
13021
|
+
colorAction: TextureLoadAction.clear,
|
|
13022
|
+
depthAction: TextureLoadAction.clear,
|
|
13023
|
+
stencilAction: TextureLoadAction.clear
|
|
13321
13024
|
});
|
|
13322
13025
|
var globalVolume = renderer.renderingData.currentFrame.globalVolume;
|
|
13323
13026
|
var bloom = _extends({
|
|
@@ -13364,95 +13067,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13364
13067
|
return ToneMappingPass;
|
|
13365
13068
|
}(RenderPass);
|
|
13366
13069
|
|
|
13367
|
-
var SemanticMap = /*#__PURE__*/ function() {
|
|
13368
|
-
function SemanticMap(semantics) {
|
|
13369
|
-
if (semantics === void 0) semantics = {};
|
|
13370
|
-
this.semantics = _extends({}, semantics);
|
|
13371
|
-
}
|
|
13372
|
-
var _proto = SemanticMap.prototype;
|
|
13373
|
-
_proto.toObject = function toObject() {
|
|
13374
|
-
return _extends({}, this.semantics);
|
|
13375
|
-
};
|
|
13376
|
-
_proto.setSemantic = function setSemantic(name, value) {
|
|
13377
|
-
if (value === undefined) {
|
|
13378
|
-
delete this.semantics[name];
|
|
13379
|
-
} else {
|
|
13380
|
-
this.semantics[name] = value;
|
|
13381
|
-
}
|
|
13382
|
-
};
|
|
13383
|
-
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13384
|
-
var ret = this.semantics[name];
|
|
13385
|
-
if (isFunction(ret)) {
|
|
13386
|
-
return ret(state);
|
|
13387
|
-
}
|
|
13388
|
-
return ret;
|
|
13389
|
-
};
|
|
13390
|
-
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13391
|
-
return name in this.semantics;
|
|
13392
|
-
};
|
|
13393
|
-
_proto.dispose = function dispose() {
|
|
13394
|
-
var _this = this;
|
|
13395
|
-
Object.keys(this.semantics).forEach(function(name) {
|
|
13396
|
-
delete _this.semantics[name];
|
|
13397
|
-
});
|
|
13398
|
-
};
|
|
13399
|
-
return SemanticMap;
|
|
13400
|
-
}();
|
|
13401
|
-
|
|
13402
|
-
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
13403
13070
|
var seed$5 = 1;
|
|
13404
13071
|
/**
|
|
13405
13072
|
* RenderFrame 抽象类
|
|
13406
13073
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
13407
13074
|
function RenderFrame(options) {
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
this.
|
|
13411
|
-
|
|
13412
|
-
this.renderPassInfoMap = new WeakMap();
|
|
13413
|
-
var camera = options.camera, keepColorBuffer = options.keepColorBuffer, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13075
|
+
this.disposed = false;
|
|
13076
|
+
this.postProcessingEnabled = false;
|
|
13077
|
+
this.enableHDR = true;
|
|
13078
|
+
var camera = options.camera, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13414
13079
|
1,
|
|
13415
13080
|
1,
|
|
13416
13081
|
0,
|
|
13417
13082
|
0
|
|
13418
|
-
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled
|
|
13419
|
-
colorAction: TextureLoadAction.whatever,
|
|
13420
|
-
stencilAction: TextureLoadAction.clear,
|
|
13421
|
-
depthAction: TextureLoadAction.whatever
|
|
13422
|
-
} : _options_clearAction;
|
|
13083
|
+
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
|
|
13423
13084
|
var engine = renderer.engine;
|
|
13424
13085
|
if (globalVolume) {
|
|
13425
13086
|
this.globalVolume = globalVolume;
|
|
13426
13087
|
}
|
|
13088
|
+
this.postProcessingEnabled = postProcessingEnabled;
|
|
13427
13089
|
this.globalUniforms = new GlobalUniforms();
|
|
13428
|
-
var attachments = []; //渲染场景物体Pass的RT
|
|
13429
|
-
var depthStencilAttachment;
|
|
13430
13090
|
this.renderer = renderer;
|
|
13431
|
-
if (postProcessingEnabled) {
|
|
13432
|
-
|
|
13433
|
-
if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13434
|
-
throw new Error("Half float texture is not supported.");
|
|
13435
|
-
}
|
|
13436
|
-
// 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
|
|
13437
|
-
var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13438
|
-
attachments = [
|
|
13439
|
-
{
|
|
13440
|
-
texture: {
|
|
13441
|
-
format: glContext.RGBA,
|
|
13442
|
-
type: textureType,
|
|
13443
|
-
magFilter: glContext.LINEAR,
|
|
13444
|
-
minFilter: glContext.LINEAR
|
|
13445
|
-
}
|
|
13446
|
-
}
|
|
13447
|
-
];
|
|
13448
|
-
depthStencilAttachment = {
|
|
13449
|
-
storageType: RenderPassAttachmentStorageType.depth_stencil_opaque
|
|
13450
|
-
};
|
|
13091
|
+
if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13092
|
+
throw new Error("Half float texture is not supported.");
|
|
13451
13093
|
}
|
|
13452
|
-
this.drawObjectPass = new DrawObjectPass(renderer
|
|
13453
|
-
depthStencilAttachment: depthStencilAttachment,
|
|
13454
|
-
attachments: attachments
|
|
13455
|
-
});
|
|
13094
|
+
this.drawObjectPass = new DrawObjectPass(renderer);
|
|
13456
13095
|
var renderPasses = [
|
|
13457
13096
|
this.drawObjectPass
|
|
13458
13097
|
];
|
|
@@ -13467,48 +13106,13 @@ var seed$5 = 1;
|
|
|
13467
13106
|
this.renderer.getHeight() / 2
|
|
13468
13107
|
];
|
|
13469
13108
|
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13470
|
-
var
|
|
13471
|
-
var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13472
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer, {
|
|
13473
|
-
attachments: [
|
|
13474
|
-
{
|
|
13475
|
-
texture: {
|
|
13476
|
-
format: glContext.RGBA,
|
|
13477
|
-
type: textureType1,
|
|
13478
|
-
minFilter: glContext.LINEAR,
|
|
13479
|
-
magFilter: glContext.LINEAR
|
|
13480
|
-
}
|
|
13481
|
-
}
|
|
13482
|
-
]
|
|
13483
|
-
});
|
|
13109
|
+
var bloomThresholdPass = new BloomThresholdPass(renderer);
|
|
13484
13110
|
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13485
13111
|
this.addRenderPass(bloomThresholdPass);
|
|
13486
13112
|
for(var i = 0; i < gaussianStep; i++){
|
|
13487
13113
|
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13488
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i
|
|
13489
|
-
|
|
13490
|
-
{
|
|
13491
|
-
texture: {
|
|
13492
|
-
format: glContext.RGBA,
|
|
13493
|
-
type: textureType1,
|
|
13494
|
-
minFilter: glContext.LINEAR,
|
|
13495
|
-
magFilter: glContext.LINEAR
|
|
13496
|
-
}
|
|
13497
|
-
}
|
|
13498
|
-
]
|
|
13499
|
-
});
|
|
13500
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
|
|
13501
|
-
attachments: [
|
|
13502
|
-
{
|
|
13503
|
-
texture: {
|
|
13504
|
-
format: glContext.RGBA,
|
|
13505
|
-
type: textureType1,
|
|
13506
|
-
minFilter: glContext.LINEAR,
|
|
13507
|
-
magFilter: glContext.LINEAR
|
|
13508
|
-
}
|
|
13509
|
-
}
|
|
13510
|
-
]
|
|
13511
|
-
});
|
|
13114
|
+
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i);
|
|
13115
|
+
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i);
|
|
13512
13116
|
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13513
13117
|
this.addRenderPass(gaussianDownHPass);
|
|
13514
13118
|
this.addRenderPass(gaussianDownVPass);
|
|
@@ -13519,18 +13123,7 @@ var seed$5 = 1;
|
|
|
13519
13123
|
viewport[2] *= 4;
|
|
13520
13124
|
viewport[3] *= 4;
|
|
13521
13125
|
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13522
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1
|
|
13523
|
-
attachments: [
|
|
13524
|
-
{
|
|
13525
|
-
texture: {
|
|
13526
|
-
format: glContext.RGBA,
|
|
13527
|
-
type: textureType1,
|
|
13528
|
-
minFilter: glContext.LINEAR,
|
|
13529
|
-
magFilter: glContext.LINEAR
|
|
13530
|
-
}
|
|
13531
|
-
}
|
|
13532
|
-
]
|
|
13533
|
-
});
|
|
13126
|
+
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1);
|
|
13534
13127
|
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13535
13128
|
this.addRenderPass(gaussianUpPass);
|
|
13536
13129
|
viewport[2] *= 2;
|
|
@@ -13539,31 +13132,17 @@ var seed$5 = 1;
|
|
|
13539
13132
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13540
13133
|
this.addRenderPass(postProcessPass);
|
|
13541
13134
|
}
|
|
13542
|
-
this.semantics = new SemanticMap(options.semantics);
|
|
13543
|
-
this.clearAction = clearAction;
|
|
13544
13135
|
this.name = "RenderFrame" + seed$5++;
|
|
13545
|
-
var firstRP = renderPasses[0];
|
|
13546
13136
|
this.camera = camera;
|
|
13547
|
-
this.keepColorBuffer = keepColorBuffer;
|
|
13548
|
-
this.renderPassInfoMap.set(firstRP, {
|
|
13549
|
-
listStart: 0,
|
|
13550
|
-
listEnd: 0,
|
|
13551
|
-
renderPass: firstRP,
|
|
13552
|
-
intermedia: false
|
|
13553
|
-
});
|
|
13554
13137
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
13555
|
-
if (!options.clearAction) {
|
|
13556
|
-
this.resetClearActions();
|
|
13557
|
-
}
|
|
13558
|
-
this.passTextureCache = new PassTextureCache(engine);
|
|
13559
|
-
// FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
|
|
13560
|
-
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
13561
|
-
var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
|
|
13562
|
-
var shader = createCopyShader(level, writeDepth);
|
|
13563
|
-
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
13564
13138
|
}
|
|
13565
13139
|
var _proto = RenderFrame.prototype;
|
|
13566
13140
|
/**
|
|
13141
|
+
* 设置 RenderPasses 参数,此函数每帧调用一次
|
|
13142
|
+
*/ _proto.setup = function setup() {
|
|
13143
|
+
this.drawObjectPass.setup(this.postProcessingEnabled);
|
|
13144
|
+
};
|
|
13145
|
+
/**
|
|
13567
13146
|
* 根据 Mesh 优先级添加到 RenderPass
|
|
13568
13147
|
* @param mesh - 要添加的 Mesh 对象
|
|
13569
13148
|
*/ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
|
|
@@ -13580,78 +13159,25 @@ var seed$5 = 1;
|
|
|
13580
13159
|
* 销毁 RenderFrame
|
|
13581
13160
|
* @param options - 可以有选择销毁一些对象
|
|
13582
13161
|
*/ _proto.dispose = function dispose(options) {
|
|
13583
|
-
if ((options == null ? void 0 : options.semantics) !== DestroyOptions.keep) {
|
|
13584
|
-
this.semantics.dispose();
|
|
13585
|
-
}
|
|
13586
13162
|
var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
|
|
13587
13163
|
if (pass !== DestroyOptions.keep) {
|
|
13588
13164
|
this._renderPasses.forEach(function(renderPass) {
|
|
13589
13165
|
renderPass.dispose(pass);
|
|
13590
13166
|
});
|
|
13591
13167
|
}
|
|
13592
|
-
this.passTextureCache.dispose();
|
|
13593
13168
|
this._renderPasses.length = 0;
|
|
13594
|
-
this.
|
|
13595
|
-
};
|
|
13596
|
-
/**
|
|
13597
|
-
* 查找 Mesh 所在的 RenderPass 索引,没找到是-1
|
|
13598
|
-
* @param mesh - 需要查找的 Mesh
|
|
13599
|
-
*/ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
|
|
13600
|
-
var index = -1;
|
|
13601
|
-
this.renderPasses.every(function(rp, idx) {
|
|
13602
|
-
if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
|
|
13603
|
-
index = idx;
|
|
13604
|
-
return false;
|
|
13605
|
-
}
|
|
13606
|
-
return true;
|
|
13607
|
-
});
|
|
13608
|
-
return index;
|
|
13609
|
-
};
|
|
13610
|
-
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
13611
|
-
var info = this.renderPassInfoMap.get(renderPass);
|
|
13612
|
-
var priority = mesh.priority;
|
|
13613
|
-
if (!info) {
|
|
13614
|
-
return;
|
|
13615
|
-
}
|
|
13616
|
-
if (renderPass.meshes.length === 0) {
|
|
13617
|
-
info.listStart = info.listEnd = priority;
|
|
13618
|
-
} else {
|
|
13619
|
-
if (priority < info.listStart) {
|
|
13620
|
-
info.listStart = priority;
|
|
13621
|
-
} else if (priority > info.listEnd) {
|
|
13622
|
-
info.listEnd = priority;
|
|
13623
|
-
}
|
|
13624
|
-
}
|
|
13625
|
-
renderPass.addMesh(mesh);
|
|
13626
|
-
};
|
|
13627
|
-
_proto.resetClearActions = function resetClearActions() {
|
|
13628
|
-
var action = this.renderPasses.length > 1 ? TextureLoadAction.clear : TextureLoadAction.whatever;
|
|
13629
|
-
this.clearAction.stencilAction = action;
|
|
13630
|
-
this.clearAction.depthAction = action;
|
|
13631
|
-
this.clearAction.colorAction = action;
|
|
13632
|
-
if (this.keepColorBuffer) {
|
|
13633
|
-
this.clearAction.colorAction = TextureLoadAction.whatever;
|
|
13634
|
-
}
|
|
13169
|
+
this.disposed = true;
|
|
13635
13170
|
};
|
|
13636
13171
|
/**
|
|
13637
13172
|
* 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
|
|
13638
13173
|
* @param passes - RenderPass 数组
|
|
13639
13174
|
*/ _proto.setRenderPasses = function setRenderPasses(passes) {
|
|
13640
|
-
var _this = this;
|
|
13641
|
-
if (this.renderer !== undefined) {
|
|
13642
|
-
passes.forEach(function(pass) {
|
|
13643
|
-
return pass.initialize(_this.renderer);
|
|
13644
|
-
});
|
|
13645
|
-
}
|
|
13646
13175
|
this._renderPasses = passes.slice();
|
|
13647
13176
|
};
|
|
13648
13177
|
/**
|
|
13649
13178
|
* 添加 RenderPass
|
|
13650
13179
|
* @param pass - 需要添加的 RenderPass
|
|
13651
13180
|
*/ _proto.addRenderPass = function addRenderPass(pass) {
|
|
13652
|
-
if (this.renderer !== undefined) {
|
|
13653
|
-
pass.initialize(this.renderer);
|
|
13654
|
-
}
|
|
13655
13181
|
this._renderPasses.push(pass);
|
|
13656
13182
|
};
|
|
13657
13183
|
/**
|
|
@@ -13668,9 +13194,9 @@ var seed$5 = 1;
|
|
|
13668
13194
|
}
|
|
13669
13195
|
},
|
|
13670
13196
|
{
|
|
13671
|
-
key: "
|
|
13197
|
+
key: "isDisposed",
|
|
13672
13198
|
get: function get() {
|
|
13673
|
-
return this.
|
|
13199
|
+
return this.disposed;
|
|
13674
13200
|
}
|
|
13675
13201
|
}
|
|
13676
13202
|
]);
|
|
@@ -13679,10 +13205,6 @@ var seed$5 = 1;
|
|
|
13679
13205
|
function getTextureSize(tex) {
|
|
13680
13206
|
return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
|
|
13681
13207
|
}
|
|
13682
|
-
function findPreviousRenderPass(renderPasses, renderPass) {
|
|
13683
|
-
var index = renderPasses.indexOf(renderPass);
|
|
13684
|
-
return renderPasses[index - 1];
|
|
13685
|
-
}
|
|
13686
13208
|
var GlobalUniforms = function GlobalUniforms() {
|
|
13687
13209
|
this.floats = {};
|
|
13688
13210
|
this.ints = {};
|
|
@@ -13720,6 +13242,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
|
|
|
13720
13242
|
return Renderbuffer;
|
|
13721
13243
|
}();
|
|
13722
13244
|
|
|
13245
|
+
var RenderTargetPool = /*#__PURE__*/ function() {
|
|
13246
|
+
function RenderTargetPool(engine) {
|
|
13247
|
+
this.engine = engine;
|
|
13248
|
+
this.temporaryRTs = [];
|
|
13249
|
+
this.currentFrame = 0;
|
|
13250
|
+
this.maxUnusedFrames = 4;
|
|
13251
|
+
}
|
|
13252
|
+
var _proto = RenderTargetPool.prototype;
|
|
13253
|
+
/**
|
|
13254
|
+
* 清理 RenderTarget 池
|
|
13255
|
+
* @param force - 是否强制清理所有未占用的 RT
|
|
13256
|
+
* @param framesOffset - 自定义未使用帧数阈值,-1 表示使用默认值
|
|
13257
|
+
*/ _proto.flush = function flush(force, framesOffset) {
|
|
13258
|
+
if (force === void 0) force = false;
|
|
13259
|
+
if (framesOffset === void 0) framesOffset = -1;
|
|
13260
|
+
this.currentFrame++;
|
|
13261
|
+
var threshold = framesOffset >= 0 ? framesOffset : this.maxUnusedFrames;
|
|
13262
|
+
for(var i = 0; i < this.temporaryRTs.length; i++){
|
|
13263
|
+
var entry = this.temporaryRTs[i];
|
|
13264
|
+
// 强制清理所有未占用的 RT,或清理超过阈值帧数未使用的 RT
|
|
13265
|
+
if (!entry.isOccupied && (force || this.currentFrame - entry.lastFrameReleased > threshold)) {
|
|
13266
|
+
entry.RT.dispose();
|
|
13267
|
+
this.temporaryRTs.splice(i--, 1);
|
|
13268
|
+
}
|
|
13269
|
+
}
|
|
13270
|
+
};
|
|
13271
|
+
_proto.get = function get(name, width, height, depthBuffer, filter, format) {
|
|
13272
|
+
if (depthBuffer === void 0) depthBuffer = 0;
|
|
13273
|
+
if (filter === void 0) filter = FilterMode.Linear;
|
|
13274
|
+
if (format === void 0) format = RenderTextureFormat.RGBA32;
|
|
13275
|
+
// 使用参数计算 hash 值作为缓存 key
|
|
13276
|
+
var hash = width + "_" + height + "_" + depthBuffer + "_" + filter + "_" + format;
|
|
13277
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13278
|
+
var entry = _step.value;
|
|
13279
|
+
if (!entry.isOccupied && entry.descriptionHash === hash) {
|
|
13280
|
+
entry.isOccupied = true;
|
|
13281
|
+
entry.RT.name = name;
|
|
13282
|
+
return entry.RT;
|
|
13283
|
+
}
|
|
13284
|
+
}
|
|
13285
|
+
var textureFilter;
|
|
13286
|
+
var textureType;
|
|
13287
|
+
var depthType = RenderPassAttachmentStorageType.none;
|
|
13288
|
+
// TODO 建立Map映射
|
|
13289
|
+
if (filter === FilterMode.Linear) {
|
|
13290
|
+
textureFilter = glContext.LINEAR;
|
|
13291
|
+
} else if (filter === FilterMode.Nearest) {
|
|
13292
|
+
textureFilter = glContext.NEAREST;
|
|
13293
|
+
}
|
|
13294
|
+
if (format === RenderTextureFormat.RGBA32) {
|
|
13295
|
+
textureType = glContext.UNSIGNED_BYTE;
|
|
13296
|
+
} else if (format === RenderTextureFormat.RGBAHalf) {
|
|
13297
|
+
textureType = glContext.HALF_FLOAT;
|
|
13298
|
+
}
|
|
13299
|
+
if (depthBuffer === 0) {
|
|
13300
|
+
depthType = RenderPassAttachmentStorageType.none;
|
|
13301
|
+
} else if (depthBuffer === 16) {
|
|
13302
|
+
depthType = RenderPassAttachmentStorageType.depth_stencil_opaque;
|
|
13303
|
+
} else if (depthBuffer === 24) {
|
|
13304
|
+
depthType = RenderPassAttachmentStorageType.depth_24_stencil_8_texture;
|
|
13305
|
+
}
|
|
13306
|
+
var colorAttachment = Texture.create(this.engine, {
|
|
13307
|
+
sourceType: TextureSourceType.framebuffer,
|
|
13308
|
+
minFilter: textureFilter,
|
|
13309
|
+
magFilter: textureFilter,
|
|
13310
|
+
internalFormat: glContext.RGBA,
|
|
13311
|
+
format: glContext.RGBA,
|
|
13312
|
+
type: textureType
|
|
13313
|
+
});
|
|
13314
|
+
var newFramebuffer = Framebuffer.create({
|
|
13315
|
+
name: name,
|
|
13316
|
+
storeAction: {},
|
|
13317
|
+
viewport: [
|
|
13318
|
+
0,
|
|
13319
|
+
0,
|
|
13320
|
+
width,
|
|
13321
|
+
height
|
|
13322
|
+
],
|
|
13323
|
+
attachments: [
|
|
13324
|
+
colorAttachment
|
|
13325
|
+
],
|
|
13326
|
+
depthStencilAttachment: {
|
|
13327
|
+
storageType: depthType
|
|
13328
|
+
}
|
|
13329
|
+
}, this.engine.renderer);
|
|
13330
|
+
var entry1 = {
|
|
13331
|
+
RT: newFramebuffer,
|
|
13332
|
+
lastFrameReleased: 0,
|
|
13333
|
+
descriptionHash: hash,
|
|
13334
|
+
isOccupied: true
|
|
13335
|
+
};
|
|
13336
|
+
this.temporaryRTs.push(entry1);
|
|
13337
|
+
return entry1.RT;
|
|
13338
|
+
};
|
|
13339
|
+
/**
|
|
13340
|
+
* 释放 RenderTarget,使其可以被复用
|
|
13341
|
+
* @param rt - 要释放的 Framebuffer
|
|
13342
|
+
*/ _proto.release = function release(rt) {
|
|
13343
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13344
|
+
var entry = _step.value;
|
|
13345
|
+
if (entry.RT === rt) {
|
|
13346
|
+
entry.isOccupied = false;
|
|
13347
|
+
entry.lastFrameReleased = this.currentFrame;
|
|
13348
|
+
break;
|
|
13349
|
+
}
|
|
13350
|
+
}
|
|
13351
|
+
};
|
|
13352
|
+
_proto.dispose = function dispose() {
|
|
13353
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13354
|
+
var entry = _step.value;
|
|
13355
|
+
entry.RT.dispose();
|
|
13356
|
+
}
|
|
13357
|
+
};
|
|
13358
|
+
return RenderTargetPool;
|
|
13359
|
+
}();
|
|
13360
|
+
|
|
13723
13361
|
var isWebGL2Available = typeof WebGL2RenderingContext === "function";
|
|
13724
13362
|
var GPUCapability = /*#__PURE__*/ function() {
|
|
13725
13363
|
function GPUCapability(gl) {
|
|
@@ -13905,70 +13543,11 @@ var CompressTextureCapabilityType;
|
|
|
13905
13543
|
return !!hasCompressedTextureSupport;
|
|
13906
13544
|
}
|
|
13907
13545
|
|
|
13908
|
-
var FilterMode;
|
|
13909
|
-
(function(FilterMode) {
|
|
13910
|
-
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
13911
|
-
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
13912
|
-
})(FilterMode || (FilterMode = {}));
|
|
13913
|
-
var RenderTextureFormat;
|
|
13914
|
-
(function(RenderTextureFormat) {
|
|
13915
|
-
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
13916
|
-
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
13917
|
-
})(RenderTextureFormat || (RenderTextureFormat = {}));
|
|
13918
|
-
/**
|
|
13919
|
-
*
|
|
13920
|
-
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
13921
|
-
function Framebuffer() {}
|
|
13922
|
-
var _proto = Framebuffer.prototype;
|
|
13923
|
-
_proto.resize = function resize(x, y, width, height) {
|
|
13924
|
-
// OVERRIDE
|
|
13925
|
-
};
|
|
13926
|
-
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
13927
|
-
// OVERRIDE
|
|
13928
|
-
};
|
|
13929
|
-
_proto.unbind = function unbind() {
|
|
13930
|
-
// OVERRIDE
|
|
13931
|
-
};
|
|
13932
|
-
_proto.bind = function bind() {
|
|
13933
|
-
// OVERRIDE
|
|
13934
|
-
};
|
|
13935
|
-
_proto.getDepthTexture = function getDepthTexture() {
|
|
13936
|
-
// OVERRIDE
|
|
13937
|
-
return undefined;
|
|
13938
|
-
};
|
|
13939
|
-
_proto.getStencilTexture = function getStencilTexture() {
|
|
13940
|
-
// OVERRIDE
|
|
13941
|
-
return undefined;
|
|
13942
|
-
};
|
|
13943
|
-
_proto.getColorTextures = function getColorTextures() {
|
|
13944
|
-
// OVERRIDE
|
|
13945
|
-
return [];
|
|
13946
|
-
};
|
|
13947
|
-
_proto.dispose = function dispose(options) {
|
|
13948
|
-
// OVERRIDE
|
|
13949
|
-
};
|
|
13950
|
-
_create_class(Framebuffer, [
|
|
13951
|
-
{
|
|
13952
|
-
key: "stencilStorage",
|
|
13953
|
-
get: function get() {
|
|
13954
|
-
// OVERRIDE
|
|
13955
|
-
return undefined;
|
|
13956
|
-
}
|
|
13957
|
-
},
|
|
13958
|
-
{
|
|
13959
|
-
key: "depthStorage",
|
|
13960
|
-
get: function get() {
|
|
13961
|
-
// OVERRIDE
|
|
13962
|
-
return undefined;
|
|
13963
|
-
}
|
|
13964
|
-
}
|
|
13965
|
-
]);
|
|
13966
|
-
return Framebuffer;
|
|
13967
|
-
}();
|
|
13968
|
-
|
|
13969
13546
|
var Renderer = /*#__PURE__*/ function() {
|
|
13970
13547
|
function Renderer(engine) {
|
|
13971
13548
|
this.engine = engine;
|
|
13549
|
+
this.currentFramebuffer = null;
|
|
13550
|
+
this.renderTargetPool = new RenderTargetPool(engine);
|
|
13972
13551
|
}
|
|
13973
13552
|
var _proto = Renderer.prototype;
|
|
13974
13553
|
_proto.setGlobalFloat = function setGlobalFloat(name, value) {
|
|
@@ -14038,8 +13617,10 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14038
13617
|
// OVERRIDE
|
|
14039
13618
|
};
|
|
14040
13619
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
14041
|
-
|
|
14042
|
-
|
|
13620
|
+
return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
13621
|
+
};
|
|
13622
|
+
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13623
|
+
this.renderTargetPool.release(rt);
|
|
14043
13624
|
};
|
|
14044
13625
|
_proto.dispose = function dispose() {
|
|
14045
13626
|
// OVERRIDE
|
|
@@ -14047,6 +13628,41 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14047
13628
|
return Renderer;
|
|
14048
13629
|
}();
|
|
14049
13630
|
|
|
13631
|
+
var SemanticMap = /*#__PURE__*/ function() {
|
|
13632
|
+
function SemanticMap(semantics) {
|
|
13633
|
+
if (semantics === void 0) semantics = {};
|
|
13634
|
+
this.semantics = _extends({}, semantics);
|
|
13635
|
+
}
|
|
13636
|
+
var _proto = SemanticMap.prototype;
|
|
13637
|
+
_proto.toObject = function toObject() {
|
|
13638
|
+
return _extends({}, this.semantics);
|
|
13639
|
+
};
|
|
13640
|
+
_proto.setSemantic = function setSemantic(name, value) {
|
|
13641
|
+
if (value === undefined) {
|
|
13642
|
+
delete this.semantics[name];
|
|
13643
|
+
} else {
|
|
13644
|
+
this.semantics[name] = value;
|
|
13645
|
+
}
|
|
13646
|
+
};
|
|
13647
|
+
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13648
|
+
var ret = this.semantics[name];
|
|
13649
|
+
if (isFunction(ret)) {
|
|
13650
|
+
return ret(state);
|
|
13651
|
+
}
|
|
13652
|
+
return ret;
|
|
13653
|
+
};
|
|
13654
|
+
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13655
|
+
return name in this.semantics;
|
|
13656
|
+
};
|
|
13657
|
+
_proto.dispose = function dispose() {
|
|
13658
|
+
var _this = this;
|
|
13659
|
+
Object.keys(this.semantics).forEach(function(name) {
|
|
13660
|
+
delete _this.semantics[name];
|
|
13661
|
+
});
|
|
13662
|
+
};
|
|
13663
|
+
return SemanticMap;
|
|
13664
|
+
}();
|
|
13665
|
+
|
|
14050
13666
|
/**
|
|
14051
13667
|
* @since 2.7.0
|
|
14052
13668
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -18077,6 +17693,11 @@ var PlayState;
|
|
|
18077
17693
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
18078
17694
|
})(PlayState || (PlayState = {}));
|
|
18079
17695
|
|
|
17696
|
+
function _assert_this_initialized(self) {
|
|
17697
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17698
|
+
return self;
|
|
17699
|
+
}
|
|
17700
|
+
|
|
18080
17701
|
var tempQuat$1 = new Quaternion();
|
|
18081
17702
|
var tempVector3 = new Vector3();
|
|
18082
17703
|
var tempVector3Second = new Vector3();
|
|
@@ -24454,8 +24075,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24454
24075
|
_this.reusable = reusable;
|
|
24455
24076
|
_this.speed = speed;
|
|
24456
24077
|
_this.name = sourceContent.name;
|
|
24457
|
-
_this
|
|
24458
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24078
|
+
PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24459
24079
|
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24460
24080
|
aspect: width / height,
|
|
24461
24081
|
pixelWidth: width,
|
|
@@ -24469,7 +24089,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24469
24089
|
_this.createRenderFrame();
|
|
24470
24090
|
Composition.buildItemTree(_this.rootItem);
|
|
24471
24091
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
24472
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24473
24092
|
return _this;
|
|
24474
24093
|
}
|
|
24475
24094
|
var _proto = Composition.prototype;
|
|
@@ -24579,12 +24198,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24579
24198
|
this.renderFrame = new RenderFrame({
|
|
24580
24199
|
camera: this.camera,
|
|
24581
24200
|
renderer: this.renderer,
|
|
24582
|
-
keepColorBuffer: this.keepColorBuffer,
|
|
24583
24201
|
globalVolume: this.globalVolume,
|
|
24584
24202
|
postProcessingEnabled: this.postProcessingEnabled
|
|
24585
24203
|
});
|
|
24586
|
-
// TODO 考虑放到构造函数
|
|
24587
|
-
this.renderFrame.cachedTextures = this.textures;
|
|
24588
24204
|
};
|
|
24589
24205
|
/**
|
|
24590
24206
|
* 跳到指定时间点(不做任何播放行为)
|
|
@@ -24635,7 +24251,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24635
24251
|
this.isEnded = false;
|
|
24636
24252
|
this.isEndCalled = false;
|
|
24637
24253
|
this.rootComposition.time = 0;
|
|
24638
|
-
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24639
24254
|
};
|
|
24640
24255
|
_proto.prepareRender = function prepareRender() {};
|
|
24641
24256
|
/**
|
|
@@ -24653,8 +24268,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24653
24268
|
var previousCompositionTime = this.time;
|
|
24654
24269
|
this.updateCompositionTime(deltaTime * this.speed / 1000);
|
|
24655
24270
|
var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
|
|
24656
|
-
// 更新 model-tree-plugin
|
|
24657
|
-
this.updatePluginLoaders(deltaTimeInMs);
|
|
24658
24271
|
this.sceneTicking.update.tick(deltaTimeInMs);
|
|
24659
24272
|
this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
|
|
24660
24273
|
this.updateCamera();
|
|
@@ -24679,15 +24292,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24679
24292
|
this.camera.updateMatrix();
|
|
24680
24293
|
};
|
|
24681
24294
|
/**
|
|
24682
|
-
* 插件更新,来自 CompVFXItem 的更新调用
|
|
24683
|
-
* @param deltaTime - 更新的时间步长
|
|
24684
|
-
*/ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
|
|
24685
|
-
var _this = this;
|
|
24686
|
-
this.pluginSystem.plugins.forEach(function(loader) {
|
|
24687
|
-
return loader.onCompositionUpdate(_this, deltaTime);
|
|
24688
|
-
});
|
|
24689
|
-
};
|
|
24690
|
-
/**
|
|
24691
24295
|
* 更新主合成组件
|
|
24692
24296
|
*/ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
|
|
24693
24297
|
if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
|
|
@@ -24846,7 +24450,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24846
24450
|
* 合成对象销毁
|
|
24847
24451
|
*/ _proto.dispose = function dispose() {
|
|
24848
24452
|
var _this = this;
|
|
24849
|
-
var _this_pluginSystem;
|
|
24850
24453
|
if (this.destroyed) {
|
|
24851
24454
|
return;
|
|
24852
24455
|
}
|
|
@@ -24866,13 +24469,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24866
24469
|
this.rootItem.dispose();
|
|
24867
24470
|
// FIXME: 注意这里增加了renderFrame销毁
|
|
24868
24471
|
this.renderFrame.dispose();
|
|
24869
|
-
|
|
24472
|
+
PluginSystem.destroyComposition(this);
|
|
24870
24473
|
this.update = function() {
|
|
24871
24474
|
{
|
|
24872
24475
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
24873
24476
|
}
|
|
24874
24477
|
};
|
|
24875
24478
|
this.dispose = noop;
|
|
24479
|
+
this.renderer.engine.removeComposition(this);
|
|
24876
24480
|
if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
24877
24481
|
return;
|
|
24878
24482
|
}
|
|
@@ -24889,7 +24493,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24889
24493
|
0
|
|
24890
24494
|
]
|
|
24891
24495
|
});
|
|
24892
|
-
this.renderer.engine.removeComposition(this);
|
|
24893
24496
|
};
|
|
24894
24497
|
/**
|
|
24895
24498
|
* 编辑器使用的 transform 修改方法
|
|
@@ -31864,7 +31467,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31864
31467
|
return ret;
|
|
31865
31468
|
}
|
|
31866
31469
|
|
|
31867
|
-
var version$1 = "2.8.0-alpha.
|
|
31470
|
+
var version$1 = "2.8.0-alpha.2";
|
|
31868
31471
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31869
31472
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31870
31473
|
var reverseParticle = false;
|
|
@@ -32379,7 +31982,7 @@ var seed = 1;
|
|
|
32379
31982
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
32380
31983
|
* @param options - 扩展参数
|
|
32381
31984
|
* @returns
|
|
32382
|
-
*/ _proto.loadScene = function loadScene(url, renderer
|
|
31985
|
+
*/ _proto.loadScene = function loadScene(url, renderer) {
|
|
32383
31986
|
var _this = this;
|
|
32384
31987
|
return _async_to_generator(function() {
|
|
32385
31988
|
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
@@ -32440,7 +32043,7 @@ var seed = 1;
|
|
|
32440
32043
|
});
|
|
32441
32044
|
});
|
|
32442
32045
|
loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
|
|
32443
|
-
var scene, link,
|
|
32046
|
+
var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
|
|
32444
32047
|
return __generator(this, function(_state) {
|
|
32445
32048
|
switch(_state.label){
|
|
32446
32049
|
case 0:
|
|
@@ -32490,7 +32093,26 @@ var seed = 1;
|
|
|
32490
32093
|
})
|
|
32491
32094
|
];
|
|
32492
32095
|
case 5:
|
|
32493
|
-
|
|
32096
|
+
jsonScene = _state.sent().jsonScene;
|
|
32097
|
+
scene = {
|
|
32098
|
+
timeInfos: timeInfos,
|
|
32099
|
+
url: url,
|
|
32100
|
+
storage: {},
|
|
32101
|
+
jsonScene: jsonScene,
|
|
32102
|
+
bins: [],
|
|
32103
|
+
textureOptions: [],
|
|
32104
|
+
textures: [],
|
|
32105
|
+
images: [],
|
|
32106
|
+
assets: _this.assets
|
|
32107
|
+
};
|
|
32108
|
+
return [
|
|
32109
|
+
4,
|
|
32110
|
+
hookTimeInfo("plugin:processAssets", function() {
|
|
32111
|
+
return _this.processPluginAssets(scene);
|
|
32112
|
+
})
|
|
32113
|
+
];
|
|
32114
|
+
case 6:
|
|
32115
|
+
_state.sent();
|
|
32494
32116
|
_jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
|
|
32495
32117
|
return [
|
|
32496
32118
|
4,
|
|
@@ -32501,46 +32123,26 @@ var seed = 1;
|
|
|
32501
32123
|
hookTimeInfo("processImages", function() {
|
|
32502
32124
|
return _this.processImages(images, isKTX2Supported);
|
|
32503
32125
|
}),
|
|
32504
|
-
hookTimeInfo("plugin:processAssets", function() {
|
|
32505
|
-
return _this.processPluginAssets(jsonScene, pluginSystem, options);
|
|
32506
|
-
}),
|
|
32507
32126
|
hookTimeInfo("processFontURL", function() {
|
|
32508
32127
|
return _this.processFontURL(fonts);
|
|
32509
32128
|
})
|
|
32510
32129
|
])
|
|
32511
32130
|
];
|
|
32512
|
-
case
|
|
32513
|
-
|
|
32131
|
+
case 7:
|
|
32132
|
+
_ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
|
|
32514
32133
|
return [
|
|
32515
32134
|
4,
|
|
32516
32135
|
hookTimeInfo("processTextures", function() {
|
|
32517
32136
|
return _this.processTextures(loadedImages, loadedBins, jsonScene);
|
|
32518
32137
|
})
|
|
32519
32138
|
];
|
|
32520
|
-
case 7:
|
|
32521
|
-
loadedTextures = _state.sent();
|
|
32522
|
-
scene = {
|
|
32523
|
-
timeInfos: timeInfos,
|
|
32524
|
-
url: url,
|
|
32525
|
-
renderLevel: _this.options.renderLevel,
|
|
32526
|
-
storage: {},
|
|
32527
|
-
pluginSystem: pluginSystem,
|
|
32528
|
-
jsonScene: jsonScene,
|
|
32529
|
-
bins: loadedBins,
|
|
32530
|
-
textureOptions: loadedTextures,
|
|
32531
|
-
textures: [],
|
|
32532
|
-
images: loadedImages,
|
|
32533
|
-
assets: _this.assets
|
|
32534
|
-
};
|
|
32535
|
-
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
32536
|
-
return [
|
|
32537
|
-
4,
|
|
32538
|
-
hookTimeInfo("plugin:prepareResource", function() {
|
|
32539
|
-
return pluginSystem.loadResources(scene, _this.options);
|
|
32540
|
-
})
|
|
32541
|
-
];
|
|
32542
32139
|
case 8:
|
|
32543
|
-
_state.sent();
|
|
32140
|
+
loadedTextures = _state.sent();
|
|
32141
|
+
(_scene_bins = scene.bins).push.apply(_scene_bins, [].concat(loadedBins));
|
|
32142
|
+
(_scene_textureOptions = scene.textureOptions).push.apply(_scene_textureOptions, [].concat(loadedTextures));
|
|
32143
|
+
(_scene_images = scene.images).push.apply(_scene_images, [].concat(loadedImages));
|
|
32144
|
+
// 降级插件会修改 this.options.renderLevel, 在 processPluginAssets 后赋值
|
|
32145
|
+
scene.renderLevel = _this.options.renderLevel;
|
|
32544
32146
|
_state.label = 9;
|
|
32545
32147
|
case 9:
|
|
32546
32148
|
totalTime = performance.now() - startTime;
|
|
@@ -32572,29 +32174,23 @@ var seed = 1;
|
|
|
32572
32174
|
return this.assets;
|
|
32573
32175
|
};
|
|
32574
32176
|
_proto.processJSON = function processJSON(json) {
|
|
32575
|
-
var _this = this;
|
|
32576
32177
|
return _async_to_generator(function() {
|
|
32577
|
-
var jsonScene, _jsonScene_plugins, plugins,
|
|
32178
|
+
var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
|
|
32578
32179
|
return __generator(this, function(_state) {
|
|
32579
|
-
|
|
32580
|
-
|
|
32581
|
-
|
|
32582
|
-
|
|
32583
|
-
|
|
32584
|
-
|
|
32585
|
-
|
|
32586
|
-
pluginSystem.processRawJSON(jsonScene, _this.options)
|
|
32587
|
-
];
|
|
32588
|
-
case 1:
|
|
32589
|
-
_state.sent();
|
|
32590
|
-
return [
|
|
32591
|
-
2,
|
|
32592
|
-
{
|
|
32593
|
-
jsonScene: jsonScene,
|
|
32594
|
-
pluginSystem: pluginSystem
|
|
32595
|
-
}
|
|
32596
|
-
];
|
|
32180
|
+
jsonScene = getStandardJSON(json);
|
|
32181
|
+
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
|
|
32182
|
+
for(_iterator = _create_for_of_iterator_helper_loose(plugins); !(_step = _iterator()).done;){
|
|
32183
|
+
customPluginName = _step.value;
|
|
32184
|
+
if (!pluginLoaderMap[customPluginName]) {
|
|
32185
|
+
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
32186
|
+
}
|
|
32597
32187
|
}
|
|
32188
|
+
return [
|
|
32189
|
+
2,
|
|
32190
|
+
{
|
|
32191
|
+
jsonScene: jsonScene
|
|
32192
|
+
}
|
|
32193
|
+
];
|
|
32598
32194
|
});
|
|
32599
32195
|
})();
|
|
32600
32196
|
};
|
|
@@ -32800,30 +32396,18 @@ var seed = 1;
|
|
|
32800
32396
|
});
|
|
32801
32397
|
})();
|
|
32802
32398
|
};
|
|
32803
|
-
_proto.processPluginAssets = function processPluginAssets(
|
|
32399
|
+
_proto.processPluginAssets = function processPluginAssets(scene) {
|
|
32804
32400
|
var _this = this;
|
|
32805
32401
|
return _async_to_generator(function() {
|
|
32806
|
-
var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
|
|
32807
32402
|
return __generator(this, function(_state) {
|
|
32808
32403
|
switch(_state.label){
|
|
32809
32404
|
case 0:
|
|
32810
32405
|
return [
|
|
32811
32406
|
4,
|
|
32812
|
-
|
|
32407
|
+
PluginSystem.processAssets(scene, _this.options)
|
|
32813
32408
|
];
|
|
32814
32409
|
case 1:
|
|
32815
|
-
|
|
32816
|
-
_pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
|
|
32817
|
-
acc.assets = acc.assets.concat(cur.assets);
|
|
32818
|
-
acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
|
|
32819
|
-
return acc;
|
|
32820
|
-
}, {
|
|
32821
|
-
assets: [],
|
|
32822
|
-
loadedAssets: []
|
|
32823
|
-
}), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
|
|
32824
|
-
for(i = 0; i < assets.length; i++){
|
|
32825
|
-
_this.assets[assets[i].id] = loadedAssets[i];
|
|
32826
|
-
}
|
|
32410
|
+
_state.sent();
|
|
32827
32411
|
return [
|
|
32828
32412
|
2
|
|
32829
32413
|
];
|
|
@@ -33250,7 +32834,6 @@ function _createTextureOptionsBySource() {
|
|
|
33250
32834
|
}
|
|
33251
32835
|
};
|
|
33252
32836
|
_proto.prepareAssets = function prepareAssets(scene, assets) {
|
|
33253
|
-
this.engine.clearResources();
|
|
33254
32837
|
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
|
|
33255
32838
|
var assetId = _step.value;
|
|
33256
32839
|
var asset = assets[assetId];
|
|
@@ -35162,8 +34745,9 @@ var DEFAULT_FPS = 60;
|
|
|
35162
34745
|
]
|
|
35163
34746
|
});
|
|
35164
34747
|
for(var i1 = 0; i1 < comps.length; i1++){
|
|
35165
|
-
!comps[i1].renderFrame.
|
|
34748
|
+
!comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
|
|
35166
34749
|
}
|
|
34750
|
+
this.renderer.renderTargetPool.flush();
|
|
35167
34751
|
};
|
|
35168
34752
|
/**
|
|
35169
34753
|
* 将渲染器重新和父容器大小对齐
|
|
@@ -35409,6 +34993,95 @@ var DEFAULT_FPS = 60;
|
|
|
35409
34993
|
return Engine;
|
|
35410
34994
|
}(EventEmitter);
|
|
35411
34995
|
|
|
34996
|
+
var def = {
|
|
34997
|
+
format: glContext.RGBA,
|
|
34998
|
+
type: glContext.UNSIGNED_BYTE,
|
|
34999
|
+
minFilter: glContext.LINEAR,
|
|
35000
|
+
magFilter: glContext.LINEAR,
|
|
35001
|
+
wrapS: glContext.CLAMP_TO_EDGE,
|
|
35002
|
+
wrapT: glContext.CLAMP_TO_EDGE
|
|
35003
|
+
};
|
|
35004
|
+
var disposeSymbol = Symbol("dispose");
|
|
35005
|
+
var PassTextureCache = /*#__PURE__*/ function() {
|
|
35006
|
+
function PassTextureCache(engine) {
|
|
35007
|
+
this.textureCache = {};
|
|
35008
|
+
this.textureRef = {};
|
|
35009
|
+
this.engine = engine;
|
|
35010
|
+
}
|
|
35011
|
+
var _proto = PassTextureCache.prototype;
|
|
35012
|
+
_proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
|
|
35013
|
+
var _this = this;
|
|
35014
|
+
var width = request.width, height = request.height, name = request.name;
|
|
35015
|
+
var options = {
|
|
35016
|
+
sourceType: TextureSourceType.framebuffer,
|
|
35017
|
+
data: {
|
|
35018
|
+
width: width,
|
|
35019
|
+
height: height
|
|
35020
|
+
},
|
|
35021
|
+
name: name
|
|
35022
|
+
};
|
|
35023
|
+
var keys = [
|
|
35024
|
+
name
|
|
35025
|
+
];
|
|
35026
|
+
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
35027
|
+
var _request_name;
|
|
35028
|
+
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
35029
|
+
options[name] = value;
|
|
35030
|
+
keys.push(name, value);
|
|
35031
|
+
});
|
|
35032
|
+
var cacheId = keys.join(":");
|
|
35033
|
+
var tex = this.textureCache[cacheId];
|
|
35034
|
+
if (tex) {
|
|
35035
|
+
this.textureRef[cacheId]++;
|
|
35036
|
+
} else {
|
|
35037
|
+
var engine = this.engine;
|
|
35038
|
+
assertExist(engine);
|
|
35039
|
+
tex = Texture.create(engine, options);
|
|
35040
|
+
this.textureCache[cacheId] = tex;
|
|
35041
|
+
this.textureRef[cacheId] = 1;
|
|
35042
|
+
// @ts-expect-error
|
|
35043
|
+
tex[disposeSymbol] = tex.dispose;
|
|
35044
|
+
tex.dispose = function() {
|
|
35045
|
+
return _this.removeTexture(cacheId);
|
|
35046
|
+
};
|
|
35047
|
+
}
|
|
35048
|
+
return tex;
|
|
35049
|
+
};
|
|
35050
|
+
_proto.removeTexture = function removeTexture(id) {
|
|
35051
|
+
var refCount = this.textureRef[id];
|
|
35052
|
+
if (refCount <= 1) {
|
|
35053
|
+
if (refCount < 0) {
|
|
35054
|
+
console.error("Ref count < 0.");
|
|
35055
|
+
}
|
|
35056
|
+
var tex = this.textureCache[id];
|
|
35057
|
+
if (tex) {
|
|
35058
|
+
// @ts-expect-error
|
|
35059
|
+
tex[disposeSymbol]();
|
|
35060
|
+
// @ts-expect-error
|
|
35061
|
+
tex.dispose = tex[disposeSymbol];
|
|
35062
|
+
}
|
|
35063
|
+
delete this.textureCache[id];
|
|
35064
|
+
delete this.textureRef[id];
|
|
35065
|
+
} else {
|
|
35066
|
+
this.textureRef[id] = refCount - 1;
|
|
35067
|
+
}
|
|
35068
|
+
};
|
|
35069
|
+
_proto.dispose = function dispose() {
|
|
35070
|
+
var _this = this;
|
|
35071
|
+
Object.keys(this.textureCache).forEach(function(key) {
|
|
35072
|
+
var texture = _this.textureCache[key];
|
|
35073
|
+
// @ts-expect-error
|
|
35074
|
+
texture[disposeSymbol]();
|
|
35075
|
+
// @ts-expect-error
|
|
35076
|
+
texture.dispose = texture[disposeSymbol];
|
|
35077
|
+
});
|
|
35078
|
+
this.textureCache = {};
|
|
35079
|
+
this.textureRef = {};
|
|
35080
|
+
this.engine = undefined;
|
|
35081
|
+
};
|
|
35082
|
+
return PassTextureCache;
|
|
35083
|
+
}();
|
|
35084
|
+
|
|
35412
35085
|
var SceneLoader = /*#__PURE__*/ function() {
|
|
35413
35086
|
function SceneLoader() {}
|
|
35414
35087
|
SceneLoader.load = function load(scene, engine, options) {
|
|
@@ -35427,16 +35100,16 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35427
35100
|
engine.assetManagers.push(assetManager);
|
|
35428
35101
|
return [
|
|
35429
35102
|
4,
|
|
35430
|
-
assetManager.loadScene(scene, engine.renderer
|
|
35431
|
-
env: engine.env
|
|
35432
|
-
})
|
|
35103
|
+
assetManager.loadScene(scene, engine.renderer)
|
|
35433
35104
|
];
|
|
35434
35105
|
case 1:
|
|
35435
35106
|
loadedScene = _state.sent();
|
|
35107
|
+
engine.clearResources();
|
|
35108
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
35109
|
+
PluginSystem.loadResources(loadedScene, assetManager.options, engine);
|
|
35436
35110
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35437
35111
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35438
35112
|
engine.assetService.initializeTexture(loadedScene);
|
|
35439
|
-
loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
|
|
35440
35113
|
composition = _this.createComposition(loadedScene, engine, options);
|
|
35441
35114
|
composition.setIndex(compositionIndex);
|
|
35442
35115
|
compileStart = performance.now();
|
|
@@ -35489,14 +35162,14 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35489
35162
|
return SceneLoader;
|
|
35490
35163
|
}();
|
|
35491
35164
|
|
|
35492
|
-
registerPlugin("camera", CameraVFXItemLoader
|
|
35493
|
-
registerPlugin("text", TextLoader
|
|
35494
|
-
registerPlugin("sprite", SpriteLoader
|
|
35495
|
-
registerPlugin("particle", ParticleLoader
|
|
35496
|
-
registerPlugin("cal", CalculateLoader
|
|
35497
|
-
registerPlugin("interact", InteractLoader
|
|
35498
|
-
var version = "2.8.0-alpha.
|
|
35165
|
+
registerPlugin("camera", CameraVFXItemLoader);
|
|
35166
|
+
registerPlugin("text", TextLoader);
|
|
35167
|
+
registerPlugin("sprite", SpriteLoader);
|
|
35168
|
+
registerPlugin("particle", ParticleLoader);
|
|
35169
|
+
registerPlugin("cal", CalculateLoader);
|
|
35170
|
+
registerPlugin("interact", InteractLoader);
|
|
35171
|
+
var version = "2.8.0-alpha.2";
|
|
35499
35172
|
logger.info("Core version: " + version + ".");
|
|
35500
35173
|
|
|
35501
|
-
export { AbstractPlugin, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, GraphInstance, GraphNode, GraphNodeData, GraphicsPath, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, NodeTransform, NotNode, NotNodeData, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, PropertyClipPlayable, PropertyTrack,
|
|
35174
|
+
export { AbstractPlugin, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, GraphInstance, GraphNode, GraphNodeData, GraphicsPath, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, NodeTransform, NotNode, NotNodeData, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, PropertyClipPlayable, PropertyTrack, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, ShapePath, SourceType, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TangentMode, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getClass, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
|
|
35502
35175
|
//# sourceMappingURL=index.mjs.map
|