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