@galacean/effects-threejs 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/index.js +649 -964
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +648 -961
- package/dist/index.mjs.map +1 -1
- package/dist/three-render-pass.d.ts +2 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -59,41 +59,6 @@ function _async_to_generator(fn) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function _array_like_to_array(arr, len) {
|
|
63
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
64
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
65
|
-
return arr2;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
-
if (!o) return;
|
|
70
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
78
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
79
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
80
|
-
// Fallback for engines without symbol support
|
|
81
|
-
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
82
|
-
if (it) o = it;
|
|
83
|
-
var i = 0;
|
|
84
|
-
return function() {
|
|
85
|
-
if (i >= o.length) return {
|
|
86
|
-
done: true
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
done: false,
|
|
90
|
-
value: o[i++]
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
62
|
function _instanceof1(left, right) {
|
|
98
63
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
99
64
|
return !!right[Symbol.hasInstance](left);
|
|
@@ -2926,134 +2891,68 @@ function applyMixins(derivedCtrl, baseCtrls) {
|
|
|
2926
2891
|
}
|
|
2927
2892
|
|
|
2928
2893
|
var pluginLoaderMap = {};
|
|
2929
|
-
var
|
|
2930
|
-
var pluginCtrlMap = {};
|
|
2894
|
+
var plugins = [];
|
|
2931
2895
|
/**
|
|
2932
2896
|
* 注册 plugin
|
|
2933
2897
|
* @param name
|
|
2934
2898
|
* @param pluginClass class of plugin
|
|
2935
2899
|
* @param itemClass class of item
|
|
2936
2900
|
* @param isDefault load
|
|
2937
|
-
*/ function registerPlugin(name, pluginClass
|
|
2938
|
-
if (
|
|
2901
|
+
*/ function registerPlugin(name, pluginClass) {
|
|
2902
|
+
if (pluginLoaderMap[name]) {
|
|
2939
2903
|
logger.error("Duplicate registration for plugin " + name + ".");
|
|
2940
2904
|
}
|
|
2941
|
-
pluginCtrlMap[name] = itemClass;
|
|
2942
2905
|
pluginLoaderMap[name] = pluginClass;
|
|
2943
|
-
|
|
2906
|
+
var pluginInstance = new pluginClass();
|
|
2907
|
+
pluginInstance.name = name;
|
|
2908
|
+
pluginInstance.initialize();
|
|
2909
|
+
plugins.push(pluginInstance);
|
|
2910
|
+
plugins.sort(function(a, b) {
|
|
2911
|
+
return a.order - b.order;
|
|
2912
|
+
});
|
|
2944
2913
|
}
|
|
2945
|
-
|
|
2946
|
-
|
|
2914
|
+
/**
|
|
2915
|
+
* 注销 plugin
|
|
2916
|
+
*/ function unregisterPlugin(name) {
|
|
2947
2917
|
delete pluginLoaderMap[name];
|
|
2948
|
-
|
|
2918
|
+
var pluginIndex = plugins.findIndex(function(plugin) {
|
|
2919
|
+
return plugin.name === name;
|
|
2920
|
+
});
|
|
2921
|
+
if (pluginIndex !== -1) {
|
|
2922
|
+
plugins.splice(pluginIndex, 1);
|
|
2923
|
+
}
|
|
2949
2924
|
}
|
|
2950
2925
|
var PluginSystem = /*#__PURE__*/ function() {
|
|
2951
|
-
function PluginSystem(
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
loaded.push(loader);
|
|
2958
|
-
loaders[name] = loader;
|
|
2959
|
-
}
|
|
2960
|
-
};
|
|
2961
|
-
defaultPlugins.forEach(addLoader);
|
|
2962
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(pluginNames), _step; !(_step = _iterator()).done;){
|
|
2963
|
-
var customPluginName = _step.value;
|
|
2964
|
-
if (!pluginLoaderMap[customPluginName]) {
|
|
2965
|
-
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
this.plugins = Object.keys(loaders).map(function(name) {
|
|
2969
|
-
var pluginConstructor = pluginLoaderMap[name];
|
|
2970
|
-
var loader = new pluginConstructor();
|
|
2971
|
-
loader.name = name;
|
|
2972
|
-
return loader;
|
|
2973
|
-
}).sort(function(a, b) {
|
|
2974
|
-
return a.order - b.order;
|
|
2975
|
-
});
|
|
2976
|
-
}
|
|
2977
|
-
var _proto = PluginSystem.prototype;
|
|
2978
|
-
_proto.initializeComposition = function initializeComposition(composition, scene) {
|
|
2979
|
-
this.plugins.forEach(function(loader) {
|
|
2926
|
+
function PluginSystem() {}
|
|
2927
|
+
PluginSystem.getPlugins = function getPlugins() {
|
|
2928
|
+
return plugins;
|
|
2929
|
+
};
|
|
2930
|
+
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2931
|
+
plugins.forEach(function(loader) {
|
|
2980
2932
|
return loader.onCompositionConstructed(composition, scene);
|
|
2981
2933
|
});
|
|
2982
2934
|
};
|
|
2983
|
-
|
|
2984
|
-
|
|
2935
|
+
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2936
|
+
plugins.forEach(function(loader) {
|
|
2985
2937
|
return loader.onCompositionDestroyed(comp);
|
|
2986
2938
|
});
|
|
2987
2939
|
};
|
|
2988
|
-
|
|
2989
|
-
this.plugins.forEach(function(loader) {
|
|
2990
|
-
return loader.onCompositionReset(comp, renderFrame);
|
|
2991
|
-
});
|
|
2992
|
-
};
|
|
2993
|
-
_proto.processRawJSON = function processRawJSON(json, options) {
|
|
2994
|
-
var _this = this;
|
|
2995
|
-
return _async_to_generator(function() {
|
|
2996
|
-
return __generator(this, function(_state) {
|
|
2997
|
-
return [
|
|
2998
|
-
2,
|
|
2999
|
-
_this.callStatic("processRawJSON", json, options)
|
|
3000
|
-
];
|
|
3001
|
-
});
|
|
3002
|
-
})();
|
|
3003
|
-
};
|
|
3004
|
-
_proto.processAssets = function processAssets(json, options) {
|
|
3005
|
-
var _this = this;
|
|
3006
|
-
return _async_to_generator(function() {
|
|
3007
|
-
return __generator(this, function(_state) {
|
|
3008
|
-
return [
|
|
3009
|
-
2,
|
|
3010
|
-
_this.callStatic("processAssets", json, options)
|
|
3011
|
-
];
|
|
3012
|
-
});
|
|
3013
|
-
})();
|
|
3014
|
-
};
|
|
3015
|
-
_proto.precompile = function precompile(compositions, renderer) {
|
|
3016
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
|
|
3017
|
-
var plugin = _step.value;
|
|
3018
|
-
plugin.precompile(compositions, renderer);
|
|
3019
|
-
}
|
|
3020
|
-
};
|
|
3021
|
-
_proto.loadResources = function loadResources(scene, options) {
|
|
3022
|
-
var _this = this;
|
|
2940
|
+
PluginSystem.processAssets = function processAssets(scene, options) {
|
|
3023
2941
|
return _async_to_generator(function() {
|
|
3024
2942
|
return __generator(this, function(_state) {
|
|
3025
2943
|
return [
|
|
3026
2944
|
2,
|
|
3027
|
-
|
|
2945
|
+
Promise.all(plugins.map(function(plugin) {
|
|
2946
|
+
return plugin.processAssets(scene, options);
|
|
2947
|
+
}))
|
|
3028
2948
|
];
|
|
3029
2949
|
});
|
|
3030
2950
|
})();
|
|
3031
2951
|
};
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
}
|
|
3036
|
-
var _this = this;
|
|
3037
|
-
return _async_to_generator(function() {
|
|
3038
|
-
var pendings, plugins, i, plugin, ctrl, _ctrl_name, _ctrl_name1;
|
|
3039
|
-
return __generator(this, function(_state) {
|
|
3040
|
-
pendings = [];
|
|
3041
|
-
plugins = _this.plugins;
|
|
3042
|
-
for(i = 0; i < plugins.length; i++){
|
|
3043
|
-
plugin = plugins[i];
|
|
3044
|
-
ctrl = pluginLoaderMap[plugin.name];
|
|
3045
|
-
if (name in ctrl) {
|
|
3046
|
-
pendings.push(Promise.resolve((_ctrl_name1 = ctrl[name]) == null ? void 0 : (_ctrl_name = _ctrl_name1).call.apply(_ctrl_name, [].concat([
|
|
3047
|
-
ctrl
|
|
3048
|
-
], args))));
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
return [
|
|
3052
|
-
2,
|
|
3053
|
-
Promise.all(pendings)
|
|
3054
|
-
];
|
|
3055
|
-
});
|
|
3056
|
-
})();
|
|
2952
|
+
PluginSystem.loadResources = function loadResources(scene, options, engine) {
|
|
2953
|
+
plugins.forEach(function(loader) {
|
|
2954
|
+
return loader.prepareResource(scene, options, engine);
|
|
2955
|
+
});
|
|
3057
2956
|
};
|
|
3058
2957
|
return PluginSystem;
|
|
3059
2958
|
}();
|
|
@@ -3061,6 +2960,8 @@ var pluginInfoMap = {
|
|
|
3061
2960
|
"alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
|
|
3062
2961
|
"downgrade": "@galacean/effects-plugin-downgrade",
|
|
3063
2962
|
"editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
|
|
2963
|
+
"ffd": "@galacean/effects-plugin-ffd",
|
|
2964
|
+
"ktx2": "@galacean/effects-plugin-ktx2",
|
|
3064
2965
|
"model": "@galacean/effects-plugin-model",
|
|
3065
2966
|
"video": "@galacean/effects-plugin-multimedia",
|
|
3066
2967
|
"audio": "@galacean/effects-plugin-multimedia",
|
|
@@ -3086,15 +2987,33 @@ function getPluginUsageInfo(name) {
|
|
|
3086
2987
|
this.name = "";
|
|
3087
2988
|
}
|
|
3088
2989
|
var _proto = AbstractPlugin.prototype;
|
|
2990
|
+
_proto.initialize = function initialize() {};
|
|
2991
|
+
/**
|
|
2992
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
2993
|
+
* 此阶段可以加载插件所需类型资源,并返回原始资源和加载后的资源。
|
|
2994
|
+
* @param scene
|
|
2995
|
+
* @param options
|
|
2996
|
+
* @returns
|
|
2997
|
+
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2998
|
+
return _async_to_generator(function() {
|
|
2999
|
+
return __generator(this, function(_state) {
|
|
3000
|
+
return [
|
|
3001
|
+
2
|
|
3002
|
+
];
|
|
3003
|
+
});
|
|
3004
|
+
})();
|
|
3005
|
+
};
|
|
3089
3006
|
/**
|
|
3090
|
-
*
|
|
3091
|
-
*
|
|
3092
|
-
*
|
|
3093
|
-
|
|
3007
|
+
* loadScene 函数调用的时候会触发此函数,
|
|
3008
|
+
* 此阶段时,json 中的图片和二进制已经被加载完成,可以对加载好的资源做进一步处理,
|
|
3009
|
+
* 如果 promise 被 reject, loadScene 函数同样会被 reject,表示场景加载失败。
|
|
3010
|
+
* 请记住,整个 load 阶段都不要创建 GL 相关的对象,只创建 JS 对象
|
|
3011
|
+
* 此阶段晚于 processAssets
|
|
3012
|
+
* @param {Scene} scene
|
|
3013
|
+
* @param {SceneLoadOptions} options
|
|
3014
|
+
*/ _proto.prepareResource = function prepareResource(scene, options, engine) {};
|
|
3094
3015
|
_proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {};
|
|
3095
|
-
_proto.onCompositionReset = function onCompositionReset(composition, frame) {};
|
|
3096
3016
|
_proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {};
|
|
3097
|
-
_proto.onCompositionUpdate = function onCompositionUpdate(composition, dt) {};
|
|
3098
3017
|
return AbstractPlugin;
|
|
3099
3018
|
}();
|
|
3100
3019
|
|
|
@@ -4079,6 +3998,41 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
4079
3998
|
get VertexBufferSemantic () { return VertexBufferSemantic; }
|
|
4080
3999
|
});
|
|
4081
4000
|
|
|
4001
|
+
function _array_like_to_array(arr, len) {
|
|
4002
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4003
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4004
|
+
return arr2;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
4008
|
+
if (!o) return;
|
|
4009
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
4010
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4011
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4012
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4013
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
4017
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
4018
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
4019
|
+
// Fallback for engines without symbol support
|
|
4020
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
4021
|
+
if (it) o = it;
|
|
4022
|
+
var i = 0;
|
|
4023
|
+
return function() {
|
|
4024
|
+
if (i >= o.length) return {
|
|
4025
|
+
done: true
|
|
4026
|
+
};
|
|
4027
|
+
return {
|
|
4028
|
+
done: false,
|
|
4029
|
+
value: o[i++]
|
|
4030
|
+
};
|
|
4031
|
+
};
|
|
4032
|
+
}
|
|
4033
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4082
4036
|
var decoratorInitialStore = new Map();
|
|
4083
4037
|
var mergedStore = new Map();
|
|
4084
4038
|
var effectsClassStore = {};
|
|
@@ -9903,6 +9857,8 @@ var TextureFactory = /*#__PURE__*/ function() {
|
|
|
9903
9857
|
internalFormat: textureData.internalFormat,
|
|
9904
9858
|
format: textureData.format,
|
|
9905
9859
|
mipmaps: textureData.mipmaps,
|
|
9860
|
+
minFilter: glContext.LINEAR,
|
|
9861
|
+
magFilter: glContext.LINEAR,
|
|
9906
9862
|
sourceFrom: sourceFrom
|
|
9907
9863
|
}, config)
|
|
9908
9864
|
];
|
|
@@ -10375,208 +10331,70 @@ var MaskProcessor = /*#__PURE__*/ function() {
|
|
|
10375
10331
|
return MaskProcessor;
|
|
10376
10332
|
}();
|
|
10377
10333
|
|
|
10378
|
-
exports.ShaderCompileResultStatus = void 0;
|
|
10379
|
-
(function(ShaderCompileResultStatus) {
|
|
10380
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10381
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10382
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10383
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10384
|
-
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10385
|
-
exports.GLSLVersion = void 0;
|
|
10386
|
-
(function(GLSLVersion) {
|
|
10387
|
-
GLSLVersion["GLSL1"] = "100";
|
|
10388
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
10389
|
-
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10390
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10391
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
10392
|
-
function ShaderVariant(engine, source) {
|
|
10393
|
-
var _this;
|
|
10394
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
10395
|
-
_this.source = source;
|
|
10396
|
-
return _this;
|
|
10397
|
-
}
|
|
10398
|
-
return ShaderVariant;
|
|
10399
|
-
}(EffectsObject);
|
|
10400
|
-
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10401
|
-
_inherits(Shader, EffectsObject);
|
|
10402
|
-
function Shader() {
|
|
10403
|
-
return EffectsObject.apply(this, arguments);
|
|
10404
|
-
}
|
|
10405
|
-
var _proto = Shader.prototype;
|
|
10406
|
-
_proto.createVariant = function createVariant(macros) {
|
|
10407
|
-
var shaderMacros = [];
|
|
10408
|
-
if (macros) {
|
|
10409
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10410
|
-
var key = _step.value;
|
|
10411
|
-
shaderMacros.push([
|
|
10412
|
-
key,
|
|
10413
|
-
macros[key]
|
|
10414
|
-
]);
|
|
10415
|
-
}
|
|
10416
|
-
}
|
|
10417
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10418
|
-
shaderVariant.shader = this;
|
|
10419
|
-
return shaderVariant;
|
|
10420
|
-
};
|
|
10421
|
-
_proto.fromData = function fromData(data) {
|
|
10422
|
-
EffectsObject.prototype.fromData.call(this, data);
|
|
10423
|
-
this.shaderData = data;
|
|
10424
|
-
};
|
|
10425
|
-
return Shader;
|
|
10426
|
-
}(EffectsObject);
|
|
10427
|
-
exports.Shader = __decorate([
|
|
10428
|
-
effectsClass(DataType.Shader)
|
|
10429
|
-
], exports.Shader);
|
|
10430
|
-
|
|
10431
10334
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10432
10335
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10433
10336
|
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}";
|
|
10434
10337
|
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";
|
|
10435
|
-
function createCopyShader(level, writeDepth) {
|
|
10436
|
-
var webgl2 = level === 2;
|
|
10437
|
-
return {
|
|
10438
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
10439
|
-
vertex: COPY_VERTEX_SHADER,
|
|
10440
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
10441
|
-
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
10442
|
-
macros: [
|
|
10443
|
-
[
|
|
10444
|
-
"DEPTH_TEXTURE",
|
|
10445
|
-
!!writeDepth
|
|
10446
|
-
]
|
|
10447
|
-
],
|
|
10448
|
-
// @ts-expect-error
|
|
10449
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
10450
|
-
};
|
|
10451
|
-
}
|
|
10452
10338
|
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
var _this = this;
|
|
10471
|
-
var width = request.width, height = request.height, name = request.name;
|
|
10472
|
-
var options = {
|
|
10473
|
-
sourceType: exports.TextureSourceType.framebuffer,
|
|
10474
|
-
data: {
|
|
10475
|
-
width: width,
|
|
10476
|
-
height: height
|
|
10477
|
-
},
|
|
10478
|
-
name: name
|
|
10479
|
-
};
|
|
10480
|
-
var keys = [
|
|
10481
|
-
name
|
|
10482
|
-
];
|
|
10483
|
-
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
10484
|
-
var _request_name;
|
|
10485
|
-
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
10486
|
-
options[name] = value;
|
|
10487
|
-
keys.push(name, value);
|
|
10488
|
-
});
|
|
10489
|
-
var cacheId = keys.join(":");
|
|
10490
|
-
var tex = this.textureCache[cacheId];
|
|
10491
|
-
if (tex) {
|
|
10492
|
-
this.textureRef[cacheId]++;
|
|
10493
|
-
} else {
|
|
10494
|
-
var engine = this.engine;
|
|
10495
|
-
assertExist(engine);
|
|
10496
|
-
tex = Texture.create(engine, options);
|
|
10497
|
-
this.textureCache[cacheId] = tex;
|
|
10498
|
-
this.textureRef[cacheId] = 1;
|
|
10499
|
-
// @ts-expect-error
|
|
10500
|
-
tex[disposeSymbol] = tex.dispose;
|
|
10501
|
-
tex.dispose = function() {
|
|
10502
|
-
return _this.removeTexture(cacheId);
|
|
10503
|
-
};
|
|
10504
|
-
}
|
|
10505
|
-
return tex;
|
|
10339
|
+
exports.FilterMode = void 0;
|
|
10340
|
+
(function(FilterMode) {
|
|
10341
|
+
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
10342
|
+
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
10343
|
+
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
10344
|
+
exports.RenderTextureFormat = void 0;
|
|
10345
|
+
(function(RenderTextureFormat) {
|
|
10346
|
+
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
10347
|
+
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
10348
|
+
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
10349
|
+
/**
|
|
10350
|
+
*
|
|
10351
|
+
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
10352
|
+
function Framebuffer() {}
|
|
10353
|
+
var _proto = Framebuffer.prototype;
|
|
10354
|
+
_proto.resize = function resize(x, y, width, height) {
|
|
10355
|
+
// OVERRIDE
|
|
10506
10356
|
};
|
|
10507
|
-
_proto.
|
|
10508
|
-
|
|
10509
|
-
if (refCount <= 1) {
|
|
10510
|
-
if (refCount < 0) {
|
|
10511
|
-
console.error("Ref count < 0.");
|
|
10512
|
-
}
|
|
10513
|
-
var tex = this.textureCache[id];
|
|
10514
|
-
if (tex) {
|
|
10515
|
-
// @ts-expect-error
|
|
10516
|
-
tex[disposeSymbol]();
|
|
10517
|
-
// @ts-expect-error
|
|
10518
|
-
tex.dispose = tex[disposeSymbol];
|
|
10519
|
-
}
|
|
10520
|
-
delete this.textureCache[id];
|
|
10521
|
-
delete this.textureRef[id];
|
|
10522
|
-
} else {
|
|
10523
|
-
this.textureRef[id] = refCount - 1;
|
|
10524
|
-
}
|
|
10357
|
+
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
10358
|
+
// OVERRIDE
|
|
10525
10359
|
};
|
|
10526
|
-
_proto.
|
|
10527
|
-
|
|
10528
|
-
Object.keys(this.textureCache).forEach(function(key) {
|
|
10529
|
-
var texture = _this.textureCache[key];
|
|
10530
|
-
// @ts-expect-error
|
|
10531
|
-
texture[disposeSymbol]();
|
|
10532
|
-
// @ts-expect-error
|
|
10533
|
-
texture.dispose = texture[disposeSymbol];
|
|
10534
|
-
});
|
|
10535
|
-
this.textureCache = {};
|
|
10536
|
-
this.textureRef = {};
|
|
10537
|
-
this.engine = undefined;
|
|
10360
|
+
_proto.unbind = function unbind() {
|
|
10361
|
+
// OVERRIDE
|
|
10538
10362
|
};
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
function _assert_this_initialized(self) {
|
|
10543
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10544
|
-
return self;
|
|
10545
|
-
}
|
|
10546
|
-
|
|
10547
|
-
var SemanticMap = /*#__PURE__*/ function() {
|
|
10548
|
-
function SemanticMap(semantics) {
|
|
10549
|
-
if (semantics === void 0) semantics = {};
|
|
10550
|
-
this.semantics = _extends({}, semantics);
|
|
10551
|
-
}
|
|
10552
|
-
var _proto = SemanticMap.prototype;
|
|
10553
|
-
_proto.toObject = function toObject() {
|
|
10554
|
-
return _extends({}, this.semantics);
|
|
10363
|
+
_proto.bind = function bind() {
|
|
10364
|
+
// OVERRIDE
|
|
10555
10365
|
};
|
|
10556
|
-
_proto.
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
} else {
|
|
10560
|
-
this.semantics[name] = value;
|
|
10561
|
-
}
|
|
10366
|
+
_proto.getDepthTexture = function getDepthTexture() {
|
|
10367
|
+
// OVERRIDE
|
|
10368
|
+
return undefined;
|
|
10562
10369
|
};
|
|
10563
|
-
_proto.
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
return ret(state);
|
|
10567
|
-
}
|
|
10568
|
-
return ret;
|
|
10370
|
+
_proto.getStencilTexture = function getStencilTexture() {
|
|
10371
|
+
// OVERRIDE
|
|
10372
|
+
return undefined;
|
|
10569
10373
|
};
|
|
10570
|
-
_proto.
|
|
10571
|
-
|
|
10374
|
+
_proto.getColorTextures = function getColorTextures() {
|
|
10375
|
+
// OVERRIDE
|
|
10376
|
+
return [];
|
|
10572
10377
|
};
|
|
10573
|
-
_proto.dispose = function dispose() {
|
|
10574
|
-
|
|
10575
|
-
Object.keys(this.semantics).forEach(function(name) {
|
|
10576
|
-
delete _this.semantics[name];
|
|
10577
|
-
});
|
|
10378
|
+
_proto.dispose = function dispose(options) {
|
|
10379
|
+
// OVERRIDE
|
|
10578
10380
|
};
|
|
10579
|
-
|
|
10381
|
+
_create_class(Framebuffer, [
|
|
10382
|
+
{
|
|
10383
|
+
key: "stencilStorage",
|
|
10384
|
+
get: function get() {
|
|
10385
|
+
// OVERRIDE
|
|
10386
|
+
return undefined;
|
|
10387
|
+
}
|
|
10388
|
+
},
|
|
10389
|
+
{
|
|
10390
|
+
key: "depthStorage",
|
|
10391
|
+
get: function get() {
|
|
10392
|
+
// OVERRIDE
|
|
10393
|
+
return undefined;
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
]);
|
|
10397
|
+
return Framebuffer;
|
|
10580
10398
|
}();
|
|
10581
10399
|
|
|
10582
10400
|
var RenderPassPriorityPrepare = 0;
|
|
@@ -10588,7 +10406,7 @@ exports.RenderPassAttachmentStorageType = void 0;
|
|
|
10588
10406
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
|
|
10589
10407
|
//stencil 8 render buffer
|
|
10590
10408
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
|
|
10591
|
-
//
|
|
10409
|
+
//depth 16 render buffer
|
|
10592
10410
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
|
|
10593
10411
|
//depth 16 & stencil 8 render buffer
|
|
10594
10412
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
|
|
@@ -10707,128 +10525,47 @@ var seed$8 = 1;
|
|
|
10707
10525
|
/**
|
|
10708
10526
|
* RenderPass 抽象类
|
|
10709
10527
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
10710
|
-
function RenderPass(renderer
|
|
10528
|
+
function RenderPass(renderer) {
|
|
10711
10529
|
/**
|
|
10712
|
-
*
|
|
10713
|
-
*/ this.
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10530
|
+
* 优先级
|
|
10531
|
+
*/ this.priority = 0;
|
|
10532
|
+
/**
|
|
10533
|
+
* 名称
|
|
10534
|
+
*/ this.name = "RenderPass" + seed$8++;
|
|
10535
|
+
/**
|
|
10536
|
+
* 包含的 Mesh 列表
|
|
10537
|
+
*/ this.meshes = [];
|
|
10538
|
+
this.disposed = false;
|
|
10539
|
+
this.framebuffer = null;
|
|
10718
10540
|
this.renderer = renderer;
|
|
10719
|
-
this.priority = priority;
|
|
10720
|
-
this.meshOrder = meshOrder;
|
|
10721
|
-
this.meshes = sortByOrder(meshes.slice(), this.meshOrder);
|
|
10722
|
-
this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
|
|
10723
|
-
this.clearAction = _extends({}, clearAction);
|
|
10724
|
-
this.storeAction = _extends({
|
|
10725
|
-
colorAction: 0,
|
|
10726
|
-
depthAction: 0,
|
|
10727
|
-
stencilAction: 0
|
|
10728
|
-
}, storeAction);
|
|
10729
|
-
this.semantics = new SemanticMap(semantics);
|
|
10730
|
-
this.options = options;
|
|
10731
|
-
this.delegate = delegate;
|
|
10732
10541
|
}
|
|
10733
10542
|
var _proto = RenderPass.prototype;
|
|
10734
10543
|
_proto.addMesh = function addMesh(mesh) {
|
|
10735
|
-
addByOrder(this.meshes, mesh
|
|
10544
|
+
addByOrder(this.meshes, mesh);
|
|
10736
10545
|
};
|
|
10737
10546
|
_proto.removeMesh = function removeMesh(mesh) {
|
|
10738
10547
|
removeItem(this.meshes, mesh);
|
|
10739
10548
|
};
|
|
10740
|
-
_proto.setMeshes = function setMeshes(meshes) {
|
|
10741
|
-
var _this_meshes;
|
|
10742
|
-
this.meshes.length = 0;
|
|
10743
|
-
(_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
|
|
10744
|
-
0,
|
|
10745
|
-
0
|
|
10746
|
-
], meshes));
|
|
10747
|
-
sortByOrder(this.meshes, this.meshOrder);
|
|
10748
|
-
return this.meshes;
|
|
10749
|
-
};
|
|
10750
|
-
// TODO 所有pass在子类配置
|
|
10751
10549
|
/**
|
|
10752
10550
|
* 配置当前pass的RT,在每帧渲染前调用
|
|
10753
10551
|
*/ _proto.configure = function configure(renderer) {
|
|
10754
|
-
|
|
10755
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
10756
|
-
} else {
|
|
10757
|
-
var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
|
|
10758
|
-
renderer.setViewport(x, y, width, height);
|
|
10759
|
-
}
|
|
10552
|
+
// OVERRIDE
|
|
10760
10553
|
};
|
|
10761
10554
|
/**
|
|
10762
10555
|
* 执行当前pass,每帧调用一次
|
|
10763
10556
|
*/ _proto.execute = function execute(renderer) {
|
|
10764
|
-
|
|
10765
|
-
renderer.renderMeshes(this.meshes);
|
|
10766
|
-
renderer.clear(this.storeAction);
|
|
10557
|
+
// OVERRIDE
|
|
10767
10558
|
};
|
|
10768
10559
|
/**
|
|
10769
|
-
* 每帧所有的pass
|
|
10770
|
-
*/ _proto.
|
|
10771
|
-
|
|
10772
|
-
var _this = this;
|
|
10773
|
-
var _options_attachments;
|
|
10774
|
-
var renderer = this.renderer;
|
|
10775
|
-
var options = this.options;
|
|
10776
|
-
if (this.attachments.length) {
|
|
10777
|
-
var _this_framebuffer;
|
|
10778
|
-
this.attachments.forEach(function(att) {
|
|
10779
|
-
return !att.externalTexture && att.dispose();
|
|
10780
|
-
});
|
|
10781
|
-
this.attachments.length = 0;
|
|
10782
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
|
|
10783
|
-
depthStencilAttachment: 2
|
|
10784
|
-
});
|
|
10785
|
-
this.framebuffer = null;
|
|
10786
|
-
}
|
|
10787
|
-
// renderpass 的 viewport 相关参数都需要动态的修改
|
|
10788
|
-
var viewport = [
|
|
10789
|
-
0,
|
|
10790
|
-
0,
|
|
10791
|
-
renderer.getWidth(),
|
|
10792
|
-
renderer.getHeight()
|
|
10793
|
-
];
|
|
10794
|
-
var size = [
|
|
10795
|
-
viewport[2],
|
|
10796
|
-
viewport[3]
|
|
10797
|
-
];
|
|
10798
|
-
var name = this.name;
|
|
10799
|
-
if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
|
|
10800
|
-
var attachments = options.attachments.map(function(attr, index) {
|
|
10801
|
-
var _attr_texture;
|
|
10802
|
-
var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
|
|
10803
|
-
size: size,
|
|
10804
|
-
name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
|
|
10805
|
-
}, attr));
|
|
10806
|
-
return attachment;
|
|
10807
|
-
});
|
|
10808
|
-
this.attachments = attachments;
|
|
10809
|
-
var framebuffer = Framebuffer.create({
|
|
10810
|
-
storeAction: this.storeAction,
|
|
10811
|
-
name: name,
|
|
10812
|
-
viewport: viewport,
|
|
10813
|
-
attachments: attachments.map(function(att) {
|
|
10814
|
-
return att.texture;
|
|
10815
|
-
}),
|
|
10816
|
-
depthStencilAttachment: options.depthStencilAttachment || {
|
|
10817
|
-
storageType: 0
|
|
10818
|
-
}
|
|
10819
|
-
}, renderer);
|
|
10820
|
-
framebuffer.bind();
|
|
10821
|
-
framebuffer.unbind();
|
|
10822
|
-
this.framebuffer = framebuffer;
|
|
10823
|
-
} else {
|
|
10824
|
-
this.attachments.length = 0;
|
|
10825
|
-
}
|
|
10560
|
+
* 每帧所有的pass渲染完后调用,用于清空临时的RT资源
|
|
10561
|
+
*/ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10562
|
+
// OVERRIDE
|
|
10826
10563
|
};
|
|
10827
10564
|
/**
|
|
10828
10565
|
* 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
|
|
10829
10566
|
*/ _proto.getViewport = function getViewport() {
|
|
10830
10567
|
var _this_framebuffer;
|
|
10831
|
-
var ret = (
|
|
10568
|
+
var ret = (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.viewport;
|
|
10832
10569
|
if (ret) {
|
|
10833
10570
|
return ret;
|
|
10834
10571
|
}
|
|
@@ -10846,72 +10583,10 @@ var seed$8 = 1;
|
|
|
10846
10583
|
];
|
|
10847
10584
|
};
|
|
10848
10585
|
/**
|
|
10849
|
-
* 获取深度 Attachment,可能没有
|
|
10850
|
-
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
10851
|
-
var framebuffer = this.framebuffer;
|
|
10852
|
-
if (framebuffer) {
|
|
10853
|
-
var depthTexture = framebuffer.getDepthTexture();
|
|
10854
|
-
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
10855
|
-
return {
|
|
10856
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10857
|
-
storage: framebuffer.depthStorage,
|
|
10858
|
-
texture: texture
|
|
10859
|
-
};
|
|
10860
|
-
}
|
|
10861
|
-
};
|
|
10862
|
-
/**
|
|
10863
|
-
* 获取蒙版 Attachment,可能没有
|
|
10864
|
-
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
10865
|
-
var framebuffer = this.framebuffer;
|
|
10866
|
-
if (framebuffer) {
|
|
10867
|
-
var stencilTexture = framebuffer.getStencilTexture();
|
|
10868
|
-
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
10869
|
-
return {
|
|
10870
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10871
|
-
storage: framebuffer.stencilStorage,
|
|
10872
|
-
texture: texture
|
|
10873
|
-
};
|
|
10874
|
-
}
|
|
10875
|
-
};
|
|
10876
|
-
_proto.getDepthTexture = function getDepthTexture(texture, external) {
|
|
10877
|
-
if (!this.depthTexture) {
|
|
10878
|
-
var _this_options_depthStencilAttachment;
|
|
10879
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10880
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10881
|
-
// TODO 为什么要initialize?
|
|
10882
|
-
//tex.initialize(this.renderer.engine);
|
|
10883
|
-
if (!external) {
|
|
10884
|
-
this.depthTexture = tex;
|
|
10885
|
-
}
|
|
10886
|
-
return tex;
|
|
10887
|
-
}
|
|
10888
|
-
return this.depthTexture;
|
|
10889
|
-
};
|
|
10890
|
-
_proto.getStencilTexture = function getStencilTexture(texture, external) {
|
|
10891
|
-
if (!this.stencilTexture) {
|
|
10892
|
-
var _this_options_depthStencilAttachment;
|
|
10893
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10894
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10895
|
-
if (!external) {
|
|
10896
|
-
this.stencilTexture = tex;
|
|
10897
|
-
}
|
|
10898
|
-
return tex;
|
|
10899
|
-
}
|
|
10900
|
-
return this.stencilTexture;
|
|
10901
|
-
};
|
|
10902
|
-
// 生成并初始化帧缓冲
|
|
10903
|
-
_proto.initialize = function initialize(renderer) {
|
|
10904
|
-
if (!this.initialized) {
|
|
10905
|
-
this._resetAttachments();
|
|
10906
|
-
this.initialized = true;
|
|
10907
|
-
}
|
|
10908
|
-
return this;
|
|
10909
|
-
};
|
|
10910
|
-
/**
|
|
10911
10586
|
* 销毁 RenderPass
|
|
10912
10587
|
* @param options - 有选择销毁内部对象
|
|
10913
10588
|
*/ _proto.dispose = function dispose(options) {
|
|
10914
|
-
if (this.
|
|
10589
|
+
if (this.disposed) {
|
|
10915
10590
|
return;
|
|
10916
10591
|
}
|
|
10917
10592
|
var destroyMeshOption = (options == null ? void 0 : options.meshes) || undefined;
|
|
@@ -10921,40 +10596,13 @@ var seed$8 = 1;
|
|
|
10921
10596
|
});
|
|
10922
10597
|
}
|
|
10923
10598
|
this.meshes.length = 0;
|
|
10924
|
-
|
|
10925
|
-
this.attachments.forEach(function(att) {
|
|
10926
|
-
var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
|
|
10927
|
-
if (!keep) {
|
|
10928
|
-
att.dispose();
|
|
10929
|
-
}
|
|
10930
|
-
});
|
|
10931
|
-
this.attachments.length = 0;
|
|
10932
|
-
if ((options == null ? void 0 : options.semantics) !== exports.DestroyOptions.keep) {
|
|
10933
|
-
this.semantics.dispose();
|
|
10934
|
-
}
|
|
10935
|
-
this.destroyed = true;
|
|
10936
|
-
var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
|
|
10937
|
-
var fbo = this.framebuffer;
|
|
10938
|
-
if (fbo) {
|
|
10939
|
-
fbo.dispose({
|
|
10940
|
-
depthStencilAttachment: depthStencilOpt
|
|
10941
|
-
});
|
|
10942
|
-
var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
|
|
10943
|
-
if (!keep) {
|
|
10944
|
-
var _this_stencilTexture, _this_depthTexture;
|
|
10945
|
-
(_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
|
|
10946
|
-
(_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
|
|
10947
|
-
}
|
|
10948
|
-
}
|
|
10949
|
-
// @ts-expect-error safe to assign
|
|
10950
|
-
this.options = null;
|
|
10951
|
-
this.initialize = throwDestroyedError;
|
|
10599
|
+
this.disposed = true;
|
|
10952
10600
|
};
|
|
10953
10601
|
_create_class(RenderPass, [
|
|
10954
10602
|
{
|
|
10955
|
-
key: "
|
|
10603
|
+
key: "isDisposed",
|
|
10956
10604
|
get: function get() {
|
|
10957
|
-
return this.
|
|
10605
|
+
return this.disposed;
|
|
10958
10606
|
}
|
|
10959
10607
|
},
|
|
10960
10608
|
{
|
|
@@ -10962,18 +10610,6 @@ var seed$8 = 1;
|
|
|
10962
10610
|
get: function get() {
|
|
10963
10611
|
return this.getViewport();
|
|
10964
10612
|
}
|
|
10965
|
-
},
|
|
10966
|
-
{
|
|
10967
|
-
key: "stencilAttachment",
|
|
10968
|
-
get: function get() {
|
|
10969
|
-
return this.getStencilAttachment();
|
|
10970
|
-
}
|
|
10971
|
-
},
|
|
10972
|
-
{
|
|
10973
|
-
key: "depthAttachment",
|
|
10974
|
-
get: function get() {
|
|
10975
|
-
return this.getDepthAttachment();
|
|
10976
|
-
}
|
|
10977
10613
|
}
|
|
10978
10614
|
]);
|
|
10979
10615
|
return RenderPass;
|
|
@@ -10981,27 +10617,95 @@ var seed$8 = 1;
|
|
|
10981
10617
|
|
|
10982
10618
|
var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
10983
10619
|
_inherits(DrawObjectPass, RenderPass);
|
|
10984
|
-
function DrawObjectPass(renderer
|
|
10620
|
+
function DrawObjectPass(renderer) {
|
|
10985
10621
|
var _this;
|
|
10986
|
-
_this = RenderPass.call(this, renderer
|
|
10987
|
-
_this.
|
|
10988
|
-
_this.
|
|
10622
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
10623
|
+
_this.useRenderTarget = false;
|
|
10624
|
+
_this.priority = RenderPassPriorityNormal;
|
|
10625
|
+
_this.name = "DrawObjectPass";
|
|
10989
10626
|
return _this;
|
|
10990
10627
|
}
|
|
10991
10628
|
var _proto = DrawObjectPass.prototype;
|
|
10992
|
-
_proto.
|
|
10993
|
-
|
|
10994
|
-
var width = this.renderer.getWidth();
|
|
10995
|
-
var height = this.renderer.getHeight();
|
|
10996
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
10629
|
+
_proto.setup = function setup(useRenderTarget) {
|
|
10630
|
+
this.useRenderTarget = useRenderTarget;
|
|
10997
10631
|
};
|
|
10998
|
-
_proto.
|
|
10999
|
-
|
|
11000
|
-
|
|
10632
|
+
_proto.configure = function configure(renderer) {
|
|
10633
|
+
if (this.useRenderTarget) {
|
|
10634
|
+
this.framebuffer = renderer.getTemporaryRT("DrawObjectPass", renderer.getWidth(), renderer.getHeight(), 16, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
10635
|
+
renderer.setFramebuffer(this.framebuffer);
|
|
10636
|
+
}
|
|
10637
|
+
};
|
|
10638
|
+
_proto.execute = function execute(renderer) {
|
|
10639
|
+
if (this.useRenderTarget) {
|
|
10640
|
+
renderer.clear({
|
|
10641
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
10642
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
10643
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
10644
|
+
});
|
|
10645
|
+
}
|
|
10646
|
+
renderer.renderMeshes(this.meshes);
|
|
10647
|
+
};
|
|
10648
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10649
|
+
if (this.useRenderTarget && this.framebuffer) {
|
|
10650
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
10651
|
+
}
|
|
11001
10652
|
};
|
|
11002
10653
|
return DrawObjectPass;
|
|
11003
10654
|
}(RenderPass);
|
|
11004
10655
|
|
|
10656
|
+
exports.ShaderCompileResultStatus = void 0;
|
|
10657
|
+
(function(ShaderCompileResultStatus) {
|
|
10658
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10659
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10660
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10661
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10662
|
+
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10663
|
+
exports.GLSLVersion = void 0;
|
|
10664
|
+
(function(GLSLVersion) {
|
|
10665
|
+
GLSLVersion["GLSL1"] = "100";
|
|
10666
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
10667
|
+
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10668
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10669
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
10670
|
+
function ShaderVariant(engine, source) {
|
|
10671
|
+
var _this;
|
|
10672
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
10673
|
+
_this.source = source;
|
|
10674
|
+
return _this;
|
|
10675
|
+
}
|
|
10676
|
+
return ShaderVariant;
|
|
10677
|
+
}(EffectsObject);
|
|
10678
|
+
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10679
|
+
_inherits(Shader, EffectsObject);
|
|
10680
|
+
function Shader() {
|
|
10681
|
+
return EffectsObject.apply(this, arguments);
|
|
10682
|
+
}
|
|
10683
|
+
var _proto = Shader.prototype;
|
|
10684
|
+
_proto.createVariant = function createVariant(macros) {
|
|
10685
|
+
var shaderMacros = [];
|
|
10686
|
+
if (macros) {
|
|
10687
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10688
|
+
var key = _step.value;
|
|
10689
|
+
shaderMacros.push([
|
|
10690
|
+
key,
|
|
10691
|
+
macros[key]
|
|
10692
|
+
]);
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10696
|
+
shaderVariant.shader = this;
|
|
10697
|
+
return shaderVariant;
|
|
10698
|
+
};
|
|
10699
|
+
_proto.fromData = function fromData(data) {
|
|
10700
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
10701
|
+
this.shaderData = data;
|
|
10702
|
+
};
|
|
10703
|
+
return Shader;
|
|
10704
|
+
}(EffectsObject);
|
|
10705
|
+
exports.Shader = __decorate([
|
|
10706
|
+
effectsClass(DataType.Shader)
|
|
10707
|
+
], exports.Shader);
|
|
10708
|
+
|
|
11005
10709
|
var _obj$6;
|
|
11006
10710
|
var BYTES_TYPE_MAP = (_obj$6 = {}, _obj$6[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT, _obj$6[glContext.INT] = Int32Array.BYTES_PER_ELEMENT, _obj$6[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT, _obj$6[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT, _obj$6);
|
|
11007
10711
|
/**
|
|
@@ -13043,9 +12747,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
13043
12747
|
// Bloom 阈值 Pass
|
|
13044
12748
|
var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
13045
12749
|
_inherits(BloomThresholdPass, RenderPass);
|
|
13046
|
-
function BloomThresholdPass(renderer
|
|
12750
|
+
function BloomThresholdPass(renderer) {
|
|
13047
12751
|
var _this;
|
|
13048
|
-
_this = RenderPass.call(this, renderer
|
|
12752
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13049
12753
|
var engine = _this.renderer.engine;
|
|
13050
12754
|
var geometry = Geometry.create(engine, {
|
|
13051
12755
|
mode: glContext.TRIANGLE_STRIP,
|
|
@@ -13083,12 +12787,12 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13083
12787
|
priority: 0
|
|
13084
12788
|
});
|
|
13085
12789
|
_this.priority = 5000;
|
|
13086
|
-
_this.
|
|
13087
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12790
|
+
_this.name = "BloomThresholdPass";
|
|
13088
12791
|
return _this;
|
|
13089
12792
|
}
|
|
13090
12793
|
var _proto = BloomThresholdPass.prototype;
|
|
13091
12794
|
_proto.configure = function configure(renderer) {
|
|
12795
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, renderer.getWidth(), renderer.getHeight(), 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13092
12796
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13093
12797
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
13094
12798
|
renderer.setFramebuffer(this.framebuffer);
|
|
@@ -13096,9 +12800,9 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13096
12800
|
_proto.execute = function execute(renderer) {
|
|
13097
12801
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
13098
12802
|
renderer.clear({
|
|
13099
|
-
colorAction: exports.
|
|
13100
|
-
depthAction: exports.
|
|
13101
|
-
stencilAction: exports.
|
|
12803
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12804
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12805
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13102
12806
|
});
|
|
13103
12807
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13104
12808
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
@@ -13108,23 +12812,21 @@ var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13108
12812
|
this.screenMesh
|
|
13109
12813
|
]);
|
|
13110
12814
|
};
|
|
13111
|
-
_proto.
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
12815
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12816
|
+
if (this.framebuffer) {
|
|
12817
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12818
|
+
}
|
|
13116
12819
|
};
|
|
13117
12820
|
_proto.dispose = function dispose(options) {
|
|
13118
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13119
12821
|
RenderPass.prototype.dispose.call(this, options);
|
|
13120
12822
|
};
|
|
13121
12823
|
return BloomThresholdPass;
|
|
13122
12824
|
}(RenderPass);
|
|
13123
12825
|
var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13124
12826
|
_inherits(HQGaussianDownSamplePass, RenderPass);
|
|
13125
|
-
function HQGaussianDownSamplePass(renderer, type, level
|
|
12827
|
+
function HQGaussianDownSamplePass(renderer, type, level) {
|
|
13126
12828
|
var _this;
|
|
13127
|
-
_this = RenderPass.call(this, renderer
|
|
12829
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13128
12830
|
_this.type = type;
|
|
13129
12831
|
_this.level = level;
|
|
13130
12832
|
var engine = _this.renderer.engine;
|
|
@@ -13170,25 +12872,22 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13170
12872
|
priority: 0
|
|
13171
12873
|
});
|
|
13172
12874
|
_this.priority = 5000;
|
|
13173
|
-
_this.
|
|
13174
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12875
|
+
_this.name = "GaussianDownPass" + type + level;
|
|
13175
12876
|
return _this;
|
|
13176
12877
|
}
|
|
13177
12878
|
var _proto = HQGaussianDownSamplePass.prototype;
|
|
13178
|
-
_proto.initialize = function initialize(renderer) {
|
|
13179
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13180
|
-
this.onResize();
|
|
13181
|
-
return this;
|
|
13182
|
-
};
|
|
13183
12879
|
_proto.configure = function configure(renderer) {
|
|
12880
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
|
|
12881
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
|
|
12882
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13184
12883
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13185
12884
|
renderer.setFramebuffer(this.framebuffer);
|
|
13186
12885
|
};
|
|
13187
12886
|
_proto.execute = function execute(renderer) {
|
|
13188
12887
|
renderer.clear({
|
|
13189
|
-
colorAction: exports.
|
|
13190
|
-
depthAction: exports.
|
|
13191
|
-
stencilAction: exports.
|
|
12888
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12889
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12890
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13192
12891
|
});
|
|
13193
12892
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13194
12893
|
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
@@ -13199,23 +12898,18 @@ var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13199
12898
|
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13200
12899
|
}
|
|
13201
12900
|
};
|
|
13202
|
-
_proto.
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13207
|
-
};
|
|
13208
|
-
_proto.dispose = function dispose(options) {
|
|
13209
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13210
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12901
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12902
|
+
if (this.framebuffer) {
|
|
12903
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12904
|
+
}
|
|
13211
12905
|
};
|
|
13212
12906
|
return HQGaussianDownSamplePass;
|
|
13213
12907
|
}(RenderPass);
|
|
13214
12908
|
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13215
12909
|
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
13216
|
-
function HQGaussianUpSamplePass(renderer, level
|
|
12910
|
+
function HQGaussianUpSamplePass(renderer, level) {
|
|
13217
12911
|
var _this;
|
|
13218
|
-
_this = RenderPass.call(this, renderer
|
|
12912
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13219
12913
|
_this.level = level;
|
|
13220
12914
|
var name = "PostProcess";
|
|
13221
12915
|
var engine = _this.renderer.engine;
|
|
@@ -13258,25 +12952,22 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13258
12952
|
priority: 0
|
|
13259
12953
|
});
|
|
13260
12954
|
_this.priority = 5000;
|
|
13261
|
-
_this.
|
|
13262
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12955
|
+
_this.name = "GaussianUpPass" + level;
|
|
13263
12956
|
return _this;
|
|
13264
12957
|
}
|
|
13265
12958
|
var _proto = HQGaussianUpSamplePass.prototype;
|
|
13266
|
-
_proto.initialize = function initialize(renderer) {
|
|
13267
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13268
|
-
this.onResize();
|
|
13269
|
-
return this;
|
|
13270
|
-
};
|
|
13271
12959
|
_proto.configure = function configure(renderer) {
|
|
12960
|
+
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
|
|
12961
|
+
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
|
|
12962
|
+
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
13272
12963
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13273
12964
|
renderer.setFramebuffer(this.framebuffer);
|
|
13274
12965
|
};
|
|
13275
12966
|
_proto.execute = function execute(renderer) {
|
|
13276
12967
|
renderer.clear({
|
|
13277
|
-
colorAction: exports.
|
|
13278
|
-
depthAction: exports.
|
|
13279
|
-
stencilAction: exports.
|
|
12968
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12969
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12970
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13280
12971
|
});
|
|
13281
12972
|
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13282
12973
|
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
@@ -13285,15 +12976,10 @@ var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13285
12976
|
this.screenMesh
|
|
13286
12977
|
]);
|
|
13287
12978
|
};
|
|
13288
|
-
_proto.
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13293
|
-
};
|
|
13294
|
-
_proto.dispose = function dispose(options) {
|
|
13295
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13296
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
12979
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12980
|
+
if (this.framebuffer) {
|
|
12981
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12982
|
+
}
|
|
13297
12983
|
};
|
|
13298
12984
|
return HQGaussianUpSamplePass;
|
|
13299
12985
|
}(RenderPass);
|
|
@@ -13302,7 +12988,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13302
12988
|
_inherits(ToneMappingPass, RenderPass);
|
|
13303
12989
|
function ToneMappingPass(renderer, sceneTextureHandle) {
|
|
13304
12990
|
var _this;
|
|
13305
|
-
_this = RenderPass.call(this, renderer
|
|
12991
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13306
12992
|
var name = "PostProcess";
|
|
13307
12993
|
var engine = _this.renderer.engine;
|
|
13308
12994
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
@@ -13345,6 +13031,7 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13345
13031
|
priority: 0
|
|
13346
13032
|
});
|
|
13347
13033
|
_this.priority = 5000;
|
|
13034
|
+
_this.name = "ToneMappingPass";
|
|
13348
13035
|
return _this;
|
|
13349
13036
|
}
|
|
13350
13037
|
var _proto = ToneMappingPass.prototype;
|
|
@@ -13357,9 +13044,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13357
13044
|
};
|
|
13358
13045
|
_proto.execute = function execute(renderer) {
|
|
13359
13046
|
renderer.clear({
|
|
13360
|
-
colorAction: exports.
|
|
13361
|
-
depthAction: exports.
|
|
13362
|
-
stencilAction: exports.
|
|
13047
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
13048
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
13049
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13363
13050
|
});
|
|
13364
13051
|
var globalVolume = renderer.renderingData.currentFrame.globalVolume;
|
|
13365
13052
|
var bloom = _extends({
|
|
@@ -13406,70 +13093,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13406
13093
|
return ToneMappingPass;
|
|
13407
13094
|
}(RenderPass);
|
|
13408
13095
|
|
|
13409
|
-
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
13410
13096
|
var seed$6 = 1;
|
|
13411
13097
|
/**
|
|
13412
13098
|
* RenderFrame 抽象类
|
|
13413
13099
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
13414
13100
|
function RenderFrame(options) {
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
this.
|
|
13418
|
-
|
|
13419
|
-
this.renderPassInfoMap = new WeakMap();
|
|
13420
|
-
var camera = options.camera, keepColorBuffer = options.keepColorBuffer, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13101
|
+
this.disposed = false;
|
|
13102
|
+
this.postProcessingEnabled = false;
|
|
13103
|
+
this.enableHDR = true;
|
|
13104
|
+
var camera = options.camera, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13421
13105
|
1,
|
|
13422
13106
|
1,
|
|
13423
13107
|
0,
|
|
13424
13108
|
0
|
|
13425
|
-
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled
|
|
13426
|
-
colorAction: exports.TextureLoadAction.whatever,
|
|
13427
|
-
stencilAction: exports.TextureLoadAction.clear,
|
|
13428
|
-
depthAction: exports.TextureLoadAction.whatever
|
|
13429
|
-
} : _options_clearAction;
|
|
13109
|
+
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
|
|
13430
13110
|
var engine = renderer.engine;
|
|
13431
13111
|
if (globalVolume) {
|
|
13432
13112
|
this.globalVolume = globalVolume;
|
|
13433
13113
|
}
|
|
13114
|
+
this.postProcessingEnabled = postProcessingEnabled;
|
|
13434
13115
|
this.globalUniforms = new GlobalUniforms();
|
|
13435
|
-
var attachments = []; //渲染场景物体Pass的RT
|
|
13436
|
-
var depthStencilAttachment;
|
|
13437
|
-
var drawObjectPassClearAction = {};
|
|
13438
13116
|
this.renderer = renderer;
|
|
13439
|
-
if (postProcessingEnabled) {
|
|
13440
|
-
|
|
13441
|
-
if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13442
|
-
throw new Error("Half float texture is not supported.");
|
|
13443
|
-
}
|
|
13444
|
-
// 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
|
|
13445
|
-
var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13446
|
-
attachments = [
|
|
13447
|
-
{
|
|
13448
|
-
texture: {
|
|
13449
|
-
format: glContext.RGBA,
|
|
13450
|
-
type: textureType,
|
|
13451
|
-
magFilter: glContext.LINEAR,
|
|
13452
|
-
minFilter: glContext.LINEAR
|
|
13453
|
-
}
|
|
13454
|
-
}
|
|
13455
|
-
];
|
|
13456
|
-
depthStencilAttachment = {
|
|
13457
|
-
storageType: exports.RenderPassAttachmentStorageType.depth_stencil_opaque
|
|
13458
|
-
};
|
|
13459
|
-
drawObjectPassClearAction = {
|
|
13460
|
-
colorAction: exports.TextureLoadAction.clear,
|
|
13461
|
-
stencilAction: exports.TextureLoadAction.clear,
|
|
13462
|
-
depthAction: exports.TextureLoadAction.clear
|
|
13463
|
-
};
|
|
13117
|
+
if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13118
|
+
throw new Error("Half float texture is not supported.");
|
|
13464
13119
|
}
|
|
13465
|
-
this.drawObjectPass = new DrawObjectPass(renderer
|
|
13466
|
-
name: RENDER_PASS_NAME_PREFIX,
|
|
13467
|
-
priority: RenderPassPriorityNormal,
|
|
13468
|
-
meshOrder: exports.OrderType.ascending,
|
|
13469
|
-
depthStencilAttachment: depthStencilAttachment,
|
|
13470
|
-
attachments: attachments,
|
|
13471
|
-
clearAction: drawObjectPassClearAction
|
|
13472
|
-
});
|
|
13120
|
+
this.drawObjectPass = new DrawObjectPass(renderer);
|
|
13473
13121
|
var renderPasses = [
|
|
13474
13122
|
this.drawObjectPass
|
|
13475
13123
|
];
|
|
@@ -13484,51 +13132,13 @@ var seed$6 = 1;
|
|
|
13484
13132
|
this.renderer.getHeight() / 2
|
|
13485
13133
|
];
|
|
13486
13134
|
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13487
|
-
var
|
|
13488
|
-
var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13489
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer, {
|
|
13490
|
-
name: "BloomThresholdPass",
|
|
13491
|
-
attachments: [
|
|
13492
|
-
{
|
|
13493
|
-
texture: {
|
|
13494
|
-
format: glContext.RGBA,
|
|
13495
|
-
type: textureType1,
|
|
13496
|
-
minFilter: glContext.LINEAR,
|
|
13497
|
-
magFilter: glContext.LINEAR
|
|
13498
|
-
}
|
|
13499
|
-
}
|
|
13500
|
-
]
|
|
13501
|
-
});
|
|
13135
|
+
var bloomThresholdPass = new BloomThresholdPass(renderer);
|
|
13502
13136
|
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13503
13137
|
this.addRenderPass(bloomThresholdPass);
|
|
13504
13138
|
for(var i = 0; i < gaussianStep; i++){
|
|
13505
13139
|
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13506
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i
|
|
13507
|
-
|
|
13508
|
-
attachments: [
|
|
13509
|
-
{
|
|
13510
|
-
texture: {
|
|
13511
|
-
format: glContext.RGBA,
|
|
13512
|
-
type: textureType1,
|
|
13513
|
-
minFilter: glContext.LINEAR,
|
|
13514
|
-
magFilter: glContext.LINEAR
|
|
13515
|
-
}
|
|
13516
|
-
}
|
|
13517
|
-
]
|
|
13518
|
-
});
|
|
13519
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
|
|
13520
|
-
name: "GaussianDownPassV" + i,
|
|
13521
|
-
attachments: [
|
|
13522
|
-
{
|
|
13523
|
-
texture: {
|
|
13524
|
-
format: glContext.RGBA,
|
|
13525
|
-
type: textureType1,
|
|
13526
|
-
minFilter: glContext.LINEAR,
|
|
13527
|
-
magFilter: glContext.LINEAR
|
|
13528
|
-
}
|
|
13529
|
-
}
|
|
13530
|
-
]
|
|
13531
|
-
});
|
|
13140
|
+
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i);
|
|
13141
|
+
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i);
|
|
13532
13142
|
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13533
13143
|
this.addRenderPass(gaussianDownHPass);
|
|
13534
13144
|
this.addRenderPass(gaussianDownVPass);
|
|
@@ -13539,19 +13149,7 @@ var seed$6 = 1;
|
|
|
13539
13149
|
viewport[2] *= 4;
|
|
13540
13150
|
viewport[3] *= 4;
|
|
13541
13151
|
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13542
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1
|
|
13543
|
-
name: "GaussianUpPass" + i1,
|
|
13544
|
-
attachments: [
|
|
13545
|
-
{
|
|
13546
|
-
texture: {
|
|
13547
|
-
format: glContext.RGBA,
|
|
13548
|
-
type: textureType1,
|
|
13549
|
-
minFilter: glContext.LINEAR,
|
|
13550
|
-
magFilter: glContext.LINEAR
|
|
13551
|
-
}
|
|
13552
|
-
}
|
|
13553
|
-
]
|
|
13554
|
-
});
|
|
13152
|
+
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1);
|
|
13555
13153
|
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13556
13154
|
this.addRenderPass(gaussianUpPass);
|
|
13557
13155
|
viewport[2] *= 2;
|
|
@@ -13560,31 +13158,17 @@ var seed$6 = 1;
|
|
|
13560
13158
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13561
13159
|
this.addRenderPass(postProcessPass);
|
|
13562
13160
|
}
|
|
13563
|
-
this.semantics = new SemanticMap(options.semantics);
|
|
13564
|
-
this.clearAction = clearAction;
|
|
13565
13161
|
this.name = "RenderFrame" + seed$6++;
|
|
13566
|
-
var firstRP = renderPasses[0];
|
|
13567
13162
|
this.camera = camera;
|
|
13568
|
-
this.keepColorBuffer = keepColorBuffer;
|
|
13569
|
-
this.renderPassInfoMap.set(firstRP, {
|
|
13570
|
-
listStart: 0,
|
|
13571
|
-
listEnd: 0,
|
|
13572
|
-
renderPass: firstRP,
|
|
13573
|
-
intermedia: false
|
|
13574
|
-
});
|
|
13575
13163
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
13576
|
-
if (!options.clearAction) {
|
|
13577
|
-
this.resetClearActions();
|
|
13578
|
-
}
|
|
13579
|
-
this.passTextureCache = new PassTextureCache(engine);
|
|
13580
|
-
// FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
|
|
13581
|
-
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
13582
|
-
var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
|
|
13583
|
-
var shader = createCopyShader(level, writeDepth);
|
|
13584
|
-
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
13585
13164
|
}
|
|
13586
13165
|
var _proto = RenderFrame.prototype;
|
|
13587
13166
|
/**
|
|
13167
|
+
* 设置 RenderPasses 参数,此函数每帧调用一次
|
|
13168
|
+
*/ _proto.setup = function setup() {
|
|
13169
|
+
this.drawObjectPass.setup(this.postProcessingEnabled);
|
|
13170
|
+
};
|
|
13171
|
+
/**
|
|
13588
13172
|
* 根据 Mesh 优先级添加到 RenderPass
|
|
13589
13173
|
* @param mesh - 要添加的 Mesh 对象
|
|
13590
13174
|
*/ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
|
|
@@ -13601,78 +13185,25 @@ var seed$6 = 1;
|
|
|
13601
13185
|
* 销毁 RenderFrame
|
|
13602
13186
|
* @param options - 可以有选择销毁一些对象
|
|
13603
13187
|
*/ _proto.dispose = function dispose(options) {
|
|
13604
|
-
if ((options == null ? void 0 : options.semantics) !== exports.DestroyOptions.keep) {
|
|
13605
|
-
this.semantics.dispose();
|
|
13606
|
-
}
|
|
13607
13188
|
var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
|
|
13608
13189
|
if (pass !== exports.DestroyOptions.keep) {
|
|
13609
13190
|
this._renderPasses.forEach(function(renderPass) {
|
|
13610
13191
|
renderPass.dispose(pass);
|
|
13611
13192
|
});
|
|
13612
13193
|
}
|
|
13613
|
-
this.passTextureCache.dispose();
|
|
13614
13194
|
this._renderPasses.length = 0;
|
|
13615
|
-
this.
|
|
13616
|
-
};
|
|
13617
|
-
/**
|
|
13618
|
-
* 查找 Mesh 所在的 RenderPass 索引,没找到是-1
|
|
13619
|
-
* @param mesh - 需要查找的 Mesh
|
|
13620
|
-
*/ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
|
|
13621
|
-
var index = -1;
|
|
13622
|
-
this.renderPasses.every(function(rp, idx) {
|
|
13623
|
-
if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
|
|
13624
|
-
index = idx;
|
|
13625
|
-
return false;
|
|
13626
|
-
}
|
|
13627
|
-
return true;
|
|
13628
|
-
});
|
|
13629
|
-
return index;
|
|
13630
|
-
};
|
|
13631
|
-
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
13632
|
-
var info = this.renderPassInfoMap.get(renderPass);
|
|
13633
|
-
var priority = mesh.priority;
|
|
13634
|
-
if (!info) {
|
|
13635
|
-
return;
|
|
13636
|
-
}
|
|
13637
|
-
if (renderPass.meshes.length === 0) {
|
|
13638
|
-
info.listStart = info.listEnd = priority;
|
|
13639
|
-
} else {
|
|
13640
|
-
if (priority < info.listStart) {
|
|
13641
|
-
info.listStart = priority;
|
|
13642
|
-
} else if (priority > info.listEnd) {
|
|
13643
|
-
info.listEnd = priority;
|
|
13644
|
-
}
|
|
13645
|
-
}
|
|
13646
|
-
renderPass.addMesh(mesh);
|
|
13647
|
-
};
|
|
13648
|
-
_proto.resetClearActions = function resetClearActions() {
|
|
13649
|
-
var action = this.renderPasses.length > 1 ? exports.TextureLoadAction.clear : exports.TextureLoadAction.whatever;
|
|
13650
|
-
this.clearAction.stencilAction = action;
|
|
13651
|
-
this.clearAction.depthAction = action;
|
|
13652
|
-
this.clearAction.colorAction = action;
|
|
13653
|
-
if (this.keepColorBuffer) {
|
|
13654
|
-
this.clearAction.colorAction = exports.TextureLoadAction.whatever;
|
|
13655
|
-
}
|
|
13195
|
+
this.disposed = true;
|
|
13656
13196
|
};
|
|
13657
13197
|
/**
|
|
13658
13198
|
* 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
|
|
13659
13199
|
* @param passes - RenderPass 数组
|
|
13660
13200
|
*/ _proto.setRenderPasses = function setRenderPasses(passes) {
|
|
13661
|
-
var _this = this;
|
|
13662
|
-
if (this.renderer !== undefined) {
|
|
13663
|
-
passes.forEach(function(pass) {
|
|
13664
|
-
return pass.initialize(_this.renderer);
|
|
13665
|
-
});
|
|
13666
|
-
}
|
|
13667
13201
|
this._renderPasses = passes.slice();
|
|
13668
13202
|
};
|
|
13669
13203
|
/**
|
|
13670
13204
|
* 添加 RenderPass
|
|
13671
13205
|
* @param pass - 需要添加的 RenderPass
|
|
13672
13206
|
*/ _proto.addRenderPass = function addRenderPass(pass) {
|
|
13673
|
-
if (this.renderer !== undefined) {
|
|
13674
|
-
pass.initialize(this.renderer);
|
|
13675
|
-
}
|
|
13676
13207
|
this._renderPasses.push(pass);
|
|
13677
13208
|
};
|
|
13678
13209
|
/**
|
|
@@ -13689,9 +13220,9 @@ var seed$6 = 1;
|
|
|
13689
13220
|
}
|
|
13690
13221
|
},
|
|
13691
13222
|
{
|
|
13692
|
-
key: "
|
|
13223
|
+
key: "isDisposed",
|
|
13693
13224
|
get: function get() {
|
|
13694
|
-
return this.
|
|
13225
|
+
return this.disposed;
|
|
13695
13226
|
}
|
|
13696
13227
|
}
|
|
13697
13228
|
]);
|
|
@@ -13700,10 +13231,6 @@ var seed$6 = 1;
|
|
|
13700
13231
|
function getTextureSize(tex) {
|
|
13701
13232
|
return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
|
|
13702
13233
|
}
|
|
13703
|
-
function findPreviousRenderPass(renderPasses, renderPass) {
|
|
13704
|
-
var index = renderPasses.indexOf(renderPass);
|
|
13705
|
-
return renderPasses[index - 1];
|
|
13706
|
-
}
|
|
13707
13234
|
var GlobalUniforms = function GlobalUniforms() {
|
|
13708
13235
|
this.floats = {};
|
|
13709
13236
|
this.ints = {};
|
|
@@ -13741,6 +13268,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
|
|
|
13741
13268
|
return Renderbuffer;
|
|
13742
13269
|
}();
|
|
13743
13270
|
|
|
13271
|
+
var RenderTargetPool = /*#__PURE__*/ function() {
|
|
13272
|
+
function RenderTargetPool(engine) {
|
|
13273
|
+
this.engine = engine;
|
|
13274
|
+
this.temporaryRTs = [];
|
|
13275
|
+
this.currentFrame = 0;
|
|
13276
|
+
this.maxUnusedFrames = 4;
|
|
13277
|
+
}
|
|
13278
|
+
var _proto = RenderTargetPool.prototype;
|
|
13279
|
+
/**
|
|
13280
|
+
* 清理 RenderTarget 池
|
|
13281
|
+
* @param force - 是否强制清理所有未占用的 RT
|
|
13282
|
+
* @param framesOffset - 自定义未使用帧数阈值,-1 表示使用默认值
|
|
13283
|
+
*/ _proto.flush = function flush(force, framesOffset) {
|
|
13284
|
+
if (force === void 0) force = false;
|
|
13285
|
+
if (framesOffset === void 0) framesOffset = -1;
|
|
13286
|
+
this.currentFrame++;
|
|
13287
|
+
var threshold = framesOffset >= 0 ? framesOffset : this.maxUnusedFrames;
|
|
13288
|
+
for(var i = 0; i < this.temporaryRTs.length; i++){
|
|
13289
|
+
var entry = this.temporaryRTs[i];
|
|
13290
|
+
// 强制清理所有未占用的 RT,或清理超过阈值帧数未使用的 RT
|
|
13291
|
+
if (!entry.isOccupied && (force || this.currentFrame - entry.lastFrameReleased > threshold)) {
|
|
13292
|
+
entry.RT.dispose();
|
|
13293
|
+
this.temporaryRTs.splice(i--, 1);
|
|
13294
|
+
}
|
|
13295
|
+
}
|
|
13296
|
+
};
|
|
13297
|
+
_proto.get = function get(name, width, height, depthBuffer, filter, format) {
|
|
13298
|
+
if (depthBuffer === void 0) depthBuffer = 0;
|
|
13299
|
+
if (filter === void 0) filter = exports.FilterMode.Linear;
|
|
13300
|
+
if (format === void 0) format = exports.RenderTextureFormat.RGBA32;
|
|
13301
|
+
// 使用参数计算 hash 值作为缓存 key
|
|
13302
|
+
var hash = width + "_" + height + "_" + depthBuffer + "_" + filter + "_" + format;
|
|
13303
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13304
|
+
var entry = _step.value;
|
|
13305
|
+
if (!entry.isOccupied && entry.descriptionHash === hash) {
|
|
13306
|
+
entry.isOccupied = true;
|
|
13307
|
+
entry.RT.name = name;
|
|
13308
|
+
return entry.RT;
|
|
13309
|
+
}
|
|
13310
|
+
}
|
|
13311
|
+
var textureFilter;
|
|
13312
|
+
var textureType;
|
|
13313
|
+
var depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13314
|
+
// TODO 建立Map映射
|
|
13315
|
+
if (filter === exports.FilterMode.Linear) {
|
|
13316
|
+
textureFilter = glContext.LINEAR;
|
|
13317
|
+
} else if (filter === exports.FilterMode.Nearest) {
|
|
13318
|
+
textureFilter = glContext.NEAREST;
|
|
13319
|
+
}
|
|
13320
|
+
if (format === exports.RenderTextureFormat.RGBA32) {
|
|
13321
|
+
textureType = glContext.UNSIGNED_BYTE;
|
|
13322
|
+
} else if (format === exports.RenderTextureFormat.RGBAHalf) {
|
|
13323
|
+
textureType = glContext.HALF_FLOAT;
|
|
13324
|
+
}
|
|
13325
|
+
if (depthBuffer === 0) {
|
|
13326
|
+
depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13327
|
+
} else if (depthBuffer === 16) {
|
|
13328
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_stencil_opaque;
|
|
13329
|
+
} else if (depthBuffer === 24) {
|
|
13330
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_24_stencil_8_texture;
|
|
13331
|
+
}
|
|
13332
|
+
var colorAttachment = Texture.create(this.engine, {
|
|
13333
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
13334
|
+
minFilter: textureFilter,
|
|
13335
|
+
magFilter: textureFilter,
|
|
13336
|
+
internalFormat: glContext.RGBA,
|
|
13337
|
+
format: glContext.RGBA,
|
|
13338
|
+
type: textureType
|
|
13339
|
+
});
|
|
13340
|
+
var newFramebuffer = Framebuffer.create({
|
|
13341
|
+
name: name,
|
|
13342
|
+
storeAction: {},
|
|
13343
|
+
viewport: [
|
|
13344
|
+
0,
|
|
13345
|
+
0,
|
|
13346
|
+
width,
|
|
13347
|
+
height
|
|
13348
|
+
],
|
|
13349
|
+
attachments: [
|
|
13350
|
+
colorAttachment
|
|
13351
|
+
],
|
|
13352
|
+
depthStencilAttachment: {
|
|
13353
|
+
storageType: depthType
|
|
13354
|
+
}
|
|
13355
|
+
}, this.engine.renderer);
|
|
13356
|
+
var entry1 = {
|
|
13357
|
+
RT: newFramebuffer,
|
|
13358
|
+
lastFrameReleased: 0,
|
|
13359
|
+
descriptionHash: hash,
|
|
13360
|
+
isOccupied: true
|
|
13361
|
+
};
|
|
13362
|
+
this.temporaryRTs.push(entry1);
|
|
13363
|
+
return entry1.RT;
|
|
13364
|
+
};
|
|
13365
|
+
/**
|
|
13366
|
+
* 释放 RenderTarget,使其可以被复用
|
|
13367
|
+
* @param rt - 要释放的 Framebuffer
|
|
13368
|
+
*/ _proto.release = function release(rt) {
|
|
13369
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13370
|
+
var entry = _step.value;
|
|
13371
|
+
if (entry.RT === rt) {
|
|
13372
|
+
entry.isOccupied = false;
|
|
13373
|
+
entry.lastFrameReleased = this.currentFrame;
|
|
13374
|
+
break;
|
|
13375
|
+
}
|
|
13376
|
+
}
|
|
13377
|
+
};
|
|
13378
|
+
_proto.dispose = function dispose() {
|
|
13379
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13380
|
+
var entry = _step.value;
|
|
13381
|
+
entry.RT.dispose();
|
|
13382
|
+
}
|
|
13383
|
+
};
|
|
13384
|
+
return RenderTargetPool;
|
|
13385
|
+
}();
|
|
13386
|
+
|
|
13744
13387
|
var isWebGL2Available = typeof WebGL2RenderingContext === "function";
|
|
13745
13388
|
var GPUCapability = /*#__PURE__*/ function() {
|
|
13746
13389
|
function GPUCapability(gl) {
|
|
@@ -13926,70 +13569,11 @@ exports.CompressTextureCapabilityType = void 0;
|
|
|
13926
13569
|
return !!hasCompressedTextureSupport;
|
|
13927
13570
|
}
|
|
13928
13571
|
|
|
13929
|
-
exports.FilterMode = void 0;
|
|
13930
|
-
(function(FilterMode) {
|
|
13931
|
-
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
13932
|
-
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
13933
|
-
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
13934
|
-
exports.RenderTextureFormat = void 0;
|
|
13935
|
-
(function(RenderTextureFormat) {
|
|
13936
|
-
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
13937
|
-
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
13938
|
-
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
13939
|
-
/**
|
|
13940
|
-
*
|
|
13941
|
-
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
13942
|
-
function Framebuffer() {}
|
|
13943
|
-
var _proto = Framebuffer.prototype;
|
|
13944
|
-
_proto.resize = function resize(x, y, width, height) {
|
|
13945
|
-
// OVERRIDE
|
|
13946
|
-
};
|
|
13947
|
-
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
13948
|
-
// OVERRIDE
|
|
13949
|
-
};
|
|
13950
|
-
_proto.unbind = function unbind() {
|
|
13951
|
-
// OVERRIDE
|
|
13952
|
-
};
|
|
13953
|
-
_proto.bind = function bind() {
|
|
13954
|
-
// OVERRIDE
|
|
13955
|
-
};
|
|
13956
|
-
_proto.getDepthTexture = function getDepthTexture() {
|
|
13957
|
-
// OVERRIDE
|
|
13958
|
-
return undefined;
|
|
13959
|
-
};
|
|
13960
|
-
_proto.getStencilTexture = function getStencilTexture() {
|
|
13961
|
-
// OVERRIDE
|
|
13962
|
-
return undefined;
|
|
13963
|
-
};
|
|
13964
|
-
_proto.getColorTextures = function getColorTextures() {
|
|
13965
|
-
// OVERRIDE
|
|
13966
|
-
return [];
|
|
13967
|
-
};
|
|
13968
|
-
_proto.dispose = function dispose(options) {
|
|
13969
|
-
// OVERRIDE
|
|
13970
|
-
};
|
|
13971
|
-
_create_class(Framebuffer, [
|
|
13972
|
-
{
|
|
13973
|
-
key: "stencilStorage",
|
|
13974
|
-
get: function get() {
|
|
13975
|
-
// OVERRIDE
|
|
13976
|
-
return undefined;
|
|
13977
|
-
}
|
|
13978
|
-
},
|
|
13979
|
-
{
|
|
13980
|
-
key: "depthStorage",
|
|
13981
|
-
get: function get() {
|
|
13982
|
-
// OVERRIDE
|
|
13983
|
-
return undefined;
|
|
13984
|
-
}
|
|
13985
|
-
}
|
|
13986
|
-
]);
|
|
13987
|
-
return Framebuffer;
|
|
13988
|
-
}();
|
|
13989
|
-
|
|
13990
13572
|
var Renderer = /*#__PURE__*/ function() {
|
|
13991
13573
|
function Renderer(engine) {
|
|
13992
13574
|
this.engine = engine;
|
|
13575
|
+
this.currentFramebuffer = null;
|
|
13576
|
+
this.renderTargetPool = new RenderTargetPool(engine);
|
|
13993
13577
|
}
|
|
13994
13578
|
var _proto = Renderer.prototype;
|
|
13995
13579
|
_proto.setGlobalFloat = function setGlobalFloat(name, value) {
|
|
@@ -14059,8 +13643,10 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14059
13643
|
// OVERRIDE
|
|
14060
13644
|
};
|
|
14061
13645
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
14062
|
-
|
|
14063
|
-
|
|
13646
|
+
return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
13647
|
+
};
|
|
13648
|
+
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13649
|
+
this.renderTargetPool.release(rt);
|
|
14064
13650
|
};
|
|
14065
13651
|
_proto.dispose = function dispose() {
|
|
14066
13652
|
// OVERRIDE
|
|
@@ -14068,6 +13654,41 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14068
13654
|
return Renderer;
|
|
14069
13655
|
}();
|
|
14070
13656
|
|
|
13657
|
+
var SemanticMap = /*#__PURE__*/ function() {
|
|
13658
|
+
function SemanticMap(semantics) {
|
|
13659
|
+
if (semantics === void 0) semantics = {};
|
|
13660
|
+
this.semantics = _extends({}, semantics);
|
|
13661
|
+
}
|
|
13662
|
+
var _proto = SemanticMap.prototype;
|
|
13663
|
+
_proto.toObject = function toObject() {
|
|
13664
|
+
return _extends({}, this.semantics);
|
|
13665
|
+
};
|
|
13666
|
+
_proto.setSemantic = function setSemantic(name, value) {
|
|
13667
|
+
if (value === undefined) {
|
|
13668
|
+
delete this.semantics[name];
|
|
13669
|
+
} else {
|
|
13670
|
+
this.semantics[name] = value;
|
|
13671
|
+
}
|
|
13672
|
+
};
|
|
13673
|
+
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13674
|
+
var ret = this.semantics[name];
|
|
13675
|
+
if (isFunction(ret)) {
|
|
13676
|
+
return ret(state);
|
|
13677
|
+
}
|
|
13678
|
+
return ret;
|
|
13679
|
+
};
|
|
13680
|
+
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13681
|
+
return name in this.semantics;
|
|
13682
|
+
};
|
|
13683
|
+
_proto.dispose = function dispose() {
|
|
13684
|
+
var _this = this;
|
|
13685
|
+
Object.keys(this.semantics).forEach(function(name) {
|
|
13686
|
+
delete _this.semantics[name];
|
|
13687
|
+
});
|
|
13688
|
+
};
|
|
13689
|
+
return SemanticMap;
|
|
13690
|
+
}();
|
|
13691
|
+
|
|
14071
13692
|
/**
|
|
14072
13693
|
* @since 2.7.0
|
|
14073
13694
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -18098,6 +17719,11 @@ exports.PlayState = void 0;
|
|
|
18098
17719
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
18099
17720
|
})(exports.PlayState || (exports.PlayState = {}));
|
|
18100
17721
|
|
|
17722
|
+
function _assert_this_initialized(self) {
|
|
17723
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17724
|
+
return self;
|
|
17725
|
+
}
|
|
17726
|
+
|
|
18101
17727
|
var tempQuat$1 = new Quaternion();
|
|
18102
17728
|
var tempVector3 = new Vector3();
|
|
18103
17729
|
var tempVector3Second = new Vector3();
|
|
@@ -24475,8 +24101,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24475
24101
|
_this.reusable = reusable;
|
|
24476
24102
|
_this.speed = speed;
|
|
24477
24103
|
_this.name = sourceContent.name;
|
|
24478
|
-
_this
|
|
24479
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24104
|
+
PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24480
24105
|
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24481
24106
|
aspect: width / height,
|
|
24482
24107
|
pixelWidth: width,
|
|
@@ -24490,7 +24115,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24490
24115
|
_this.createRenderFrame();
|
|
24491
24116
|
Composition.buildItemTree(_this.rootItem);
|
|
24492
24117
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
24493
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24494
24118
|
return _this;
|
|
24495
24119
|
}
|
|
24496
24120
|
var _proto = Composition.prototype;
|
|
@@ -24600,12 +24224,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24600
24224
|
this.renderFrame = new RenderFrame({
|
|
24601
24225
|
camera: this.camera,
|
|
24602
24226
|
renderer: this.renderer,
|
|
24603
|
-
keepColorBuffer: this.keepColorBuffer,
|
|
24604
24227
|
globalVolume: this.globalVolume,
|
|
24605
24228
|
postProcessingEnabled: this.postProcessingEnabled
|
|
24606
24229
|
});
|
|
24607
|
-
// TODO 考虑放到构造函数
|
|
24608
|
-
this.renderFrame.cachedTextures = this.textures;
|
|
24609
24230
|
};
|
|
24610
24231
|
/**
|
|
24611
24232
|
* 跳到指定时间点(不做任何播放行为)
|
|
@@ -24656,7 +24277,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24656
24277
|
this.isEnded = false;
|
|
24657
24278
|
this.isEndCalled = false;
|
|
24658
24279
|
this.rootComposition.time = 0;
|
|
24659
|
-
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24660
24280
|
};
|
|
24661
24281
|
_proto.prepareRender = function prepareRender() {};
|
|
24662
24282
|
/**
|
|
@@ -24674,8 +24294,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24674
24294
|
var previousCompositionTime = this.time;
|
|
24675
24295
|
this.updateCompositionTime(deltaTime * this.speed / 1000);
|
|
24676
24296
|
var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
|
|
24677
|
-
// 更新 model-tree-plugin
|
|
24678
|
-
this.updatePluginLoaders(deltaTimeInMs);
|
|
24679
24297
|
this.sceneTicking.update.tick(deltaTimeInMs);
|
|
24680
24298
|
this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
|
|
24681
24299
|
this.updateCamera();
|
|
@@ -24700,15 +24318,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24700
24318
|
this.camera.updateMatrix();
|
|
24701
24319
|
};
|
|
24702
24320
|
/**
|
|
24703
|
-
* 插件更新,来自 CompVFXItem 的更新调用
|
|
24704
|
-
* @param deltaTime - 更新的时间步长
|
|
24705
|
-
*/ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
|
|
24706
|
-
var _this = this;
|
|
24707
|
-
this.pluginSystem.plugins.forEach(function(loader) {
|
|
24708
|
-
return loader.onCompositionUpdate(_this, deltaTime);
|
|
24709
|
-
});
|
|
24710
|
-
};
|
|
24711
|
-
/**
|
|
24712
24321
|
* 更新主合成组件
|
|
24713
24322
|
*/ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
|
|
24714
24323
|
if (this.rootComposition.state === exports.PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
|
|
@@ -24867,7 +24476,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24867
24476
|
* 合成对象销毁
|
|
24868
24477
|
*/ _proto.dispose = function dispose() {
|
|
24869
24478
|
var _this = this;
|
|
24870
|
-
var _this_pluginSystem;
|
|
24871
24479
|
if (this.destroyed) {
|
|
24872
24480
|
return;
|
|
24873
24481
|
}
|
|
@@ -24887,13 +24495,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24887
24495
|
this.rootItem.dispose();
|
|
24888
24496
|
// FIXME: 注意这里增加了renderFrame销毁
|
|
24889
24497
|
this.renderFrame.dispose();
|
|
24890
|
-
|
|
24498
|
+
PluginSystem.destroyComposition(this);
|
|
24891
24499
|
this.update = function() {
|
|
24892
24500
|
{
|
|
24893
24501
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
24894
24502
|
}
|
|
24895
24503
|
};
|
|
24896
24504
|
this.dispose = noop;
|
|
24505
|
+
this.renderer.engine.removeComposition(this);
|
|
24897
24506
|
if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
24898
24507
|
return;
|
|
24899
24508
|
}
|
|
@@ -24910,7 +24519,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24910
24519
|
0
|
|
24911
24520
|
]
|
|
24912
24521
|
});
|
|
24913
|
-
this.renderer.engine.removeComposition(this);
|
|
24914
24522
|
};
|
|
24915
24523
|
/**
|
|
24916
24524
|
* 编辑器使用的 transform 修改方法
|
|
@@ -29303,6 +28911,12 @@ var TextComponentBase = /*#__PURE__*/ function() {
|
|
|
29303
28911
|
this.textLayout.textVerticalAlign = value;
|
|
29304
28912
|
this.isDirty = true;
|
|
29305
28913
|
};
|
|
28914
|
+
/**
|
|
28915
|
+
* @deprecated 2.8.0 本方法已废弃,请使用 setTextVerticalAlign 替代。
|
|
28916
|
+
*/ _proto.setTextBaseline = function setTextBaseline(value) {
|
|
28917
|
+
console.warn("setTextBaseline 已废弃,请改用 setTextVerticalAlign。" + "本次调用将转调用 setTextVerticalAlign。");
|
|
28918
|
+
this.setTextVerticalAlign(value);
|
|
28919
|
+
};
|
|
29306
28920
|
_proto.setTextColor = function setTextColor(value) {
|
|
29307
28921
|
if (this.textStyle.textColor === value) {
|
|
29308
28922
|
return;
|
|
@@ -29567,7 +29181,9 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29567
29181
|
this.lineCount = this.getLineCount(this.text);
|
|
29568
29182
|
this.isDirty = true;
|
|
29569
29183
|
};
|
|
29570
|
-
|
|
29184
|
+
/**
|
|
29185
|
+
* 根据配置更新文本样式和布局
|
|
29186
|
+
*/ _proto.updateWithOptions = function updateWithOptions(options) {
|
|
29571
29187
|
// 初始化 textStyle 和 textLayout
|
|
29572
29188
|
if (!this.textStyle) {
|
|
29573
29189
|
this.textStyle = new TextStyle(options);
|
|
@@ -31877,7 +31493,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31877
31493
|
return ret;
|
|
31878
31494
|
}
|
|
31879
31495
|
|
|
31880
|
-
var version$2 = "2.8.0-alpha.
|
|
31496
|
+
var version$2 = "2.8.0-alpha.2";
|
|
31881
31497
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31882
31498
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31883
31499
|
var reverseParticle = false;
|
|
@@ -32392,7 +32008,7 @@ var seed$1 = 1;
|
|
|
32392
32008
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
32393
32009
|
* @param options - 扩展参数
|
|
32394
32010
|
* @returns
|
|
32395
|
-
*/ _proto.loadScene = function loadScene(url, renderer
|
|
32011
|
+
*/ _proto.loadScene = function loadScene(url, renderer) {
|
|
32396
32012
|
var _this = this;
|
|
32397
32013
|
return _async_to_generator(function() {
|
|
32398
32014
|
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
@@ -32453,7 +32069,7 @@ var seed$1 = 1;
|
|
|
32453
32069
|
});
|
|
32454
32070
|
});
|
|
32455
32071
|
loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
|
|
32456
|
-
var scene, link,
|
|
32072
|
+
var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
|
|
32457
32073
|
return __generator(this, function(_state) {
|
|
32458
32074
|
switch(_state.label){
|
|
32459
32075
|
case 0:
|
|
@@ -32503,7 +32119,26 @@ var seed$1 = 1;
|
|
|
32503
32119
|
})
|
|
32504
32120
|
];
|
|
32505
32121
|
case 5:
|
|
32506
|
-
|
|
32122
|
+
jsonScene = _state.sent().jsonScene;
|
|
32123
|
+
scene = {
|
|
32124
|
+
timeInfos: timeInfos,
|
|
32125
|
+
url: url,
|
|
32126
|
+
storage: {},
|
|
32127
|
+
jsonScene: jsonScene,
|
|
32128
|
+
bins: [],
|
|
32129
|
+
textureOptions: [],
|
|
32130
|
+
textures: [],
|
|
32131
|
+
images: [],
|
|
32132
|
+
assets: _this.assets
|
|
32133
|
+
};
|
|
32134
|
+
return [
|
|
32135
|
+
4,
|
|
32136
|
+
hookTimeInfo("plugin:processAssets", function() {
|
|
32137
|
+
return _this.processPluginAssets(scene);
|
|
32138
|
+
})
|
|
32139
|
+
];
|
|
32140
|
+
case 6:
|
|
32141
|
+
_state.sent();
|
|
32507
32142
|
_jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
|
|
32508
32143
|
return [
|
|
32509
32144
|
4,
|
|
@@ -32514,46 +32149,26 @@ var seed$1 = 1;
|
|
|
32514
32149
|
hookTimeInfo("processImages", function() {
|
|
32515
32150
|
return _this.processImages(images, isKTX2Supported);
|
|
32516
32151
|
}),
|
|
32517
|
-
hookTimeInfo("plugin:processAssets", function() {
|
|
32518
|
-
return _this.processPluginAssets(jsonScene, pluginSystem, options);
|
|
32519
|
-
}),
|
|
32520
32152
|
hookTimeInfo("processFontURL", function() {
|
|
32521
32153
|
return _this.processFontURL(fonts);
|
|
32522
32154
|
})
|
|
32523
32155
|
])
|
|
32524
32156
|
];
|
|
32525
|
-
case
|
|
32526
|
-
|
|
32157
|
+
case 7:
|
|
32158
|
+
_ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
|
|
32527
32159
|
return [
|
|
32528
32160
|
4,
|
|
32529
32161
|
hookTimeInfo("processTextures", function() {
|
|
32530
32162
|
return _this.processTextures(loadedImages, loadedBins, jsonScene);
|
|
32531
32163
|
})
|
|
32532
32164
|
];
|
|
32533
|
-
case 7:
|
|
32534
|
-
loadedTextures = _state.sent();
|
|
32535
|
-
scene = {
|
|
32536
|
-
timeInfos: timeInfos,
|
|
32537
|
-
url: url,
|
|
32538
|
-
renderLevel: _this.options.renderLevel,
|
|
32539
|
-
storage: {},
|
|
32540
|
-
pluginSystem: pluginSystem,
|
|
32541
|
-
jsonScene: jsonScene,
|
|
32542
|
-
bins: loadedBins,
|
|
32543
|
-
textureOptions: loadedTextures,
|
|
32544
|
-
textures: [],
|
|
32545
|
-
images: loadedImages,
|
|
32546
|
-
assets: _this.assets
|
|
32547
|
-
};
|
|
32548
|
-
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
32549
|
-
return [
|
|
32550
|
-
4,
|
|
32551
|
-
hookTimeInfo("plugin:prepareResource", function() {
|
|
32552
|
-
return pluginSystem.loadResources(scene, _this.options);
|
|
32553
|
-
})
|
|
32554
|
-
];
|
|
32555
32165
|
case 8:
|
|
32556
|
-
_state.sent();
|
|
32166
|
+
loadedTextures = _state.sent();
|
|
32167
|
+
(_scene_bins = scene.bins).push.apply(_scene_bins, [].concat(loadedBins));
|
|
32168
|
+
(_scene_textureOptions = scene.textureOptions).push.apply(_scene_textureOptions, [].concat(loadedTextures));
|
|
32169
|
+
(_scene_images = scene.images).push.apply(_scene_images, [].concat(loadedImages));
|
|
32170
|
+
// 降级插件会修改 this.options.renderLevel, 在 processPluginAssets 后赋值
|
|
32171
|
+
scene.renderLevel = _this.options.renderLevel;
|
|
32557
32172
|
_state.label = 9;
|
|
32558
32173
|
case 9:
|
|
32559
32174
|
totalTime = performance.now() - startTime;
|
|
@@ -32585,29 +32200,23 @@ var seed$1 = 1;
|
|
|
32585
32200
|
return this.assets;
|
|
32586
32201
|
};
|
|
32587
32202
|
_proto.processJSON = function processJSON(json) {
|
|
32588
|
-
var _this = this;
|
|
32589
32203
|
return _async_to_generator(function() {
|
|
32590
|
-
var jsonScene, _jsonScene_plugins, plugins,
|
|
32204
|
+
var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
|
|
32591
32205
|
return __generator(this, function(_state) {
|
|
32592
|
-
|
|
32593
|
-
|
|
32594
|
-
|
|
32595
|
-
|
|
32596
|
-
|
|
32597
|
-
|
|
32598
|
-
|
|
32599
|
-
pluginSystem.processRawJSON(jsonScene, _this.options)
|
|
32600
|
-
];
|
|
32601
|
-
case 1:
|
|
32602
|
-
_state.sent();
|
|
32603
|
-
return [
|
|
32604
|
-
2,
|
|
32605
|
-
{
|
|
32606
|
-
jsonScene: jsonScene,
|
|
32607
|
-
pluginSystem: pluginSystem
|
|
32608
|
-
}
|
|
32609
|
-
];
|
|
32206
|
+
jsonScene = getStandardJSON(json);
|
|
32207
|
+
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
|
|
32208
|
+
for(_iterator = _create_for_of_iterator_helper_loose(plugins); !(_step = _iterator()).done;){
|
|
32209
|
+
customPluginName = _step.value;
|
|
32210
|
+
if (!pluginLoaderMap[customPluginName]) {
|
|
32211
|
+
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
32212
|
+
}
|
|
32610
32213
|
}
|
|
32214
|
+
return [
|
|
32215
|
+
2,
|
|
32216
|
+
{
|
|
32217
|
+
jsonScene: jsonScene
|
|
32218
|
+
}
|
|
32219
|
+
];
|
|
32611
32220
|
});
|
|
32612
32221
|
})();
|
|
32613
32222
|
};
|
|
@@ -32813,30 +32422,18 @@ var seed$1 = 1;
|
|
|
32813
32422
|
});
|
|
32814
32423
|
})();
|
|
32815
32424
|
};
|
|
32816
|
-
_proto.processPluginAssets = function processPluginAssets(
|
|
32425
|
+
_proto.processPluginAssets = function processPluginAssets(scene) {
|
|
32817
32426
|
var _this = this;
|
|
32818
32427
|
return _async_to_generator(function() {
|
|
32819
|
-
var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
|
|
32820
32428
|
return __generator(this, function(_state) {
|
|
32821
32429
|
switch(_state.label){
|
|
32822
32430
|
case 0:
|
|
32823
32431
|
return [
|
|
32824
32432
|
4,
|
|
32825
|
-
|
|
32433
|
+
PluginSystem.processAssets(scene, _this.options)
|
|
32826
32434
|
];
|
|
32827
32435
|
case 1:
|
|
32828
|
-
|
|
32829
|
-
_pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
|
|
32830
|
-
acc.assets = acc.assets.concat(cur.assets);
|
|
32831
|
-
acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
|
|
32832
|
-
return acc;
|
|
32833
|
-
}, {
|
|
32834
|
-
assets: [],
|
|
32835
|
-
loadedAssets: []
|
|
32836
|
-
}), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
|
|
32837
|
-
for(i = 0; i < assets.length; i++){
|
|
32838
|
-
_this.assets[assets[i].id] = loadedAssets[i];
|
|
32839
|
-
}
|
|
32436
|
+
_state.sent();
|
|
32840
32437
|
return [
|
|
32841
32438
|
2
|
|
32842
32439
|
];
|
|
@@ -33263,7 +32860,6 @@ function _createTextureOptionsBySource() {
|
|
|
33263
32860
|
}
|
|
33264
32861
|
};
|
|
33265
32862
|
_proto.prepareAssets = function prepareAssets(scene, assets) {
|
|
33266
|
-
this.engine.clearResources();
|
|
33267
32863
|
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
|
|
33268
32864
|
var assetId = _step.value;
|
|
33269
32865
|
var asset = assets[assetId];
|
|
@@ -35175,8 +34771,9 @@ var DEFAULT_FPS = 60;
|
|
|
35175
34771
|
]
|
|
35176
34772
|
});
|
|
35177
34773
|
for(var i1 = 0; i1 < comps.length; i1++){
|
|
35178
|
-
!comps[i1].renderFrame.
|
|
34774
|
+
!comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
|
|
35179
34775
|
}
|
|
34776
|
+
this.renderer.renderTargetPool.flush();
|
|
35180
34777
|
};
|
|
35181
34778
|
/**
|
|
35182
34779
|
* 将渲染器重新和父容器大小对齐
|
|
@@ -35422,6 +35019,95 @@ var DEFAULT_FPS = 60;
|
|
|
35422
35019
|
return Engine;
|
|
35423
35020
|
}(EventEmitter);
|
|
35424
35021
|
|
|
35022
|
+
var def = {
|
|
35023
|
+
format: glContext.RGBA,
|
|
35024
|
+
type: glContext.UNSIGNED_BYTE,
|
|
35025
|
+
minFilter: glContext.LINEAR,
|
|
35026
|
+
magFilter: glContext.LINEAR,
|
|
35027
|
+
wrapS: glContext.CLAMP_TO_EDGE,
|
|
35028
|
+
wrapT: glContext.CLAMP_TO_EDGE
|
|
35029
|
+
};
|
|
35030
|
+
var disposeSymbol = Symbol("dispose");
|
|
35031
|
+
var PassTextureCache = /*#__PURE__*/ function() {
|
|
35032
|
+
function PassTextureCache(engine) {
|
|
35033
|
+
this.textureCache = {};
|
|
35034
|
+
this.textureRef = {};
|
|
35035
|
+
this.engine = engine;
|
|
35036
|
+
}
|
|
35037
|
+
var _proto = PassTextureCache.prototype;
|
|
35038
|
+
_proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
|
|
35039
|
+
var _this = this;
|
|
35040
|
+
var width = request.width, height = request.height, name = request.name;
|
|
35041
|
+
var options = {
|
|
35042
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
35043
|
+
data: {
|
|
35044
|
+
width: width,
|
|
35045
|
+
height: height
|
|
35046
|
+
},
|
|
35047
|
+
name: name
|
|
35048
|
+
};
|
|
35049
|
+
var keys = [
|
|
35050
|
+
name
|
|
35051
|
+
];
|
|
35052
|
+
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
35053
|
+
var _request_name;
|
|
35054
|
+
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
35055
|
+
options[name] = value;
|
|
35056
|
+
keys.push(name, value);
|
|
35057
|
+
});
|
|
35058
|
+
var cacheId = keys.join(":");
|
|
35059
|
+
var tex = this.textureCache[cacheId];
|
|
35060
|
+
if (tex) {
|
|
35061
|
+
this.textureRef[cacheId]++;
|
|
35062
|
+
} else {
|
|
35063
|
+
var engine = this.engine;
|
|
35064
|
+
assertExist(engine);
|
|
35065
|
+
tex = Texture.create(engine, options);
|
|
35066
|
+
this.textureCache[cacheId] = tex;
|
|
35067
|
+
this.textureRef[cacheId] = 1;
|
|
35068
|
+
// @ts-expect-error
|
|
35069
|
+
tex[disposeSymbol] = tex.dispose;
|
|
35070
|
+
tex.dispose = function() {
|
|
35071
|
+
return _this.removeTexture(cacheId);
|
|
35072
|
+
};
|
|
35073
|
+
}
|
|
35074
|
+
return tex;
|
|
35075
|
+
};
|
|
35076
|
+
_proto.removeTexture = function removeTexture(id) {
|
|
35077
|
+
var refCount = this.textureRef[id];
|
|
35078
|
+
if (refCount <= 1) {
|
|
35079
|
+
if (refCount < 0) {
|
|
35080
|
+
console.error("Ref count < 0.");
|
|
35081
|
+
}
|
|
35082
|
+
var tex = this.textureCache[id];
|
|
35083
|
+
if (tex) {
|
|
35084
|
+
// @ts-expect-error
|
|
35085
|
+
tex[disposeSymbol]();
|
|
35086
|
+
// @ts-expect-error
|
|
35087
|
+
tex.dispose = tex[disposeSymbol];
|
|
35088
|
+
}
|
|
35089
|
+
delete this.textureCache[id];
|
|
35090
|
+
delete this.textureRef[id];
|
|
35091
|
+
} else {
|
|
35092
|
+
this.textureRef[id] = refCount - 1;
|
|
35093
|
+
}
|
|
35094
|
+
};
|
|
35095
|
+
_proto.dispose = function dispose() {
|
|
35096
|
+
var _this = this;
|
|
35097
|
+
Object.keys(this.textureCache).forEach(function(key) {
|
|
35098
|
+
var texture = _this.textureCache[key];
|
|
35099
|
+
// @ts-expect-error
|
|
35100
|
+
texture[disposeSymbol]();
|
|
35101
|
+
// @ts-expect-error
|
|
35102
|
+
texture.dispose = texture[disposeSymbol];
|
|
35103
|
+
});
|
|
35104
|
+
this.textureCache = {};
|
|
35105
|
+
this.textureRef = {};
|
|
35106
|
+
this.engine = undefined;
|
|
35107
|
+
};
|
|
35108
|
+
return PassTextureCache;
|
|
35109
|
+
}();
|
|
35110
|
+
|
|
35425
35111
|
var SceneLoader = /*#__PURE__*/ function() {
|
|
35426
35112
|
function SceneLoader() {}
|
|
35427
35113
|
SceneLoader.load = function load(scene, engine, options) {
|
|
@@ -35440,16 +35126,16 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35440
35126
|
engine.assetManagers.push(assetManager);
|
|
35441
35127
|
return [
|
|
35442
35128
|
4,
|
|
35443
|
-
assetManager.loadScene(scene, engine.renderer
|
|
35444
|
-
env: engine.env
|
|
35445
|
-
})
|
|
35129
|
+
assetManager.loadScene(scene, engine.renderer)
|
|
35446
35130
|
];
|
|
35447
35131
|
case 1:
|
|
35448
35132
|
loadedScene = _state.sent();
|
|
35133
|
+
engine.clearResources();
|
|
35134
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
35135
|
+
PluginSystem.loadResources(loadedScene, assetManager.options, engine);
|
|
35449
35136
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35450
35137
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35451
35138
|
engine.assetService.initializeTexture(loadedScene);
|
|
35452
|
-
loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
|
|
35453
35139
|
composition = _this.createComposition(loadedScene, engine, options);
|
|
35454
35140
|
composition.setIndex(compositionIndex);
|
|
35455
35141
|
compileStart = performance.now();
|
|
@@ -35502,13 +35188,13 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35502
35188
|
return SceneLoader;
|
|
35503
35189
|
}();
|
|
35504
35190
|
|
|
35505
|
-
registerPlugin("camera", CameraVFXItemLoader
|
|
35506
|
-
registerPlugin("text", TextLoader
|
|
35507
|
-
registerPlugin("sprite", SpriteLoader
|
|
35508
|
-
registerPlugin("particle", ParticleLoader
|
|
35509
|
-
registerPlugin("cal", CalculateLoader
|
|
35510
|
-
registerPlugin("interact", InteractLoader
|
|
35511
|
-
var version$1 = "2.8.0-alpha.
|
|
35191
|
+
registerPlugin("camera", CameraVFXItemLoader);
|
|
35192
|
+
registerPlugin("text", TextLoader);
|
|
35193
|
+
registerPlugin("sprite", SpriteLoader);
|
|
35194
|
+
registerPlugin("particle", ParticleLoader);
|
|
35195
|
+
registerPlugin("cal", CalculateLoader);
|
|
35196
|
+
registerPlugin("interact", InteractLoader);
|
|
35197
|
+
var version$1 = "2.8.0-alpha.2";
|
|
35512
35198
|
logger.info("Core version: " + version$1 + ".");
|
|
35513
35199
|
|
|
35514
35200
|
var _obj;
|
|
@@ -36786,7 +36472,7 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
36786
36472
|
return [
|
|
36787
36473
|
4,
|
|
36788
36474
|
Promise.all(scenes.map(/*#__PURE__*/ _async_to_generator(function(url, index) {
|
|
36789
|
-
var _this_assetService_assembleSceneLoadOptions, source, opts, assetManager, _$scene, composition;
|
|
36475
|
+
var _this_assetService_assembleSceneLoadOptions, source, opts, assetManager, _$scene, engine, composition;
|
|
36790
36476
|
return __generator(this, function(_state) {
|
|
36791
36477
|
switch(_state.label){
|
|
36792
36478
|
case 0:
|
|
@@ -36796,16 +36482,17 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
36796
36482
|
assetManager = new AssetManager(opts);
|
|
36797
36483
|
return [
|
|
36798
36484
|
4,
|
|
36799
|
-
assetManager.loadScene(source, _this.renderer
|
|
36800
|
-
env: _this.env
|
|
36801
|
-
})
|
|
36485
|
+
assetManager.loadScene(source, _this.renderer)
|
|
36802
36486
|
];
|
|
36803
36487
|
case 1:
|
|
36804
36488
|
_$scene = _state.sent();
|
|
36489
|
+
engine = _this.engine;
|
|
36490
|
+
engine.clearResources();
|
|
36491
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
36492
|
+
PluginSystem.loadResources(_$scene, assetManager.options, engine);
|
|
36805
36493
|
_this.assetService.prepareAssets(_$scene, assetManager.getAssets());
|
|
36806
36494
|
_this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
|
|
36807
36495
|
_this.assetService.initializeTexture(_$scene);
|
|
36808
|
-
_$scene.pluginSystem.precompile(_$scene.jsonScene.compositions, _this.renderer);
|
|
36809
36496
|
composition = _this.createComposition(_$scene, opts);
|
|
36810
36497
|
_this.baseCompositionIndex += 1;
|
|
36811
36498
|
composition.setIndex(baseOrder + index);
|
|
@@ -37097,7 +36784,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
37097
36784
|
*/ Mesh.create = function(engine, props) {
|
|
37098
36785
|
return new ThreeMesh(engine, props);
|
|
37099
36786
|
};
|
|
37100
|
-
var version = "2.8.0-alpha.
|
|
36787
|
+
var version = "2.8.0-alpha.2";
|
|
37101
36788
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
37102
36789
|
|
|
37103
36790
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -37212,7 +36899,6 @@ exports.Pose = Pose;
|
|
|
37212
36899
|
exports.PoseNode = PoseNode;
|
|
37213
36900
|
exports.PropertyClipPlayable = PropertyClipPlayable;
|
|
37214
36901
|
exports.PropertyTrack = PropertyTrack;
|
|
37215
|
-
exports.RENDER_PASS_NAME_PREFIX = RENDER_PASS_NAME_PREFIX;
|
|
37216
36902
|
exports.RENDER_PREFER_LOOKUP_TEXTURE = RENDER_PREFER_LOOKUP_TEXTURE;
|
|
37217
36903
|
exports.RUNTIME_ENV = RUNTIME_ENV;
|
|
37218
36904
|
exports.RandomSetValue = RandomSetValue;
|
|
@@ -37225,6 +36911,7 @@ exports.RenderPassPriorityNormal = RenderPassPriorityNormal;
|
|
|
37225
36911
|
exports.RenderPassPriorityPostprocess = RenderPassPriorityPostprocess;
|
|
37226
36912
|
exports.RenderPassPriorityPrepare = RenderPassPriorityPrepare;
|
|
37227
36913
|
exports.RenderTargetHandle = RenderTargetHandle;
|
|
36914
|
+
exports.RenderTargetPool = RenderTargetPool;
|
|
37228
36915
|
exports.Renderbuffer = Renderbuffer;
|
|
37229
36916
|
exports.Renderer = Renderer;
|
|
37230
36917
|
exports.RendererComponent = RendererComponent;
|
|
@@ -37293,14 +36980,12 @@ exports.colorGradingFrag = colorGradingFrag;
|
|
|
37293
36980
|
exports.colorStopsFromGradient = colorStopsFromGradient;
|
|
37294
36981
|
exports.colorToArr = colorToArr$1;
|
|
37295
36982
|
exports.combineImageTemplate = combineImageTemplate;
|
|
37296
|
-
exports.createCopyShader = createCopyShader;
|
|
37297
36983
|
exports.createGLContext = createGLContext;
|
|
37298
36984
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
37299
36985
|
exports.createShape = createShape;
|
|
37300
36986
|
exports.createValueGetter = createValueGetter;
|
|
37301
36987
|
exports.curveEps = curveEps;
|
|
37302
36988
|
exports.decimalEqual = decimalEqual;
|
|
37303
|
-
exports.defaultPlugins = defaultPlugins;
|
|
37304
36989
|
exports.deserializeMipmapTexture = deserializeMipmapTexture;
|
|
37305
36990
|
exports.earcut = earcut;
|
|
37306
36991
|
exports.effectsClass = effectsClass;
|
|
@@ -37308,7 +36993,6 @@ exports.effectsClassStore = effectsClassStore;
|
|
|
37308
36993
|
exports.enlargeBuffer = enlargeBuffer;
|
|
37309
36994
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
37310
36995
|
exports.ensureVec3 = ensureVec3;
|
|
37311
|
-
exports.findPreviousRenderPass = findPreviousRenderPass;
|
|
37312
36996
|
exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
37313
36997
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
37314
36998
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
@@ -37329,6 +37013,7 @@ exports.getMergedStore = getMergedStore;
|
|
|
37329
37013
|
exports.getNodeDataClass = getNodeDataClass;
|
|
37330
37014
|
exports.getParticleMeshShader = getParticleMeshShader;
|
|
37331
37015
|
exports.getPixelRatio = getPixelRatio;
|
|
37016
|
+
exports.getPluginUsageInfo = getPluginUsageInfo;
|
|
37332
37017
|
exports.getPreMultiAlpha = getPreMultiAlpha;
|
|
37333
37018
|
exports.getStandardComposition = getStandardComposition;
|
|
37334
37019
|
exports.getStandardImage = getStandardImage;
|