@galacean/effects-core 1.2.3 → 1.3.0-alpha.0
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/downloader.d.ts +1 -11
- package/dist/index.js +90 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -75
- package/dist/index.mjs.map +1 -1
- package/dist/template-image/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/downloader.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
type SuccessHandler<T> = (data: T) => void;
|
|
2
2
|
type ErrorHandler = (status: number, responseText: string) => void;
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
type VideoLoadOptions = {
|
|
7
|
-
/**
|
|
8
|
-
* 视频是否循环播放
|
|
9
|
-
*/
|
|
10
|
-
loop?: boolean;
|
|
11
|
-
};
|
|
12
3
|
/**
|
|
13
4
|
* JSON 值,它可以是字符串、数字、布尔值、对象或者 JSON 值的数组。
|
|
14
5
|
*
|
|
@@ -77,7 +68,6 @@ export declare function loadBlob(url: string): Promise<Blob>;
|
|
|
77
68
|
/**
|
|
78
69
|
* 异步加载一个视频文件
|
|
79
70
|
* @param url - 视频文件的 URL 或 MediaProvider 对象
|
|
80
|
-
* @param options - 加载参数
|
|
81
71
|
*/
|
|
82
|
-
export declare function loadVideo(url: string | MediaProvider
|
|
72
|
+
export declare function loadVideo(url: string | MediaProvider): Promise<HTMLVideoElement>;
|
|
83
73
|
export {};
|
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: v1.
|
|
6
|
+
* Version: v1.3.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -686,7 +686,7 @@ function asserts(condition, msg) {
|
|
|
686
686
|
* Name: @galacean/effects-specification
|
|
687
687
|
* Description: Galacean Effects JSON Specification
|
|
688
688
|
* Author: Ant Group CO., Ltd.
|
|
689
|
-
* Version: v1.0.
|
|
689
|
+
* Version: v1.1.0-alpha.0
|
|
690
690
|
*/
|
|
691
691
|
|
|
692
692
|
/*********************************************/
|
|
@@ -1067,6 +1067,16 @@ var CompositionEndBehavior$1;
|
|
|
1067
1067
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
|
|
1068
1068
|
})(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
|
|
1069
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* 动态换图类型
|
|
1072
|
+
* @since 1.3.0
|
|
1073
|
+
*/
|
|
1074
|
+
var BackgroundType$1;
|
|
1075
|
+
(function (BackgroundType) {
|
|
1076
|
+
BackgroundType["video"] = "video";
|
|
1077
|
+
BackgroundType["image"] = "image";
|
|
1078
|
+
})(BackgroundType$1 || (BackgroundType$1 = {}));
|
|
1079
|
+
|
|
1070
1080
|
/*********************************************/
|
|
1071
1081
|
/* 基本数值属性参数 */
|
|
1072
1082
|
/*********************************************/
|
|
@@ -1356,6 +1366,7 @@ var FontStyle$1;
|
|
|
1356
1366
|
|
|
1357
1367
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1358
1368
|
__proto__: null,
|
|
1369
|
+
get BackgroundType () { return BackgroundType$1; },
|
|
1359
1370
|
get BezierKeyframeType () { return BezierKeyframeType$1; },
|
|
1360
1371
|
get BlendingMode () { return BlendingMode$1; },
|
|
1361
1372
|
BloomFilterThresholdAvgColor: BloomFilterThresholdAvgColor,
|
|
@@ -10153,10 +10164,8 @@ function loadBlob(url) {
|
|
|
10153
10164
|
/**
|
|
10154
10165
|
* 异步加载一个视频文件
|
|
10155
10166
|
* @param url - 视频文件的 URL 或 MediaProvider 对象
|
|
10156
|
-
* @param options - 加载参数
|
|
10157
10167
|
*/
|
|
10158
|
-
function loadVideo(url
|
|
10159
|
-
if (options === void 0) { options = {}; }
|
|
10168
|
+
function loadVideo(url) {
|
|
10160
10169
|
return __awaiter(this, void 0, void 0, function () {
|
|
10161
10170
|
var video;
|
|
10162
10171
|
return __generator(this, function (_a) {
|
|
@@ -10169,9 +10178,6 @@ function loadVideo(url, options) {
|
|
|
10169
10178
|
}
|
|
10170
10179
|
video.crossOrigin = 'anonymous';
|
|
10171
10180
|
video.muted = true;
|
|
10172
|
-
if (options.loop) {
|
|
10173
|
-
video.addEventListener('ended', function () { return video.play(); });
|
|
10174
|
-
}
|
|
10175
10181
|
if (isAndroid()) {
|
|
10176
10182
|
video.setAttribute('renderer', 'standard');
|
|
10177
10183
|
}
|
|
@@ -19655,6 +19661,26 @@ function getBackgroundImage(template, variables) {
|
|
|
19655
19661
|
}
|
|
19656
19662
|
return templateBackground;
|
|
19657
19663
|
}
|
|
19664
|
+
function loadMedia(url, loadFn) {
|
|
19665
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19666
|
+
return __generator(this, function (_a) {
|
|
19667
|
+
switch (_a.label) {
|
|
19668
|
+
case 0:
|
|
19669
|
+
if (!Array.isArray(url)) return [3 /*break*/, 5];
|
|
19670
|
+
_a.label = 1;
|
|
19671
|
+
case 1:
|
|
19672
|
+
_a.trys.push([1, 3, , 5]);
|
|
19673
|
+
return [4 /*yield*/, loadFn(url[0])];
|
|
19674
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
19675
|
+
case 3:
|
|
19676
|
+
_a.sent();
|
|
19677
|
+
return [4 /*yield*/, loadFn(url[1])];
|
|
19678
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
19679
|
+
case 5: return [2 /*return*/, loadFn(url)];
|
|
19680
|
+
}
|
|
19681
|
+
});
|
|
19682
|
+
});
|
|
19683
|
+
}
|
|
19658
19684
|
function drawImageAndTemplate(viewer, image, template, variables, opt) {
|
|
19659
19685
|
var _a;
|
|
19660
19686
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -21546,7 +21572,7 @@ var filters = {
|
|
|
21546
21572
|
* Name: @galacean/effects-specification
|
|
21547
21573
|
* Description: Galacean Effects JSON Specification
|
|
21548
21574
|
* Author: Ant Group CO., Ltd.
|
|
21549
|
-
* Version: v1.0.
|
|
21575
|
+
* Version: v1.1.0-alpha.0
|
|
21550
21576
|
*/
|
|
21551
21577
|
|
|
21552
21578
|
/*********************************************/
|
|
@@ -21925,6 +21951,16 @@ var CompositionEndBehavior;
|
|
|
21925
21951
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21926
21952
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21927
21953
|
|
|
21954
|
+
/**
|
|
21955
|
+
* 动态换图类型
|
|
21956
|
+
* @since 1.3.0
|
|
21957
|
+
*/
|
|
21958
|
+
var BackgroundType;
|
|
21959
|
+
(function (BackgroundType) {
|
|
21960
|
+
BackgroundType["video"] = "video";
|
|
21961
|
+
BackgroundType["image"] = "image";
|
|
21962
|
+
})(BackgroundType || (BackgroundType = {}));
|
|
21963
|
+
|
|
21928
21964
|
/*********************************************/
|
|
21929
21965
|
/* 基本数值属性参数 */
|
|
21930
21966
|
/*********************************************/
|
|
@@ -23009,11 +23045,9 @@ function getStandardImage(image, index, imageTags) {
|
|
|
23009
23045
|
else if (image.url) {
|
|
23010
23046
|
return {
|
|
23011
23047
|
url: image.url,
|
|
23012
|
-
type: image.type,
|
|
23013
23048
|
webp: image.webp,
|
|
23014
23049
|
renderLevel: renderLevel,
|
|
23015
23050
|
oriY: oriY,
|
|
23016
|
-
loop: image.loop,
|
|
23017
23051
|
};
|
|
23018
23052
|
}
|
|
23019
23053
|
else if (image && image.sourceType) {
|
|
@@ -23765,79 +23799,61 @@ var AssetManager = /** @class */ (function () {
|
|
|
23765
23799
|
_a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
|
|
23766
23800
|
baseUrl = this.baseUrl;
|
|
23767
23801
|
jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
|
|
23768
|
-
var png, webp, imageURL, webpURL, template,
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
switch (_e.label) {
|
|
23802
|
+
var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, resultImage, compressed, src, bufferURL, _a, url, image;
|
|
23803
|
+
return __generator(this, function (_b) {
|
|
23804
|
+
switch (_b.label) {
|
|
23772
23805
|
case 0:
|
|
23773
|
-
if (!usage[idx])
|
|
23806
|
+
if (!usage[idx]) {
|
|
23807
|
+
return [2 /*return*/, undefined];
|
|
23808
|
+
}
|
|
23774
23809
|
png = img.url, webp = img.webp;
|
|
23775
23810
|
imageURL = new URL(png, baseUrl).href;
|
|
23776
23811
|
webpURL = webp && new URL(webp, baseUrl).href;
|
|
23777
|
-
if (!('template' in img)) return [3 /*break*/,
|
|
23812
|
+
if (!('template' in img)) return [3 /*break*/, 13];
|
|
23778
23813
|
template = img.template;
|
|
23779
|
-
|
|
23780
|
-
|
|
23814
|
+
isTemplateV2 = 'v' in template && template.v === 2 && template.background;
|
|
23815
|
+
background = isTemplateV2 ? template.background : undefined;
|
|
23816
|
+
if (!(isTemplateV2 && background)) return [3 /*break*/, 8];
|
|
23781
23817
|
url_1 = getBackgroundImage(template, variables);
|
|
23782
|
-
|
|
23783
|
-
|
|
23784
|
-
|
|
23818
|
+
isVideo = background.type === BackgroundType$1.video;
|
|
23819
|
+
loadFn = background && isVideo ? loadVideo : loadImage;
|
|
23820
|
+
_b.label = 1;
|
|
23785
23821
|
case 1:
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
return [4 /*yield*/, loadImage(url_1[0])];
|
|
23822
|
+
_b.trys.push([1, 6, , 7]);
|
|
23823
|
+
return [4 /*yield*/, loadMedia(url_1, loadFn)];
|
|
23789
23824
|
case 2:
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
return [3 /*break*/, 5];
|
|
23825
|
+
resultImage = _b.sent();
|
|
23826
|
+
if (!(resultImage instanceof HTMLVideoElement)) return [3 /*break*/, 3];
|
|
23827
|
+
return [2 /*return*/, resultImage];
|
|
23794
23828
|
case 3:
|
|
23795
|
-
|
|
23796
|
-
|
|
23797
|
-
|
|
23798
|
-
case 4:
|
|
23799
|
-
result = (_c.image = _e.sent(),
|
|
23800
|
-
_c.url = url_1[1],
|
|
23801
|
-
_c);
|
|
23802
|
-
return [3 /*break*/, 5];
|
|
23803
|
-
case 5:
|
|
23804
|
-
if (variables) {
|
|
23805
|
-
variables[name_1] = result.url;
|
|
23829
|
+
// 如果是加载图片且是数组,设置变量,视频情况下不需要
|
|
23830
|
+
if (background && !Array.isArray(url_1) && variables) {
|
|
23831
|
+
variables[background.name] = url_1;
|
|
23806
23832
|
}
|
|
23807
|
-
return [
|
|
23833
|
+
return [4 /*yield*/, combineImageTemplate(resultImage, template, variables, this.options, img.oriY === -1)];
|
|
23834
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
23835
|
+
case 5: return [3 /*break*/, 7];
|
|
23808
23836
|
case 6:
|
|
23809
|
-
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
case
|
|
23813
|
-
|
|
23814
|
-
|
|
23815
|
-
|
|
23816
|
-
|
|
23817
|
-
|
|
23818
|
-
case
|
|
23819
|
-
case 10:
|
|
23820
|
-
// 测试场景:'年兽大爆炸——8个彩蛋t1'
|
|
23821
|
-
result = _e.sent();
|
|
23822
|
-
_e.label = 11;
|
|
23837
|
+
_b.sent();
|
|
23838
|
+
throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, "."));
|
|
23839
|
+
case 7: return [3 /*break*/, 12];
|
|
23840
|
+
case 8:
|
|
23841
|
+
_b.trys.push([8, 11, , 12]);
|
|
23842
|
+
return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23843
|
+
case 9:
|
|
23844
|
+
resultImage = _b.sent();
|
|
23845
|
+
return [4 /*yield*/, combineImageTemplate(resultImage.image, template, variables, this.options, img.oriY === -1)];
|
|
23846
|
+
case 10: return [2 /*return*/, _b.sent()];
|
|
23823
23847
|
case 11:
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
case 12:
|
|
23827
|
-
_e.trys.push([12, 14, , 15]);
|
|
23828
|
-
return [4 /*yield*/, combineImageTemplate(result.image, template, variables, this.options, img.oriY === -1)];
|
|
23848
|
+
_b.sent();
|
|
23849
|
+
throw new Error("Failed to load. Check the template, URL: ".concat(imageURL, "."));
|
|
23850
|
+
case 12: return [3 /*break*/, 14];
|
|
23829
23851
|
case 13:
|
|
23830
|
-
templateImage = _e.sent();
|
|
23831
|
-
return [3 /*break*/, 15];
|
|
23832
|
-
case 14:
|
|
23833
|
-
_e.sent();
|
|
23834
|
-
throw new Error("image template fail: ".concat(imageURL));
|
|
23835
|
-
case 15: return [2 /*return*/, templateImage];
|
|
23836
|
-
case 16:
|
|
23837
23852
|
if ('type' in img && img.type === 'video') {
|
|
23838
|
-
loop = img.loop;
|
|
23839
23853
|
// 视频
|
|
23840
|
-
|
|
23854
|
+
// TODO: 2024.03.28 后面考虑下掉非推荐的视频元素使用方式
|
|
23855
|
+
console.warn('The video element is deprecated. Use template BackgroundType.video instead.');
|
|
23856
|
+
return [2 /*return*/, loadVideo(img.url)];
|
|
23841
23857
|
}
|
|
23842
23858
|
else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
23843
23859
|
compressed = img.compressed;
|
|
@@ -23863,13 +23879,12 @@ var AssetManager = /** @class */ (function () {
|
|
|
23863
23879
|
img instanceof Texture) {
|
|
23864
23880
|
return [2 /*return*/, img];
|
|
23865
23881
|
}
|
|
23866
|
-
|
|
23867
|
-
case
|
|
23868
|
-
case
|
|
23869
|
-
_a =
|
|
23882
|
+
_b.label = 14;
|
|
23883
|
+
case 14: return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23884
|
+
case 15:
|
|
23885
|
+
_a = _b.sent(), url = _a.url, image = _a.image;
|
|
23870
23886
|
this.assets[idx] = { url: url, type: exports.TextureSourceType.image };
|
|
23871
23887
|
return [2 /*return*/, image];
|
|
23872
|
-
case 19: return [2 /*return*/, undefined];
|
|
23873
23888
|
}
|
|
23874
23889
|
});
|
|
23875
23890
|
}); });
|
|
@@ -25601,6 +25616,7 @@ exports.itemVert = itemVert;
|
|
|
25601
25616
|
exports.loadBinary = loadBinary;
|
|
25602
25617
|
exports.loadBlob = loadBlob;
|
|
25603
25618
|
exports.loadImage = loadImage;
|
|
25619
|
+
exports.loadMedia = loadMedia;
|
|
25604
25620
|
exports.loadVideo = loadVideo;
|
|
25605
25621
|
exports.loadWebPOptional = loadWebPOptional;
|
|
25606
25622
|
exports.logger = logger;
|