@galacean/effects 1.2.2 → 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/index.js +113 -75
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +6 -6
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +113 -76
- package/dist/index.mjs.map +1 -1
- package/dist/weapp.js +112 -74
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +112 -75
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime player 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) {
|
|
@@ -23470,6 +23504,26 @@ var AssetManager = /** @class */ (function () {
|
|
|
23470
23504
|
var _a = options.timeout, timeout = _a === void 0 ? 10 : _a;
|
|
23471
23505
|
this.timeout = timeout;
|
|
23472
23506
|
};
|
|
23507
|
+
/**
|
|
23508
|
+
* 根据用户传入的参数修改场景数据
|
|
23509
|
+
*/
|
|
23510
|
+
AssetManager.prototype.updateSceneData = function (compositions) {
|
|
23511
|
+
var variables = this.options.variables;
|
|
23512
|
+
if (!variables || Object.keys(variables).length <= 0) {
|
|
23513
|
+
return compositions;
|
|
23514
|
+
}
|
|
23515
|
+
compositions.forEach(function (composition) {
|
|
23516
|
+
composition.items.forEach(function (item) {
|
|
23517
|
+
if (item.type === ItemType$1.text) {
|
|
23518
|
+
var textVariable = variables[item.name];
|
|
23519
|
+
if (textVariable) {
|
|
23520
|
+
item.content.options.text = textVariable;
|
|
23521
|
+
}
|
|
23522
|
+
}
|
|
23523
|
+
});
|
|
23524
|
+
});
|
|
23525
|
+
return compositions;
|
|
23526
|
+
};
|
|
23473
23527
|
/**
|
|
23474
23528
|
* 场景创建,通过 json 创建出场景对象,并进行提前编译等工作
|
|
23475
23529
|
* @param url - json 的 URL 链接或者 json 对象
|
|
@@ -23561,6 +23615,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23561
23615
|
for (i = 0; i < scene.images.length; i++) {
|
|
23562
23616
|
scene.textureOptions[i].image = scene.images[i];
|
|
23563
23617
|
}
|
|
23618
|
+
scene.jsonScene.compositions = this.updateSceneData(scene.jsonScene.compositions);
|
|
23564
23619
|
_e.label = 5;
|
|
23565
23620
|
case 5: return [3 /*break*/, 12];
|
|
23566
23621
|
case 6: return [4 /*yield*/, hookTimeInfo('processJSON', function () { return _this.processJSON(rawJSON); })];
|
|
@@ -23580,6 +23635,7 @@ var AssetManager = /** @class */ (function () {
|
|
|
23580
23635
|
return [4 /*yield*/, hookTimeInfo('processTextures', function () { return _this.processTextures(loadedImages_1, loadedBins_1, jsonScene_1); })];
|
|
23581
23636
|
case 10:
|
|
23582
23637
|
loadedTextures = _e.sent();
|
|
23638
|
+
jsonScene_1.compositions = this.updateSceneData(jsonScene_1.compositions);
|
|
23583
23639
|
scene = {
|
|
23584
23640
|
url: url,
|
|
23585
23641
|
renderLevel: this.options.renderLevel,
|
|
@@ -23743,79 +23799,61 @@ var AssetManager = /** @class */ (function () {
|
|
|
23743
23799
|
_a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
|
|
23744
23800
|
baseUrl = this.baseUrl;
|
|
23745
23801
|
jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
|
|
23746
|
-
var png, webp, imageURL, webpURL, template,
|
|
23747
|
-
|
|
23748
|
-
|
|
23749
|
-
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) {
|
|
23750
23805
|
case 0:
|
|
23751
|
-
if (!usage[idx])
|
|
23806
|
+
if (!usage[idx]) {
|
|
23807
|
+
return [2 /*return*/, undefined];
|
|
23808
|
+
}
|
|
23752
23809
|
png = img.url, webp = img.webp;
|
|
23753
23810
|
imageURL = new URL(png, baseUrl).href;
|
|
23754
23811
|
webpURL = webp && new URL(webp, baseUrl).href;
|
|
23755
|
-
if (!('template' in img)) return [3 /*break*/,
|
|
23812
|
+
if (!('template' in img)) return [3 /*break*/, 13];
|
|
23756
23813
|
template = img.template;
|
|
23757
|
-
|
|
23758
|
-
|
|
23814
|
+
isTemplateV2 = 'v' in template && template.v === 2 && template.background;
|
|
23815
|
+
background = isTemplateV2 ? template.background : undefined;
|
|
23816
|
+
if (!(isTemplateV2 && background)) return [3 /*break*/, 8];
|
|
23759
23817
|
url_1 = getBackgroundImage(template, variables);
|
|
23760
|
-
|
|
23761
|
-
|
|
23762
|
-
|
|
23818
|
+
isVideo = background.type === BackgroundType$1.video;
|
|
23819
|
+
loadFn = background && isVideo ? loadVideo : loadImage;
|
|
23820
|
+
_b.label = 1;
|
|
23763
23821
|
case 1:
|
|
23764
|
-
|
|
23765
|
-
|
|
23766
|
-
return [4 /*yield*/, loadImage(url_1[0])];
|
|
23822
|
+
_b.trys.push([1, 6, , 7]);
|
|
23823
|
+
return [4 /*yield*/, loadMedia(url_1, loadFn)];
|
|
23767
23824
|
case 2:
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
return [3 /*break*/, 5];
|
|
23825
|
+
resultImage = _b.sent();
|
|
23826
|
+
if (!(resultImage instanceof HTMLVideoElement)) return [3 /*break*/, 3];
|
|
23827
|
+
return [2 /*return*/, resultImage];
|
|
23772
23828
|
case 3:
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
case 4:
|
|
23777
|
-
result = (_c.image = _e.sent(),
|
|
23778
|
-
_c.url = url_1[1],
|
|
23779
|
-
_c);
|
|
23780
|
-
return [3 /*break*/, 5];
|
|
23781
|
-
case 5:
|
|
23782
|
-
if (variables) {
|
|
23783
|
-
variables[name_1] = result.url;
|
|
23829
|
+
// 如果是加载图片且是数组,设置变量,视频情况下不需要
|
|
23830
|
+
if (background && !Array.isArray(url_1) && variables) {
|
|
23831
|
+
variables[background.name] = url_1;
|
|
23784
23832
|
}
|
|
23785
|
-
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];
|
|
23786
23836
|
case 6:
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
case
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
|
|
23796
|
-
case
|
|
23797
|
-
case 10:
|
|
23798
|
-
// 测试场景:'年兽大爆炸——8个彩蛋t1'
|
|
23799
|
-
result = _e.sent();
|
|
23800
|
-
_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()];
|
|
23801
23847
|
case 11:
|
|
23802
|
-
|
|
23803
|
-
|
|
23804
|
-
case 12:
|
|
23805
|
-
_e.trys.push([12, 14, , 15]);
|
|
23806
|
-
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];
|
|
23807
23851
|
case 13:
|
|
23808
|
-
templateImage = _e.sent();
|
|
23809
|
-
return [3 /*break*/, 15];
|
|
23810
|
-
case 14:
|
|
23811
|
-
_e.sent();
|
|
23812
|
-
throw new Error("image template fail: ".concat(imageURL));
|
|
23813
|
-
case 15: return [2 /*return*/, templateImage];
|
|
23814
|
-
case 16:
|
|
23815
23852
|
if ('type' in img && img.type === 'video') {
|
|
23816
|
-
loop = img.loop;
|
|
23817
23853
|
// 视频
|
|
23818
|
-
|
|
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)];
|
|
23819
23857
|
}
|
|
23820
23858
|
else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
23821
23859
|
compressed = img.compressed;
|
|
@@ -23841,13 +23879,12 @@ var AssetManager = /** @class */ (function () {
|
|
|
23841
23879
|
img instanceof Texture) {
|
|
23842
23880
|
return [2 /*return*/, img];
|
|
23843
23881
|
}
|
|
23844
|
-
|
|
23845
|
-
case
|
|
23846
|
-
case
|
|
23847
|
-
_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;
|
|
23848
23886
|
this.assets[idx] = { url: url, type: exports.TextureSourceType.image };
|
|
23849
23887
|
return [2 /*return*/, image];
|
|
23850
|
-
case 19: return [2 /*return*/, undefined];
|
|
23851
23888
|
}
|
|
23852
23889
|
});
|
|
23853
23890
|
}); });
|
|
@@ -30424,7 +30461,7 @@ Renderer.create = function (canvas, framework, renderOptions) {
|
|
|
30424
30461
|
Engine.create = function (gl) {
|
|
30425
30462
|
return new GLEngine(gl);
|
|
30426
30463
|
};
|
|
30427
|
-
var version = "1.
|
|
30464
|
+
var version = "1.3.0-alpha.0";
|
|
30428
30465
|
logger.info('player version: ' + version);
|
|
30429
30466
|
|
|
30430
30467
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -30630,6 +30667,7 @@ exports.itemVert = itemVert;
|
|
|
30630
30667
|
exports.loadBinary = loadBinary;
|
|
30631
30668
|
exports.loadBlob = loadBlob;
|
|
30632
30669
|
exports.loadImage = loadImage;
|
|
30670
|
+
exports.loadMedia = loadMedia;
|
|
30633
30671
|
exports.loadVideo = loadVideo;
|
|
30634
30672
|
exports.loadWebPOptional = loadWebPOptional;
|
|
30635
30673
|
exports.logger = logger;
|