@galacean/effects-core 2.8.0-alpha.2 → 2.8.0-alpha.4
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/README.md +279 -135
- package/dist/asset-manager.d.ts +1 -1
- package/dist/components/effect-component.d.ts +2 -1
- package/dist/components/mesh-component.d.ts +7 -1
- package/dist/index.js +829 -808
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +829 -808
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-system.d.ts +4 -4
- package/dist/plugins/cal/calculate-loader.d.ts +2 -2
- package/dist/plugins/camera/camera-vfx-item-loader.d.ts +2 -2
- package/dist/plugins/interact/interact-loader.d.ts +2 -2
- package/dist/plugins/particle/particle-loader.d.ts +2 -2
- package/dist/plugins/particle/particle-system.d.ts +2 -1
- package/dist/plugins/plugin.d.ts +24 -19
- package/dist/plugins/sprite/sprite-item.d.ts +0 -1
- package/dist/plugins/sprite/sprite-loader.d.ts +2 -2
- package/dist/plugins/text/text-item.d.ts +21 -1
- package/dist/plugins/text/text-loader.d.ts +2 -2
- package/dist/render/post-process-pass.d.ts +9 -24
- package/dist/render/renderer.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2883,7 +2883,6 @@ var plugins = [];
|
|
|
2883
2883
|
pluginLoaderMap[name] = pluginClass;
|
|
2884
2884
|
var pluginInstance = new pluginClass();
|
|
2885
2885
|
pluginInstance.name = name;
|
|
2886
|
-
pluginInstance.initialize();
|
|
2887
2886
|
plugins.push(pluginInstance);
|
|
2888
2887
|
plugins.sort(function(a, b) {
|
|
2889
2888
|
return a.order - b.order;
|
|
@@ -2907,29 +2906,29 @@ var PluginSystem = /*#__PURE__*/ function() {
|
|
|
2907
2906
|
};
|
|
2908
2907
|
PluginSystem.initializeComposition = function initializeComposition(composition, scene) {
|
|
2909
2908
|
plugins.forEach(function(loader) {
|
|
2910
|
-
return loader.
|
|
2909
|
+
return loader.onCompositionCreated(composition, scene);
|
|
2911
2910
|
});
|
|
2912
2911
|
};
|
|
2913
2912
|
PluginSystem.destroyComposition = function destroyComposition(comp) {
|
|
2914
2913
|
plugins.forEach(function(loader) {
|
|
2915
|
-
return loader.
|
|
2914
|
+
return loader.onCompositionDestroy(comp);
|
|
2916
2915
|
});
|
|
2917
2916
|
};
|
|
2918
|
-
PluginSystem.
|
|
2917
|
+
PluginSystem.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2919
2918
|
return _async_to_generator(function() {
|
|
2920
2919
|
return __generator(this, function(_state) {
|
|
2921
2920
|
return [
|
|
2922
2921
|
2,
|
|
2923
2922
|
Promise.all(plugins.map(function(plugin) {
|
|
2924
|
-
return plugin.
|
|
2923
|
+
return plugin.onAssetsLoadStart(scene, options);
|
|
2925
2924
|
}))
|
|
2926
2925
|
];
|
|
2927
2926
|
});
|
|
2928
2927
|
})();
|
|
2929
2928
|
};
|
|
2930
|
-
PluginSystem.
|
|
2929
|
+
PluginSystem.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {
|
|
2931
2930
|
plugins.forEach(function(loader) {
|
|
2932
|
-
return loader.
|
|
2931
|
+
return loader.onAssetsLoadFinish(scene, options, engine);
|
|
2933
2932
|
});
|
|
2934
2933
|
};
|
|
2935
2934
|
return PluginSystem;
|
|
@@ -2959,20 +2958,18 @@ function getPluginUsageInfo(name) {
|
|
|
2959
2958
|
/**
|
|
2960
2959
|
* 抽象插件类
|
|
2961
2960
|
* 注册合成不同生命周期的回调函数
|
|
2962
|
-
*/ var
|
|
2963
|
-
function
|
|
2961
|
+
*/ var Plugin = /*#__PURE__*/ function() {
|
|
2962
|
+
function Plugin() {
|
|
2964
2963
|
this.order = 100;
|
|
2965
|
-
this.name = "";
|
|
2964
|
+
this.name = "Plugin";
|
|
2966
2965
|
}
|
|
2967
|
-
var _proto =
|
|
2968
|
-
_proto.initialize = function initialize() {};
|
|
2966
|
+
var _proto = Plugin.prototype;
|
|
2969
2967
|
/**
|
|
2970
|
-
*
|
|
2971
|
-
*
|
|
2972
|
-
* @param scene
|
|
2973
|
-
* @param options
|
|
2974
|
-
|
|
2975
|
-
*/ _proto.processAssets = function processAssets(scene, options) {
|
|
2968
|
+
* 场景加载时触发,用于加载插件所需的自定义资源。
|
|
2969
|
+
* 此阶段适合发起异步资源请求。
|
|
2970
|
+
* @param scene - 场景对象
|
|
2971
|
+
* @param options - 场景加载选项
|
|
2972
|
+
*/ _proto.onAssetsLoadStart = function onAssetsLoadStart(scene, options) {
|
|
2976
2973
|
return _async_to_generator(function() {
|
|
2977
2974
|
return __generator(this, function(_state) {
|
|
2978
2975
|
return [
|
|
@@ -2982,17 +2979,22 @@ function getPluginUsageInfo(name) {
|
|
|
2982
2979
|
})();
|
|
2983
2980
|
};
|
|
2984
2981
|
/**
|
|
2985
|
-
*
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2982
|
+
* 场景资源加载完成后触发。
|
|
2983
|
+
* 此时 JSON 中的图片和二进制已加载完成,可对资源做进一步处理。
|
|
2984
|
+
* @param scene - 场景对象
|
|
2985
|
+
* @param options - 场景加载选项
|
|
2986
|
+
* @param engine - 引擎实例
|
|
2987
|
+
*/ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
|
|
2988
|
+
/**
|
|
2989
|
+
* 合成创建完成后触发。
|
|
2990
|
+
* @param composition - 合成对象
|
|
2991
|
+
* @param scene - 场景对象
|
|
2992
|
+
*/ _proto.onCompositionCreated = function onCompositionCreated(composition, scene) {};
|
|
2993
|
+
/**
|
|
2994
|
+
* 合成销毁时触发。
|
|
2995
|
+
* @param composition - 合成对象
|
|
2996
|
+
*/ _proto.onCompositionDestroy = function onCompositionDestroy(composition) {};
|
|
2997
|
+
return Plugin;
|
|
2996
2998
|
}();
|
|
2997
2999
|
|
|
2998
3000
|
function _set_prototype_of(o, p) {
|
|
@@ -7230,13 +7232,388 @@ __decorate([
|
|
|
7230
7232
|
serialize()
|
|
7231
7233
|
], RendererComponent.prototype, "_priority", void 0);
|
|
7232
7234
|
|
|
7235
|
+
exports.ShaderType = void 0;
|
|
7236
|
+
(function(ShaderType) {
|
|
7237
|
+
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
7238
|
+
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
7239
|
+
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
7240
|
+
exports.MaskMode = void 0;
|
|
7241
|
+
(function(MaskMode) {
|
|
7242
|
+
/**
|
|
7243
|
+
* 无
|
|
7244
|
+
*/ MaskMode[MaskMode["NONE"] = 0] = "NONE";
|
|
7245
|
+
/**
|
|
7246
|
+
* 蒙版
|
|
7247
|
+
*/ MaskMode[MaskMode["MASK"] = 1] = "MASK";
|
|
7248
|
+
/**
|
|
7249
|
+
* 被遮挡
|
|
7250
|
+
*/ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
|
|
7251
|
+
/**
|
|
7252
|
+
* 被反向遮挡
|
|
7253
|
+
*/ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
|
|
7254
|
+
})(exports.MaskMode || (exports.MaskMode = {}));
|
|
7255
|
+
|
|
7256
|
+
exports.TextureLoadAction = void 0;
|
|
7257
|
+
(function(TextureLoadAction) {
|
|
7258
|
+
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
7259
|
+
//preserve previous attachment
|
|
7260
|
+
//load = 1,
|
|
7261
|
+
//clear attachment
|
|
7262
|
+
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
7263
|
+
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
7264
|
+
exports.TextureSourceType = void 0;
|
|
7265
|
+
(function(TextureSourceType) {
|
|
7266
|
+
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
7267
|
+
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
7268
|
+
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
7269
|
+
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
7270
|
+
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
7271
|
+
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
7272
|
+
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
7273
|
+
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
7274
|
+
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
7275
|
+
|
|
7276
|
+
var MaskProcessor = /*#__PURE__*/ function() {
|
|
7277
|
+
function MaskProcessor(engine) {
|
|
7278
|
+
this.engine = engine;
|
|
7279
|
+
this.alphaMaskEnabled = false;
|
|
7280
|
+
this.maskMode = exports.MaskMode.NONE;
|
|
7281
|
+
this.maskable = null;
|
|
7282
|
+
this.stencilClearAction = {
|
|
7283
|
+
stencilAction: exports.TextureLoadAction.clear
|
|
7284
|
+
};
|
|
7285
|
+
}
|
|
7286
|
+
var _proto = MaskProcessor.prototype;
|
|
7287
|
+
_proto.getRefValue = function getRefValue() {
|
|
7288
|
+
return 1;
|
|
7289
|
+
};
|
|
7290
|
+
_proto.setMaskOptions = function setMaskOptions(data) {
|
|
7291
|
+
var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_inverted = data.inverted, inverted = _data_inverted === void 0 ? false : _data_inverted, reference = data.reference, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
|
|
7292
|
+
this.alphaMaskEnabled = alphaMaskEnabled;
|
|
7293
|
+
if (isMask) {
|
|
7294
|
+
this.maskMode = exports.MaskMode.MASK;
|
|
7295
|
+
} else {
|
|
7296
|
+
this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
|
|
7297
|
+
this.maskable = this.engine.findObject(reference);
|
|
7298
|
+
}
|
|
7299
|
+
};
|
|
7300
|
+
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
7301
|
+
if (this.maskable) {
|
|
7302
|
+
renderer.clear(this.stencilClearAction);
|
|
7303
|
+
this.maskable.drawStencilMask(renderer);
|
|
7304
|
+
}
|
|
7305
|
+
};
|
|
7306
|
+
return MaskProcessor;
|
|
7307
|
+
}();
|
|
7308
|
+
|
|
7309
|
+
/**
|
|
7310
|
+
* Helper class to create a WebGL Context
|
|
7311
|
+
*
|
|
7312
|
+
* @param canvas
|
|
7313
|
+
* @param glType
|
|
7314
|
+
* @param options
|
|
7315
|
+
* @returns
|
|
7316
|
+
*/ function createGLContext(canvas, glType, options) {
|
|
7317
|
+
if (glType === void 0) glType = "webgl";
|
|
7318
|
+
var context;
|
|
7319
|
+
if (glType === "webgl2") {
|
|
7320
|
+
context = canvas.getContext("webgl2", options);
|
|
7321
|
+
if (!context) {
|
|
7322
|
+
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
7323
|
+
}
|
|
7324
|
+
}
|
|
7325
|
+
if (!context || glType === "webgl") {
|
|
7326
|
+
context = canvas.getContext("webgl", options);
|
|
7327
|
+
}
|
|
7328
|
+
if (!context) {
|
|
7329
|
+
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
7330
|
+
}
|
|
7331
|
+
return context;
|
|
7332
|
+
}
|
|
7333
|
+
|
|
7334
|
+
function gpuTimer(gl) {
|
|
7335
|
+
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
7336
|
+
if (ext) {
|
|
7337
|
+
var query = gl.createQuery();
|
|
7338
|
+
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
7339
|
+
return __generator(this, function(_state) {
|
|
7340
|
+
return [
|
|
7341
|
+
2,
|
|
7342
|
+
new Promise(function(resolve, reject) {
|
|
7343
|
+
if (query) {
|
|
7344
|
+
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
7345
|
+
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
7346
|
+
if (available && !disjoint) {
|
|
7347
|
+
// See how much time the rendering of the object took in nanoseconds.
|
|
7348
|
+
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
7349
|
+
// taken to use all significant bits of the result, not just the
|
|
7350
|
+
// least significant 32 bits.
|
|
7351
|
+
resolve(timeElapsed / 1000 / 1000);
|
|
7352
|
+
}
|
|
7353
|
+
if (available || disjoint) {
|
|
7354
|
+
// Clean up the query object.
|
|
7355
|
+
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
7356
|
+
query = null;
|
|
7357
|
+
}
|
|
7358
|
+
available !== null && query && window.setTimeout(function() {
|
|
7359
|
+
getTime().then(resolve).catch;
|
|
7360
|
+
}, 1);
|
|
7361
|
+
}
|
|
7362
|
+
})
|
|
7363
|
+
];
|
|
7364
|
+
});
|
|
7365
|
+
});
|
|
7366
|
+
if (!query) {
|
|
7367
|
+
return;
|
|
7368
|
+
}
|
|
7369
|
+
return {
|
|
7370
|
+
begin: function() {
|
|
7371
|
+
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
7372
|
+
},
|
|
7373
|
+
end: function() {
|
|
7374
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
7375
|
+
},
|
|
7376
|
+
getTime: getTime
|
|
7377
|
+
};
|
|
7378
|
+
}
|
|
7379
|
+
}
|
|
7380
|
+
|
|
7381
|
+
var initErrors = [];
|
|
7382
|
+
var glContext = {};
|
|
7383
|
+
var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
|
|
7384
|
+
var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
|
|
7385
|
+
if (!initErrors.length) {
|
|
7386
|
+
initGLContext();
|
|
7387
|
+
}
|
|
7388
|
+
function initGLContext() {
|
|
7389
|
+
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
7390
|
+
if (typeof WebGL2RenderingContext === "function") {
|
|
7391
|
+
copy(WebGL2RenderingContext);
|
|
7392
|
+
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
7393
|
+
copy(WebGLRenderingContext);
|
|
7394
|
+
copy(WebGLRenderingContext.prototype);
|
|
7395
|
+
} else {
|
|
7396
|
+
if (canUseBOM) {
|
|
7397
|
+
initErrors.push(// iOS 16 lockdown mode
|
|
7398
|
+
isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
7399
|
+
} else {
|
|
7400
|
+
initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7403
|
+
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
7404
|
+
// @ts-expect-error set default value
|
|
7405
|
+
glContext["HALF_FLOAT"] = 5131;
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
function isWebGL2(gl) {
|
|
7409
|
+
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
7410
|
+
}
|
|
7411
|
+
function copy(target) {
|
|
7412
|
+
for(var name in target){
|
|
7413
|
+
if (/^[A-Z_]/.test(name)) {
|
|
7414
|
+
// @ts-expect-error safe to assign
|
|
7415
|
+
glContext[name] = target[name];
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7418
|
+
}
|
|
7419
|
+
function vertexFormatType2GLType(formatType) {
|
|
7420
|
+
switch(formatType){
|
|
7421
|
+
case VertexFormatType.Float32:
|
|
7422
|
+
return WebGLRenderingContext["FLOAT"];
|
|
7423
|
+
case VertexFormatType.Int16:
|
|
7424
|
+
return WebGLRenderingContext["SHORT"];
|
|
7425
|
+
case VertexFormatType.Int8:
|
|
7426
|
+
return WebGLRenderingContext["BYTE"];
|
|
7427
|
+
case VertexFormatType.UInt16:
|
|
7428
|
+
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
7429
|
+
case VertexFormatType.UInt8:
|
|
7430
|
+
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
7431
|
+
default:
|
|
7432
|
+
return WebGLRenderingContext["FLOAT"];
|
|
7433
|
+
}
|
|
7434
|
+
}
|
|
7435
|
+
function glType2VertexFormatType(webglType) {
|
|
7436
|
+
switch(webglType){
|
|
7437
|
+
case WebGLRenderingContext["FLOAT"]:
|
|
7438
|
+
return VertexFormatType.Float32;
|
|
7439
|
+
case WebGLRenderingContext["SHORT"]:
|
|
7440
|
+
return VertexFormatType.Int16;
|
|
7441
|
+
case WebGLRenderingContext["BYTE"]:
|
|
7442
|
+
return VertexFormatType.Int8;
|
|
7443
|
+
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
7444
|
+
return VertexFormatType.UInt16;
|
|
7445
|
+
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
7446
|
+
return VertexFormatType.UInt8;
|
|
7447
|
+
default:
|
|
7448
|
+
return VertexFormatType.Float32;
|
|
7449
|
+
}
|
|
7450
|
+
}
|
|
7451
|
+
|
|
7452
|
+
function valIfUndefined(val, def) {
|
|
7453
|
+
if (val === undefined || val === null) {
|
|
7454
|
+
return def;
|
|
7455
|
+
}
|
|
7456
|
+
return val;
|
|
7457
|
+
}
|
|
7458
|
+
function getPreMultiAlpha(blending) {
|
|
7459
|
+
switch(blending){
|
|
7460
|
+
case BlendingMode.ALPHA:
|
|
7461
|
+
return 1;
|
|
7462
|
+
case BlendingMode.ADD:
|
|
7463
|
+
return 1;
|
|
7464
|
+
case BlendingMode.SUBTRACTION:
|
|
7465
|
+
return 1;
|
|
7466
|
+
case BlendingMode.STRONG_LIGHT:
|
|
7467
|
+
return 1;
|
|
7468
|
+
case BlendingMode.WEAK_LIGHT:
|
|
7469
|
+
return 1;
|
|
7470
|
+
case BlendingMode.SUPERPOSITION:
|
|
7471
|
+
return 2;
|
|
7472
|
+
case BlendingMode.BRIGHTNESS:
|
|
7473
|
+
return 3;
|
|
7474
|
+
case BlendingMode.MULTIPLY:
|
|
7475
|
+
return 0;
|
|
7476
|
+
default:
|
|
7477
|
+
// 处理undefined
|
|
7478
|
+
return 1;
|
|
7479
|
+
}
|
|
7480
|
+
}
|
|
7481
|
+
function setBlendMode(material, blendMode) {
|
|
7482
|
+
switch(blendMode){
|
|
7483
|
+
case undefined:
|
|
7484
|
+
material.blendFunction = [
|
|
7485
|
+
glContext.ONE,
|
|
7486
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7487
|
+
glContext.ONE,
|
|
7488
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7489
|
+
];
|
|
7490
|
+
break;
|
|
7491
|
+
case BlendingMode.ALPHA:
|
|
7492
|
+
material.blendFunction = [
|
|
7493
|
+
glContext.ONE,
|
|
7494
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7495
|
+
glContext.ONE,
|
|
7496
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7497
|
+
];
|
|
7498
|
+
break;
|
|
7499
|
+
case BlendingMode.ADD:
|
|
7500
|
+
material.blendFunction = [
|
|
7501
|
+
glContext.ONE,
|
|
7502
|
+
glContext.ONE,
|
|
7503
|
+
glContext.ONE,
|
|
7504
|
+
glContext.ONE
|
|
7505
|
+
];
|
|
7506
|
+
break;
|
|
7507
|
+
case BlendingMode.SUBTRACTION:
|
|
7508
|
+
material.blendFunction = [
|
|
7509
|
+
glContext.ONE,
|
|
7510
|
+
glContext.ONE,
|
|
7511
|
+
glContext.ZERO,
|
|
7512
|
+
glContext.ONE
|
|
7513
|
+
];
|
|
7514
|
+
material.blendEquation = [
|
|
7515
|
+
glContext.FUNC_REVERSE_SUBTRACT,
|
|
7516
|
+
glContext.FUNC_REVERSE_SUBTRACT
|
|
7517
|
+
];
|
|
7518
|
+
break;
|
|
7519
|
+
case BlendingMode.SUPERPOSITION:
|
|
7520
|
+
material.blendFunction = [
|
|
7521
|
+
glContext.ONE,
|
|
7522
|
+
glContext.ONE,
|
|
7523
|
+
glContext.ONE,
|
|
7524
|
+
glContext.ONE
|
|
7525
|
+
];
|
|
7526
|
+
break;
|
|
7527
|
+
case BlendingMode.MULTIPLY:
|
|
7528
|
+
material.blendFunction = [
|
|
7529
|
+
glContext.DST_COLOR,
|
|
7530
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7531
|
+
glContext.DST_COLOR,
|
|
7532
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7533
|
+
];
|
|
7534
|
+
break;
|
|
7535
|
+
case BlendingMode.BRIGHTNESS:
|
|
7536
|
+
material.blendFunction = [
|
|
7537
|
+
glContext.ONE,
|
|
7538
|
+
glContext.ONE_MINUS_SRC_ALPHA,
|
|
7539
|
+
glContext.ONE,
|
|
7540
|
+
glContext.ONE_MINUS_SRC_ALPHA
|
|
7541
|
+
];
|
|
7542
|
+
break;
|
|
7543
|
+
case BlendingMode.STRONG_LIGHT:
|
|
7544
|
+
material.blendFunction = [
|
|
7545
|
+
glContext.DST_COLOR,
|
|
7546
|
+
glContext.DST_ALPHA,
|
|
7547
|
+
glContext.ZERO,
|
|
7548
|
+
glContext.ONE
|
|
7549
|
+
];
|
|
7550
|
+
break;
|
|
7551
|
+
case BlendingMode.WEAK_LIGHT:
|
|
7552
|
+
material.blendFunction = [
|
|
7553
|
+
glContext.DST_COLOR,
|
|
7554
|
+
glContext.ZERO,
|
|
7555
|
+
glContext.ZERO,
|
|
7556
|
+
glContext.ONE
|
|
7557
|
+
];
|
|
7558
|
+
break;
|
|
7559
|
+
default:
|
|
7560
|
+
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
function setSideMode(material, side) {
|
|
7564
|
+
if (side === SideMode.DOUBLE) {
|
|
7565
|
+
material.culling = false;
|
|
7566
|
+
} else {
|
|
7567
|
+
material.culling = true;
|
|
7568
|
+
material.frontFace = glContext.CW;
|
|
7569
|
+
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
7570
|
+
}
|
|
7571
|
+
}
|
|
7572
|
+
function setMaskMode(material, maskMode) {
|
|
7573
|
+
switch(maskMode){
|
|
7574
|
+
case undefined:
|
|
7575
|
+
material.stencilTest = false;
|
|
7576
|
+
break;
|
|
7577
|
+
case exports.MaskMode.MASK:
|
|
7578
|
+
material.stencilTest = true;
|
|
7579
|
+
material.stencilFunc = [
|
|
7580
|
+
glContext.ALWAYS,
|
|
7581
|
+
glContext.ALWAYS
|
|
7582
|
+
];
|
|
7583
|
+
material.stencilOpZPass = [
|
|
7584
|
+
glContext.REPLACE,
|
|
7585
|
+
glContext.REPLACE
|
|
7586
|
+
];
|
|
7587
|
+
break;
|
|
7588
|
+
case exports.MaskMode.OBSCURED:
|
|
7589
|
+
material.stencilTest = true;
|
|
7590
|
+
material.stencilFunc = [
|
|
7591
|
+
glContext.EQUAL,
|
|
7592
|
+
glContext.EQUAL
|
|
7593
|
+
];
|
|
7594
|
+
break;
|
|
7595
|
+
case exports.MaskMode.REVERSE_OBSCURED:
|
|
7596
|
+
material.stencilTest = true;
|
|
7597
|
+
material.stencilFunc = [
|
|
7598
|
+
glContext.NOTEQUAL,
|
|
7599
|
+
glContext.NOTEQUAL
|
|
7600
|
+
];
|
|
7601
|
+
break;
|
|
7602
|
+
case exports.MaskMode.NONE:
|
|
7603
|
+
material.stencilTest = false;
|
|
7604
|
+
break;
|
|
7605
|
+
default:
|
|
7606
|
+
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
7607
|
+
}
|
|
7608
|
+
}
|
|
7609
|
+
|
|
7233
7610
|
/**
|
|
7234
7611
|
* Mesh 组件
|
|
7235
7612
|
*/ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
|
|
7236
7613
|
_inherits(MeshComponent, RendererComponent);
|
|
7237
|
-
function MeshComponent() {
|
|
7614
|
+
function MeshComponent(engine) {
|
|
7238
7615
|
var _this;
|
|
7239
|
-
_this = RendererComponent.
|
|
7616
|
+
_this = RendererComponent.call(this, engine) || this;
|
|
7240
7617
|
/**
|
|
7241
7618
|
* 用于点击测试的碰撞器
|
|
7242
7619
|
*/ _this.meshCollider = new MeshCollider();
|
|
@@ -7252,6 +7629,7 @@ __decorate([
|
|
|
7252
7629
|
};
|
|
7253
7630
|
}
|
|
7254
7631
|
};
|
|
7632
|
+
_this.maskManager = new MaskProcessor(engine);
|
|
7255
7633
|
return _this;
|
|
7256
7634
|
}
|
|
7257
7635
|
var _proto = MeshComponent.prototype;
|
|
@@ -7261,12 +7639,42 @@ __decorate([
|
|
|
7261
7639
|
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
7262
7640
|
}
|
|
7263
7641
|
};
|
|
7642
|
+
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
7643
|
+
if (!this.isActiveAndEnabled) {
|
|
7644
|
+
return;
|
|
7645
|
+
}
|
|
7646
|
+
for(var i = 0; i < this.materials.length; i++){
|
|
7647
|
+
var material = this.materials[i];
|
|
7648
|
+
var previousColorMask = material.colorMask;
|
|
7649
|
+
material.colorMask = false;
|
|
7650
|
+
renderer.drawGeometry(this.geometry, this.transform.getWorldMatrix(), material, i);
|
|
7651
|
+
material.colorMask = previousColorMask;
|
|
7652
|
+
}
|
|
7653
|
+
};
|
|
7264
7654
|
_proto.getBoundingBox = function getBoundingBox() {
|
|
7265
7655
|
var worldMatrix = this.transform.getWorldMatrix();
|
|
7266
7656
|
this.meshCollider.setGeometry(this.geometry, worldMatrix);
|
|
7267
7657
|
var boundingBox = this.meshCollider.getBoundingBox();
|
|
7268
7658
|
return boundingBox;
|
|
7269
7659
|
};
|
|
7660
|
+
// TODO: Update data spec
|
|
7661
|
+
_proto.fromData = function fromData(data) {
|
|
7662
|
+
RendererComponent.prototype.fromData.call(this, data);
|
|
7663
|
+
var maskableRendererData = data;
|
|
7664
|
+
var maskOptions = maskableRendererData.mask;
|
|
7665
|
+
if (maskOptions) {
|
|
7666
|
+
this.maskManager.setMaskOptions(maskOptions);
|
|
7667
|
+
}
|
|
7668
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.materials), _step; !(_step = _iterator()).done;){
|
|
7669
|
+
var material = _step.value;
|
|
7670
|
+
var stencilRef = this.maskManager.getRefValue();
|
|
7671
|
+
material.stencilRef = [
|
|
7672
|
+
stencilRef,
|
|
7673
|
+
stencilRef
|
|
7674
|
+
];
|
|
7675
|
+
setMaskMode(material, this.maskManager.maskMode);
|
|
7676
|
+
}
|
|
7677
|
+
};
|
|
7270
7678
|
return MeshComponent;
|
|
7271
7679
|
}(RendererComponent);
|
|
7272
7680
|
__decorate([
|
|
@@ -8456,348 +8864,6 @@ Matrix4.tempVec1 = new Vector3();
|
|
|
8456
8864
|
Matrix4.tempVec2 = new Vector3();
|
|
8457
8865
|
Matrix4.tempMat0 = new Matrix4();
|
|
8458
8866
|
|
|
8459
|
-
/**
|
|
8460
|
-
* Helper class to create a WebGL Context
|
|
8461
|
-
*
|
|
8462
|
-
* @param canvas
|
|
8463
|
-
* @param glType
|
|
8464
|
-
* @param options
|
|
8465
|
-
* @returns
|
|
8466
|
-
*/ function createGLContext(canvas, glType, options) {
|
|
8467
|
-
if (glType === void 0) glType = "webgl";
|
|
8468
|
-
var context;
|
|
8469
|
-
if (glType === "webgl2") {
|
|
8470
|
-
context = canvas.getContext("webgl2", options);
|
|
8471
|
-
if (!context) {
|
|
8472
|
-
console.debug("WebGL2 context retrieval failed, falling back to WebGL context.");
|
|
8473
|
-
}
|
|
8474
|
-
}
|
|
8475
|
-
if (!context || glType === "webgl") {
|
|
8476
|
-
context = canvas.getContext("webgl", options);
|
|
8477
|
-
}
|
|
8478
|
-
if (!context) {
|
|
8479
|
-
throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");
|
|
8480
|
-
}
|
|
8481
|
-
return context;
|
|
8482
|
-
}
|
|
8483
|
-
|
|
8484
|
-
function gpuTimer(gl) {
|
|
8485
|
-
var ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
8486
|
-
if (ext) {
|
|
8487
|
-
var query = gl.createQuery();
|
|
8488
|
-
var getTime = /*#__PURE__*/ _async_to_generator(function() {
|
|
8489
|
-
return __generator(this, function(_state) {
|
|
8490
|
-
return [
|
|
8491
|
-
2,
|
|
8492
|
-
new Promise(function(resolve, reject) {
|
|
8493
|
-
if (query) {
|
|
8494
|
-
var available = gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE);
|
|
8495
|
-
var disjoint = gl.getParameter(ext.GPU_DISJOINT_EXT);
|
|
8496
|
-
if (available && !disjoint) {
|
|
8497
|
-
// See how much time the rendering of the object took in nanoseconds.
|
|
8498
|
-
var timeElapsed = gl.getQueryParameter(query, gl.QUERY_RESULT); // Do something useful with the time. Note that care should be
|
|
8499
|
-
// taken to use all significant bits of the result, not just the
|
|
8500
|
-
// least significant 32 bits.
|
|
8501
|
-
resolve(timeElapsed / 1000 / 1000);
|
|
8502
|
-
}
|
|
8503
|
-
if (available || disjoint) {
|
|
8504
|
-
// Clean up the query object.
|
|
8505
|
-
gl.deleteQuery(query); // Don't re-enter this polling loop.
|
|
8506
|
-
query = null;
|
|
8507
|
-
}
|
|
8508
|
-
available !== null && query && window.setTimeout(function() {
|
|
8509
|
-
getTime().then(resolve).catch;
|
|
8510
|
-
}, 1);
|
|
8511
|
-
}
|
|
8512
|
-
})
|
|
8513
|
-
];
|
|
8514
|
-
});
|
|
8515
|
-
});
|
|
8516
|
-
if (!query) {
|
|
8517
|
-
return;
|
|
8518
|
-
}
|
|
8519
|
-
return {
|
|
8520
|
-
begin: function() {
|
|
8521
|
-
query && gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
8522
|
-
},
|
|
8523
|
-
end: function() {
|
|
8524
|
-
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
8525
|
-
},
|
|
8526
|
-
getTime: getTime
|
|
8527
|
-
};
|
|
8528
|
-
}
|
|
8529
|
-
}
|
|
8530
|
-
|
|
8531
|
-
var initErrors = [];
|
|
8532
|
-
var glContext = {};
|
|
8533
|
-
var IOS16_LOCKDOWN_MODE = "iOS16 lockdown mode, WebGL Constants not in global";
|
|
8534
|
-
var WEBGL_CONSTANTS_NOT_IN_GLOBAL = "WebGL Constants not in global, please check your environment";
|
|
8535
|
-
if (!initErrors.length) {
|
|
8536
|
-
initGLContext();
|
|
8537
|
-
}
|
|
8538
|
-
function initGLContext() {
|
|
8539
|
-
// 重要:iOS 9/10 低版本需要拷贝 gl context 的 prototype,要不然会有属性值的缺失
|
|
8540
|
-
if (typeof WebGL2RenderingContext === "function") {
|
|
8541
|
-
copy(WebGL2RenderingContext);
|
|
8542
|
-
} else if (typeof WebGLRenderingContext !== "undefined") {
|
|
8543
|
-
copy(WebGLRenderingContext);
|
|
8544
|
-
copy(WebGLRenderingContext.prototype);
|
|
8545
|
-
} else {
|
|
8546
|
-
if (canUseBOM) {
|
|
8547
|
-
initErrors.push(// iOS 16 lockdown mode
|
|
8548
|
-
isIOS() ? IOS16_LOCKDOWN_MODE : WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
8549
|
-
} else {
|
|
8550
|
-
initErrors.push(WEBGL_CONSTANTS_NOT_IN_GLOBAL);
|
|
8551
|
-
}
|
|
8552
|
-
}
|
|
8553
|
-
if (!initErrors.length && !("HALF_FLOAT" in glContext)) {
|
|
8554
|
-
// @ts-expect-error set default value
|
|
8555
|
-
glContext["HALF_FLOAT"] = 5131;
|
|
8556
|
-
}
|
|
8557
|
-
}
|
|
8558
|
-
function isWebGL2(gl) {
|
|
8559
|
-
return typeof WebGL2RenderingContext !== "undefined" && gl.constructor.name === "WebGL2RenderingContext";
|
|
8560
|
-
}
|
|
8561
|
-
function copy(target) {
|
|
8562
|
-
for(var name in target){
|
|
8563
|
-
if (/^[A-Z_]/.test(name)) {
|
|
8564
|
-
// @ts-expect-error safe to assign
|
|
8565
|
-
glContext[name] = target[name];
|
|
8566
|
-
}
|
|
8567
|
-
}
|
|
8568
|
-
}
|
|
8569
|
-
function vertexFormatType2GLType(formatType) {
|
|
8570
|
-
switch(formatType){
|
|
8571
|
-
case VertexFormatType.Float32:
|
|
8572
|
-
return WebGLRenderingContext["FLOAT"];
|
|
8573
|
-
case VertexFormatType.Int16:
|
|
8574
|
-
return WebGLRenderingContext["SHORT"];
|
|
8575
|
-
case VertexFormatType.Int8:
|
|
8576
|
-
return WebGLRenderingContext["BYTE"];
|
|
8577
|
-
case VertexFormatType.UInt16:
|
|
8578
|
-
return WebGLRenderingContext["UNSIGNED_SHORT"];
|
|
8579
|
-
case VertexFormatType.UInt8:
|
|
8580
|
-
return WebGLRenderingContext["UNSIGNED_BYTE"];
|
|
8581
|
-
default:
|
|
8582
|
-
return WebGLRenderingContext["FLOAT"];
|
|
8583
|
-
}
|
|
8584
|
-
}
|
|
8585
|
-
function glType2VertexFormatType(webglType) {
|
|
8586
|
-
switch(webglType){
|
|
8587
|
-
case WebGLRenderingContext["FLOAT"]:
|
|
8588
|
-
return VertexFormatType.Float32;
|
|
8589
|
-
case WebGLRenderingContext["SHORT"]:
|
|
8590
|
-
return VertexFormatType.Int16;
|
|
8591
|
-
case WebGLRenderingContext["BYTE"]:
|
|
8592
|
-
return VertexFormatType.Int8;
|
|
8593
|
-
case WebGLRenderingContext["UNSIGNED_SHORT"]:
|
|
8594
|
-
return VertexFormatType.UInt16;
|
|
8595
|
-
case WebGLRenderingContext["UNSIGNED_BYTE"]:
|
|
8596
|
-
return VertexFormatType.UInt8;
|
|
8597
|
-
default:
|
|
8598
|
-
return VertexFormatType.Float32;
|
|
8599
|
-
}
|
|
8600
|
-
}
|
|
8601
|
-
|
|
8602
|
-
exports.ShaderType = void 0;
|
|
8603
|
-
(function(ShaderType) {
|
|
8604
|
-
ShaderType[ShaderType["vertex"] = 0] = "vertex";
|
|
8605
|
-
ShaderType[ShaderType["fragment"] = 1] = "fragment";
|
|
8606
|
-
})(exports.ShaderType || (exports.ShaderType = {}));
|
|
8607
|
-
exports.MaskMode = void 0;
|
|
8608
|
-
(function(MaskMode) {
|
|
8609
|
-
/**
|
|
8610
|
-
* 无
|
|
8611
|
-
*/ MaskMode[MaskMode["NONE"] = 0] = "NONE";
|
|
8612
|
-
/**
|
|
8613
|
-
* 蒙版
|
|
8614
|
-
*/ MaskMode[MaskMode["MASK"] = 1] = "MASK";
|
|
8615
|
-
/**
|
|
8616
|
-
* 被遮挡
|
|
8617
|
-
*/ MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
|
|
8618
|
-
/**
|
|
8619
|
-
* 被反向遮挡
|
|
8620
|
-
*/ MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
|
|
8621
|
-
})(exports.MaskMode || (exports.MaskMode = {}));
|
|
8622
|
-
|
|
8623
|
-
function valIfUndefined(val, def) {
|
|
8624
|
-
if (val === undefined || val === null) {
|
|
8625
|
-
return def;
|
|
8626
|
-
}
|
|
8627
|
-
return val;
|
|
8628
|
-
}
|
|
8629
|
-
function getPreMultiAlpha(blending) {
|
|
8630
|
-
switch(blending){
|
|
8631
|
-
case BlendingMode.ALPHA:
|
|
8632
|
-
return 1;
|
|
8633
|
-
case BlendingMode.ADD:
|
|
8634
|
-
return 1;
|
|
8635
|
-
case BlendingMode.SUBTRACTION:
|
|
8636
|
-
return 1;
|
|
8637
|
-
case BlendingMode.STRONG_LIGHT:
|
|
8638
|
-
return 1;
|
|
8639
|
-
case BlendingMode.WEAK_LIGHT:
|
|
8640
|
-
return 1;
|
|
8641
|
-
case BlendingMode.SUPERPOSITION:
|
|
8642
|
-
return 2;
|
|
8643
|
-
case BlendingMode.BRIGHTNESS:
|
|
8644
|
-
return 3;
|
|
8645
|
-
case BlendingMode.MULTIPLY:
|
|
8646
|
-
return 0;
|
|
8647
|
-
default:
|
|
8648
|
-
// 处理undefined
|
|
8649
|
-
return 1;
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
function setBlendMode(material, blendMode) {
|
|
8653
|
-
switch(blendMode){
|
|
8654
|
-
case undefined:
|
|
8655
|
-
material.blendFunction = [
|
|
8656
|
-
glContext.ONE,
|
|
8657
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8658
|
-
glContext.ONE,
|
|
8659
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8660
|
-
];
|
|
8661
|
-
break;
|
|
8662
|
-
case BlendingMode.ALPHA:
|
|
8663
|
-
material.blendFunction = [
|
|
8664
|
-
glContext.ONE,
|
|
8665
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8666
|
-
glContext.ONE,
|
|
8667
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8668
|
-
];
|
|
8669
|
-
break;
|
|
8670
|
-
case BlendingMode.ADD:
|
|
8671
|
-
material.blendFunction = [
|
|
8672
|
-
glContext.ONE,
|
|
8673
|
-
glContext.ONE,
|
|
8674
|
-
glContext.ONE,
|
|
8675
|
-
glContext.ONE
|
|
8676
|
-
];
|
|
8677
|
-
break;
|
|
8678
|
-
case BlendingMode.SUBTRACTION:
|
|
8679
|
-
material.blendFunction = [
|
|
8680
|
-
glContext.ONE,
|
|
8681
|
-
glContext.ONE,
|
|
8682
|
-
glContext.ZERO,
|
|
8683
|
-
glContext.ONE
|
|
8684
|
-
];
|
|
8685
|
-
material.blendEquation = [
|
|
8686
|
-
glContext.FUNC_REVERSE_SUBTRACT,
|
|
8687
|
-
glContext.FUNC_REVERSE_SUBTRACT
|
|
8688
|
-
];
|
|
8689
|
-
break;
|
|
8690
|
-
case BlendingMode.SUPERPOSITION:
|
|
8691
|
-
material.blendFunction = [
|
|
8692
|
-
glContext.ONE,
|
|
8693
|
-
glContext.ONE,
|
|
8694
|
-
glContext.ONE,
|
|
8695
|
-
glContext.ONE
|
|
8696
|
-
];
|
|
8697
|
-
break;
|
|
8698
|
-
case BlendingMode.MULTIPLY:
|
|
8699
|
-
material.blendFunction = [
|
|
8700
|
-
glContext.DST_COLOR,
|
|
8701
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8702
|
-
glContext.DST_COLOR,
|
|
8703
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8704
|
-
];
|
|
8705
|
-
break;
|
|
8706
|
-
case BlendingMode.BRIGHTNESS:
|
|
8707
|
-
material.blendFunction = [
|
|
8708
|
-
glContext.ONE,
|
|
8709
|
-
glContext.ONE_MINUS_SRC_ALPHA,
|
|
8710
|
-
glContext.ONE,
|
|
8711
|
-
glContext.ONE_MINUS_SRC_ALPHA
|
|
8712
|
-
];
|
|
8713
|
-
break;
|
|
8714
|
-
case BlendingMode.STRONG_LIGHT:
|
|
8715
|
-
material.blendFunction = [
|
|
8716
|
-
glContext.DST_COLOR,
|
|
8717
|
-
glContext.DST_ALPHA,
|
|
8718
|
-
glContext.ZERO,
|
|
8719
|
-
glContext.ONE
|
|
8720
|
-
];
|
|
8721
|
-
break;
|
|
8722
|
-
case BlendingMode.WEAK_LIGHT:
|
|
8723
|
-
material.blendFunction = [
|
|
8724
|
-
glContext.DST_COLOR,
|
|
8725
|
-
glContext.ZERO,
|
|
8726
|
-
glContext.ZERO,
|
|
8727
|
-
glContext.ONE
|
|
8728
|
-
];
|
|
8729
|
-
break;
|
|
8730
|
-
default:
|
|
8731
|
-
console.warn("BlendMode " + blendMode + " not in specification, please set blend params separately.");
|
|
8732
|
-
}
|
|
8733
|
-
}
|
|
8734
|
-
function setSideMode(material, side) {
|
|
8735
|
-
if (side === SideMode.DOUBLE) {
|
|
8736
|
-
material.culling = false;
|
|
8737
|
-
} else {
|
|
8738
|
-
material.culling = true;
|
|
8739
|
-
material.frontFace = glContext.CW;
|
|
8740
|
-
material.cullFace = side === SideMode.BACK ? glContext.BACK : glContext.FRONT;
|
|
8741
|
-
}
|
|
8742
|
-
}
|
|
8743
|
-
function setMaskMode(material, maskMode) {
|
|
8744
|
-
switch(maskMode){
|
|
8745
|
-
case undefined:
|
|
8746
|
-
material.stencilTest = false;
|
|
8747
|
-
break;
|
|
8748
|
-
case exports.MaskMode.MASK:
|
|
8749
|
-
material.stencilTest = true;
|
|
8750
|
-
material.stencilFunc = [
|
|
8751
|
-
glContext.ALWAYS,
|
|
8752
|
-
glContext.ALWAYS
|
|
8753
|
-
];
|
|
8754
|
-
material.stencilOpZPass = [
|
|
8755
|
-
glContext.REPLACE,
|
|
8756
|
-
glContext.REPLACE
|
|
8757
|
-
];
|
|
8758
|
-
break;
|
|
8759
|
-
case exports.MaskMode.OBSCURED:
|
|
8760
|
-
material.stencilTest = true;
|
|
8761
|
-
material.stencilFunc = [
|
|
8762
|
-
glContext.EQUAL,
|
|
8763
|
-
glContext.EQUAL
|
|
8764
|
-
];
|
|
8765
|
-
break;
|
|
8766
|
-
case exports.MaskMode.REVERSE_OBSCURED:
|
|
8767
|
-
material.stencilTest = true;
|
|
8768
|
-
material.stencilFunc = [
|
|
8769
|
-
glContext.NOTEQUAL,
|
|
8770
|
-
glContext.NOTEQUAL
|
|
8771
|
-
];
|
|
8772
|
-
break;
|
|
8773
|
-
case exports.MaskMode.NONE:
|
|
8774
|
-
material.stencilTest = false;
|
|
8775
|
-
break;
|
|
8776
|
-
default:
|
|
8777
|
-
console.warn("MaskMode " + maskMode + " not in specification, please set stencil params seperately.");
|
|
8778
|
-
}
|
|
8779
|
-
}
|
|
8780
|
-
|
|
8781
|
-
exports.TextureLoadAction = void 0;
|
|
8782
|
-
(function(TextureLoadAction) {
|
|
8783
|
-
TextureLoadAction[TextureLoadAction["whatever"] = 0] = "whatever";
|
|
8784
|
-
//preserve previous attachment
|
|
8785
|
-
//load = 1,
|
|
8786
|
-
//clear attachment
|
|
8787
|
-
TextureLoadAction[TextureLoadAction["clear"] = 2] = "clear";
|
|
8788
|
-
})(exports.TextureLoadAction || (exports.TextureLoadAction = {}));
|
|
8789
|
-
exports.TextureSourceType = void 0;
|
|
8790
|
-
(function(TextureSourceType) {
|
|
8791
|
-
TextureSourceType[TextureSourceType["none"] = 0] = "none";
|
|
8792
|
-
TextureSourceType[TextureSourceType["data"] = 1] = "data";
|
|
8793
|
-
TextureSourceType[TextureSourceType["image"] = 2] = "image";
|
|
8794
|
-
TextureSourceType[TextureSourceType["compressed"] = 3] = "compressed";
|
|
8795
|
-
TextureSourceType[TextureSourceType["video"] = 4] = "video";
|
|
8796
|
-
TextureSourceType[TextureSourceType["canvas"] = 5] = "canvas";
|
|
8797
|
-
TextureSourceType[TextureSourceType["framebuffer"] = 6] = "framebuffer";
|
|
8798
|
-
TextureSourceType[TextureSourceType["mipmaps"] = 7] = "mipmaps";
|
|
8799
|
-
})(exports.TextureSourceType || (exports.TextureSourceType = {}));
|
|
8800
|
-
|
|
8801
8867
|
/**
|
|
8802
8868
|
* 负责下载各种资源,并提供了一些异步加载和缓存管理的功能
|
|
8803
8869
|
*/ var Downloader = /*#__PURE__*/ function() {
|
|
@@ -10276,39 +10342,6 @@ exports.MaterialRenderType = void 0;
|
|
|
10276
10342
|
return Material;
|
|
10277
10343
|
}(EffectsObject);
|
|
10278
10344
|
|
|
10279
|
-
var MaskProcessor = /*#__PURE__*/ function() {
|
|
10280
|
-
function MaskProcessor(engine) {
|
|
10281
|
-
this.engine = engine;
|
|
10282
|
-
this.alphaMaskEnabled = false;
|
|
10283
|
-
this.maskMode = exports.MaskMode.NONE;
|
|
10284
|
-
this.maskable = null;
|
|
10285
|
-
this.stencilClearAction = {
|
|
10286
|
-
stencilAction: exports.TextureLoadAction.clear
|
|
10287
|
-
};
|
|
10288
|
-
}
|
|
10289
|
-
var _proto = MaskProcessor.prototype;
|
|
10290
|
-
_proto.getRefValue = function getRefValue() {
|
|
10291
|
-
return 1;
|
|
10292
|
-
};
|
|
10293
|
-
_proto.setMaskOptions = function setMaskOptions(data) {
|
|
10294
|
-
var _data_isMask = data.isMask, isMask = _data_isMask === void 0 ? false : _data_isMask, _data_inverted = data.inverted, inverted = _data_inverted === void 0 ? false : _data_inverted, reference = data.reference, _data_alphaMaskEnabled = data.alphaMaskEnabled, alphaMaskEnabled = _data_alphaMaskEnabled === void 0 ? false : _data_alphaMaskEnabled;
|
|
10295
|
-
this.alphaMaskEnabled = alphaMaskEnabled;
|
|
10296
|
-
if (isMask) {
|
|
10297
|
-
this.maskMode = exports.MaskMode.MASK;
|
|
10298
|
-
} else {
|
|
10299
|
-
this.maskMode = inverted ? exports.MaskMode.REVERSE_OBSCURED : exports.MaskMode.OBSCURED;
|
|
10300
|
-
this.maskable = this.engine.findObject(reference);
|
|
10301
|
-
}
|
|
10302
|
-
};
|
|
10303
|
-
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
10304
|
-
if (this.maskable) {
|
|
10305
|
-
renderer.clear(this.stencilClearAction);
|
|
10306
|
-
this.maskable.drawStencilMask(renderer);
|
|
10307
|
-
}
|
|
10308
|
-
};
|
|
10309
|
-
return MaskProcessor;
|
|
10310
|
-
}();
|
|
10311
|
-
|
|
10312
10345
|
var EFFECTS_COPY_MESH_NAME = "effects-internal-copy";
|
|
10313
10346
|
var COPY_MESH_SHADER_ID = "effects-internal-copy-mesh";
|
|
10314
10347
|
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}";
|
|
@@ -10621,6 +10654,9 @@ var DrawObjectPass = /*#__PURE__*/ function(RenderPass) {
|
|
|
10621
10654
|
stencilAction: exports.TextureLoadAction.clear
|
|
10622
10655
|
});
|
|
10623
10656
|
}
|
|
10657
|
+
this.meshes.sort(function(a, b) {
|
|
10658
|
+
return a.priority - b.priority;
|
|
10659
|
+
});
|
|
10624
10660
|
renderer.renderMeshes(this.meshes);
|
|
10625
10661
|
};
|
|
10626
10662
|
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
@@ -12722,244 +12758,131 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
12722
12758
|
return ShaderFactory;
|
|
12723
12759
|
}();
|
|
12724
12760
|
|
|
12725
|
-
// Bloom
|
|
12726
|
-
var
|
|
12727
|
-
_inherits(
|
|
12728
|
-
function
|
|
12761
|
+
// Bloom Pass - 包含阈值提取、高斯模糊(Down Sample 和 Up Sample)
|
|
12762
|
+
var BloomPass = /*#__PURE__*/ function(RenderPass) {
|
|
12763
|
+
_inherits(BloomPass, RenderPass);
|
|
12764
|
+
function BloomPass(renderer, iterationCount) {
|
|
12765
|
+
if (iterationCount === void 0) iterationCount = 4;
|
|
12729
12766
|
var _this;
|
|
12730
12767
|
_this = RenderPass.call(this, renderer) || this;
|
|
12768
|
+
_this.tempRTs = [];
|
|
12769
|
+
_this.iterationCount = iterationCount;
|
|
12731
12770
|
var engine = _this.renderer.engine;
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
attributes: {
|
|
12735
|
-
aPos: {
|
|
12736
|
-
type: glContext.FLOAT,
|
|
12737
|
-
size: 2,
|
|
12738
|
-
data: new Float32Array([
|
|
12739
|
-
-1,
|
|
12740
|
-
1,
|
|
12741
|
-
-1,
|
|
12742
|
-
-1,
|
|
12743
|
-
1,
|
|
12744
|
-
1,
|
|
12745
|
-
1,
|
|
12746
|
-
-1
|
|
12747
|
-
])
|
|
12748
|
-
}
|
|
12749
|
-
},
|
|
12750
|
-
drawCount: 4
|
|
12751
|
-
});
|
|
12752
|
-
var material = Material.create(engine, {
|
|
12771
|
+
// Threshold material
|
|
12772
|
+
_this.thresholdMaterial = Material.create(engine, {
|
|
12753
12773
|
shader: {
|
|
12754
12774
|
vertex: screenMeshVert,
|
|
12755
12775
|
fragment: thresholdFrag,
|
|
12756
12776
|
glslVersion: exports.GLSLVersion.GLSL1
|
|
12757
12777
|
}
|
|
12758
12778
|
});
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12779
|
+
_this.thresholdMaterial.blending = false;
|
|
12780
|
+
_this.thresholdMaterial.depthTest = false;
|
|
12781
|
+
_this.thresholdMaterial.culling = false;
|
|
12782
|
+
// Down sample H material
|
|
12783
|
+
_this.downSampleHMaterial = Material.create(engine, {
|
|
12784
|
+
shader: {
|
|
12785
|
+
vertex: screenMeshVert,
|
|
12786
|
+
fragment: gaussianDownHFrag,
|
|
12787
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12788
|
+
}
|
|
12766
12789
|
});
|
|
12790
|
+
_this.downSampleHMaterial.blending = false;
|
|
12791
|
+
_this.downSampleHMaterial.depthTest = false;
|
|
12792
|
+
_this.downSampleHMaterial.culling = false;
|
|
12793
|
+
// Down sample V material
|
|
12794
|
+
_this.downSampleVMaterial = Material.create(engine, {
|
|
12795
|
+
shader: {
|
|
12796
|
+
vertex: screenMeshVert,
|
|
12797
|
+
fragment: gaussianDownVFrag,
|
|
12798
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12799
|
+
}
|
|
12800
|
+
});
|
|
12801
|
+
_this.downSampleVMaterial.blending = false;
|
|
12802
|
+
_this.downSampleVMaterial.depthTest = false;
|
|
12803
|
+
_this.downSampleVMaterial.culling = false;
|
|
12804
|
+
// Up sample material
|
|
12805
|
+
_this.upSampleMaterial = Material.create(engine, {
|
|
12806
|
+
shader: {
|
|
12807
|
+
vertex: screenMeshVert,
|
|
12808
|
+
fragment: gaussianUpFrag,
|
|
12809
|
+
glslVersion: exports.GLSLVersion.GLSL1
|
|
12810
|
+
}
|
|
12811
|
+
});
|
|
12812
|
+
_this.upSampleMaterial.blending = false;
|
|
12813
|
+
_this.upSampleMaterial.depthTest = false;
|
|
12814
|
+
_this.upSampleMaterial.culling = false;
|
|
12767
12815
|
_this.priority = 5000;
|
|
12768
|
-
_this.name = "
|
|
12816
|
+
_this.name = "BloomPass";
|
|
12769
12817
|
return _this;
|
|
12770
12818
|
}
|
|
12771
|
-
var _proto =
|
|
12819
|
+
var _proto = BloomPass.prototype;
|
|
12772
12820
|
_proto.configure = function configure(renderer) {
|
|
12773
|
-
|
|
12821
|
+
// 获取场景纹理用于 ToneMappingPass
|
|
12774
12822
|
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
12775
12823
|
this.sceneTextureHandle.texture = this.mainTexture;
|
|
12776
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
12777
12824
|
};
|
|
12778
12825
|
_proto.execute = function execute(renderer) {
|
|
12779
12826
|
var _renderer_renderingData_currentFrame_globalVolume_bloom, _renderer_renderingData_currentFrame_globalVolume;
|
|
12780
|
-
renderer.
|
|
12781
|
-
|
|
12782
|
-
depthAction: exports.TextureLoadAction.clear,
|
|
12783
|
-
stencilAction: exports.TextureLoadAction.clear
|
|
12784
|
-
});
|
|
12785
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
12827
|
+
var baseWidth = renderer.getWidth();
|
|
12828
|
+
var baseHeight = renderer.getHeight();
|
|
12786
12829
|
var _renderer_renderingData_currentFrame_globalVolume_bloom_threshold;
|
|
12830
|
+
// 1. Threshold pass - 提取高亮区域
|
|
12787
12831
|
var threshold = (_renderer_renderingData_currentFrame_globalVolume_bloom_threshold = (_renderer_renderingData_currentFrame_globalVolume = renderer.renderingData.currentFrame.globalVolume) == null ? void 0 : (_renderer_renderingData_currentFrame_globalVolume_bloom = _renderer_renderingData_currentFrame_globalVolume.bloom) == null ? void 0 : _renderer_renderingData_currentFrame_globalVolume_bloom.threshold) != null ? _renderer_renderingData_currentFrame_globalVolume_bloom_threshold : 1.0;
|
|
12788
|
-
this.
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
]
|
|
12832
|
+
this.thresholdRT = renderer.getTemporaryRT("_BloomThreshold", baseWidth, baseHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12833
|
+
this.thresholdMaterial.setFloat("_Threshold", threshold);
|
|
12834
|
+
renderer.blit(this.mainTexture, this.thresholdRT, this.thresholdMaterial);
|
|
12835
|
+
var currentTexture = this.thresholdRT.getColorTextures()[0];
|
|
12836
|
+
// 2. Down sample passes
|
|
12837
|
+
for(var i = 0; i < this.iterationCount; i++){
|
|
12838
|
+
var downWidth = Math.floor(baseWidth / Math.pow(2, i + 1));
|
|
12839
|
+
var downHeight = Math.floor(baseHeight / Math.pow(2, i + 1));
|
|
12840
|
+
// Horizontal pass
|
|
12841
|
+
var tempH = renderer.getTemporaryRT("_BloomDownH" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12842
|
+
this.downSampleHMaterial.setVector2("_TextureSize", getTextureSize(currentTexture));
|
|
12843
|
+
renderer.blit(currentTexture, tempH, this.downSampleHMaterial);
|
|
12844
|
+
// Vertical pass
|
|
12845
|
+
var tempV = renderer.getTemporaryRT("_BloomDownV" + i, downWidth, downHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12846
|
+
this.downSampleVMaterial.setVector2("_TextureSize", getTextureSize(tempH.getColorTextures()[0]));
|
|
12847
|
+
renderer.blit(tempH.getColorTextures()[0], tempV, this.downSampleVMaterial);
|
|
12848
|
+
// 释放 H pass RT,保留 V pass RT 用于 up sample
|
|
12849
|
+
renderer.releaseTemporaryRT(tempH);
|
|
12850
|
+
this.tempRTs.push(tempV);
|
|
12851
|
+
currentTexture = tempV.getColorTextures()[0];
|
|
12852
|
+
}
|
|
12853
|
+
// 释放 threshold RT
|
|
12854
|
+
renderer.releaseTemporaryRT(this.thresholdRT);
|
|
12855
|
+
// 3. Up sample passes
|
|
12856
|
+
for(var i1 = this.iterationCount - 1; i1 > 0; i1--){
|
|
12857
|
+
var upWidth = Math.floor(baseWidth / Math.pow(2, i1 - 1));
|
|
12858
|
+
var upHeight = Math.floor(baseHeight / Math.pow(2, i1 - 1));
|
|
12859
|
+
var tempUp = renderer.getTemporaryRT("_BloomUp" + i1, upWidth, upHeight, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12860
|
+
// 获取下一层的 down sample 结果
|
|
12861
|
+
var downSampleTexture = this.tempRTs[i1 - 1].getColorTextures()[0];
|
|
12862
|
+
this.upSampleMaterial.setTexture("_GaussianDownTex", downSampleTexture);
|
|
12863
|
+
this.upSampleMaterial.setVector2("_GaussianDownTextureSize", getTextureSize(downSampleTexture));
|
|
12864
|
+
renderer.blit(currentTexture, tempUp, this.upSampleMaterial);
|
|
12865
|
+
currentTexture = tempUp.getColorTextures()[0];
|
|
12866
|
+
this.tempRTs.push(tempUp);
|
|
12867
|
+
}
|
|
12868
|
+
// 设置最终输出到当前 framebuffer
|
|
12869
|
+
renderer.setFramebuffer(this.tempRTs[this.tempRTs.length - 1]);
|
|
12792
12870
|
};
|
|
12793
12871
|
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12794
|
-
|
|
12795
|
-
|
|
12872
|
+
// 释放所有临时 RT
|
|
12873
|
+
for(var i = 0; i < this.tempRTs.length; i++){
|
|
12874
|
+
renderer.releaseTemporaryRT(this.tempRTs[i]);
|
|
12796
12875
|
}
|
|
12876
|
+
this.tempRTs = [];
|
|
12797
12877
|
};
|
|
12798
12878
|
_proto.dispose = function dispose(options) {
|
|
12879
|
+
this.thresholdMaterial.dispose();
|
|
12880
|
+
this.downSampleHMaterial.dispose();
|
|
12881
|
+
this.downSampleVMaterial.dispose();
|
|
12882
|
+
this.upSampleMaterial.dispose();
|
|
12799
12883
|
RenderPass.prototype.dispose.call(this, options);
|
|
12800
12884
|
};
|
|
12801
|
-
return
|
|
12802
|
-
}(RenderPass);
|
|
12803
|
-
var HQGaussianDownSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
12804
|
-
_inherits(HQGaussianDownSamplePass, RenderPass);
|
|
12805
|
-
function HQGaussianDownSamplePass(renderer, type, level) {
|
|
12806
|
-
var _this;
|
|
12807
|
-
_this = RenderPass.call(this, renderer) || this;
|
|
12808
|
-
_this.type = type;
|
|
12809
|
-
_this.level = level;
|
|
12810
|
-
var engine = _this.renderer.engine;
|
|
12811
|
-
var name = "PostProcess";
|
|
12812
|
-
var geometry = Geometry.create(engine, {
|
|
12813
|
-
name: name,
|
|
12814
|
-
mode: glContext.TRIANGLE_STRIP,
|
|
12815
|
-
attributes: {
|
|
12816
|
-
aPos: {
|
|
12817
|
-
type: glContext.FLOAT,
|
|
12818
|
-
size: 2,
|
|
12819
|
-
data: new Float32Array([
|
|
12820
|
-
-1,
|
|
12821
|
-
1,
|
|
12822
|
-
-1,
|
|
12823
|
-
-1,
|
|
12824
|
-
1,
|
|
12825
|
-
1,
|
|
12826
|
-
1,
|
|
12827
|
-
-1
|
|
12828
|
-
])
|
|
12829
|
-
}
|
|
12830
|
-
},
|
|
12831
|
-
drawCount: 4
|
|
12832
|
-
});
|
|
12833
|
-
var fragment = type === "H" ? gaussianDownHFrag : gaussianDownVFrag;
|
|
12834
|
-
var shader = {
|
|
12835
|
-
vertex: screenMeshVert,
|
|
12836
|
-
fragment: fragment,
|
|
12837
|
-
glslVersion: exports.GLSLVersion.GLSL1
|
|
12838
|
-
};
|
|
12839
|
-
var material = Material.create(engine, {
|
|
12840
|
-
name: name,
|
|
12841
|
-
shader: shader
|
|
12842
|
-
});
|
|
12843
|
-
material.blending = false;
|
|
12844
|
-
material.depthTest = false;
|
|
12845
|
-
material.culling = false;
|
|
12846
|
-
_this.screenMesh = Mesh.create(engine, {
|
|
12847
|
-
name: name,
|
|
12848
|
-
geometry: geometry,
|
|
12849
|
-
material: material,
|
|
12850
|
-
priority: 0
|
|
12851
|
-
});
|
|
12852
|
-
_this.priority = 5000;
|
|
12853
|
-
_this.name = "GaussianDownPass" + type + level;
|
|
12854
|
-
return _this;
|
|
12855
|
-
}
|
|
12856
|
-
var _proto = HQGaussianDownSamplePass.prototype;
|
|
12857
|
-
_proto.configure = function configure(renderer) {
|
|
12858
|
-
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level + 1));
|
|
12859
|
-
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level + 1));
|
|
12860
|
-
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12861
|
-
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
12862
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
12863
|
-
};
|
|
12864
|
-
_proto.execute = function execute(renderer) {
|
|
12865
|
-
renderer.clear({
|
|
12866
|
-
colorAction: exports.TextureLoadAction.clear,
|
|
12867
|
-
depthAction: exports.TextureLoadAction.clear,
|
|
12868
|
-
stencilAction: exports.TextureLoadAction.clear
|
|
12869
|
-
});
|
|
12870
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
12871
|
-
this.screenMesh.material.setVector2("_TextureSize", getTextureSize(this.mainTexture));
|
|
12872
|
-
renderer.renderMeshes([
|
|
12873
|
-
this.screenMesh
|
|
12874
|
-
]);
|
|
12875
|
-
if (this.type === "V") {
|
|
12876
|
-
this.gaussianResult.texture = renderer.getFramebuffer().getColorTextures()[0];
|
|
12877
|
-
}
|
|
12878
|
-
};
|
|
12879
|
-
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12880
|
-
if (this.framebuffer) {
|
|
12881
|
-
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12882
|
-
}
|
|
12883
|
-
};
|
|
12884
|
-
return HQGaussianDownSamplePass;
|
|
12885
|
-
}(RenderPass);
|
|
12886
|
-
var HQGaussianUpSamplePass = /*#__PURE__*/ function(RenderPass) {
|
|
12887
|
-
_inherits(HQGaussianUpSamplePass, RenderPass);
|
|
12888
|
-
function HQGaussianUpSamplePass(renderer, level) {
|
|
12889
|
-
var _this;
|
|
12890
|
-
_this = RenderPass.call(this, renderer) || this;
|
|
12891
|
-
_this.level = level;
|
|
12892
|
-
var name = "PostProcess";
|
|
12893
|
-
var engine = _this.renderer.engine;
|
|
12894
|
-
var geometry = Geometry.create(engine, {
|
|
12895
|
-
name: name,
|
|
12896
|
-
mode: glContext.TRIANGLE_STRIP,
|
|
12897
|
-
attributes: {
|
|
12898
|
-
aPos: {
|
|
12899
|
-
type: glContext.FLOAT,
|
|
12900
|
-
size: 2,
|
|
12901
|
-
data: new Float32Array([
|
|
12902
|
-
-1,
|
|
12903
|
-
1,
|
|
12904
|
-
-1,
|
|
12905
|
-
-1,
|
|
12906
|
-
1,
|
|
12907
|
-
1,
|
|
12908
|
-
1,
|
|
12909
|
-
-1
|
|
12910
|
-
])
|
|
12911
|
-
}
|
|
12912
|
-
},
|
|
12913
|
-
drawCount: 4
|
|
12914
|
-
});
|
|
12915
|
-
var shader = {
|
|
12916
|
-
vertex: screenMeshVert,
|
|
12917
|
-
fragment: gaussianUpFrag
|
|
12918
|
-
};
|
|
12919
|
-
var material = Material.create(engine, {
|
|
12920
|
-
name: name,
|
|
12921
|
-
shader: shader
|
|
12922
|
-
});
|
|
12923
|
-
material.blending = false;
|
|
12924
|
-
material.depthTest = false;
|
|
12925
|
-
material.culling = false;
|
|
12926
|
-
_this.screenMesh = Mesh.create(engine, {
|
|
12927
|
-
name: name,
|
|
12928
|
-
geometry: geometry,
|
|
12929
|
-
material: material,
|
|
12930
|
-
priority: 0
|
|
12931
|
-
});
|
|
12932
|
-
_this.priority = 5000;
|
|
12933
|
-
_this.name = "GaussianUpPass" + level;
|
|
12934
|
-
return _this;
|
|
12935
|
-
}
|
|
12936
|
-
var _proto = HQGaussianUpSamplePass.prototype;
|
|
12937
|
-
_proto.configure = function configure(renderer) {
|
|
12938
|
-
var width = Math.floor(this.renderer.getWidth() / Math.pow(2, this.level - 1));
|
|
12939
|
-
var height = Math.floor(this.renderer.getHeight() / Math.pow(2, this.level - 1));
|
|
12940
|
-
this.framebuffer = renderer.getTemporaryRT(this.name, width, height, 0, exports.FilterMode.Linear, exports.RenderTextureFormat.RGBAHalf);
|
|
12941
|
-
this.mainTexture = renderer.getFramebuffer().getColorTextures()[0];
|
|
12942
|
-
renderer.setFramebuffer(this.framebuffer);
|
|
12943
|
-
};
|
|
12944
|
-
_proto.execute = function execute(renderer) {
|
|
12945
|
-
renderer.clear({
|
|
12946
|
-
colorAction: exports.TextureLoadAction.clear,
|
|
12947
|
-
depthAction: exports.TextureLoadAction.clear,
|
|
12948
|
-
stencilAction: exports.TextureLoadAction.clear
|
|
12949
|
-
});
|
|
12950
|
-
this.screenMesh.material.setTexture("_MainTex", this.mainTexture);
|
|
12951
|
-
this.screenMesh.material.setTexture("_GaussianDownTex", this.gaussianDownSampleResult.texture);
|
|
12952
|
-
this.screenMesh.material.setVector2("_GaussianDownTextureSize", getTextureSize(this.gaussianDownSampleResult.texture));
|
|
12953
|
-
renderer.renderMeshes([
|
|
12954
|
-
this.screenMesh
|
|
12955
|
-
]);
|
|
12956
|
-
};
|
|
12957
|
-
_proto.onCameraCleanup = function onCameraCleanup(renderer) {
|
|
12958
|
-
if (this.framebuffer) {
|
|
12959
|
-
renderer.releaseTemporaryRT(this.framebuffer);
|
|
12960
|
-
}
|
|
12961
|
-
};
|
|
12962
|
-
return HQGaussianUpSamplePass;
|
|
12885
|
+
return BloomPass;
|
|
12963
12886
|
}(RenderPass);
|
|
12964
12887
|
// 合并Bloom的高斯模糊结果,并应用ACES Tonemapping
|
|
12965
12888
|
var ToneMappingPass = /*#__PURE__*/ function(RenderPass) {
|
|
@@ -13103,36 +13026,11 @@ var seed$5 = 1;
|
|
|
13103
13026
|
if (postProcessingEnabled) {
|
|
13104
13027
|
var sceneTextureHandle = new RenderTargetHandle(engine); //保存后处理前的屏幕图像
|
|
13105
13028
|
var gaussianStep = 7; // 高斯模糊的迭代次数,次数越高模糊范围越大
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
];
|
|
13112
|
-
var gaussianDownResults = new Array(gaussianStep); //存放多个高斯Pass的模糊结果,用于Bloom
|
|
13113
|
-
var bloomThresholdPass = new BloomThresholdPass(renderer);
|
|
13114
|
-
bloomThresholdPass.sceneTextureHandle = sceneTextureHandle;
|
|
13115
|
-
this.addRenderPass(bloomThresholdPass);
|
|
13116
|
-
for(var i = 0; i < gaussianStep; i++){
|
|
13117
|
-
gaussianDownResults[i] = new RenderTargetHandle(engine);
|
|
13118
|
-
var gaussianDownHPass = new HQGaussianDownSamplePass(renderer, "H", i);
|
|
13119
|
-
var gaussianDownVPass = new HQGaussianDownSamplePass(renderer, "V", i);
|
|
13120
|
-
gaussianDownVPass.gaussianResult = gaussianDownResults[i];
|
|
13121
|
-
this.addRenderPass(gaussianDownHPass);
|
|
13122
|
-
this.addRenderPass(gaussianDownVPass);
|
|
13123
|
-
viewport[2] /= 2;
|
|
13124
|
-
viewport[3] /= 2;
|
|
13125
|
-
// TODO 限制最大迭代
|
|
13126
|
-
}
|
|
13127
|
-
viewport[2] *= 4;
|
|
13128
|
-
viewport[3] *= 4;
|
|
13129
|
-
for(var i1 = 0; i1 < gaussianStep - 1; i1++){
|
|
13130
|
-
var gaussianUpPass = new HQGaussianUpSamplePass(renderer, gaussianStep - i1);
|
|
13131
|
-
gaussianUpPass.gaussianDownSampleResult = gaussianDownResults[gaussianStep - 2 - i1];
|
|
13132
|
-
this.addRenderPass(gaussianUpPass);
|
|
13133
|
-
viewport[2] *= 2;
|
|
13134
|
-
viewport[3] *= 2;
|
|
13135
|
-
}
|
|
13029
|
+
// Bloom Pass(包含阈值提取、高斯模糊)
|
|
13030
|
+
var bloomPass = new BloomPass(renderer, gaussianStep);
|
|
13031
|
+
bloomPass.sceneTextureHandle = sceneTextureHandle;
|
|
13032
|
+
this.addRenderPass(bloomPass);
|
|
13033
|
+
// Tone Mapping Pass
|
|
13136
13034
|
var postProcessPass = new ToneMappingPass(renderer, sceneTextureHandle);
|
|
13137
13035
|
this.addRenderPass(postProcessPass);
|
|
13138
13036
|
}
|
|
@@ -13626,6 +13524,14 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
13626
13524
|
_proto.releaseTemporaryRT = function releaseTemporaryRT(rt) {
|
|
13627
13525
|
this.renderTargetPool.release(rt);
|
|
13628
13526
|
};
|
|
13527
|
+
/**
|
|
13528
|
+
* 将源纹理复制到目标 Framebuffer,可使用自定义材质进行处理
|
|
13529
|
+
* @param source - 源纹理
|
|
13530
|
+
* @param destination - 目标 Framebuffer,如果为 null 则渲染到屏幕
|
|
13531
|
+
* @param material - 可选的自定义材质,不传则使用默认复制材质
|
|
13532
|
+
*/ _proto.blit = function blit(source, destination, material) {
|
|
13533
|
+
// OVERRIDE
|
|
13534
|
+
};
|
|
13629
13535
|
_proto.dispose = function dispose() {
|
|
13630
13536
|
// OVERRIDE
|
|
13631
13537
|
};
|
|
@@ -16688,13 +16594,49 @@ exports.CameraController = __decorate([
|
|
|
16688
16594
|
effectsClass(DataType.CameraController)
|
|
16689
16595
|
], exports.CameraController);
|
|
16690
16596
|
|
|
16691
|
-
|
|
16692
|
-
|
|
16597
|
+
function _get_prototype_of(o) {
|
|
16598
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
16599
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
16600
|
+
};
|
|
16601
|
+
return _get_prototype_of(o);
|
|
16602
|
+
}
|
|
16603
|
+
|
|
16604
|
+
function _is_native_function(fn) {
|
|
16605
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
16606
|
+
}
|
|
16607
|
+
|
|
16608
|
+
function _wrap_native_super(Class) {
|
|
16609
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
16610
|
+
_wrap_native_super = function _wrap_native_super(Class) {
|
|
16611
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
16612
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
16613
|
+
if (typeof _cache !== "undefined") {
|
|
16614
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
16615
|
+
_cache.set(Class, Wrapper);
|
|
16616
|
+
}
|
|
16617
|
+
function Wrapper() {
|
|
16618
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
16619
|
+
}
|
|
16620
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
16621
|
+
constructor: {
|
|
16622
|
+
value: Wrapper,
|
|
16623
|
+
enumerable: false,
|
|
16624
|
+
writable: true,
|
|
16625
|
+
configurable: true
|
|
16626
|
+
}
|
|
16627
|
+
});
|
|
16628
|
+
return _set_prototype_of(Wrapper, Class);
|
|
16629
|
+
};
|
|
16630
|
+
return _wrap_native_super(Class);
|
|
16631
|
+
}
|
|
16632
|
+
|
|
16633
|
+
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
16634
|
+
_inherits(CameraVFXItemLoader, Plugin);
|
|
16693
16635
|
function CameraVFXItemLoader() {
|
|
16694
|
-
return
|
|
16636
|
+
return Plugin.apply(this, arguments);
|
|
16695
16637
|
}
|
|
16696
16638
|
return CameraVFXItemLoader;
|
|
16697
|
-
}(
|
|
16639
|
+
}(_wrap_native_super(Plugin));
|
|
16698
16640
|
|
|
16699
16641
|
exports.HitTestType = void 0;
|
|
16700
16642
|
(function(HitTestType) {
|
|
@@ -16978,13 +16920,13 @@ function getCoord(event) {
|
|
|
16978
16920
|
};
|
|
16979
16921
|
}
|
|
16980
16922
|
|
|
16981
|
-
var InteractLoader = /*#__PURE__*/ function(
|
|
16982
|
-
_inherits(InteractLoader,
|
|
16923
|
+
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
16924
|
+
_inherits(InteractLoader, Plugin);
|
|
16983
16925
|
function InteractLoader() {
|
|
16984
|
-
return
|
|
16926
|
+
return Plugin.apply(this, arguments);
|
|
16985
16927
|
}
|
|
16986
16928
|
return InteractLoader;
|
|
16987
|
-
}(
|
|
16929
|
+
}(_wrap_native_super(Plugin));
|
|
16988
16930
|
|
|
16989
16931
|
var vertex = "\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n}\n";
|
|
16990
16932
|
var fragment = "\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n";
|
|
@@ -17583,16 +17525,16 @@ function shouldIgnoreBouncing(arg, mul) {
|
|
|
17583
17525
|
return MeshCollider;
|
|
17584
17526
|
}();
|
|
17585
17527
|
|
|
17586
|
-
var SpriteLoader = /*#__PURE__*/ function(
|
|
17587
|
-
_inherits(SpriteLoader,
|
|
17528
|
+
var SpriteLoader = /*#__PURE__*/ function(Plugin) {
|
|
17529
|
+
_inherits(SpriteLoader, Plugin);
|
|
17588
17530
|
function SpriteLoader() {
|
|
17589
17531
|
var _this;
|
|
17590
|
-
_this =
|
|
17532
|
+
_this = Plugin.apply(this, arguments) || this;
|
|
17591
17533
|
_this.name = "sprite";
|
|
17592
17534
|
return _this;
|
|
17593
17535
|
}
|
|
17594
17536
|
return SpriteLoader;
|
|
17595
|
-
}(
|
|
17537
|
+
}(_wrap_native_super(Plugin));
|
|
17596
17538
|
|
|
17597
17539
|
/**
|
|
17598
17540
|
* 动画图可播放节点对象
|
|
@@ -20083,7 +20025,7 @@ function calculateDirection(prePoint, point, nextPoint) {
|
|
|
20083
20025
|
if (this.time >= 0 && this.time < particleSystem.item.duration && particleSystem.isEnded()) {
|
|
20084
20026
|
particleSystem.reset();
|
|
20085
20027
|
}
|
|
20086
|
-
particleSystem.
|
|
20028
|
+
particleSystem.simulate(this.time - particleSystem.time);
|
|
20087
20029
|
}
|
|
20088
20030
|
this.lastTime = this.time;
|
|
20089
20031
|
};
|
|
@@ -21534,126 +21476,133 @@ exports.ParticleSystem = /*#__PURE__*/ function(Component) {
|
|
|
21534
21476
|
this.initEmitterTransform();
|
|
21535
21477
|
};
|
|
21536
21478
|
_proto.onUpdate = function onUpdate(dt) {
|
|
21537
|
-
this.
|
|
21479
|
+
if (!this.frozen) {
|
|
21480
|
+
this.update(dt);
|
|
21481
|
+
}
|
|
21482
|
+
};
|
|
21483
|
+
_proto.simulate = function simulate(time) {
|
|
21484
|
+
this.update(time * 1000);
|
|
21485
|
+
this.frozen = true;
|
|
21538
21486
|
};
|
|
21539
21487
|
_proto.update = function update(delta) {
|
|
21540
21488
|
var _this = this;
|
|
21541
|
-
if (this.started
|
|
21542
|
-
|
|
21543
|
-
|
|
21544
|
-
|
|
21545
|
-
|
|
21546
|
-
|
|
21547
|
-
|
|
21548
|
-
|
|
21549
|
-
|
|
21550
|
-
|
|
21551
|
-
|
|
21552
|
-
|
|
21553
|
-
|
|
21554
|
-
|
|
21555
|
-
|
|
21556
|
-
|
|
21557
|
-
|
|
21558
|
-
|
|
21559
|
-
|
|
21560
|
-
|
|
21561
|
-
|
|
21562
|
-
|
|
21563
|
-
|
|
21489
|
+
if (!this.started) {
|
|
21490
|
+
return;
|
|
21491
|
+
}
|
|
21492
|
+
var now = this.time + delta / 1000;
|
|
21493
|
+
var options = this.options;
|
|
21494
|
+
var loopStartTime = this.loopStartTime;
|
|
21495
|
+
var emission = this.emission;
|
|
21496
|
+
this.time = now;
|
|
21497
|
+
this.upDirectionWorld = null;
|
|
21498
|
+
this.renderer.updateTime(now, delta);
|
|
21499
|
+
var link = this.particleLink;
|
|
21500
|
+
var emitterLifetime = (now - loopStartTime) / this.item.duration;
|
|
21501
|
+
var timePassed = this.timePassed;
|
|
21502
|
+
var trailUpdated = false;
|
|
21503
|
+
var updateTrail = function() {
|
|
21504
|
+
if (_this.trails && !trailUpdated) {
|
|
21505
|
+
trailUpdated = true;
|
|
21506
|
+
link.forEach(function(param) {
|
|
21507
|
+
var time = param[0], pointIndex = param[1], delay = param[2], point = param[3];
|
|
21508
|
+
if (time < timePassed) {
|
|
21509
|
+
_this.clearPointTrail(pointIndex);
|
|
21510
|
+
} else if (timePassed > delay) {
|
|
21511
|
+
_this.updatePointTrail(pointIndex, emitterLifetime, point, delay);
|
|
21512
|
+
}
|
|
21513
|
+
});
|
|
21514
|
+
}
|
|
21515
|
+
};
|
|
21516
|
+
if (!this.ended) {
|
|
21517
|
+
var duration = this.item.duration;
|
|
21518
|
+
var lifetime = this.lifetime;
|
|
21519
|
+
if (timePassed < duration) {
|
|
21520
|
+
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21521
|
+
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21522
|
+
var maxEmissionCount = pointCount;
|
|
21523
|
+
var timeDelta = interval / pointCount;
|
|
21524
|
+
var meshTime = now;
|
|
21525
|
+
var maxCount = options.maxCount;
|
|
21526
|
+
this.updateEmitterTransform(timePassed);
|
|
21527
|
+
var shouldSkipGenerate = function() {
|
|
21528
|
+
var first = link.first;
|
|
21529
|
+
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21530
|
+
};
|
|
21531
|
+
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21532
|
+
if (shouldSkipGenerate()) {
|
|
21533
|
+
break;
|
|
21534
|
+
}
|
|
21535
|
+
var p = this.createPoint(lifetime);
|
|
21536
|
+
p.delay += meshTime + i * timeDelta;
|
|
21537
|
+
this.addParticle(p, maxCount);
|
|
21538
|
+
this.lastEmitTime = timePassed;
|
|
21564
21539
|
}
|
|
21565
|
-
|
|
21566
|
-
|
|
21567
|
-
|
|
21568
|
-
|
|
21569
|
-
if (timePassed < duration) {
|
|
21570
|
-
var interval = 1 / emission.rateOverTime.getValue(lifetime);
|
|
21571
|
-
var pointCount = Math.floor((timePassed - this.lastEmitTime) / interval);
|
|
21572
|
-
var maxEmissionCount = pointCount;
|
|
21573
|
-
var timeDelta = interval / pointCount;
|
|
21574
|
-
var meshTime = now;
|
|
21575
|
-
var maxCount = options.maxCount;
|
|
21576
|
-
this.updateEmitterTransform(timePassed);
|
|
21577
|
-
var shouldSkipGenerate = function() {
|
|
21578
|
-
var first = link.first;
|
|
21579
|
-
return _this.emissionStopped || link.length === maxCount && first && first.content[0] - loopStartTime > timePassed;
|
|
21580
|
-
};
|
|
21581
|
-
for(var i = 0; i < maxEmissionCount && i < maxCount; i++){
|
|
21582
|
-
if (shouldSkipGenerate()) {
|
|
21583
|
-
break;
|
|
21584
|
-
}
|
|
21585
|
-
var p = this.createPoint(lifetime);
|
|
21586
|
-
p.delay += meshTime + i * timeDelta;
|
|
21587
|
-
this.addParticle(p, maxCount);
|
|
21588
|
-
this.lastEmitTime = timePassed;
|
|
21540
|
+
var bursts = emission.bursts;
|
|
21541
|
+
for(var j = (bursts == null ? void 0 : bursts.length) - 1, cursor = 0; j >= 0 && cursor < maxCount; j--){
|
|
21542
|
+
if (shouldSkipGenerate()) {
|
|
21543
|
+
break;
|
|
21589
21544
|
}
|
|
21590
|
-
var
|
|
21591
|
-
|
|
21592
|
-
|
|
21593
|
-
|
|
21545
|
+
var burst = bursts[j];
|
|
21546
|
+
var opts = !burst.disabled && burst.getGeneratorOptions(timePassed, lifetime);
|
|
21547
|
+
if (opts) {
|
|
21548
|
+
var originVec = [
|
|
21549
|
+
0,
|
|
21550
|
+
0,
|
|
21551
|
+
0
|
|
21552
|
+
];
|
|
21553
|
+
var offsets = emission.burstOffsets[j];
|
|
21554
|
+
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21555
|
+
if (burst.once) {
|
|
21556
|
+
this.removeBurst(j);
|
|
21594
21557
|
}
|
|
21595
|
-
var
|
|
21596
|
-
|
|
21597
|
-
|
|
21598
|
-
|
|
21599
|
-
0,
|
|
21600
|
-
0,
|
|
21601
|
-
0
|
|
21602
|
-
];
|
|
21603
|
-
var offsets = emission.burstOffsets[j];
|
|
21604
|
-
var burstOffset = offsets && offsets[opts.cycleIndex] || originVec;
|
|
21605
|
-
if (burst.once) {
|
|
21606
|
-
this.removeBurst(j);
|
|
21607
|
-
}
|
|
21608
|
-
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21609
|
-
var _p_transform;
|
|
21610
|
-
if (shouldSkipGenerate()) {
|
|
21611
|
-
break;
|
|
21612
|
-
}
|
|
21613
|
-
var p1 = this.initPoint(this.shape.generate({
|
|
21614
|
-
total: opts.total,
|
|
21615
|
-
index: opts.index,
|
|
21616
|
-
burstIndex: i1,
|
|
21617
|
-
burstCount: opts.count
|
|
21618
|
-
}));
|
|
21619
|
-
p1.delay += meshTime;
|
|
21620
|
-
cursor++;
|
|
21621
|
-
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21622
|
-
this.addParticle(p1, maxCount);
|
|
21558
|
+
for(var i1 = 0; i1 < opts.count && cursor < maxCount; i1++){
|
|
21559
|
+
var _p_transform;
|
|
21560
|
+
if (shouldSkipGenerate()) {
|
|
21561
|
+
break;
|
|
21623
21562
|
}
|
|
21563
|
+
var p1 = this.initPoint(this.shape.generate({
|
|
21564
|
+
total: opts.total,
|
|
21565
|
+
index: opts.index,
|
|
21566
|
+
burstIndex: i1,
|
|
21567
|
+
burstCount: opts.count
|
|
21568
|
+
}));
|
|
21569
|
+
p1.delay += meshTime;
|
|
21570
|
+
cursor++;
|
|
21571
|
+
(_p_transform = p1.transform).translate.apply(_p_transform, [].concat(burstOffset));
|
|
21572
|
+
this.addParticle(p1, maxCount);
|
|
21624
21573
|
}
|
|
21625
21574
|
}
|
|
21626
|
-
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21627
|
-
updateTrail();
|
|
21628
|
-
this.loopStartTime = now - duration;
|
|
21629
|
-
this.lastEmitTime -= duration;
|
|
21630
|
-
this.time -= duration;
|
|
21631
|
-
emission.bursts.forEach(function(b) {
|
|
21632
|
-
return b.reset();
|
|
21633
|
-
});
|
|
21634
|
-
this.particleLink.forEach(function(content) {
|
|
21635
|
-
content[0] -= duration;
|
|
21636
|
-
content[2] -= duration;
|
|
21637
|
-
content[3].delay -= duration;
|
|
21638
|
-
});
|
|
21639
|
-
this.renderer.minusTimeForLoop(duration);
|
|
21640
|
-
} else {
|
|
21641
|
-
this.ended = true;
|
|
21642
|
-
var endBehavior = this.item.endBehavior;
|
|
21643
|
-
if (endBehavior === EndBehavior.freeze) {
|
|
21644
|
-
this.frozen = true;
|
|
21645
|
-
}
|
|
21646
21575
|
}
|
|
21647
|
-
} else if (this.item.endBehavior
|
|
21648
|
-
|
|
21649
|
-
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21576
|
+
} else if (this.item.endBehavior === EndBehavior.restart) {
|
|
21577
|
+
updateTrail();
|
|
21578
|
+
this.loopStartTime = now - duration;
|
|
21579
|
+
this.lastEmitTime -= duration;
|
|
21580
|
+
this.time -= duration;
|
|
21581
|
+
emission.bursts.forEach(function(b) {
|
|
21582
|
+
return b.reset();
|
|
21583
|
+
});
|
|
21584
|
+
this.particleLink.forEach(function(content) {
|
|
21585
|
+
content[0] -= duration;
|
|
21586
|
+
content[2] -= duration;
|
|
21587
|
+
content[3].delay -= duration;
|
|
21588
|
+
});
|
|
21589
|
+
this.renderer.minusTimeForLoop(duration);
|
|
21590
|
+
} else {
|
|
21591
|
+
this.ended = true;
|
|
21592
|
+
var endBehavior = this.item.endBehavior;
|
|
21593
|
+
if (endBehavior === EndBehavior.freeze) {
|
|
21594
|
+
this.frozen = true;
|
|
21595
|
+
}
|
|
21596
|
+
}
|
|
21597
|
+
} else if (this.item.endBehavior !== EndBehavior.restart) {
|
|
21598
|
+
if (EndBehavior.destroy === this.item.endBehavior) {
|
|
21599
|
+
var node = link.last;
|
|
21600
|
+
if (node && node.content[0] < this.time) {
|
|
21601
|
+
this.destroyed = true;
|
|
21653
21602
|
}
|
|
21654
21603
|
}
|
|
21655
|
-
updateTrail();
|
|
21656
21604
|
}
|
|
21605
|
+
updateTrail();
|
|
21657
21606
|
};
|
|
21658
21607
|
_proto.drawStencilMask = function drawStencilMask(renderer) {
|
|
21659
21608
|
if (!this.isActiveAndEnabled) {
|
|
@@ -25693,7 +25642,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25693
25642
|
_this = MaskableGraphic.call(this, engine) || this;
|
|
25694
25643
|
_this.time = 0;
|
|
25695
25644
|
_this.duration = 1;
|
|
25696
|
-
_this.loop = true;
|
|
25697
25645
|
/**
|
|
25698
25646
|
* @internal
|
|
25699
25647
|
*/ _this.splits = singleSplits;
|
|
@@ -25708,11 +25656,15 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25708
25656
|
var _this = this;
|
|
25709
25657
|
var time = this.time;
|
|
25710
25658
|
var duration = this.duration;
|
|
25711
|
-
|
|
25659
|
+
var textureAnimation = this.textureSheetAnimation;
|
|
25660
|
+
var _textureAnimation_loop;
|
|
25661
|
+
// TODO: Update textureAnimation spec.
|
|
25662
|
+
// @ts-expect-error
|
|
25663
|
+
var loop = (_textureAnimation_loop = textureAnimation == null ? void 0 : textureAnimation.loop) != null ? _textureAnimation_loop : true;
|
|
25664
|
+
if (time > duration && loop) {
|
|
25712
25665
|
time = time % duration;
|
|
25713
25666
|
}
|
|
25714
25667
|
var life = Math.min(Math.max(time / duration, 0.0), 1.0);
|
|
25715
|
-
var ta = this.textureSheetAnimation;
|
|
25716
25668
|
var video = this.renderer.texture.source.video;
|
|
25717
25669
|
if (video) {
|
|
25718
25670
|
if (time === 0) {
|
|
@@ -25724,9 +25676,9 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25724
25676
|
}
|
|
25725
25677
|
this.renderer.texture.uploadCurrentVideoFrame();
|
|
25726
25678
|
}
|
|
25727
|
-
if (
|
|
25679
|
+
if (textureAnimation) {
|
|
25728
25680
|
var _this_material_getVector4;
|
|
25729
|
-
var total =
|
|
25681
|
+
var total = textureAnimation.total || textureAnimation.row * textureAnimation.col;
|
|
25730
25682
|
var texRectX = 0;
|
|
25731
25683
|
var texRectY = 0;
|
|
25732
25684
|
var texRectW = 1;
|
|
@@ -25747,20 +25699,20 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25747
25699
|
}
|
|
25748
25700
|
var dx, dy;
|
|
25749
25701
|
if (flip) {
|
|
25750
|
-
dx = 1 /
|
|
25751
|
-
dy = 1 /
|
|
25702
|
+
dx = 1 / textureAnimation.row * texRectW;
|
|
25703
|
+
dy = 1 / textureAnimation.col * texRectH;
|
|
25752
25704
|
} else {
|
|
25753
|
-
dx = 1 /
|
|
25754
|
-
dy = 1 /
|
|
25705
|
+
dx = 1 / textureAnimation.col * texRectW;
|
|
25706
|
+
dy = 1 / textureAnimation.row * texRectH;
|
|
25755
25707
|
}
|
|
25756
25708
|
var texOffset;
|
|
25757
|
-
if (
|
|
25709
|
+
if (textureAnimation.animate) {
|
|
25758
25710
|
var frameIndex = Math.round(life * (total - 1));
|
|
25759
|
-
var yIndex = Math.floor(frameIndex /
|
|
25760
|
-
var xIndex = frameIndex - yIndex *
|
|
25711
|
+
var yIndex = Math.floor(frameIndex / textureAnimation.col);
|
|
25712
|
+
var xIndex = frameIndex - yIndex * textureAnimation.col;
|
|
25761
25713
|
texOffset = flip ? [
|
|
25762
25714
|
dx * yIndex,
|
|
25763
|
-
dy * (
|
|
25715
|
+
dy * (textureAnimation.col - xIndex)
|
|
25764
25716
|
] : [
|
|
25765
25717
|
dx * xIndex,
|
|
25766
25718
|
dy * (1 + yIndex)
|
|
@@ -25948,8 +25900,6 @@ exports.SpriteComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
25948
25900
|
var _data_duration;
|
|
25949
25901
|
//@ts-expect-error
|
|
25950
25902
|
this.duration = (_data_duration = data.duration) != null ? _data_duration : this.item.duration;
|
|
25951
|
-
var _data_loop;
|
|
25952
|
-
this.loop = (_data_loop = data.loop) != null ? _data_loop : true;
|
|
25953
25903
|
};
|
|
25954
25904
|
return SpriteComponent;
|
|
25955
25905
|
}(MaskableGraphic);
|
|
@@ -25957,21 +25907,21 @@ exports.SpriteComponent = __decorate([
|
|
|
25957
25907
|
effectsClass(DataType.SpriteComponent)
|
|
25958
25908
|
], exports.SpriteComponent);
|
|
25959
25909
|
|
|
25960
|
-
var ParticleLoader = /*#__PURE__*/ function(
|
|
25961
|
-
_inherits(ParticleLoader,
|
|
25910
|
+
var ParticleLoader = /*#__PURE__*/ function(Plugin) {
|
|
25911
|
+
_inherits(ParticleLoader, Plugin);
|
|
25962
25912
|
function ParticleLoader() {
|
|
25963
|
-
return
|
|
25913
|
+
return Plugin.apply(this, arguments);
|
|
25964
25914
|
}
|
|
25965
25915
|
return ParticleLoader;
|
|
25966
|
-
}(
|
|
25916
|
+
}(_wrap_native_super(Plugin));
|
|
25967
25917
|
|
|
25968
|
-
var CalculateLoader = /*#__PURE__*/ function(
|
|
25969
|
-
_inherits(CalculateLoader,
|
|
25918
|
+
var CalculateLoader = /*#__PURE__*/ function(Plugin) {
|
|
25919
|
+
_inherits(CalculateLoader, Plugin);
|
|
25970
25920
|
function CalculateLoader() {
|
|
25971
|
-
return
|
|
25921
|
+
return Plugin.apply(this, arguments);
|
|
25972
25922
|
}
|
|
25973
25923
|
return CalculateLoader;
|
|
25974
|
-
}(
|
|
25924
|
+
}(_wrap_native_super(Plugin));
|
|
25975
25925
|
|
|
25976
25926
|
// Based on:
|
|
25977
25927
|
/**
|
|
@@ -29073,6 +29023,12 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29073
29023
|
/**
|
|
29074
29024
|
* 每一行文本的最大宽度
|
|
29075
29025
|
*/ _this.maxLineWidth = 0;
|
|
29026
|
+
/**
|
|
29027
|
+
* 初始文本宽度,用于计算缩放比例
|
|
29028
|
+
*/ _this.baseTextWidth = 0;
|
|
29029
|
+
/**
|
|
29030
|
+
* 初始 `transform.size.x`,用于按比例更新显示宽度
|
|
29031
|
+
*/ _this.baseScaleX = 1;
|
|
29076
29032
|
_this.name = "MText" + seed$1++;
|
|
29077
29033
|
// 初始化canvas资源
|
|
29078
29034
|
_this.canvas = canvasPool.getCanvas();
|
|
@@ -29098,10 +29054,11 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29098
29054
|
text: "默认文本",
|
|
29099
29055
|
fontFamily: "AlibabaSans-BoldItalic",
|
|
29100
29056
|
fontSize: 40,
|
|
29057
|
+
// 统一使用 0-1 颜色值
|
|
29101
29058
|
textColor: [
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29059
|
+
1,
|
|
29060
|
+
1,
|
|
29061
|
+
1,
|
|
29105
29062
|
1
|
|
29106
29063
|
],
|
|
29107
29064
|
fontWeight: TextWeight.normal,
|
|
@@ -29138,6 +29095,10 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29138
29095
|
// TextComponentBase
|
|
29139
29096
|
this.updateWithOptions(options);
|
|
29140
29097
|
this.renderText(options);
|
|
29098
|
+
// 记录初始的 textWidth 和 x 缩放,用于后续按比例更新显示宽度
|
|
29099
|
+
// 添加兜底值 1 防止除 0
|
|
29100
|
+
this.baseTextWidth = options.textWidth || this.textLayout.width || 1;
|
|
29101
|
+
this.baseScaleX = this.item.transform.size.x;
|
|
29141
29102
|
// 恢复默认颜色
|
|
29142
29103
|
this.material.setColor("_Color", new Color(1, 1, 1, 1));
|
|
29143
29104
|
};
|
|
@@ -29336,9 +29297,9 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29336
29297
|
if (style.isOutlined) {
|
|
29337
29298
|
_this.setupOutline();
|
|
29338
29299
|
}
|
|
29339
|
-
//
|
|
29300
|
+
// textColor 统一是 0-1,写入 canvas 时乘 255
|
|
29340
29301
|
var _style_textColor = style.textColor, r = _style_textColor[0], g = _style_textColor[1], b = _style_textColor[2], a = _style_textColor[3];
|
|
29341
|
-
context.fillStyle = "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
|
|
29302
|
+
context.fillStyle = "rgba(" + r * 255 + ", " + g * 255 + ", " + b * 255 + ", " + a + ")";
|
|
29342
29303
|
var charsInfo = [];
|
|
29343
29304
|
var x = 0;
|
|
29344
29305
|
var y = layout.getOffsetY(style, _this.lineCount, lineHeight, fontSize);
|
|
@@ -29400,6 +29361,46 @@ exports.TextComponent = /*#__PURE__*/ function(MaskableGraphic) {
|
|
|
29400
29361
|
layout.autoWidth = normalizedValue;
|
|
29401
29362
|
this.isDirty = true;
|
|
29402
29363
|
};
|
|
29364
|
+
/**
|
|
29365
|
+
* 设置文本框宽度
|
|
29366
|
+
* 手动设置宽度时会自动关闭 `autoWidth`
|
|
29367
|
+
* 同时会按比例更新 `transform.size.x`,让 UI 框宽度也跟着变化
|
|
29368
|
+
* @param value - 文本框宽度
|
|
29369
|
+
*/ _proto.setTextWidth = function setTextWidth(value) {
|
|
29370
|
+
var width = Math.max(0, Number(value) || 0);
|
|
29371
|
+
var layout = this.textLayout;
|
|
29372
|
+
// 宽度没变且已是非 autoWidth 模式,直接返回
|
|
29373
|
+
if (layout.width === width && layout.autoWidth === false) {
|
|
29374
|
+
return;
|
|
29375
|
+
}
|
|
29376
|
+
// 手动设置宽度时关闭 autoWidth
|
|
29377
|
+
layout.autoWidth = false;
|
|
29378
|
+
layout.width = width;
|
|
29379
|
+
// 按当前 overflow 模式重新计算行数和 maxLineWidth
|
|
29380
|
+
this.lineCount = this.getLineCount(this.text || "");
|
|
29381
|
+
this.isDirty = true;
|
|
29382
|
+
// 同步更新外层显示宽度(按比例缩放 transform)
|
|
29383
|
+
// 这样 UI 框的视觉宽度也会跟着文本宽度变化
|
|
29384
|
+
if (this.baseTextWidth > 0) {
|
|
29385
|
+
var scale = width / this.baseTextWidth;
|
|
29386
|
+
this.item.transform.size.x = this.baseScaleX * scale;
|
|
29387
|
+
}
|
|
29388
|
+
};
|
|
29389
|
+
/**
|
|
29390
|
+
* 设置文本框高度
|
|
29391
|
+
* @param value - 文本框高度
|
|
29392
|
+
*/ _proto.setTextHeight = function setTextHeight(value) {
|
|
29393
|
+
var height = Math.max(0, Number(value) || 0);
|
|
29394
|
+
if (height === 0) {
|
|
29395
|
+
return;
|
|
29396
|
+
}
|
|
29397
|
+
var layout = this.textLayout;
|
|
29398
|
+
if (layout.height === height) {
|
|
29399
|
+
return;
|
|
29400
|
+
}
|
|
29401
|
+
layout.height = height;
|
|
29402
|
+
this.isDirty = true;
|
|
29403
|
+
};
|
|
29403
29404
|
_proto.setFontSize = function setFontSize(value) {
|
|
29404
29405
|
if (this.textStyle.fontSize === value) {
|
|
29405
29406
|
return;
|
|
@@ -29467,13 +29468,13 @@ applyMixins(exports.TextComponent, [
|
|
|
29467
29468
|
]);
|
|
29468
29469
|
|
|
29469
29470
|
// TODO: 注册必须用
|
|
29470
|
-
var TextLoader = /*#__PURE__*/ function(
|
|
29471
|
-
_inherits(TextLoader,
|
|
29471
|
+
var TextLoader = /*#__PURE__*/ function(Plugin) {
|
|
29472
|
+
_inherits(TextLoader, Plugin);
|
|
29472
29473
|
function TextLoader() {
|
|
29473
|
-
return
|
|
29474
|
+
return Plugin.apply(this, arguments);
|
|
29474
29475
|
}
|
|
29475
29476
|
return TextLoader;
|
|
29476
|
-
}(
|
|
29477
|
+
}(_wrap_native_super(Plugin));
|
|
29477
29478
|
|
|
29478
29479
|
var Asset = /*#__PURE__*/ function(EffectsObject) {
|
|
29479
29480
|
_inherits(Asset, EffectsObject);
|
|
@@ -30530,6 +30531,10 @@ function version35Migration(json) {
|
|
|
30530
30531
|
if (component.dataType === DataType.TextComponent || component.dataType === DataType.RichTextComponent && component.options) {
|
|
30531
30532
|
ensureTextVerticalAlign(component.options);
|
|
30532
30533
|
}
|
|
30534
|
+
// 处理文本颜色从 0-255 到 0-1 的转换
|
|
30535
|
+
if (component.dataType === DataType.TextComponent) {
|
|
30536
|
+
convertTextColorTo01(component.options);
|
|
30537
|
+
}
|
|
30533
30538
|
}
|
|
30534
30539
|
}
|
|
30535
30540
|
//@ts-expect-error
|
|
@@ -30549,6 +30554,22 @@ function version35Migration(json) {
|
|
|
30549
30554
|
options.TextVerticalAlign = options.textBaseline;
|
|
30550
30555
|
}
|
|
30551
30556
|
}
|
|
30557
|
+
/**
|
|
30558
|
+
* 将文本颜色从 0-255 转换到 0-1
|
|
30559
|
+
*/ function convertTextColorTo01(options) {
|
|
30560
|
+
if (!options || !options.textColor) {
|
|
30561
|
+
return;
|
|
30562
|
+
}
|
|
30563
|
+
var textColor = options.textColor;
|
|
30564
|
+
var _textColor_;
|
|
30565
|
+
// 将 RGB 从 0-255 转换到 0-1(alpha 通道已经是 0-1,不需要转换)
|
|
30566
|
+
options.textColor = [
|
|
30567
|
+
textColor[0] / 255.0,
|
|
30568
|
+
textColor[1] / 255.0,
|
|
30569
|
+
textColor[2] / 255.0,
|
|
30570
|
+
(_textColor_ = textColor[3]) != null ? _textColor_ : 1
|
|
30571
|
+
];
|
|
30572
|
+
}
|
|
30552
30573
|
/**
|
|
30553
30574
|
* 根据形状获取形状几何体数据
|
|
30554
30575
|
* @param shape - 形状
|
|
@@ -31471,7 +31492,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
31471
31492
|
return ret;
|
|
31472
31493
|
}
|
|
31473
31494
|
|
|
31474
|
-
var version$1 = "2.8.0-alpha.
|
|
31495
|
+
var version$1 = "2.8.0-alpha.4";
|
|
31475
31496
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
31476
31497
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
31477
31498
|
var reverseParticle = false;
|
|
@@ -32111,8 +32132,8 @@ var seed = 1;
|
|
|
32111
32132
|
};
|
|
32112
32133
|
return [
|
|
32113
32134
|
4,
|
|
32114
|
-
hookTimeInfo("plugin:
|
|
32115
|
-
return _this.
|
|
32135
|
+
hookTimeInfo("plugin:onAssetsLoadStart", function() {
|
|
32136
|
+
return _this.onPluginSceneLoadStart(scene);
|
|
32116
32137
|
})
|
|
32117
32138
|
];
|
|
32118
32139
|
case 6:
|
|
@@ -32400,7 +32421,7 @@ var seed = 1;
|
|
|
32400
32421
|
});
|
|
32401
32422
|
})();
|
|
32402
32423
|
};
|
|
32403
|
-
_proto.
|
|
32424
|
+
_proto.onPluginSceneLoadStart = function onPluginSceneLoadStart(scene) {
|
|
32404
32425
|
var _this = this;
|
|
32405
32426
|
return _async_to_generator(function() {
|
|
32406
32427
|
return __generator(this, function(_state) {
|
|
@@ -32408,7 +32429,7 @@ var seed = 1;
|
|
|
32408
32429
|
case 0:
|
|
32409
32430
|
return [
|
|
32410
32431
|
4,
|
|
32411
|
-
PluginSystem.
|
|
32432
|
+
PluginSystem.onAssetsLoadStart(scene, _this.options)
|
|
32412
32433
|
];
|
|
32413
32434
|
case 1:
|
|
32414
32435
|
_state.sent();
|
|
@@ -35109,8 +35130,8 @@ var SceneLoader = /*#__PURE__*/ function() {
|
|
|
35109
35130
|
case 1:
|
|
35110
35131
|
loadedScene = _state.sent();
|
|
35111
35132
|
engine.clearResources();
|
|
35112
|
-
// 触发插件系统 pluginSystem 的回调
|
|
35113
|
-
PluginSystem.
|
|
35133
|
+
// 触发插件系统 pluginSystem 的回调 onAssetsLoadFinish
|
|
35134
|
+
PluginSystem.onAssetsLoadFinish(loadedScene, assetManager.options, engine);
|
|
35114
35135
|
engine.assetService.prepareAssets(loadedScene, loadedScene.assets);
|
|
35115
35136
|
engine.assetService.updateTextVariables(loadedScene, options.variables);
|
|
35116
35137
|
engine.assetService.initializeTexture(loadedScene);
|
|
@@ -35172,10 +35193,9 @@ registerPlugin("sprite", SpriteLoader);
|
|
|
35172
35193
|
registerPlugin("particle", ParticleLoader);
|
|
35173
35194
|
registerPlugin("cal", CalculateLoader);
|
|
35174
35195
|
registerPlugin("interact", InteractLoader);
|
|
35175
|
-
var version = "2.8.0-alpha.
|
|
35196
|
+
var version = "2.8.0-alpha.4";
|
|
35176
35197
|
logger.info("Core version: " + version + ".");
|
|
35177
35198
|
|
|
35178
|
-
exports.AbstractPlugin = AbstractPlugin;
|
|
35179
35199
|
exports.ActivationMixerPlayable = ActivationMixerPlayable;
|
|
35180
35200
|
exports.ActivationPlayable = ActivationPlayable;
|
|
35181
35201
|
exports.AndNode = AndNode;
|
|
@@ -35275,6 +35295,7 @@ exports.PathSegments = PathSegments;
|
|
|
35275
35295
|
exports.Playable = Playable;
|
|
35276
35296
|
exports.PlayableAsset = PlayableAsset;
|
|
35277
35297
|
exports.PlayableOutput = PlayableOutput;
|
|
35298
|
+
exports.Plugin = Plugin;
|
|
35278
35299
|
exports.PluginSystem = PluginSystem;
|
|
35279
35300
|
exports.PointerEventData = PointerEventData;
|
|
35280
35301
|
exports.PolyStar = PolyStar;
|