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