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