@galacean/effects-specification 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +160 -178
- package/dist/fallback.js.map +1 -1
- package/dist/fallback.mjs +160 -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.5
|
|
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,14 @@ 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
|
-
|
|
1554
|
-
|
|
1586
|
+
//@ts-expect-error
|
|
1587
|
+
textureOptions.id = generateGUID();
|
|
1588
|
+
//@ts-expect-error
|
|
1589
|
+
textureOptions.dataType = DataType.Texture;
|
|
1555
1590
|
});
|
|
1556
1591
|
if (result.textures.length < result.images.length) {
|
|
1557
1592
|
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
@@ -1635,7 +1670,7 @@ function version30Migration(json) {
|
|
|
1635
1670
|
Object.assign(item, {
|
|
1636
1671
|
transform: {
|
|
1637
1672
|
position: { x: position[0], y: position[1], z: position[2] },
|
|
1638
|
-
|
|
1673
|
+
eulerHint: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1639
1674
|
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1640
1675
|
},
|
|
1641
1676
|
});
|
|
@@ -1705,105 +1740,54 @@ function version30Migration(json) {
|
|
|
1705
1740
|
}
|
|
1706
1741
|
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1707
1742
|
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) {
|
|
1743
|
+
if (item.type === ItemType.sprite ||
|
|
1744
|
+
item.type === ItemType.particle ||
|
|
1745
|
+
item.type === ItemType.mesh ||
|
|
1746
|
+
item.type === ItemType.skybox ||
|
|
1747
|
+
item.type === ItemType.light ||
|
|
1748
|
+
item.type === 'camera' ||
|
|
1749
|
+
item.type === ItemType.tree ||
|
|
1750
|
+
item.type === ItemType.interact ||
|
|
1751
|
+
item.type === ItemType.camera ||
|
|
1752
|
+
item.type === ItemType.text) {
|
|
1769
1753
|
item.components = [];
|
|
1770
1754
|
result.components.push(item.content);
|
|
1771
1755
|
item.content.id = uuid;
|
|
1772
|
-
item.content.dataType = DataType.TreeComponent;
|
|
1773
1756
|
item.content.item = { id: item.id };
|
|
1774
1757
|
item.dataType = DataType.VFXItemData;
|
|
1775
|
-
//@ts-expect-error
|
|
1776
1758
|
item.components.push({ id: item.content.id });
|
|
1777
1759
|
}
|
|
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
|
-
|
|
1760
|
+
switch (item.type) {
|
|
1761
|
+
case ItemType.sprite:
|
|
1762
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
1763
|
+
break;
|
|
1764
|
+
case ItemType.particle:
|
|
1765
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
1766
|
+
break;
|
|
1767
|
+
case ItemType.mesh:
|
|
1768
|
+
item.content.dataType = DataType.MeshComponent;
|
|
1769
|
+
break;
|
|
1770
|
+
case ItemType.skybox:
|
|
1771
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
1772
|
+
break;
|
|
1773
|
+
case ItemType.light:
|
|
1774
|
+
item.content.dataType = DataType.LightComponent;
|
|
1775
|
+
break;
|
|
1776
|
+
case 'camera':
|
|
1777
|
+
item.content.dataType = DataType.CameraComponent;
|
|
1778
|
+
break;
|
|
1779
|
+
case ItemType.tree:
|
|
1780
|
+
item.content.dataType = DataType.TreeComponent;
|
|
1781
|
+
break;
|
|
1782
|
+
case ItemType.interact:
|
|
1783
|
+
item.content.dataType = DataType.InteractComponent;
|
|
1784
|
+
break;
|
|
1785
|
+
case ItemType.camera:
|
|
1786
|
+
item.content.dataType = DataType.CameraController;
|
|
1787
|
+
break;
|
|
1788
|
+
case ItemType.text:
|
|
1789
|
+
item.content.dataType = DataType.TextComponent;
|
|
1790
|
+
break;
|
|
1807
1791
|
}
|
|
1808
1792
|
}
|
|
1809
1793
|
}
|
|
@@ -1925,11 +1909,9 @@ function getStandardImage(image, index, imageTags) {
|
|
|
1925
1909
|
else if (image.url) {
|
|
1926
1910
|
return {
|
|
1927
1911
|
url: image.url,
|
|
1928
|
-
type: image.type,
|
|
1929
1912
|
webp: image.webp,
|
|
1930
1913
|
renderLevel: renderLevel,
|
|
1931
1914
|
oriY: oriY,
|
|
1932
|
-
loop: image.loop,
|
|
1933
1915
|
};
|
|
1934
1916
|
}
|
|
1935
1917
|
else if (image && image.sourceType) {
|
|
@@ -1942,7 +1924,7 @@ function getStandardComposition(composition, opt) {
|
|
|
1942
1924
|
if (opt === void 0) { opt = {}; }
|
|
1943
1925
|
var ret = {
|
|
1944
1926
|
id: composition.id + '',
|
|
1945
|
-
camera:
|
|
1927
|
+
camera: __assign({ clipMode: CAMERA_CLIP_MODE_NORMAL }, composition.camera),
|
|
1946
1928
|
duration: composition.duration,
|
|
1947
1929
|
endBehavior: composition.endBehavior,
|
|
1948
1930
|
items: composition.items.map(function (item) { return getStandardItem(item, opt); }),
|