@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.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,20 +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
|
-
textureOptions =
|
|
1587
|
-
|
|
1588
|
-
id: generateGUID(), dataType: DataType.Texture });
|
|
1586
|
+
textureOptions.id = generateGUID();
|
|
1587
|
+
textureOptions.dataType = DataType.Texture;
|
|
1589
1588
|
});
|
|
1590
1589
|
if (result.textures.length < result.images.length) {
|
|
1591
1590
|
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
1592
1591
|
result.textures.push({
|
|
1593
|
-
//@ts-expect-error
|
|
1594
1592
|
id: generateGUID(),
|
|
1595
1593
|
dataType: DataType.Texture,
|
|
1596
1594
|
source: i,
|
|
@@ -1598,16 +1596,16 @@ function version30Migration(json) {
|
|
|
1598
1596
|
});
|
|
1599
1597
|
}
|
|
1600
1598
|
}
|
|
1599
|
+
var itemGuidMap = {};
|
|
1601
1600
|
var _loop_1 = function (composition) {
|
|
1602
|
-
var
|
|
1601
|
+
var e_3, _q;
|
|
1603
1602
|
// composition 的 endbehaviour 兼容
|
|
1604
1603
|
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
1605
1604
|
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
1606
1605
|
}
|
|
1607
|
-
var itemGuidMap = {};
|
|
1608
1606
|
try {
|
|
1609
|
-
for (var
|
|
1610
|
-
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;
|
|
1611
1609
|
itemGuidMap[item.id] = generateGUID();
|
|
1612
1610
|
// TODO: 编辑器测试用,上线后删除
|
|
1613
1611
|
//@ts-expect-error
|
|
@@ -1615,12 +1613,12 @@ function version30Migration(json) {
|
|
|
1615
1613
|
item.id = itemGuidMap[item.id];
|
|
1616
1614
|
}
|
|
1617
1615
|
}
|
|
1618
|
-
catch (
|
|
1616
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1619
1617
|
finally {
|
|
1620
1618
|
try {
|
|
1621
|
-
if (
|
|
1619
|
+
if (_s && !_s.done && (_q = _r.return)) _q.call(_r);
|
|
1622
1620
|
}
|
|
1623
|
-
finally { if (
|
|
1621
|
+
finally { if (e_3) throw e_3.error; }
|
|
1624
1622
|
}
|
|
1625
1623
|
composition.items.forEach(function (item, index) {
|
|
1626
1624
|
if (item.parentId) {
|
|
@@ -1638,179 +1636,177 @@ function version30Migration(json) {
|
|
|
1638
1636
|
// @ts-expect-error fix item type
|
|
1639
1637
|
composition.items[index] = { id: item.id };
|
|
1640
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 {
|
|
1641
1649
|
try {
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
var oldTextureId = item.content.trails.texture;
|
|
1656
|
-
//@ts-expect-error
|
|
1657
|
-
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
1658
|
-
}
|
|
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 };
|
|
1659
1663
|
}
|
|
1660
1664
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
//@ts-expect-error
|
|
1666
|
-
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
1667
|
-
//@ts-expect-error
|
|
1668
|
-
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
1669
|
-
Object.assign(item, {
|
|
1670
|
-
transform: {
|
|
1671
|
-
position: { x: position[0], y: position[1], z: position[2] },
|
|
1672
|
-
eulerHint: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1673
|
-
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1674
|
-
},
|
|
1675
|
-
});
|
|
1676
|
-
// sprite 的 scale 转为 size
|
|
1677
|
-
if (item.type === ItemType.sprite) {
|
|
1678
|
-
item.transform.size = { x: scale[0], y: scale[1] };
|
|
1679
|
-
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
1680
|
-
}
|
|
1681
|
-
// sprite 的 anchor 修正
|
|
1682
|
-
if (item.type === ItemType.sprite) {
|
|
1683
|
-
var content = item.content;
|
|
1684
|
-
if (!content.renderer) {
|
|
1685
|
-
content.renderer = {};
|
|
1686
|
-
}
|
|
1687
|
-
var renderer = content.renderer;
|
|
1688
|
-
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1689
|
-
var startSize = item.transform.size;
|
|
1690
|
-
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
1691
|
-
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
1692
|
-
item.transform.position.x += -realAnchor[0] * ((_f = startSize === null || startSize === void 0 ? void 0 : startSize.x) !== null && _f !== void 0 ? _f : 1);
|
|
1693
|
-
item.transform.position.y += -realAnchor[1] * ((_g = startSize === null || startSize === void 0 ? void 0 : startSize.y) !== null && _g !== void 0 ? _g : 1);
|
|
1694
|
-
}
|
|
1695
|
-
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 };
|
|
1696
1669
|
}
|
|
1697
1670
|
}
|
|
1698
|
-
|
|
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) {
|
|
1699
1694
|
var content = item.content;
|
|
1700
1695
|
if (!content.renderer) {
|
|
1701
1696
|
content.renderer = {};
|
|
1702
1697
|
}
|
|
1703
1698
|
var renderer = content.renderer;
|
|
1704
|
-
|
|
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) };
|
|
1705
1707
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
var
|
|
1709
|
-
if (
|
|
1710
|
-
|
|
1711
|
-
clips: [
|
|
1712
|
-
{
|
|
1713
|
-
dataType: 'TransformAnimationPlayableAsset',
|
|
1714
|
-
animationClip: {
|
|
1715
|
-
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
1716
|
-
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
1717
|
-
positionOverLifetime: item.content.positionOverLifetime,
|
|
1718
|
-
},
|
|
1719
|
-
},
|
|
1720
|
-
],
|
|
1721
|
-
});
|
|
1708
|
+
}
|
|
1709
|
+
if (item.type === ItemType.particle) {
|
|
1710
|
+
var content = item.content;
|
|
1711
|
+
if (!content.renderer) {
|
|
1712
|
+
content.renderer = {};
|
|
1722
1713
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
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,
|
|
1732
1729
|
},
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1736
|
-
// gizmo 的 target id 转换为新的 item guid
|
|
1737
|
-
if (item.content.options.target) {
|
|
1738
|
-
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
1739
|
-
}
|
|
1740
|
-
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1741
|
-
var uuid = generateGUID();
|
|
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) {
|
|
1752
|
-
item.components = [];
|
|
1753
|
-
result.components.push(item.content);
|
|
1754
|
-
item.content.id = uuid;
|
|
1755
|
-
item.content.item = { id: item.id };
|
|
1756
|
-
item.dataType = DataType.VFXItemData;
|
|
1757
|
-
item.components.push({ id: item.content.id });
|
|
1758
|
-
}
|
|
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;
|
|
1790
|
-
}
|
|
1730
|
+
},
|
|
1731
|
+
],
|
|
1732
|
+
});
|
|
1791
1733
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
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;
|
|
1797
1801
|
}
|
|
1798
|
-
finally { if (e_3) throw e_3.error; }
|
|
1799
|
-
}
|
|
1800
|
-
};
|
|
1801
|
-
try {
|
|
1802
|
-
// 更正Composition.endBehavior
|
|
1803
|
-
for (var _k = __values(json.compositions), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1804
|
-
var composition = _l.value;
|
|
1805
|
-
_loop_1(composition);
|
|
1806
1802
|
}
|
|
1807
1803
|
}
|
|
1808
|
-
catch (
|
|
1804
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1809
1805
|
finally {
|
|
1810
1806
|
try {
|
|
1811
|
-
if (
|
|
1807
|
+
if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
|
|
1812
1808
|
}
|
|
1813
|
-
finally { if (
|
|
1809
|
+
finally { if (e_2) throw e_2.error; }
|
|
1814
1810
|
}
|
|
1815
1811
|
result.version = '3.0';
|
|
1816
1812
|
return result;
|