@galacean/effects-threejs 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/index.js +91 -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 +91 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v1.
|
|
6
|
+
* Version: v1.3.0-alpha.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -708,7 +708,7 @@ function asserts(condition, msg) {
|
|
|
708
708
|
* Name: @galacean/effects-specification
|
|
709
709
|
* Description: Galacean Effects JSON Specification
|
|
710
710
|
* Author: Ant Group CO., Ltd.
|
|
711
|
-
* Version: v1.0.
|
|
711
|
+
* Version: v1.1.0-alpha.0
|
|
712
712
|
*/
|
|
713
713
|
|
|
714
714
|
/*********************************************/
|
|
@@ -1089,6 +1089,16 @@ var CompositionEndBehavior$1;
|
|
|
1089
1089
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY$1] = "pause_destroy";
|
|
1090
1090
|
})(CompositionEndBehavior$1 || (CompositionEndBehavior$1 = {}));
|
|
1091
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* 动态换图类型
|
|
1094
|
+
* @since 1.3.0
|
|
1095
|
+
*/
|
|
1096
|
+
var BackgroundType$1;
|
|
1097
|
+
(function (BackgroundType) {
|
|
1098
|
+
BackgroundType["video"] = "video";
|
|
1099
|
+
BackgroundType["image"] = "image";
|
|
1100
|
+
})(BackgroundType$1 || (BackgroundType$1 = {}));
|
|
1101
|
+
|
|
1092
1102
|
/*********************************************/
|
|
1093
1103
|
/* 基本数值属性参数 */
|
|
1094
1104
|
/*********************************************/
|
|
@@ -1378,6 +1388,7 @@ var FontStyle$1;
|
|
|
1378
1388
|
|
|
1379
1389
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
1380
1390
|
__proto__: null,
|
|
1391
|
+
get BackgroundType () { return BackgroundType$1; },
|
|
1381
1392
|
get BezierKeyframeType () { return BezierKeyframeType$1; },
|
|
1382
1393
|
get BlendingMode () { return BlendingMode$1; },
|
|
1383
1394
|
BloomFilterThresholdAvgColor: BloomFilterThresholdAvgColor,
|
|
@@ -10175,10 +10186,8 @@ function loadBlob(url) {
|
|
|
10175
10186
|
/**
|
|
10176
10187
|
* 异步加载一个视频文件
|
|
10177
10188
|
* @param url - 视频文件的 URL 或 MediaProvider 对象
|
|
10178
|
-
* @param options - 加载参数
|
|
10179
10189
|
*/
|
|
10180
|
-
function loadVideo(url
|
|
10181
|
-
if (options === void 0) { options = {}; }
|
|
10190
|
+
function loadVideo(url) {
|
|
10182
10191
|
return __awaiter(this, void 0, void 0, function () {
|
|
10183
10192
|
var video;
|
|
10184
10193
|
return __generator(this, function (_a) {
|
|
@@ -10191,9 +10200,6 @@ function loadVideo(url, options) {
|
|
|
10191
10200
|
}
|
|
10192
10201
|
video.crossOrigin = 'anonymous';
|
|
10193
10202
|
video.muted = true;
|
|
10194
|
-
if (options.loop) {
|
|
10195
|
-
video.addEventListener('ended', function () { return video.play(); });
|
|
10196
|
-
}
|
|
10197
10203
|
if (isAndroid()) {
|
|
10198
10204
|
video.setAttribute('renderer', 'standard');
|
|
10199
10205
|
}
|
|
@@ -19677,6 +19683,26 @@ function getBackgroundImage(template, variables) {
|
|
|
19677
19683
|
}
|
|
19678
19684
|
return templateBackground;
|
|
19679
19685
|
}
|
|
19686
|
+
function loadMedia(url, loadFn) {
|
|
19687
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19688
|
+
return __generator(this, function (_a) {
|
|
19689
|
+
switch (_a.label) {
|
|
19690
|
+
case 0:
|
|
19691
|
+
if (!Array.isArray(url)) return [3 /*break*/, 5];
|
|
19692
|
+
_a.label = 1;
|
|
19693
|
+
case 1:
|
|
19694
|
+
_a.trys.push([1, 3, , 5]);
|
|
19695
|
+
return [4 /*yield*/, loadFn(url[0])];
|
|
19696
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
19697
|
+
case 3:
|
|
19698
|
+
_a.sent();
|
|
19699
|
+
return [4 /*yield*/, loadFn(url[1])];
|
|
19700
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
19701
|
+
case 5: return [2 /*return*/, loadFn(url)];
|
|
19702
|
+
}
|
|
19703
|
+
});
|
|
19704
|
+
});
|
|
19705
|
+
}
|
|
19680
19706
|
function drawImageAndTemplate(viewer, image, template, variables, opt) {
|
|
19681
19707
|
var _a;
|
|
19682
19708
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -21568,7 +21594,7 @@ var filters = {
|
|
|
21568
21594
|
* Name: @galacean/effects-specification
|
|
21569
21595
|
* Description: Galacean Effects JSON Specification
|
|
21570
21596
|
* Author: Ant Group CO., Ltd.
|
|
21571
|
-
* Version: v1.0.
|
|
21597
|
+
* Version: v1.1.0-alpha.0
|
|
21572
21598
|
*/
|
|
21573
21599
|
|
|
21574
21600
|
/*********************************************/
|
|
@@ -21947,6 +21973,16 @@ var CompositionEndBehavior;
|
|
|
21947
21973
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21948
21974
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21949
21975
|
|
|
21976
|
+
/**
|
|
21977
|
+
* 动态换图类型
|
|
21978
|
+
* @since 1.3.0
|
|
21979
|
+
*/
|
|
21980
|
+
var BackgroundType;
|
|
21981
|
+
(function (BackgroundType) {
|
|
21982
|
+
BackgroundType["video"] = "video";
|
|
21983
|
+
BackgroundType["image"] = "image";
|
|
21984
|
+
})(BackgroundType || (BackgroundType = {}));
|
|
21985
|
+
|
|
21950
21986
|
/*********************************************/
|
|
21951
21987
|
/* 基本数值属性参数 */
|
|
21952
21988
|
/*********************************************/
|
|
@@ -23031,11 +23067,9 @@ function getStandardImage(image, index, imageTags) {
|
|
|
23031
23067
|
else if (image.url) {
|
|
23032
23068
|
return {
|
|
23033
23069
|
url: image.url,
|
|
23034
|
-
type: image.type,
|
|
23035
23070
|
webp: image.webp,
|
|
23036
23071
|
renderLevel: renderLevel,
|
|
23037
23072
|
oriY: oriY,
|
|
23038
|
-
loop: image.loop,
|
|
23039
23073
|
};
|
|
23040
23074
|
}
|
|
23041
23075
|
else if (image && image.sourceType) {
|
|
@@ -23787,79 +23821,61 @@ var AssetManager = /** @class */ (function () {
|
|
|
23787
23821
|
_a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
|
|
23788
23822
|
baseUrl = this.baseUrl;
|
|
23789
23823
|
jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
|
|
23790
|
-
var png, webp, imageURL, webpURL, template,
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
switch (_e.label) {
|
|
23824
|
+
var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, resultImage, compressed, src, bufferURL, _a, url, image;
|
|
23825
|
+
return __generator(this, function (_b) {
|
|
23826
|
+
switch (_b.label) {
|
|
23794
23827
|
case 0:
|
|
23795
|
-
if (!usage[idx])
|
|
23828
|
+
if (!usage[idx]) {
|
|
23829
|
+
return [2 /*return*/, undefined];
|
|
23830
|
+
}
|
|
23796
23831
|
png = img.url, webp = img.webp;
|
|
23797
23832
|
imageURL = new URL(png, baseUrl).href;
|
|
23798
23833
|
webpURL = webp && new URL(webp, baseUrl).href;
|
|
23799
|
-
if (!('template' in img)) return [3 /*break*/,
|
|
23834
|
+
if (!('template' in img)) return [3 /*break*/, 13];
|
|
23800
23835
|
template = img.template;
|
|
23801
|
-
|
|
23802
|
-
|
|
23836
|
+
isTemplateV2 = 'v' in template && template.v === 2 && template.background;
|
|
23837
|
+
background = isTemplateV2 ? template.background : undefined;
|
|
23838
|
+
if (!(isTemplateV2 && background)) return [3 /*break*/, 8];
|
|
23803
23839
|
url_1 = getBackgroundImage(template, variables);
|
|
23804
|
-
|
|
23805
|
-
|
|
23806
|
-
|
|
23840
|
+
isVideo = background.type === BackgroundType$1.video;
|
|
23841
|
+
loadFn = background && isVideo ? loadVideo : loadImage;
|
|
23842
|
+
_b.label = 1;
|
|
23807
23843
|
case 1:
|
|
23808
|
-
|
|
23809
|
-
|
|
23810
|
-
return [4 /*yield*/, loadImage(url_1[0])];
|
|
23844
|
+
_b.trys.push([1, 6, , 7]);
|
|
23845
|
+
return [4 /*yield*/, loadMedia(url_1, loadFn)];
|
|
23811
23846
|
case 2:
|
|
23812
|
-
|
|
23813
|
-
|
|
23814
|
-
|
|
23815
|
-
return [3 /*break*/, 5];
|
|
23847
|
+
resultImage = _b.sent();
|
|
23848
|
+
if (!(resultImage instanceof HTMLVideoElement)) return [3 /*break*/, 3];
|
|
23849
|
+
return [2 /*return*/, resultImage];
|
|
23816
23850
|
case 3:
|
|
23817
|
-
|
|
23818
|
-
|
|
23819
|
-
|
|
23820
|
-
case 4:
|
|
23821
|
-
result = (_c.image = _e.sent(),
|
|
23822
|
-
_c.url = url_1[1],
|
|
23823
|
-
_c);
|
|
23824
|
-
return [3 /*break*/, 5];
|
|
23825
|
-
case 5:
|
|
23826
|
-
if (variables) {
|
|
23827
|
-
variables[name_1] = result.url;
|
|
23851
|
+
// 如果是加载图片且是数组,设置变量,视频情况下不需要
|
|
23852
|
+
if (background && !Array.isArray(url_1) && variables) {
|
|
23853
|
+
variables[background.name] = url_1;
|
|
23828
23854
|
}
|
|
23829
|
-
return [
|
|
23855
|
+
return [4 /*yield*/, combineImageTemplate(resultImage, template, variables, this.options, img.oriY === -1)];
|
|
23856
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
23857
|
+
case 5: return [3 /*break*/, 7];
|
|
23830
23858
|
case 6:
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
|
|
23834
|
-
case
|
|
23835
|
-
|
|
23836
|
-
|
|
23837
|
-
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
case
|
|
23841
|
-
case 10:
|
|
23842
|
-
// 测试场景:'年兽大爆炸——8个彩蛋t1'
|
|
23843
|
-
result = _e.sent();
|
|
23844
|
-
_e.label = 11;
|
|
23859
|
+
_b.sent();
|
|
23860
|
+
throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, "."));
|
|
23861
|
+
case 7: return [3 /*break*/, 12];
|
|
23862
|
+
case 8:
|
|
23863
|
+
_b.trys.push([8, 11, , 12]);
|
|
23864
|
+
return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23865
|
+
case 9:
|
|
23866
|
+
resultImage = _b.sent();
|
|
23867
|
+
return [4 /*yield*/, combineImageTemplate(resultImage.image, template, variables, this.options, img.oriY === -1)];
|
|
23868
|
+
case 10: return [2 /*return*/, _b.sent()];
|
|
23845
23869
|
case 11:
|
|
23846
|
-
|
|
23847
|
-
|
|
23848
|
-
case 12:
|
|
23849
|
-
_e.trys.push([12, 14, , 15]);
|
|
23850
|
-
return [4 /*yield*/, combineImageTemplate(result.image, template, variables, this.options, img.oriY === -1)];
|
|
23870
|
+
_b.sent();
|
|
23871
|
+
throw new Error("Failed to load. Check the template, URL: ".concat(imageURL, "."));
|
|
23872
|
+
case 12: return [3 /*break*/, 14];
|
|
23851
23873
|
case 13:
|
|
23852
|
-
templateImage = _e.sent();
|
|
23853
|
-
return [3 /*break*/, 15];
|
|
23854
|
-
case 14:
|
|
23855
|
-
_e.sent();
|
|
23856
|
-
throw new Error("image template fail: ".concat(imageURL));
|
|
23857
|
-
case 15: return [2 /*return*/, templateImage];
|
|
23858
|
-
case 16:
|
|
23859
23874
|
if ('type' in img && img.type === 'video') {
|
|
23860
|
-
loop = img.loop;
|
|
23861
23875
|
// 视频
|
|
23862
|
-
|
|
23876
|
+
// TODO: 2024.03.28 后面考虑下掉非推荐的视频元素使用方式
|
|
23877
|
+
console.warn('The video element is deprecated. Use template BackgroundType.video instead.');
|
|
23878
|
+
return [2 /*return*/, loadVideo(img.url)];
|
|
23863
23879
|
}
|
|
23864
23880
|
else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
23865
23881
|
compressed = img.compressed;
|
|
@@ -23885,13 +23901,12 @@ var AssetManager = /** @class */ (function () {
|
|
|
23885
23901
|
img instanceof Texture) {
|
|
23886
23902
|
return [2 /*return*/, img];
|
|
23887
23903
|
}
|
|
23888
|
-
|
|
23889
|
-
case
|
|
23890
|
-
case
|
|
23891
|
-
_a =
|
|
23904
|
+
_b.label = 14;
|
|
23905
|
+
case 14: return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23906
|
+
case 15:
|
|
23907
|
+
_a = _b.sent(), url = _a.url, image = _a.image;
|
|
23892
23908
|
this.assets[idx] = { url: url, type: exports.TextureSourceType.image };
|
|
23893
23909
|
return [2 /*return*/, image];
|
|
23894
|
-
case 19: return [2 /*return*/, undefined];
|
|
23895
23910
|
}
|
|
23896
23911
|
});
|
|
23897
23912
|
}); });
|
|
@@ -26935,7 +26950,7 @@ Geometry.create = function (engine, options) {
|
|
|
26935
26950
|
Mesh.create = function (engine, props) {
|
|
26936
26951
|
return new ThreeMesh(engine, props);
|
|
26937
26952
|
};
|
|
26938
|
-
var version = "1.
|
|
26953
|
+
var version = "1.3.0-alpha.0";
|
|
26939
26954
|
logger.info('THREEJS plugin version: ' + version);
|
|
26940
26955
|
|
|
26941
26956
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27141,6 +27156,7 @@ exports.itemVert = itemVert;
|
|
|
27141
27156
|
exports.loadBinary = loadBinary;
|
|
27142
27157
|
exports.loadBlob = loadBlob;
|
|
27143
27158
|
exports.loadImage = loadImage;
|
|
27159
|
+
exports.loadMedia = loadMedia;
|
|
27144
27160
|
exports.loadVideo = loadVideo;
|
|
27145
27161
|
exports.loadWebPOptional = loadWebPOptional;
|
|
27146
27162
|
exports.logger = logger;
|