@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.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.3
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
- Copyright (c) Microsoft Corporation.
792
-
793
- Permission to use, copy, modify, and/or distribute this software for any
794
- purpose with or without fee is hereby granted.
795
-
796
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
797
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
798
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
799
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
800
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
801
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
802
- PERFORMANCE OF THIS SOFTWARE.
803
- ***************************************************************************** */
804
-
805
- var __assign = function() {
806
- __assign = Object.assign || function __assign(t) {
807
- for (var s, i = 1, n = arguments.length; i < n; i++) {
808
- s = arguments[i];
809
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
810
- }
811
- return t;
812
- };
813
- return __assign.apply(this, arguments);
814
- };
815
-
816
- function __values(o) {
817
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
818
- if (m) return m.call(o);
819
- if (o && typeof o.length === "number") return {
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 = Object.assign({}, json, {
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
- Object.assign(textureOptions, {
1552
- id: generateGUID(),
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
- rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
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.components = [];
1710
- result.components.push(item.content);
1711
- item.content.id = uuid;
1712
- item.content.dataType = DataType.SpriteComponent;
1713
- item.content.item = { id: item.id };
1714
- item.dataType = DataType.VFXItemData;
1715
- //@ts-expect-error
1716
- item.components.push({ id: item.content.id });
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
- else if (item.type === ItemType.interact) {
1779
- item.components = [];
1780
- result.components.push(item.content);
1781
- item.content.id = uuid;
1782
- item.content.dataType = DataType.InteractComponent;
1783
- item.content.item = { id: item.id };
1784
- item.dataType = DataType.VFXItemData;
1785
- //@ts-expect-error
1786
- item.components.push({ id: item.content.id });
1787
- }
1788
- else if (item.type === ItemType.camera) {
1789
- item.components = [];
1790
- result.components.push(item.content);
1791
- item.content.id = uuid;
1792
- item.content.dataType = DataType.CameraController;
1793
- item.content.item = { id: item.id };
1794
- item.dataType = DataType.VFXItemData;
1795
- //@ts-expect-error
1796
- item.components.push({ id: item.content.id });
1797
- }
1798
- else if (item.type === ItemType.text) {
1799
- item.components = [];
1800
- result.components.push(item.content);
1801
- item.content.id = uuid;
1802
- item.content.dataType = DataType.TextComponent;
1803
- item.content.item = { id: item.id };
1804
- item.dataType = DataType.VFXItemData;
1805
- //@ts-expect-error
1806
- item.components.push({ id: item.content.id });
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: Object.assign({ clipMode: CAMERA_CLIP_MODE_NORMAL }, composition.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); }),