@galacean/effects-specification 2.0.0-alpha.3 → 2.0.0-alpha.4
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/fallback/index.d.ts +2 -2
- package/dist/fallback.js +159 -178
- package/dist/fallback.js.map +1 -1
- package/dist/fallback.mjs +159 -178
- package/dist/fallback.mjs.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -2
- package/dist/index.mjs.map +1 -1
- package/dist/src/components.d.ts +38 -0
- package/dist/src/image.d.ts +9 -4
- package/dist/src/item/model/mesh.d.ts +3 -3
- package/dist/src/scene.d.ts +2 -1
- package/dist/src/type.d.ts +20 -4
- package/dist/src/vfx-item-data.d.ts +2 -2
- package/package.json +2 -2
package/dist/fallback.mjs
CHANGED
|
@@ -2,9 +2,79 @@
|
|
|
2
2
|
* Name: @galacean/effects-specification
|
|
3
3
|
* Description: Galacean Effects JSON Specification
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
|
-
* Version: v2.0.0-alpha.
|
|
5
|
+
* Version: v2.0.0-alpha.4
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
|
|
23
|
+
var __assign = function() {
|
|
24
|
+
__assign = Object.assign || function __assign(t) {
|
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
+
s = arguments[i];
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
};
|
|
31
|
+
return __assign.apply(this, arguments);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function __values(o) {
|
|
35
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
36
|
+
if (m) return m.call(o);
|
|
37
|
+
if (o && typeof o.length === "number") return {
|
|
38
|
+
next: function () {
|
|
39
|
+
if (o && i >= o.length) o = void 0;
|
|
40
|
+
return { value: o && o[i++], done: !o };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function __read(o, n) {
|
|
47
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
48
|
+
if (!m) return o;
|
|
49
|
+
var i = m.call(o), r, ar = [], e;
|
|
50
|
+
try {
|
|
51
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
52
|
+
}
|
|
53
|
+
catch (error) { e = { error: error }; }
|
|
54
|
+
finally {
|
|
55
|
+
try {
|
|
56
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
57
|
+
}
|
|
58
|
+
finally { if (e) throw e.error; }
|
|
59
|
+
}
|
|
60
|
+
return ar;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function __spreadArray(to, from, pack) {
|
|
64
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
+
if (ar || !(i in from)) {
|
|
66
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
+
ar[i] = from[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
74
|
+
var e = new Error(message);
|
|
75
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
76
|
+
};
|
|
77
|
+
|
|
8
78
|
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
9
79
|
var native = {
|
|
10
80
|
randomUUID
|
|
@@ -454,6 +524,16 @@ var CompositionEndBehavior;
|
|
|
454
524
|
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
455
525
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
456
526
|
|
|
527
|
+
/**
|
|
528
|
+
* 动态换图类型
|
|
529
|
+
* @since 1.3.0
|
|
530
|
+
*/
|
|
531
|
+
var BackgroundType;
|
|
532
|
+
(function (BackgroundType) {
|
|
533
|
+
BackgroundType["video"] = "video";
|
|
534
|
+
BackgroundType["image"] = "image";
|
|
535
|
+
})(BackgroundType || (BackgroundType = {}));
|
|
536
|
+
|
|
457
537
|
/*********************************************/
|
|
458
538
|
/* 基本数值属性参数 */
|
|
459
539
|
/*********************************************/
|
|
@@ -786,76 +866,37 @@ var DataType;
|
|
|
786
866
|
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
787
867
|
DataType["TreeComponent"] = "TreeComponent";
|
|
788
868
|
})(DataType || (DataType = {}));
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
next: function () {
|
|
821
|
-
if (o && i >= o.length) o = void 0;
|
|
822
|
-
return { value: o && o[i++], done: !o };
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
function __read(o, n) {
|
|
829
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
830
|
-
if (!m) return o;
|
|
831
|
-
var i = m.call(o), r, ar = [], e;
|
|
832
|
-
try {
|
|
833
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
834
|
-
}
|
|
835
|
-
catch (error) { e = { error: error }; }
|
|
836
|
-
finally {
|
|
837
|
-
try {
|
|
838
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
839
|
-
}
|
|
840
|
-
finally { if (e) throw e.error; }
|
|
841
|
-
}
|
|
842
|
-
return ar;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function __spreadArray(to, from, pack) {
|
|
846
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
847
|
-
if (ar || !(i in from)) {
|
|
848
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
849
|
-
ar[i] = from[i];
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
856
|
-
var e = new Error(message);
|
|
857
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
858
|
-
};
|
|
869
|
+
var GeometryType;
|
|
870
|
+
(function (GeometryType) {
|
|
871
|
+
/**
|
|
872
|
+
* Draw single points.
|
|
873
|
+
*/
|
|
874
|
+
GeometryType[GeometryType["POINTS"] = 0] = "POINTS";
|
|
875
|
+
/**
|
|
876
|
+
* Draw lines. Each vertex connects to the one after it.
|
|
877
|
+
*/
|
|
878
|
+
GeometryType[GeometryType["LINES"] = 1] = "LINES";
|
|
879
|
+
/**
|
|
880
|
+
* Draw lines. Each set of two vertices is treated as a separate line segment.
|
|
881
|
+
*/
|
|
882
|
+
GeometryType[GeometryType["LINE_LOOP"] = 2] = "LINE_LOOP";
|
|
883
|
+
/**
|
|
884
|
+
* Draw a connected group of line segments from the first vertex to the last.
|
|
885
|
+
*/
|
|
886
|
+
GeometryType[GeometryType["LINE_STRIP"] = 3] = "LINE_STRIP";
|
|
887
|
+
/**
|
|
888
|
+
* Draw triangles. Each set of three vertices creates a separate triangle.
|
|
889
|
+
*/
|
|
890
|
+
GeometryType[GeometryType["TRIANGLES"] = 4] = "TRIANGLES";
|
|
891
|
+
/**
|
|
892
|
+
* Draw a connected strip of triangles.
|
|
893
|
+
*/
|
|
894
|
+
GeometryType[GeometryType["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP";
|
|
895
|
+
/**
|
|
896
|
+
* Draw a connected group of triangles. Each vertex connects to the previous and the first vertex in the fan.
|
|
897
|
+
*/
|
|
898
|
+
GeometryType[GeometryType["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN";
|
|
899
|
+
})(GeometryType || (GeometryType = {}));
|
|
859
900
|
|
|
860
901
|
var _a;
|
|
861
902
|
function arrAdd(arr, item) {
|
|
@@ -1538,20 +1579,13 @@ function version22Migration(json) {
|
|
|
1538
1579
|
function version30Migration(json) {
|
|
1539
1580
|
var e_1, _a;
|
|
1540
1581
|
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1541
|
-
var result =
|
|
1542
|
-
items: [],
|
|
1543
|
-
components: [],
|
|
1544
|
-
materials: [],
|
|
1545
|
-
shaders: [],
|
|
1546
|
-
geometries: [],
|
|
1547
|
-
});
|
|
1582
|
+
var result = __assign(__assign({}, json), { items: [], components: [], materials: [], shaders: [], geometries: [] });
|
|
1548
1583
|
// 兼容老版本数据中不存在textures的情况
|
|
1549
1584
|
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
1550
1585
|
result.textures.forEach(function (textureOptions) {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
dataType: DataType.Texture
|
|
1554
|
-
});
|
|
1586
|
+
textureOptions = __assign(__assign({}, textureOptions), {
|
|
1587
|
+
// @ts-expect-error
|
|
1588
|
+
id: generateGUID(), dataType: DataType.Texture });
|
|
1555
1589
|
});
|
|
1556
1590
|
if (result.textures.length < result.images.length) {
|
|
1557
1591
|
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
@@ -1635,7 +1669,7 @@ function version30Migration(json) {
|
|
|
1635
1669
|
Object.assign(item, {
|
|
1636
1670
|
transform: {
|
|
1637
1671
|
position: { x: position[0], y: position[1], z: position[2] },
|
|
1638
|
-
|
|
1672
|
+
eulerHint: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1639
1673
|
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1640
1674
|
},
|
|
1641
1675
|
});
|
|
@@ -1705,105 +1739,54 @@ function version30Migration(json) {
|
|
|
1705
1739
|
}
|
|
1706
1740
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1707
1741
|
var uuid = generateGUID();
|
|
1708
|
-
if (item.type === ItemType.sprite
|
|
1709
|
-
item.
|
|
1710
|
-
|
|
1711
|
-
item.
|
|
1712
|
-
item.
|
|
1713
|
-
item.
|
|
1714
|
-
item.
|
|
1715
|
-
|
|
1716
|
-
item.
|
|
1717
|
-
|
|
1718
|
-
else if (item.type === ItemType.particle) {
|
|
1719
|
-
item.components = [];
|
|
1720
|
-
result.components.push(item.content);
|
|
1721
|
-
item.content.id = uuid;
|
|
1722
|
-
item.content.dataType = DataType.ParticleSystem;
|
|
1723
|
-
item.content.item = { id: item.id };
|
|
1724
|
-
item.dataType = DataType.VFXItemData;
|
|
1725
|
-
//@ts-expect-error
|
|
1726
|
-
item.components.push({ id: item.content.id });
|
|
1727
|
-
}
|
|
1728
|
-
else if (item.type === ItemType.mesh) {
|
|
1729
|
-
item.components = [];
|
|
1730
|
-
result.components.push(item.content);
|
|
1731
|
-
item.content.id = uuid;
|
|
1732
|
-
item.content.dataType = DataType.MeshComponent;
|
|
1733
|
-
item.content.item = { id: item.id };
|
|
1734
|
-
item.dataType = DataType.VFXItemData;
|
|
1735
|
-
//@ts-expect-error
|
|
1736
|
-
item.components.push({ id: item.content.id });
|
|
1737
|
-
}
|
|
1738
|
-
else if (item.type === ItemType.skybox) {
|
|
1739
|
-
item.components = [];
|
|
1740
|
-
result.components.push(item.content);
|
|
1741
|
-
item.content.id = uuid;
|
|
1742
|
-
item.content.dataType = DataType.SkyboxComponent;
|
|
1743
|
-
item.content.item = { id: item.id };
|
|
1744
|
-
item.dataType = DataType.VFXItemData;
|
|
1745
|
-
//@ts-expect-error
|
|
1746
|
-
item.components.push({ id: item.content.id });
|
|
1747
|
-
}
|
|
1748
|
-
else if (item.type === ItemType.light) {
|
|
1749
|
-
item.components = [];
|
|
1750
|
-
result.components.push(item.content);
|
|
1751
|
-
item.content.id = uuid;
|
|
1752
|
-
item.content.dataType = DataType.LightComponent;
|
|
1753
|
-
item.content.item = { id: item.id };
|
|
1754
|
-
item.dataType = DataType.VFXItemData;
|
|
1755
|
-
//@ts-expect-error
|
|
1756
|
-
item.components.push({ id: item.content.id });
|
|
1757
|
-
}
|
|
1758
|
-
else if (item.type === 'camera') {
|
|
1759
|
-
item.components = [];
|
|
1760
|
-
result.components.push(item.content);
|
|
1761
|
-
item.content.id = uuid;
|
|
1762
|
-
item.content.dataType = DataType.CameraComponent;
|
|
1763
|
-
item.content.item = { id: item.id };
|
|
1764
|
-
item.dataType = DataType.VFXItemData;
|
|
1765
|
-
//@ts-expect-error
|
|
1766
|
-
item.components.push({ id: item.content.id });
|
|
1767
|
-
}
|
|
1768
|
-
else if (item.type === ItemType.tree) {
|
|
1742
|
+
if (item.type === ItemType.sprite ||
|
|
1743
|
+
item.type === ItemType.particle ||
|
|
1744
|
+
item.type === ItemType.mesh ||
|
|
1745
|
+
item.type === ItemType.skybox ||
|
|
1746
|
+
item.type === ItemType.light ||
|
|
1747
|
+
item.type === 'camera' ||
|
|
1748
|
+
item.type === ItemType.tree ||
|
|
1749
|
+
item.type === ItemType.interact ||
|
|
1750
|
+
item.type === ItemType.camera ||
|
|
1751
|
+
item.type === ItemType.text) {
|
|
1769
1752
|
item.components = [];
|
|
1770
1753
|
result.components.push(item.content);
|
|
1771
1754
|
item.content.id = uuid;
|
|
1772
|
-
item.content.dataType = DataType.TreeComponent;
|
|
1773
1755
|
item.content.item = { id: item.id };
|
|
1774
1756
|
item.dataType = DataType.VFXItemData;
|
|
1775
|
-
//@ts-expect-error
|
|
1776
1757
|
item.components.push({ id: item.content.id });
|
|
1777
1758
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1759
|
+
switch (item.type) {
|
|
1760
|
+
case ItemType.sprite:
|
|
1761
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
1762
|
+
break;
|
|
1763
|
+
case ItemType.particle:
|
|
1764
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
1765
|
+
break;
|
|
1766
|
+
case ItemType.mesh:
|
|
1767
|
+
item.content.dataType = DataType.MeshComponent;
|
|
1768
|
+
break;
|
|
1769
|
+
case ItemType.skybox:
|
|
1770
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
1771
|
+
break;
|
|
1772
|
+
case ItemType.light:
|
|
1773
|
+
item.content.dataType = DataType.LightComponent;
|
|
1774
|
+
break;
|
|
1775
|
+
case 'camera':
|
|
1776
|
+
item.content.dataType = DataType.CameraComponent;
|
|
1777
|
+
break;
|
|
1778
|
+
case ItemType.tree:
|
|
1779
|
+
item.content.dataType = DataType.TreeComponent;
|
|
1780
|
+
break;
|
|
1781
|
+
case ItemType.interact:
|
|
1782
|
+
item.content.dataType = DataType.InteractComponent;
|
|
1783
|
+
break;
|
|
1784
|
+
case ItemType.camera:
|
|
1785
|
+
item.content.dataType = DataType.CameraController;
|
|
1786
|
+
break;
|
|
1787
|
+
case ItemType.text:
|
|
1788
|
+
item.content.dataType = DataType.TextComponent;
|
|
1789
|
+
break;
|
|
1807
1790
|
}
|
|
1808
1791
|
}
|
|
1809
1792
|
}
|
|
@@ -1925,11 +1908,9 @@ function getStandardImage(image, index, imageTags) {
|
|
|
1925
1908
|
else if (image.url) {
|
|
1926
1909
|
return {
|
|
1927
1910
|
url: image.url,
|
|
1928
|
-
type: image.type,
|
|
1929
1911
|
webp: image.webp,
|
|
1930
1912
|
renderLevel: renderLevel,
|
|
1931
1913
|
oriY: oriY,
|
|
1932
|
-
loop: image.loop,
|
|
1933
1914
|
};
|
|
1934
1915
|
}
|
|
1935
1916
|
else if (image && image.sourceType) {
|
|
@@ -1942,7 +1923,7 @@ function getStandardComposition(composition, opt) {
|
|
|
1942
1923
|
if (opt === void 0) { opt = {}; }
|
|
1943
1924
|
var ret = {
|
|
1944
1925
|
id: composition.id + '',
|
|
1945
|
-
camera:
|
|
1926
|
+
camera: __assign({ clipMode: CAMERA_CLIP_MODE_NORMAL }, composition.camera),
|
|
1946
1927
|
duration: composition.duration,
|
|
1947
1928
|
endBehavior: composition.endBehavior,
|
|
1948
1929
|
items: composition.items.map(function (item) { return getStandardItem(item, opt); }),
|