@galacean/effects-core 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 CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.8.0-alpha.1
6
+ * Version: v2.8.0-alpha.3
7
7
  */
8
8
 
9
9
  'use strict';
@@ -37,41 +37,6 @@ function _async_to_generator(fn) {
37
37
  };
38
38
  }
39
39
 
40
- function _array_like_to_array(arr, len) {
41
- if (len == null || len > arr.length) len = arr.length;
42
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
43
- return arr2;
44
- }
45
-
46
- function _unsupported_iterable_to_array(o, minLen) {
47
- if (!o) return;
48
- if (typeof o === "string") return _array_like_to_array(o, minLen);
49
- var n = Object.prototype.toString.call(o).slice(8, -1);
50
- if (n === "Object" && o.constructor) n = o.constructor.name;
51
- if (n === "Map" || n === "Set") return Array.from(n);
52
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
53
- }
54
-
55
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
56
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
57
- if (it) return (it = it.call(o)).next.bind(it);
58
- // Fallback for engines without symbol support
59
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
60
- if (it) o = it;
61
- var i = 0;
62
- return function() {
63
- if (i >= o.length) return {
64
- done: true
65
- };
66
- return {
67
- done: false,
68
- value: o[i++]
69
- };
70
- };
71
- }
72
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
- }
74
-
75
40
  function _instanceof1(left, right) {
76
41
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
77
42
  return !!right[Symbol.hasInstance](left);
@@ -2904,134 +2869,68 @@ function applyMixins(derivedCtrl, baseCtrls) {
2904
2869
  }
2905
2870
 
2906
2871
  var pluginLoaderMap = {};
2907
- var defaultPlugins = [];
2908
- var pluginCtrlMap = {};
2872
+ var plugins = [];
2909
2873
  /**
2910
2874
  * 注册 plugin
2911
2875
  * @param name
2912
2876
  * @param pluginClass class of plugin
2913
2877
  * @param itemClass class of item
2914
2878
  * @param isDefault load
2915
- */ function registerPlugin(name, pluginClass, itemClass) {
2916
- if (pluginCtrlMap[name]) {
2879
+ */ function registerPlugin(name, pluginClass) {
2880
+ if (pluginLoaderMap[name]) {
2917
2881
  logger.error("Duplicate registration for plugin " + name + ".");
2918
2882
  }
2919
- pluginCtrlMap[name] = itemClass;
2920
2883
  pluginLoaderMap[name] = pluginClass;
2921
- addItem(defaultPlugins, name);
2884
+ var pluginInstance = new pluginClass();
2885
+ pluginInstance.name = name;
2886
+ pluginInstance.initialize();
2887
+ plugins.push(pluginInstance);
2888
+ plugins.sort(function(a, b) {
2889
+ return a.order - b.order;
2890
+ });
2922
2891
  }
2923
- function unregisterPlugin(name) {
2924
- delete pluginCtrlMap[name];
2892
+ /**
2893
+ * 注销 plugin
2894
+ */ function unregisterPlugin(name) {
2925
2895
  delete pluginLoaderMap[name];
2926
- removeItem(defaultPlugins, name);
2896
+ var pluginIndex = plugins.findIndex(function(plugin) {
2897
+ return plugin.name === name;
2898
+ });
2899
+ if (pluginIndex !== -1) {
2900
+ plugins.splice(pluginIndex, 1);
2901
+ }
2927
2902
  }
2928
2903
  var PluginSystem = /*#__PURE__*/ function() {
2929
- function PluginSystem(pluginNames) {
2930
- var loaders = {};
2931
- var loaded = [];
2932
- var addLoader = function(name) {
2933
- var loader = pluginLoaderMap[name];
2934
- if (!loaded.includes(loader)) {
2935
- loaded.push(loader);
2936
- loaders[name] = loader;
2937
- }
2938
- };
2939
- defaultPlugins.forEach(addLoader);
2940
- for(var _iterator = _create_for_of_iterator_helper_loose(pluginNames), _step; !(_step = _iterator()).done;){
2941
- var customPluginName = _step.value;
2942
- if (!pluginLoaderMap[customPluginName]) {
2943
- throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
2944
- }
2945
- }
2946
- this.plugins = Object.keys(loaders).map(function(name) {
2947
- var pluginConstructor = pluginLoaderMap[name];
2948
- var loader = new pluginConstructor();
2949
- loader.name = name;
2950
- return loader;
2951
- }).sort(function(a, b) {
2952
- return a.order - b.order;
2953
- });
2954
- }
2955
- var _proto = PluginSystem.prototype;
2956
- _proto.initializeComposition = function initializeComposition(composition, scene) {
2957
- this.plugins.forEach(function(loader) {
2904
+ function PluginSystem() {}
2905
+ PluginSystem.getPlugins = function getPlugins() {
2906
+ return plugins;
2907
+ };
2908
+ PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
2909
+ plugins.forEach(function(loader) {
2958
2910
  return loader.onCompositionConstructed(composition, scene);
2959
2911
  });
2960
2912
  };
2961
- _proto.destroyComposition = function destroyComposition(comp) {
2962
- this.plugins.forEach(function(loader) {
2913
+ PluginSystem.destroyComposition = function destroyComposition(comp) {
2914
+ plugins.forEach(function(loader) {
2963
2915
  return loader.onCompositionDestroyed(comp);
2964
2916
  });
2965
2917
  };
2966
- _proto.resetComposition = function resetComposition(comp, renderFrame) {
2967
- this.plugins.forEach(function(loader) {
2968
- return loader.onCompositionReset(comp, renderFrame);
2969
- });
2970
- };
2971
- _proto.processRawJSON = function processRawJSON(json, options) {
2972
- var _this = this;
2973
- return _async_to_generator(function() {
2974
- return __generator(this, function(_state) {
2975
- return [
2976
- 2,
2977
- _this.callStatic("processRawJSON", json, options)
2978
- ];
2979
- });
2980
- })();
2981
- };
2982
- _proto.processAssets = function processAssets(json, options) {
2983
- var _this = this;
2984
- return _async_to_generator(function() {
2985
- return __generator(this, function(_state) {
2986
- return [
2987
- 2,
2988
- _this.callStatic("processAssets", json, options)
2989
- ];
2990
- });
2991
- })();
2992
- };
2993
- _proto.precompile = function precompile(compositions, renderer) {
2994
- for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
2995
- var plugin = _step.value;
2996
- plugin.precompile(compositions, renderer);
2997
- }
2998
- };
2999
- _proto.loadResources = function loadResources(scene, options) {
3000
- var _this = this;
2918
+ PluginSystem.processAssets = function processAssets(scene, options) {
3001
2919
  return _async_to_generator(function() {
3002
2920
  return __generator(this, function(_state) {
3003
2921
  return [
3004
2922
  2,
3005
- _this.callStatic("prepareResource", scene, options)
2923
+ Promise.all(plugins.map(function(plugin) {
2924
+ return plugin.processAssets(scene, options);
2925
+ }))
3006
2926
  ];
3007
2927
  });
3008
2928
  })();
3009
2929
  };
3010
- _proto.callStatic = function callStatic(name) {
3011
- for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
3012
- args[_key - 1] = arguments[_key];
3013
- }
3014
- var _this = this;
3015
- return _async_to_generator(function() {
3016
- var pendings, plugins, i, plugin, ctrl, _ctrl_name, _ctrl_name1;
3017
- return __generator(this, function(_state) {
3018
- pendings = [];
3019
- plugins = _this.plugins;
3020
- for(i = 0; i < plugins.length; i++){
3021
- plugin = plugins[i];
3022
- ctrl = pluginLoaderMap[plugin.name];
3023
- if (name in ctrl) {
3024
- pendings.push(Promise.resolve((_ctrl_name1 = ctrl[name]) == null ? void 0 : (_ctrl_name = _ctrl_name1).call.apply(_ctrl_name, [].concat([
3025
- ctrl
3026
- ], args))));
3027
- }
3028
- }
3029
- return [
3030
- 2,
3031
- Promise.all(pendings)
3032
- ];
3033
- });
3034
- })();
2930
+ PluginSystem.loadResources = function loadResources(scene, options, engine) {
2931
+ plugins.forEach(function(loader) {
2932
+ return loader.prepareResource(scene, options, engine);
2933
+ });
3035
2934
  };
3036
2935
  return PluginSystem;
3037
2936
  }();
@@ -3039,6 +2938,8 @@ var pluginInfoMap = {
3039
2938
  "alipay-downgrade": "@galacean/effects-plugin-alipay-downgrade",
3040
2939
  "downgrade": "@galacean/effects-plugin-downgrade",
3041
2940
  "editor-gizmo": "@galacean/effects-plugin-editor-gizmo",
2941
+ "ffd": "@galacean/effects-plugin-ffd",
2942
+ "ktx2": "@galacean/effects-plugin-ktx2",
3042
2943
  "model": "@galacean/effects-plugin-model",
3043
2944
  "video": "@galacean/effects-plugin-multimedia",
3044
2945
  "audio": "@galacean/effects-plugin-multimedia",
@@ -3064,15 +2965,33 @@ function getPluginUsageInfo(name) {
3064
2965
  this.name = "";
3065
2966
  }
3066
2967
  var _proto = AbstractPlugin.prototype;
2968
+ _proto.initialize = function initialize() {};
3067
2969
  /**
3068
- * 在加载到 JSON 后,就可以进行提前编译
3069
- * @param json
3070
- * @param player
3071
- */ _proto.precompile = function precompile(compositions, renderer) {};
2970
+ * loadScene 函数调用的时候会触发此函数,
2971
+ * 此阶段可以加载插件所需类型资源,并返回原始资源和加载后的资源。
2972
+ * @param scene
2973
+ * @param options
2974
+ * @returns
2975
+ */ _proto.processAssets = function processAssets(scene, options) {
2976
+ return _async_to_generator(function() {
2977
+ return __generator(this, function(_state) {
2978
+ return [
2979
+ 2
2980
+ ];
2981
+ });
2982
+ })();
2983
+ };
2984
+ /**
2985
+ * loadScene 函数调用的时候会触发此函数,
2986
+ * 此阶段时,json 中的图片和二进制已经被加载完成,可以对加载好的资源做进一步处理,
2987
+ * 如果 promise 被 reject, loadScene 函数同样会被 reject,表示场景加载失败。
2988
+ * 请记住,整个 load 阶段都不要创建 GL 相关的对象,只创建 JS 对象
2989
+ * 此阶段晚于 processAssets
2990
+ * @param {Scene} scene
2991
+ * @param {SceneLoadOptions} options
2992
+ */ _proto.prepareResource = function prepareResource(scene, options, engine) {};
3072
2993
  _proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {};
3073
- _proto.onCompositionReset = function onCompositionReset(composition, frame) {};
3074
2994
  _proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {};
3075
- _proto.onCompositionUpdate = function onCompositionUpdate(composition, dt) {};
3076
2995
  return AbstractPlugin;
3077
2996
  }();
3078
2997
 
@@ -4057,6 +3976,41 @@ var index$1 = /*#__PURE__*/Object.freeze({
4057
3976
  get VertexBufferSemantic () { return VertexBufferSemantic; }
4058
3977
  });
4059
3978
 
3979
+ function _array_like_to_array(arr, len) {
3980
+ if (len == null || len > arr.length) len = arr.length;
3981
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
3982
+ return arr2;
3983
+ }
3984
+
3985
+ function _unsupported_iterable_to_array(o, minLen) {
3986
+ if (!o) return;
3987
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
3988
+ var n = Object.prototype.toString.call(o).slice(8, -1);
3989
+ if (n === "Object" && o.constructor) n = o.constructor.name;
3990
+ if (n === "Map" || n === "Set") return Array.from(n);
3991
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
3992
+ }
3993
+
3994
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
3995
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
3996
+ if (it) return (it = it.call(o)).next.bind(it);
3997
+ // Fallback for engines without symbol support
3998
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
3999
+ if (it) o = it;
4000
+ var i = 0;
4001
+ return function() {
4002
+ if (i >= o.length) return {
4003
+ done: true
4004
+ };
4005
+ return {
4006
+ done: false,
4007
+ value: o[i++]
4008
+ };
4009
+ };
4010
+ }
4011
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4012
+ }
4013
+
4060
4014
  var decoratorInitialStore = new Map();
4061
4015
  var mergedStore = new Map();
4062
4016
  var effectsClassStore = {};
@@ -7276,13 +7230,388 @@ __decorate([
7276
7230
  serialize()
7277
7231
  ], RendererComponent.prototype, "_priority", void 0);
7278
7232
 
7233
+ exports.ShaderType = void 0;
7234
+ (function(ShaderType) {
7235
+ ShaderType[ShaderType["vertex"] = 0] = "vertex";
7236
+ ShaderType[ShaderType["fragment"] = 1] = "fragment";
7237
+ })(exports.ShaderType || (exports.ShaderType = {}));
7238
+ exports.MaskMode = void 0;
7239
+ (function(MaskMode) {
7240
+ /**
7241
+ * 无
7242
+ */ MaskMode[MaskMode["NONE"] = 0] = "NONE";
7243
+ /**
7244
+ * 蒙版
7245
+ */ MaskMode[MaskMode["MASK"] = 1] = "MASK";
7246
+ /**
7247
+ * 被遮挡
7248
+ */ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
7249
+ /**
7250
+ * 被反向遮挡
7251
+ */ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
7252
+ })(exports.MaskMode || (exports.MaskMode = {}));
7253
+
7254
+ exports.TextureLoadAction = void 0;
7255
+ (function(TextureLoadAction) {
7256
+ TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
7257
+ //preserve previous attachment
7258
+ //load = 1,
7259
+ //clear attachment
7260
+ TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
7261
+ })(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
7262
+ exports.TextureSourceType = void 0;
7263
+ (function(TextureSourceType) {
7264
+ TextureSourceType[TextureSourceType["none"] = 0] = "none";
7265
+ TextureSourceType[TextureSourceType["data"] = 1] = "data";
7266
+ TextureSourceType[TextureSourceType["image"] = 2] = "image";
7267
+ TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
7268
+ TextureSourceType[TextureSourceType["video"] = 4] = "video";
7269
+ TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
7270
+ TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
7271
+ TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
7272
+ })(exports.TextureSourceType || (exports.TextureSourceType = {}));
7273
+
7274
+ var MaskProcessor = /*#__PURE__*/ function() {
7275
+ function MaskProcessor(engine) {
7276
+ this.engine = engine;
7277
+ this.alphaMaskEnabled = false;
7278
+ this.maskMode = exports.MaskMode.NONE;
7279
+ this.maskable = null;
7280
+ this.stencilClearAction = {
7281
+ stencilAction: exports.TextureLoadAction.clear
7282
+ };
7283
+ }
7284
+ var _proto = MaskProcessor.prototype;
7285
+ _proto.getRefValue = function getRefValue() {
7286
+ return 1;
7287
+ };
7288
+ _proto.setMaskOptions = function setMaskOptions(data) {
7289
+ 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;
7290
+ this.alphaMaskEnabled = alphaMaskEnabled;
7291
+ if (isMask) {
7292
+ this.maskMode = exports.MaskMode.MASK;
7293
+ } else {
7294
+ this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
7295
+ this.maskable = this.engine.findObject(reference);
7296
+ }
7297
+ };
7298
+ _proto.drawStencilMask = function drawStencilMask(renderer) {
7299
+ if (this.maskable) {
7300
+ renderer.clear(this.stencilClearAction);
7301
+ this.maskable.drawStencilMask(renderer);
7302
+ }
7303
+ };
7304
+ return MaskProcessor;
7305
+ }();
7306
+
7307
+ /**
7308
+ * Helper class to create a WebGL Context
7309
+ *
7310
+ * @param canvas
7311
+ * @param glType
7312
+ * @param options
7313
+ * @returns
7314
+ */ function createGLContext(canvas, glType, options) {
7315
+ if (glType === void 0) glType = "webgl";
7316
+ var context;
7317
+ if (glType === "webgl2") {
7318
+ context = canvas.getContext("webgl2", options);
7319
+ if (!context) {
7320
+ console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
7321
+ }
7322
+ }
7323
+ if (!context || glType === "webgl") {
7324
+ context = canvas.getContext("webgl", options);
7325
+ }
7326
+ if (!context) {
7327
+ throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
7328
+ }
7329
+ return context;
7330
+ }
7331
+
7332
+ function gpuTimer(gl) {
7333
+ var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
7334
+ if (ext) {
7335
+ var query = gl.createQuery();
7336
+ var getTime = /*#__PURE__*/ _async_to_generator(function() {
7337
+ return __generator(this, function(_state) {
7338
+ return [
7339
+ 2,
7340
+ new Promise(function(resolve, reject) {
7341
+ if (query) {
7342
+ var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
7343
+ var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
7344
+ if (available && !disjoint) {
7345
+ // See how much time the rendering of the object took in nanoseconds.
7346
+ var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
7347
+ // taken to use all significant bits of the result, not just the
7348
+ // least significant 32 bits.
7349
+ resolve(timeElapsed / 1000 / 1000);
7350
+ }
7351
+ if (available || disjoint) {
7352
+ // Clean up the query object.
7353
+ gl.deleteQuery(query); // Don't re-enter this polling loop.
7354
+ query = null;
7355
+ }
7356
+ available !== null && query && window.setTimeout(function() {
7357
+ getTime().then(resolve).catch;
7358
+ }, 1);
7359
+ }
7360
+ })
7361
+ ];
7362
+ });
7363
+ });
7364
+ if (!query) {
7365
+ return;
7366
+ }
7367
+ return {
7368
+ begin: function() {
7369
+ query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
7370
+ },
7371
+ end: function() {
7372
+ gl.endQuery(ext.TIME_ELAPSED_EXT);
7373
+ },
7374
+ getTime: getTime
7375
+ };
7376
+ }
7377
+ }
7378
+
7379
+ var initErrors = [];
7380
+ var glContext = {};
7381
+ var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
7382
+ var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
7383
+ if (!initErrors.length) {
7384
+ initGLContext();
7385
+ }
7386
+ function initGLContext() {
7387
+ // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
7388
+ if (typeof WebGL2RenderingContext === "function") {
7389
+ copy(WebGL2RenderingContext);
7390
+ } else if (typeof WebGLRenderingContext !== "undefined") {
7391
+ copy(WebGLRenderingContext);
7392
+ copy(WebGLRenderingContext.prototype);
7393
+ } else {
7394
+ if (canUseBOM) {
7395
+ initErrors.push(// iOS 16 lockdown mode
7396
+ isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
7397
+ } else {
7398
+ initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
7399
+ }
7400
+ }
7401
+ if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
7402
+ // @ts-expect-error set default value
7403
+ glContext["HALF_FLOAT"] = 5131;
7404
+ }
7405
+ }
7406
+ function isWebGL2(gl) {
7407
+ return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
7408
+ }
7409
+ function copy(target) {
7410
+ for(var name in target){
7411
+ if (/^[A-Z_]/.test(name)) {
7412
+ // @ts-expect-error safe to assign
7413
+ glContext[name] = target[name];
7414
+ }
7415
+ }
7416
+ }
7417
+ function vertexFormatType2GLType(formatType) {
7418
+ switch(formatType){
7419
+ case VertexFormatType.Float32:
7420
+ return WebGLRenderingContext["FLOAT"];
7421
+ case VertexFormatType.Int16:
7422
+ return WebGLRenderingContext["SHORT"];
7423
+ case VertexFormatType.Int8:
7424
+ return WebGLRenderingContext["BYTE"];
7425
+ case VertexFormatType.UInt16:
7426
+ return WebGLRenderingContext["UNSIGNED_SHORT"];
7427
+ case VertexFormatType.UInt8:
7428
+ return WebGLRenderingContext["UNSIGNED_BYTE"];
7429
+ default:
7430
+ return WebGLRenderingContext["FLOAT"];
7431
+ }
7432
+ }
7433
+ function glType2VertexFormatType(webglType) {
7434
+ switch(webglType){
7435
+ case WebGLRenderingContext["FLOAT"]:
7436
+ return VertexFormatType.Float32;
7437
+ case WebGLRenderingContext["SHORT"]:
7438
+ return VertexFormatType.Int16;
7439
+ case WebGLRenderingContext["BYTE"]:
7440
+ return VertexFormatType.Int8;
7441
+ case WebGLRenderingContext["UNSIGNED_SHORT"]:
7442
+ return VertexFormatType.UInt16;
7443
+ case WebGLRenderingContext["UNSIGNED_BYTE"]:
7444
+ return VertexFormatType.UInt8;
7445
+ default:
7446
+ return VertexFormatType.Float32;
7447
+ }
7448
+ }
7449
+
7450
+ function valIfUndefined(val, def) {
7451
+ if (val === undefined || val === null) {
7452
+ return def;
7453
+ }
7454
+ return val;
7455
+ }
7456
+ function getPreMultiAlpha(blending) {
7457
+ switch(blending){
7458
+ case BlendingMode.ALPHA:
7459
+ return 1;
7460
+ case BlendingMode.ADD:
7461
+ return 1;
7462
+ case BlendingMode.SUBTRACTION:
7463
+ return 1;
7464
+ case BlendingMode.STRONG_LIGHT:
7465
+ return 1;
7466
+ case BlendingMode.WEAK_LIGHT:
7467
+ return 1;
7468
+ case BlendingMode.SUPERPOSITION:
7469
+ return 2;
7470
+ case BlendingMode.BRIGHTNESS:
7471
+ return 3;
7472
+ case BlendingMode.MULTIPLY:
7473
+ return 0;
7474
+ default:
7475
+ // 处理undefined
7476
+ return 1;
7477
+ }
7478
+ }
7479
+ function setBlendMode(material, blendMode) {
7480
+ switch(blendMode){
7481
+ case undefined:
7482
+ material.blendFunction = [
7483
+ glContext.ONE,
7484
+ glContext.ONE_MINUS_SRC_ALPHA,
7485
+ glContext.ONE,
7486
+ glContext.ONE_MINUS_SRC_ALPHA
7487
+ ];
7488
+ break;
7489
+ case BlendingMode.ALPHA:
7490
+ material.blendFunction = [
7491
+ glContext.ONE,
7492
+ glContext.ONE_MINUS_SRC_ALPHA,
7493
+ glContext.ONE,
7494
+ glContext.ONE_MINUS_SRC_ALPHA
7495
+ ];
7496
+ break;
7497
+ case BlendingMode.ADD:
7498
+ material.blendFunction = [
7499
+ glContext.ONE,
7500
+ glContext.ONE,
7501
+ glContext.ONE,
7502
+ glContext.ONE
7503
+ ];
7504
+ break;
7505
+ case BlendingMode.SUBTRACTION:
7506
+ material.blendFunction = [
7507
+ glContext.ONE,
7508
+ glContext.ONE,
7509
+ glContext.ZERO,
7510
+ glContext.ONE
7511
+ ];
7512
+ material.blendEquation = [
7513
+ glContext.FUNC_REVERSE_SUBTRACT,
7514
+ glContext.FUNC_REVERSE_SUBTRACT
7515
+ ];
7516
+ break;
7517
+ case BlendingMode.SUPERPOSITION:
7518
+ material.blendFunction = [
7519
+ glContext.ONE,
7520
+ glContext.ONE,
7521
+ glContext.ONE,
7522
+ glContext.ONE
7523
+ ];
7524
+ break;
7525
+ case BlendingMode.MULTIPLY:
7526
+ material.blendFunction = [
7527
+ glContext.DST_COLOR,
7528
+ glContext.ONE_MINUS_SRC_ALPHA,
7529
+ glContext.DST_COLOR,
7530
+ glContext.ONE_MINUS_SRC_ALPHA
7531
+ ];
7532
+ break;
7533
+ case BlendingMode.BRIGHTNESS:
7534
+ material.blendFunction = [
7535
+ glContext.ONE,
7536
+ glContext.ONE_MINUS_SRC_ALPHA,
7537
+ glContext.ONE,
7538
+ glContext.ONE_MINUS_SRC_ALPHA
7539
+ ];
7540
+ break;
7541
+ case BlendingMode.STRONG_LIGHT:
7542
+ material.blendFunction = [
7543
+ glContext.DST_COLOR,
7544
+ glContext.DST_ALPHA,
7545
+ glContext.ZERO,
7546
+ glContext.ONE
7547
+ ];
7548
+ break;
7549
+ case BlendingMode.WEAK_LIGHT:
7550
+ material.blendFunction = [
7551
+ glContext.DST_COLOR,
7552
+ glContext.ZERO,
7553
+ glContext.ZERO,
7554
+ glContext.ONE
7555
+ ];
7556
+ break;
7557
+ default:
7558
+ console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
7559
+ }
7560
+ }
7561
+ function setSideMode(material, side) {
7562
+ if (side === SideMode.DOUBLE) {
7563
+ material.culling = false;
7564
+ } else {
7565
+ material.culling = true;
7566
+ material.frontFace = glContext.CW;
7567
+ material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
7568
+ }
7569
+ }
7570
+ function setMaskMode(material, maskMode) {
7571
+ switch(maskMode){
7572
+ case undefined:
7573
+ material.stencilTest = false;
7574
+ break;
7575
+ case exports.MaskMode.MASK:
7576
+ material.stencilTest = true;
7577
+ material.stencilFunc = [
7578
+ glContext.ALWAYS,
7579
+ glContext.ALWAYS
7580
+ ];
7581
+ material.stencilOpZPass = [
7582
+ glContext.REPLACE,
7583
+ glContext.REPLACE
7584
+ ];
7585
+ break;
7586
+ case exports.MaskMode.OBSCURED:
7587
+ material.stencilTest = true;
7588
+ material.stencilFunc = [
7589
+ glContext.EQUAL,
7590
+ glContext.EQUAL
7591
+ ];
7592
+ break;
7593
+ case exports.MaskMode.REVERSE_OBSCURED:
7594
+ material.stencilTest = true;
7595
+ material.stencilFunc = [
7596
+ glContext.NOTEQUAL,
7597
+ glContext.NOTEQUAL
7598
+ ];
7599
+ break;
7600
+ case exports.MaskMode.NONE:
7601
+ material.stencilTest = false;
7602
+ break;
7603
+ default:
7604
+ console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
7605
+ }
7606
+ }
7607
+
7279
7608
  /**
7280
7609
  * Mesh 组件
7281
7610
  */ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
7282
7611
  _inherits(MeshComponent, RendererComponent);
7283
- function MeshComponent() {
7612
+ function MeshComponent(engine) {
7284
7613
  var _this;
7285
- _this = RendererComponent.apply(this, arguments) || this;
7614
+ _this = RendererComponent.call(this, engine) || this;
7286
7615
  /**
7287
7616
  * 用于点击测试的碰撞器
7288
7617
  */ _this.meshCollider = new MeshCollider();
@@ -7298,6 +7627,7 @@ __decorate([
7298
7627
  };
7299
7628
  }
7300
7629
  };
7630
+ _this.maskManager = new MaskProcessor(engine);
7301
7631
  return _this;
7302
7632
  }
7303
7633
  var _proto = MeshComponent.prototype;
@@ -7307,12 +7637,42 @@ __decorate([
7307
7637
  renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
7308
7638
  }
7309
7639
  };
7640
+ _proto.drawStencilMask = function drawStencilMask(renderer) {
7641
+ if (!this.isActiveAndEnabled) {
7642
+ return;
7643
+ }
7644
+ for(var i = 0; i < this.materials.length; i++){
7645
+ var material = this.materials[i];
7646
+ var previousColorMask = material.colorMask;
7647
+ material.colorMask = false;
7648
+ renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
7649
+ material.colorMask = previousColorMask;
7650
+ }
7651
+ };
7310
7652
  _proto.getBoundingBox = function getBoundingBox() {
7311
7653
  var worldMatrix = this.transform.getWorldMatrix();
7312
7654
  this.meshCollider.setGeometry(this.geometry, worldMatrix);
7313
7655
  var boundingBox = this.meshCollider.getBoundingBox();
7314
7656
  return boundingBox;
7315
7657
  };
7658
+ // TODO: Update data spec
7659
+ _proto.fromData = function fromData(data) {
7660
+ RendererComponent.prototype.fromData.call(this, data);
7661
+ var maskableRendererData = data;
7662
+ var maskOptions = maskableRendererData.mask;
7663
+ if (maskOptions) {
7664
+ this.maskManager.setMaskOptions(maskOptions);
7665
+ }
7666
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
7667
+ var material = _step.value;
7668
+ var stencilRef = this.maskManager.getRefValue();
7669
+ material.stencilRef = [
7670
+ stencilRef,
7671
+ stencilRef
7672
+ ];
7673
+ setMaskMode(material, this.maskManager.maskMode);
7674
+ }
7675
+ };
7316
7676
  return MeshComponent;
7317
7677
  }(RendererComponent);
7318
7678
  __decorate([
@@ -8502,348 +8862,6 @@ Matrix4.tempVec1 = new Vector3();
8502
8862
  Matrix4.tempVec2 = new Vector3();
8503
8863
  Matrix4.tempMat0 = new Matrix4();
8504
8864
 
8505
- /**
8506
- * Helper class to create a WebGL Context
8507
- *
8508
- * @param canvas
8509
- * @param glType
8510
- * @param options
8511
- * @returns
8512
- */ function createGLContext(canvas, glType, options) {
8513
- if (glType === void 0) glType = "webgl";
8514
- var context;
8515
- if (glType === "webgl2") {
8516
- context = canvas.getContext("webgl2", options);
8517
- if (!context) {
8518
- console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
8519
- }
8520
- }
8521
- if (!context || glType === "webgl") {
8522
- context = canvas.getContext("webgl", options);
8523
- }
8524
- if (!context) {
8525
- throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
8526
- }
8527
- return context;
8528
- }
8529
-
8530
- function gpuTimer(gl) {
8531
- var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
8532
- if (ext) {
8533
- var query = gl.createQuery();
8534
- var getTime = /*#__PURE__*/ _async_to_generator(function() {
8535
- return __generator(this, function(_state) {
8536
- return [
8537
- 2,
8538
- new Promise(function(resolve, reject) {
8539
- if (query) {
8540
- var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
8541
- var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
8542
- if (available && !disjoint) {
8543
- // See how much time the rendering of the object took in nanoseconds.
8544
- var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
8545
- // taken to use all significant bits of the result, not just the
8546
- // least significant 32 bits.
8547
- resolve(timeElapsed / 1000 / 1000);
8548
- }
8549
- if (available || disjoint) {
8550
- // Clean up the query object.
8551
- gl.deleteQuery(query); // Don't re-enter this polling loop.
8552
- query = null;
8553
- }
8554
- available !== null && query && window.setTimeout(function() {
8555
- getTime().then(resolve).catch;
8556
- }, 1);
8557
- }
8558
- })
8559
- ];
8560
- });
8561
- });
8562
- if (!query) {
8563
- return;
8564
- }
8565
- return {
8566
- begin: function() {
8567
- query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
8568
- },
8569
- end: function() {
8570
- gl.endQuery(ext.TIME_ELAPSED_EXT);
8571
- },
8572
- getTime: getTime
8573
- };
8574
- }
8575
- }
8576
-
8577
- var initErrors = [];
8578
- var glContext = {};
8579
- var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
8580
- var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
8581
- if (!initErrors.length) {
8582
- initGLContext();
8583
- }
8584
- function initGLContext() {
8585
- // 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
8586
- if (typeof WebGL2RenderingContext === "function") {
8587
- copy(WebGL2RenderingContext);
8588
- } else if (typeof WebGLRenderingContext !== "undefined") {
8589
- copy(WebGLRenderingContext);
8590
- copy(WebGLRenderingContext.prototype);
8591
- } else {
8592
- if (canUseBOM) {
8593
- initErrors.push(// iOS 16 lockdown mode
8594
- isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
8595
- } else {
8596
- initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
8597
- }
8598
- }
8599
- if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
8600
- // @ts-expect-error set default value
8601
- glContext["HALF_FLOAT"] = 5131;
8602
- }
8603
- }
8604
- function isWebGL2(gl) {
8605
- return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
8606
- }
8607
- function copy(target) {
8608
- for(var name in target){
8609
- if (/^[A-Z_]/.test(name)) {
8610
- // @ts-expect-error safe to assign
8611
- glContext[name] = target[name];
8612
- }
8613
- }
8614
- }
8615
- function vertexFormatType2GLType(formatType) {
8616
- switch(formatType){
8617
- case VertexFormatType.Float32:
8618
- return WebGLRenderingContext["FLOAT"];
8619
- case VertexFormatType.Int16:
8620
- return WebGLRenderingContext["SHORT"];
8621
- case VertexFormatType.Int8:
8622
- return WebGLRenderingContext["BYTE"];
8623
- case VertexFormatType.UInt16:
8624
- return WebGLRenderingContext["UNSIGNED_SHORT"];
8625
- case VertexFormatType.UInt8:
8626
- return WebGLRenderingContext["UNSIGNED_BYTE"];
8627
- default:
8628
- return WebGLRenderingContext["FLOAT"];
8629
- }
8630
- }
8631
- function glType2VertexFormatType(webglType) {
8632
- switch(webglType){
8633
- case WebGLRenderingContext["FLOAT"]:
8634
- return VertexFormatType.Float32;
8635
- case WebGLRenderingContext["SHORT"]:
8636
- return VertexFormatType.Int16;
8637
- case WebGLRenderingContext["BYTE"]:
8638
- return VertexFormatType.Int8;
8639
- case WebGLRenderingContext["UNSIGNED_SHORT"]:
8640
- return VertexFormatType.UInt16;
8641
- case WebGLRenderingContext["UNSIGNED_BYTE"]:
8642
- return VertexFormatType.UInt8;
8643
- default:
8644
- return VertexFormatType.Float32;
8645
- }
8646
- }
8647
-
8648
- exports.ShaderType = void 0;
8649
- (function(ShaderType) {
8650
- ShaderType[ShaderType["vertex"] = 0] = "vertex";
8651
- ShaderType[ShaderType["fragment"] = 1] = "fragment";
8652
- })(exports.ShaderType || (exports.ShaderType = {}));
8653
- exports.MaskMode = void 0;
8654
- (function(MaskMode) {
8655
- /**
8656
- * 无
8657
- */ MaskMode[MaskMode["NONE"] = 0] = "NONE";
8658
- /**
8659
- * 蒙版
8660
- */ MaskMode[MaskMode["MASK"] = 1] = "MASK";
8661
- /**
8662
- * 被遮挡
8663
- */ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
8664
- /**
8665
- * 被反向遮挡
8666
- */ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
8667
- })(exports.MaskMode || (exports.MaskMode = {}));
8668
-
8669
- function valIfUndefined(val, def) {
8670
- if (val === undefined || val === null) {
8671
- return def;
8672
- }
8673
- return val;
8674
- }
8675
- function getPreMultiAlpha(blending) {
8676
- switch(blending){
8677
- case BlendingMode.ALPHA:
8678
- return 1;
8679
- case BlendingMode.ADD:
8680
- return 1;
8681
- case BlendingMode.SUBTRACTION:
8682
- return 1;
8683
- case BlendingMode.STRONG_LIGHT:
8684
- return 1;
8685
- case BlendingMode.WEAK_LIGHT:
8686
- return 1;
8687
- case BlendingMode.SUPERPOSITION:
8688
- return 2;
8689
- case BlendingMode.BRIGHTNESS:
8690
- return 3;
8691
- case BlendingMode.MULTIPLY:
8692
- return 0;
8693
- default:
8694
- // 处理undefined
8695
- return 1;
8696
- }
8697
- }
8698
- function setBlendMode(material, blendMode) {
8699
- switch(blendMode){
8700
- case undefined:
8701
- material.blendFunction = [
8702
- glContext.ONE,
8703
- glContext.ONE_MINUS_SRC_ALPHA,
8704
- glContext.ONE,
8705
- glContext.ONE_MINUS_SRC_ALPHA
8706
- ];
8707
- break;
8708
- case BlendingMode.ALPHA:
8709
- material.blendFunction = [
8710
- glContext.ONE,
8711
- glContext.ONE_MINUS_SRC_ALPHA,
8712
- glContext.ONE,
8713
- glContext.ONE_MINUS_SRC_ALPHA
8714
- ];
8715
- break;
8716
- case BlendingMode.ADD:
8717
- material.blendFunction = [
8718
- glContext.ONE,
8719
- glContext.ONE,
8720
- glContext.ONE,
8721
- glContext.ONE
8722
- ];
8723
- break;
8724
- case BlendingMode.SUBTRACTION:
8725
- material.blendFunction = [
8726
- glContext.ONE,
8727
- glContext.ONE,
8728
- glContext.ZERO,
8729
- glContext.ONE
8730
- ];
8731
- material.blendEquation = [
8732
- glContext.FUNC_REVERSE_SUBTRACT,
8733
- glContext.FUNC_REVERSE_SUBTRACT
8734
- ];
8735
- break;
8736
- case BlendingMode.SUPERPOSITION:
8737
- material.blendFunction = [
8738
- glContext.ONE,
8739
- glContext.ONE,
8740
- glContext.ONE,
8741
- glContext.ONE
8742
- ];
8743
- break;
8744
- case BlendingMode.MULTIPLY:
8745
- material.blendFunction = [
8746
- glContext.DST_COLOR,
8747
- glContext.ONE_MINUS_SRC_ALPHA,
8748
- glContext.DST_COLOR,
8749
- glContext.ONE_MINUS_SRC_ALPHA
8750
- ];
8751
- break;
8752
- case BlendingMode.BRIGHTNESS:
8753
- material.blendFunction = [
8754
- glContext.ONE,
8755
- glContext.ONE_MINUS_SRC_ALPHA,
8756
- glContext.ONE,
8757
- glContext.ONE_MINUS_SRC_ALPHA
8758
- ];
8759
- break;
8760
- case BlendingMode.STRONG_LIGHT:
8761
- material.blendFunction = [
8762
- glContext.DST_COLOR,
8763
- glContext.DST_ALPHA,
8764
- glContext.ZERO,
8765
- glContext.ONE
8766
- ];
8767
- break;
8768
- case BlendingMode.WEAK_LIGHT:
8769
- material.blendFunction = [
8770
- glContext.DST_COLOR,
8771
- glContext.ZERO,
8772
- glContext.ZERO,
8773
- glContext.ONE
8774
- ];
8775
- break;
8776
- default:
8777
- console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
8778
- }
8779
- }
8780
- function setSideMode(material, side) {
8781
- if (side === SideMode.DOUBLE) {
8782
- material.culling = false;
8783
- } else {
8784
- material.culling = true;
8785
- material.frontFace = glContext.CW;
8786
- material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
8787
- }
8788
- }
8789
- function setMaskMode(material, maskMode) {
8790
- switch(maskMode){
8791
- case undefined:
8792
- material.stencilTest = false;
8793
- break;
8794
- case exports.MaskMode.MASK:
8795
- material.stencilTest = true;
8796
- material.stencilFunc = [
8797
- glContext.ALWAYS,
8798
- glContext.ALWAYS
8799
- ];
8800
- material.stencilOpZPass = [
8801
- glContext.REPLACE,
8802
- glContext.REPLACE
8803
- ];
8804
- break;
8805
- case exports.MaskMode.OBSCURED:
8806
- material.stencilTest = true;
8807
- material.stencilFunc = [
8808
- glContext.EQUAL,
8809
- glContext.EQUAL
8810
- ];
8811
- break;
8812
- case exports.MaskMode.REVERSE_OBSCURED:
8813
- material.stencilTest = true;
8814
- material.stencilFunc = [
8815
- glContext.NOTEQUAL,
8816
- glContext.NOTEQUAL
8817
- ];
8818
- break;
8819
- case exports.MaskMode.NONE:
8820
- material.stencilTest = false;
8821
- break;
8822
- default:
8823
- console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
8824
- }
8825
- }
8826
-
8827
- exports.TextureLoadAction = void 0;
8828
- (function(TextureLoadAction) {
8829
- TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
8830
- //preserve previous attachment
8831
- //load = 1,
8832
- //clear attachment
8833
- TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
8834
- })(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
8835
- exports.TextureSourceType = void 0;
8836
- (function(TextureSourceType) {
8837
- TextureSourceType[TextureSourceType["none"] = 0] = "none";
8838
- TextureSourceType[TextureSourceType["data"] = 1] = "data";
8839
- TextureSourceType[TextureSourceType["image"] = 2] = "image";
8840
- TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
8841
- TextureSourceType[TextureSourceType["video"] = 4] = "video";
8842
- TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
8843
- TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
8844
- TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
8845
- })(exports.TextureSourceType || (exports.TextureSourceType = {}));
8846
-
8847
8865
  /**
8848
8866
  * 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
8849
8867
  */ var Downloader = /*#__PURE__*/ function() {
@@ -10322,208 +10340,72 @@ exports.MaterialRenderType = void 0;
10322
10340
  return Material;
10323
10341
  }(EffectsObject);
10324
10342
 
10325
- var MaskProcessor = /*#__PURE__*/ function() {
10326
- function MaskProcessor(engine) {
10327
- this.engine = engine;
10328
- this.alphaMaskEnabled = false;
10329
- this.maskMode = exports.MaskMode.NONE;
10330
- this.maskable = null;
10331
- this.stencilClearAction = {
10332
- stencilAction: exports.TextureLoadAction.clear
10333
- };
10334
- }
10335
- var _proto = MaskProcessor.prototype;
10336
- _proto.getRefValue = function getRefValue() {
10337
- return 1;
10343
+ var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
10344
+ var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
10345
+ 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}";
10346
+ 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";
10347
+
10348
+ exports.FilterMode = void 0;
10349
+ (function(FilterMode) {
10350
+ FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
10351
+ FilterMode[FilterMode["Linear"] = 1] = "Linear";
10352
+ })(exports.FilterMode || (exports.FilterMode = {}));
10353
+ exports.RenderTextureFormat = void 0;
10354
+ (function(RenderTextureFormat) {
10355
+ RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
10356
+ RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
10357
+ })(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
10358
+ /**
10359
+ *
10360
+ */ var Framebuffer = /*#__PURE__*/ function() {
10361
+ function Framebuffer() {}
10362
+ var _proto = Framebuffer.prototype;
10363
+ _proto.resize = function resize(x, y, width, height) {
10364
+ // OVERRIDE
10338
10365
  };
10339
- _proto.setMaskOptions = function setMaskOptions(data) {
10340
- 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;
10341
- this.alphaMaskEnabled = alphaMaskEnabled;
10342
- if (isMask) {
10343
- this.maskMode = exports.MaskMode.MASK;
10344
- } else {
10345
- this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
10346
- this.maskable = this.engine.findObject(reference);
10347
- }
10366
+ _proto.resetColorTextures = function resetColorTextures(textures) {
10367
+ // OVERRIDE
10348
10368
  };
10349
- _proto.drawStencilMask = function drawStencilMask(renderer) {
10350
- if (this.maskable) {
10351
- renderer.clear(this.stencilClearAction);
10352
- this.maskable.drawStencilMask(renderer);
10353
- }
10369
+ _proto.unbind = function unbind() {
10370
+ // OVERRIDE
10354
10371
  };
10355
- return MaskProcessor;
10356
- }();
10357
-
10358
- exports.ShaderCompileResultStatus = void 0;
10359
- (function(ShaderCompileResultStatus) {
10360
- ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
10361
- ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
10362
- ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
10363
- ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
10364
- })(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
10365
- exports.GLSLVersion = void 0;
10366
- (function(GLSLVersion) {
10367
- GLSLVersion["GLSL1"] = "100";
10368
- GLSLVersion["GLSL3"] = "300 es";
10369
- })(exports.GLSLVersion || (exports.GLSLVersion = {}));
10370
- var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
10371
- _inherits(ShaderVariant, EffectsObject);
10372
- function ShaderVariant(engine, source) {
10373
- var _this;
10374
- _this = EffectsObject.call(this, engine) || this;
10375
- _this.source = source;
10376
- return _this;
10377
- }
10378
- return ShaderVariant;
10379
- }(EffectsObject);
10380
- exports.Shader = /*#__PURE__*/ function(EffectsObject) {
10381
- _inherits(Shader, EffectsObject);
10382
- function Shader() {
10383
- return EffectsObject.apply(this, arguments);
10384
- }
10385
- var _proto = Shader.prototype;
10386
- _proto.createVariant = function createVariant(macros) {
10387
- var shaderMacros = [];
10388
- if (macros) {
10389
- for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
10390
- var key = _step.value;
10391
- shaderMacros.push([
10392
- key,
10393
- macros[key]
10394
- ]);
10395
- }
10396
- }
10397
- var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
10398
- shaderVariant.shader = this;
10399
- return shaderVariant;
10372
+ _proto.bind = function bind() {
10373
+ // OVERRIDE
10400
10374
  };
10401
- _proto.fromData = function fromData(data) {
10402
- EffectsObject.prototype.fromData.call(this, data);
10403
- this.shaderData = data;
10375
+ _proto.getDepthTexture = function getDepthTexture() {
10376
+ // OVERRIDE
10377
+ return undefined;
10404
10378
  };
10405
- return Shader;
10406
- }(EffectsObject);
10407
- exports.Shader = __decorate([
10408
- effectsClass(DataType.Shader)
10409
- ], exports.Shader);
10410
-
10411
- var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
10412
- var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
10413
- var COPY_VERTEX_SHADER = "\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}";
10414
- var COPY_FRAGMENT_SHADER = "precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";
10415
- function createCopyShader(level, writeDepth) {
10416
- var webgl2 = level === 2;
10417
- return {
10418
- name: EFFECTS_COPY_MESH_NAME,
10419
- vertex: COPY_VERTEX_SHADER,
10420
- fragment: COPY_FRAGMENT_SHADER,
10421
- glslVersion: webgl2 ? exports.GLSLVersion.GLSL3 : exports.GLSLVersion.GLSL1,
10422
- macros: [
10423
- [
10424
- "DEPTH_TEXTURE",
10425
- !!writeDepth
10426
- ]
10427
- ],
10428
- // @ts-expect-error
10429
- cacheId: COPY_MESH_SHADER_ID + +writeDepth
10379
+ _proto.getStencilTexture = function getStencilTexture() {
10380
+ // OVERRIDE
10381
+ return undefined;
10430
10382
  };
10431
- }
10432
-
10433
- var def = {
10434
- format: glContext.RGBA,
10435
- type: glContext.UNSIGNED_BYTE,
10436
- minFilter: glContext.LINEAR,
10437
- magFilter: glContext.LINEAR,
10438
- wrapS: glContext.CLAMP_TO_EDGE,
10439
- wrapT: glContext.CLAMP_TO_EDGE
10440
- };
10441
- var disposeSymbol = Symbol("dispose");
10442
- var PassTextureCache = /*#__PURE__*/ function() {
10443
- function PassTextureCache(engine) {
10444
- this.textureCache = {};
10445
- this.textureRef = {};
10446
- this.engine = engine;
10447
- }
10448
- var _proto = PassTextureCache.prototype;
10449
- _proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
10450
- var _this = this;
10451
- var width = request.width, height = request.height, name = request.name;
10452
- var options = {
10453
- sourceType: exports.TextureSourceType.framebuffer,
10454
- data: {
10455
- width: width,
10456
- height: height
10457
- },
10458
- name: name
10459
- };
10460
- var keys = [
10461
- name
10462
- ];
10463
- Object.getOwnPropertyNames(def).forEach(function(name) {
10464
- var _request_name;
10465
- var value = (_request_name = request[name]) != null ? _request_name : def[name];
10466
- options[name] = value;
10467
- keys.push(name, value);
10468
- });
10469
- var cacheId = keys.join(":");
10470
- var tex = this.textureCache[cacheId];
10471
- if (tex) {
10472
- this.textureRef[cacheId]++;
10473
- } else {
10474
- var engine = this.engine;
10475
- assertExist(engine);
10476
- tex = Texture.create(engine, options);
10477
- this.textureCache[cacheId] = tex;
10478
- this.textureRef[cacheId] = 1;
10479
- // @ts-expect-error
10480
- tex[disposeSymbol] = tex.dispose;
10481
- tex.dispose = function() {
10482
- return _this.removeTexture(cacheId);
10483
- };
10484
- }
10485
- return tex;
10383
+ _proto.getColorTextures = function getColorTextures() {
10384
+ // OVERRIDE
10385
+ return [];
10486
10386
  };
10487
- _proto.removeTexture = function removeTexture(id) {
10488
- var refCount = this.textureRef[id];
10489
- if (refCount <= 1) {
10490
- if (refCount < 0) {
10491
- console.error("Ref count < 0.");
10387
+ _proto.dispose = function dispose(options) {
10388
+ // OVERRIDE
10389
+ };
10390
+ _create_class(Framebuffer, [
10391
+ {
10392
+ key: "stencilStorage",
10393
+ get: function get() {
10394
+ // OVERRIDE
10395
+ return undefined;
10492
10396
  }
10493
- var tex = this.textureCache[id];
10494
- if (tex) {
10495
- // @ts-expect-error
10496
- tex[disposeSymbol]();
10497
- // @ts-expect-error
10498
- tex.dispose = tex[disposeSymbol];
10397
+ },
10398
+ {
10399
+ key: "depthStorage",
10400
+ get: function get() {
10401
+ // OVERRIDE
10402
+ return undefined;
10499
10403
  }
10500
- delete this.textureCache[id];
10501
- delete this.textureRef[id];
10502
- } else {
10503
- this.textureRef[id] = refCount - 1;
10504
10404
  }
10505
- };
10506
- _proto.dispose = function dispose() {
10507
- var _this = this;
10508
- Object.keys(this.textureCache).forEach(function(key) {
10509
- var texture = _this.textureCache[key];
10510
- // @ts-expect-error
10511
- texture[disposeSymbol]();
10512
- // @ts-expect-error
10513
- texture.dispose = texture[disposeSymbol];
10514
- });
10515
- this.textureCache = {};
10516
- this.textureRef = {};
10517
- this.engine = undefined;
10518
- };
10519
- return PassTextureCache;
10405
+ ]);
10406
+ return Framebuffer;
10520
10407
  }();
10521
10408
 
10522
- function _assert_this_initialized(self) {
10523
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
10524
- return self;
10525
- }
10526
-
10527
10409
  var RenderPassPriorityPrepare = 0;
10528
10410
  var RenderPassPriorityNormal = 1000;
10529
10411
  var RenderPassPriorityPostprocess = 3000;
@@ -10533,7 +10415,7 @@ exports.RenderPassAttachmentStorageType = void 0;
10533
10415
  RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["color"] = 1] = "color";
10534
10416
  //stencil 8 render buffer
10535
10417
  RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["stencil_8_opaque"] = 2] = "stencil_8_opaque";
10536
- //stencil 16 render buffer
10418
+ //depth 16 render buffer
10537
10419
  RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_16_opaque"] = 3] = "depth_16_opaque";
10538
10420
  //depth 16 & stencil 8 render buffer
10539
10421
  RenderPassAttachmentStorageType[RenderPassAttachmentStorageType["depth_stencil_opaque"] = 4] = "depth_stencil_opaque";
@@ -10652,61 +10534,31 @@ var seed$7 = 1;
10652
10534
  /**
10653
10535
  * RenderPass 抽象类
10654
10536
  */ var RenderPass = /*#__PURE__*/ function() {
10655
- function RenderPass(renderer, options) {
10537
+ function RenderPass(renderer) {
10656
10538
  /**
10657
10539
  * 优先级
10658
10540
  */ this.priority = 0;
10659
10541
  /**
10660
- * ColorAttachment 数组
10661
- */ this.attachments = [];
10662
- /**
10663
10542
  * 名称
10664
10543
  */ this.name = "RenderPass" + seed$7++;
10665
10544
  /**
10666
10545
  * 包含的 Mesh 列表
10667
10546
  */ this.meshes = [];
10668
- /**
10669
- * Mesh 渲染顺序,按照优先级升序或降序
10670
- */ this.meshOrder = exports.OrderType.ascending;
10671
10547
  this.disposed = false;
10672
- this.initialized = false;
10673
- var depthStencilAttachment = options.depthStencilAttachment;
10548
+ this.framebuffer = null;
10674
10549
  this.renderer = renderer;
10675
- this.depthStencilType = (depthStencilAttachment == null ? void 0 : depthStencilAttachment.storageType) || 0;
10676
- this.storeAction = {
10677
- colorAction: 0,
10678
- depthAction: 0,
10679
- stencilAction: 0
10680
- };
10681
- this.options = options;
10682
10550
  }
10683
10551
  var _proto = RenderPass.prototype;
10684
10552
  _proto.addMesh = function addMesh(mesh) {
10685
- addByOrder(this.meshes, mesh, this.meshOrder);
10553
+ addByOrder(this.meshes, mesh);
10686
10554
  };
10687
10555
  _proto.removeMesh = function removeMesh(mesh) {
10688
10556
  removeItem(this.meshes, mesh);
10689
10557
  };
10690
- _proto.setMeshes = function setMeshes(meshes) {
10691
- var _this_meshes;
10692
- this.meshes.length = 0;
10693
- (_this_meshes = this.meshes).splice.apply(_this_meshes, [].concat([
10694
- 0,
10695
- 0
10696
- ], meshes));
10697
- sortByOrder(this.meshes, this.meshOrder);
10698
- return this.meshes;
10699
- };
10700
- // TODO 所有pass在子类配置
10701
10558
  /**
10702
10559
  * 配置当前pass的RT,在每帧渲染前调用
10703
10560
  */ _proto.configure = function configure(renderer) {
10704
- if (this.framebuffer) {
10705
- renderer.setFramebuffer(this.framebuffer);
10706
- } else {
10707
- var _this_getViewport = this.getViewport(), x = _this_getViewport[0], y = _this_getViewport[1], width = _this_getViewport[2], height = _this_getViewport[3];
10708
- renderer.setViewport(x, y, width, height);
10709
- }
10561
+ // OVERRIDE
10710
10562
  };
10711
10563
  /**
10712
10564
  * 执行当前pass,每帧调用一次
@@ -10714,66 +10566,10 @@ var seed$7 = 1;
10714
10566
  // OVERRIDE
10715
10567
  };
10716
10568
  /**
10717
- * 每帧所有的pass渲染完后调用,通常用于清空临时的RT资源
10718
- */ _proto.frameCleanup = function frameCleanup(renderer) {
10569
+ * 每帧所有的pass渲染完后调用,用于清空临时的RT资源
10570
+ */ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
10719
10571
  // OVERRIDE
10720
10572
  };
10721
- _proto._resetAttachments = function _resetAttachments() {
10722
- var _this = this;
10723
- var _options_attachments;
10724
- var renderer = this.renderer;
10725
- var options = this.options;
10726
- if (this.attachments.length) {
10727
- var _this_framebuffer;
10728
- this.attachments.forEach(function(att) {
10729
- return !att.externalTexture && att.dispose();
10730
- });
10731
- this.attachments.length = 0;
10732
- (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.dispose({
10733
- depthStencilAttachment: 2
10734
- });
10735
- this.framebuffer = null;
10736
- }
10737
- // renderpass 的 viewport 相关参数都需要动态的修改
10738
- var viewport = [
10739
- 0,
10740
- 0,
10741
- renderer.getWidth(),
10742
- renderer.getHeight()
10743
- ];
10744
- var size = [
10745
- viewport[2],
10746
- viewport[3]
10747
- ];
10748
- var name = this.name;
10749
- if ((_options_attachments = options.attachments) == null ? void 0 : _options_attachments.length) {
10750
- var attachments = options.attachments.map(function(attr, index) {
10751
- var _attr_texture;
10752
- var attachment = new RenderTargetHandle(_this.renderer.engine, _extends({
10753
- size: size,
10754
- name: ((_attr_texture = attr.texture) == null ? void 0 : _attr_texture.name) || name + "##color_" + index
10755
- }, attr));
10756
- return attachment;
10757
- });
10758
- this.attachments = attachments;
10759
- var framebuffer = Framebuffer.create({
10760
- storeAction: this.storeAction,
10761
- name: name,
10762
- viewport: viewport,
10763
- attachments: attachments.map(function(att) {
10764
- return att.texture;
10765
- }),
10766
- depthStencilAttachment: options.depthStencilAttachment || {
10767
- storageType: 0
10768
- }
10769
- }, renderer);
10770
- framebuffer.bind();
10771
- framebuffer.unbind();
10772
- this.framebuffer = framebuffer;
10773
- } else {
10774
- this.attachments.length = 0;
10775
- }
10776
- };
10777
10573
  /**
10778
10574
  * 获取当前视口大小,格式:[x偏移,y偏移,宽度,高度]
10779
10575
  */ _proto.getViewport = function getViewport() {
@@ -10796,68 +10592,6 @@ var seed$7 = 1;
10796
10592
  ];
10797
10593
  };
10798
10594
  /**
10799
- * 获取深度 Attachment,可能没有
10800
- */ _proto.getDepthAttachment = function getDepthAttachment() {
10801
- var framebuffer = this.framebuffer;
10802
- if (framebuffer) {
10803
- var depthTexture = framebuffer.getDepthTexture();
10804
- var texture = depthTexture ? this.getDepthTexture(depthTexture, framebuffer.externalStorage) : undefined;
10805
- return {
10806
- storageType: framebuffer.depthStencilStorageType,
10807
- storage: framebuffer.depthStorage,
10808
- texture: texture
10809
- };
10810
- }
10811
- };
10812
- /**
10813
- * 获取蒙版 Attachment,可能没有
10814
- */ _proto.getStencilAttachment = function getStencilAttachment() {
10815
- var framebuffer = this.framebuffer;
10816
- if (framebuffer) {
10817
- var stencilTexture = framebuffer.getStencilTexture();
10818
- var texture = stencilTexture ? this.getDepthTexture(stencilTexture, framebuffer.externalStorage) : undefined;
10819
- return {
10820
- storageType: framebuffer.depthStencilStorageType,
10821
- storage: framebuffer.stencilStorage,
10822
- texture: texture
10823
- };
10824
- }
10825
- };
10826
- _proto.getDepthTexture = function getDepthTexture(texture, external) {
10827
- if (!this.depthTexture) {
10828
- var _this_options_depthStencilAttachment;
10829
- var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
10830
- var tex = texture === outTex ? outTex : texture;
10831
- // TODO 为什么要initialize?
10832
- //tex.initialize(this.renderer.engine);
10833
- if (!external) {
10834
- this.depthTexture = tex;
10835
- }
10836
- return tex;
10837
- }
10838
- return this.depthTexture;
10839
- };
10840
- _proto.getStencilTexture = function getStencilTexture(texture, external) {
10841
- if (!this.stencilTexture) {
10842
- var _this_options_depthStencilAttachment;
10843
- var outTex = (_this_options_depthStencilAttachment = this.options.depthStencilAttachment) == null ? void 0 : _this_options_depthStencilAttachment.texture;
10844
- var tex = texture === outTex ? outTex : texture;
10845
- if (!external) {
10846
- this.stencilTexture = tex;
10847
- }
10848
- return tex;
10849
- }
10850
- return this.stencilTexture;
10851
- };
10852
- // 生成并初始化帧缓冲
10853
- _proto.initialize = function initialize(renderer) {
10854
- if (!this.initialized) {
10855
- this._resetAttachments();
10856
- this.initialized = true;
10857
- }
10858
- return this;
10859
- };
10860
- /**
10861
10595
  * 销毁 RenderPass
10862
10596
  * @param options - 有选择销毁内部对象
10863
10597
  */ _proto.dispose = function dispose(options) {
@@ -10871,35 +10605,11 @@ var seed$7 = 1;
10871
10605
  });
10872
10606
  }
10873
10607
  this.meshes.length = 0;
10874
- var colorOpt = (options == null ? void 0 : options.colorAttachment) ? options.colorAttachment : 0;
10875
- this.attachments.forEach(function(att) {
10876
- var keep = att.externalTexture && colorOpt === 2 || colorOpt === 1;
10877
- if (!keep) {
10878
- att.dispose();
10879
- }
10880
- });
10881
- this.attachments.length = 0;
10882
10608
  this.disposed = true;
10883
- var depthStencilOpt = (options == null ? void 0 : options.depthStencilAttachment) ? options.depthStencilAttachment : 0;
10884
- var fbo = this.framebuffer;
10885
- if (fbo) {
10886
- fbo.dispose({
10887
- depthStencilAttachment: depthStencilOpt
10888
- });
10889
- var keep = fbo.externalStorage && depthStencilOpt === 2 || depthStencilOpt === 1;
10890
- if (!keep) {
10891
- var _this_stencilTexture, _this_depthTexture;
10892
- (_this_stencilTexture = this.stencilTexture) == null ? void 0 : _this_stencilTexture.dispose();
10893
- (_this_depthTexture = this.depthTexture) == null ? void 0 : _this_depthTexture.dispose();
10894
- }
10895
- }
10896
- // @ts-expect-error safe to assign
10897
- this.options = null;
10898
- this.initialize = throwDestroyedError;
10899
10609
  };
10900
10610
  _create_class(RenderPass, [
10901
10611
  {
10902
- key: "isDestroyed",
10612
+ key: "isDisposed",
10903
10613
  get: function get() {
10904
10614
  return this.disposed;
10905
10615
  }
@@ -10909,18 +10619,6 @@ var seed$7 = 1;
10909
10619
  get: function get() {
10910
10620
  return this.getViewport();
10911
10621
  }
10912
- },
10913
- {
10914
- key: "stencilAttachment",
10915
- get: function get() {
10916
- return this.getStencilAttachment();
10917
- }
10918
- },
10919
- {
10920
- key: "depthAttachment",
10921
- get: function get() {
10922
- return this.getDepthAttachment();
10923
- }
10924
10622
  }
10925
10623
  ]);
10926
10624
  return RenderPass;
@@ -10928,38 +10626,95 @@ var seed$7 = 1;
10928
10626
 
10929
10627
  var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
10930
10628
  _inherits(DrawObjectPass, RenderPass);
10931
- function DrawObjectPass(renderer, options) {
10629
+ function DrawObjectPass(renderer) {
10932
10630
  var _this;
10933
- _this = RenderPass.call(this, renderer, options) || this;
10631
+ _this = RenderPass.call(this, renderer) || this;
10632
+ _this.useRenderTarget = false;
10934
10633
  _this.priority = RenderPassPriorityNormal;
10935
10634
  _this.name = "DrawObjectPass";
10936
- _this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
10937
- _this.renderer.engine.on("resize", _this.onResize);
10938
10635
  return _this;
10939
10636
  }
10940
10637
  var _proto = DrawObjectPass.prototype;
10638
+ _proto.setup = function setup(useRenderTarget) {
10639
+ this.useRenderTarget = useRenderTarget;
10640
+ };
10641
+ _proto.configure = function configure(renderer) {
10642
+ if (this.useRenderTarget) {
10643
+ this.framebuffer = renderer.getTemporaryRT("DrawObjectPass", renderer.getWidth(), renderer.getHeight(), 16, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
10644
+ renderer.setFramebuffer(this.framebuffer);
10645
+ }
10646
+ };
10941
10647
  _proto.execute = function execute(renderer) {
10942
- renderer.clear({
10943
- colorAction: exports.TextureLoadAction.clear,
10944
- depthAction: exports.TextureLoadAction.clear,
10945
- stencilAction: exports.TextureLoadAction.clear
10946
- });
10648
+ if (this.useRenderTarget) {
10649
+ renderer.clear({
10650
+ colorAction: exports.TextureLoadAction.clear,
10651
+ depthAction: exports.TextureLoadAction.clear,
10652
+ stencilAction: exports.TextureLoadAction.clear
10653
+ });
10654
+ }
10947
10655
  renderer.renderMeshes(this.meshes);
10948
- renderer.clear(this.storeAction);
10949
- };
10950
- _proto.onResize = function onResize() {
10951
- var _this_framebuffer;
10952
- var width = this.renderer.getWidth();
10953
- var height = this.renderer.getHeight();
10954
- (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
10955
10656
  };
10956
- _proto.dispose = function dispose(options) {
10957
- this.renderer.engine.off("resize", this.onResize);
10958
- RenderPass.prototype.dispose.call(this, options);
10657
+ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
10658
+ if (this.useRenderTarget && this.framebuffer) {
10659
+ renderer.releaseTemporaryRT(this.framebuffer);
10660
+ }
10959
10661
  };
10960
10662
  return DrawObjectPass;
10961
10663
  }(RenderPass);
10962
10664
 
10665
+ exports.ShaderCompileResultStatus = void 0;
10666
+ (function(ShaderCompileResultStatus) {
10667
+ ShaderCompileResultStatus[ShaderCompileResultStatus["noShader"] = 0] = "noShader";
10668
+ ShaderCompileResultStatus[ShaderCompileResultStatus["success"] = 1] = "success";
10669
+ ShaderCompileResultStatus[ShaderCompileResultStatus["fail"] = 2] = "fail";
10670
+ ShaderCompileResultStatus[ShaderCompileResultStatus["compiling"] = 3] = "compiling";
10671
+ })(exports.ShaderCompileResultStatus || (exports.ShaderCompileResultStatus = {}));
10672
+ exports.GLSLVersion = void 0;
10673
+ (function(GLSLVersion) {
10674
+ GLSLVersion["GLSL1"] = "100";
10675
+ GLSLVersion["GLSL3"] = "300 es";
10676
+ })(exports.GLSLVersion || (exports.GLSLVersion = {}));
10677
+ var ShaderVariant = /*#__PURE__*/ function(EffectsObject) {
10678
+ _inherits(ShaderVariant, EffectsObject);
10679
+ function ShaderVariant(engine, source) {
10680
+ var _this;
10681
+ _this = EffectsObject.call(this, engine) || this;
10682
+ _this.source = source;
10683
+ return _this;
10684
+ }
10685
+ return ShaderVariant;
10686
+ }(EffectsObject);
10687
+ exports.Shader = /*#__PURE__*/ function(EffectsObject) {
10688
+ _inherits(Shader, EffectsObject);
10689
+ function Shader() {
10690
+ return EffectsObject.apply(this, arguments);
10691
+ }
10692
+ var _proto = Shader.prototype;
10693
+ _proto.createVariant = function createVariant(macros) {
10694
+ var shaderMacros = [];
10695
+ if (macros) {
10696
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(macros)), _step; !(_step = _iterator()).done;){
10697
+ var key = _step.value;
10698
+ shaderMacros.push([
10699
+ key,
10700
+ macros[key]
10701
+ ]);
10702
+ }
10703
+ }
10704
+ var shaderVariant = this.engine.getShaderLibrary().createShader(this.shaderData, shaderMacros);
10705
+ shaderVariant.shader = this;
10706
+ return shaderVariant;
10707
+ };
10708
+ _proto.fromData = function fromData(data) {
10709
+ EffectsObject.prototype.fromData.call(this, data);
10710
+ this.shaderData = data;
10711
+ };
10712
+ return Shader;
10713
+ }(EffectsObject);
10714
+ exports.Shader = __decorate([
10715
+ effectsClass(DataType.Shader)
10716
+ ], exports.Shader);
10717
+
10963
10718
  var _obj$5;
10964
10719
  var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[glContext.FLOAT] = Float32Array.BYTES_PER_ELEMENT, _obj$5[glContext.INT] = Int32Array.BYTES_PER_ELEMENT, _obj$5[glContext.SHORT] = Int16Array.BYTES_PER_ELEMENT, _obj$5[glContext.BYTE] = Int8Array.BYTES_PER_ELEMENT, _obj$5);
10965
10720
  /**
@@ -12998,272 +12753,138 @@ var ShaderFactory = /*#__PURE__*/ function() {
12998
12753
  return ShaderFactory;
12999
12754
  }();
13000
12755
 
13001
- // Bloom 阈值 Pass
13002
- var BloomThresholdPass = /*#__PURE__*/ function(RenderPass) {
13003
- _inherits(BloomThresholdPass, RenderPass);
13004
- function BloomThresholdPass(renderer, option) {
12756
+ // Bloom Pass - 包含阈值提取、高斯模糊(Down Sample 和 Up Sample)
12757
+ var BloomPass = /*#__PURE__*/ function(RenderPass) {
12758
+ _inherits(BloomPass, RenderPass);
12759
+ function BloomPass(renderer, iterationCount) {
12760
+ if (iterationCount === void 0) iterationCount = 4;
13005
12761
  var _this;
13006
- _this = RenderPass.call(this, renderer, option) || this;
12762
+ _this = RenderPass.call(this, renderer) || this;
12763
+ _this.tempRTs = [];
12764
+ _this.iterationCount = iterationCount;
13007
12765
  var engine = _this.renderer.engine;
13008
- var geometry = Geometry.create(engine, {
13009
- mode: glContext.TRIANGLE_STRIP,
13010
- attributes: {
13011
- aPos: {
13012
- type: glContext.FLOAT,
13013
- size: 2,
13014
- data: new Float32Array([
13015
- -1,
13016
- 1,
13017
- -1,
13018
- -1,
13019
- 1,
13020
- 1,
13021
- 1,
13022
- -1
13023
- ])
13024
- }
13025
- },
13026
- drawCount: 4
13027
- });
13028
- var material = Material.create(engine, {
12766
+ // Threshold material
12767
+ _this.thresholdMaterial = Material.create(engine, {
13029
12768
  shader: {
13030
12769
  vertex: screenMeshVert,
13031
12770
  fragment: thresholdFrag,
13032
12771
  glslVersion: exports.GLSLVersion.GLSL1
13033
12772
  }
13034
12773
  });
13035
- material.blending = false;
13036
- material.depthTest = false;
13037
- material.culling = false;
13038
- _this.screenMesh = Mesh.create(engine, {
13039
- geometry: geometry,
13040
- material: material,
13041
- priority: 0
12774
+ _this.thresholdMaterial.blending = false;
12775
+ _this.thresholdMaterial.depthTest = false;
12776
+ _this.thresholdMaterial.culling = false;
12777
+ // Down sample H material
12778
+ _this.downSampleHMaterial = Material.create(engine, {
12779
+ shader: {
12780
+ vertex: screenMeshVert,
12781
+ fragment: gaussianDownHFrag,
12782
+ glslVersion: exports.GLSLVersion.GLSL1
12783
+ }
13042
12784
  });
12785
+ _this.downSampleHMaterial.blending = false;
12786
+ _this.downSampleHMaterial.depthTest = false;
12787
+ _this.downSampleHMaterial.culling = false;
12788
+ // Down sample V material
12789
+ _this.downSampleVMaterial = Material.create(engine, {
12790
+ shader: {
12791
+ vertex: screenMeshVert,
12792
+ fragment: gaussianDownVFrag,
12793
+ glslVersion: exports.GLSLVersion.GLSL1
12794
+ }
12795
+ });
12796
+ _this.downSampleVMaterial.blending = false;
12797
+ _this.downSampleVMaterial.depthTest = false;
12798
+ _this.downSampleVMaterial.culling = false;
12799
+ // Up sample material
12800
+ _this.upSampleMaterial = Material.create(engine, {
12801
+ shader: {
12802
+ vertex: screenMeshVert,
12803
+ fragment: gaussianUpFrag,
12804
+ glslVersion: exports.GLSLVersion.GLSL1
12805
+ }
12806
+ });
12807
+ _this.upSampleMaterial.blending = false;
12808
+ _this.upSampleMaterial.depthTest = false;
12809
+ _this.upSampleMaterial.culling = false;
13043
12810
  _this.priority = 5000;
13044
- _this.name = "BloomThresholdPass";
13045
- _this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
13046
- _this.renderer.engine.on("resize", _this.onResize);
12811
+ _this.name = "BloomPass";
13047
12812
  return _this;
13048
12813
  }
13049
- var _proto = BloomThresholdPass.prototype;
12814
+ var _proto = BloomPass.prototype;
13050
12815
  _proto.configure = function configure(renderer) {
12816
+ // 获取场景纹理用于 ToneMappingPass
13051
12817
  this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
13052
12818
  this.sceneTextureHandle.texture = this.mainTexture;
13053
- renderer.setFramebuffer(this.framebuffer);
13054
12819
  };
13055
12820
  _proto.execute = function execute(renderer) {
13056
12821
  var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
13057
- renderer.clear({
13058
- colorAction: exports.TextureStoreAction.clear,
13059
- depthAction: exports.TextureStoreAction.clear,
13060
- stencilAction: exports.TextureStoreAction.clear
13061
- });
13062
- this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
12822
+ var baseWidth = renderer.getWidth();
12823
+ var baseHeight = renderer.getHeight();
13063
12824
  var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
12825
+ // 1. Threshold pass - 提取高亮区域
13064
12826
  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;
13065
- this.screenMesh.material.setFloat("_Threshold", threshold);
13066
- renderer.renderMeshes([
13067
- this.screenMesh
13068
- ]);
13069
- };
13070
- _proto.onResize = function onResize() {
13071
- var _this_framebuffer;
13072
- var width = this.renderer.getWidth();
13073
- var height = this.renderer.getHeight();
13074
- (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
13075
- };
13076
- _proto.dispose = function dispose(options) {
13077
- this.renderer.engine.off("resize", this.onResize);
13078
- RenderPass.prototype.dispose.call(this, options);
13079
- };
13080
- return BloomThresholdPass;
13081
- }(RenderPass);
13082
- var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
13083
- _inherits(HQGaussianDownSamplePass, RenderPass);
13084
- function HQGaussianDownSamplePass(renderer, type, level, options) {
13085
- var _this;
13086
- _this = RenderPass.call(this, renderer, options) || this;
13087
- _this.type = type;
13088
- _this.level = level;
13089
- var engine = _this.renderer.engine;
13090
- var name = "PostProcess";
13091
- var geometry = Geometry.create(engine, {
13092
- name: name,
13093
- mode: glContext.TRIANGLE_STRIP,
13094
- attributes: {
13095
- aPos: {
13096
- type: glContext.FLOAT,
13097
- size: 2,
13098
- data: new Float32Array([
13099
- -1,
13100
- 1,
13101
- -1,
13102
- -1,
13103
- 1,
13104
- 1,
13105
- 1,
13106
- -1
13107
- ])
13108
- }
13109
- },
13110
- drawCount: 4
13111
- });
13112
- var fragment = type === "H" ? gaussianDownHFrag : gaussianDownVFrag;
13113
- var shader = {
13114
- vertex: screenMeshVert,
13115
- fragment: fragment,
13116
- glslVersion: exports.GLSLVersion.GLSL1
13117
- };
13118
- var material = Material.create(engine, {
13119
- name: name,
13120
- shader: shader
13121
- });
13122
- material.blending = false;
13123
- material.depthTest = false;
13124
- material.culling = false;
13125
- _this.screenMesh = Mesh.create(engine, {
13126
- name: name,
13127
- geometry: geometry,
13128
- material: material,
13129
- priority: 0
13130
- });
13131
- _this.priority = 5000;
13132
- _this.name = "GaussianDownPass" + type + level;
13133
- _this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
13134
- _this.renderer.engine.on("resize", _this.onResize);
13135
- return _this;
13136
- }
13137
- var _proto = HQGaussianDownSamplePass.prototype;
13138
- _proto.initialize = function initialize(renderer) {
13139
- RenderPass.prototype.initialize.call(this, renderer);
13140
- this.onResize();
13141
- return this;
13142
- };
13143
- _proto.configure = function configure(renderer) {
13144
- this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
13145
- renderer.setFramebuffer(this.framebuffer);
13146
- };
13147
- _proto.execute = function execute(renderer) {
13148
- renderer.clear({
13149
- colorAction: exports.TextureStoreAction.clear,
13150
- depthAction: exports.TextureStoreAction.clear,
13151
- stencilAction: exports.TextureStoreAction.clear
13152
- });
13153
- this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
13154
- this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
13155
- renderer.renderMeshes([
13156
- this.screenMesh
13157
- ]);
13158
- if (this.type === "V") {
13159
- this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
13160
- }
13161
- };
13162
- _proto.onResize = function onResize() {
13163
- var _this_framebuffer;
13164
- var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
13165
- var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
13166
- (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
13167
- };
13168
- _proto.dispose = function dispose(options) {
13169
- this.renderer.engine.off("resize", this.onResize);
13170
- RenderPass.prototype.dispose.call(this, options);
13171
- };
13172
- return HQGaussianDownSamplePass;
13173
- }(RenderPass);
13174
- var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
13175
- _inherits(HQGaussianUpSamplePass, RenderPass);
13176
- function HQGaussianUpSamplePass(renderer, level, options) {
13177
- var _this;
13178
- _this = RenderPass.call(this, renderer, options) || this;
13179
- _this.level = level;
13180
- var name = "PostProcess";
13181
- var engine = _this.renderer.engine;
13182
- var geometry = Geometry.create(engine, {
13183
- name: name,
13184
- mode: glContext.TRIANGLE_STRIP,
13185
- attributes: {
13186
- aPos: {
13187
- type: glContext.FLOAT,
13188
- size: 2,
13189
- data: new Float32Array([
13190
- -1,
13191
- 1,
13192
- -1,
13193
- -1,
13194
- 1,
13195
- 1,
13196
- 1,
13197
- -1
13198
- ])
13199
- }
13200
- },
13201
- drawCount: 4
13202
- });
13203
- var shader = {
13204
- vertex: screenMeshVert,
13205
- fragment: gaussianUpFrag
13206
- };
13207
- var material = Material.create(engine, {
13208
- name: name,
13209
- shader: shader
13210
- });
13211
- material.blending = false;
13212
- material.depthTest = false;
13213
- material.culling = false;
13214
- _this.screenMesh = Mesh.create(engine, {
13215
- name: name,
13216
- geometry: geometry,
13217
- material: material,
13218
- priority: 0
13219
- });
13220
- _this.priority = 5000;
13221
- _this.name = "GaussianUpPass" + level;
13222
- _this.onResize = _this.onResize.bind(_assert_this_initialized(_this));
13223
- _this.renderer.engine.on("resize", _this.onResize);
13224
- return _this;
13225
- }
13226
- var _proto = HQGaussianUpSamplePass.prototype;
13227
- _proto.initialize = function initialize(renderer) {
13228
- RenderPass.prototype.initialize.call(this, renderer);
13229
- this.onResize();
13230
- return this;
13231
- };
13232
- _proto.configure = function configure(renderer) {
13233
- this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
13234
- renderer.setFramebuffer(this.framebuffer);
13235
- };
13236
- _proto.execute = function execute(renderer) {
13237
- renderer.clear({
13238
- colorAction: exports.TextureStoreAction.clear,
13239
- depthAction: exports.TextureStoreAction.clear,
13240
- stencilAction: exports.TextureStoreAction.clear
13241
- });
13242
- this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
13243
- this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
13244
- this.screenMesh.material.setVector2("_GaussianDownTextureSize", getTextureSize(this.gaussianDownSampleResult.texture));
13245
- renderer.renderMeshes([
13246
- this.screenMesh
13247
- ]);
13248
- };
13249
- _proto.onResize = function onResize() {
13250
- var _this_framebuffer;
13251
- var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
13252
- var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
13253
- (_this_framebuffer = this.framebuffer) == null ? void 0 : _this_framebuffer.resize(0, 0, width, height);
12827
+ this.thresholdRT = renderer.getTemporaryRT("_BloomThreshold", baseWidth, baseHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
12828
+ this.thresholdMaterial.setFloat("_Threshold", threshold);
12829
+ renderer.blit(this.mainTexture, this.thresholdRT, this.thresholdMaterial);
12830
+ var currentTexture = this.thresholdRT.getColorTextures()[0];
12831
+ // 2. Down sample passes
12832
+ for(var i = 0; i < this.iterationCount; i++){
12833
+ var downWidth = Math.floor(baseWidth / Math.pow(2, i + 1));
12834
+ var downHeight = Math.floor(baseHeight / Math.pow(2, i + 1));
12835
+ // Horizontal pass
12836
+ var tempH = renderer.getTemporaryRT("_BloomDownH" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
12837
+ this.downSampleHMaterial.setVector2("_TextureSize", getTextureSize(currentTexture));
12838
+ renderer.blit(currentTexture, tempH, this.downSampleHMaterial);
12839
+ // Vertical pass
12840
+ var tempV = renderer.getTemporaryRT("_BloomDownV" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
12841
+ this.downSampleVMaterial.setVector2("_TextureSize", getTextureSize(tempH.getColorTextures()[0]));
12842
+ renderer.blit(tempH.getColorTextures()[0], tempV, this.downSampleVMaterial);
12843
+ // 释放 H pass RT,保留 V pass RT 用于 up sample
12844
+ renderer.releaseTemporaryRT(tempH);
12845
+ this.tempRTs.push(tempV);
12846
+ currentTexture = tempV.getColorTextures()[0];
12847
+ }
12848
+ // 释放 threshold RT
12849
+ renderer.releaseTemporaryRT(this.thresholdRT);
12850
+ // 3. Up sample passes
12851
+ for(var i1 = this.iterationCount - 1; i1 > 0; i1--){
12852
+ var upWidth = Math.floor(baseWidth / Math.pow(2, i1 - 1));
12853
+ var upHeight = Math.floor(baseHeight / Math.pow(2, i1 - 1));
12854
+ var tempUp = renderer.getTemporaryRT("_BloomUp" + i1, upWidth, upHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
12855
+ // 获取下一层的 down sample 结果
12856
+ var downSampleTexture = this.tempRTs[i1 - 1].getColorTextures()[0];
12857
+ this.upSampleMaterial.setTexture("_GaussianDownTex", downSampleTexture);
12858
+ this.upSampleMaterial.setVector2("_GaussianDownTextureSize", getTextureSize(downSampleTexture));
12859
+ renderer.blit(currentTexture, tempUp, this.upSampleMaterial);
12860
+ currentTexture = tempUp.getColorTextures()[0];
12861
+ this.tempRTs.push(tempUp);
12862
+ }
12863
+ // 设置最终输出到当前 framebuffer
12864
+ renderer.setFramebuffer(this.tempRTs[this.tempRTs.length - 1]);
12865
+ };
12866
+ _proto.onCameraCleanup = function onCameraCleanup(renderer) {
12867
+ // 释放所有临时 RT
12868
+ for(var i = 0; i < this.tempRTs.length; i++){
12869
+ renderer.releaseTemporaryRT(this.tempRTs[i]);
12870
+ }
12871
+ this.tempRTs = [];
13254
12872
  };
13255
12873
  _proto.dispose = function dispose(options) {
13256
- this.renderer.engine.off("resize", this.onResize);
12874
+ this.thresholdMaterial.dispose();
12875
+ this.downSampleHMaterial.dispose();
12876
+ this.downSampleVMaterial.dispose();
12877
+ this.upSampleMaterial.dispose();
13257
12878
  RenderPass.prototype.dispose.call(this, options);
13258
12879
  };
13259
- return HQGaussianUpSamplePass;
12880
+ return BloomPass;
13260
12881
  }(RenderPass);
13261
12882
  // 合并Bloom的高斯模糊结果,并应用ACES Tonemapping
13262
12883
  var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
13263
12884
  _inherits(ToneMappingPass, RenderPass);
13264
12885
  function ToneMappingPass(renderer, sceneTextureHandle) {
13265
12886
  var _this;
13266
- _this = RenderPass.call(this, renderer, {}) || this;
12887
+ _this = RenderPass.call(this, renderer) || this;
13267
12888
  var name = "PostProcess";
13268
12889
  var engine = _this.renderer.engine;
13269
12890
  _this.sceneTextureHandle = sceneTextureHandle ? sceneTextureHandle : new RenderTargetHandle(engine);
@@ -13319,9 +12940,9 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
13319
12940
  };
13320
12941
  _proto.execute = function execute(renderer) {
13321
12942
  renderer.clear({
13322
- colorAction: exports.TextureStoreAction.clear,
13323
- depthAction: exports.TextureStoreAction.clear,
13324
- stencilAction: exports.TextureStoreAction.clear
12943
+ colorAction: exports.TextureLoadAction.clear,
12944
+ depthAction: exports.TextureLoadAction.clear,
12945
+ stencilAction: exports.TextureLoadAction.clear
13325
12946
  });
13326
12947
  var globalVolume = renderer.renderingData.currentFrame.globalVolume;
13327
12948
  var bloom = _extends({
@@ -13368,95 +12989,31 @@ var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
13368
12989
  return ToneMappingPass;
13369
12990
  }(RenderPass);
13370
12991
 
13371
- var SemanticMap = /*#__PURE__*/ function() {
13372
- function SemanticMap(semantics) {
13373
- if (semantics === void 0) semantics = {};
13374
- this.semantics = _extends({}, semantics);
13375
- }
13376
- var _proto = SemanticMap.prototype;
13377
- _proto.toObject = function toObject() {
13378
- return _extends({}, this.semantics);
13379
- };
13380
- _proto.setSemantic = function setSemantic(name, value) {
13381
- if (value === undefined) {
13382
- delete this.semantics[name];
13383
- } else {
13384
- this.semantics[name] = value;
13385
- }
13386
- };
13387
- _proto.getSemanticValue = function getSemanticValue(name, state) {
13388
- var ret = this.semantics[name];
13389
- if (isFunction(ret)) {
13390
- return ret(state);
13391
- }
13392
- return ret;
13393
- };
13394
- _proto.hasSemanticValue = function hasSemanticValue(name) {
13395
- return name in this.semantics;
13396
- };
13397
- _proto.dispose = function dispose() {
13398
- var _this = this;
13399
- Object.keys(this.semantics).forEach(function(name) {
13400
- delete _this.semantics[name];
13401
- });
13402
- };
13403
- return SemanticMap;
13404
- }();
13405
-
13406
- var RENDER_PASS_NAME_PREFIX = "_effects_default_";
13407
12992
  var seed$5 = 1;
13408
12993
  /**
13409
12994
  * RenderFrame 抽象类
13410
12995
  */ var RenderFrame = /*#__PURE__*/ function() {
13411
12996
  function RenderFrame(options) {
13412
- var _this_renderer_getShaderLibrary;
13413
- // TODO: 是否有用
13414
- this.renderQueue = [];
13415
- this.destroyed = false;
13416
- this.renderPassInfoMap = new WeakMap();
13417
- var camera = options.camera, keepColorBuffer = options.keepColorBuffer, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
12997
+ this.disposed = false;
12998
+ this.postProcessingEnabled = false;
12999
+ this.enableHDR = true;
13000
+ var camera = options.camera, renderer = options.renderer, _options_editorTransform = options.editorTransform, editorTransform = _options_editorTransform === void 0 ? [
13418
13001
  1,
13419
13002
  1,
13420
13003
  0,
13421
13004
  0
13422
- ] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled, _options_clearAction = options.clearAction, clearAction = _options_clearAction === void 0 ? {
13423
- colorAction: exports.TextureLoadAction.whatever,
13424
- stencilAction: exports.TextureLoadAction.clear,
13425
- depthAction: exports.TextureLoadAction.whatever
13426
- } : _options_clearAction;
13005
+ ] : _options_editorTransform, globalVolume = options.globalVolume, _options_postProcessingEnabled = options.postProcessingEnabled, postProcessingEnabled = _options_postProcessingEnabled === void 0 ? false : _options_postProcessingEnabled;
13427
13006
  var engine = renderer.engine;
13428
13007
  if (globalVolume) {
13429
13008
  this.globalVolume = globalVolume;
13430
13009
  }
13010
+ this.postProcessingEnabled = postProcessingEnabled;
13431
13011
  this.globalUniforms = new GlobalUniforms();
13432
- var attachments = []; //渲染场景物体Pass的RT
13433
- var depthStencilAttachment;
13434
13012
  this.renderer = renderer;
13435
- if (postProcessingEnabled) {
13436
- var enableHDR = true;
13437
- if (!this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
13438
- throw new Error("Half float texture is not supported.");
13439
- }
13440
- // 使用HDR浮点纹理,FLOAT在IOS上报错,使用HALF_FLOAT
13441
- var textureType = enableHDR ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
13442
- attachments = [
13443
- {
13444
- texture: {
13445
- format: glContext.RGBA,
13446
- type: textureType,
13447
- magFilter: glContext.LINEAR,
13448
- minFilter: glContext.LINEAR
13449
- }
13450
- }
13451
- ];
13452
- depthStencilAttachment = {
13453
- storageType: exports.RenderPassAttachmentStorageType.depth_stencil_opaque
13454
- };
13013
+ if (postProcessingEnabled && this.enableHDR && !this.renderer.engine.gpuCapability.detail.halfFloatTexture) {
13014
+ throw new Error("Half float texture is not supported.");
13455
13015
  }
13456
- this.drawObjectPass = new DrawObjectPass(renderer, {
13457
- depthStencilAttachment: depthStencilAttachment,
13458
- attachments: attachments
13459
- });
13016
+ this.drawObjectPass = new DrawObjectPass(renderer);
13460
13017
  var renderPasses = [
13461
13018
  this.drawObjectPass
13462
13019
  ];
@@ -13464,110 +13021,25 @@ var seed$5 = 1;
13464
13021
  if (postProcessingEnabled) {
13465
13022
  var sceneTextureHandle = new RenderTargetHandle(engine); //保存后处理前的屏幕图像
13466
13023
  var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
13467
- var viewport = [
13468
- 0,
13469
- 0,
13470
- this.renderer.getWidth() / 2,
13471
- this.renderer.getHeight() / 2
13472
- ];
13473
- var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
13474
- var enableHDR1 = true;
13475
- var textureType1 = enableHDR1 ? glContext.HALF_FLOAT : glContext.UNSIGNED_BYTE;
13476
- var bloomThresholdPass = new BloomThresholdPass(renderer, {
13477
- attachments: [
13478
- {
13479
- texture: {
13480
- format: glContext.RGBA,
13481
- type: textureType1,
13482
- minFilter: glContext.LINEAR,
13483
- magFilter: glContext.LINEAR
13484
- }
13485
- }
13486
- ]
13487
- });
13488
- bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
13489
- this.addRenderPass(bloomThresholdPass);
13490
- for(var i = 0; i < gaussianStep; i++){
13491
- gaussianDownResults[i] = new RenderTargetHandle(engine);
13492
- var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i, {
13493
- attachments: [
13494
- {
13495
- texture: {
13496
- format: glContext.RGBA,
13497
- type: textureType1,
13498
- minFilter: glContext.LINEAR,
13499
- magFilter: glContext.LINEAR
13500
- }
13501
- }
13502
- ]
13503
- });
13504
- var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i, {
13505
- attachments: [
13506
- {
13507
- texture: {
13508
- format: glContext.RGBA,
13509
- type: textureType1,
13510
- minFilter: glContext.LINEAR,
13511
- magFilter: glContext.LINEAR
13512
- }
13513
- }
13514
- ]
13515
- });
13516
- gaussianDownVPass.gaussianResult = gaussianDownResults[i];
13517
- this.addRenderPass(gaussianDownHPass);
13518
- this.addRenderPass(gaussianDownVPass);
13519
- viewport[2] /= 2;
13520
- viewport[3] /= 2;
13521
- // TODO 限制最大迭代
13522
- }
13523
- viewport[2] *= 4;
13524
- viewport[3] *= 4;
13525
- for(var i1 = 0; i1 < gaussianStep - 1; i1++){
13526
- var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1, {
13527
- attachments: [
13528
- {
13529
- texture: {
13530
- format: glContext.RGBA,
13531
- type: textureType1,
13532
- minFilter: glContext.LINEAR,
13533
- magFilter: glContext.LINEAR
13534
- }
13535
- }
13536
- ]
13537
- });
13538
- gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
13539
- this.addRenderPass(gaussianUpPass);
13540
- viewport[2] *= 2;
13541
- viewport[3] *= 2;
13542
- }
13024
+ // Bloom Pass(包含阈值提取、高斯模糊)
13025
+ var bloomPass = new BloomPass(renderer, gaussianStep);
13026
+ bloomPass.sceneTextureHandle = sceneTextureHandle;
13027
+ this.addRenderPass(bloomPass);
13028
+ // Tone Mapping Pass
13543
13029
  var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
13544
13030
  this.addRenderPass(postProcessPass);
13545
13031
  }
13546
- this.semantics = new SemanticMap(options.semantics);
13547
- this.clearAction = clearAction;
13548
13032
  this.name = "RenderFrame" + seed$5++;
13549
- var firstRP = renderPasses[0];
13550
13033
  this.camera = camera;
13551
- this.keepColorBuffer = keepColorBuffer;
13552
- this.renderPassInfoMap.set(firstRP, {
13553
- listStart: 0,
13554
- listEnd: 0,
13555
- renderPass: firstRP,
13556
- intermedia: false
13557
- });
13558
13034
  this.editorTransform = Vector4.fromArray(editorTransform);
13559
- if (!options.clearAction) {
13560
- this.resetClearActions();
13561
- }
13562
- this.passTextureCache = new PassTextureCache(engine);
13563
- // FIXME: addShader是为了性能考虑,如果影响不大,下面代码可以删除
13564
- var _engine_gpuCapability = engine.gpuCapability, detail = _engine_gpuCapability.detail, level = _engine_gpuCapability.level;
13565
- var writeDepth = detail.readableDepthStencilTextures && detail.writableFragDepth;
13566
- var shader = createCopyShader(level, writeDepth);
13567
- (_this_renderer_getShaderLibrary = this.renderer.getShaderLibrary()) == null ? void 0 : _this_renderer_getShaderLibrary.addShader(shader);
13568
13035
  }
13569
13036
  var _proto = RenderFrame.prototype;
13570
13037
  /**
13038
+ * 设置 RenderPasses 参数,此函数每帧调用一次
13039
+ */ _proto.setup = function setup() {
13040
+ this.drawObjectPass.setup(this.postProcessingEnabled);
13041
+ };
13042
+ /**
13571
13043
  * 根据 Mesh 优先级添加到 RenderPass
13572
13044
  * @param mesh - 要添加的 Mesh 对象
13573
13045
  */ _proto.addMeshToDefaultRenderPass = function addMeshToDefaultRenderPass(mesh) {
@@ -13584,78 +13056,25 @@ var seed$5 = 1;
13584
13056
  * 销毁 RenderFrame
13585
13057
  * @param options - 可以有选择销毁一些对象
13586
13058
  */ _proto.dispose = function dispose(options) {
13587
- if ((options == null ? void 0 : options.semantics) !== exports.DestroyOptions.keep) {
13588
- this.semantics.dispose();
13589
- }
13590
13059
  var pass = (options == null ? void 0 : options.passes) ? options.passes : undefined;
13591
13060
  if (pass !== exports.DestroyOptions.keep) {
13592
13061
  this._renderPasses.forEach(function(renderPass) {
13593
13062
  renderPass.dispose(pass);
13594
13063
  });
13595
13064
  }
13596
- this.passTextureCache.dispose();
13597
13065
  this._renderPasses.length = 0;
13598
- this.destroyed = true;
13599
- };
13600
- /**
13601
- * 查找 Mesh 所在的 RenderPass 索引,没找到是-1
13602
- * @param mesh - 需要查找的 Mesh
13603
- */ _proto.findMeshRenderPassIndex = function findMeshRenderPassIndex(mesh) {
13604
- var index = -1;
13605
- this.renderPasses.every(function(rp, idx) {
13606
- if (rp.name.startsWith(RENDER_PASS_NAME_PREFIX) && rp.meshes.includes(mesh)) {
13607
- index = idx;
13608
- return false;
13609
- }
13610
- return true;
13611
- });
13612
- return index;
13613
- };
13614
- _proto.addToRenderPass = function addToRenderPass(renderPass, mesh) {
13615
- var info = this.renderPassInfoMap.get(renderPass);
13616
- var priority = mesh.priority;
13617
- if (!info) {
13618
- return;
13619
- }
13620
- if (renderPass.meshes.length === 0) {
13621
- info.listStart = info.listEnd = priority;
13622
- } else {
13623
- if (priority < info.listStart) {
13624
- info.listStart = priority;
13625
- } else if (priority > info.listEnd) {
13626
- info.listEnd = priority;
13627
- }
13628
- }
13629
- renderPass.addMesh(mesh);
13630
- };
13631
- _proto.resetClearActions = function resetClearActions() {
13632
- var action = this.renderPasses.length > 1 ? exports.TextureLoadAction.clear : exports.TextureLoadAction.whatever;
13633
- this.clearAction.stencilAction = action;
13634
- this.clearAction.depthAction = action;
13635
- this.clearAction.colorAction = action;
13636
- if (this.keepColorBuffer) {
13637
- this.clearAction.colorAction = exports.TextureLoadAction.whatever;
13638
- }
13066
+ this.disposed = true;
13639
13067
  };
13640
13068
  /**
13641
13069
  * 设置 RenderPass 数组,直接修改内部的 RenderPass 数组
13642
13070
  * @param passes - RenderPass 数组
13643
13071
  */ _proto.setRenderPasses = function setRenderPasses(passes) {
13644
- var _this = this;
13645
- if (this.renderer !== undefined) {
13646
- passes.forEach(function(pass) {
13647
- return pass.initialize(_this.renderer);
13648
- });
13649
- }
13650
13072
  this._renderPasses = passes.slice();
13651
13073
  };
13652
13074
  /**
13653
13075
  * 添加 RenderPass
13654
13076
  * @param pass - 需要添加的 RenderPass
13655
13077
  */ _proto.addRenderPass = function addRenderPass(pass) {
13656
- if (this.renderer !== undefined) {
13657
- pass.initialize(this.renderer);
13658
- }
13659
13078
  this._renderPasses.push(pass);
13660
13079
  };
13661
13080
  /**
@@ -13672,9 +13091,9 @@ var seed$5 = 1;
13672
13091
  }
13673
13092
  },
13674
13093
  {
13675
- key: "isDestroyed",
13094
+ key: "isDisposed",
13676
13095
  get: function get() {
13677
- return this.destroyed;
13096
+ return this.disposed;
13678
13097
  }
13679
13098
  }
13680
13099
  ]);
@@ -13683,10 +13102,6 @@ var seed$5 = 1;
13683
13102
  function getTextureSize(tex) {
13684
13103
  return tex ? new Vector2(tex.getWidth(), tex.getHeight()) : new Vector2();
13685
13104
  }
13686
- function findPreviousRenderPass(renderPasses, renderPass) {
13687
- var index = renderPasses.indexOf(renderPass);
13688
- return renderPasses[index - 1];
13689
- }
13690
13105
  var GlobalUniforms = function GlobalUniforms() {
13691
13106
  this.floats = {};
13692
13107
  this.ints = {};
@@ -13724,6 +13139,122 @@ var Renderbuffer = /*#__PURE__*/ function() {
13724
13139
  return Renderbuffer;
13725
13140
  }();
13726
13141
 
13142
+ var RenderTargetPool = /*#__PURE__*/ function() {
13143
+ function RenderTargetPool(engine) {
13144
+ this.engine = engine;
13145
+ this.temporaryRTs = [];
13146
+ this.currentFrame = 0;
13147
+ this.maxUnusedFrames = 4;
13148
+ }
13149
+ var _proto = RenderTargetPool.prototype;
13150
+ /**
13151
+ * 清理 RenderTarget 池
13152
+ * @param force - 是否强制清理所有未占用的 RT
13153
+ * @param framesOffset - 自定义未使用帧数阈值,-1 表示使用默认值
13154
+ */ _proto.flush = function flush(force, framesOffset) {
13155
+ if (force === void 0) force = false;
13156
+ if (framesOffset === void 0) framesOffset = -1;
13157
+ this.currentFrame++;
13158
+ var threshold = framesOffset >= 0 ? framesOffset : this.maxUnusedFrames;
13159
+ for(var i = 0; i < this.temporaryRTs.length; i++){
13160
+ var entry = this.temporaryRTs[i];
13161
+ // 强制清理所有未占用的 RT,或清理超过阈值帧数未使用的 RT
13162
+ if (!entry.isOccupied && (force || this.currentFrame - entry.lastFrameReleased > threshold)) {
13163
+ entry.RT.dispose();
13164
+ this.temporaryRTs.splice(i--, 1);
13165
+ }
13166
+ }
13167
+ };
13168
+ _proto.get = function get(name, width, height, depthBuffer, filter, format) {
13169
+ if (depthBuffer === void 0) depthBuffer = 0;
13170
+ if (filter === void 0) filter = exports.FilterMode.Linear;
13171
+ if (format === void 0) format = exports.RenderTextureFormat.RGBA32;
13172
+ // 使用参数计算 hash 值作为缓存 key
13173
+ var hash = width + "_" + height + "_" + depthBuffer + "_" + filter + "_" + format;
13174
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
13175
+ var entry = _step.value;
13176
+ if (!entry.isOccupied && entry.descriptionHash === hash) {
13177
+ entry.isOccupied = true;
13178
+ entry.RT.name = name;
13179
+ return entry.RT;
13180
+ }
13181
+ }
13182
+ var textureFilter;
13183
+ var textureType;
13184
+ var depthType = exports.RenderPassAttachmentStorageType.none;
13185
+ // TODO 建立Map映射
13186
+ if (filter === exports.FilterMode.Linear) {
13187
+ textureFilter = glContext.LINEAR;
13188
+ } else if (filter === exports.FilterMode.Nearest) {
13189
+ textureFilter = glContext.NEAREST;
13190
+ }
13191
+ if (format === exports.RenderTextureFormat.RGBA32) {
13192
+ textureType = glContext.UNSIGNED_BYTE;
13193
+ } else if (format === exports.RenderTextureFormat.RGBAHalf) {
13194
+ textureType = glContext.HALF_FLOAT;
13195
+ }
13196
+ if (depthBuffer === 0) {
13197
+ depthType = exports.RenderPassAttachmentStorageType.none;
13198
+ } else if (depthBuffer === 16) {
13199
+ depthType = exports.RenderPassAttachmentStorageType.depth_stencil_opaque;
13200
+ } else if (depthBuffer === 24) {
13201
+ depthType = exports.RenderPassAttachmentStorageType.depth_24_stencil_8_texture;
13202
+ }
13203
+ var colorAttachment = Texture.create(this.engine, {
13204
+ sourceType: exports.TextureSourceType.framebuffer,
13205
+ minFilter: textureFilter,
13206
+ magFilter: textureFilter,
13207
+ internalFormat: glContext.RGBA,
13208
+ format: glContext.RGBA,
13209
+ type: textureType
13210
+ });
13211
+ var newFramebuffer = Framebuffer.create({
13212
+ name: name,
13213
+ storeAction: {},
13214
+ viewport: [
13215
+ 0,
13216
+ 0,
13217
+ width,
13218
+ height
13219
+ ],
13220
+ attachments: [
13221
+ colorAttachment
13222
+ ],
13223
+ depthStencilAttachment: {
13224
+ storageType: depthType
13225
+ }
13226
+ }, this.engine.renderer);
13227
+ var entry1 = {
13228
+ RT: newFramebuffer,
13229
+ lastFrameReleased: 0,
13230
+ descriptionHash: hash,
13231
+ isOccupied: true
13232
+ };
13233
+ this.temporaryRTs.push(entry1);
13234
+ return entry1.RT;
13235
+ };
13236
+ /**
13237
+ * 释放 RenderTarget,使其可以被复用
13238
+ * @param rt - 要释放的 Framebuffer
13239
+ */ _proto.release = function release(rt) {
13240
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
13241
+ var entry = _step.value;
13242
+ if (entry.RT === rt) {
13243
+ entry.isOccupied = false;
13244
+ entry.lastFrameReleased = this.currentFrame;
13245
+ break;
13246
+ }
13247
+ }
13248
+ };
13249
+ _proto.dispose = function dispose() {
13250
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.temporaryRTs), _step; !(_step = _iterator()).done;){
13251
+ var entry = _step.value;
13252
+ entry.RT.dispose();
13253
+ }
13254
+ };
13255
+ return RenderTargetPool;
13256
+ }();
13257
+
13727
13258
  var isWebGL2Available = typeof WebGL2RenderingContext === "function";
13728
13259
  var GPUCapability = /*#__PURE__*/ function() {
13729
13260
  function GPUCapability(gl) {
@@ -13909,70 +13440,11 @@ exports.CompressTextureCapabilityType = void 0;
13909
13440
  return !!hasCompressedTextureSupport;
13910
13441
  }
13911
13442
 
13912
- exports.FilterMode = void 0;
13913
- (function(FilterMode) {
13914
- FilterMode[FilterMode["Nearest"] = 0] = "Nearest";
13915
- FilterMode[FilterMode["Linear"] = 1] = "Linear";
13916
- })(exports.FilterMode || (exports.FilterMode = {}));
13917
- exports.RenderTextureFormat = void 0;
13918
- (function(RenderTextureFormat) {
13919
- RenderTextureFormat[RenderTextureFormat["RGBA32"] = 0] = "RGBA32";
13920
- RenderTextureFormat[RenderTextureFormat["RGBAHalf"] = 1] = "RGBAHalf";
13921
- })(exports.RenderTextureFormat || (exports.RenderTextureFormat = {}));
13922
- /**
13923
- *
13924
- */ var Framebuffer = /*#__PURE__*/ function() {
13925
- function Framebuffer() {}
13926
- var _proto = Framebuffer.prototype;
13927
- _proto.resize = function resize(x, y, width, height) {
13928
- // OVERRIDE
13929
- };
13930
- _proto.resetColorTextures = function resetColorTextures(textures) {
13931
- // OVERRIDE
13932
- };
13933
- _proto.unbind = function unbind() {
13934
- // OVERRIDE
13935
- };
13936
- _proto.bind = function bind() {
13937
- // OVERRIDE
13938
- };
13939
- _proto.getDepthTexture = function getDepthTexture() {
13940
- // OVERRIDE
13941
- return undefined;
13942
- };
13943
- _proto.getStencilTexture = function getStencilTexture() {
13944
- // OVERRIDE
13945
- return undefined;
13946
- };
13947
- _proto.getColorTextures = function getColorTextures() {
13948
- // OVERRIDE
13949
- return [];
13950
- };
13951
- _proto.dispose = function dispose(options) {
13952
- // OVERRIDE
13953
- };
13954
- _create_class(Framebuffer, [
13955
- {
13956
- key: "stencilStorage",
13957
- get: function get() {
13958
- // OVERRIDE
13959
- return undefined;
13960
- }
13961
- },
13962
- {
13963
- key: "depthStorage",
13964
- get: function get() {
13965
- // OVERRIDE
13966
- return undefined;
13967
- }
13968
- }
13969
- ]);
13970
- return Framebuffer;
13971
- }();
13972
-
13973
13443
  var Renderer = /*#__PURE__*/ function() {
13974
13444
  function Renderer(engine) {
13975
13445
  this.engine = engine;
13446
+ this.currentFramebuffer = null;
13447
+ this.renderTargetPool = new RenderTargetPool(engine);
13976
13448
  }
13977
13449
  var _proto = Renderer.prototype;
13978
13450
  _proto.setGlobalFloat = function setGlobalFloat(name, value) {
@@ -14042,8 +13514,18 @@ var Renderer = /*#__PURE__*/ function() {
14042
13514
  // OVERRIDE
14043
13515
  };
14044
13516
  _proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
14045
- // OVERRIDE
14046
- return null;
13517
+ return this.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
13518
+ };
13519
+ _proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
13520
+ this.renderTargetPool.release(rt);
13521
+ };
13522
+ /**
13523
+ * 将源纹理复制到目标 Framebuffer,可使用自定义材质进行处理
13524
+ * @param source - 源纹理
13525
+ * @param destination - 目标 Framebuffer,如果为 null 则渲染到屏幕
13526
+ * @param material - 可选的自定义材质,不传则使用默认复制材质
13527
+ */ _proto.blit = function blit(source, destination, material) {
13528
+ // OVERRIDE
14047
13529
  };
14048
13530
  _proto.dispose = function dispose() {
14049
13531
  // OVERRIDE
@@ -14051,6 +13533,41 @@ var Renderer = /*#__PURE__*/ function() {
14051
13533
  return Renderer;
14052
13534
  }();
14053
13535
 
13536
+ var SemanticMap = /*#__PURE__*/ function() {
13537
+ function SemanticMap(semantics) {
13538
+ if (semantics === void 0) semantics = {};
13539
+ this.semantics = _extends({}, semantics);
13540
+ }
13541
+ var _proto = SemanticMap.prototype;
13542
+ _proto.toObject = function toObject() {
13543
+ return _extends({}, this.semantics);
13544
+ };
13545
+ _proto.setSemantic = function setSemantic(name, value) {
13546
+ if (value === undefined) {
13547
+ delete this.semantics[name];
13548
+ } else {
13549
+ this.semantics[name] = value;
13550
+ }
13551
+ };
13552
+ _proto.getSemanticValue = function getSemanticValue(name, state) {
13553
+ var ret = this.semantics[name];
13554
+ if (isFunction(ret)) {
13555
+ return ret(state);
13556
+ }
13557
+ return ret;
13558
+ };
13559
+ _proto.hasSemanticValue = function hasSemanticValue(name) {
13560
+ return name in this.semantics;
13561
+ };
13562
+ _proto.dispose = function dispose() {
13563
+ var _this = this;
13564
+ Object.keys(this.semantics).forEach(function(name) {
13565
+ delete _this.semantics[name];
13566
+ });
13567
+ };
13568
+ return SemanticMap;
13569
+ }();
13570
+
14054
13571
  /**
14055
13572
  * @since 2.7.0
14056
13573
  */ var MaskableGraphic = /*#__PURE__*/ function(RendererComponent) {
@@ -18081,6 +17598,11 @@ exports.PlayState = void 0;
18081
17598
  PlayState[PlayState["Paused"] = 1] = "Paused";
18082
17599
  })(exports.PlayState || (exports.PlayState = {}));
18083
17600
 
17601
+ function _assert_this_initialized(self) {
17602
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
17603
+ return self;
17604
+ }
17605
+
18084
17606
  var tempQuat$1 = new Quaternion();
18085
17607
  var tempVector3 = new Vector3();
18086
17608
  var tempVector3Second = new Vector3();
@@ -24458,8 +23980,7 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24458
23980
  _this.reusable = reusable;
24459
23981
  _this.speed = speed;
24460
23982
  _this.name = sourceContent.name;
24461
- _this.pluginSystem = scene.pluginSystem;
24462
- _this.pluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
23983
+ PluginSystem.initializeComposition(_assert_this_initialized(_this), scene);
24463
23984
  _this.camera = new Camera(_this.name, _extends({}, sourceContent == null ? void 0 : sourceContent.camera, {
24464
23985
  aspect: width / height,
24465
23986
  pixelWidth: width,
@@ -24473,7 +23994,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24473
23994
  _this.createRenderFrame();
24474
23995
  Composition.buildItemTree(_this.rootItem);
24475
23996
  _this.rootComposition.setChildrenRenderOrder(0);
24476
- _this.pluginSystem.resetComposition(_assert_this_initialized(_this), _this.renderFrame);
24477
23997
  return _this;
24478
23998
  }
24479
23999
  var _proto = Composition.prototype;
@@ -24583,12 +24103,9 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24583
24103
  this.renderFrame = new RenderFrame({
24584
24104
  camera: this.camera,
24585
24105
  renderer: this.renderer,
24586
- keepColorBuffer: this.keepColorBuffer,
24587
24106
  globalVolume: this.globalVolume,
24588
24107
  postProcessingEnabled: this.postProcessingEnabled
24589
24108
  });
24590
- // TODO 考虑放到构造函数
24591
- this.renderFrame.cachedTextures = this.textures;
24592
24109
  };
24593
24110
  /**
24594
24111
  * 跳到指定时间点(不做任何播放行为)
@@ -24639,7 +24156,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24639
24156
  this.isEnded = false;
24640
24157
  this.isEndCalled = false;
24641
24158
  this.rootComposition.time = 0;
24642
- this.pluginSystem.resetComposition(this, this.renderFrame);
24643
24159
  };
24644
24160
  _proto.prepareRender = function prepareRender() {};
24645
24161
  /**
@@ -24657,8 +24173,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24657
24173
  var previousCompositionTime = this.time;
24658
24174
  this.updateCompositionTime(deltaTime * this.speed / 1000);
24659
24175
  var deltaTimeInMs = (this.time - previousCompositionTime) * 1000;
24660
- // 更新 model-tree-plugin
24661
- this.updatePluginLoaders(deltaTimeInMs);
24662
24176
  this.sceneTicking.update.tick(deltaTimeInMs);
24663
24177
  this.sceneTicking.lateUpdate.tick(deltaTimeInMs);
24664
24178
  this.updateCamera();
@@ -24683,15 +24197,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24683
24197
  this.camera.updateMatrix();
24684
24198
  };
24685
24199
  /**
24686
- * 插件更新,来自 CompVFXItem 的更新调用
24687
- * @param deltaTime - 更新的时间步长
24688
- */ _proto.updatePluginLoaders = function updatePluginLoaders(deltaTime) {
24689
- var _this = this;
24690
- this.pluginSystem.plugins.forEach(function(loader) {
24691
- return loader.onCompositionUpdate(_this, deltaTime);
24692
- });
24693
- };
24694
- /**
24695
24200
  * 更新主合成组件
24696
24201
  */ _proto.updateCompositionTime = function updateCompositionTime(deltaTime) {
24697
24202
  if (this.rootComposition.state === exports.PlayState.Paused || !this.rootComposition.isActiveAndEnabled) {
@@ -24850,7 +24355,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24850
24355
  * 合成对象销毁
24851
24356
  */ _proto.dispose = function dispose() {
24852
24357
  var _this = this;
24853
- var _this_pluginSystem;
24854
24358
  if (this.destroyed) {
24855
24359
  return;
24856
24360
  }
@@ -24870,13 +24374,14 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24870
24374
  this.rootItem.dispose();
24871
24375
  // FIXME: 注意这里增加了renderFrame销毁
24872
24376
  this.renderFrame.dispose();
24873
- (_this_pluginSystem = this.pluginSystem) == null ? void 0 : _this_pluginSystem.destroyComposition(this);
24377
+ PluginSystem.destroyComposition(this);
24874
24378
  this.update = function() {
24875
24379
  {
24876
24380
  logger.error("Update disposed composition: " + _this.name + ".");
24877
24381
  }
24878
24382
  };
24879
24383
  this.dispose = noop;
24384
+ this.renderer.engine.removeComposition(this);
24880
24385
  if (this.getEngine().env === PLAYER_OPTIONS_ENV_EDITOR) {
24881
24386
  return;
24882
24387
  }
@@ -24893,7 +24398,6 @@ var LateUpdateTickData = /*#__PURE__*/ function(TickData) {
24893
24398
  0
24894
24399
  ]
24895
24400
  });
24896
- this.renderer.engine.removeComposition(this);
24897
24401
  };
24898
24402
  /**
24899
24403
  * 编辑器使用的 transform 修改方法
@@ -31868,7 +31372,7 @@ function getStandardSpriteContent(sprite, transform) {
31868
31372
  return ret;
31869
31373
  }
31870
31374
 
31871
- var version$1 = "2.8.0-alpha.1";
31375
+ var version$1 = "2.8.0-alpha.3";
31872
31376
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
31873
31377
  var standardVersion = /^(\d+)\.(\d+)$/;
31874
31378
  var reverseParticle = false;
@@ -32383,7 +31887,7 @@ var seed = 1;
32383
31887
  * @param renderer - renderer 对象,用于获取管理、编译 shader 及 GPU 上下文的参数
32384
31888
  * @param options - 扩展参数
32385
31889
  * @returns
32386
- */ _proto.loadScene = function loadScene(url, renderer, options) {
31890
+ */ _proto.loadScene = function loadScene(url, renderer) {
32387
31891
  var _this = this;
32388
31892
  return _async_to_generator(function() {
32389
31893
  var rawJSON, assetUrl, startTime, timeInfoMessages, gpuInstance, _gpuInstance_detail_ktx2Support, isKTX2Supported, timeInfos, loadTimer, cancelLoading, waitPromise, hookTimeInfo, loadResourcePromise;
@@ -32444,7 +31948,7 @@ var seed = 1;
32444
31948
  });
32445
31949
  });
32446
31950
  loadResourcePromise = /*#__PURE__*/ _async_to_generator(function() {
32447
- var scene, link, _ref, jsonScene, pluginSystem, _jsonScene_bins, bins, images, fonts, _ref1, loadedBins, loadedImages, loadedTextures, totalTime;
31951
+ var scene, link, _scene_bins, _scene_textureOptions, _scene_images, jsonScene, _jsonScene_bins, bins, images, fonts, _ref, loadedBins, loadedImages, loadedTextures, totalTime;
32448
31952
  return __generator(this, function(_state) {
32449
31953
  switch(_state.label){
32450
31954
  case 0:
@@ -32494,7 +31998,26 @@ var seed = 1;
32494
31998
  })
32495
31999
  ];
32496
32000
  case 5:
32497
- _ref = _state.sent(), jsonScene = _ref.jsonScene, pluginSystem = _ref.pluginSystem;
32001
+ jsonScene = _state.sent().jsonScene;
32002
+ scene = {
32003
+ timeInfos: timeInfos,
32004
+ url: url,
32005
+ storage: {},
32006
+ jsonScene: jsonScene,
32007
+ bins: [],
32008
+ textureOptions: [],
32009
+ textures: [],
32010
+ images: [],
32011
+ assets: _this.assets
32012
+ };
32013
+ return [
32014
+ 4,
32015
+ hookTimeInfo("plugin:processAssets", function() {
32016
+ return _this.processPluginAssets(scene);
32017
+ })
32018
+ ];
32019
+ case 6:
32020
+ _state.sent();
32498
32021
  _jsonScene_bins = jsonScene.bins, bins = _jsonScene_bins === void 0 ? [] : _jsonScene_bins, images = jsonScene.images, fonts = jsonScene.fonts;
32499
32022
  return [
32500
32023
  4,
@@ -32505,46 +32028,26 @@ var seed = 1;
32505
32028
  hookTimeInfo("processImages", function() {
32506
32029
  return _this.processImages(images, isKTX2Supported);
32507
32030
  }),
32508
- hookTimeInfo("plugin:processAssets", function() {
32509
- return _this.processPluginAssets(jsonScene, pluginSystem, options);
32510
- }),
32511
32031
  hookTimeInfo("processFontURL", function() {
32512
32032
  return _this.processFontURL(fonts);
32513
32033
  })
32514
32034
  ])
32515
32035
  ];
32516
- case 6:
32517
- _ref1 = _state.sent(), loadedBins = _ref1[0], loadedImages = _ref1[1];
32036
+ case 7:
32037
+ _ref = _state.sent(), loadedBins = _ref[0], loadedImages = _ref[1];
32518
32038
  return [
32519
32039
  4,
32520
32040
  hookTimeInfo("processTextures", function() {
32521
32041
  return _this.processTextures(loadedImages, loadedBins, jsonScene);
32522
32042
  })
32523
32043
  ];
32524
- case 7:
32525
- loadedTextures = _state.sent();
32526
- scene = {
32527
- timeInfos: timeInfos,
32528
- url: url,
32529
- renderLevel: _this.options.renderLevel,
32530
- storage: {},
32531
- pluginSystem: pluginSystem,
32532
- jsonScene: jsonScene,
32533
- bins: loadedBins,
32534
- textureOptions: loadedTextures,
32535
- textures: [],
32536
- images: loadedImages,
32537
- assets: _this.assets
32538
- };
32539
- // 触发插件系统 pluginSystem 的回调 prepareResource
32540
- return [
32541
- 4,
32542
- hookTimeInfo("plugin:prepareResource", function() {
32543
- return pluginSystem.loadResources(scene, _this.options);
32544
- })
32545
- ];
32546
32044
  case 8:
32547
- _state.sent();
32045
+ loadedTextures = _state.sent();
32046
+ (_scene_bins = scene.bins).push.apply(_scene_bins, [].concat(loadedBins));
32047
+ (_scene_textureOptions = scene.textureOptions).push.apply(_scene_textureOptions, [].concat(loadedTextures));
32048
+ (_scene_images = scene.images).push.apply(_scene_images, [].concat(loadedImages));
32049
+ // 降级插件会修改 this.options.renderLevel, 在 processPluginAssets 后赋值
32050
+ scene.renderLevel = _this.options.renderLevel;
32548
32051
  _state.label = 9;
32549
32052
  case 9:
32550
32053
  totalTime = performance.now() - startTime;
@@ -32576,29 +32079,23 @@ var seed = 1;
32576
32079
  return this.assets;
32577
32080
  };
32578
32081
  _proto.processJSON = function processJSON(json) {
32579
- var _this = this;
32580
32082
  return _async_to_generator(function() {
32581
- var jsonScene, _jsonScene_plugins, plugins, pluginSystem;
32083
+ var jsonScene, _jsonScene_plugins, plugins, _iterator, _step, customPluginName;
32582
32084
  return __generator(this, function(_state) {
32583
- switch(_state.label){
32584
- case 0:
32585
- jsonScene = getStandardJSON(json);
32586
- _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
32587
- pluginSystem = new PluginSystem(plugins);
32588
- return [
32589
- 4,
32590
- pluginSystem.processRawJSON(jsonScene, _this.options)
32591
- ];
32592
- case 1:
32593
- _state.sent();
32594
- return [
32595
- 2,
32596
- {
32597
- jsonScene: jsonScene,
32598
- pluginSystem: pluginSystem
32599
- }
32600
- ];
32085
+ jsonScene = getStandardJSON(json);
32086
+ _jsonScene_plugins = jsonScene.plugins, plugins = _jsonScene_plugins === void 0 ? [] : _jsonScene_plugins;
32087
+ for(_iterator = _create_for_of_iterator_helper_loose(plugins); !(_step = _iterator()).done;){
32088
+ customPluginName = _step.value;
32089
+ if (!pluginLoaderMap[customPluginName]) {
32090
+ throw new Error("The plugin '" + customPluginName + "' not found." + getPluginUsageInfo(customPluginName));
32091
+ }
32601
32092
  }
32093
+ return [
32094
+ 2,
32095
+ {
32096
+ jsonScene: jsonScene
32097
+ }
32098
+ ];
32602
32099
  });
32603
32100
  })();
32604
32101
  };
@@ -32804,30 +32301,18 @@ var seed = 1;
32804
32301
  });
32805
32302
  })();
32806
32303
  };
32807
- _proto.processPluginAssets = function processPluginAssets(jsonScene, pluginSystem, options) {
32304
+ _proto.processPluginAssets = function processPluginAssets(scene) {
32808
32305
  var _this = this;
32809
32306
  return _async_to_generator(function() {
32810
- var pluginResult, _pluginResult_reduce, assets, loadedAssets, i;
32811
32307
  return __generator(this, function(_state) {
32812
32308
  switch(_state.label){
32813
32309
  case 0:
32814
32310
  return [
32815
32311
  4,
32816
- pluginSystem.processAssets(jsonScene, options)
32312
+ PluginSystem.processAssets(scene, _this.options)
32817
32313
  ];
32818
32314
  case 1:
32819
- pluginResult = _state.sent();
32820
- _pluginResult_reduce = pluginResult.reduce(function(acc, cur) {
32821
- acc.assets = acc.assets.concat(cur.assets);
32822
- acc.loadedAssets = acc.loadedAssets.concat(cur.loadedAssets);
32823
- return acc;
32824
- }, {
32825
- assets: [],
32826
- loadedAssets: []
32827
- }), assets = _pluginResult_reduce.assets, loadedAssets = _pluginResult_reduce.loadedAssets;
32828
- for(i = 0; i < assets.length; i++){
32829
- _this.assets[assets[i].id] = loadedAssets[i];
32830
- }
32315
+ _state.sent();
32831
32316
  return [
32832
32317
  2
32833
32318
  ];
@@ -33254,7 +32739,6 @@ function _createTextureOptionsBySource() {
33254
32739
  }
33255
32740
  };
33256
32741
  _proto.prepareAssets = function prepareAssets(scene, assets) {
33257
- this.engine.clearResources();
33258
32742
  for(var _iterator = _create_for_of_iterator_helper_loose(Object.keys(assets)), _step; !(_step = _iterator()).done;){
33259
32743
  var assetId = _step.value;
33260
32744
  var asset = assets[assetId];
@@ -35166,8 +34650,9 @@ var DEFAULT_FPS = 60;
35166
34650
  ]
35167
34651
  });
35168
34652
  for(var i1 = 0; i1 < comps.length; i1++){
35169
- !comps[i1].renderFrame.isDestroyed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
34653
+ !comps[i1].renderFrame.isDisposed && this.renderer.renderRenderFrame(comps[i1].renderFrame);
35170
34654
  }
34655
+ this.renderer.renderTargetPool.flush();
35171
34656
  };
35172
34657
  /**
35173
34658
  * 将渲染器重新和父容器大小对齐
@@ -35413,6 +34898,95 @@ var DEFAULT_FPS = 60;
35413
34898
  return Engine;
35414
34899
  }(EventEmitter);
35415
34900
 
34901
+ var def = {
34902
+ format: glContext.RGBA,
34903
+ type: glContext.UNSIGNED_BYTE,
34904
+ minFilter: glContext.LINEAR,
34905
+ magFilter: glContext.LINEAR,
34906
+ wrapS: glContext.CLAMP_TO_EDGE,
34907
+ wrapT: glContext.CLAMP_TO_EDGE
34908
+ };
34909
+ var disposeSymbol = Symbol("dispose");
34910
+ var PassTextureCache = /*#__PURE__*/ function() {
34911
+ function PassTextureCache(engine) {
34912
+ this.textureCache = {};
34913
+ this.textureRef = {};
34914
+ this.engine = engine;
34915
+ }
34916
+ var _proto = PassTextureCache.prototype;
34917
+ _proto.requestColorAttachmentTexture = function requestColorAttachmentTexture(request) {
34918
+ var _this = this;
34919
+ var width = request.width, height = request.height, name = request.name;
34920
+ var options = {
34921
+ sourceType: exports.TextureSourceType.framebuffer,
34922
+ data: {
34923
+ width: width,
34924
+ height: height
34925
+ },
34926
+ name: name
34927
+ };
34928
+ var keys = [
34929
+ name
34930
+ ];
34931
+ Object.getOwnPropertyNames(def).forEach(function(name) {
34932
+ var _request_name;
34933
+ var value = (_request_name = request[name]) != null ? _request_name : def[name];
34934
+ options[name] = value;
34935
+ keys.push(name, value);
34936
+ });
34937
+ var cacheId = keys.join(":");
34938
+ var tex = this.textureCache[cacheId];
34939
+ if (tex) {
34940
+ this.textureRef[cacheId]++;
34941
+ } else {
34942
+ var engine = this.engine;
34943
+ assertExist(engine);
34944
+ tex = Texture.create(engine, options);
34945
+ this.textureCache[cacheId] = tex;
34946
+ this.textureRef[cacheId] = 1;
34947
+ // @ts-expect-error
34948
+ tex[disposeSymbol] = tex.dispose;
34949
+ tex.dispose = function() {
34950
+ return _this.removeTexture(cacheId);
34951
+ };
34952
+ }
34953
+ return tex;
34954
+ };
34955
+ _proto.removeTexture = function removeTexture(id) {
34956
+ var refCount = this.textureRef[id];
34957
+ if (refCount <= 1) {
34958
+ if (refCount < 0) {
34959
+ console.error("Ref count < 0.");
34960
+ }
34961
+ var tex = this.textureCache[id];
34962
+ if (tex) {
34963
+ // @ts-expect-error
34964
+ tex[disposeSymbol]();
34965
+ // @ts-expect-error
34966
+ tex.dispose = tex[disposeSymbol];
34967
+ }
34968
+ delete this.textureCache[id];
34969
+ delete this.textureRef[id];
34970
+ } else {
34971
+ this.textureRef[id] = refCount - 1;
34972
+ }
34973
+ };
34974
+ _proto.dispose = function dispose() {
34975
+ var _this = this;
34976
+ Object.keys(this.textureCache).forEach(function(key) {
34977
+ var texture = _this.textureCache[key];
34978
+ // @ts-expect-error
34979
+ texture[disposeSymbol]();
34980
+ // @ts-expect-error
34981
+ texture.dispose = texture[disposeSymbol];
34982
+ });
34983
+ this.textureCache = {};
34984
+ this.textureRef = {};
34985
+ this.engine = undefined;
34986
+ };
34987
+ return PassTextureCache;
34988
+ }();
34989
+
35416
34990
  var SceneLoader = /*#__PURE__*/ function() {
35417
34991
  function SceneLoader() {}
35418
34992
  SceneLoader.load = function load(scene, engine, options) {
@@ -35431,16 +35005,16 @@ var SceneLoader = /*#__PURE__*/ function() {
35431
35005
  engine.assetManagers.push(assetManager);
35432
35006
  return [
35433
35007
  4,
35434
- assetManager.loadScene(scene, engine.renderer, {
35435
- env: engine.env
35436
- })
35008
+ assetManager.loadScene(scene, engine.renderer)
35437
35009
  ];
35438
35010
  case 1:
35439
35011
  loadedScene = _state.sent();
35012
+ engine.clearResources();
35013
+ // 触发插件系统 pluginSystem 的回调 prepareResource
35014
+ PluginSystem.loadResources(loadedScene, assetManager.options, engine);
35440
35015
  engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
35441
35016
  engine.assetService.updateTextVariables(loadedScene, options.variables);
35442
35017
  engine.assetService.initializeTexture(loadedScene);
35443
- loadedScene.pluginSystem.precompile(loadedScene.jsonScene.compositions, engine.renderer);
35444
35018
  composition = _this.createComposition(loadedScene, engine, options);
35445
35019
  composition.setIndex(compositionIndex);
35446
35020
  compileStart = performance.now();
@@ -35493,13 +35067,13 @@ var SceneLoader = /*#__PURE__*/ function() {
35493
35067
  return SceneLoader;
35494
35068
  }();
35495
35069
 
35496
- registerPlugin("camera", CameraVFXItemLoader, exports.VFXItem);
35497
- registerPlugin("text", TextLoader, exports.VFXItem);
35498
- registerPlugin("sprite", SpriteLoader, exports.VFXItem);
35499
- registerPlugin("particle", ParticleLoader, exports.VFXItem);
35500
- registerPlugin("cal", CalculateLoader, exports.VFXItem);
35501
- registerPlugin("interact", InteractLoader, exports.VFXItem);
35502
- var version = "2.8.0-alpha.1";
35070
+ registerPlugin("camera", CameraVFXItemLoader);
35071
+ registerPlugin("text", TextLoader);
35072
+ registerPlugin("sprite", SpriteLoader);
35073
+ registerPlugin("particle", ParticleLoader);
35074
+ registerPlugin("cal", CalculateLoader);
35075
+ registerPlugin("interact", InteractLoader);
35076
+ var version = "2.8.0-alpha.3";
35503
35077
  logger.info("Core version: " + version + ".");
35504
35078
 
35505
35079
  exports.AbstractPlugin = AbstractPlugin;
@@ -35610,7 +35184,6 @@ exports.Pose = Pose;
35610
35184
  exports.PoseNode = PoseNode;
35611
35185
  exports.PropertyClipPlayable = PropertyClipPlayable;
35612
35186
  exports.PropertyTrack = PropertyTrack;
35613
- exports.RENDER_PASS_NAME_PREFIX = RENDER_PASS_NAME_PREFIX;
35614
35187
  exports.RENDER_PREFER_LOOKUP_TEXTURE = RENDER_PREFER_LOOKUP_TEXTURE;
35615
35188
  exports.RUNTIME_ENV = RUNTIME_ENV;
35616
35189
  exports.RandomSetValue = RandomSetValue;
@@ -35623,6 +35196,7 @@ exports.RenderPassPriorityNormal = RenderPassPriorityNormal;
35623
35196
  exports.RenderPassPriorityPostprocess = RenderPassPriorityPostprocess;
35624
35197
  exports.RenderPassPriorityPrepare = RenderPassPriorityPrepare;
35625
35198
  exports.RenderTargetHandle = RenderTargetHandle;
35199
+ exports.RenderTargetPool = RenderTargetPool;
35626
35200
  exports.Renderbuffer = Renderbuffer;
35627
35201
  exports.Renderer = Renderer;
35628
35202
  exports.RendererComponent = RendererComponent;
@@ -35685,14 +35259,12 @@ exports.colorGradingFrag = colorGradingFrag;
35685
35259
  exports.colorStopsFromGradient = colorStopsFromGradient;
35686
35260
  exports.colorToArr = colorToArr$1;
35687
35261
  exports.combineImageTemplate = combineImageTemplate;
35688
- exports.createCopyShader = createCopyShader;
35689
35262
  exports.createGLContext = createGLContext;
35690
35263
  exports.createKeyFrameMeta = createKeyFrameMeta;
35691
35264
  exports.createShape = createShape;
35692
35265
  exports.createValueGetter = createValueGetter;
35693
35266
  exports.curveEps = curveEps;
35694
35267
  exports.decimalEqual = decimalEqual;
35695
- exports.defaultPlugins = defaultPlugins;
35696
35268
  exports.deserializeMipmapTexture = deserializeMipmapTexture;
35697
35269
  exports.earcut = earcut;
35698
35270
  exports.effectsClass = effectsClass;
@@ -35700,7 +35272,6 @@ exports.effectsClassStore = effectsClassStore;
35700
35272
  exports.enlargeBuffer = enlargeBuffer;
35701
35273
  exports.ensureFixedNumber = ensureFixedNumber;
35702
35274
  exports.ensureVec3 = ensureVec3;
35703
- exports.findPreviousRenderPass = findPreviousRenderPass;
35704
35275
  exports.gaussianDownHFrag = gaussianDownHFrag;
35705
35276
  exports.gaussianDownVFrag = gaussianDownVFrag;
35706
35277
  exports.gaussianUpFrag = gaussianUpFrag;
@@ -35721,6 +35292,7 @@ exports.getMergedStore = getMergedStore;
35721
35292
  exports.getNodeDataClass = getNodeDataClass;
35722
35293
  exports.getParticleMeshShader = getParticleMeshShader;
35723
35294
  exports.getPixelRatio = getPixelRatio;
35295
+ exports.getPluginUsageInfo = getPluginUsageInfo;
35724
35296
  exports.getPreMultiAlpha = getPreMultiAlpha;
35725
35297
  exports.getStandardComposition = getStandardComposition;
35726
35298
  exports.getStandardImage = getStandardImage;