@galacean/effects-threejs 1.2.6 → 1.3.0-alpha.1
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 +93 -77
- 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 +93 -78
- 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.1
|
|
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.1
|
|
711
|
+
* Version: v1.1.0-alpha.1
|
|
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
|
}
|
|
@@ -19682,6 +19688,26 @@ function getBackgroundImage(template, variables) {
|
|
|
19682
19688
|
}
|
|
19683
19689
|
return templateBackground;
|
|
19684
19690
|
}
|
|
19691
|
+
function loadMedia(url, loadFn) {
|
|
19692
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19693
|
+
return __generator(this, function (_a) {
|
|
19694
|
+
switch (_a.label) {
|
|
19695
|
+
case 0:
|
|
19696
|
+
if (!Array.isArray(url)) return [3 /*break*/, 5];
|
|
19697
|
+
_a.label = 1;
|
|
19698
|
+
case 1:
|
|
19699
|
+
_a.trys.push([1, 3, , 5]);
|
|
19700
|
+
return [4 /*yield*/, loadFn(url[0])];
|
|
19701
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
19702
|
+
case 3:
|
|
19703
|
+
_a.sent();
|
|
19704
|
+
return [4 /*yield*/, loadFn(url[1])];
|
|
19705
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
19706
|
+
case 5: return [2 /*return*/, loadFn(url)];
|
|
19707
|
+
}
|
|
19708
|
+
});
|
|
19709
|
+
});
|
|
19710
|
+
}
|
|
19685
19711
|
function drawImageAndTemplate(viewer, image, template, variables, opt) {
|
|
19686
19712
|
var _a;
|
|
19687
19713
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -21573,7 +21599,7 @@ var filters = {
|
|
|
21573
21599
|
* Name: @galacean/effects-specification
|
|
21574
21600
|
* Description: Galacean Effects JSON Specification
|
|
21575
21601
|
* Author: Ant Group CO., Ltd.
|
|
21576
|
-
* Version: v1.0.1
|
|
21602
|
+
* Version: v1.1.0-alpha.1
|
|
21577
21603
|
*/
|
|
21578
21604
|
|
|
21579
21605
|
/*********************************************/
|
|
@@ -21952,6 +21978,16 @@ var CompositionEndBehavior;
|
|
|
21952
21978
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
21953
21979
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
21954
21980
|
|
|
21981
|
+
/**
|
|
21982
|
+
* 动态换图类型
|
|
21983
|
+
* @since 1.3.0
|
|
21984
|
+
*/
|
|
21985
|
+
var BackgroundType;
|
|
21986
|
+
(function (BackgroundType) {
|
|
21987
|
+
BackgroundType["video"] = "video";
|
|
21988
|
+
BackgroundType["image"] = "image";
|
|
21989
|
+
})(BackgroundType || (BackgroundType = {}));
|
|
21990
|
+
|
|
21955
21991
|
/*********************************************/
|
|
21956
21992
|
/* 基本数值属性参数 */
|
|
21957
21993
|
/*********************************************/
|
|
@@ -23036,11 +23072,9 @@ function getStandardImage(image, index, imageTags) {
|
|
|
23036
23072
|
else if (image.url) {
|
|
23037
23073
|
return {
|
|
23038
23074
|
url: image.url,
|
|
23039
|
-
type: image.type,
|
|
23040
23075
|
webp: image.webp,
|
|
23041
23076
|
renderLevel: renderLevel,
|
|
23042
23077
|
oriY: oriY,
|
|
23043
|
-
loop: image.loop,
|
|
23044
23078
|
};
|
|
23045
23079
|
}
|
|
23046
23080
|
else if (image && image.sourceType) {
|
|
@@ -23794,79 +23828,61 @@ var AssetManager = /** @class */ (function () {
|
|
|
23794
23828
|
_a = this.options, useCompressedTexture = _a.useCompressedTexture, variables = _a.variables;
|
|
23795
23829
|
baseUrl = this.baseUrl;
|
|
23796
23830
|
jobs = images.map(function (img, idx) { return __awaiter(_this, void 0, void 0, function () {
|
|
23797
|
-
var png, webp, imageURL, webpURL, template,
|
|
23798
|
-
|
|
23799
|
-
|
|
23800
|
-
switch (_e.label) {
|
|
23831
|
+
var png, webp, imageURL, webpURL, template, isTemplateV2, background, url_1, isVideo, loadFn, resultImage, resultImage, compressed, src, bufferURL, _a, url, image;
|
|
23832
|
+
return __generator(this, function (_b) {
|
|
23833
|
+
switch (_b.label) {
|
|
23801
23834
|
case 0:
|
|
23802
|
-
if (!usage[idx])
|
|
23835
|
+
if (!usage[idx]) {
|
|
23836
|
+
return [2 /*return*/, undefined];
|
|
23837
|
+
}
|
|
23803
23838
|
png = img.url, webp = img.webp;
|
|
23804
23839
|
imageURL = new URL(png, baseUrl).href;
|
|
23805
23840
|
webpURL = webp && new URL(webp, baseUrl).href;
|
|
23806
|
-
if (!('template' in img)) return [3 /*break*/,
|
|
23841
|
+
if (!('template' in img)) return [3 /*break*/, 13];
|
|
23807
23842
|
template = img.template;
|
|
23808
|
-
|
|
23809
|
-
|
|
23843
|
+
isTemplateV2 = 'v' in template && template.v === 2 && template.background;
|
|
23844
|
+
background = isTemplateV2 ? template.background : undefined;
|
|
23845
|
+
if (!(isTemplateV2 && background)) return [3 /*break*/, 8];
|
|
23810
23846
|
url_1 = getBackgroundImage(template, variables);
|
|
23811
|
-
|
|
23812
|
-
|
|
23813
|
-
|
|
23847
|
+
isVideo = background.type === BackgroundType$1.video;
|
|
23848
|
+
loadFn = background && isVideo ? loadVideo : loadImage;
|
|
23849
|
+
_b.label = 1;
|
|
23814
23850
|
case 1:
|
|
23815
|
-
|
|
23816
|
-
|
|
23817
|
-
return [4 /*yield*/, loadImage(url_1[0])];
|
|
23851
|
+
_b.trys.push([1, 6, , 7]);
|
|
23852
|
+
return [4 /*yield*/, loadMedia(url_1, loadFn)];
|
|
23818
23853
|
case 2:
|
|
23819
|
-
|
|
23820
|
-
|
|
23821
|
-
|
|
23822
|
-
return [3 /*break*/, 5];
|
|
23854
|
+
resultImage = _b.sent();
|
|
23855
|
+
if (!(resultImage instanceof HTMLVideoElement)) return [3 /*break*/, 3];
|
|
23856
|
+
return [2 /*return*/, resultImage];
|
|
23823
23857
|
case 3:
|
|
23824
|
-
|
|
23825
|
-
|
|
23826
|
-
|
|
23827
|
-
case 4:
|
|
23828
|
-
result = (_c.image = _e.sent(),
|
|
23829
|
-
_c.url = url_1[1],
|
|
23830
|
-
_c);
|
|
23831
|
-
return [3 /*break*/, 5];
|
|
23832
|
-
case 5:
|
|
23833
|
-
if (variables) {
|
|
23834
|
-
variables[name_1] = result.url;
|
|
23858
|
+
// 如果是加载图片且是数组,设置变量,视频情况下不需要
|
|
23859
|
+
if (background && !Array.isArray(url_1) && variables) {
|
|
23860
|
+
variables[background.name] = url_1;
|
|
23835
23861
|
}
|
|
23836
|
-
return [
|
|
23862
|
+
return [4 /*yield*/, combineImageTemplate(resultImage, template, variables, this.options, img.oriY === -1)];
|
|
23863
|
+
case 4: return [2 /*return*/, _b.sent()];
|
|
23864
|
+
case 5: return [3 /*break*/, 7];
|
|
23837
23865
|
case 6:
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
case
|
|
23842
|
-
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
case
|
|
23848
|
-
case 10:
|
|
23849
|
-
// 测试场景:'年兽大爆炸——8个彩蛋t1'
|
|
23850
|
-
result = _e.sent();
|
|
23851
|
-
_e.label = 11;
|
|
23866
|
+
_b.sent();
|
|
23867
|
+
throw new Error("Failed to load. Check the template or if the URL is ".concat(isVideo ? 'video' : 'image', " type, URL: ").concat(url_1, "."));
|
|
23868
|
+
case 7: return [3 /*break*/, 12];
|
|
23869
|
+
case 8:
|
|
23870
|
+
_b.trys.push([8, 11, , 12]);
|
|
23871
|
+
return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23872
|
+
case 9:
|
|
23873
|
+
resultImage = _b.sent();
|
|
23874
|
+
return [4 /*yield*/, combineImageTemplate(resultImage.image, template, variables, this.options, img.oriY === -1)];
|
|
23875
|
+
case 10: return [2 /*return*/, _b.sent()];
|
|
23852
23876
|
case 11:
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
case 12:
|
|
23856
|
-
_e.trys.push([12, 14, , 15]);
|
|
23857
|
-
return [4 /*yield*/, combineImageTemplate(result.image, template, variables, this.options, img.oriY === -1)];
|
|
23877
|
+
_b.sent();
|
|
23878
|
+
throw new Error("Failed to load. Check the template, URL: ".concat(imageURL, "."));
|
|
23879
|
+
case 12: return [3 /*break*/, 14];
|
|
23858
23880
|
case 13:
|
|
23859
|
-
templateImage = _e.sent();
|
|
23860
|
-
return [3 /*break*/, 15];
|
|
23861
|
-
case 14:
|
|
23862
|
-
_e.sent();
|
|
23863
|
-
throw new Error("image template fail: ".concat(imageURL));
|
|
23864
|
-
case 15: return [2 /*return*/, templateImage];
|
|
23865
|
-
case 16:
|
|
23866
23881
|
if ('type' in img && img.type === 'video') {
|
|
23867
|
-
loop = img.loop;
|
|
23868
23882
|
// 视频
|
|
23869
|
-
|
|
23883
|
+
// TODO: 2024.03.28 后面考虑下掉非推荐的视频元素使用方式
|
|
23884
|
+
console.warn('The video element is deprecated. Use template BackgroundType.video instead.');
|
|
23885
|
+
return [2 /*return*/, loadVideo(img.url)];
|
|
23870
23886
|
}
|
|
23871
23887
|
else if ('compressed' in img && useCompressedTexture && compressedTexture) {
|
|
23872
23888
|
compressed = img.compressed;
|
|
@@ -23892,13 +23908,12 @@ var AssetManager = /** @class */ (function () {
|
|
|
23892
23908
|
img instanceof Texture) {
|
|
23893
23909
|
return [2 /*return*/, img];
|
|
23894
23910
|
}
|
|
23895
|
-
|
|
23896
|
-
case
|
|
23897
|
-
case
|
|
23898
|
-
_a =
|
|
23911
|
+
_b.label = 14;
|
|
23912
|
+
case 14: return [4 /*yield*/, loadWebPOptional(imageURL, webpURL)];
|
|
23913
|
+
case 15:
|
|
23914
|
+
_a = _b.sent(), url = _a.url, image = _a.image;
|
|
23899
23915
|
this.assets[idx] = { url: url, type: exports.TextureSourceType.image };
|
|
23900
23916
|
return [2 /*return*/, image];
|
|
23901
|
-
case 19: return [2 /*return*/, undefined];
|
|
23902
23917
|
}
|
|
23903
23918
|
});
|
|
23904
23919
|
}); });
|
|
@@ -24045,10 +24060,10 @@ function createTextureOptionsBySource(image, sourceFrom) {
|
|
|
24045
24060
|
}
|
|
24046
24061
|
throw new Error('Invalid texture options');
|
|
24047
24062
|
}
|
|
24048
|
-
function isCanvas(
|
|
24063
|
+
function isCanvas(canvas) {
|
|
24049
24064
|
var _a;
|
|
24050
24065
|
// 小程序 Canvas 无法使用 instanceof HTMLCanvasElement 判断
|
|
24051
|
-
return typeof
|
|
24066
|
+
return typeof canvas === 'object' && canvas !== null && ((_a = canvas.tagName) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'CANVAS';
|
|
24052
24067
|
}
|
|
24053
24068
|
|
|
24054
24069
|
var CompVFXItem = /** @class */ (function (_super) {
|
|
@@ -26947,7 +26962,7 @@ Geometry.create = function (engine, options) {
|
|
|
26947
26962
|
Mesh.create = function (engine, props) {
|
|
26948
26963
|
return new ThreeMesh(engine, props);
|
|
26949
26964
|
};
|
|
26950
|
-
var version = "1.
|
|
26965
|
+
var version = "1.3.0-alpha.1";
|
|
26951
26966
|
logger.info('THREEJS plugin version: ' + version);
|
|
26952
26967
|
|
|
26953
26968
|
exports.AbstractPlugin = AbstractPlugin;
|
|
@@ -27153,6 +27168,7 @@ exports.itemVert = itemVert;
|
|
|
27153
27168
|
exports.loadBinary = loadBinary;
|
|
27154
27169
|
exports.loadBlob = loadBlob;
|
|
27155
27170
|
exports.loadImage = loadImage;
|
|
27171
|
+
exports.loadMedia = loadMedia;
|
|
27156
27172
|
exports.loadVideo = loadVideo;
|
|
27157
27173
|
exports.loadWebPOptional = loadWebPOptional;
|
|
27158
27174
|
exports.logger = logger;
|