@galacean/effects-specification 2.0.0-alpha.4 → 2.0.0-alpha.6
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.js +164 -168
- package/dist/fallback.js.map +1 -1
- package/dist/fallback.mjs +164 -168
- package/dist/fallback.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/src/components.d.ts +1 -1
- package/dist/src/image.d.ts +4 -0
- package/package.json +1 -1
package/dist/fallback.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.6
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
@@ -1581,20 +1581,18 @@ function version22Migration(json) {
|
|
|
1581
1581
|
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
1582
1582
|
*/
|
|
1583
1583
|
function version30Migration(json) {
|
|
1584
|
-
var e_1, _a;
|
|
1585
|
-
var
|
|
1584
|
+
var e_1, _a, e_2, _b;
|
|
1585
|
+
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1586
1586
|
var result = __assign(__assign({}, json), { items: [], components: [], materials: [], shaders: [], geometries: [] });
|
|
1587
1587
|
// 兼容老版本数据中不存在textures的情况
|
|
1588
|
-
(
|
|
1588
|
+
(_c = result.textures) !== null && _c !== void 0 ? _c : (result.textures = []);
|
|
1589
1589
|
result.textures.forEach(function (textureOptions) {
|
|
1590
|
-
textureOptions =
|
|
1591
|
-
|
|
1592
|
-
id: generateGUID(), dataType: DataType.Texture });
|
|
1590
|
+
textureOptions.id = generateGUID();
|
|
1591
|
+
textureOptions.dataType = DataType.Texture;
|
|
1593
1592
|
});
|
|
1594
1593
|
if (result.textures.length < result.images.length) {
|
|
1595
1594
|
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
1596
1595
|
result.textures.push({
|
|
1597
|
-
//@ts-expect-error
|
|
1598
1596
|
id: generateGUID(),
|
|
1599
1597
|
dataType: DataType.Texture,
|
|
1600
1598
|
source: i,
|
|
@@ -1602,16 +1600,16 @@ function version30Migration(json) {
|
|
|
1602
1600
|
});
|
|
1603
1601
|
}
|
|
1604
1602
|
}
|
|
1603
|
+
var itemGuidMap = {};
|
|
1605
1604
|
var _loop_1 = function (composition) {
|
|
1606
|
-
var
|
|
1605
|
+
var e_3, _q;
|
|
1607
1606
|
// composition 的 endbehaviour 兼容
|
|
1608
1607
|
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
1609
1608
|
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
1610
1609
|
}
|
|
1611
|
-
var itemGuidMap = {};
|
|
1612
1610
|
try {
|
|
1613
|
-
for (var
|
|
1614
|
-
var item =
|
|
1611
|
+
for (var _r = (e_3 = void 0, __values(composition.items)), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
1612
|
+
var item = _s.value;
|
|
1615
1613
|
itemGuidMap[item.id] = generateGUID();
|
|
1616
1614
|
// TODO: 编辑器测试用,上线后删除
|
|
1617
1615
|
//@ts-expect-error
|
|
@@ -1619,12 +1617,12 @@ function version30Migration(json) {
|
|
|
1619
1617
|
item.id = itemGuidMap[item.id];
|
|
1620
1618
|
}
|
|
1621
1619
|
}
|
|
1622
|
-
catch (
|
|
1620
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1623
1621
|
finally {
|
|
1624
1622
|
try {
|
|
1625
|
-
if (
|
|
1623
|
+
if (_s && !_s.done && (_q = _r.return)) _q.call(_r);
|
|
1626
1624
|
}
|
|
1627
|
-
finally { if (
|
|
1625
|
+
finally { if (e_3) throw e_3.error; }
|
|
1628
1626
|
}
|
|
1629
1627
|
composition.items.forEach(function (item, index) {
|
|
1630
1628
|
if (item.parentId) {
|
|
@@ -1642,179 +1640,177 @@ function version30Migration(json) {
|
|
|
1642
1640
|
// @ts-expect-error fix item type
|
|
1643
1641
|
composition.items[index] = { id: item.id };
|
|
1644
1642
|
});
|
|
1643
|
+
};
|
|
1644
|
+
try {
|
|
1645
|
+
// 更正Composition.endBehavior
|
|
1646
|
+
for (var _l = __values(json.compositions), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
1647
|
+
var composition = _m.value;
|
|
1648
|
+
_loop_1(composition);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1652
|
+
finally {
|
|
1645
1653
|
try {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
var oldTextureId = item.content.trails.texture;
|
|
1660
|
-
//@ts-expect-error
|
|
1661
|
-
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
1662
|
-
}
|
|
1654
|
+
if (_m && !_m.done && (_a = _l.return)) _a.call(_l);
|
|
1655
|
+
}
|
|
1656
|
+
finally { if (e_1) throw e_1.error; }
|
|
1657
|
+
}
|
|
1658
|
+
try {
|
|
1659
|
+
for (var _o = __values(result.items), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
1660
|
+
var item = _p.value;
|
|
1661
|
+
// 原 texture 索引转为统一 guid 索引
|
|
1662
|
+
if (item.content) {
|
|
1663
|
+
if (item.content.renderer) {
|
|
1664
|
+
if (item.content.renderer.texture !== undefined) {
|
|
1665
|
+
var oldTextureId = item.content.renderer.texture;
|
|
1666
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
1663
1667
|
}
|
|
1664
1668
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
//@ts-expect-error
|
|
1670
|
-
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
1671
|
-
//@ts-expect-error
|
|
1672
|
-
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
1673
|
-
Object.assign(item, {
|
|
1674
|
-
transform: {
|
|
1675
|
-
position: { x: position[0], y: position[1], z: position[2] },
|
|
1676
|
-
eulerHint: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1677
|
-
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1678
|
-
},
|
|
1679
|
-
});
|
|
1680
|
-
// sprite 的 scale 转为 size
|
|
1681
|
-
if (item.type === ItemType.sprite) {
|
|
1682
|
-
item.transform.size = { x: scale[0], y: scale[1] };
|
|
1683
|
-
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
1684
|
-
}
|
|
1685
|
-
// sprite 的 anchor 修正
|
|
1686
|
-
if (item.type === ItemType.sprite) {
|
|
1687
|
-
var content = item.content;
|
|
1688
|
-
if (!content.renderer) {
|
|
1689
|
-
content.renderer = {};
|
|
1690
|
-
}
|
|
1691
|
-
var renderer = content.renderer;
|
|
1692
|
-
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1693
|
-
var startSize = item.transform.size;
|
|
1694
|
-
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
1695
|
-
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
1696
|
-
item.transform.position.x += -realAnchor[0] * ((_f = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _f !== void 0 ? _f : 1);
|
|
1697
|
-
item.transform.position.y += -realAnchor[1] * ((_g = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _g !== void 0 ? _g : 1);
|
|
1698
|
-
}
|
|
1699
|
-
item.transform.anchor = { x: realAnchor[0] * ((_h = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _h !== void 0 ? _h : 1), y: realAnchor[1] * ((_j = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _j !== void 0 ? _j : 1) };
|
|
1669
|
+
if (item.content.trails) {
|
|
1670
|
+
if (item.content.trails.texture !== undefined) {
|
|
1671
|
+
var oldTextureId = item.content.trails.texture;
|
|
1672
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
1700
1673
|
}
|
|
1701
1674
|
}
|
|
1702
|
-
|
|
1675
|
+
}
|
|
1676
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
1677
|
+
if (item.transform) {
|
|
1678
|
+
//@ts-expect-error
|
|
1679
|
+
var position = __spreadArray([], __read((_d = item.transform.position) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
1680
|
+
//@ts-expect-error
|
|
1681
|
+
var rotation = __spreadArray([], __read((_e = item.transform.rotation) !== null && _e !== void 0 ? _e : [0, 0, 0]), false);
|
|
1682
|
+
//@ts-expect-error
|
|
1683
|
+
var scale = __spreadArray([], __read((_f = item.transform.scale) !== null && _f !== void 0 ? _f : [1, 1, 1]), false);
|
|
1684
|
+
Object.assign(item, {
|
|
1685
|
+
transform: {
|
|
1686
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
1687
|
+
eulerHint: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1688
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1689
|
+
},
|
|
1690
|
+
});
|
|
1691
|
+
// sprite 的 scale 转为 size
|
|
1692
|
+
if (item.type === ItemType.sprite) {
|
|
1693
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
1694
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
1695
|
+
}
|
|
1696
|
+
// sprite 的 anchor 修正
|
|
1697
|
+
if (item.type === ItemType.sprite) {
|
|
1703
1698
|
var content = item.content;
|
|
1704
1699
|
if (!content.renderer) {
|
|
1705
1700
|
content.renderer = {};
|
|
1706
1701
|
}
|
|
1707
1702
|
var renderer = content.renderer;
|
|
1708
|
-
|
|
1703
|
+
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1704
|
+
var startSize = item.transform.size;
|
|
1705
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
1706
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
1707
|
+
item.transform.position.x += -realAnchor[0] * ((_g = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _g !== void 0 ? _g : 1);
|
|
1708
|
+
item.transform.position.y += -realAnchor[1] * ((_h = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _h !== void 0 ? _h : 1);
|
|
1709
|
+
}
|
|
1710
|
+
item.transform.anchor = { x: realAnchor[0] * ((_j = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _j !== void 0 ? _j : 1), y: realAnchor[1] * ((_k = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _k !== void 0 ? _k : 1) };
|
|
1709
1711
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
var
|
|
1713
|
-
if (
|
|
1714
|
-
|
|
1715
|
-
clips: [
|
|
1716
|
-
{
|
|
1717
|
-
dataType: 'TransformAnimationPlayableAsset',
|
|
1718
|
-
animationClip: {
|
|
1719
|
-
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
1720
|
-
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
1721
|
-
positionOverLifetime: item.content.positionOverLifetime,
|
|
1722
|
-
},
|
|
1723
|
-
},
|
|
1724
|
-
],
|
|
1725
|
-
});
|
|
1712
|
+
}
|
|
1713
|
+
if (item.type === ItemType.particle) {
|
|
1714
|
+
var content = item.content;
|
|
1715
|
+
if (!content.renderer) {
|
|
1716
|
+
content.renderer = {};
|
|
1726
1717
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1718
|
+
var renderer = content.renderer;
|
|
1719
|
+
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1720
|
+
}
|
|
1721
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
1722
|
+
item.content.tracks = [];
|
|
1723
|
+
var tracks = item.content.tracks;
|
|
1724
|
+
if (item.type !== ItemType.particle) {
|
|
1725
|
+
tracks.push({
|
|
1726
|
+
clips: [
|
|
1727
|
+
{
|
|
1728
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
1729
|
+
animationClip: {
|
|
1730
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
1731
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
1732
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
1736
1733
|
},
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
}
|
|
1740
|
-
// gizmo 的 target id 转换为新的 item guid
|
|
1741
|
-
if (item.content.options.target) {
|
|
1742
|
-
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
1743
|
-
}
|
|
1744
|
-
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1745
|
-
var uuid = generateGUID();
|
|
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) {
|
|
1756
|
-
item.components = [];
|
|
1757
|
-
result.components.push(item.content);
|
|
1758
|
-
item.content.id = uuid;
|
|
1759
|
-
item.content.item = { id: item.id };
|
|
1760
|
-
item.dataType = DataType.VFXItemData;
|
|
1761
|
-
item.components.push({ id: item.content.id });
|
|
1762
|
-
}
|
|
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;
|
|
1794
|
-
}
|
|
1734
|
+
},
|
|
1735
|
+
],
|
|
1736
|
+
});
|
|
1795
1737
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1738
|
+
if (item.type === ItemType.sprite) {
|
|
1739
|
+
tracks.push({
|
|
1740
|
+
clips: [
|
|
1741
|
+
{
|
|
1742
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
1743
|
+
animationClip: {
|
|
1744
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
1745
|
+
startColor: item.content.options.startColor,
|
|
1746
|
+
},
|
|
1747
|
+
},
|
|
1748
|
+
],
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
1752
|
+
if (item.content.options.target) {
|
|
1753
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
1754
|
+
}
|
|
1755
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1756
|
+
var uuid = generateGUID();
|
|
1757
|
+
if (item.type === ItemType.sprite ||
|
|
1758
|
+
item.type === ItemType.particle ||
|
|
1759
|
+
item.type === ItemType.mesh ||
|
|
1760
|
+
item.type === ItemType.skybox ||
|
|
1761
|
+
item.type === ItemType.light ||
|
|
1762
|
+
item.type === 'camera' ||
|
|
1763
|
+
item.type === ItemType.tree ||
|
|
1764
|
+
item.type === ItemType.interact ||
|
|
1765
|
+
item.type === ItemType.camera ||
|
|
1766
|
+
item.type === ItemType.text) {
|
|
1767
|
+
item.components = [];
|
|
1768
|
+
result.components.push(item.content);
|
|
1769
|
+
item.content.id = uuid;
|
|
1770
|
+
item.content.item = { id: item.id };
|
|
1771
|
+
item.dataType = DataType.VFXItemData;
|
|
1772
|
+
item.components.push({ id: item.content.id });
|
|
1773
|
+
}
|
|
1774
|
+
switch (item.type) {
|
|
1775
|
+
case ItemType.sprite:
|
|
1776
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
1777
|
+
break;
|
|
1778
|
+
case ItemType.particle:
|
|
1779
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
1780
|
+
break;
|
|
1781
|
+
case ItemType.mesh:
|
|
1782
|
+
item.content.dataType = DataType.MeshComponent;
|
|
1783
|
+
break;
|
|
1784
|
+
case ItemType.skybox:
|
|
1785
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
1786
|
+
break;
|
|
1787
|
+
case ItemType.light:
|
|
1788
|
+
item.content.dataType = DataType.LightComponent;
|
|
1789
|
+
break;
|
|
1790
|
+
case 'camera':
|
|
1791
|
+
item.content.dataType = DataType.CameraComponent;
|
|
1792
|
+
break;
|
|
1793
|
+
case ItemType.tree:
|
|
1794
|
+
item.content.dataType = DataType.TreeComponent;
|
|
1795
|
+
break;
|
|
1796
|
+
case ItemType.interact:
|
|
1797
|
+
item.content.dataType = DataType.InteractComponent;
|
|
1798
|
+
break;
|
|
1799
|
+
case ItemType.camera:
|
|
1800
|
+
item.content.dataType = DataType.CameraController;
|
|
1801
|
+
break;
|
|
1802
|
+
case ItemType.text:
|
|
1803
|
+
item.content.dataType = DataType.TextComponent;
|
|
1804
|
+
break;
|
|
1801
1805
|
}
|
|
1802
|
-
finally { if (e_3) throw e_3.error; }
|
|
1803
|
-
}
|
|
1804
|
-
};
|
|
1805
|
-
try {
|
|
1806
|
-
// 更正Composition.endBehavior
|
|
1807
|
-
for (var _k = __values(json.compositions), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1808
|
-
var composition = _l.value;
|
|
1809
|
-
_loop_1(composition);
|
|
1810
1806
|
}
|
|
1811
1807
|
}
|
|
1812
|
-
catch (
|
|
1808
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1813
1809
|
finally {
|
|
1814
1810
|
try {
|
|
1815
|
-
if (
|
|
1811
|
+
if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
|
|
1816
1812
|
}
|
|
1817
|
-
finally { if (
|
|
1813
|
+
finally { if (e_2) throw e_2.error; }
|
|
1818
1814
|
}
|
|
1819
1815
|
result.version = '3.0';
|
|
1820
1816
|
return result;
|