@galacean/engine-core 1.4.13 → 1.4.15
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/main.js +25 -13
- package/dist/main.js.map +1 -1
- package/dist/module.js +25 -13
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/asset/AssetPromise.d.ts +30 -5
package/dist/module.js
CHANGED
|
@@ -19387,12 +19387,24 @@ var AssetPromise = /*#__PURE__*/ function() {
|
|
|
19387
19387
|
this._onCancelHandler && this._onCancelHandler();
|
|
19388
19388
|
return this;
|
|
19389
19389
|
};
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19390
|
+
AssetPromise.resolve = function resolve(value) {
|
|
19391
|
+
if (value === undefined) {
|
|
19392
|
+
return new AssetPromise(function(resolve) {
|
|
19393
|
+
return resolve();
|
|
19394
|
+
});
|
|
19395
|
+
} else if (_instanceof(value, AssetPromise) || _instanceof(value, Promise)) {
|
|
19396
|
+
return new AssetPromise(function(resolve, reject) {
|
|
19397
|
+
value.then(function(resolved) {
|
|
19398
|
+
return resolve(resolved);
|
|
19399
|
+
}, reject);
|
|
19400
|
+
});
|
|
19401
|
+
} else {
|
|
19402
|
+
return new AssetPromise(function(resolve) {
|
|
19403
|
+
return resolve(value);
|
|
19404
|
+
});
|
|
19405
|
+
}
|
|
19406
|
+
};
|
|
19407
|
+
AssetPromise.all = function all(values) {
|
|
19396
19408
|
return new AssetPromise(function(resolve, reject, setTaskCompleteProgress) {
|
|
19397
19409
|
var onComplete = function onComplete(index, resultValue) {
|
|
19398
19410
|
completed++;
|
|
@@ -19403,7 +19415,7 @@ var AssetPromise = /*#__PURE__*/ function() {
|
|
|
19403
19415
|
}
|
|
19404
19416
|
};
|
|
19405
19417
|
var onProgress = function onProgress(promise, index) {
|
|
19406
|
-
if (_instanceof(promise,
|
|
19418
|
+
if (_instanceof(promise, AssetPromise) || _instanceof(promise, Promise)) {
|
|
19407
19419
|
promise.then(function(value) {
|
|
19408
19420
|
onComplete(index, value);
|
|
19409
19421
|
}, reject);
|
|
@@ -19413,14 +19425,14 @@ var AssetPromise = /*#__PURE__*/ function() {
|
|
|
19413
19425
|
});
|
|
19414
19426
|
}
|
|
19415
19427
|
};
|
|
19416
|
-
var count =
|
|
19428
|
+
var count = Array.from(values).length;
|
|
19417
19429
|
var results = new Array(count);
|
|
19418
19430
|
var completed = 0;
|
|
19419
19431
|
if (count === 0) {
|
|
19420
19432
|
return resolve(results);
|
|
19421
19433
|
}
|
|
19422
19434
|
for(var i = 0; i < count; i++){
|
|
19423
|
-
onProgress(
|
|
19435
|
+
onProgress(values[i], i);
|
|
19424
19436
|
}
|
|
19425
19437
|
});
|
|
19426
19438
|
};
|
|
@@ -20003,12 +20015,12 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
20003
20015
|
var obj = this._objectPool[refId];
|
|
20004
20016
|
var promise;
|
|
20005
20017
|
if (obj) {
|
|
20006
|
-
promise =
|
|
20018
|
+
promise = AssetPromise.resolve(obj);
|
|
20007
20019
|
} else {
|
|
20008
20020
|
var resourceConfig = this._idResourceMap[refId];
|
|
20009
20021
|
if (!resourceConfig) {
|
|
20010
20022
|
Logger.warn("refId:" + refId + " is not find in this._idResourceMap.");
|
|
20011
|
-
return
|
|
20023
|
+
return AssetPromise.resolve(null);
|
|
20012
20024
|
}
|
|
20013
20025
|
var url = resourceConfig.virtualPath;
|
|
20014
20026
|
if (key) {
|
|
@@ -24122,7 +24134,7 @@ var fragBlurH = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\
|
|
|
24122
24134
|
|
|
24123
24135
|
var fragBlurV = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n vec2 texelSize = renderer_texelSize.xy;\n\n // Optimized bilinear 5-tap gaussian on the same-sized source (9-tap equivalent)\n mediump vec4 c0 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 3.23076923));\n mediump vec4 c1 = sampleTexture(renderer_BlitTexture, v_uv - vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c2 = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 c3 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 1.38461538));\n mediump vec4 c4 = sampleTexture(renderer_BlitTexture, v_uv + vec2(0.0, texelSize.y * 3.23076923));\n\n gl_FragColor = c0 * 0.07027027 + c1 * 0.31621622\n + c2 * 0.22702703\n + c3 * 0.31621622 + c4 * 0.07027027;\n\n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
24124
24136
|
|
|
24125
|
-
var fragPrefilter = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n\t#ifdef BLOOM_HQ\n vec2 texelSize = renderer_texelSize.xy;\n mediump vec4 A = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, -1.0));\n mediump vec4 C = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, -1.0));\n mediump vec4 D = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, -0.5));\n mediump vec4 F = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 H = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 0.0));\n mediump vec4 I = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, 0.5));\n mediump vec4 K = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, 1.0));\n mediump vec4 M = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 1.0));\n\n mediump vec2 scale = vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 samplerColor = (D + E + I + J) * div.x;\n samplerColor += (A + B + G + F) * div.y;\n samplerColor += (B + C + H + G) * div.y;\n samplerColor += (F + G + L + K) * div.y;\n samplerColor += (G + H + M + L) * div.y;\n #else\n mediump vec4 samplerColor = sampleTexture(renderer_BlitTexture, v_uv);\n #endif\n\n mediump vec3 color = samplerColor.rgb;\n\n // User controlled clamp to limit crazy high broken spec\n color = min(color, HALF_MAX);\n\n // Thresholding\n mediump float brightness = max3(color);\n float threshold = material_BloomParams.x;\n float thresholdKnee = material_BloomParams.y;\n mediump float softness = clamp(brightness - threshold + thresholdKnee, 0.0, 2.0 * thresholdKnee);\n softness = (softness * softness) / (4.0 * thresholdKnee + 1e-4);\n mediump float multiplier = max(brightness - threshold, softness) / max(brightness, 1e-4);\n color *= multiplier;\n\n // Clamp colors to positive once in prefilter. Encode can have a sqrt, and sqrt(-x) == NaN. Up/Downsample passes would then spread the NaN.\n color = max(color, 0.0);\n\n gl_FragColor = vec4(color,
|
|
24137
|
+
var fragPrefilter = "#define GLSLIFY 1\n#include <PostCommon>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 renderer_texelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n\t#ifdef BLOOM_HQ\n vec2 texelSize = renderer_texelSize.xy;\n mediump vec4 A = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, -1.0));\n mediump vec4 C = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, -1.0));\n mediump vec4 D = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, -0.5));\n mediump vec4 F = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = sampleTexture(renderer_BlitTexture, v_uv);\n mediump vec4 H = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 0.0));\n mediump vec4 I = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.5, 0.5));\n mediump vec4 K = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(0.0, 1.0));\n mediump vec4 M = sampleTexture(renderer_BlitTexture, v_uv + texelSize * vec2(1.0, 1.0));\n\n mediump vec2 scale = vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 samplerColor = (D + E + I + J) * div.x;\n samplerColor += (A + B + G + F) * div.y;\n samplerColor += (B + C + H + G) * div.y;\n samplerColor += (F + G + L + K) * div.y;\n samplerColor += (G + H + M + L) * div.y;\n #else\n mediump vec4 samplerColor = sampleTexture(renderer_BlitTexture, v_uv);\n #endif\n\n mediump vec3 color = samplerColor.rgb;\n\n // User controlled clamp to limit crazy high broken spec\n color = min(color, HALF_MAX);\n\n // Thresholding\n mediump float brightness = max3(color);\n float threshold = material_BloomParams.x;\n float thresholdKnee = material_BloomParams.y;\n mediump float softness = clamp(brightness - threshold + thresholdKnee, 0.0, 2.0 * thresholdKnee);\n softness = (softness * softness) / (4.0 * thresholdKnee + 1e-4);\n mediump float multiplier = max(brightness - threshold, softness) / max(brightness, 1e-4);\n color *= multiplier;\n\n // Clamp colors to positive once in prefilter. Encode can have a sqrt, and sqrt(-x) == NaN. Up/Downsample passes would then spread the NaN.\n color = max(color, 0.0);\n\n // Bloom is addtive blend mode, we should set alpha 0 to avoid browser background color dark when canvas alpha and premultiplyAlpha is true\n gl_FragColor = vec4(color, 0.0);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}\n"; // eslint-disable-line
|
|
24126
24138
|
|
|
24127
24139
|
var fragUpsample = "#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n\nvarying vec2 v_uv;\nuniform sampler2D renderer_BlitTexture;\nuniform sampler2D material_lowMipTexture;\nuniform vec4 material_BloomParams; // x: threshold (linear), y: threshold knee, z: scatter\nuniform vec4 material_lowMipTexelSize; // x: 1/width, y: 1/height, z: width, w: height\n\nvoid main(){\n mediump vec4 highMip = sampleTexture(renderer_BlitTexture, v_uv);\n\n #ifdef BLOOM_HQ\n mediump vec4 lowMip = sampleTexture2DBicubic(material_lowMipTexture, v_uv, material_lowMipTexelSize);\n #else\n mediump vec4 lowMip = sampleTexture(material_lowMipTexture, v_uv);\n #endif\n \n gl_FragColor = mix(highMip, lowMip, material_BloomParams.z);\n \n #ifndef ENGINE_IS_COLORSPACE_GAMMA\n gl_FragColor = linearToGamma(gl_FragColor);\n #endif\n}"; // eslint-disable-line
|
|
24128
24140
|
|
|
@@ -24382,7 +24394,7 @@ var PostProcessUberPass = /*#__PURE__*/ function(PostProcessPass) {
|
|
|
24382
24394
|
var thresholdKnee = thresholdLinear * 0.5; // Hardcoded soft knee
|
|
24383
24395
|
var bloomParams = bloomShaderData.getVector4(BloomEffect._bloomParams);
|
|
24384
24396
|
var scatterLerp = MathUtil.lerp(0.05, 0.95, scatter.value);
|
|
24385
|
-
bloomParams.x =
|
|
24397
|
+
bloomParams.x = thresholdLinear;
|
|
24386
24398
|
bloomParams.y = thresholdKnee;
|
|
24387
24399
|
bloomParams.z = scatterLerp;
|
|
24388
24400
|
var bloomIntensityParams = uberShaderData.getVector4(BloomEffect._bloomIntensityParams);
|