@galacean/effects-threejs 2.8.0-alpha.1 → 2.8.0-alpha.3
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 +1102 -1529
- 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 +1101 -1526
- 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.3
|
|
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() {};
|
|
3089
2991
|
/**
|
|
3090
|
-
*
|
|
3091
|
-
*
|
|
3092
|
-
* @param
|
|
3093
|
-
|
|
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
|
+
};
|
|
3006
|
+
/**
|
|
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 = {};
|
|
@@ -7298,13 +7252,388 @@ __decorate([
|
|
|
7298
7252
|
serialize()
|
|
7299
7253
|
], RendererComponent.prototype, "_priority", void 0);
|
|
7300
7254
|
|
|
7255
|
+
exports.ShaderType = void 0;
|
|
7256
|
+
(function(ShaderType) {
|
|
7257
|
+
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
7258
|
+
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
7259
|
+
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
7260
|
+
exports.MaskMode = void 0;
|
|
7261
|
+
(function(MaskMode) {
|
|
7262
|
+
/**
|
|
7263
|
+
* 无
|
|
7264
|
+
*/ MaskMode[MaskMode["NONE"] = 0] = "NONE";
|
|
7265
|
+
/**
|
|
7266
|
+
* 蒙版
|
|
7267
|
+
*/ MaskMode[MaskMode["MASK"] = 1] = "MASK";
|
|
7268
|
+
/**
|
|
7269
|
+
* 被遮挡
|
|
7270
|
+
*/ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
|
|
7271
|
+
/**
|
|
7272
|
+
* 被反向遮挡
|
|
7273
|
+
*/ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
|
|
7274
|
+
})(exports.MaskMode || (exports.MaskMode = {}));
|
|
7275
|
+
|
|
7276
|
+
exports.TextureLoadAction = void 0;
|
|
7277
|
+
(function(TextureLoadAction) {
|
|
7278
|
+
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
7279
|
+
//preserve previous attachment
|
|
7280
|
+
//load = 1,
|
|
7281
|
+
//clear attachment
|
|
7282
|
+
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
7283
|
+
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
7284
|
+
exports.TextureSourceType = void 0;
|
|
7285
|
+
(function(TextureSourceType) {
|
|
7286
|
+
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
7287
|
+
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
7288
|
+
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
7289
|
+
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
7290
|
+
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
7291
|
+
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
7292
|
+
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
7293
|
+
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
7294
|
+
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
7295
|
+
|
|
7296
|
+
var MaskProcessor = /*#__PURE__*/ function() {
|
|
7297
|
+
function MaskProcessor(engine) {
|
|
7298
|
+
this.engine = engine;
|
|
7299
|
+
this.alphaMaskEnabled = false;
|
|
7300
|
+
this.maskMode = exports.MaskMode.NONE;
|
|
7301
|
+
this.maskable = null;
|
|
7302
|
+
this.stencilClearAction = {
|
|
7303
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
7304
|
+
};
|
|
7305
|
+
}
|
|
7306
|
+
var _proto = MaskProcessor.prototype;
|
|
7307
|
+
_proto.getRefValue = function getRefValue() {
|
|
7308
|
+
return 1;
|
|
7309
|
+
};
|
|
7310
|
+
_proto.setMaskOptions = function setMaskOptions(data) {
|
|
7311
|
+
var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_inverted = data.inverted, inverted = _data_inverted === void 0 ? false : _data_inverted, reference = data.reference, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
|
|
7312
|
+
this.alphaMaskEnabled = alphaMaskEnabled;
|
|
7313
|
+
if (isMask) {
|
|
7314
|
+
this.maskMode = exports.MaskMode.MASK;
|
|
7315
|
+
} else {
|
|
7316
|
+
this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
|
|
7317
|
+
this.maskable = this.engine.findObject(reference);
|
|
7318
|
+
}
|
|
7319
|
+
};
|
|
7320
|
+
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
7321
|
+
if (this.maskable) {
|
|
7322
|
+
renderer.clear(this.stencilClearAction);
|
|
7323
|
+
this.maskable.drawStencilMask(renderer);
|
|
7324
|
+
}
|
|
7325
|
+
};
|
|
7326
|
+
return MaskProcessor;
|
|
7327
|
+
}();
|
|
7328
|
+
|
|
7329
|
+
/**
|
|
7330
|
+
* Helper class to create a WebGL Context
|
|
7331
|
+
*
|
|
7332
|
+
* @param canvas
|
|
7333
|
+
* @param glType
|
|
7334
|
+
* @param options
|
|
7335
|
+
* @returns
|
|
7336
|
+
*/ function createGLContext(canvas, glType, options) {
|
|
7337
|
+
if (glType === void 0) glType = "webgl";
|
|
7338
|
+
var context;
|
|
7339
|
+
if (glType === "webgl2") {
|
|
7340
|
+
context = canvas.getContext("webgl2", options);
|
|
7341
|
+
if (!context) {
|
|
7342
|
+
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
7343
|
+
}
|
|
7344
|
+
}
|
|
7345
|
+
if (!context || glType === "webgl") {
|
|
7346
|
+
context = canvas.getContext("webgl", options);
|
|
7347
|
+
}
|
|
7348
|
+
if (!context) {
|
|
7349
|
+
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
7350
|
+
}
|
|
7351
|
+
return context;
|
|
7352
|
+
}
|
|
7353
|
+
|
|
7354
|
+
function gpuTimer(gl) {
|
|
7355
|
+
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
7356
|
+
if (ext) {
|
|
7357
|
+
var query = gl.createQuery();
|
|
7358
|
+
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
7359
|
+
return __generator(this, function(_state) {
|
|
7360
|
+
return [
|
|
7361
|
+
2,
|
|
7362
|
+
new Promise(function(resolve, reject) {
|
|
7363
|
+
if (query) {
|
|
7364
|
+
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
7365
|
+
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
7366
|
+
if (available && !disjoint) {
|
|
7367
|
+
// See how much time the rendering of the object took in nanoseconds.
|
|
7368
|
+
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
7369
|
+
// taken to use all significant bits of the result, not just the
|
|
7370
|
+
// least significant 32 bits.
|
|
7371
|
+
resolve(timeElapsed / 1000 / 1000);
|
|
7372
|
+
}
|
|
7373
|
+
if (available || disjoint) {
|
|
7374
|
+
// Clean up the query object.
|
|
7375
|
+
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
7376
|
+
query = null;
|
|
7377
|
+
}
|
|
7378
|
+
available !== null && query && window.setTimeout(function() {
|
|
7379
|
+
getTime().then(resolve).catch;
|
|
7380
|
+
}, 1);
|
|
7381
|
+
}
|
|
7382
|
+
})
|
|
7383
|
+
];
|
|
7384
|
+
});
|
|
7385
|
+
});
|
|
7386
|
+
if (!query) {
|
|
7387
|
+
return;
|
|
7388
|
+
}
|
|
7389
|
+
return {
|
|
7390
|
+
begin: function() {
|
|
7391
|
+
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
7392
|
+
},
|
|
7393
|
+
end: function() {
|
|
7394
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
7395
|
+
},
|
|
7396
|
+
getTime: getTime
|
|
7397
|
+
};
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
|
|
7401
|
+
var initErrors = [];
|
|
7402
|
+
var glContext = {};
|
|
7403
|
+
var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
|
|
7404
|
+
var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
|
|
7405
|
+
if (!initErrors.length) {
|
|
7406
|
+
initGLContext();
|
|
7407
|
+
}
|
|
7408
|
+
function initGLContext() {
|
|
7409
|
+
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
7410
|
+
if (typeof WebGL2RenderingContext === "function") {
|
|
7411
|
+
copy(WebGL2RenderingContext);
|
|
7412
|
+
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
7413
|
+
copy(WebGLRenderingContext);
|
|
7414
|
+
copy(WebGLRenderingContext.prototype);
|
|
7415
|
+
} else {
|
|
7416
|
+
if (canUseBOM) {
|
|
7417
|
+
initErrors.push(// iOS 16 lockdown mode
|
|
7418
|
+
isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
7419
|
+
} else {
|
|
7420
|
+
initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
7421
|
+
}
|
|
7422
|
+
}
|
|
7423
|
+
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
7424
|
+
// @ts-expect-error set default value
|
|
7425
|
+
glContext["HALF_FLOAT"] = 5131;
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7428
|
+
function isWebGL2(gl) {
|
|
7429
|
+
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
7430
|
+
}
|
|
7431
|
+
function copy(target) {
|
|
7432
|
+
for(var name in target){
|
|
7433
|
+
if (/^[A-Z_]/.test(name)) {
|
|
7434
|
+
// @ts-expect-error safe to assign
|
|
7435
|
+
glContext[name] = target[name];
|
|
7436
|
+
}
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
function vertexFormatType2GLType(formatType) {
|
|
7440
|
+
switch(formatType){
|
|
7441
|
+
case VertexFormatType.Float32:
|
|
7442
|
+
return WebGLRenderingContext["FLOAT"];
|
|
7443
|
+
case VertexFormatType.Int16:
|
|
7444
|
+
return WebGLRenderingContext["SHORT"];
|
|
7445
|
+
case VertexFormatType.Int8:
|
|
7446
|
+
return WebGLRenderingContext["BYTE"];
|
|
7447
|
+
case VertexFormatType.UInt16:
|
|
7448
|
+
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
7449
|
+
case VertexFormatType.UInt8:
|
|
7450
|
+
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
7451
|
+
default:
|
|
7452
|
+
return WebGLRenderingContext["FLOAT"];
|
|
7453
|
+
}
|
|
7454
|
+
}
|
|
7455
|
+
function glType2VertexFormatType(webglType) {
|
|
7456
|
+
switch(webglType){
|
|
7457
|
+
case WebGLRenderingContext["FLOAT"]:
|
|
7458
|
+
return VertexFormatType.Float32;
|
|
7459
|
+
case WebGLRenderingContext["SHORT"]:
|
|
7460
|
+
return VertexFormatType.Int16;
|
|
7461
|
+
case WebGLRenderingContext["BYTE"]:
|
|
7462
|
+
return VertexFormatType.Int8;
|
|
7463
|
+
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
7464
|
+
return VertexFormatType.UInt16;
|
|
7465
|
+
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
7466
|
+
return VertexFormatType.UInt8;
|
|
7467
|
+
default:
|
|
7468
|
+
return VertexFormatType.Float32;
|
|
7469
|
+
}
|
|
7470
|
+
}
|
|
7471
|
+
|
|
7472
|
+
function valIfUndefined(val, def) {
|
|
7473
|
+
if (val === undefined || val === null) {
|
|
7474
|
+
return def;
|
|
7475
|
+
}
|
|
7476
|
+
return val;
|
|
7477
|
+
}
|
|
7478
|
+
function getPreMultiAlpha(blending) {
|
|
7479
|
+
switch(blending){
|
|
7480
|
+
case BlendingMode.ALPHA:
|
|
7481
|
+
return 1;
|
|
7482
|
+
case BlendingMode.ADD:
|
|
7483
|
+
return 1;
|
|
7484
|
+
case BlendingMode.SUBTRACTION:
|
|
7485
|
+
return 1;
|
|
7486
|
+
case BlendingMode.STRONG_LIGHT:
|
|
7487
|
+
return 1;
|
|
7488
|
+
case BlendingMode.WEAK_LIGHT:
|
|
7489
|
+
return 1;
|
|
7490
|
+
case BlendingMode.SUPERPOSITION:
|
|
7491
|
+
return 2;
|
|
7492
|
+
case BlendingMode.BRIGHTNESS:
|
|
7493
|
+
return 3;
|
|
7494
|
+
case BlendingMode.MULTIPLY:
|
|
7495
|
+
return 0;
|
|
7496
|
+
default:
|
|
7497
|
+
// 处理undefined
|
|
7498
|
+
return 1;
|
|
7499
|
+
}
|
|
7500
|
+
}
|
|
7501
|
+
function setBlendMode(material, blendMode) {
|
|
7502
|
+
switch(blendMode){
|
|
7503
|
+
case undefined:
|
|
7504
|
+
material.blendFunction = [
|
|
7505
|
+
glContext.ONE,
|
|
7506
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7507
|
+
glContext.ONE,
|
|
7508
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7509
|
+
];
|
|
7510
|
+
break;
|
|
7511
|
+
case BlendingMode.ALPHA:
|
|
7512
|
+
material.blendFunction = [
|
|
7513
|
+
glContext.ONE,
|
|
7514
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7515
|
+
glContext.ONE,
|
|
7516
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7517
|
+
];
|
|
7518
|
+
break;
|
|
7519
|
+
case BlendingMode.ADD:
|
|
7520
|
+
material.blendFunction = [
|
|
7521
|
+
glContext.ONE,
|
|
7522
|
+
glContext.ONE,
|
|
7523
|
+
glContext.ONE,
|
|
7524
|
+
glContext.ONE
|
|
7525
|
+
];
|
|
7526
|
+
break;
|
|
7527
|
+
case BlendingMode.SUBTRACTION:
|
|
7528
|
+
material.blendFunction = [
|
|
7529
|
+
glContext.ONE,
|
|
7530
|
+
glContext.ONE,
|
|
7531
|
+
glContext.ZERO,
|
|
7532
|
+
glContext.ONE
|
|
7533
|
+
];
|
|
7534
|
+
material.blendEquation = [
|
|
7535
|
+
glContext.FUNC_REVERSE_SUBTRACT,
|
|
7536
|
+
glContext.FUNC_REVERSE_SUBTRACT
|
|
7537
|
+
];
|
|
7538
|
+
break;
|
|
7539
|
+
case BlendingMode.SUPERPOSITION:
|
|
7540
|
+
material.blendFunction = [
|
|
7541
|
+
glContext.ONE,
|
|
7542
|
+
glContext.ONE,
|
|
7543
|
+
glContext.ONE,
|
|
7544
|
+
glContext.ONE
|
|
7545
|
+
];
|
|
7546
|
+
break;
|
|
7547
|
+
case BlendingMode.MULTIPLY:
|
|
7548
|
+
material.blendFunction = [
|
|
7549
|
+
glContext.DST_COLOR,
|
|
7550
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7551
|
+
glContext.DST_COLOR,
|
|
7552
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7553
|
+
];
|
|
7554
|
+
break;
|
|
7555
|
+
case BlendingMode.BRIGHTNESS:
|
|
7556
|
+
material.blendFunction = [
|
|
7557
|
+
glContext.ONE,
|
|
7558
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7559
|
+
glContext.ONE,
|
|
7560
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7561
|
+
];
|
|
7562
|
+
break;
|
|
7563
|
+
case BlendingMode.STRONG_LIGHT:
|
|
7564
|
+
material.blendFunction = [
|
|
7565
|
+
glContext.DST_COLOR,
|
|
7566
|
+
glContext.DST_ALPHA,
|
|
7567
|
+
glContext.ZERO,
|
|
7568
|
+
glContext.ONE
|
|
7569
|
+
];
|
|
7570
|
+
break;
|
|
7571
|
+
case BlendingMode.WEAK_LIGHT:
|
|
7572
|
+
material.blendFunction = [
|
|
7573
|
+
glContext.DST_COLOR,
|
|
7574
|
+
glContext.ZERO,
|
|
7575
|
+
glContext.ZERO,
|
|
7576
|
+
glContext.ONE
|
|
7577
|
+
];
|
|
7578
|
+
break;
|
|
7579
|
+
default:
|
|
7580
|
+
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
7581
|
+
}
|
|
7582
|
+
}
|
|
7583
|
+
function setSideMode(material, side) {
|
|
7584
|
+
if (side === SideMode.DOUBLE) {
|
|
7585
|
+
material.culling = false;
|
|
7586
|
+
} else {
|
|
7587
|
+
material.culling = true;
|
|
7588
|
+
material.frontFace = glContext.CW;
|
|
7589
|
+
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
function setMaskMode(material, maskMode) {
|
|
7593
|
+
switch(maskMode){
|
|
7594
|
+
case undefined:
|
|
7595
|
+
material.stencilTest = false;
|
|
7596
|
+
break;
|
|
7597
|
+
case exports.MaskMode.MASK:
|
|
7598
|
+
material.stencilTest = true;
|
|
7599
|
+
material.stencilFunc = [
|
|
7600
|
+
glContext.ALWAYS,
|
|
7601
|
+
glContext.ALWAYS
|
|
7602
|
+
];
|
|
7603
|
+
material.stencilOpZPass = [
|
|
7604
|
+
glContext.REPLACE,
|
|
7605
|
+
glContext.REPLACE
|
|
7606
|
+
];
|
|
7607
|
+
break;
|
|
7608
|
+
case exports.MaskMode.OBSCURED:
|
|
7609
|
+
material.stencilTest = true;
|
|
7610
|
+
material.stencilFunc = [
|
|
7611
|
+
glContext.EQUAL,
|
|
7612
|
+
glContext.EQUAL
|
|
7613
|
+
];
|
|
7614
|
+
break;
|
|
7615
|
+
case exports.MaskMode.REVERSE_OBSCURED:
|
|
7616
|
+
material.stencilTest = true;
|
|
7617
|
+
material.stencilFunc = [
|
|
7618
|
+
glContext.NOTEQUAL,
|
|
7619
|
+
glContext.NOTEQUAL
|
|
7620
|
+
];
|
|
7621
|
+
break;
|
|
7622
|
+
case exports.MaskMode.NONE:
|
|
7623
|
+
material.stencilTest = false;
|
|
7624
|
+
break;
|
|
7625
|
+
default:
|
|
7626
|
+
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
7627
|
+
}
|
|
7628
|
+
}
|
|
7629
|
+
|
|
7301
7630
|
/**
|
|
7302
7631
|
* Mesh 组件
|
|
7303
7632
|
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
7304
7633
|
_inherits(MeshComponent, RendererComponent);
|
|
7305
|
-
function MeshComponent() {
|
|
7634
|
+
function MeshComponent(engine) {
|
|
7306
7635
|
var _this;
|
|
7307
|
-
_this = RendererComponent.
|
|
7636
|
+
_this = RendererComponent.call(this, engine) || this;
|
|
7308
7637
|
/**
|
|
7309
7638
|
* 用于点击测试的碰撞器
|
|
7310
7639
|
*/ _this.meshCollider = new MeshCollider();
|
|
@@ -7320,6 +7649,7 @@ __decorate([
|
|
|
7320
7649
|
};
|
|
7321
7650
|
}
|
|
7322
7651
|
};
|
|
7652
|
+
_this.maskManager = new MaskProcessor(engine);
|
|
7323
7653
|
return _this;
|
|
7324
7654
|
}
|
|
7325
7655
|
var _proto = MeshComponent.prototype;
|
|
@@ -7329,12 +7659,42 @@ __decorate([
|
|
|
7329
7659
|
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
7330
7660
|
}
|
|
7331
7661
|
};
|
|
7662
|
+
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
7663
|
+
if (!this.isActiveAndEnabled) {
|
|
7664
|
+
return;
|
|
7665
|
+
}
|
|
7666
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
7667
|
+
var material = this.materials[i];
|
|
7668
|
+
var previousColorMask = material.colorMask;
|
|
7669
|
+
material.colorMask = false;
|
|
7670
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
7671
|
+
material.colorMask = previousColorMask;
|
|
7672
|
+
}
|
|
7673
|
+
};
|
|
7332
7674
|
_proto.getBoundingBox = function getBoundingBox() {
|
|
7333
7675
|
var worldMatrix = this.transform.getWorldMatrix();
|
|
7334
7676
|
this.meshCollider.setGeometry(this.geometry, worldMatrix);
|
|
7335
7677
|
var boundingBox = this.meshCollider.getBoundingBox();
|
|
7336
7678
|
return boundingBox;
|
|
7337
7679
|
};
|
|
7680
|
+
// TODO: Update data spec
|
|
7681
|
+
_proto.fromData = function fromData(data) {
|
|
7682
|
+
RendererComponent.prototype.fromData.call(this, data);
|
|
7683
|
+
var maskableRendererData = data;
|
|
7684
|
+
var maskOptions = maskableRendererData.mask;
|
|
7685
|
+
if (maskOptions) {
|
|
7686
|
+
this.maskManager.setMaskOptions(maskOptions);
|
|
7687
|
+
}
|
|
7688
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
|
|
7689
|
+
var material = _step.value;
|
|
7690
|
+
var stencilRef = this.maskManager.getRefValue();
|
|
7691
|
+
material.stencilRef = [
|
|
7692
|
+
stencilRef,
|
|
7693
|
+
stencilRef
|
|
7694
|
+
];
|
|
7695
|
+
setMaskMode(material, this.maskManager.maskMode);
|
|
7696
|
+
}
|
|
7697
|
+
};
|
|
7338
7698
|
return MeshComponent;
|
|
7339
7699
|
}(RendererComponent);
|
|
7340
7700
|
__decorate([
|
|
@@ -8524,348 +8884,6 @@ Matrix4.tempVec1 = new Vector3();
|
|
|
8524
8884
|
Matrix4.tempVec2 = new Vector3();
|
|
8525
8885
|
Matrix4.tempMat0 = new Matrix4();
|
|
8526
8886
|
|
|
8527
|
-
/**
|
|
8528
|
-
* Helper class to create a WebGL Context
|
|
8529
|
-
*
|
|
8530
|
-
* @param canvas
|
|
8531
|
-
* @param glType
|
|
8532
|
-
* @param options
|
|
8533
|
-
* @returns
|
|
8534
|
-
*/ function createGLContext(canvas, glType, options) {
|
|
8535
|
-
if (glType === void 0) glType = "webgl";
|
|
8536
|
-
var context;
|
|
8537
|
-
if (glType === "webgl2") {
|
|
8538
|
-
context = canvas.getContext("webgl2", options);
|
|
8539
|
-
if (!context) {
|
|
8540
|
-
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
8541
|
-
}
|
|
8542
|
-
}
|
|
8543
|
-
if (!context || glType === "webgl") {
|
|
8544
|
-
context = canvas.getContext("webgl", options);
|
|
8545
|
-
}
|
|
8546
|
-
if (!context) {
|
|
8547
|
-
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
8548
|
-
}
|
|
8549
|
-
return context;
|
|
8550
|
-
}
|
|
8551
|
-
|
|
8552
|
-
function gpuTimer(gl) {
|
|
8553
|
-
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
8554
|
-
if (ext) {
|
|
8555
|
-
var query = gl.createQuery();
|
|
8556
|
-
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
8557
|
-
return __generator(this, function(_state) {
|
|
8558
|
-
return [
|
|
8559
|
-
2,
|
|
8560
|
-
new Promise(function(resolve, reject) {
|
|
8561
|
-
if (query) {
|
|
8562
|
-
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
8563
|
-
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
8564
|
-
if (available && !disjoint) {
|
|
8565
|
-
// See how much time the rendering of the object took in nanoseconds.
|
|
8566
|
-
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
8567
|
-
// taken to use all significant bits of the result, not just the
|
|
8568
|
-
// least significant 32 bits.
|
|
8569
|
-
resolve(timeElapsed / 1000 / 1000);
|
|
8570
|
-
}
|
|
8571
|
-
if (available || disjoint) {
|
|
8572
|
-
// Clean up the query object.
|
|
8573
|
-
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
8574
|
-
query = null;
|
|
8575
|
-
}
|
|
8576
|
-
available !== null && query && window.setTimeout(function() {
|
|
8577
|
-
getTime().then(resolve).catch;
|
|
8578
|
-
}, 1);
|
|
8579
|
-
}
|
|
8580
|
-
})
|
|
8581
|
-
];
|
|
8582
|
-
});
|
|
8583
|
-
});
|
|
8584
|
-
if (!query) {
|
|
8585
|
-
return;
|
|
8586
|
-
}
|
|
8587
|
-
return {
|
|
8588
|
-
begin: function() {
|
|
8589
|
-
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
8590
|
-
},
|
|
8591
|
-
end: function() {
|
|
8592
|
-
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
8593
|
-
},
|
|
8594
|
-
getTime: getTime
|
|
8595
|
-
};
|
|
8596
|
-
}
|
|
8597
|
-
}
|
|
8598
|
-
|
|
8599
|
-
var initErrors = [];
|
|
8600
|
-
var glContext = {};
|
|
8601
|
-
var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
|
|
8602
|
-
var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
|
|
8603
|
-
if (!initErrors.length) {
|
|
8604
|
-
initGLContext();
|
|
8605
|
-
}
|
|
8606
|
-
function initGLContext() {
|
|
8607
|
-
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
8608
|
-
if (typeof WebGL2RenderingContext === "function") {
|
|
8609
|
-
copy(WebGL2RenderingContext);
|
|
8610
|
-
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
8611
|
-
copy(WebGLRenderingContext);
|
|
8612
|
-
copy(WebGLRenderingContext.prototype);
|
|
8613
|
-
} else {
|
|
8614
|
-
if (canUseBOM) {
|
|
8615
|
-
initErrors.push(// iOS 16 lockdown mode
|
|
8616
|
-
isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
8617
|
-
} else {
|
|
8618
|
-
initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
8619
|
-
}
|
|
8620
|
-
}
|
|
8621
|
-
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
8622
|
-
// @ts-expect-error set default value
|
|
8623
|
-
glContext["HALF_FLOAT"] = 5131;
|
|
8624
|
-
}
|
|
8625
|
-
}
|
|
8626
|
-
function isWebGL2(gl) {
|
|
8627
|
-
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
8628
|
-
}
|
|
8629
|
-
function copy(target) {
|
|
8630
|
-
for(var name in target){
|
|
8631
|
-
if (/^[A-Z_]/.test(name)) {
|
|
8632
|
-
// @ts-expect-error safe to assign
|
|
8633
|
-
glContext[name] = target[name];
|
|
8634
|
-
}
|
|
8635
|
-
}
|
|
8636
|
-
}
|
|
8637
|
-
function vertexFormatType2GLType(formatType) {
|
|
8638
|
-
switch(formatType){
|
|
8639
|
-
case VertexFormatType.Float32:
|
|
8640
|
-
return WebGLRenderingContext["FLOAT"];
|
|
8641
|
-
case VertexFormatType.Int16:
|
|
8642
|
-
return WebGLRenderingContext["SHORT"];
|
|
8643
|
-
case VertexFormatType.Int8:
|
|
8644
|
-
return WebGLRenderingContext["BYTE"];
|
|
8645
|
-
case VertexFormatType.UInt16:
|
|
8646
|
-
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
8647
|
-
case VertexFormatType.UInt8:
|
|
8648
|
-
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
8649
|
-
default:
|
|
8650
|
-
return WebGLRenderingContext["FLOAT"];
|
|
8651
|
-
}
|
|
8652
|
-
}
|
|
8653
|
-
function glType2VertexFormatType(webglType) {
|
|
8654
|
-
switch(webglType){
|
|
8655
|
-
case WebGLRenderingContext["FLOAT"]:
|
|
8656
|
-
return VertexFormatType.Float32;
|
|
8657
|
-
case WebGLRenderingContext["SHORT"]:
|
|
8658
|
-
return VertexFormatType.Int16;
|
|
8659
|
-
case WebGLRenderingContext["BYTE"]:
|
|
8660
|
-
return VertexFormatType.Int8;
|
|
8661
|
-
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
8662
|
-
return VertexFormatType.UInt16;
|
|
8663
|
-
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
8664
|
-
return VertexFormatType.UInt8;
|
|
8665
|
-
default:
|
|
8666
|
-
return VertexFormatType.Float32;
|
|
8667
|
-
}
|
|
8668
|
-
}
|
|
8669
|
-
|
|
8670
|
-
exports.ShaderType = void 0;
|
|
8671
|
-
(function(ShaderType) {
|
|
8672
|
-
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
8673
|
-
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
8674
|
-
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
8675
|
-
exports.MaskMode = void 0;
|
|
8676
|
-
(function(MaskMode) {
|
|
8677
|
-
/**
|
|
8678
|
-
* 无
|
|
8679
|
-
*/ MaskMode[MaskMode["NONE"] = 0] = "NONE";
|
|
8680
|
-
/**
|
|
8681
|
-
* 蒙版
|
|
8682
|
-
*/ MaskMode[MaskMode["MASK"] = 1] = "MASK";
|
|
8683
|
-
/**
|
|
8684
|
-
* 被遮挡
|
|
8685
|
-
*/ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
|
|
8686
|
-
/**
|
|
8687
|
-
* 被反向遮挡
|
|
8688
|
-
*/ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
|
|
8689
|
-
})(exports.MaskMode || (exports.MaskMode = {}));
|
|
8690
|
-
|
|
8691
|
-
function valIfUndefined(val, def) {
|
|
8692
|
-
if (val === undefined || val === null) {
|
|
8693
|
-
return def;
|
|
8694
|
-
}
|
|
8695
|
-
return val;
|
|
8696
|
-
}
|
|
8697
|
-
function getPreMultiAlpha(blending) {
|
|
8698
|
-
switch(blending){
|
|
8699
|
-
case BlendingMode.ALPHA:
|
|
8700
|
-
return 1;
|
|
8701
|
-
case BlendingMode.ADD:
|
|
8702
|
-
return 1;
|
|
8703
|
-
case BlendingMode.SUBTRACTION:
|
|
8704
|
-
return 1;
|
|
8705
|
-
case BlendingMode.STRONG_LIGHT:
|
|
8706
|
-
return 1;
|
|
8707
|
-
case BlendingMode.WEAK_LIGHT:
|
|
8708
|
-
return 1;
|
|
8709
|
-
case BlendingMode.SUPERPOSITION:
|
|
8710
|
-
return 2;
|
|
8711
|
-
case BlendingMode.BRIGHTNESS:
|
|
8712
|
-
return 3;
|
|
8713
|
-
case BlendingMode.MULTIPLY:
|
|
8714
|
-
return 0;
|
|
8715
|
-
default:
|
|
8716
|
-
// 处理undefined
|
|
8717
|
-
return 1;
|
|
8718
|
-
}
|
|
8719
|
-
}
|
|
8720
|
-
function setBlendMode(material, blendMode) {
|
|
8721
|
-
switch(blendMode){
|
|
8722
|
-
case undefined:
|
|
8723
|
-
material.blendFunction = [
|
|
8724
|
-
glContext.ONE,
|
|
8725
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8726
|
-
glContext.ONE,
|
|
8727
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8728
|
-
];
|
|
8729
|
-
break;
|
|
8730
|
-
case BlendingMode.ALPHA:
|
|
8731
|
-
material.blendFunction = [
|
|
8732
|
-
glContext.ONE,
|
|
8733
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8734
|
-
glContext.ONE,
|
|
8735
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8736
|
-
];
|
|
8737
|
-
break;
|
|
8738
|
-
case BlendingMode.ADD:
|
|
8739
|
-
material.blendFunction = [
|
|
8740
|
-
glContext.ONE,
|
|
8741
|
-
glContext.ONE,
|
|
8742
|
-
glContext.ONE,
|
|
8743
|
-
glContext.ONE
|
|
8744
|
-
];
|
|
8745
|
-
break;
|
|
8746
|
-
case BlendingMode.SUBTRACTION:
|
|
8747
|
-
material.blendFunction = [
|
|
8748
|
-
glContext.ONE,
|
|
8749
|
-
glContext.ONE,
|
|
8750
|
-
glContext.ZERO,
|
|
8751
|
-
glContext.ONE
|
|
8752
|
-
];
|
|
8753
|
-
material.blendEquation = [
|
|
8754
|
-
glContext.FUNC_REVERSE_SUBTRACT,
|
|
8755
|
-
glContext.FUNC_REVERSE_SUBTRACT
|
|
8756
|
-
];
|
|
8757
|
-
break;
|
|
8758
|
-
case BlendingMode.SUPERPOSITION:
|
|
8759
|
-
material.blendFunction = [
|
|
8760
|
-
glContext.ONE,
|
|
8761
|
-
glContext.ONE,
|
|
8762
|
-
glContext.ONE,
|
|
8763
|
-
glContext.ONE
|
|
8764
|
-
];
|
|
8765
|
-
break;
|
|
8766
|
-
case BlendingMode.MULTIPLY:
|
|
8767
|
-
material.blendFunction = [
|
|
8768
|
-
glContext.DST_COLOR,
|
|
8769
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8770
|
-
glContext.DST_COLOR,
|
|
8771
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8772
|
-
];
|
|
8773
|
-
break;
|
|
8774
|
-
case BlendingMode.BRIGHTNESS:
|
|
8775
|
-
material.blendFunction = [
|
|
8776
|
-
glContext.ONE,
|
|
8777
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8778
|
-
glContext.ONE,
|
|
8779
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8780
|
-
];
|
|
8781
|
-
break;
|
|
8782
|
-
case BlendingMode.STRONG_LIGHT:
|
|
8783
|
-
material.blendFunction = [
|
|
8784
|
-
glContext.DST_COLOR,
|
|
8785
|
-
glContext.DST_ALPHA,
|
|
8786
|
-
glContext.ZERO,
|
|
8787
|
-
glContext.ONE
|
|
8788
|
-
];
|
|
8789
|
-
break;
|
|
8790
|
-
case BlendingMode.WEAK_LIGHT:
|
|
8791
|
-
material.blendFunction = [
|
|
8792
|
-
glContext.DST_COLOR,
|
|
8793
|
-
glContext.ZERO,
|
|
8794
|
-
glContext.ZERO,
|
|
8795
|
-
glContext.ONE
|
|
8796
|
-
];
|
|
8797
|
-
break;
|
|
8798
|
-
default:
|
|
8799
|
-
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
8800
|
-
}
|
|
8801
|
-
}
|
|
8802
|
-
function setSideMode(material, side) {
|
|
8803
|
-
if (side === SideMode.DOUBLE) {
|
|
8804
|
-
material.culling = false;
|
|
8805
|
-
} else {
|
|
8806
|
-
material.culling = true;
|
|
8807
|
-
material.frontFace = glContext.CW;
|
|
8808
|
-
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
8809
|
-
}
|
|
8810
|
-
}
|
|
8811
|
-
function setMaskMode(material, maskMode) {
|
|
8812
|
-
switch(maskMode){
|
|
8813
|
-
case undefined:
|
|
8814
|
-
material.stencilTest = false;
|
|
8815
|
-
break;
|
|
8816
|
-
case exports.MaskMode.MASK:
|
|
8817
|
-
material.stencilTest = true;
|
|
8818
|
-
material.stencilFunc = [
|
|
8819
|
-
glContext.ALWAYS,
|
|
8820
|
-
glContext.ALWAYS
|
|
8821
|
-
];
|
|
8822
|
-
material.stencilOpZPass = [
|
|
8823
|
-
glContext.REPLACE,
|
|
8824
|
-
glContext.REPLACE
|
|
8825
|
-
];
|
|
8826
|
-
break;
|
|
8827
|
-
case exports.MaskMode.OBSCURED:
|
|
8828
|
-
material.stencilTest = true;
|
|
8829
|
-
material.stencilFunc = [
|
|
8830
|
-
glContext.EQUAL,
|
|
8831
|
-
glContext.EQUAL
|
|
8832
|
-
];
|
|
8833
|
-
break;
|
|
8834
|
-
case exports.MaskMode.REVERSE_OBSCURED:
|
|
8835
|
-
material.stencilTest = true;
|
|
8836
|
-
material.stencilFunc = [
|
|
8837
|
-
glContext.NOTEQUAL,
|
|
8838
|
-
glContext.NOTEQUAL
|
|
8839
|
-
];
|
|
8840
|
-
break;
|
|
8841
|
-
case exports.MaskMode.NONE:
|
|
8842
|
-
material.stencilTest = false;
|
|
8843
|
-
break;
|
|
8844
|
-
default:
|
|
8845
|
-
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
8846
|
-
}
|
|
8847
|
-
}
|
|
8848
|
-
|
|
8849
|
-
exports.TextureLoadAction = void 0;
|
|
8850
|
-
(function(TextureLoadAction) {
|
|
8851
|
-
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
8852
|
-
//preserve previous attachment
|
|
8853
|
-
//load = 1,
|
|
8854
|
-
//clear attachment
|
|
8855
|
-
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
8856
|
-
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
8857
|
-
exports.TextureSourceType = void 0;
|
|
8858
|
-
(function(TextureSourceType) {
|
|
8859
|
-
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
8860
|
-
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
8861
|
-
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
8862
|
-
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
8863
|
-
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
8864
|
-
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
8865
|
-
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
8866
|
-
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
8867
|
-
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
8868
|
-
|
|
8869
8887
|
/**
|
|
8870
8888
|
* 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
|
|
8871
8889
|
*/ var Downloader = /*#__PURE__*/ function() {
|
|
@@ -10344,208 +10362,72 @@ exports.MaterialRenderType = void 0;
|
|
|
10344
10362
|
return Material;
|
|
10345
10363
|
}(EffectsObject);
|
|
10346
10364
|
|
|
10347
|
-
var
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10365
|
+
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10366
|
+
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10367
|
+
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}";
|
|
10368
|
+
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";
|
|
10369
|
+
|
|
10370
|
+
exports.FilterMode = void 0;
|
|
10371
|
+
(function(FilterMode) {
|
|
10372
|
+
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
10373
|
+
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
10374
|
+
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
10375
|
+
exports.RenderTextureFormat = void 0;
|
|
10376
|
+
(function(RenderTextureFormat) {
|
|
10377
|
+
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
10378
|
+
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
10379
|
+
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
10380
|
+
/**
|
|
10381
|
+
*
|
|
10382
|
+
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
10383
|
+
function Framebuffer() {}
|
|
10384
|
+
var _proto = Framebuffer.prototype;
|
|
10385
|
+
_proto.resize = function resize(x, y, width, height) {
|
|
10386
|
+
// OVERRIDE
|
|
10360
10387
|
};
|
|
10361
|
-
_proto.
|
|
10362
|
-
|
|
10363
|
-
this.alphaMaskEnabled = alphaMaskEnabled;
|
|
10364
|
-
if (isMask) {
|
|
10365
|
-
this.maskMode = exports.MaskMode.MASK;
|
|
10366
|
-
} else {
|
|
10367
|
-
this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
|
|
10368
|
-
this.maskable = this.engine.findObject(reference);
|
|
10369
|
-
}
|
|
10388
|
+
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
10389
|
+
// OVERRIDE
|
|
10370
10390
|
};
|
|
10371
|
-
_proto.
|
|
10372
|
-
|
|
10373
|
-
renderer.clear(this.stencilClearAction);
|
|
10374
|
-
this.maskable.drawStencilMask(renderer);
|
|
10375
|
-
}
|
|
10391
|
+
_proto.unbind = function unbind() {
|
|
10392
|
+
// OVERRIDE
|
|
10376
10393
|
};
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
exports.ShaderCompileResultStatus = void 0;
|
|
10381
|
-
(function(ShaderCompileResultStatus) {
|
|
10382
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10383
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10384
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10385
|
-
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10386
|
-
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10387
|
-
exports.GLSLVersion = void 0;
|
|
10388
|
-
(function(GLSLVersion) {
|
|
10389
|
-
GLSLVersion["GLSL1"] = "100";
|
|
10390
|
-
GLSLVersion["GLSL3"] = "300 es";
|
|
10391
|
-
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10392
|
-
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10393
|
-
_inherits(ShaderVariant, EffectsObject);
|
|
10394
|
-
function ShaderVariant(engine, source) {
|
|
10395
|
-
var _this;
|
|
10396
|
-
_this = EffectsObject.call(this, engine) || this;
|
|
10397
|
-
_this.source = source;
|
|
10398
|
-
return _this;
|
|
10399
|
-
}
|
|
10400
|
-
return ShaderVariant;
|
|
10401
|
-
}(EffectsObject);
|
|
10402
|
-
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10403
|
-
_inherits(Shader, EffectsObject);
|
|
10404
|
-
function Shader() {
|
|
10405
|
-
return EffectsObject.apply(this, arguments);
|
|
10406
|
-
}
|
|
10407
|
-
var _proto = Shader.prototype;
|
|
10408
|
-
_proto.createVariant = function createVariant(macros) {
|
|
10409
|
-
var shaderMacros = [];
|
|
10410
|
-
if (macros) {
|
|
10411
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10412
|
-
var key = _step.value;
|
|
10413
|
-
shaderMacros.push([
|
|
10414
|
-
key,
|
|
10415
|
-
macros[key]
|
|
10416
|
-
]);
|
|
10417
|
-
}
|
|
10418
|
-
}
|
|
10419
|
-
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10420
|
-
shaderVariant.shader = this;
|
|
10421
|
-
return shaderVariant;
|
|
10394
|
+
_proto.bind = function bind() {
|
|
10395
|
+
// OVERRIDE
|
|
10422
10396
|
};
|
|
10423
|
-
_proto.
|
|
10424
|
-
|
|
10425
|
-
|
|
10397
|
+
_proto.getDepthTexture = function getDepthTexture() {
|
|
10398
|
+
// OVERRIDE
|
|
10399
|
+
return undefined;
|
|
10426
10400
|
};
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
effectsClass(DataType.Shader)
|
|
10431
|
-
], exports.Shader);
|
|
10432
|
-
|
|
10433
|
-
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10434
|
-
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10435
|
-
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}";
|
|
10436
|
-
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";
|
|
10437
|
-
function createCopyShader(level, writeDepth) {
|
|
10438
|
-
var webgl2 = level === 2;
|
|
10439
|
-
return {
|
|
10440
|
-
name: EFFECTS_COPY_MESH_NAME,
|
|
10441
|
-
vertex: COPY_VERTEX_SHADER,
|
|
10442
|
-
fragment: COPY_FRAGMENT_SHADER,
|
|
10443
|
-
glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
|
|
10444
|
-
macros: [
|
|
10445
|
-
[
|
|
10446
|
-
"DEPTH_TEXTURE",
|
|
10447
|
-
!!writeDepth
|
|
10448
|
-
]
|
|
10449
|
-
],
|
|
10450
|
-
// @ts-expect-error
|
|
10451
|
-
cacheId: COPY_MESH_SHADER_ID + +writeDepth
|
|
10401
|
+
_proto.getStencilTexture = function getStencilTexture() {
|
|
10402
|
+
// OVERRIDE
|
|
10403
|
+
return undefined;
|
|
10452
10404
|
};
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
format: glContext.RGBA,
|
|
10457
|
-
type: glContext.UNSIGNED_BYTE,
|
|
10458
|
-
minFilter: glContext.LINEAR,
|
|
10459
|
-
magFilter: glContext.LINEAR,
|
|
10460
|
-
wrapS: glContext.CLAMP_TO_EDGE,
|
|
10461
|
-
wrapT: glContext.CLAMP_TO_EDGE
|
|
10462
|
-
};
|
|
10463
|
-
var disposeSymbol = Symbol("dispose");
|
|
10464
|
-
var PassTextureCache = /*#__PURE__*/ function() {
|
|
10465
|
-
function PassTextureCache(engine) {
|
|
10466
|
-
this.textureCache = {};
|
|
10467
|
-
this.textureRef = {};
|
|
10468
|
-
this.engine = engine;
|
|
10469
|
-
}
|
|
10470
|
-
var _proto = PassTextureCache.prototype;
|
|
10471
|
-
_proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
|
|
10472
|
-
var _this = this;
|
|
10473
|
-
var width = request.width, height = request.height, name = request.name;
|
|
10474
|
-
var options = {
|
|
10475
|
-
sourceType: exports.TextureSourceType.framebuffer,
|
|
10476
|
-
data: {
|
|
10477
|
-
width: width,
|
|
10478
|
-
height: height
|
|
10479
|
-
},
|
|
10480
|
-
name: name
|
|
10481
|
-
};
|
|
10482
|
-
var keys = [
|
|
10483
|
-
name
|
|
10484
|
-
];
|
|
10485
|
-
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
10486
|
-
var _request_name;
|
|
10487
|
-
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
10488
|
-
options[name] = value;
|
|
10489
|
-
keys.push(name, value);
|
|
10490
|
-
});
|
|
10491
|
-
var cacheId = keys.join(":");
|
|
10492
|
-
var tex = this.textureCache[cacheId];
|
|
10493
|
-
if (tex) {
|
|
10494
|
-
this.textureRef[cacheId]++;
|
|
10495
|
-
} else {
|
|
10496
|
-
var engine = this.engine;
|
|
10497
|
-
assertExist(engine);
|
|
10498
|
-
tex = Texture.create(engine, options);
|
|
10499
|
-
this.textureCache[cacheId] = tex;
|
|
10500
|
-
this.textureRef[cacheId] = 1;
|
|
10501
|
-
// @ts-expect-error
|
|
10502
|
-
tex[disposeSymbol] = tex.dispose;
|
|
10503
|
-
tex.dispose = function() {
|
|
10504
|
-
return _this.removeTexture(cacheId);
|
|
10505
|
-
};
|
|
10506
|
-
}
|
|
10507
|
-
return tex;
|
|
10405
|
+
_proto.getColorTextures = function getColorTextures() {
|
|
10406
|
+
// OVERRIDE
|
|
10407
|
+
return [];
|
|
10508
10408
|
};
|
|
10509
|
-
_proto.
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10409
|
+
_proto.dispose = function dispose(options) {
|
|
10410
|
+
// OVERRIDE
|
|
10411
|
+
};
|
|
10412
|
+
_create_class(Framebuffer, [
|
|
10413
|
+
{
|
|
10414
|
+
key: "stencilStorage",
|
|
10415
|
+
get: function get() {
|
|
10416
|
+
// OVERRIDE
|
|
10417
|
+
return undefined;
|
|
10514
10418
|
}
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
//
|
|
10520
|
-
|
|
10419
|
+
},
|
|
10420
|
+
{
|
|
10421
|
+
key: "depthStorage",
|
|
10422
|
+
get: function get() {
|
|
10423
|
+
// OVERRIDE
|
|
10424
|
+
return undefined;
|
|
10521
10425
|
}
|
|
10522
|
-
delete this.textureCache[id];
|
|
10523
|
-
delete this.textureRef[id];
|
|
10524
|
-
} else {
|
|
10525
|
-
this.textureRef[id] = refCount - 1;
|
|
10526
10426
|
}
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
var _this = this;
|
|
10530
|
-
Object.keys(this.textureCache).forEach(function(key) {
|
|
10531
|
-
var texture = _this.textureCache[key];
|
|
10532
|
-
// @ts-expect-error
|
|
10533
|
-
texture[disposeSymbol]();
|
|
10534
|
-
// @ts-expect-error
|
|
10535
|
-
texture.dispose = texture[disposeSymbol];
|
|
10536
|
-
});
|
|
10537
|
-
this.textureCache = {};
|
|
10538
|
-
this.textureRef = {};
|
|
10539
|
-
this.engine = undefined;
|
|
10540
|
-
};
|
|
10541
|
-
return PassTextureCache;
|
|
10427
|
+
]);
|
|
10428
|
+
return Framebuffer;
|
|
10542
10429
|
}();
|
|
10543
10430
|
|
|
10544
|
-
function _assert_this_initialized(self) {
|
|
10545
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
10546
|
-
return self;
|
|
10547
|
-
}
|
|
10548
|
-
|
|
10549
10431
|
var RenderPassPriorityPrepare = 0;
|
|
10550
10432
|
var RenderPassPriorityNormal = 1000;
|
|
10551
10433
|
var RenderPassPriorityPostprocess = 3000;
|
|
@@ -10555,7 +10437,7 @@ exports.RenderPassAttachmentStorageType = void 0;
|
|
|
10555
10437
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
|
|
10556
10438
|
//stencil 8 render buffer
|
|
10557
10439
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
|
|
10558
|
-
//
|
|
10440
|
+
//depth 16 render buffer
|
|
10559
10441
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
|
|
10560
10442
|
//depth 16 & stencil 8 render buffer
|
|
10561
10443
|
RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
|
|
@@ -10674,61 +10556,31 @@ var seed$8 = 1;
|
|
|
10674
10556
|
/**
|
|
10675
10557
|
* RenderPass 抽象类
|
|
10676
10558
|
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
10677
|
-
function RenderPass(renderer
|
|
10559
|
+
function RenderPass(renderer) {
|
|
10678
10560
|
/**
|
|
10679
10561
|
* 优先级
|
|
10680
10562
|
*/ this.priority = 0;
|
|
10681
10563
|
/**
|
|
10682
|
-
* ColorAttachment 数组
|
|
10683
|
-
*/ this.attachments = [];
|
|
10684
|
-
/**
|
|
10685
10564
|
* 名称
|
|
10686
10565
|
*/ this.name = "RenderPass" + seed$8++;
|
|
10687
10566
|
/**
|
|
10688
10567
|
* 包含的 Mesh 列表
|
|
10689
10568
|
*/ this.meshes = [];
|
|
10690
|
-
/**
|
|
10691
|
-
* Mesh 渲染顺序,按照优先级升序或降序
|
|
10692
|
-
*/ this.meshOrder = exports.OrderType.ascending;
|
|
10693
10569
|
this.disposed = false;
|
|
10694
|
-
this.
|
|
10695
|
-
var depthStencilAttachment = options.depthStencilAttachment;
|
|
10570
|
+
this.framebuffer = null;
|
|
10696
10571
|
this.renderer = renderer;
|
|
10697
|
-
this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
|
|
10698
|
-
this.storeAction = {
|
|
10699
|
-
colorAction: 0,
|
|
10700
|
-
depthAction: 0,
|
|
10701
|
-
stencilAction: 0
|
|
10702
|
-
};
|
|
10703
|
-
this.options = options;
|
|
10704
10572
|
}
|
|
10705
10573
|
var _proto = RenderPass.prototype;
|
|
10706
10574
|
_proto.addMesh = function addMesh(mesh) {
|
|
10707
|
-
addByOrder(this.meshes, mesh
|
|
10575
|
+
addByOrder(this.meshes, mesh);
|
|
10708
10576
|
};
|
|
10709
10577
|
_proto.removeMesh = function removeMesh(mesh) {
|
|
10710
10578
|
removeItem(this.meshes, mesh);
|
|
10711
10579
|
};
|
|
10712
|
-
_proto.setMeshes = function setMeshes(meshes) {
|
|
10713
|
-
var _this_meshes;
|
|
10714
|
-
this.meshes.length = 0;
|
|
10715
|
-
(_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
|
|
10716
|
-
0,
|
|
10717
|
-
0
|
|
10718
|
-
], meshes));
|
|
10719
|
-
sortByOrder(this.meshes, this.meshOrder);
|
|
10720
|
-
return this.meshes;
|
|
10721
|
-
};
|
|
10722
|
-
// TODO 所有pass在子类配置
|
|
10723
10580
|
/**
|
|
10724
10581
|
* 配置当前pass的RT,在每帧渲染前调用
|
|
10725
10582
|
*/ _proto.configure = function configure(renderer) {
|
|
10726
|
-
|
|
10727
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
10728
|
-
} else {
|
|
10729
|
-
var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
|
|
10730
|
-
renderer.setViewport(x, y, width, height);
|
|
10731
|
-
}
|
|
10583
|
+
// OVERRIDE
|
|
10732
10584
|
};
|
|
10733
10585
|
/**
|
|
10734
10586
|
* 执行当前pass,每帧调用一次
|
|
@@ -10736,66 +10588,10 @@ var seed$8 = 1;
|
|
|
10736
10588
|
// OVERRIDE
|
|
10737
10589
|
};
|
|
10738
10590
|
/**
|
|
10739
|
-
* 每帧所有的pass
|
|
10740
|
-
*/ _proto.
|
|
10591
|
+
* 每帧所有的pass渲染完后调用,用于清空临时的RT资源
|
|
10592
|
+
*/ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10741
10593
|
// OVERRIDE
|
|
10742
10594
|
};
|
|
10743
|
-
_proto._resetAttachments = function _resetAttachments() {
|
|
10744
|
-
var _this = this;
|
|
10745
|
-
var _options_attachments;
|
|
10746
|
-
var renderer = this.renderer;
|
|
10747
|
-
var options = this.options;
|
|
10748
|
-
if (this.attachments.length) {
|
|
10749
|
-
var _this_framebuffer;
|
|
10750
|
-
this.attachments.forEach(function(att) {
|
|
10751
|
-
return !att.externalTexture && att.dispose();
|
|
10752
|
-
});
|
|
10753
|
-
this.attachments.length = 0;
|
|
10754
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
|
|
10755
|
-
depthStencilAttachment: 2
|
|
10756
|
-
});
|
|
10757
|
-
this.framebuffer = null;
|
|
10758
|
-
}
|
|
10759
|
-
// renderpass 的 viewport 相关参数都需要动态的修改
|
|
10760
|
-
var viewport = [
|
|
10761
|
-
0,
|
|
10762
|
-
0,
|
|
10763
|
-
renderer.getWidth(),
|
|
10764
|
-
renderer.getHeight()
|
|
10765
|
-
];
|
|
10766
|
-
var size = [
|
|
10767
|
-
viewport[2],
|
|
10768
|
-
viewport[3]
|
|
10769
|
-
];
|
|
10770
|
-
var name = this.name;
|
|
10771
|
-
if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
|
|
10772
|
-
var attachments = options.attachments.map(function(attr, index) {
|
|
10773
|
-
var _attr_texture;
|
|
10774
|
-
var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
|
|
10775
|
-
size: size,
|
|
10776
|
-
name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
|
|
10777
|
-
}, attr));
|
|
10778
|
-
return attachment;
|
|
10779
|
-
});
|
|
10780
|
-
this.attachments = attachments;
|
|
10781
|
-
var framebuffer = Framebuffer.create({
|
|
10782
|
-
storeAction: this.storeAction,
|
|
10783
|
-
name: name,
|
|
10784
|
-
viewport: viewport,
|
|
10785
|
-
attachments: attachments.map(function(att) {
|
|
10786
|
-
return att.texture;
|
|
10787
|
-
}),
|
|
10788
|
-
depthStencilAttachment: options.depthStencilAttachment || {
|
|
10789
|
-
storageType: 0
|
|
10790
|
-
}
|
|
10791
|
-
}, renderer);
|
|
10792
|
-
framebuffer.bind();
|
|
10793
|
-
framebuffer.unbind();
|
|
10794
|
-
this.framebuffer = framebuffer;
|
|
10795
|
-
} else {
|
|
10796
|
-
this.attachments.length = 0;
|
|
10797
|
-
}
|
|
10798
|
-
};
|
|
10799
10595
|
/**
|
|
10800
10596
|
* 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
|
|
10801
10597
|
*/ _proto.getViewport = function getViewport() {
|
|
@@ -10818,68 +10614,6 @@ var seed$8 = 1;
|
|
|
10818
10614
|
];
|
|
10819
10615
|
};
|
|
10820
10616
|
/**
|
|
10821
|
-
* 获取深度 Attachment,可能没有
|
|
10822
|
-
*/ _proto.getDepthAttachment = function getDepthAttachment() {
|
|
10823
|
-
var framebuffer = this.framebuffer;
|
|
10824
|
-
if (framebuffer) {
|
|
10825
|
-
var depthTexture = framebuffer.getDepthTexture();
|
|
10826
|
-
var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
|
|
10827
|
-
return {
|
|
10828
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10829
|
-
storage: framebuffer.depthStorage,
|
|
10830
|
-
texture: texture
|
|
10831
|
-
};
|
|
10832
|
-
}
|
|
10833
|
-
};
|
|
10834
|
-
/**
|
|
10835
|
-
* 获取蒙版 Attachment,可能没有
|
|
10836
|
-
*/ _proto.getStencilAttachment = function getStencilAttachment() {
|
|
10837
|
-
var framebuffer = this.framebuffer;
|
|
10838
|
-
if (framebuffer) {
|
|
10839
|
-
var stencilTexture = framebuffer.getStencilTexture();
|
|
10840
|
-
var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
|
|
10841
|
-
return {
|
|
10842
|
-
storageType: framebuffer.depthStencilStorageType,
|
|
10843
|
-
storage: framebuffer.stencilStorage,
|
|
10844
|
-
texture: texture
|
|
10845
|
-
};
|
|
10846
|
-
}
|
|
10847
|
-
};
|
|
10848
|
-
_proto.getDepthTexture = function getDepthTexture(texture, external) {
|
|
10849
|
-
if (!this.depthTexture) {
|
|
10850
|
-
var _this_options_depthStencilAttachment;
|
|
10851
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10852
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10853
|
-
// TODO 为什么要initialize?
|
|
10854
|
-
//tex.initialize(this.renderer.engine);
|
|
10855
|
-
if (!external) {
|
|
10856
|
-
this.depthTexture = tex;
|
|
10857
|
-
}
|
|
10858
|
-
return tex;
|
|
10859
|
-
}
|
|
10860
|
-
return this.depthTexture;
|
|
10861
|
-
};
|
|
10862
|
-
_proto.getStencilTexture = function getStencilTexture(texture, external) {
|
|
10863
|
-
if (!this.stencilTexture) {
|
|
10864
|
-
var _this_options_depthStencilAttachment;
|
|
10865
|
-
var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
|
|
10866
|
-
var tex = texture === outTex ? outTex : texture;
|
|
10867
|
-
if (!external) {
|
|
10868
|
-
this.stencilTexture = tex;
|
|
10869
|
-
}
|
|
10870
|
-
return tex;
|
|
10871
|
-
}
|
|
10872
|
-
return this.stencilTexture;
|
|
10873
|
-
};
|
|
10874
|
-
// 生成并初始化帧缓冲
|
|
10875
|
-
_proto.initialize = function initialize(renderer) {
|
|
10876
|
-
if (!this.initialized) {
|
|
10877
|
-
this._resetAttachments();
|
|
10878
|
-
this.initialized = true;
|
|
10879
|
-
}
|
|
10880
|
-
return this;
|
|
10881
|
-
};
|
|
10882
|
-
/**
|
|
10883
10617
|
* 销毁 RenderPass
|
|
10884
10618
|
* @param options - 有选择销毁内部对象
|
|
10885
10619
|
*/ _proto.dispose = function dispose(options) {
|
|
@@ -10893,35 +10627,11 @@ var seed$8 = 1;
|
|
|
10893
10627
|
});
|
|
10894
10628
|
}
|
|
10895
10629
|
this.meshes.length = 0;
|
|
10896
|
-
var colorOpt = (options == null ? void 0 : options.colorAttachment) ? options.colorAttachment : 0;
|
|
10897
|
-
this.attachments.forEach(function(att) {
|
|
10898
|
-
var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
|
|
10899
|
-
if (!keep) {
|
|
10900
|
-
att.dispose();
|
|
10901
|
-
}
|
|
10902
|
-
});
|
|
10903
|
-
this.attachments.length = 0;
|
|
10904
10630
|
this.disposed = true;
|
|
10905
|
-
var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
|
|
10906
|
-
var fbo = this.framebuffer;
|
|
10907
|
-
if (fbo) {
|
|
10908
|
-
fbo.dispose({
|
|
10909
|
-
depthStencilAttachment: depthStencilOpt
|
|
10910
|
-
});
|
|
10911
|
-
var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
|
|
10912
|
-
if (!keep) {
|
|
10913
|
-
var _this_stencilTexture, _this_depthTexture;
|
|
10914
|
-
(_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
|
|
10915
|
-
(_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
|
|
10916
|
-
}
|
|
10917
|
-
}
|
|
10918
|
-
// @ts-expect-error safe to assign
|
|
10919
|
-
this.options = null;
|
|
10920
|
-
this.initialize = throwDestroyedError;
|
|
10921
10631
|
};
|
|
10922
10632
|
_create_class(RenderPass, [
|
|
10923
10633
|
{
|
|
10924
|
-
key: "
|
|
10634
|
+
key: "isDisposed",
|
|
10925
10635
|
get: function get() {
|
|
10926
10636
|
return this.disposed;
|
|
10927
10637
|
}
|
|
@@ -10931,18 +10641,6 @@ var seed$8 = 1;
|
|
|
10931
10641
|
get: function get() {
|
|
10932
10642
|
return this.getViewport();
|
|
10933
10643
|
}
|
|
10934
|
-
},
|
|
10935
|
-
{
|
|
10936
|
-
key: "stencilAttachment",
|
|
10937
|
-
get: function get() {
|
|
10938
|
-
return this.getStencilAttachment();
|
|
10939
|
-
}
|
|
10940
|
-
},
|
|
10941
|
-
{
|
|
10942
|
-
key: "depthAttachment",
|
|
10943
|
-
get: function get() {
|
|
10944
|
-
return this.getDepthAttachment();
|
|
10945
|
-
}
|
|
10946
10644
|
}
|
|
10947
10645
|
]);
|
|
10948
10646
|
return RenderPass;
|
|
@@ -10950,38 +10648,95 @@ var seed$8 = 1;
|
|
|
10950
10648
|
|
|
10951
10649
|
var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
10952
10650
|
_inherits(DrawObjectPass, RenderPass);
|
|
10953
|
-
function DrawObjectPass(renderer
|
|
10651
|
+
function DrawObjectPass(renderer) {
|
|
10954
10652
|
var _this;
|
|
10955
|
-
_this = RenderPass.call(this, renderer
|
|
10653
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
10654
|
+
_this.useRenderTarget = false;
|
|
10956
10655
|
_this.priority = RenderPassPriorityNormal;
|
|
10957
10656
|
_this.name = "DrawObjectPass";
|
|
10958
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
10959
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
10960
10657
|
return _this;
|
|
10961
10658
|
}
|
|
10962
10659
|
var _proto = DrawObjectPass.prototype;
|
|
10660
|
+
_proto.setup = function setup(useRenderTarget) {
|
|
10661
|
+
this.useRenderTarget = useRenderTarget;
|
|
10662
|
+
};
|
|
10663
|
+
_proto.configure = function configure(renderer) {
|
|
10664
|
+
if (this.useRenderTarget) {
|
|
10665
|
+
this.framebuffer = renderer.getTemporaryRT("DrawObjectPass", renderer.getWidth(), renderer.getHeight(), 16, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
10666
|
+
renderer.setFramebuffer(this.framebuffer);
|
|
10667
|
+
}
|
|
10668
|
+
};
|
|
10963
10669
|
_proto.execute = function execute(renderer) {
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10670
|
+
if (this.useRenderTarget) {
|
|
10671
|
+
renderer.clear({
|
|
10672
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
10673
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
10674
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
10675
|
+
});
|
|
10676
|
+
}
|
|
10969
10677
|
renderer.renderMeshes(this.meshes);
|
|
10970
|
-
renderer.clear(this.storeAction);
|
|
10971
|
-
};
|
|
10972
|
-
_proto.onResize = function onResize() {
|
|
10973
|
-
var _this_framebuffer;
|
|
10974
|
-
var width = this.renderer.getWidth();
|
|
10975
|
-
var height = this.renderer.getHeight();
|
|
10976
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
10977
10678
|
};
|
|
10978
|
-
_proto.
|
|
10979
|
-
this.
|
|
10980
|
-
|
|
10679
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
10680
|
+
if (this.useRenderTarget && this.framebuffer) {
|
|
10681
|
+
renderer.releaseTemporaryRT(this.framebuffer);
|
|
10682
|
+
}
|
|
10981
10683
|
};
|
|
10982
10684
|
return DrawObjectPass;
|
|
10983
10685
|
}(RenderPass);
|
|
10984
10686
|
|
|
10687
|
+
exports.ShaderCompileResultStatus = void 0;
|
|
10688
|
+
(function(ShaderCompileResultStatus) {
|
|
10689
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
|
|
10690
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
|
|
10691
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
|
|
10692
|
+
ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
|
|
10693
|
+
})(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
|
|
10694
|
+
exports.GLSLVersion = void 0;
|
|
10695
|
+
(function(GLSLVersion) {
|
|
10696
|
+
GLSLVersion["GLSL1"] = "100";
|
|
10697
|
+
GLSLVersion["GLSL3"] = "300 es";
|
|
10698
|
+
})(exports.GLSLVersion || (exports.GLSLVersion = {}));
|
|
10699
|
+
var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
|
|
10700
|
+
_inherits(ShaderVariant, EffectsObject);
|
|
10701
|
+
function ShaderVariant(engine, source) {
|
|
10702
|
+
var _this;
|
|
10703
|
+
_this = EffectsObject.call(this, engine) || this;
|
|
10704
|
+
_this.source = source;
|
|
10705
|
+
return _this;
|
|
10706
|
+
}
|
|
10707
|
+
return ShaderVariant;
|
|
10708
|
+
}(EffectsObject);
|
|
10709
|
+
exports.Shader = /*#__PURE__*/ function(EffectsObject) {
|
|
10710
|
+
_inherits(Shader, EffectsObject);
|
|
10711
|
+
function Shader() {
|
|
10712
|
+
return EffectsObject.apply(this, arguments);
|
|
10713
|
+
}
|
|
10714
|
+
var _proto = Shader.prototype;
|
|
10715
|
+
_proto.createVariant = function createVariant(macros) {
|
|
10716
|
+
var shaderMacros = [];
|
|
10717
|
+
if (macros) {
|
|
10718
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
|
|
10719
|
+
var key = _step.value;
|
|
10720
|
+
shaderMacros.push([
|
|
10721
|
+
key,
|
|
10722
|
+
macros[key]
|
|
10723
|
+
]);
|
|
10724
|
+
}
|
|
10725
|
+
}
|
|
10726
|
+
var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
|
|
10727
|
+
shaderVariant.shader = this;
|
|
10728
|
+
return shaderVariant;
|
|
10729
|
+
};
|
|
10730
|
+
_proto.fromData = function fromData(data) {
|
|
10731
|
+
EffectsObject.prototype.fromData.call(this, data);
|
|
10732
|
+
this.shaderData = data;
|
|
10733
|
+
};
|
|
10734
|
+
return Shader;
|
|
10735
|
+
}(EffectsObject);
|
|
10736
|
+
exports.Shader = __decorate([
|
|
10737
|
+
effectsClass(DataType.Shader)
|
|
10738
|
+
], exports.Shader);
|
|
10739
|
+
|
|
10985
10740
|
var _obj$6;
|
|
10986
10741
|
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);
|
|
10987
10742
|
/**
|
|
@@ -13020,272 +12775,138 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
13020
12775
|
return ShaderFactory;
|
|
13021
12776
|
}();
|
|
13022
12777
|
|
|
13023
|
-
// Bloom
|
|
13024
|
-
var
|
|
13025
|
-
_inherits(
|
|
13026
|
-
function
|
|
12778
|
+
// Bloom Pass - 包含阈值提取、高斯模糊(Down Sample 和 Up Sample)
|
|
12779
|
+
var BloomPass = /*#__PURE__*/ function(RenderPass) {
|
|
12780
|
+
_inherits(BloomPass, RenderPass);
|
|
12781
|
+
function BloomPass(renderer, iterationCount) {
|
|
12782
|
+
if (iterationCount === void 0) iterationCount = 4;
|
|
13027
12783
|
var _this;
|
|
13028
|
-
_this = RenderPass.call(this, renderer
|
|
12784
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
12785
|
+
_this.tempRTs = [];
|
|
12786
|
+
_this.iterationCount = iterationCount;
|
|
13029
12787
|
var engine = _this.renderer.engine;
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
attributes: {
|
|
13033
|
-
aPos: {
|
|
13034
|
-
type: glContext.FLOAT,
|
|
13035
|
-
size: 2,
|
|
13036
|
-
data: new Float32Array([
|
|
13037
|
-
-1,
|
|
13038
|
-
1,
|
|
13039
|
-
-1,
|
|
13040
|
-
-1,
|
|
13041
|
-
1,
|
|
13042
|
-
1,
|
|
13043
|
-
1,
|
|
13044
|
-
-1
|
|
13045
|
-
])
|
|
13046
|
-
}
|
|
13047
|
-
},
|
|
13048
|
-
drawCount: 4
|
|
13049
|
-
});
|
|
13050
|
-
var material = Material.create(engine, {
|
|
12788
|
+
// Threshold material
|
|
12789
|
+
_this.thresholdMaterial = Material.create(engine, {
|
|
13051
12790
|
shader: {
|
|
13052
12791
|
vertex: screenMeshVert,
|
|
13053
12792
|
fragment: thresholdFrag,
|
|
13054
12793
|
glslVersion: exports.GLSLVersion.GLSL1
|
|
13055
12794
|
}
|
|
13056
12795
|
});
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
12796
|
+
_this.thresholdMaterial.blending = false;
|
|
12797
|
+
_this.thresholdMaterial.depthTest = false;
|
|
12798
|
+
_this.thresholdMaterial.culling = false;
|
|
12799
|
+
// Down sample H material
|
|
12800
|
+
_this.downSampleHMaterial = Material.create(engine, {
|
|
12801
|
+
shader: {
|
|
12802
|
+
vertex: screenMeshVert,
|
|
12803
|
+
fragment: gaussianDownHFrag,
|
|
12804
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12805
|
+
}
|
|
13064
12806
|
});
|
|
12807
|
+
_this.downSampleHMaterial.blending = false;
|
|
12808
|
+
_this.downSampleHMaterial.depthTest = false;
|
|
12809
|
+
_this.downSampleHMaterial.culling = false;
|
|
12810
|
+
// Down sample V material
|
|
12811
|
+
_this.downSampleVMaterial = Material.create(engine, {
|
|
12812
|
+
shader: {
|
|
12813
|
+
vertex: screenMeshVert,
|
|
12814
|
+
fragment: gaussianDownVFrag,
|
|
12815
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12816
|
+
}
|
|
12817
|
+
});
|
|
12818
|
+
_this.downSampleVMaterial.blending = false;
|
|
12819
|
+
_this.downSampleVMaterial.depthTest = false;
|
|
12820
|
+
_this.downSampleVMaterial.culling = false;
|
|
12821
|
+
// Up sample material
|
|
12822
|
+
_this.upSampleMaterial = Material.create(engine, {
|
|
12823
|
+
shader: {
|
|
12824
|
+
vertex: screenMeshVert,
|
|
12825
|
+
fragment: gaussianUpFrag,
|
|
12826
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12827
|
+
}
|
|
12828
|
+
});
|
|
12829
|
+
_this.upSampleMaterial.blending = false;
|
|
12830
|
+
_this.upSampleMaterial.depthTest = false;
|
|
12831
|
+
_this.upSampleMaterial.culling = false;
|
|
13065
12832
|
_this.priority = 5000;
|
|
13066
|
-
_this.name = "
|
|
13067
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13068
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
12833
|
+
_this.name = "BloomPass";
|
|
13069
12834
|
return _this;
|
|
13070
12835
|
}
|
|
13071
|
-
var _proto =
|
|
12836
|
+
var _proto = BloomPass.prototype;
|
|
13072
12837
|
_proto.configure = function configure(renderer) {
|
|
12838
|
+
// 获取场景纹理用于 ToneMappingPass
|
|
13073
12839
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13074
12840
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
13075
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
13076
12841
|
};
|
|
13077
12842
|
_proto.execute = function execute(renderer) {
|
|
13078
12843
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
13079
|
-
renderer.
|
|
13080
|
-
|
|
13081
|
-
depthAction: exports.TextureStoreAction.clear,
|
|
13082
|
-
stencilAction: exports.TextureStoreAction.clear
|
|
13083
|
-
});
|
|
13084
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
12844
|
+
var baseWidth = renderer.getWidth();
|
|
12845
|
+
var baseHeight = renderer.getHeight();
|
|
13085
12846
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
12847
|
+
// 1. Threshold pass - 提取高亮区域
|
|
13086
12848
|
var threshold = (_renderer_renderingData_currentFrame_globalVolume_bloom_threshold = (_renderer_renderingData_currentFrame_globalVolume = renderer.renderingData.currentFrame.globalVolume) == null ? void 0 : (_renderer_renderingData_currentFrame_globalVolume_bloom = _renderer_renderingData_currentFrame_globalVolume.bloom) == null ? void 0 : _renderer_renderingData_currentFrame_globalVolume_bloom.threshold) != null ? _renderer_renderingData_currentFrame_globalVolume_bloom_threshold : 1.0;
|
|
13087
|
-
this.
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
]
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
var
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
drawCount: 4
|
|
13133
|
-
});
|
|
13134
|
-
var fragment = type === "H" ? gaussianDownHFrag : gaussianDownVFrag;
|
|
13135
|
-
var shader = {
|
|
13136
|
-
vertex: screenMeshVert,
|
|
13137
|
-
fragment: fragment,
|
|
13138
|
-
glslVersion: exports.GLSLVersion.GLSL1
|
|
13139
|
-
};
|
|
13140
|
-
var material = Material.create(engine, {
|
|
13141
|
-
name: name,
|
|
13142
|
-
shader: shader
|
|
13143
|
-
});
|
|
13144
|
-
material.blending = false;
|
|
13145
|
-
material.depthTest = false;
|
|
13146
|
-
material.culling = false;
|
|
13147
|
-
_this.screenMesh = Mesh.create(engine, {
|
|
13148
|
-
name: name,
|
|
13149
|
-
geometry: geometry,
|
|
13150
|
-
material: material,
|
|
13151
|
-
priority: 0
|
|
13152
|
-
});
|
|
13153
|
-
_this.priority = 5000;
|
|
13154
|
-
_this.name = "GaussianDownPass" + type + level;
|
|
13155
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13156
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13157
|
-
return _this;
|
|
13158
|
-
}
|
|
13159
|
-
var _proto = HQGaussianDownSamplePass.prototype;
|
|
13160
|
-
_proto.initialize = function initialize(renderer) {
|
|
13161
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13162
|
-
this.onResize();
|
|
13163
|
-
return this;
|
|
13164
|
-
};
|
|
13165
|
-
_proto.configure = function configure(renderer) {
|
|
13166
|
-
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13167
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
13168
|
-
};
|
|
13169
|
-
_proto.execute = function execute(renderer) {
|
|
13170
|
-
renderer.clear({
|
|
13171
|
-
colorAction: exports.TextureStoreAction.clear,
|
|
13172
|
-
depthAction: exports.TextureStoreAction.clear,
|
|
13173
|
-
stencilAction: exports.TextureStoreAction.clear
|
|
13174
|
-
});
|
|
13175
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13176
|
-
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
13177
|
-
renderer.renderMeshes([
|
|
13178
|
-
this.screenMesh
|
|
13179
|
-
]);
|
|
13180
|
-
if (this.type === "V") {
|
|
13181
|
-
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13182
|
-
}
|
|
13183
|
-
};
|
|
13184
|
-
_proto.onResize = function onResize() {
|
|
13185
|
-
var _this_framebuffer;
|
|
13186
|
-
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
|
|
13187
|
-
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
|
|
13188
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
13189
|
-
};
|
|
13190
|
-
_proto.dispose = function dispose(options) {
|
|
13191
|
-
this.renderer.engine.off("resize", this.onResize);
|
|
13192
|
-
RenderPass.prototype.dispose.call(this, options);
|
|
13193
|
-
};
|
|
13194
|
-
return HQGaussianDownSamplePass;
|
|
13195
|
-
}(RenderPass);
|
|
13196
|
-
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
13197
|
-
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
13198
|
-
function HQGaussianUpSamplePass(renderer, level, options) {
|
|
13199
|
-
var _this;
|
|
13200
|
-
_this = RenderPass.call(this, renderer, options) || this;
|
|
13201
|
-
_this.level = level;
|
|
13202
|
-
var name = "PostProcess";
|
|
13203
|
-
var engine = _this.renderer.engine;
|
|
13204
|
-
var geometry = Geometry.create(engine, {
|
|
13205
|
-
name: name,
|
|
13206
|
-
mode: glContext.TRIANGLE_STRIP,
|
|
13207
|
-
attributes: {
|
|
13208
|
-
aPos: {
|
|
13209
|
-
type: glContext.FLOAT,
|
|
13210
|
-
size: 2,
|
|
13211
|
-
data: new Float32Array([
|
|
13212
|
-
-1,
|
|
13213
|
-
1,
|
|
13214
|
-
-1,
|
|
13215
|
-
-1,
|
|
13216
|
-
1,
|
|
13217
|
-
1,
|
|
13218
|
-
1,
|
|
13219
|
-
-1
|
|
13220
|
-
])
|
|
13221
|
-
}
|
|
13222
|
-
},
|
|
13223
|
-
drawCount: 4
|
|
13224
|
-
});
|
|
13225
|
-
var shader = {
|
|
13226
|
-
vertex: screenMeshVert,
|
|
13227
|
-
fragment: gaussianUpFrag
|
|
13228
|
-
};
|
|
13229
|
-
var material = Material.create(engine, {
|
|
13230
|
-
name: name,
|
|
13231
|
-
shader: shader
|
|
13232
|
-
});
|
|
13233
|
-
material.blending = false;
|
|
13234
|
-
material.depthTest = false;
|
|
13235
|
-
material.culling = false;
|
|
13236
|
-
_this.screenMesh = Mesh.create(engine, {
|
|
13237
|
-
name: name,
|
|
13238
|
-
geometry: geometry,
|
|
13239
|
-
material: material,
|
|
13240
|
-
priority: 0
|
|
13241
|
-
});
|
|
13242
|
-
_this.priority = 5000;
|
|
13243
|
-
_this.name = "GaussianUpPass" + level;
|
|
13244
|
-
_this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
|
|
13245
|
-
_this.renderer.engine.on("resize", _this.onResize);
|
|
13246
|
-
return _this;
|
|
13247
|
-
}
|
|
13248
|
-
var _proto = HQGaussianUpSamplePass.prototype;
|
|
13249
|
-
_proto.initialize = function initialize(renderer) {
|
|
13250
|
-
RenderPass.prototype.initialize.call(this, renderer);
|
|
13251
|
-
this.onResize();
|
|
13252
|
-
return this;
|
|
13253
|
-
};
|
|
13254
|
-
_proto.configure = function configure(renderer) {
|
|
13255
|
-
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
13256
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
13257
|
-
};
|
|
13258
|
-
_proto.execute = function execute(renderer) {
|
|
13259
|
-
renderer.clear({
|
|
13260
|
-
colorAction: exports.TextureStoreAction.clear,
|
|
13261
|
-
depthAction: exports.TextureStoreAction.clear,
|
|
13262
|
-
stencilAction: exports.TextureStoreAction.clear
|
|
13263
|
-
});
|
|
13264
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
13265
|
-
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
13266
|
-
this.screenMesh.material.setVector2("_GaussianDownTextureSize", getTextureSize(this.gaussianDownSampleResult.texture));
|
|
13267
|
-
renderer.renderMeshes([
|
|
13268
|
-
this.screenMesh
|
|
13269
|
-
]);
|
|
13270
|
-
};
|
|
13271
|
-
_proto.onResize = function onResize() {
|
|
13272
|
-
var _this_framebuffer;
|
|
13273
|
-
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
|
|
13274
|
-
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
|
|
13275
|
-
(_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
|
|
12849
|
+
this.thresholdRT = renderer.getTemporaryRT("_BloomThreshold", baseWidth, baseHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12850
|
+
this.thresholdMaterial.setFloat("_Threshold", threshold);
|
|
12851
|
+
renderer.blit(this.mainTexture, this.thresholdRT, this.thresholdMaterial);
|
|
12852
|
+
var currentTexture = this.thresholdRT.getColorTextures()[0];
|
|
12853
|
+
// 2. Down sample passes
|
|
12854
|
+
for(var i = 0; i < this.iterationCount; i++){
|
|
12855
|
+
var downWidth = Math.floor(baseWidth / Math.pow(2, i + 1));
|
|
12856
|
+
var downHeight = Math.floor(baseHeight / Math.pow(2, i + 1));
|
|
12857
|
+
// Horizontal pass
|
|
12858
|
+
var tempH = renderer.getTemporaryRT("_BloomDownH" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12859
|
+
this.downSampleHMaterial.setVector2("_TextureSize", getTextureSize(currentTexture));
|
|
12860
|
+
renderer.blit(currentTexture, tempH, this.downSampleHMaterial);
|
|
12861
|
+
// Vertical pass
|
|
12862
|
+
var tempV = renderer.getTemporaryRT("_BloomDownV" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12863
|
+
this.downSampleVMaterial.setVector2("_TextureSize", getTextureSize(tempH.getColorTextures()[0]));
|
|
12864
|
+
renderer.blit(tempH.getColorTextures()[0], tempV, this.downSampleVMaterial);
|
|
12865
|
+
// 释放 H pass RT,保留 V pass RT 用于 up sample
|
|
12866
|
+
renderer.releaseTemporaryRT(tempH);
|
|
12867
|
+
this.tempRTs.push(tempV);
|
|
12868
|
+
currentTexture = tempV.getColorTextures()[0];
|
|
12869
|
+
}
|
|
12870
|
+
// 释放 threshold RT
|
|
12871
|
+
renderer.releaseTemporaryRT(this.thresholdRT);
|
|
12872
|
+
// 3. Up sample passes
|
|
12873
|
+
for(var i1 = this.iterationCount - 1; i1 > 0; i1--){
|
|
12874
|
+
var upWidth = Math.floor(baseWidth / Math.pow(2, i1 - 1));
|
|
12875
|
+
var upHeight = Math.floor(baseHeight / Math.pow(2, i1 - 1));
|
|
12876
|
+
var tempUp = renderer.getTemporaryRT("_BloomUp" + i1, upWidth, upHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12877
|
+
// 获取下一层的 down sample 结果
|
|
12878
|
+
var downSampleTexture = this.tempRTs[i1 - 1].getColorTextures()[0];
|
|
12879
|
+
this.upSampleMaterial.setTexture("_GaussianDownTex", downSampleTexture);
|
|
12880
|
+
this.upSampleMaterial.setVector2("_GaussianDownTextureSize", getTextureSize(downSampleTexture));
|
|
12881
|
+
renderer.blit(currentTexture, tempUp, this.upSampleMaterial);
|
|
12882
|
+
currentTexture = tempUp.getColorTextures()[0];
|
|
12883
|
+
this.tempRTs.push(tempUp);
|
|
12884
|
+
}
|
|
12885
|
+
// 设置最终输出到当前 framebuffer
|
|
12886
|
+
renderer.setFramebuffer(this.tempRTs[this.tempRTs.length - 1]);
|
|
12887
|
+
};
|
|
12888
|
+
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12889
|
+
// 释放所有临时 RT
|
|
12890
|
+
for(var i = 0; i < this.tempRTs.length; i++){
|
|
12891
|
+
renderer.releaseTemporaryRT(this.tempRTs[i]);
|
|
12892
|
+
}
|
|
12893
|
+
this.tempRTs = [];
|
|
13276
12894
|
};
|
|
13277
12895
|
_proto.dispose = function dispose(options) {
|
|
13278
|
-
this.
|
|
12896
|
+
this.thresholdMaterial.dispose();
|
|
12897
|
+
this.downSampleHMaterial.dispose();
|
|
12898
|
+
this.downSampleVMaterial.dispose();
|
|
12899
|
+
this.upSampleMaterial.dispose();
|
|
13279
12900
|
RenderPass.prototype.dispose.call(this, options);
|
|
13280
12901
|
};
|
|
13281
|
-
return
|
|
12902
|
+
return BloomPass;
|
|
13282
12903
|
}(RenderPass);
|
|
13283
12904
|
// 合并Bloom的高斯模糊结果,并应用ACES Tonemapping
|
|
13284
12905
|
var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
13285
12906
|
_inherits(ToneMappingPass, RenderPass);
|
|
13286
12907
|
function ToneMappingPass(renderer, sceneTextureHandle) {
|
|
13287
12908
|
var _this;
|
|
13288
|
-
_this = RenderPass.call(this, renderer
|
|
12909
|
+
_this = RenderPass.call(this, renderer) || this;
|
|
13289
12910
|
var name = "PostProcess";
|
|
13290
12911
|
var engine = _this.renderer.engine;
|
|
13291
12912
|
_this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
|
|
@@ -13341,9 +12962,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13341
12962
|
};
|
|
13342
12963
|
_proto.execute = function execute(renderer) {
|
|
13343
12964
|
renderer.clear({
|
|
13344
|
-
colorAction: exports.
|
|
13345
|
-
depthAction: exports.
|
|
13346
|
-
stencilAction: exports.
|
|
12965
|
+
colorAction: exports.TextureLoadAction.clear,
|
|
12966
|
+
depthAction: exports.TextureLoadAction.clear,
|
|
12967
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
13347
12968
|
});
|
|
13348
12969
|
var globalVolume = renderer.renderingData.currentFrame.globalVolume;
|
|
13349
12970
|
var bloom = _extends({
|
|
@@ -13390,95 +13011,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
13390
13011
|
return ToneMappingPass;
|
|
13391
13012
|
}(RenderPass);
|
|
13392
13013
|
|
|
13393
|
-
var SemanticMap = /*#__PURE__*/ function() {
|
|
13394
|
-
function SemanticMap(semantics) {
|
|
13395
|
-
if (semantics === void 0) semantics = {};
|
|
13396
|
-
this.semantics = _extends({}, semantics);
|
|
13397
|
-
}
|
|
13398
|
-
var _proto = SemanticMap.prototype;
|
|
13399
|
-
_proto.toObject = function toObject() {
|
|
13400
|
-
return _extends({}, this.semantics);
|
|
13401
|
-
};
|
|
13402
|
-
_proto.setSemantic = function setSemantic(name, value) {
|
|
13403
|
-
if (value === undefined) {
|
|
13404
|
-
delete this.semantics[name];
|
|
13405
|
-
} else {
|
|
13406
|
-
this.semantics[name] = value;
|
|
13407
|
-
}
|
|
13408
|
-
};
|
|
13409
|
-
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13410
|
-
var ret = this.semantics[name];
|
|
13411
|
-
if (isFunction(ret)) {
|
|
13412
|
-
return ret(state);
|
|
13413
|
-
}
|
|
13414
|
-
return ret;
|
|
13415
|
-
};
|
|
13416
|
-
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13417
|
-
return name in this.semantics;
|
|
13418
|
-
};
|
|
13419
|
-
_proto.dispose = function dispose() {
|
|
13420
|
-
var _this = this;
|
|
13421
|
-
Object.keys(this.semantics).forEach(function(name) {
|
|
13422
|
-
delete _this.semantics[name];
|
|
13423
|
-
});
|
|
13424
|
-
};
|
|
13425
|
-
return SemanticMap;
|
|
13426
|
-
}();
|
|
13427
|
-
|
|
13428
|
-
var RENDER_PASS_NAME_PREFIX = "_effects_default_";
|
|
13429
13014
|
var seed$6 = 1;
|
|
13430
13015
|
/**
|
|
13431
13016
|
* RenderFrame 抽象类
|
|
13432
13017
|
*/ var RenderFrame = /*#__PURE__*/ function() {
|
|
13433
13018
|
function RenderFrame(options) {
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
this.
|
|
13437
|
-
|
|
13438
|
-
this.renderPassInfoMap = new WeakMap();
|
|
13439
|
-
var camera = options.camera, keepColorBuffer = options.keepColorBuffer, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13019
|
+
this.disposed = false;
|
|
13020
|
+
this.postProcessingEnabled = false;
|
|
13021
|
+
this.enableHDR = true;
|
|
13022
|
+
var camera = options.camera, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
|
|
13440
13023
|
1,
|
|
13441
13024
|
1,
|
|
13442
13025
|
0,
|
|
13443
13026
|
0
|
|
13444
|
-
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled
|
|
13445
|
-
colorAction: exports.TextureLoadAction.whatever,
|
|
13446
|
-
stencilAction: exports.TextureLoadAction.clear,
|
|
13447
|
-
depthAction: exports.TextureLoadAction.whatever
|
|
13448
|
-
} : _options_clearAction;
|
|
13027
|
+
] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
|
|
13449
13028
|
var engine = renderer.engine;
|
|
13450
13029
|
if (globalVolume) {
|
|
13451
13030
|
this.globalVolume = globalVolume;
|
|
13452
13031
|
}
|
|
13032
|
+
this.postProcessingEnabled = postProcessingEnabled;
|
|
13453
13033
|
this.globalUniforms = new GlobalUniforms();
|
|
13454
|
-
var attachments = []; //渲染场景物体Pass的RT
|
|
13455
|
-
var depthStencilAttachment;
|
|
13456
13034
|
this.renderer = renderer;
|
|
13457
|
-
if (postProcessingEnabled) {
|
|
13458
|
-
|
|
13459
|
-
if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13460
|
-
throw new Error("Half float texture is not supported.");
|
|
13461
|
-
}
|
|
13462
|
-
// 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
|
|
13463
|
-
var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13464
|
-
attachments = [
|
|
13465
|
-
{
|
|
13466
|
-
texture: {
|
|
13467
|
-
format: glContext.RGBA,
|
|
13468
|
-
type: textureType,
|
|
13469
|
-
magFilter: glContext.LINEAR,
|
|
13470
|
-
minFilter: glContext.LINEAR
|
|
13471
|
-
}
|
|
13472
|
-
}
|
|
13473
|
-
];
|
|
13474
|
-
depthStencilAttachment = {
|
|
13475
|
-
storageType: exports.RenderPassAttachmentStorageType.depth_stencil_opaque
|
|
13476
|
-
};
|
|
13035
|
+
if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
|
|
13036
|
+
throw new Error("Half float texture is not supported.");
|
|
13477
13037
|
}
|
|
13478
|
-
this.drawObjectPass = new DrawObjectPass(renderer
|
|
13479
|
-
depthStencilAttachment: depthStencilAttachment,
|
|
13480
|
-
attachments: attachments
|
|
13481
|
-
});
|
|
13038
|
+
this.drawObjectPass = new DrawObjectPass(renderer);
|
|
13482
13039
|
var renderPasses = [
|
|
13483
13040
|
this.drawObjectPass
|
|
13484
13041
|
];
|
|
@@ -13486,110 +13043,25 @@ var seed$6 = 1;
|
|
|
13486
13043
|
if (postProcessingEnabled) {
|
|
13487
13044
|
var sceneTextureHandle = new RenderTargetHandle(engine); //保存后处理前的屏幕图像
|
|
13488
13045
|
var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
];
|
|
13495
|
-
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13496
|
-
var enableHDR1 = true;
|
|
13497
|
-
var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
|
|
13498
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer, {
|
|
13499
|
-
attachments: [
|
|
13500
|
-
{
|
|
13501
|
-
texture: {
|
|
13502
|
-
format: glContext.RGBA,
|
|
13503
|
-
type: textureType1,
|
|
13504
|
-
minFilter: glContext.LINEAR,
|
|
13505
|
-
magFilter: glContext.LINEAR
|
|
13506
|
-
}
|
|
13507
|
-
}
|
|
13508
|
-
]
|
|
13509
|
-
});
|
|
13510
|
-
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13511
|
-
this.addRenderPass(bloomThresholdPass);
|
|
13512
|
-
for(var i = 0; i < gaussianStep; i++){
|
|
13513
|
-
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13514
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i, {
|
|
13515
|
-
attachments: [
|
|
13516
|
-
{
|
|
13517
|
-
texture: {
|
|
13518
|
-
format: glContext.RGBA,
|
|
13519
|
-
type: textureType1,
|
|
13520
|
-
minFilter: glContext.LINEAR,
|
|
13521
|
-
magFilter: glContext.LINEAR
|
|
13522
|
-
}
|
|
13523
|
-
}
|
|
13524
|
-
]
|
|
13525
|
-
});
|
|
13526
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
|
|
13527
|
-
attachments: [
|
|
13528
|
-
{
|
|
13529
|
-
texture: {
|
|
13530
|
-
format: glContext.RGBA,
|
|
13531
|
-
type: textureType1,
|
|
13532
|
-
minFilter: glContext.LINEAR,
|
|
13533
|
-
magFilter: glContext.LINEAR
|
|
13534
|
-
}
|
|
13535
|
-
}
|
|
13536
|
-
]
|
|
13537
|
-
});
|
|
13538
|
-
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13539
|
-
this.addRenderPass(gaussianDownHPass);
|
|
13540
|
-
this.addRenderPass(gaussianDownVPass);
|
|
13541
|
-
viewport[2] /= 2;
|
|
13542
|
-
viewport[3] /= 2;
|
|
13543
|
-
// TODO 限制最大迭代
|
|
13544
|
-
}
|
|
13545
|
-
viewport[2] *= 4;
|
|
13546
|
-
viewport[3] *= 4;
|
|
13547
|
-
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13548
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1, {
|
|
13549
|
-
attachments: [
|
|
13550
|
-
{
|
|
13551
|
-
texture: {
|
|
13552
|
-
format: glContext.RGBA,
|
|
13553
|
-
type: textureType1,
|
|
13554
|
-
minFilter: glContext.LINEAR,
|
|
13555
|
-
magFilter: glContext.LINEAR
|
|
13556
|
-
}
|
|
13557
|
-
}
|
|
13558
|
-
]
|
|
13559
|
-
});
|
|
13560
|
-
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13561
|
-
this.addRenderPass(gaussianUpPass);
|
|
13562
|
-
viewport[2] *= 2;
|
|
13563
|
-
viewport[3] *= 2;
|
|
13564
|
-
}
|
|
13046
|
+
// Bloom Pass(包含阈值提取、高斯模糊)
|
|
13047
|
+
var bloomPass = new BloomPass(renderer, gaussianStep);
|
|
13048
|
+
bloomPass.sceneTextureHandle = sceneTextureHandle;
|
|
13049
|
+
this.addRenderPass(bloomPass);
|
|
13050
|
+
// Tone Mapping Pass
|
|
13565
13051
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13566
13052
|
this.addRenderPass(postProcessPass);
|
|
13567
13053
|
}
|
|
13568
|
-
this.semantics = new SemanticMap(options.semantics);
|
|
13569
|
-
this.clearAction = clearAction;
|
|
13570
13054
|
this.name = "RenderFrame" + seed$6++;
|
|
13571
|
-
var firstRP = renderPasses[0];
|
|
13572
13055
|
this.camera = camera;
|
|
13573
|
-
this.keepColorBuffer = keepColorBuffer;
|
|
13574
|
-
this.renderPassInfoMap.set(firstRP, {
|
|
13575
|
-
listStart: 0,
|
|
13576
|
-
listEnd: 0,
|
|
13577
|
-
renderPass: firstRP,
|
|
13578
|
-
intermedia: false
|
|
13579
|
-
});
|
|
13580
13056
|
this.editorTransform = Vector4.fromArray(editorTransform);
|
|
13581
|
-
if (!options.clearAction) {
|
|
13582
|
-
this.resetClearActions();
|
|
13583
|
-
}
|
|
13584
|
-
this.passTextureCache = new PassTextureCache(engine);
|
|
13585
|
-
// FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
|
|
13586
|
-
var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
|
|
13587
|
-
var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
|
|
13588
|
-
var shader = createCopyShader(level, writeDepth);
|
|
13589
|
-
(_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
|
|
13590
13057
|
}
|
|
13591
13058
|
var _proto = RenderFrame.prototype;
|
|
13592
13059
|
/**
|
|
13060
|
+
* 设置 RenderPasses 参数,此函数每帧调用一次
|
|
13061
|
+
*/ _proto.setup = function setup() {
|
|
13062
|
+
this.drawObjectPass.setup(this.postProcessingEnabled);
|
|
13063
|
+
};
|
|
13064
|
+
/**
|
|
13593
13065
|
* 根据 Mesh 优先级添加到 RenderPass
|
|
13594
13066
|
* @param mesh - 要添加的 Mesh 对象
|
|
13595
13067
|
*/ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
|
|
@@ -13606,78 +13078,25 @@ var seed$6 = 1;
|
|
|
13606
13078
|
* 销毁 RenderFrame
|
|
13607
13079
|
* @param options - 可以有选择销毁一些对象
|
|
13608
13080
|
*/ _proto.dispose = function dispose(options) {
|
|
13609
|
-
if ((options == null ? void 0 : options.semantics) !== exports.DestroyOptions.keep) {
|
|
13610
|
-
this.semantics.dispose();
|
|
13611
|
-
}
|
|
13612
13081
|
var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
|
|
13613
13082
|
if (pass !== exports.DestroyOptions.keep) {
|
|
13614
13083
|
this._renderPasses.forEach(function(renderPass) {
|
|
13615
13084
|
renderPass.dispose(pass);
|
|
13616
13085
|
});
|
|
13617
13086
|
}
|
|
13618
|
-
this.passTextureCache.dispose();
|
|
13619
13087
|
this._renderPasses.length = 0;
|
|
13620
|
-
this.
|
|
13621
|
-
};
|
|
13622
|
-
/**
|
|
13623
|
-
* 查找 Mesh 所在的 RenderPass 索引,没找到是-1
|
|
13624
|
-
* @param mesh - 需要查找的 Mesh
|
|
13625
|
-
*/ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
|
|
13626
|
-
var index = -1;
|
|
13627
|
-
this.renderPasses.every(function(rp, idx) {
|
|
13628
|
-
if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
|
|
13629
|
-
index = idx;
|
|
13630
|
-
return false;
|
|
13631
|
-
}
|
|
13632
|
-
return true;
|
|
13633
|
-
});
|
|
13634
|
-
return index;
|
|
13635
|
-
};
|
|
13636
|
-
_proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
|
|
13637
|
-
var info = this.renderPassInfoMap.get(renderPass);
|
|
13638
|
-
var priority = mesh.priority;
|
|
13639
|
-
if (!info) {
|
|
13640
|
-
return;
|
|
13641
|
-
}
|
|
13642
|
-
if (renderPass.meshes.length === 0) {
|
|
13643
|
-
info.listStart = info.listEnd = priority;
|
|
13644
|
-
} else {
|
|
13645
|
-
if (priority < info.listStart) {
|
|
13646
|
-
info.listStart = priority;
|
|
13647
|
-
} else if (priority > info.listEnd) {
|
|
13648
|
-
info.listEnd = priority;
|
|
13649
|
-
}
|
|
13650
|
-
}
|
|
13651
|
-
renderPass.addMesh(mesh);
|
|
13652
|
-
};
|
|
13653
|
-
_proto.resetClearActions = function resetClearActions() {
|
|
13654
|
-
var action = this.renderPasses.length > 1 ? exports.TextureLoadAction.clear : exports.TextureLoadAction.whatever;
|
|
13655
|
-
this.clearAction.stencilAction = action;
|
|
13656
|
-
this.clearAction.depthAction = action;
|
|
13657
|
-
this.clearAction.colorAction = action;
|
|
13658
|
-
if (this.keepColorBuffer) {
|
|
13659
|
-
this.clearAction.colorAction = exports.TextureLoadAction.whatever;
|
|
13660
|
-
}
|
|
13088
|
+
this.disposed = true;
|
|
13661
13089
|
};
|
|
13662
13090
|
/**
|
|
13663
13091
|
* 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
|
|
13664
13092
|
* @param passes - RenderPass 数组
|
|
13665
13093
|
*/ _proto.setRenderPasses = function setRenderPasses(passes) {
|
|
13666
|
-
var _this = this;
|
|
13667
|
-
if (this.renderer !== undefined) {
|
|
13668
|
-
passes.forEach(function(pass) {
|
|
13669
|
-
return pass.initialize(_this.renderer);
|
|
13670
|
-
});
|
|
13671
|
-
}
|
|
13672
13094
|
this._renderPasses = passes.slice();
|
|
13673
13095
|
};
|
|
13674
13096
|
/**
|
|
13675
13097
|
* 添加 RenderPass
|
|
13676
13098
|
* @param pass - 需要添加的 RenderPass
|
|
13677
13099
|
*/ _proto.addRenderPass = function addRenderPass(pass) {
|
|
13678
|
-
if (this.renderer !== undefined) {
|
|
13679
|
-
pass.initialize(this.renderer);
|
|
13680
|
-
}
|
|
13681
13100
|
this._renderPasses.push(pass);
|
|
13682
13101
|
};
|
|
13683
13102
|
/**
|
|
@@ -13694,9 +13113,9 @@ var seed$6 = 1;
|
|
|
13694
13113
|
}
|
|
13695
13114
|
},
|
|
13696
13115
|
{
|
|
13697
|
-
key: "
|
|
13116
|
+
key: "isDisposed",
|
|
13698
13117
|
get: function get() {
|
|
13699
|
-
return this.
|
|
13118
|
+
return this.disposed;
|
|
13700
13119
|
}
|
|
13701
13120
|
}
|
|
13702
13121
|
]);
|
|
@@ -13705,10 +13124,6 @@ var seed$6 = 1;
|
|
|
13705
13124
|
function getTextureSize(tex) {
|
|
13706
13125
|
return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
|
|
13707
13126
|
}
|
|
13708
|
-
function findPreviousRenderPass(renderPasses, renderPass) {
|
|
13709
|
-
var index = renderPasses.indexOf(renderPass);
|
|
13710
|
-
return renderPasses[index - 1];
|
|
13711
|
-
}
|
|
13712
13127
|
var GlobalUniforms = function GlobalUniforms() {
|
|
13713
13128
|
this.floats = {};
|
|
13714
13129
|
this.ints = {};
|
|
@@ -13746,6 +13161,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
|
|
|
13746
13161
|
return Renderbuffer;
|
|
13747
13162
|
}();
|
|
13748
13163
|
|
|
13164
|
+
var RenderTargetPool = /*#__PURE__*/ function() {
|
|
13165
|
+
function RenderTargetPool(engine) {
|
|
13166
|
+
this.engine = engine;
|
|
13167
|
+
this.temporaryRTs = [];
|
|
13168
|
+
this.currentFrame = 0;
|
|
13169
|
+
this.maxUnusedFrames = 4;
|
|
13170
|
+
}
|
|
13171
|
+
var _proto = RenderTargetPool.prototype;
|
|
13172
|
+
/**
|
|
13173
|
+
* 清理 RenderTarget 池
|
|
13174
|
+
* @param force - 是否强制清理所有未占用的 RT
|
|
13175
|
+
* @param framesOffset - 自定义未使用帧数阈值,-1 表示使用默认值
|
|
13176
|
+
*/ _proto.flush = function flush(force, framesOffset) {
|
|
13177
|
+
if (force === void 0) force = false;
|
|
13178
|
+
if (framesOffset === void 0) framesOffset = -1;
|
|
13179
|
+
this.currentFrame++;
|
|
13180
|
+
var threshold = framesOffset >= 0 ? framesOffset : this.maxUnusedFrames;
|
|
13181
|
+
for(var i = 0; i < this.temporaryRTs.length; i++){
|
|
13182
|
+
var entry = this.temporaryRTs[i];
|
|
13183
|
+
// 强制清理所有未占用的 RT,或清理超过阈值帧数未使用的 RT
|
|
13184
|
+
if (!entry.isOccupied && (force || this.currentFrame - entry.lastFrameReleased > threshold)) {
|
|
13185
|
+
entry.RT.dispose();
|
|
13186
|
+
this.temporaryRTs.splice(i--, 1);
|
|
13187
|
+
}
|
|
13188
|
+
}
|
|
13189
|
+
};
|
|
13190
|
+
_proto.get = function get(name, width, height, depthBuffer, filter, format) {
|
|
13191
|
+
if (depthBuffer === void 0) depthBuffer = 0;
|
|
13192
|
+
if (filter === void 0) filter = exports.FilterMode.Linear;
|
|
13193
|
+
if (format === void 0) format = exports.RenderTextureFormat.RGBA32;
|
|
13194
|
+
// 使用参数计算 hash 值作为缓存 key
|
|
13195
|
+
var hash = width + "_" + height + "_" + depthBuffer + "_" + filter + "_" + format;
|
|
13196
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13197
|
+
var entry = _step.value;
|
|
13198
|
+
if (!entry.isOccupied && entry.descriptionHash === hash) {
|
|
13199
|
+
entry.isOccupied = true;
|
|
13200
|
+
entry.RT.name = name;
|
|
13201
|
+
return entry.RT;
|
|
13202
|
+
}
|
|
13203
|
+
}
|
|
13204
|
+
var textureFilter;
|
|
13205
|
+
var textureType;
|
|
13206
|
+
var depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13207
|
+
// TODO 建立Map映射
|
|
13208
|
+
if (filter === exports.FilterMode.Linear) {
|
|
13209
|
+
textureFilter = glContext.LINEAR;
|
|
13210
|
+
} else if (filter === exports.FilterMode.Nearest) {
|
|
13211
|
+
textureFilter = glContext.NEAREST;
|
|
13212
|
+
}
|
|
13213
|
+
if (format === exports.RenderTextureFormat.RGBA32) {
|
|
13214
|
+
textureType = glContext.UNSIGNED_BYTE;
|
|
13215
|
+
} else if (format === exports.RenderTextureFormat.RGBAHalf) {
|
|
13216
|
+
textureType = glContext.HALF_FLOAT;
|
|
13217
|
+
}
|
|
13218
|
+
if (depthBuffer === 0) {
|
|
13219
|
+
depthType = exports.RenderPassAttachmentStorageType.none;
|
|
13220
|
+
} else if (depthBuffer === 16) {
|
|
13221
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_stencil_opaque;
|
|
13222
|
+
} else if (depthBuffer === 24) {
|
|
13223
|
+
depthType = exports.RenderPassAttachmentStorageType.depth_24_stencil_8_texture;
|
|
13224
|
+
}
|
|
13225
|
+
var colorAttachment = Texture.create(this.engine, {
|
|
13226
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
13227
|
+
minFilter: textureFilter,
|
|
13228
|
+
magFilter: textureFilter,
|
|
13229
|
+
internalFormat: glContext.RGBA,
|
|
13230
|
+
format: glContext.RGBA,
|
|
13231
|
+
type: textureType
|
|
13232
|
+
});
|
|
13233
|
+
var newFramebuffer = Framebuffer.create({
|
|
13234
|
+
name: name,
|
|
13235
|
+
storeAction: {},
|
|
13236
|
+
viewport: [
|
|
13237
|
+
0,
|
|
13238
|
+
0,
|
|
13239
|
+
width,
|
|
13240
|
+
height
|
|
13241
|
+
],
|
|
13242
|
+
attachments: [
|
|
13243
|
+
colorAttachment
|
|
13244
|
+
],
|
|
13245
|
+
depthStencilAttachment: {
|
|
13246
|
+
storageType: depthType
|
|
13247
|
+
}
|
|
13248
|
+
}, this.engine.renderer);
|
|
13249
|
+
var entry1 = {
|
|
13250
|
+
RT: newFramebuffer,
|
|
13251
|
+
lastFrameReleased: 0,
|
|
13252
|
+
descriptionHash: hash,
|
|
13253
|
+
isOccupied: true
|
|
13254
|
+
};
|
|
13255
|
+
this.temporaryRTs.push(entry1);
|
|
13256
|
+
return entry1.RT;
|
|
13257
|
+
};
|
|
13258
|
+
/**
|
|
13259
|
+
* 释放 RenderTarget,使其可以被复用
|
|
13260
|
+
* @param rt - 要释放的 Framebuffer
|
|
13261
|
+
*/ _proto.release = function release(rt) {
|
|
13262
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13263
|
+
var entry = _step.value;
|
|
13264
|
+
if (entry.RT === rt) {
|
|
13265
|
+
entry.isOccupied = false;
|
|
13266
|
+
entry.lastFrameReleased = this.currentFrame;
|
|
13267
|
+
break;
|
|
13268
|
+
}
|
|
13269
|
+
}
|
|
13270
|
+
};
|
|
13271
|
+
_proto.dispose = function dispose() {
|
|
13272
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
|
|
13273
|
+
var entry = _step.value;
|
|
13274
|
+
entry.RT.dispose();
|
|
13275
|
+
}
|
|
13276
|
+
};
|
|
13277
|
+
return RenderTargetPool;
|
|
13278
|
+
}();
|
|
13279
|
+
|
|
13749
13280
|
var isWebGL2Available = typeof WebGL2RenderingContext === "function";
|
|
13750
13281
|
var GPUCapability = /*#__PURE__*/ function() {
|
|
13751
13282
|
function GPUCapability(gl) {
|
|
@@ -13931,70 +13462,11 @@ exports.CompressTextureCapabilityType = void 0;
|
|
|
13931
13462
|
return !!hasCompressedTextureSupport;
|
|
13932
13463
|
}
|
|
13933
13464
|
|
|
13934
|
-
exports.FilterMode = void 0;
|
|
13935
|
-
(function(FilterMode) {
|
|
13936
|
-
FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
|
|
13937
|
-
FilterMode[FilterMode["Linear"] = 1] = "Linear";
|
|
13938
|
-
})(exports.FilterMode || (exports.FilterMode = {}));
|
|
13939
|
-
exports.RenderTextureFormat = void 0;
|
|
13940
|
-
(function(RenderTextureFormat) {
|
|
13941
|
-
RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
|
|
13942
|
-
RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
|
|
13943
|
-
})(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
|
|
13944
|
-
/**
|
|
13945
|
-
*
|
|
13946
|
-
*/ var Framebuffer = /*#__PURE__*/ function() {
|
|
13947
|
-
function Framebuffer() {}
|
|
13948
|
-
var _proto = Framebuffer.prototype;
|
|
13949
|
-
_proto.resize = function resize(x, y, width, height) {
|
|
13950
|
-
// OVERRIDE
|
|
13951
|
-
};
|
|
13952
|
-
_proto.resetColorTextures = function resetColorTextures(textures) {
|
|
13953
|
-
// OVERRIDE
|
|
13954
|
-
};
|
|
13955
|
-
_proto.unbind = function unbind() {
|
|
13956
|
-
// OVERRIDE
|
|
13957
|
-
};
|
|
13958
|
-
_proto.bind = function bind() {
|
|
13959
|
-
// OVERRIDE
|
|
13960
|
-
};
|
|
13961
|
-
_proto.getDepthTexture = function getDepthTexture() {
|
|
13962
|
-
// OVERRIDE
|
|
13963
|
-
return undefined;
|
|
13964
|
-
};
|
|
13965
|
-
_proto.getStencilTexture = function getStencilTexture() {
|
|
13966
|
-
// OVERRIDE
|
|
13967
|
-
return undefined;
|
|
13968
|
-
};
|
|
13969
|
-
_proto.getColorTextures = function getColorTextures() {
|
|
13970
|
-
// OVERRIDE
|
|
13971
|
-
return [];
|
|
13972
|
-
};
|
|
13973
|
-
_proto.dispose = function dispose(options) {
|
|
13974
|
-
// OVERRIDE
|
|
13975
|
-
};
|
|
13976
|
-
_create_class(Framebuffer, [
|
|
13977
|
-
{
|
|
13978
|
-
key: "stencilStorage",
|
|
13979
|
-
get: function get() {
|
|
13980
|
-
// OVERRIDE
|
|
13981
|
-
return undefined;
|
|
13982
|
-
}
|
|
13983
|
-
},
|
|
13984
|
-
{
|
|
13985
|
-
key: "depthStorage",
|
|
13986
|
-
get: function get() {
|
|
13987
|
-
// OVERRIDE
|
|
13988
|
-
return undefined;
|
|
13989
|
-
}
|
|
13990
|
-
}
|
|
13991
|
-
]);
|
|
13992
|
-
return Framebuffer;
|
|
13993
|
-
}();
|
|
13994
|
-
|
|
13995
13465
|
var Renderer = /*#__PURE__*/ function() {
|
|
13996
13466
|
function Renderer(engine) {
|
|
13997
13467
|
this.engine = engine;
|
|
13468
|
+
this.currentFramebuffer = null;
|
|
13469
|
+
this.renderTargetPool = new RenderTargetPool(engine);
|
|
13998
13470
|
}
|
|
13999
13471
|
var _proto = Renderer.prototype;
|
|
14000
13472
|
_proto.setGlobalFloat = function setGlobalFloat(name, value) {
|
|
@@ -14064,8 +13536,18 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14064
13536
|
// OVERRIDE
|
|
14065
13537
|
};
|
|
14066
13538
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
14067
|
-
|
|
14068
|
-
|
|
13539
|
+
return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
13540
|
+
};
|
|
13541
|
+
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13542
|
+
this.renderTargetPool.release(rt);
|
|
13543
|
+
};
|
|
13544
|
+
/**
|
|
13545
|
+
* 将源纹理复制到目标 Framebuffer,可使用自定义材质进行处理
|
|
13546
|
+
* @param source - 源纹理
|
|
13547
|
+
* @param destination - 目标 Framebuffer,如果为 null 则渲染到屏幕
|
|
13548
|
+
* @param material - 可选的自定义材质,不传则使用默认复制材质
|
|
13549
|
+
*/ _proto.blit = function blit(source, destination, material) {
|
|
13550
|
+
// OVERRIDE
|
|
14069
13551
|
};
|
|
14070
13552
|
_proto.dispose = function dispose() {
|
|
14071
13553
|
// OVERRIDE
|
|
@@ -14073,6 +13555,41 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
14073
13555
|
return Renderer;
|
|
14074
13556
|
}();
|
|
14075
13557
|
|
|
13558
|
+
var SemanticMap = /*#__PURE__*/ function() {
|
|
13559
|
+
function SemanticMap(semantics) {
|
|
13560
|
+
if (semantics === void 0) semantics = {};
|
|
13561
|
+
this.semantics = _extends({}, semantics);
|
|
13562
|
+
}
|
|
13563
|
+
var _proto = SemanticMap.prototype;
|
|
13564
|
+
_proto.toObject = function toObject() {
|
|
13565
|
+
return _extends({}, this.semantics);
|
|
13566
|
+
};
|
|
13567
|
+
_proto.setSemantic = function setSemantic(name, value) {
|
|
13568
|
+
if (value === undefined) {
|
|
13569
|
+
delete this.semantics[name];
|
|
13570
|
+
} else {
|
|
13571
|
+
this.semantics[name] = value;
|
|
13572
|
+
}
|
|
13573
|
+
};
|
|
13574
|
+
_proto.getSemanticValue = function getSemanticValue(name, state) {
|
|
13575
|
+
var ret = this.semantics[name];
|
|
13576
|
+
if (isFunction(ret)) {
|
|
13577
|
+
return ret(state);
|
|
13578
|
+
}
|
|
13579
|
+
return ret;
|
|
13580
|
+
};
|
|
13581
|
+
_proto.hasSemanticValue = function hasSemanticValue(name) {
|
|
13582
|
+
return name in this.semantics;
|
|
13583
|
+
};
|
|
13584
|
+
_proto.dispose = function dispose() {
|
|
13585
|
+
var _this = this;
|
|
13586
|
+
Object.keys(this.semantics).forEach(function(name) {
|
|
13587
|
+
delete _this.semantics[name];
|
|
13588
|
+
});
|
|
13589
|
+
};
|
|
13590
|
+
return SemanticMap;
|
|
13591
|
+
}();
|
|
13592
|
+
|
|
14076
13593
|
/**
|
|
14077
13594
|
* @since 2.7.0
|
|
14078
13595
|
*/ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
|
|
@@ -18103,6 +17620,11 @@ exports.PlayState = void 0;
|
|
|
18103
17620
|
PlayState[PlayState["Paused"] = 1] = "Paused";
|
|
18104
17621
|
})(exports.PlayState || (exports.PlayState = {}));
|
|
18105
17622
|
|
|
17623
|
+
function _assert_this_initialized(self) {
|
|
17624
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
17625
|
+
return self;
|
|
17626
|
+
}
|
|
17627
|
+
|
|
18106
17628
|
var tempQuat$1 = new Quaternion();
|
|
18107
17629
|
var tempVector3 = new Vector3();
|
|
18108
17630
|
var tempVector3Second = new Vector3();
|
|
@@ -24480,8 +24002,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24480
24002
|
_this.reusable = reusable;
|
|
24481
24003
|
_this.speed = speed;
|
|
24482
24004
|
_this.name = sourceContent.name;
|
|
24483
|
-
_this
|
|
24484
|
-
_this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24005
|
+
PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
|
|
24485
24006
|
_this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
|
|
24486
24007
|
aspect: width / height,
|
|
24487
24008
|
pixelWidth: width,
|
|
@@ -24495,7 +24016,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24495
24016
|
_this.createRenderFrame();
|
|
24496
24017
|
Composition.buildItemTree(_this.rootItem);
|
|
24497
24018
|
_this.rootComposition.setChildrenRenderOrder(0);
|
|
24498
|
-
_this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
|
|
24499
24019
|
return _this;
|
|
24500
24020
|
}
|
|
24501
24021
|
var _proto = Composition.prototype;
|
|
@@ -24605,12 +24125,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24605
24125
|
this.renderFrame = new RenderFrame({
|
|
24606
24126
|
camera: this.camera,
|
|
24607
24127
|
renderer: this.renderer,
|
|
24608
|
-
keepColorBuffer: this.keepColorBuffer,
|
|
24609
24128
|
globalVolume: this.globalVolume,
|
|
24610
24129
|
postProcessingEnabled: this.postProcessingEnabled
|
|
24611
24130
|
});
|
|
24612
|
-
// TODO 考虑放到构造函数
|
|
24613
|
-
this.renderFrame.cachedTextures = this.textures;
|
|
24614
24131
|
};
|
|
24615
24132
|
/**
|
|
24616
24133
|
* 跳到指定时间点(不做任何播放行为)
|
|
@@ -24661,7 +24178,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24661
24178
|
this.isEnded = false;
|
|
24662
24179
|
this.isEndCalled = false;
|
|
24663
24180
|
this.rootComposition.time = 0;
|
|
24664
|
-
this.pluginSystem.resetComposition(this, this.renderFrame);
|
|
24665
24181
|
};
|
|
24666
24182
|
_proto.prepareRender = function prepareRender() {};
|
|
24667
24183
|
/**
|
|
@@ -24679,8 +24195,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24679
24195
|
var previousCompositionTime = this.time;
|
|
24680
24196
|
this.updateCompositionTime(deltaTime * this.speed / 1000);
|
|
24681
24197
|
var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
|
|
24682
|
-
// 更新 model-tree-plugin
|
|
24683
|
-
this.updatePluginLoaders(deltaTimeInMs);
|
|
24684
24198
|
this.sceneTicking.update.tick(deltaTimeInMs);
|
|
24685
24199
|
this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
|
|
24686
24200
|
this.updateCamera();
|
|
@@ -24705,15 +24219,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24705
24219
|
this.camera.updateMatrix();
|
|
24706
24220
|
};
|
|
24707
24221
|
/**
|
|
24708
|
-
* 插件更新,来自 CompVFXItem 的更新调用
|
|
24709
|
-
* @param deltaTime - 更新的时间步长
|
|
24710
|
-
*/ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
|
|
24711
|
-
var _this = this;
|
|
24712
|
-
this.pluginSystem.plugins.forEach(function(loader) {
|
|
24713
|
-
return loader.onCompositionUpdate(_this, deltaTime);
|
|
24714
|
-
});
|
|
24715
|
-
};
|
|
24716
|
-
/**
|
|
24717
24222
|
* 更新主合成组件
|
|
24718
24223
|
*/ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
|
|
24719
24224
|
if (this.rootComposition.state === exports.PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
|
|
@@ -24872,7 +24377,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24872
24377
|
* 合成对象销毁
|
|
24873
24378
|
*/ _proto.dispose = function dispose() {
|
|
24874
24379
|
var _this = this;
|
|
24875
|
-
var _this_pluginSystem;
|
|
24876
24380
|
if (this.destroyed) {
|
|
24877
24381
|
return;
|
|
24878
24382
|
}
|
|
@@ -24892,13 +24396,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24892
24396
|
this.rootItem.dispose();
|
|
24893
24397
|
// FIXME: 注意这里增加了renderFrame销毁
|
|
24894
24398
|
this.renderFrame.dispose();
|
|
24895
|
-
|
|
24399
|
+
PluginSystem.destroyComposition(this);
|
|
24896
24400
|
this.update = function() {
|
|
24897
24401
|
{
|
|
24898
24402
|
logger.error("Update disposed composition: " + _this.name + ".");
|
|
24899
24403
|
}
|
|
24900
24404
|
};
|
|
24901
24405
|
this.dispose = noop;
|
|
24406
|
+
this.renderer.engine.removeComposition(this);
|
|
24902
24407
|
if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
|
|
24903
24408
|
return;
|
|
24904
24409
|
}
|
|
@@ -24915,7 +24420,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
|
|
|
24915
24420
|
0
|
|
24916
24421
|
]
|
|
24917
24422
|
});
|
|
24918
|
-
this.renderer.engine.removeComposition(this);
|
|
24919
24423
|
};
|
|
24920
24424
|
/**
|
|
24921
24425
|
* 编辑器使用的 transform 修改方法
|
|
@@ -31890,7 +31394,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31890
31394
|
return ret;
|
|
31891
31395
|
}
|
|
31892
31396
|
|
|
31893
|
-
var version$2 = "2.8.0-alpha.
|
|
31397
|
+
var version$2 = "2.8.0-alpha.3";
|
|
31894
31398
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31895
31399
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31896
31400
|
var reverseParticle = false;
|
|
@@ -32405,7 +31909,7 @@ var seed$1 = 1;
|
|
|
32405
31909
|
* @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
|
|
32406
31910
|
* @param options - 扩展参数
|
|
32407
31911
|
* @returns
|
|
32408
|
-
*/ _proto.loadScene = function loadScene(url, renderer
|
|
31912
|
+
*/ _proto.loadScene = function loadScene(url, renderer) {
|
|
32409
31913
|
var _this = this;
|
|
32410
31914
|
return _async_to_generator(function() {
|
|
32411
31915
|
var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
|
|
@@ -32466,7 +31970,7 @@ var seed$1 = 1;
|
|
|
32466
31970
|
});
|
|
32467
31971
|
});
|
|
32468
31972
|
loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
|
|
32469
|
-
var scene, link,
|
|
31973
|
+
var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
|
|
32470
31974
|
return __generator(this, function(_state) {
|
|
32471
31975
|
switch(_state.label){
|
|
32472
31976
|
case 0:
|
|
@@ -32516,7 +32020,26 @@ var seed$1 = 1;
|
|
|
32516
32020
|
})
|
|
32517
32021
|
];
|
|
32518
32022
|
case 5:
|
|
32519
|
-
|
|
32023
|
+
jsonScene = _state.sent().jsonScene;
|
|
32024
|
+
scene = {
|
|
32025
|
+
timeInfos: timeInfos,
|
|
32026
|
+
url: url,
|
|
32027
|
+
storage: {},
|
|
32028
|
+
jsonScene: jsonScene,
|
|
32029
|
+
bins: [],
|
|
32030
|
+
textureOptions: [],
|
|
32031
|
+
textures: [],
|
|
32032
|
+
images: [],
|
|
32033
|
+
assets: _this.assets
|
|
32034
|
+
};
|
|
32035
|
+
return [
|
|
32036
|
+
4,
|
|
32037
|
+
hookTimeInfo("plugin:processAssets", function() {
|
|
32038
|
+
return _this.processPluginAssets(scene);
|
|
32039
|
+
})
|
|
32040
|
+
];
|
|
32041
|
+
case 6:
|
|
32042
|
+
_state.sent();
|
|
32520
32043
|
_jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
|
|
32521
32044
|
return [
|
|
32522
32045
|
4,
|
|
@@ -32527,46 +32050,26 @@ var seed$1 = 1;
|
|
|
32527
32050
|
hookTimeInfo("processImages", function() {
|
|
32528
32051
|
return _this.processImages(images, isKTX2Supported);
|
|
32529
32052
|
}),
|
|
32530
|
-
hookTimeInfo("plugin:processAssets", function() {
|
|
32531
|
-
return _this.processPluginAssets(jsonScene, pluginSystem, options);
|
|
32532
|
-
}),
|
|
32533
32053
|
hookTimeInfo("processFontURL", function() {
|
|
32534
32054
|
return _this.processFontURL(fonts);
|
|
32535
32055
|
})
|
|
32536
32056
|
])
|
|
32537
32057
|
];
|
|
32538
|
-
case
|
|
32539
|
-
|
|
32058
|
+
case 7:
|
|
32059
|
+
_ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
|
|
32540
32060
|
return [
|
|
32541
32061
|
4,
|
|
32542
32062
|
hookTimeInfo("processTextures", function() {
|
|
32543
32063
|
return _this.processTextures(loadedImages, loadedBins, jsonScene);
|
|
32544
32064
|
})
|
|
32545
32065
|
];
|
|
32546
|
-
case 7:
|
|
32547
|
-
loadedTextures = _state.sent();
|
|
32548
|
-
scene = {
|
|
32549
|
-
timeInfos: timeInfos,
|
|
32550
|
-
url: url,
|
|
32551
|
-
renderLevel: _this.options.renderLevel,
|
|
32552
|
-
storage: {},
|
|
32553
|
-
pluginSystem: pluginSystem,
|
|
32554
|
-
jsonScene: jsonScene,
|
|
32555
|
-
bins: loadedBins,
|
|
32556
|
-
textureOptions: loadedTextures,
|
|
32557
|
-
textures: [],
|
|
32558
|
-
images: loadedImages,
|
|
32559
|
-
assets: _this.assets
|
|
32560
|
-
};
|
|
32561
|
-
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
32562
|
-
return [
|
|
32563
|
-
4,
|
|
32564
|
-
hookTimeInfo("plugin:prepareResource", function() {
|
|
32565
|
-
return pluginSystem.loadResources(scene, _this.options);
|
|
32566
|
-
})
|
|
32567
|
-
];
|
|
32568
32066
|
case 8:
|
|
32569
|
-
_state.sent();
|
|
32067
|
+
loadedTextures = _state.sent();
|
|
32068
|
+
(_scene_bins = scene.bins).push.apply(_scene_bins, [].concat(loadedBins));
|
|
32069
|
+
(_scene_textureOptions = scene.textureOptions).push.apply(_scene_textureOptions, [].concat(loadedTextures));
|
|
32070
|
+
(_scene_images = scene.images).push.apply(_scene_images, [].concat(loadedImages));
|
|
32071
|
+
// 降级插件会修改 this.options.renderLevel, 在 processPluginAssets 后赋值
|
|
32072
|
+
scene.renderLevel = _this.options.renderLevel;
|
|
32570
32073
|
_state.label = 9;
|
|
32571
32074
|
case 9:
|
|
32572
32075
|
totalTime = performance.now() - startTime;
|
|
@@ -32598,29 +32101,23 @@ var seed$1 = 1;
|
|
|
32598
32101
|
return this.assets;
|
|
32599
32102
|
};
|
|
32600
32103
|
_proto.processJSON = function processJSON(json) {
|
|
32601
|
-
var _this = this;
|
|
32602
32104
|
return _async_to_generator(function() {
|
|
32603
|
-
var jsonScene, _jsonScene_plugins, plugins,
|
|
32105
|
+
var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
|
|
32604
32106
|
return __generator(this, function(_state) {
|
|
32605
|
-
|
|
32606
|
-
|
|
32607
|
-
|
|
32608
|
-
|
|
32609
|
-
|
|
32610
|
-
|
|
32611
|
-
|
|
32612
|
-
pluginSystem.processRawJSON(jsonScene, _this.options)
|
|
32613
|
-
];
|
|
32614
|
-
case 1:
|
|
32615
|
-
_state.sent();
|
|
32616
|
-
return [
|
|
32617
|
-
2,
|
|
32618
|
-
{
|
|
32619
|
-
jsonScene: jsonScene,
|
|
32620
|
-
pluginSystem: pluginSystem
|
|
32621
|
-
}
|
|
32622
|
-
];
|
|
32107
|
+
jsonScene = getStandardJSON(json);
|
|
32108
|
+
_jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
|
|
32109
|
+
for(_iterator = _create_for_of_iterator_helper_loose(plugins); !(_step = _iterator()).done;){
|
|
32110
|
+
customPluginName = _step.value;
|
|
32111
|
+
if (!pluginLoaderMap[customPluginName]) {
|
|
32112
|
+
throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
|
|
32113
|
+
}
|
|
32623
32114
|
}
|
|
32115
|
+
return [
|
|
32116
|
+
2,
|
|
32117
|
+
{
|
|
32118
|
+
jsonScene: jsonScene
|
|
32119
|
+
}
|
|
32120
|
+
];
|
|
32624
32121
|
});
|
|
32625
32122
|
})();
|
|
32626
32123
|
};
|
|
@@ -32826,30 +32323,18 @@ var seed$1 = 1;
|
|
|
32826
32323
|
});
|
|
32827
32324
|
})();
|
|
32828
32325
|
};
|
|
32829
|
-
_proto.processPluginAssets = function processPluginAssets(
|
|
32326
|
+
_proto.processPluginAssets = function processPluginAssets(scene) {
|
|
32830
32327
|
var _this = this;
|
|
32831
32328
|
return _async_to_generator(function() {
|
|
32832
|
-
var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
|
|
32833
32329
|
return __generator(this, function(_state) {
|
|
32834
32330
|
switch(_state.label){
|
|
32835
32331
|
case 0:
|
|
32836
32332
|
return [
|
|
32837
32333
|
4,
|
|
32838
|
-
|
|
32334
|
+
PluginSystem.processAssets(scene, _this.options)
|
|
32839
32335
|
];
|
|
32840
32336
|
case 1:
|
|
32841
|
-
|
|
32842
|
-
_pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
|
|
32843
|
-
acc.assets = acc.assets.concat(cur.assets);
|
|
32844
|
-
acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
|
|
32845
|
-
return acc;
|
|
32846
|
-
}, {
|
|
32847
|
-
assets: [],
|
|
32848
|
-
loadedAssets: []
|
|
32849
|
-
}), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
|
|
32850
|
-
for(i = 0; i < assets.length; i++){
|
|
32851
|
-
_this.assets[assets[i].id] = loadedAssets[i];
|
|
32852
|
-
}
|
|
32337
|
+
_state.sent();
|
|
32853
32338
|
return [
|
|
32854
32339
|
2
|
|
32855
32340
|
];
|
|
@@ -33276,7 +32761,6 @@ function _createTextureOptionsBySource() {
|
|
|
33276
32761
|
}
|
|
33277
32762
|
};
|
|
33278
32763
|
_proto.prepareAssets = function prepareAssets(scene, assets) {
|
|
33279
|
-
this.engine.clearResources();
|
|
33280
32764
|
for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
|
|
33281
32765
|
var assetId = _step.value;
|
|
33282
32766
|
var asset = assets[assetId];
|
|
@@ -35188,8 +34672,9 @@ var DEFAULT_FPS = 60;
|
|
|
35188
34672
|
]
|
|
35189
34673
|
});
|
|
35190
34674
|
for(var i1 = 0; i1 < comps.length; i1++){
|
|
35191
|
-
!comps[i1].renderFrame.
|
|
34675
|
+
!comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
|
|
35192
34676
|
}
|
|
34677
|
+
this.renderer.renderTargetPool.flush();
|
|
35193
34678
|
};
|
|
35194
34679
|
/**
|
|
35195
34680
|
* 将渲染器重新和父容器大小对齐
|
|
@@ -35435,6 +34920,95 @@ var DEFAULT_FPS = 60;
|
|
|
35435
34920
|
return Engine;
|
|
35436
34921
|
}(EventEmitter);
|
|
35437
34922
|
|
|
34923
|
+
var def = {
|
|
34924
|
+
format: glContext.RGBA,
|
|
34925
|
+
type: glContext.UNSIGNED_BYTE,
|
|
34926
|
+
minFilter: glContext.LINEAR,
|
|
34927
|
+
magFilter: glContext.LINEAR,
|
|
34928
|
+
wrapS: glContext.CLAMP_TO_EDGE,
|
|
34929
|
+
wrapT: glContext.CLAMP_TO_EDGE
|
|
34930
|
+
};
|
|
34931
|
+
var disposeSymbol = Symbol("dispose");
|
|
34932
|
+
var PassTextureCache = /*#__PURE__*/ function() {
|
|
34933
|
+
function PassTextureCache(engine) {
|
|
34934
|
+
this.textureCache = {};
|
|
34935
|
+
this.textureRef = {};
|
|
34936
|
+
this.engine = engine;
|
|
34937
|
+
}
|
|
34938
|
+
var _proto = PassTextureCache.prototype;
|
|
34939
|
+
_proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
|
|
34940
|
+
var _this = this;
|
|
34941
|
+
var width = request.width, height = request.height, name = request.name;
|
|
34942
|
+
var options = {
|
|
34943
|
+
sourceType: exports.TextureSourceType.framebuffer,
|
|
34944
|
+
data: {
|
|
34945
|
+
width: width,
|
|
34946
|
+
height: height
|
|
34947
|
+
},
|
|
34948
|
+
name: name
|
|
34949
|
+
};
|
|
34950
|
+
var keys = [
|
|
34951
|
+
name
|
|
34952
|
+
];
|
|
34953
|
+
Object.getOwnPropertyNames(def).forEach(function(name) {
|
|
34954
|
+
var _request_name;
|
|
34955
|
+
var value = (_request_name = request[name]) != null ? _request_name : def[name];
|
|
34956
|
+
options[name] = value;
|
|
34957
|
+
keys.push(name, value);
|
|
34958
|
+
});
|
|
34959
|
+
var cacheId = keys.join(":");
|
|
34960
|
+
var tex = this.textureCache[cacheId];
|
|
34961
|
+
if (tex) {
|
|
34962
|
+
this.textureRef[cacheId]++;
|
|
34963
|
+
} else {
|
|
34964
|
+
var engine = this.engine;
|
|
34965
|
+
assertExist(engine);
|
|
34966
|
+
tex = Texture.create(engine, options);
|
|
34967
|
+
this.textureCache[cacheId] = tex;
|
|
34968
|
+
this.textureRef[cacheId] = 1;
|
|
34969
|
+
// @ts-expect-error
|
|
34970
|
+
tex[disposeSymbol] = tex.dispose;
|
|
34971
|
+
tex.dispose = function() {
|
|
34972
|
+
return _this.removeTexture(cacheId);
|
|
34973
|
+
};
|
|
34974
|
+
}
|
|
34975
|
+
return tex;
|
|
34976
|
+
};
|
|
34977
|
+
_proto.removeTexture = function removeTexture(id) {
|
|
34978
|
+
var refCount = this.textureRef[id];
|
|
34979
|
+
if (refCount <= 1) {
|
|
34980
|
+
if (refCount < 0) {
|
|
34981
|
+
console.error("Ref count < 0.");
|
|
34982
|
+
}
|
|
34983
|
+
var tex = this.textureCache[id];
|
|
34984
|
+
if (tex) {
|
|
34985
|
+
// @ts-expect-error
|
|
34986
|
+
tex[disposeSymbol]();
|
|
34987
|
+
// @ts-expect-error
|
|
34988
|
+
tex.dispose = tex[disposeSymbol];
|
|
34989
|
+
}
|
|
34990
|
+
delete this.textureCache[id];
|
|
34991
|
+
delete this.textureRef[id];
|
|
34992
|
+
} else {
|
|
34993
|
+
this.textureRef[id] = refCount - 1;
|
|
34994
|
+
}
|
|
34995
|
+
};
|
|
34996
|
+
_proto.dispose = function dispose() {
|
|
34997
|
+
var _this = this;
|
|
34998
|
+
Object.keys(this.textureCache).forEach(function(key) {
|
|
34999
|
+
var texture = _this.textureCache[key];
|
|
35000
|
+
// @ts-expect-error
|
|
35001
|
+
texture[disposeSymbol]();
|
|
35002
|
+
// @ts-expect-error
|
|
35003
|
+
texture.dispose = texture[disposeSymbol];
|
|
35004
|
+
});
|
|
35005
|
+
this.textureCache = {};
|
|
35006
|
+
this.textureRef = {};
|
|
35007
|
+
this.engine = undefined;
|
|
35008
|
+
};
|
|
35009
|
+
return PassTextureCache;
|
|
35010
|
+
}();
|
|
35011
|
+
|
|
35438
35012
|
var SceneLoader = /*#__PURE__*/ function() {
|
|
35439
35013
|
function SceneLoader() {}
|
|
35440
35014
|
SceneLoader.load = function load(scene, engine, options) {
|
|
@@ -35453,16 +35027,16 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35453
35027
|
engine.assetManagers.push(assetManager);
|
|
35454
35028
|
return [
|
|
35455
35029
|
4,
|
|
35456
|
-
assetManager.loadScene(scene, engine.renderer
|
|
35457
|
-
env: engine.env
|
|
35458
|
-
})
|
|
35030
|
+
assetManager.loadScene(scene, engine.renderer)
|
|
35459
35031
|
];
|
|
35460
35032
|
case 1:
|
|
35461
35033
|
loadedScene = _state.sent();
|
|
35034
|
+
engine.clearResources();
|
|
35035
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
35036
|
+
PluginSystem.loadResources(loadedScene, assetManager.options, engine);
|
|
35462
35037
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35463
35038
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35464
35039
|
engine.assetService.initializeTexture(loadedScene);
|
|
35465
|
-
loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
|
|
35466
35040
|
composition = _this.createComposition(loadedScene, engine, options);
|
|
35467
35041
|
composition.setIndex(compositionIndex);
|
|
35468
35042
|
compileStart = performance.now();
|
|
@@ -35515,13 +35089,13 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35515
35089
|
return SceneLoader;
|
|
35516
35090
|
}();
|
|
35517
35091
|
|
|
35518
|
-
registerPlugin("camera", CameraVFXItemLoader
|
|
35519
|
-
registerPlugin("text", TextLoader
|
|
35520
|
-
registerPlugin("sprite", SpriteLoader
|
|
35521
|
-
registerPlugin("particle", ParticleLoader
|
|
35522
|
-
registerPlugin("cal", CalculateLoader
|
|
35523
|
-
registerPlugin("interact", InteractLoader
|
|
35524
|
-
var version$1 = "2.8.0-alpha.
|
|
35092
|
+
registerPlugin("camera", CameraVFXItemLoader);
|
|
35093
|
+
registerPlugin("text", TextLoader);
|
|
35094
|
+
registerPlugin("sprite", SpriteLoader);
|
|
35095
|
+
registerPlugin("particle", ParticleLoader);
|
|
35096
|
+
registerPlugin("cal", CalculateLoader);
|
|
35097
|
+
registerPlugin("interact", InteractLoader);
|
|
35098
|
+
var version$1 = "2.8.0-alpha.3";
|
|
35525
35099
|
logger.info("Core version: " + version$1 + ".");
|
|
35526
35100
|
|
|
35527
35101
|
var _obj;
|
|
@@ -36799,7 +36373,7 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
36799
36373
|
return [
|
|
36800
36374
|
4,
|
|
36801
36375
|
Promise.all(scenes.map(/*#__PURE__*/ _async_to_generator(function(url, index) {
|
|
36802
|
-
var _this_assetService_assembleSceneLoadOptions, source, opts, assetManager, _$scene, composition;
|
|
36376
|
+
var _this_assetService_assembleSceneLoadOptions, source, opts, assetManager, _$scene, engine, composition;
|
|
36803
36377
|
return __generator(this, function(_state) {
|
|
36804
36378
|
switch(_state.label){
|
|
36805
36379
|
case 0:
|
|
@@ -36809,16 +36383,17 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
36809
36383
|
assetManager = new AssetManager(opts);
|
|
36810
36384
|
return [
|
|
36811
36385
|
4,
|
|
36812
|
-
assetManager.loadScene(source, _this.renderer
|
|
36813
|
-
env: _this.env
|
|
36814
|
-
})
|
|
36386
|
+
assetManager.loadScene(source, _this.renderer)
|
|
36815
36387
|
];
|
|
36816
36388
|
case 1:
|
|
36817
36389
|
_$scene = _state.sent();
|
|
36390
|
+
engine = _this.engine;
|
|
36391
|
+
engine.clearResources();
|
|
36392
|
+
// 触发插件系统 pluginSystem 的回调 prepareResource
|
|
36393
|
+
PluginSystem.loadResources(_$scene, assetManager.options, engine);
|
|
36818
36394
|
_this.assetService.prepareAssets(_$scene, assetManager.getAssets());
|
|
36819
36395
|
_this.assetService.updateTextVariables(_$scene, assetManager.options.variables);
|
|
36820
36396
|
_this.assetService.initializeTexture(_$scene);
|
|
36821
|
-
_$scene.pluginSystem.precompile(_$scene.jsonScene.compositions, _this.renderer);
|
|
36822
36397
|
composition = _this.createComposition(_$scene, opts);
|
|
36823
36398
|
_this.baseCompositionIndex += 1;
|
|
36824
36399
|
composition.setIndex(baseOrder + index);
|
|
@@ -37110,7 +36685,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
37110
36685
|
*/ Mesh.create = function(engine, props) {
|
|
37111
36686
|
return new ThreeMesh(engine, props);
|
|
37112
36687
|
};
|
|
37113
|
-
var version = "2.8.0-alpha.
|
|
36688
|
+
var version = "2.8.0-alpha.3";
|
|
37114
36689
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
37115
36690
|
|
|
37116
36691
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -37225,7 +36800,6 @@ exports.Pose = Pose;
|
|
|
37225
36800
|
exports.PoseNode = PoseNode;
|
|
37226
36801
|
exports.PropertyClipPlayable = PropertyClipPlayable;
|
|
37227
36802
|
exports.PropertyTrack = PropertyTrack;
|
|
37228
|
-
exports.RENDER_PASS_NAME_PREFIX = RENDER_PASS_NAME_PREFIX;
|
|
37229
36803
|
exports.RENDER_PREFER_LOOKUP_TEXTURE = RENDER_PREFER_LOOKUP_TEXTURE;
|
|
37230
36804
|
exports.RUNTIME_ENV = RUNTIME_ENV;
|
|
37231
36805
|
exports.RandomSetValue = RandomSetValue;
|
|
@@ -37238,6 +36812,7 @@ exports.RenderPassPriorityNormal = RenderPassPriorityNormal;
|
|
|
37238
36812
|
exports.RenderPassPriorityPostprocess = RenderPassPriorityPostprocess;
|
|
37239
36813
|
exports.RenderPassPriorityPrepare = RenderPassPriorityPrepare;
|
|
37240
36814
|
exports.RenderTargetHandle = RenderTargetHandle;
|
|
36815
|
+
exports.RenderTargetPool = RenderTargetPool;
|
|
37241
36816
|
exports.Renderbuffer = Renderbuffer;
|
|
37242
36817
|
exports.Renderer = Renderer;
|
|
37243
36818
|
exports.RendererComponent = RendererComponent;
|
|
@@ -37306,14 +36881,12 @@ exports.colorGradingFrag = colorGradingFrag;
|
|
|
37306
36881
|
exports.colorStopsFromGradient = colorStopsFromGradient;
|
|
37307
36882
|
exports.colorToArr = colorToArr$1;
|
|
37308
36883
|
exports.combineImageTemplate = combineImageTemplate;
|
|
37309
|
-
exports.createCopyShader = createCopyShader;
|
|
37310
36884
|
exports.createGLContext = createGLContext;
|
|
37311
36885
|
exports.createKeyFrameMeta = createKeyFrameMeta;
|
|
37312
36886
|
exports.createShape = createShape;
|
|
37313
36887
|
exports.createValueGetter = createValueGetter;
|
|
37314
36888
|
exports.curveEps = curveEps;
|
|
37315
36889
|
exports.decimalEqual = decimalEqual;
|
|
37316
|
-
exports.defaultPlugins = defaultPlugins;
|
|
37317
36890
|
exports.deserializeMipmapTexture = deserializeMipmapTexture;
|
|
37318
36891
|
exports.earcut = earcut;
|
|
37319
36892
|
exports.effectsClass = effectsClass;
|
|
@@ -37321,7 +36894,6 @@ exports.effectsClassStore = effectsClassStore;
|
|
|
37321
36894
|
exports.enlargeBuffer = enlargeBuffer;
|
|
37322
36895
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
37323
36896
|
exports.ensureVec3 = ensureVec3;
|
|
37324
|
-
exports.findPreviousRenderPass = findPreviousRenderPass;
|
|
37325
36897
|
exports.gaussianDownHFrag = gaussianDownHFrag;
|
|
37326
36898
|
exports.gaussianDownVFrag = gaussianDownVFrag;
|
|
37327
36899
|
exports.gaussianUpFrag = gaussianUpFrag;
|
|
@@ -37342,6 +36914,7 @@ exports.getMergedStore = getMergedStore;
|
|
|
37342
36914
|
exports.getNodeDataClass = getNodeDataClass;
|
|
37343
36915
|
exports.getParticleMeshShader = getParticleMeshShader;
|
|
37344
36916
|
exports.getPixelRatio = getPixelRatio;
|
|
36917
|
+
exports.getPluginUsageInfo = getPluginUsageInfo;
|
|
37345
36918
|
exports.getPreMultiAlpha = getPreMultiAlpha;
|
|
37346
36919
|
exports.getStandardComposition = getStandardComposition;
|
|
37347
36920
|
exports.getStandardImage = getStandardImage;
|