@galacean/effects-core 2.8.0-alpha.0 → 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 +642 -958
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +641 -955
- 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/plugins/text/text-component-base.d.ts +4 -0
- package/dist/plugins/text/text-item.d.ts +5 -2
- package/dist/render/create-copy-shader.d.ts +0 -2
- package/dist/render/draw-object-pass.d.ts +6 -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 +9 -118
- 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;
|
|
2969
|
-
return _async_to_generator(function() {
|
|
2970
|
-
return __generator(this, function(_state) {
|
|
2971
|
-
return [
|
|
2972
|
-
2,
|
|
2973
|
-
_this.callStatic("processRawJSON", json, options)
|
|
2974
|
-
];
|
|
2975
|
-
});
|
|
2976
|
-
})();
|
|
2977
|
-
};
|
|
2978
|
-
_proto.processAssets = function processAssets(json, options) {
|
|
2979
|
-
var _this = this;
|
|
2914
|
+
PluginSystem.processAssets = function processAssets(scene, options) {
|
|
2980
2915
|
return _async_to_generator(function() {
|
|
2981
2916
|
return __generator(this, function(_state) {
|
|
2982
2917
|
return [
|
|
2983
2918
|
2,
|
|
2984
|
-
|
|
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() {};
|
|
2965
|
+
/**
|
|
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
|
+
};
|
|
3063
2980
|
/**
|
|
3064
|
-
*
|
|
3065
|
-
*
|
|
3066
|
-
*
|
|
3067
|
-
|
|
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 = {};
|
|
@@ -9877,6 +9831,8 @@ var TextureFactory = /*#__PURE__*/ function() {
|
|
|
9877
9831
|
internalFormat: textureData.internalFormat,
|
|
9878
9832
|
format: textureData.format,
|
|
9879
9833
|
mipmaps: textureData.mipmaps,
|
|
9834
|
+
minFilter: glContext.LINEAR,
|
|
9835
|
+
magFilter: glContext.LINEAR,
|
|
9880
9836
|
sourceFrom: sourceFrom
|
|
9881
9837
|
}, config)
|
|
9882
9838
|
];
|
|
@@ -10349,208 +10305,70 @@ var MaskProcessor = /*#__PURE__*/ function() {
|
|
|
10349
10305
|
return MaskProcessor;
|
|
10350
10306
|
}();
|
|
10351
10307
|
|
|
10352
|
-
var ShaderCompileResultStatus;
|
|
10353
|
-
(function(ShaderCompileResultStatus) {
|
|
10354
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10355
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10356
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10357
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10358
|
-
})(ShaderCompileResultStatus || (ShaderCompileResultStatus = {}));
|
|
10359
|
-
var GLSLVersion;
|
|
10360
|
-
(function(GLSLVersion) {
|
|
10361
|
-
GLSLVersion["GLSL1"] = "100";
|
|
10362
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
10363
|
-
})(GLSLVersion || (GLSLVersion = {}));
|
|
10364
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10365
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
10366
|
-
function ShaderVariant(engine, source) {
|
|
10367
|
-
var _this;
|
|
10368
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
10369
|
-
_this.source = source;
|
|
10370
|
-
return _this;
|
|
10371
|
-
}
|
|
10372
|
-
return ShaderVariant;
|
|
10373
|
-
}(EffectsObject);
|
|
10374
|
-
var Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10375
|
-
_inherits(Shader, EffectsObject);
|
|
10376
|
-
function Shader() {
|
|
10377
|
-
return EffectsObject.apply(this, arguments);
|
|
10378
|
-
}
|
|
10379
|
-
var _proto = Shader.prototype;
|
|
10380
|
-
_proto.createVariant = function createVariant(macros) {
|
|
10381
|
-
var shaderMacros = [];
|
|
10382
|
-
if (macros) {
|
|
10383
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10384
|
-
var key = _step.value;
|
|
10385
|
-
shaderMacros.push([
|
|
10386
|
-
key,
|
|
10387
|
-
macros[key]
|
|
10388
|
-
]);
|
|
10389
|
-
}
|
|
10390
|
-
}
|
|
10391
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10392
|
-
shaderVariant.shader = this;
|
|
10393
|
-
return shaderVariant;
|
|
10394
|
-
};
|
|
10395
|
-
_proto.fromData = function fromData(data) {
|
|
10396
|
-
EffectsObject.prototype.fromData.call(this, data);
|
|
10397
|
-
this.shaderData = data;
|
|
10398
|
-
};
|
|
10399
|
-
return Shader;
|
|
10400
|
-
}(EffectsObject);
|
|
10401
|
-
Shader = __decorate([
|
|
10402
|
-
effectsClass(DataType.Shader)
|
|
10403
|
-
], Shader);
|
|
10404
|
-
|
|
10405
10308
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10406
10309
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10407
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}";
|
|
10408
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";
|
|
10409
|
-
function createCopyShader(level, writeDepth) {
|
|
10410
|
-
var webgl2 = level === 2;
|
|
10411
|
-
return {
|
|
10412
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
10413
|
-
vertex: COPY_VERTEX_SHADER,
|
|
10414
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
10415
|
-
glslVersion: webgl2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1,
|
|
10416
|
-
macros: [
|
|
10417
|
-
[
|
|
10418
|
-
"DEPTH_TEXTURE",
|
|
10419
|
-
!!writeDepth
|
|
10420
|
-
]
|
|
10421
|
-
],
|
|
10422
|
-
// @ts-expect-error
|
|
10423
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
10424
|
-
};
|
|
10425
|
-
}
|
|
10426
10312
|
|
|
10427
|
-
var
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
var _this = this;
|
|
10445
|
-
var width = request.width, height = request.height, name = request.name;
|
|
10446
|
-
var options = {
|
|
10447
|
-
sourceType: TextureSourceType.framebuffer,
|
|
10448
|
-
data: {
|
|
10449
|
-
width: width,
|
|
10450
|
-
height: height
|
|
10451
|
-
},
|
|
10452
|
-
name: name
|
|
10453
|
-
};
|
|
10454
|
-
var keys = [
|
|
10455
|
-
name
|
|
10456
|
-
];
|
|
10457
|
-
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
10458
|
-
var _request_name;
|
|
10459
|
-
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
10460
|
-
options[name] = value;
|
|
10461
|
-
keys.push(name, value);
|
|
10462
|
-
});
|
|
10463
|
-
var cacheId = keys.join(":");
|
|
10464
|
-
var tex = this.textureCache[cacheId];
|
|
10465
|
-
if (tex) {
|
|
10466
|
-
this.textureRef[cacheId]++;
|
|
10467
|
-
} else {
|
|
10468
|
-
var engine = this.engine;
|
|
10469
|
-
assertExist(engine);
|
|
10470
|
-
tex = Texture.create(engine, options);
|
|
10471
|
-
this.textureCache[cacheId] = tex;
|
|
10472
|
-
this.textureRef[cacheId] = 1;
|
|
10473
|
-
// @ts-expect-error
|
|
10474
|
-
tex[disposeSymbol] = tex.dispose;
|
|
10475
|
-
tex.dispose = function() {
|
|
10476
|
-
return _this.removeTexture(cacheId);
|
|
10477
|
-
};
|
|
10478
|
-
}
|
|
10479
|
-
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
|
|
10480
10330
|
};
|
|
10481
|
-
_proto.
|
|
10482
|
-
|
|
10483
|
-
if (refCount <= 1) {
|
|
10484
|
-
if (refCount < 0) {
|
|
10485
|
-
console.error("Ref count < 0.");
|
|
10486
|
-
}
|
|
10487
|
-
var tex = this.textureCache[id];
|
|
10488
|
-
if (tex) {
|
|
10489
|
-
// @ts-expect-error
|
|
10490
|
-
tex[disposeSymbol]();
|
|
10491
|
-
// @ts-expect-error
|
|
10492
|
-
tex.dispose = tex[disposeSymbol];
|
|
10493
|
-
}
|
|
10494
|
-
delete this.textureCache[id];
|
|
10495
|
-
delete this.textureRef[id];
|
|
10496
|
-
} else {
|
|
10497
|
-
this.textureRef[id] = refCount - 1;
|
|
10498
|
-
}
|
|
10331
|
+
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
10332
|
+
// OVERRIDE
|
|
10499
10333
|
};
|
|
10500
|
-
_proto.
|
|
10501
|
-
|
|
10502
|
-
Object.keys(this.textureCache).forEach(function(key) {
|
|
10503
|
-
var texture = _this.textureCache[key];
|
|
10504
|
-
// @ts-expect-error
|
|
10505
|
-
texture[disposeSymbol]();
|
|
10506
|
-
// @ts-expect-error
|
|
10507
|
-
texture.dispose = texture[disposeSymbol];
|
|
10508
|
-
});
|
|
10509
|
-
this.textureCache = {};
|
|
10510
|
-
this.textureRef = {};
|
|
10511
|
-
this.engine = undefined;
|
|
10334
|
+
_proto.unbind = function unbind() {
|
|
10335
|
+
// OVERRIDE
|
|
10512
10336
|
};
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
function _assert_this_initialized(self) {
|
|
10517
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10518
|
-
return self;
|
|
10519
|
-
}
|
|
10520
|
-
|
|
10521
|
-
var SemanticMap = /*#__PURE__*/ function() {
|
|
10522
|
-
function SemanticMap(semantics) {
|
|
10523
|
-
if (semantics === void 0) semantics = {};
|
|
10524
|
-
this.semantics = _extends({}, semantics);
|
|
10525
|
-
}
|
|
10526
|
-
var _proto = SemanticMap.prototype;
|
|
10527
|
-
_proto.toObject = function toObject() {
|
|
10528
|
-
return _extends({}, this.semantics);
|
|
10337
|
+
_proto.bind = function bind() {
|
|
10338
|
+
// OVERRIDE
|
|
10529
10339
|
};
|
|
10530
|
-
_proto.
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
} else {
|
|
10534
|
-
this.semantics[name] = value;
|
|
10535
|
-
}
|
|
10340
|
+
_proto.getDepthTexture = function getDepthTexture() {
|
|
10341
|
+
// OVERRIDE
|
|
10342
|
+
return undefined;
|
|
10536
10343
|
};
|
|
10537
|
-
_proto.
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
return ret(state);
|
|
10541
|
-
}
|
|
10542
|
-
return ret;
|
|
10344
|
+
_proto.getStencilTexture = function getStencilTexture() {
|
|
10345
|
+
// OVERRIDE
|
|
10346
|
+
return undefined;
|
|
10543
10347
|
};
|
|
10544
|
-
_proto.
|
|
10545
|
-
|
|
10348
|
+
_proto.getColorTextures = function getColorTextures() {
|
|
10349
|
+
// OVERRIDE
|
|
10350
|
+
return [];
|
|
10546
10351
|
};
|
|
10547
|
-
_proto.dispose = function dispose() {
|
|
10548
|
-
|
|
10549
|
-
Object.keys(this.semantics).forEach(function(name) {
|
|
10550
|
-
delete _this.semantics[name];
|
|
10551
|
-
});
|
|
10352
|
+
_proto.dispose = function dispose(options) {
|
|
10353
|
+
// OVERRIDE
|
|
10552
10354
|
};
|
|
10553
|
-
|
|
10355
|
+
_create_class(Framebuffer, [
|
|
10356
|
+
{
|
|
10357
|
+
key: "stencilStorage",
|
|
10358
|
+
get: function get() {
|
|
10359
|
+
// OVERRIDE
|
|
10360
|
+
return undefined;
|
|
10361
|
+
}
|
|
10362
|
+
},
|
|
10363
|
+
{
|
|
10364
|
+
key: "depthStorage",
|
|
10365
|
+
get: function get() {
|
|
10366
|
+
// OVERRIDE
|
|
10367
|
+
return undefined;
|
|
10368
|
+
}
|
|
10369
|
+
}
|
|
10370
|
+
]);
|
|
10371
|
+
return Framebuffer;
|
|
10554
10372
|
}();
|
|
10555
10373
|
|
|
10556
10374
|
var RenderPassPriorityPrepare = 0;
|
|
@@ -10562,7 +10380,7 @@ var RenderPassAttachmentStorageType;
|
|
|
10562
10380
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
|
|
10563
10381
|
//stencil 8 render buffer
|
|
10564
10382
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
|
|
10565
|
-
//
|
|
10383
|
+
//depth 16 render buffer
|
|
10566
10384
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
|
|
10567
10385
|
//depth 16 & stencil 8 render buffer
|
|
10568
10386
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
|
|
@@ -10681,128 +10499,47 @@ var seed$7 = 1;
|
|
|
10681
10499
|
/**
|
|
10682
10500
|
* RenderPass 抽象类
|
|
10683
10501
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
10684
|
-
function RenderPass(renderer
|
|
10502
|
+
function RenderPass(renderer) {
|
|
10685
10503
|
/**
|
|
10686
|
-
*
|
|
10687
|
-
*/ this.
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10504
|
+
* 优先级
|
|
10505
|
+
*/ this.priority = 0;
|
|
10506
|
+
/**
|
|
10507
|
+
* 名称
|
|
10508
|
+
*/ this.name = "RenderPass" + seed$7++;
|
|
10509
|
+
/**
|
|
10510
|
+
* 包含的 Mesh 列表
|
|
10511
|
+
*/ this.meshes = [];
|
|
10512
|
+
this.disposed = false;
|
|
10513
|
+
this.framebuffer = null;
|
|
10692
10514
|
this.renderer = renderer;
|
|
10693
|
-
this.priority = priority;
|
|
10694
|
-
this.meshOrder = meshOrder;
|
|
10695
|
-
this.meshes = sortByOrder(meshes.slice(), this.meshOrder);
|
|
10696
|
-
this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
|
|
10697
|
-
this.clearAction = _extends({}, clearAction);
|
|
10698
|
-
this.storeAction = _extends({
|
|
10699
|
-
colorAction: 0,
|
|
10700
|
-
depthAction: 0,
|
|
10701
|
-
stencilAction: 0
|
|
10702
|
-
}, storeAction);
|
|
10703
|
-
this.semantics = new SemanticMap(semantics);
|
|
10704
|
-
this.options = options;
|
|
10705
|
-
this.delegate = delegate;
|
|
10706
10515
|
}
|
|
10707
10516
|
var _proto = RenderPass.prototype;
|
|
10708
10517
|
_proto.addMesh = function addMesh(mesh) {
|
|
10709
|
-
addByOrder(this.meshes, mesh
|
|
10518
|
+
addByOrder(this.meshes, mesh);
|
|
10710
10519
|
};
|
|
10711
10520
|
_proto.removeMesh = function removeMesh(mesh) {
|
|
10712
10521
|
removeItem(this.meshes, mesh);
|
|
10713
10522
|
};
|
|
10714
|
-
_proto.setMeshes = function setMeshes(meshes) {
|
|
10715
|
-
var _this_meshes;
|
|
10716
|
-
this.meshes.length = 0;
|
|
10717
|
-
(_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
|
|
10718
|
-
0,
|
|
10719
|
-
0
|
|
10720
|
-
], meshes));
|
|
10721
|
-
sortByOrder(this.meshes, this.meshOrder);
|
|
10722
|
-
return this.meshes;
|
|
10723
|
-
};
|
|
10724
|
-
// TODO 所有pass在子类配置
|
|
10725
10523
|
/**
|
|
10726
10524
|
* 配置当前pass的RT,在每帧渲染前调用
|
|
10727
10525
|
*/ _proto.configure = function configure(renderer) {
|
|
10728
|
-
|
|
10729
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
10730
|
-
} else {
|
|
10731
|
-
var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
|
|
10732
|
-
renderer.setViewport(x, y, width, height);
|
|
10733
|
-
}
|
|
10526
|
+
// OVERRIDE
|
|
10734
10527
|
};
|
|
10735
10528
|
/**
|
|
10736
10529
|
* 执行当前pass,每帧调用一次
|
|
10737
10530
|
*/ _proto.execute = function execute(renderer) {
|
|
10738
|
-
|
|
10739
|
-
renderer.renderMeshes(this.meshes);
|
|
10740
|
-
renderer.clear(this.storeAction);
|
|
10531
|
+
// OVERRIDE
|
|
10741
10532
|
};
|
|
10742
10533
|
/**
|
|
10743
|
-
* 每帧所有的pass
|
|
10744
|
-
*/ _proto.
|
|
10745
|
-
|
|
10746
|
-
var _this = this;
|
|
10747
|
-
var _options_attachments;
|
|
10748
|
-
var renderer = this.renderer;
|
|
10749
|
-
var options = this.options;
|
|
10750
|
-
if (this.attachments.length) {
|
|
10751
|
-
var _this_framebuffer;
|
|
10752
|
-
this.attachments.forEach(function(att) {
|
|
10753
|
-
return !att.externalTexture && att.dispose();
|
|
10754
|
-
});
|
|
10755
|
-
this.attachments.length = 0;
|
|
10756
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
|
|
10757
|
-
depthStencilAttachment: 2
|
|
10758
|
-
});
|
|
10759
|
-
this.framebuffer = null;
|
|
10760
|
-
}
|
|
10761
|
-
// renderpass 的 viewport 相关参数都需要动态的修改
|
|
10762
|
-
var viewport = [
|
|
10763
|
-
0,
|
|
10764
|
-
0,
|
|
10765
|
-
renderer.getWidth(),
|
|
10766
|
-
renderer.getHeight()
|
|
10767
|
-
];
|
|
10768
|
-
var size = [
|
|
10769
|
-
viewport[2],
|
|
10770
|
-
viewport[3]
|
|
10771
|
-
];
|
|
10772
|
-
var name = this.name;
|
|
10773
|
-
if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
|
|
10774
|
-
var attachments = options.attachments.map(function(attr, index) {
|
|
10775
|
-
var _attr_texture;
|
|
10776
|
-
var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
|
|
10777
|
-
size: size,
|
|
10778
|
-
name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
|
|
10779
|
-
}, attr));
|
|
10780
|
-
return attachment;
|
|
10781
|
-
});
|
|
10782
|
-
this.attachments = attachments;
|
|
10783
|
-
var framebuffer = Framebuffer.create({
|
|
10784
|
-
storeAction: this.storeAction,
|
|
10785
|
-
name: name,
|
|
10786
|
-
viewport: viewport,
|
|
10787
|
-
attachments: attachments.map(function(att) {
|
|
10788
|
-
return att.texture;
|
|
10789
|
-
}),
|
|
10790
|
-
depthStencilAttachment: options.depthStencilAttachment || {
|
|
10791
|
-
storageType: 0
|
|
10792
|
-
}
|
|
10793
|
-
}, renderer);
|
|
10794
|
-
framebuffer.bind();
|
|
10795
|
-
framebuffer.unbind();
|
|
10796
|
-
this.framebuffer = framebuffer;
|
|
10797
|
-
} else {
|
|
10798
|
-
this.attachments.length = 0;
|
|
10799
|
-
}
|
|
10534
|
+
* 每帧所有的pass渲染完后调用,用于清空临时的RT资源
|
|
10535
|
+
*/ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10536
|
+
// OVERRIDE
|
|
10800
10537
|
};
|
|
10801
10538
|
/**
|
|
10802
10539
|
* 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
|
|
10803
10540
|
*/ _proto.getViewport = function getViewport() {
|
|
10804
10541
|
var _this_framebuffer;
|
|
10805
|
-
var ret = (
|
|
10542
|
+
var ret = (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.viewport;
|
|
10806
10543
|
if (ret) {
|
|
10807
10544
|
return ret;
|
|
10808
10545
|
}
|
|
@@ -10820,72 +10557,10 @@ var seed$7 = 1;
|
|
|
10820
10557
|
];
|
|
10821
10558
|
};
|
|
10822
10559
|
/**
|
|
10823
|
-
* 获取深度 Attachment,可能没有
|
|
10824
|
-
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
10825
|
-
var framebuffer = this.framebuffer;
|
|
10826
|
-
if (framebuffer) {
|
|
10827
|
-
var depthTexture = framebuffer.getDepthTexture();
|
|
10828
|
-
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
10829
|
-
return {
|
|
10830
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10831
|
-
storage: framebuffer.depthStorage,
|
|
10832
|
-
texture: texture
|
|
10833
|
-
};
|
|
10834
|
-
}
|
|
10835
|
-
};
|
|
10836
|
-
/**
|
|
10837
|
-
* 获取蒙版 Attachment,可能没有
|
|
10838
|
-
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
10839
|
-
var framebuffer = this.framebuffer;
|
|
10840
|
-
if (framebuffer) {
|
|
10841
|
-
var stencilTexture = framebuffer.getStencilTexture();
|
|
10842
|
-
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
10843
|
-
return {
|
|
10844
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10845
|
-
storage: framebuffer.stencilStorage,
|
|
10846
|
-
texture: texture
|
|
10847
|
-
};
|
|
10848
|
-
}
|
|
10849
|
-
};
|
|
10850
|
-
_proto.getDepthTexture = function getDepthTexture(texture, external) {
|
|
10851
|
-
if (!this.depthTexture) {
|
|
10852
|
-
var _this_options_depthStencilAttachment;
|
|
10853
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10854
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10855
|
-
// TODO 为什么要initialize?
|
|
10856
|
-
//tex.initialize(this.renderer.engine);
|
|
10857
|
-
if (!external) {
|
|
10858
|
-
this.depthTexture = tex;
|
|
10859
|
-
}
|
|
10860
|
-
return tex;
|
|
10861
|
-
}
|
|
10862
|
-
return this.depthTexture;
|
|
10863
|
-
};
|
|
10864
|
-
_proto.getStencilTexture = function getStencilTexture(texture, external) {
|
|
10865
|
-
if (!this.stencilTexture) {
|
|
10866
|
-
var _this_options_depthStencilAttachment;
|
|
10867
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10868
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10869
|
-
if (!external) {
|
|
10870
|
-
this.stencilTexture = tex;
|
|
10871
|
-
}
|
|
10872
|
-
return tex;
|
|
10873
|
-
}
|
|
10874
|
-
return this.stencilTexture;
|
|
10875
|
-
};
|
|
10876
|
-
// 生成并初始化帧缓冲
|
|
10877
|
-
_proto.initialize = function initialize(renderer) {
|
|
10878
|
-
if (!this.initialized) {
|
|
10879
|
-
this._resetAttachments();
|
|
10880
|
-
this.initialized = true;
|
|
10881
|
-
}
|
|
10882
|
-
return this;
|
|
10883
|
-
};
|
|
10884
|
-
/**
|
|
10885
10560
|
* 销毁 RenderPass
|
|
10886
10561
|
* @param options - 有选择销毁内部对象
|
|
10887
10562
|
*/ _proto.dispose = function dispose(options) {
|
|
10888
|
-
if (this.
|
|
10563
|
+
if (this.disposed) {
|
|
10889
10564
|
return;
|
|
10890
10565
|
}
|
|
10891
10566
|
var destroyMeshOption = (options == null ? void 0 : options.meshes) || undefined;
|
|
@@ -10895,40 +10570,13 @@ var seed$7 = 1;
|
|
|
10895
10570
|
});
|
|
10896
10571
|
}
|
|
10897
10572
|
this.meshes.length = 0;
|
|
10898
|
-
|
|
10899
|
-
this.attachments.forEach(function(att) {
|
|
10900
|
-
var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
|
|
10901
|
-
if (!keep) {
|
|
10902
|
-
att.dispose();
|
|
10903
|
-
}
|
|
10904
|
-
});
|
|
10905
|
-
this.attachments.length = 0;
|
|
10906
|
-
if ((options == null ? void 0 : options.semantics) !== DestroyOptions.keep) {
|
|
10907
|
-
this.semantics.dispose();
|
|
10908
|
-
}
|
|
10909
|
-
this.destroyed = true;
|
|
10910
|
-
var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
|
|
10911
|
-
var fbo = this.framebuffer;
|
|
10912
|
-
if (fbo) {
|
|
10913
|
-
fbo.dispose({
|
|
10914
|
-
depthStencilAttachment: depthStencilOpt
|
|
10915
|
-
});
|
|
10916
|
-
var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
|
|
10917
|
-
if (!keep) {
|
|
10918
|
-
var _this_stencilTexture, _this_depthTexture;
|
|
10919
|
-
(_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
|
|
10920
|
-
(_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
|
|
10921
|
-
}
|
|
10922
|
-
}
|
|
10923
|
-
// @ts-expect-error safe to assign
|
|
10924
|
-
this.options = null;
|
|
10925
|
-
this.initialize = throwDestroyedError;
|
|
10573
|
+
this.disposed = true;
|
|
10926
10574
|
};
|
|
10927
10575
|
_create_class(RenderPass, [
|
|
10928
10576
|
{
|
|
10929
|
-
key: "
|
|
10577
|
+
key: "isDisposed",
|
|
10930
10578
|
get: function get() {
|
|
10931
|
-
return this.
|
|
10579
|
+
return this.disposed;
|
|
10932
10580
|
}
|
|
10933
10581
|
},
|
|
10934
10582
|
{
|
|
@@ -10936,18 +10584,6 @@ var seed$7 = 1;
|
|
|
10936
10584
|
get: function get() {
|
|
10937
10585
|
return this.getViewport();
|
|
10938
10586
|
}
|
|
10939
|
-
},
|
|
10940
|
-
{
|
|
10941
|
-
key: "stencilAttachment",
|
|
10942
|
-
get: function get() {
|
|
10943
|
-
return this.getStencilAttachment();
|
|
10944
|
-
}
|
|
10945
|
-
},
|
|
10946
|
-
{
|
|
10947
|
-
key: "depthAttachment",
|
|
10948
|
-
get: function get() {
|
|
10949
|
-
return this.getDepthAttachment();
|
|
10950
|
-
}
|
|
10951
10587
|
}
|
|
10952
10588
|
]);
|
|
10953
10589
|
return RenderPass;
|
|
@@ -10955,27 +10591,95 @@ var seed$7 = 1;
|
|
|
10955
10591
|
|
|
10956
10592
|
var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
10957
10593
|
_inherits(DrawObjectPass, RenderPass);
|
|
10958
|
-
function DrawObjectPass(renderer
|
|
10594
|
+
function DrawObjectPass(renderer) {
|
|
10959
10595
|
var _this;
|
|
10960
|
-
_this = RenderPass.call(this, renderer
|
|
10961
|
-
_this.
|
|
10962
|
-
_this.
|
|
10596
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
10597
|
+
_this.useRenderTarget = false;
|
|
10598
|
+
_this.priority = RenderPassPriorityNormal;
|
|
10599
|
+
_this.name = "DrawObjectPass";
|
|
10963
10600
|
return _this;
|
|
10964
10601
|
}
|
|
10965
10602
|
var _proto = DrawObjectPass.prototype;
|
|
10966
|
-
_proto.
|
|
10967
|
-
|
|
10968
|
-
var width = this.renderer.getWidth();
|
|
10969
|
-
var height = this.renderer.getHeight();
|
|
10970
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
10603
|
+
_proto.setup = function setup(useRenderTarget) {
|
|
10604
|
+
this.useRenderTarget = useRenderTarget;
|
|
10971
10605
|
};
|
|
10972
|
-
_proto.
|
|
10973
|
-
|
|
10974
|
-
|
|
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
|
+
};
|
|
10612
|
+
_proto.execute = function execute(renderer) {
|
|
10613
|
+
if (this.useRenderTarget) {
|
|
10614
|
+
renderer.clear({
|
|
10615
|
+
colorAction: TextureLoadAction.clear,
|
|
10616
|
+
depthAction: TextureLoadAction.clear,
|
|
10617
|
+
stencilAction: TextureLoadAction.clear
|
|
10618
|
+
});
|
|
10619
|
+
}
|
|
10620
|
+
renderer.renderMeshes(this.meshes);
|
|
10621
|
+
};
|
|
10622
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10623
|
+
if (this.useRenderTarget && this.framebuffer) {
|
|
10624
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
10625
|
+
}
|
|
10975
10626
|
};
|
|
10976
10627
|
return DrawObjectPass;
|
|
10977
10628
|
}(RenderPass);
|
|
10978
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
|
+
|
|
10979
10683
|
var _obj$5;
|
|
10980
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);
|
|
10981
10685
|
/**
|
|
@@ -13017,9 +12721,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
13017
12721
|
// Bloom 阈值 Pass
|
|
13018
12722
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
13019
12723
|
_inherits(BloomThresholdPass, RenderPass);
|
|
13020
|
-
function BloomThresholdPass(renderer
|
|
12724
|
+
function BloomThresholdPass(renderer) {
|
|
13021
12725
|
var _this;
|
|
13022
|
-
_this = RenderPass.call(this, renderer
|
|
12726
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13023
12727
|
var engine = _this.renderer.engine;
|
|
13024
12728
|
var geometry = Geometry.create(engine, {
|
|
13025
12729
|
mode: glContext.TRIANGLE_STRIP,
|
|
@@ -13057,12 +12761,12 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13057
12761
|
priority: 0
|
|
13058
12762
|
});
|
|
13059
12763
|
_this.priority = 5000;
|
|
13060
|
-
_this.
|
|
13061
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12764
|
+
_this.name = "BloomThresholdPass";
|
|
13062
12765
|
return _this;
|
|
13063
12766
|
}
|
|
13064
12767
|
var _proto = BloomThresholdPass.prototype;
|
|
13065
12768
|
_proto.configure = function configure(renderer) {
|
|
12769
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, renderer.getWidth(), renderer.getHeight(), 0, FilterMode.Linear, RenderTextureFormat.RGBAHalf);
|
|
13066
12770
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13067
12771
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
13068
12772
|
renderer.setFramebuffer(this.framebuffer);
|
|
@@ -13070,9 +12774,9 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13070
12774
|
_proto.execute = function execute(renderer) {
|
|
13071
12775
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
13072
12776
|
renderer.clear({
|
|
13073
|
-
colorAction:
|
|
13074
|
-
depthAction:
|
|
13075
|
-
stencilAction:
|
|
12777
|
+
colorAction: TextureLoadAction.clear,
|
|
12778
|
+
depthAction: TextureLoadAction.clear,
|
|
12779
|
+
stencilAction: TextureLoadAction.clear
|
|
13076
12780
|
});
|
|
13077
12781
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13078
12782
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
@@ -13082,23 +12786,21 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13082
12786
|
this.screenMesh
|
|
13083
12787
|
]);
|
|
13084
12788
|
};
|
|
13085
|
-
_proto.
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
(_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
|
+
}
|
|
13090
12793
|
};
|
|
13091
12794
|
_proto.dispose = function dispose(options) {
|
|
13092
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13093
12795
|
RenderPass.prototype.dispose.call(this, options);
|
|
13094
12796
|
};
|
|
13095
12797
|
return BloomThresholdPass;
|
|
13096
12798
|
}(RenderPass);
|
|
13097
12799
|
var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13098
12800
|
_inherits(HQGaussianDownSamplePass, RenderPass);
|
|
13099
|
-
function HQGaussianDownSamplePass(renderer, type, level
|
|
12801
|
+
function HQGaussianDownSamplePass(renderer, type, level) {
|
|
13100
12802
|
var _this;
|
|
13101
|
-
_this = RenderPass.call(this, renderer
|
|
12803
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13102
12804
|
_this.type = type;
|
|
13103
12805
|
_this.level = level;
|
|
13104
12806
|
var engine = _this.renderer.engine;
|
|
@@ -13144,25 +12846,22 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13144
12846
|
priority: 0
|
|
13145
12847
|
});
|
|
13146
12848
|
_this.priority = 5000;
|
|
13147
|
-
_this.
|
|
13148
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12849
|
+
_this.name = "GaussianDownPass" + type + level;
|
|
13149
12850
|
return _this;
|
|
13150
12851
|
}
|
|
13151
12852
|
var _proto = HQGaussianDownSamplePass.prototype;
|
|
13152
|
-
_proto.initialize = function initialize(renderer) {
|
|
13153
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13154
|
-
this.onResize();
|
|
13155
|
-
return this;
|
|
13156
|
-
};
|
|
13157
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);
|
|
13158
12857
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13159
12858
|
renderer.setFramebuffer(this.framebuffer);
|
|
13160
12859
|
};
|
|
13161
12860
|
_proto.execute = function execute(renderer) {
|
|
13162
12861
|
renderer.clear({
|
|
13163
|
-
colorAction:
|
|
13164
|
-
depthAction:
|
|
13165
|
-
stencilAction:
|
|
12862
|
+
colorAction: TextureLoadAction.clear,
|
|
12863
|
+
depthAction: TextureLoadAction.clear,
|
|
12864
|
+
stencilAction: TextureLoadAction.clear
|
|
13166
12865
|
});
|
|
13167
12866
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13168
12867
|
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
@@ -13173,23 +12872,18 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13173
12872
|
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13174
12873
|
}
|
|
13175
12874
|
};
|
|
13176
|
-
_proto.
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13181
|
-
};
|
|
13182
|
-
_proto.dispose = function dispose(options) {
|
|
13183
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13184
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12875
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12876
|
+
if (this.framebuffer) {
|
|
12877
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12878
|
+
}
|
|
13185
12879
|
};
|
|
13186
12880
|
return HQGaussianDownSamplePass;
|
|
13187
12881
|
}(RenderPass);
|
|
13188
12882
|
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13189
12883
|
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
13190
|
-
function HQGaussianUpSamplePass(renderer, level
|
|
12884
|
+
function HQGaussianUpSamplePass(renderer, level) {
|
|
13191
12885
|
var _this;
|
|
13192
|
-
_this = RenderPass.call(this, renderer
|
|
12886
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13193
12887
|
_this.level = level;
|
|
13194
12888
|
var name = "PostProcess";
|
|
13195
12889
|
var engine = _this.renderer.engine;
|
|
@@ -13232,25 +12926,22 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13232
12926
|
priority: 0
|
|
13233
12927
|
});
|
|
13234
12928
|
_this.priority = 5000;
|
|
13235
|
-
_this.
|
|
13236
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12929
|
+
_this.name = "GaussianUpPass" + level;
|
|
13237
12930
|
return _this;
|
|
13238
12931
|
}
|
|
13239
12932
|
var _proto = HQGaussianUpSamplePass.prototype;
|
|
13240
|
-
_proto.initialize = function initialize(renderer) {
|
|
13241
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13242
|
-
this.onResize();
|
|
13243
|
-
return this;
|
|
13244
|
-
};
|
|
13245
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);
|
|
13246
12937
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13247
12938
|
renderer.setFramebuffer(this.framebuffer);
|
|
13248
12939
|
};
|
|
13249
12940
|
_proto.execute = function execute(renderer) {
|
|
13250
12941
|
renderer.clear({
|
|
13251
|
-
colorAction:
|
|
13252
|
-
depthAction:
|
|
13253
|
-
stencilAction:
|
|
12942
|
+
colorAction: TextureLoadAction.clear,
|
|
12943
|
+
depthAction: TextureLoadAction.clear,
|
|
12944
|
+
stencilAction: TextureLoadAction.clear
|
|
13254
12945
|
});
|
|
13255
12946
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13256
12947
|
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
@@ -13259,15 +12950,10 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13259
12950
|
this.screenMesh
|
|
13260
12951
|
]);
|
|
13261
12952
|
};
|
|
13262
|
-
_proto.
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13267
|
-
};
|
|
13268
|
-
_proto.dispose = function dispose(options) {
|
|
13269
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13270
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12953
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12954
|
+
if (this.framebuffer) {
|
|
12955
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12956
|
+
}
|
|
13271
12957
|
};
|
|
13272
12958
|
return HQGaussianUpSamplePass;
|
|
13273
12959
|
}(RenderPass);
|
|
@@ -13276,7 +12962,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13276
12962
|
_inherits(ToneMappingPass, RenderPass);
|
|
13277
12963
|
function ToneMappingPass(renderer, sceneTextureHandle) {
|
|
13278
12964
|
var _this;
|
|
13279
|
-
_this = RenderPass.call(this, renderer
|
|
12965
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13280
12966
|
var name = "PostProcess";
|
|
13281
12967
|
var engine = _this.renderer.engine;
|
|
13282
12968
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
@@ -13319,6 +13005,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13319
13005
|
priority: 0
|
|
13320
13006
|
});
|
|
13321
13007
|
_this.priority = 5000;
|
|
13008
|
+
_this.name = "ToneMappingPass";
|
|
13322
13009
|
return _this;
|
|
13323
13010
|
}
|
|
13324
13011
|
var _proto = ToneMappingPass.prototype;
|
|
@@ -13331,9 +13018,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13331
13018
|
};
|
|
13332
13019
|
_proto.execute = function execute(renderer) {
|
|
13333
13020
|
renderer.clear({
|
|
13334
|
-
colorAction:
|
|
13335
|
-
depthAction:
|
|
13336
|
-
stencilAction:
|
|
13021
|
+
colorAction: TextureLoadAction.clear,
|
|
13022
|
+
depthAction: TextureLoadAction.clear,
|
|
13023
|
+
stencilAction: TextureLoadAction.clear
|
|
13337
13024
|
});
|
|
13338
13025
|
var globalVolume = renderer.renderingData.currentFrame.globalVolume;
|
|
13339
13026
|
var bloom = _extends({
|
|
@@ -13380,70 +13067,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13380
13067
|
return ToneMappingPass;
|
|
13381
13068
|
}(RenderPass);
|
|
13382
13069
|
|
|
13383
|
-
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
13384
13070
|
var seed$5 = 1;
|
|
13385
13071
|
/**
|
|
13386
13072
|
* RenderFrame 抽象类
|
|
13387
13073
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
13388
13074
|
function RenderFrame(options) {
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
this.
|
|
13392
|
-
|
|
13393
|
-
this.renderPassInfoMap = new WeakMap();
|
|
13394
|
-
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 ? [
|
|
13395
13079
|
1,
|
|
13396
13080
|
1,
|
|
13397
13081
|
0,
|
|
13398
13082
|
0
|
|
13399
|
-
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled
|
|
13400
|
-
colorAction: TextureLoadAction.whatever,
|
|
13401
|
-
stencilAction: TextureLoadAction.clear,
|
|
13402
|
-
depthAction: TextureLoadAction.whatever
|
|
13403
|
-
} : _options_clearAction;
|
|
13083
|
+
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
|
|
13404
13084
|
var engine = renderer.engine;
|
|
13405
13085
|
if (globalVolume) {
|
|
13406
13086
|
this.globalVolume = globalVolume;
|
|
13407
13087
|
}
|
|
13088
|
+
this.postProcessingEnabled = postProcessingEnabled;
|
|
13408
13089
|
this.globalUniforms = new GlobalUniforms();
|
|
13409
|
-
var attachments = []; //渲染场景物体Pass的RT
|
|
13410
|
-
var depthStencilAttachment;
|
|
13411
|
-
var drawObjectPassClearAction = {};
|
|
13412
13090
|
this.renderer = renderer;
|
|
13413
|
-
if (postProcessingEnabled) {
|
|
13414
|
-
|
|
13415
|
-
if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13416
|
-
throw new Error("Half float texture is not supported.");
|
|
13417
|
-
}
|
|
13418
|
-
// 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
|
|
13419
|
-
var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13420
|
-
attachments = [
|
|
13421
|
-
{
|
|
13422
|
-
texture: {
|
|
13423
|
-
format: glContext.RGBA,
|
|
13424
|
-
type: textureType,
|
|
13425
|
-
magFilter: glContext.LINEAR,
|
|
13426
|
-
minFilter: glContext.LINEAR
|
|
13427
|
-
}
|
|
13428
|
-
}
|
|
13429
|
-
];
|
|
13430
|
-
depthStencilAttachment = {
|
|
13431
|
-
storageType: RenderPassAttachmentStorageType.depth_stencil_opaque
|
|
13432
|
-
};
|
|
13433
|
-
drawObjectPassClearAction = {
|
|
13434
|
-
colorAction: TextureLoadAction.clear,
|
|
13435
|
-
stencilAction: TextureLoadAction.clear,
|
|
13436
|
-
depthAction: TextureLoadAction.clear
|
|
13437
|
-
};
|
|
13091
|
+
if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13092
|
+
throw new Error("Half float texture is not supported.");
|
|
13438
13093
|
}
|
|
13439
|
-
this.drawObjectPass = new DrawObjectPass(renderer
|
|
13440
|
-
name: RENDER_PASS_NAME_PREFIX,
|
|
13441
|
-
priority: RenderPassPriorityNormal,
|
|
13442
|
-
meshOrder: OrderType.ascending,
|
|
13443
|
-
depthStencilAttachment: depthStencilAttachment,
|
|
13444
|
-
attachments: attachments,
|
|
13445
|
-
clearAction: drawObjectPassClearAction
|
|
13446
|
-
});
|
|
13094
|
+
this.drawObjectPass = new DrawObjectPass(renderer);
|
|
13447
13095
|
var renderPasses = [
|
|
13448
13096
|
this.drawObjectPass
|
|
13449
13097
|
];
|
|
@@ -13458,51 +13106,13 @@ var seed$5 = 1;
|
|
|
13458
13106
|
this.renderer.getHeight() / 2
|
|
13459
13107
|
];
|
|
13460
13108
|
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13461
|
-
var
|
|
13462
|
-
var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13463
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer, {
|
|
13464
|
-
name: "BloomThresholdPass",
|
|
13465
|
-
attachments: [
|
|
13466
|
-
{
|
|
13467
|
-
texture: {
|
|
13468
|
-
format: glContext.RGBA,
|
|
13469
|
-
type: textureType1,
|
|
13470
|
-
minFilter: glContext.LINEAR,
|
|
13471
|
-
magFilter: glContext.LINEAR
|
|
13472
|
-
}
|
|
13473
|
-
}
|
|
13474
|
-
]
|
|
13475
|
-
});
|
|
13109
|
+
var bloomThresholdPass = new BloomThresholdPass(renderer);
|
|
13476
13110
|
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13477
13111
|
this.addRenderPass(bloomThresholdPass);
|
|
13478
13112
|
for(var i = 0; i < gaussianStep; i++){
|
|
13479
13113
|
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13480
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i
|
|
13481
|
-
|
|
13482
|
-
attachments: [
|
|
13483
|
-
{
|
|
13484
|
-
texture: {
|
|
13485
|
-
format: glContext.RGBA,
|
|
13486
|
-
type: textureType1,
|
|
13487
|
-
minFilter: glContext.LINEAR,
|
|
13488
|
-
magFilter: glContext.LINEAR
|
|
13489
|
-
}
|
|
13490
|
-
}
|
|
13491
|
-
]
|
|
13492
|
-
});
|
|
13493
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
|
|
13494
|
-
name: "GaussianDownPassV" + i,
|
|
13495
|
-
attachments: [
|
|
13496
|
-
{
|
|
13497
|
-
texture: {
|
|
13498
|
-
format: glContext.RGBA,
|
|
13499
|
-
type: textureType1,
|
|
13500
|
-
minFilter: glContext.LINEAR,
|
|
13501
|
-
magFilter: glContext.LINEAR
|
|
13502
|
-
}
|
|
13503
|
-
}
|
|
13504
|
-
]
|
|
13505
|
-
});
|
|
13114
|
+
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i);
|
|
13115
|
+
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i);
|
|
13506
13116
|
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13507
13117
|
this.addRenderPass(gaussianDownHPass);
|
|
13508
13118
|
this.addRenderPass(gaussianDownVPass);
|
|
@@ -13513,19 +13123,7 @@ var seed$5 = 1;
|
|
|
13513
13123
|
viewport[2] *= 4;
|
|
13514
13124
|
viewport[3] *= 4;
|
|
13515
13125
|
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13516
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1
|
|
13517
|
-
name: "GaussianUpPass" + i1,
|
|
13518
|
-
attachments: [
|
|
13519
|
-
{
|
|
13520
|
-
texture: {
|
|
13521
|
-
format: glContext.RGBA,
|
|
13522
|
-
type: textureType1,
|
|
13523
|
-
minFilter: glContext.LINEAR,
|
|
13524
|
-
magFilter: glContext.LINEAR
|
|
13525
|
-
}
|
|
13526
|
-
}
|
|
13527
|
-
]
|
|
13528
|
-
});
|
|
13126
|
+
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1);
|
|
13529
13127
|
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13530
13128
|
this.addRenderPass(gaussianUpPass);
|
|
13531
13129
|
viewport[2] *= 2;
|
|
@@ -13534,31 +13132,17 @@ var seed$5 = 1;
|
|
|
13534
13132
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13535
13133
|
this.addRenderPass(postProcessPass);
|
|
13536
13134
|
}
|
|
13537
|
-
this.semantics = new SemanticMap(options.semantics);
|
|
13538
|
-
this.clearAction = clearAction;
|
|
13539
13135
|
this.name = "RenderFrame" + seed$5++;
|
|
13540
|
-
var firstRP = renderPasses[0];
|
|
13541
13136
|
this.camera = camera;
|
|
13542
|
-
this.keepColorBuffer = keepColorBuffer;
|
|
13543
|
-
this.renderPassInfoMap.set(firstRP, {
|
|
13544
|
-
listStart: 0,
|
|
13545
|
-
listEnd: 0,
|
|
13546
|
-
renderPass: firstRP,
|
|
13547
|
-
intermedia: false
|
|
13548
|
-
});
|
|
13549
13137
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
13550
|
-
if (!options.clearAction) {
|
|
13551
|
-
this.resetClearActions();
|
|
13552
|
-
}
|
|
13553
|
-
this.passTextureCache = new PassTextureCache(engine);
|
|
13554
|
-
// FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
|
|
13555
|
-
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
13556
|
-
var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
|
|
13557
|
-
var shader = createCopyShader(level, writeDepth);
|
|
13558
|
-
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
13559
13138
|
}
|
|
13560
13139
|
var _proto = RenderFrame.prototype;
|
|
13561
13140
|
/**
|
|
13141
|
+
* 设置 RenderPasses 参数,此函数每帧调用一次
|
|
13142
|
+
*/ _proto.setup = function setup() {
|
|
13143
|
+
this.drawObjectPass.setup(this.postProcessingEnabled);
|
|
13144
|
+
};
|
|
13145
|
+
/**
|
|
13562
13146
|
* 根据 Mesh 优先级添加到 RenderPass
|
|
13563
13147
|
* @param mesh - 要添加的 Mesh 对象
|
|
13564
13148
|
*/ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
|
|
@@ -13575,78 +13159,25 @@ var seed$5 = 1;
|
|
|
13575
13159
|
* 销毁 RenderFrame
|
|
13576
13160
|
* @param options - 可以有选择销毁一些对象
|
|
13577
13161
|
*/ _proto.dispose = function dispose(options) {
|
|
13578
|
-
if ((options == null ? void 0 : options.semantics) !== DestroyOptions.keep) {
|
|
13579
|
-
this.semantics.dispose();
|
|
13580
|
-
}
|
|
13581
13162
|
var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
|
|
13582
13163
|
if (pass !== DestroyOptions.keep) {
|
|
13583
13164
|
this._renderPasses.forEach(function(renderPass) {
|
|
13584
13165
|
renderPass.dispose(pass);
|
|
13585
13166
|
});
|
|
13586
13167
|
}
|
|
13587
|
-
this.passTextureCache.dispose();
|
|
13588
13168
|
this._renderPasses.length = 0;
|
|
13589
|
-
this.
|
|
13590
|
-
};
|
|
13591
|
-
/**
|
|
13592
|
-
* 查找 Mesh 所在的 RenderPass 索引,没找到是-1
|
|
13593
|
-
* @param mesh - 需要查找的 Mesh
|
|
13594
|
-
*/ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
|
|
13595
|
-
var index = -1;
|
|
13596
|
-
this.renderPasses.every(function(rp, idx) {
|
|
13597
|
-
if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
|
|
13598
|
-
index = idx;
|
|
13599
|
-
return false;
|
|
13600
|
-
}
|
|
13601
|
-
return true;
|
|
13602
|
-
});
|
|
13603
|
-
return index;
|
|
13604
|
-
};
|
|
13605
|
-
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
13606
|
-
var info = this.renderPassInfoMap.get(renderPass);
|
|
13607
|
-
var priority = mesh.priority;
|
|
13608
|
-
if (!info) {
|
|
13609
|
-
return;
|
|
13610
|
-
}
|
|
13611
|
-
if (renderPass.meshes.length === 0) {
|
|
13612
|
-
info.listStart = info.listEnd = priority;
|
|
13613
|
-
} else {
|
|
13614
|
-
if (priority < info.listStart) {
|
|
13615
|
-
info.listStart = priority;
|
|
13616
|
-
} else if (priority > info.listEnd) {
|
|
13617
|
-
info.listEnd = priority;
|
|
13618
|
-
}
|
|
13619
|
-
}
|
|
13620
|
-
renderPass.addMesh(mesh);
|
|
13621
|
-
};
|
|
13622
|
-
_proto.resetClearActions = function resetClearActions() {
|
|
13623
|
-
var action = this.renderPasses.length > 1 ? TextureLoadAction.clear : TextureLoadAction.whatever;
|
|
13624
|
-
this.clearAction.stencilAction = action;
|
|
13625
|
-
this.clearAction.depthAction = action;
|
|
13626
|
-
this.clearAction.colorAction = action;
|
|
13627
|
-
if (this.keepColorBuffer) {
|
|
13628
|
-
this.clearAction.colorAction = TextureLoadAction.whatever;
|
|
13629
|
-
}
|
|
13169
|
+
this.disposed = true;
|
|
13630
13170
|
};
|
|
13631
13171
|
/**
|
|
13632
13172
|
* 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
|
|
13633
13173
|
* @param passes - RenderPass 数组
|
|
13634
13174
|
*/ _proto.setRenderPasses = function setRenderPasses(passes) {
|
|
13635
|
-
var _this = this;
|
|
13636
|
-
if (this.renderer !== undefined) {
|
|
13637
|
-
passes.forEach(function(pass) {
|
|
13638
|
-
return pass.initialize(_this.renderer);
|
|
13639
|
-
});
|
|
13640
|
-
}
|
|
13641
13175
|
this._renderPasses = passes.slice();
|
|
13642
13176
|
};
|
|
13643
13177
|
/**
|
|
13644
13178
|
* 添加 RenderPass
|
|
13645
13179
|
* @param pass - 需要添加的 RenderPass
|
|
13646
13180
|
*/ _proto.addRenderPass = function addRenderPass(pass) {
|
|
13647
|
-
if (this.renderer !== undefined) {
|
|
13648
|
-
pass.initialize(this.renderer);
|
|
13649
|
-
}
|
|
13650
13181
|
this._renderPasses.push(pass);
|
|
13651
13182
|
};
|
|
13652
13183
|
/**
|
|
@@ -13663,9 +13194,9 @@ var seed$5 = 1;
|
|
|
13663
13194
|
}
|
|
13664
13195
|
},
|
|
13665
13196
|
{
|
|
13666
|
-
key: "
|
|
13197
|
+
key: "isDisposed",
|
|
13667
13198
|
get: function get() {
|
|
13668
|
-
return this.
|
|
13199
|
+
return this.disposed;
|
|
13669
13200
|
}
|
|
13670
13201
|
}
|
|
13671
13202
|
]);
|
|
@@ -13674,10 +13205,6 @@ var seed$5 = 1;
|
|
|
13674
13205
|
function getTextureSize(tex) {
|
|
13675
13206
|
return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
|
|
13676
13207
|
}
|
|
13677
|
-
function findPreviousRenderPass(renderPasses, renderPass) {
|
|
13678
|
-
var index = renderPasses.indexOf(renderPass);
|
|
13679
|
-
return renderPasses[index - 1];
|
|
13680
|
-
}
|
|
13681
13208
|
var GlobalUniforms = function GlobalUniforms() {
|
|
13682
13209
|
this.floats = {};
|
|
13683
13210
|
this.ints = {};
|
|
@@ -13715,6 +13242,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
|
|
|
13715
13242
|
return Renderbuffer;
|
|
13716
13243
|
}();
|
|
13717
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
|
+
|
|
13718
13361
|
var isWebGL2Available = typeof WebGL2RenderingContext === "function";
|
|
13719
13362
|
var GPUCapability = /*#__PURE__*/ function() {
|
|
13720
13363
|
function GPUCapability(gl) {
|
|
@@ -13900,70 +13543,11 @@ var CompressTextureCapabilityType;
|
|
|
13900
13543
|
return !!hasCompressedTextureSupport;
|
|
13901
13544
|
}
|
|
13902
13545
|
|
|
13903
|
-
var FilterMode;
|
|
13904
|
-
(function(FilterMode) {
|
|
13905
|
-
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
13906
|
-
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
13907
|
-
})(FilterMode || (FilterMode = {}));
|
|
13908
|
-
var RenderTextureFormat;
|
|
13909
|
-
(function(RenderTextureFormat) {
|
|
13910
|
-
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
13911
|
-
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
13912
|
-
})(RenderTextureFormat || (RenderTextureFormat = {}));
|
|
13913
|
-
/**
|
|
13914
|
-
*
|
|
13915
|
-
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
13916
|
-
function Framebuffer() {}
|
|
13917
|
-
var _proto = Framebuffer.prototype;
|
|
13918
|
-
_proto.resize = function resize(x, y, width, height) {
|
|
13919
|
-
// OVERRIDE
|
|
13920
|
-
};
|
|
13921
|
-
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
13922
|
-
// OVERRIDE
|
|
13923
|
-
};
|
|
13924
|
-
_proto.unbind = function unbind() {
|
|
13925
|
-
// OVERRIDE
|
|
13926
|
-
};
|
|
13927
|
-
_proto.bind = function bind() {
|
|
13928
|
-
// OVERRIDE
|
|
13929
|
-
};
|
|
13930
|
-
_proto.getDepthTexture = function getDepthTexture() {
|
|
13931
|
-
// OVERRIDE
|
|
13932
|
-
return undefined;
|
|
13933
|
-
};
|
|
13934
|
-
_proto.getStencilTexture = function getStencilTexture() {
|
|
13935
|
-
// OVERRIDE
|
|
13936
|
-
return undefined;
|
|
13937
|
-
};
|
|
13938
|
-
_proto.getColorTextures = function getColorTextures() {
|
|
13939
|
-
// OVERRIDE
|
|
13940
|
-
return [];
|
|
13941
|
-
};
|
|
13942
|
-
_proto.dispose = function dispose(options) {
|
|
13943
|
-
// OVERRIDE
|
|
13944
|
-
};
|
|
13945
|
-
_create_class(Framebuffer, [
|
|
13946
|
-
{
|
|
13947
|
-
key: "stencilStorage",
|
|
13948
|
-
get: function get() {
|
|
13949
|
-
// OVERRIDE
|
|
13950
|
-
return undefined;
|
|
13951
|
-
}
|
|
13952
|
-
},
|
|
13953
|
-
{
|
|
13954
|
-
key: "depthStorage",
|
|
13955
|
-
get: function get() {
|
|
13956
|
-
// OVERRIDE
|
|
13957
|
-
return undefined;
|
|
13958
|
-
}
|
|
13959
|
-
}
|
|
13960
|
-
]);
|
|
13961
|
-
return Framebuffer;
|
|
13962
|
-
}();
|
|
13963
|
-
|
|
13964
13546
|
var Renderer = /*#__PURE__*/ function() {
|
|
13965
13547
|
function Renderer(engine) {
|
|
13966
13548
|
this.engine = engine;
|
|
13549
|
+
this.currentFramebuffer = null;
|
|
13550
|
+
this.renderTargetPool = new RenderTargetPool(engine);
|
|
13967
13551
|
}
|
|
13968
13552
|
var _proto = Renderer.prototype;
|
|
13969
13553
|
_proto.setGlobalFloat = function setGlobalFloat(name, value) {
|
|
@@ -14033,8 +13617,10 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14033
13617
|
// OVERRIDE
|
|
14034
13618
|
};
|
|
14035
13619
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
14036
|
-
|
|
14037
|
-
|
|
13620
|
+
return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
13621
|
+
};
|
|
13622
|
+
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13623
|
+
this.renderTargetPool.release(rt);
|
|
14038
13624
|
};
|
|
14039
13625
|
_proto.dispose = function dispose() {
|
|
14040
13626
|
// OVERRIDE
|
|
@@ -14042,6 +13628,41 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14042
13628
|
return Renderer;
|
|
14043
13629
|
}();
|
|
14044
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
|
+
|
|
14045
13666
|
/**
|
|
14046
13667
|
* @since 2.7.0
|
|
14047
13668
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -18072,6 +17693,11 @@ var PlayState;
|
|
|
18072
17693
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
18073
17694
|
})(PlayState || (PlayState = {}));
|
|
18074
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
|
+
|
|
18075
17701
|
var tempQuat$1 = new Quaternion();
|
|
18076
17702
|
var tempVector3 = new Vector3();
|
|
18077
17703
|
var tempVector3Second = new Vector3();
|
|
@@ -24449,8 +24075,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24449
24075
|
_this.reusable = reusable;
|
|
24450
24076
|
_this.speed = speed;
|
|
24451
24077
|
_this.name = sourceContent.name;
|
|
24452
|
-
_this
|
|
24453
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24078
|
+
PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24454
24079
|
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24455
24080
|
aspect: width / height,
|
|
24456
24081
|
pixelWidth: width,
|
|
@@ -24464,7 +24089,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24464
24089
|
_this.createRenderFrame();
|
|
24465
24090
|
Composition.buildItemTree(_this.rootItem);
|
|
24466
24091
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
24467
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24468
24092
|
return _this;
|
|
24469
24093
|
}
|
|
24470
24094
|
var _proto = Composition.prototype;
|
|
@@ -24574,12 +24198,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24574
24198
|
this.renderFrame = new RenderFrame({
|
|
24575
24199
|
camera: this.camera,
|
|
24576
24200
|
renderer: this.renderer,
|
|
24577
|
-
keepColorBuffer: this.keepColorBuffer,
|
|
24578
24201
|
globalVolume: this.globalVolume,
|
|
24579
24202
|
postProcessingEnabled: this.postProcessingEnabled
|
|
24580
24203
|
});
|
|
24581
|
-
// TODO 考虑放到构造函数
|
|
24582
|
-
this.renderFrame.cachedTextures = this.textures;
|
|
24583
24204
|
};
|
|
24584
24205
|
/**
|
|
24585
24206
|
* 跳到指定时间点(不做任何播放行为)
|
|
@@ -24630,7 +24251,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24630
24251
|
this.isEnded = false;
|
|
24631
24252
|
this.isEndCalled = false;
|
|
24632
24253
|
this.rootComposition.time = 0;
|
|
24633
|
-
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24634
24254
|
};
|
|
24635
24255
|
_proto.prepareRender = function prepareRender() {};
|
|
24636
24256
|
/**
|
|
@@ -24648,8 +24268,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24648
24268
|
var previousCompositionTime = this.time;
|
|
24649
24269
|
this.updateCompositionTime(deltaTime * this.speed / 1000);
|
|
24650
24270
|
var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
|
|
24651
|
-
// 更新 model-tree-plugin
|
|
24652
|
-
this.updatePluginLoaders(deltaTimeInMs);
|
|
24653
24271
|
this.sceneTicking.update.tick(deltaTimeInMs);
|
|
24654
24272
|
this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
|
|
24655
24273
|
this.updateCamera();
|
|
@@ -24674,15 +24292,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24674
24292
|
this.camera.updateMatrix();
|
|
24675
24293
|
};
|
|
24676
24294
|
/**
|
|
24677
|
-
* 插件更新,来自 CompVFXItem 的更新调用
|
|
24678
|
-
* @param deltaTime - 更新的时间步长
|
|
24679
|
-
*/ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
|
|
24680
|
-
var _this = this;
|
|
24681
|
-
this.pluginSystem.plugins.forEach(function(loader) {
|
|
24682
|
-
return loader.onCompositionUpdate(_this, deltaTime);
|
|
24683
|
-
});
|
|
24684
|
-
};
|
|
24685
|
-
/**
|
|
24686
24295
|
* 更新主合成组件
|
|
24687
24296
|
*/ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
|
|
24688
24297
|
if (this.rootComposition.state === PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
|
|
@@ -24841,7 +24450,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24841
24450
|
* 合成对象销毁
|
|
24842
24451
|
*/ _proto.dispose = function dispose() {
|
|
24843
24452
|
var _this = this;
|
|
24844
|
-
var _this_pluginSystem;
|
|
24845
24453
|
if (this.destroyed) {
|
|
24846
24454
|
return;
|
|
24847
24455
|
}
|
|
@@ -24861,13 +24469,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24861
24469
|
this.rootItem.dispose();
|
|
24862
24470
|
// FIXME: 注意这里增加了renderFrame销毁
|
|
24863
24471
|
this.renderFrame.dispose();
|
|
24864
|
-
|
|
24472
|
+
PluginSystem.destroyComposition(this);
|
|
24865
24473
|
this.update = function() {
|
|
24866
24474
|
{
|
|
24867
24475
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
24868
24476
|
}
|
|
24869
24477
|
};
|
|
24870
24478
|
this.dispose = noop;
|
|
24479
|
+
this.renderer.engine.removeComposition(this);
|
|
24871
24480
|
if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
24872
24481
|
return;
|
|
24873
24482
|
}
|
|
@@ -24884,7 +24493,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24884
24493
|
0
|
|
24885
24494
|
]
|
|
24886
24495
|
});
|
|
24887
|
-
this.renderer.engine.removeComposition(this);
|
|
24888
24496
|
};
|
|
24889
24497
|
/**
|
|
24890
24498
|
* 编辑器使用的 transform 修改方法
|
|
@@ -29277,6 +28885,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
29277
28885
|
this.textLayout.textVerticalAlign = value;
|
|
29278
28886
|
this.isDirty = true;
|
|
29279
28887
|
};
|
|
28888
|
+
/**
|
|
28889
|
+
* @deprecated 2.8.0 本方法已废弃,请使用 setTextVerticalAlign 替代。
|
|
28890
|
+
*/ _proto.setTextBaseline = function setTextBaseline(value) {
|
|
28891
|
+
console.warn("setTextBaseline 已废弃,请改用 setTextVerticalAlign。" + "本次调用将转调用 setTextVerticalAlign。");
|
|
28892
|
+
this.setTextVerticalAlign(value);
|
|
28893
|
+
};
|
|
29280
28894
|
_proto.setTextColor = function setTextColor(value) {
|
|
29281
28895
|
if (this.textStyle.textColor === value) {
|
|
29282
28896
|
return;
|
|
@@ -29541,7 +29155,9 @@ var TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29541
29155
|
this.lineCount = this.getLineCount(this.text);
|
|
29542
29156
|
this.isDirty = true;
|
|
29543
29157
|
};
|
|
29544
|
-
|
|
29158
|
+
/**
|
|
29159
|
+
* 根据配置更新文本样式和布局
|
|
29160
|
+
*/ _proto.updateWithOptions = function updateWithOptions(options) {
|
|
29545
29161
|
// 初始化 textStyle 和 textLayout
|
|
29546
29162
|
if (!this.textStyle) {
|
|
29547
29163
|
this.textStyle = new TextStyle(options);
|
|
@@ -31851,7 +31467,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31851
31467
|
return ret;
|
|
31852
31468
|
}
|
|
31853
31469
|
|
|
31854
|
-
var version$1 = "2.8.0-alpha.
|
|
31470
|
+
var version$1 = "2.8.0-alpha.2";
|
|
31855
31471
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31856
31472
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31857
31473
|
var reverseParticle = false;
|
|
@@ -32366,7 +31982,7 @@ var seed = 1;
|
|
|
32366
31982
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
32367
31983
|
* @param options - 扩展参数
|
|
32368
31984
|
* @returns
|
|
32369
|
-
*/ _proto.loadScene = function loadScene(url, renderer
|
|
31985
|
+
*/ _proto.loadScene = function loadScene(url, renderer) {
|
|
32370
31986
|
var _this = this;
|
|
32371
31987
|
return _async_to_generator(function() {
|
|
32372
31988
|
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
@@ -32427,7 +32043,7 @@ var seed = 1;
|
|
|
32427
32043
|
});
|
|
32428
32044
|
});
|
|
32429
32045
|
loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
|
|
32430
|
-
var scene, link,
|
|
32046
|
+
var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
|
|
32431
32047
|
return __generator(this, function(_state) {
|
|
32432
32048
|
switch(_state.label){
|
|
32433
32049
|
case 0:
|
|
@@ -32477,7 +32093,26 @@ var seed = 1;
|
|
|
32477
32093
|
})
|
|
32478
32094
|
];
|
|
32479
32095
|
case 5:
|
|
32480
|
-
|
|
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();
|
|
32481
32116
|
_jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
|
|
32482
32117
|
return [
|
|
32483
32118
|
4,
|
|
@@ -32488,46 +32123,26 @@ var seed = 1;
|
|
|
32488
32123
|
hookTimeInfo("processImages", function() {
|
|
32489
32124
|
return _this.processImages(images, isKTX2Supported);
|
|
32490
32125
|
}),
|
|
32491
|
-
hookTimeInfo("plugin:processAssets", function() {
|
|
32492
|
-
return _this.processPluginAssets(jsonScene, pluginSystem, options);
|
|
32493
|
-
}),
|
|
32494
32126
|
hookTimeInfo("processFontURL", function() {
|
|
32495
32127
|
return _this.processFontURL(fonts);
|
|
32496
32128
|
})
|
|
32497
32129
|
])
|
|
32498
32130
|
];
|
|
32499
|
-
case
|
|
32500
|
-
|
|
32131
|
+
case 7:
|
|
32132
|
+
_ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
|
|
32501
32133
|
return [
|
|
32502
32134
|
4,
|
|
32503
32135
|
hookTimeInfo("processTextures", function() {
|
|
32504
32136
|
return _this.processTextures(loadedImages, loadedBins, jsonScene);
|
|
32505
32137
|
})
|
|
32506
32138
|
];
|
|
32507
|
-
case 7:
|
|
32508
|
-
loadedTextures = _state.sent();
|
|
32509
|
-
scene = {
|
|
32510
|
-
timeInfos: timeInfos,
|
|
32511
|
-
url: url,
|
|
32512
|
-
renderLevel: _this.options.renderLevel,
|
|
32513
|
-
storage: {},
|
|
32514
|
-
pluginSystem: pluginSystem,
|
|
32515
|
-
jsonScene: jsonScene,
|
|
32516
|
-
bins: loadedBins,
|
|
32517
|
-
textureOptions: loadedTextures,
|
|
32518
|
-
textures: [],
|
|
32519
|
-
images: loadedImages,
|
|
32520
|
-
assets: _this.assets
|
|
32521
|
-
};
|
|
32522
|
-
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
32523
|
-
return [
|
|
32524
|
-
4,
|
|
32525
|
-
hookTimeInfo("plugin:prepareResource", function() {
|
|
32526
|
-
return pluginSystem.loadResources(scene, _this.options);
|
|
32527
|
-
})
|
|
32528
|
-
];
|
|
32529
32139
|
case 8:
|
|
32530
|
-
_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;
|
|
32531
32146
|
_state.label = 9;
|
|
32532
32147
|
case 9:
|
|
32533
32148
|
totalTime = performance.now() - startTime;
|
|
@@ -32559,29 +32174,23 @@ var seed = 1;
|
|
|
32559
32174
|
return this.assets;
|
|
32560
32175
|
};
|
|
32561
32176
|
_proto.processJSON = function processJSON(json) {
|
|
32562
|
-
var _this = this;
|
|
32563
32177
|
return _async_to_generator(function() {
|
|
32564
|
-
var jsonScene, _jsonScene_plugins, plugins,
|
|
32178
|
+
var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
|
|
32565
32179
|
return __generator(this, function(_state) {
|
|
32566
|
-
|
|
32567
|
-
|
|
32568
|
-
|
|
32569
|
-
|
|
32570
|
-
|
|
32571
|
-
|
|
32572
|
-
|
|
32573
|
-
pluginSystem.processRawJSON(jsonScene, _this.options)
|
|
32574
|
-
];
|
|
32575
|
-
case 1:
|
|
32576
|
-
_state.sent();
|
|
32577
|
-
return [
|
|
32578
|
-
2,
|
|
32579
|
-
{
|
|
32580
|
-
jsonScene: jsonScene,
|
|
32581
|
-
pluginSystem: pluginSystem
|
|
32582
|
-
}
|
|
32583
|
-
];
|
|
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
|
+
}
|
|
32584
32187
|
}
|
|
32188
|
+
return [
|
|
32189
|
+
2,
|
|
32190
|
+
{
|
|
32191
|
+
jsonScene: jsonScene
|
|
32192
|
+
}
|
|
32193
|
+
];
|
|
32585
32194
|
});
|
|
32586
32195
|
})();
|
|
32587
32196
|
};
|
|
@@ -32787,30 +32396,18 @@ var seed = 1;
|
|
|
32787
32396
|
});
|
|
32788
32397
|
})();
|
|
32789
32398
|
};
|
|
32790
|
-
_proto.processPluginAssets = function processPluginAssets(
|
|
32399
|
+
_proto.processPluginAssets = function processPluginAssets(scene) {
|
|
32791
32400
|
var _this = this;
|
|
32792
32401
|
return _async_to_generator(function() {
|
|
32793
|
-
var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
|
|
32794
32402
|
return __generator(this, function(_state) {
|
|
32795
32403
|
switch(_state.label){
|
|
32796
32404
|
case 0:
|
|
32797
32405
|
return [
|
|
32798
32406
|
4,
|
|
32799
|
-
|
|
32407
|
+
PluginSystem.processAssets(scene, _this.options)
|
|
32800
32408
|
];
|
|
32801
32409
|
case 1:
|
|
32802
|
-
|
|
32803
|
-
_pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
|
|
32804
|
-
acc.assets = acc.assets.concat(cur.assets);
|
|
32805
|
-
acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
|
|
32806
|
-
return acc;
|
|
32807
|
-
}, {
|
|
32808
|
-
assets: [],
|
|
32809
|
-
loadedAssets: []
|
|
32810
|
-
}), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
|
|
32811
|
-
for(i = 0; i < assets.length; i++){
|
|
32812
|
-
_this.assets[assets[i].id] = loadedAssets[i];
|
|
32813
|
-
}
|
|
32410
|
+
_state.sent();
|
|
32814
32411
|
return [
|
|
32815
32412
|
2
|
|
32816
32413
|
];
|
|
@@ -33237,7 +32834,6 @@ function _createTextureOptionsBySource() {
|
|
|
33237
32834
|
}
|
|
33238
32835
|
};
|
|
33239
32836
|
_proto.prepareAssets = function prepareAssets(scene, assets) {
|
|
33240
|
-
this.engine.clearResources();
|
|
33241
32837
|
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
|
|
33242
32838
|
var assetId = _step.value;
|
|
33243
32839
|
var asset = assets[assetId];
|
|
@@ -35149,8 +34745,9 @@ var DEFAULT_FPS = 60;
|
|
|
35149
34745
|
]
|
|
35150
34746
|
});
|
|
35151
34747
|
for(var i1 = 0; i1 < comps.length; i1++){
|
|
35152
|
-
!comps[i1].renderFrame.
|
|
34748
|
+
!comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
|
|
35153
34749
|
}
|
|
34750
|
+
this.renderer.renderTargetPool.flush();
|
|
35154
34751
|
};
|
|
35155
34752
|
/**
|
|
35156
34753
|
* 将渲染器重新和父容器大小对齐
|
|
@@ -35396,6 +34993,95 @@ var DEFAULT_FPS = 60;
|
|
|
35396
34993
|
return Engine;
|
|
35397
34994
|
}(EventEmitter);
|
|
35398
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
|
+
|
|
35399
35085
|
var SceneLoader = /*#__PURE__*/ function() {
|
|
35400
35086
|
function SceneLoader() {}
|
|
35401
35087
|
SceneLoader.load = function load(scene, engine, options) {
|
|
@@ -35414,16 +35100,16 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35414
35100
|
engine.assetManagers.push(assetManager);
|
|
35415
35101
|
return [
|
|
35416
35102
|
4,
|
|
35417
|
-
assetManager.loadScene(scene, engine.renderer
|
|
35418
|
-
env: engine.env
|
|
35419
|
-
})
|
|
35103
|
+
assetManager.loadScene(scene, engine.renderer)
|
|
35420
35104
|
];
|
|
35421
35105
|
case 1:
|
|
35422
35106
|
loadedScene = _state.sent();
|
|
35107
|
+
engine.clearResources();
|
|
35108
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
35109
|
+
PluginSystem.loadResources(loadedScene, assetManager.options, engine);
|
|
35423
35110
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35424
35111
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35425
35112
|
engine.assetService.initializeTexture(loadedScene);
|
|
35426
|
-
loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
|
|
35427
35113
|
composition = _this.createComposition(loadedScene, engine, options);
|
|
35428
35114
|
composition.setIndex(compositionIndex);
|
|
35429
35115
|
compileStart = performance.now();
|
|
@@ -35476,14 +35162,14 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35476
35162
|
return SceneLoader;
|
|
35477
35163
|
}();
|
|
35478
35164
|
|
|
35479
|
-
registerPlugin("camera", CameraVFXItemLoader
|
|
35480
|
-
registerPlugin("text", TextLoader
|
|
35481
|
-
registerPlugin("sprite", SpriteLoader
|
|
35482
|
-
registerPlugin("particle", ParticleLoader
|
|
35483
|
-
registerPlugin("cal", CalculateLoader
|
|
35484
|
-
registerPlugin("interact", InteractLoader
|
|
35485
|
-
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";
|
|
35486
35172
|
logger.info("Core version: " + version + ".");
|
|
35487
35173
|
|
|
35488
|
-
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 };
|
|
35489
35175
|
//# sourceMappingURL=index.mjs.map
|