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