@galacean/effects-specification 2.0.0-alpha.0 → 2.0.0-alpha.2
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/migration.d.ts +7 -3
- package/dist/fallback/utils.d.ts +8 -1
- package/dist/fallback.js +429 -5
- package/dist/fallback.js.map +1 -1
- package/dist/fallback.mjs +427 -6
- package/dist/fallback.mjs.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -2
- package/dist/index.mjs.map +1 -1
- package/dist/src/binary.d.ts +1 -1
- package/dist/src/components.d.ts +4 -3
- package/dist/src/composition.d.ts +5 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/item/base-item.d.ts +3 -8
- package/dist/src/item/camera-item.d.ts +1 -1
- package/dist/src/item/composition-item.d.ts +1 -1
- package/dist/src/item/effect-item.d.ts +17 -0
- package/dist/src/item/interact-item.d.ts +2 -2
- package/dist/src/item/model/camera.d.ts +20 -4
- package/dist/src/item/model/light.d.ts +1 -1
- package/dist/src/item/model/material.d.ts +1 -1
- package/dist/src/item/model/mesh.d.ts +1 -1
- package/dist/src/item/model/skybox.d.ts +1 -1
- package/dist/src/item/null-item.d.ts +1 -1
- package/dist/src/item/particle-item.d.ts +2 -2
- package/dist/src/item/particle-shape.d.ts +1 -1
- package/dist/src/item/sprite-item.d.ts +2 -2
- package/dist/src/item/text-item.d.ts +3 -3
- package/dist/src/scene.d.ts +6 -11
- package/dist/src/text.d.ts +1 -1
- package/dist/src/type.d.ts +6 -2
- package/package.json +3 -2
- /package/dist/src/{numberExpression.d.ts → number-expression.d.ts} +0 -0
package/dist/fallback.mjs
CHANGED
|
@@ -2,9 +2,74 @@
|
|
|
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.2
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
9
|
+
var native = {
|
|
10
|
+
randomUUID
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
14
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
15
|
+
// generators (like Math.random()).
|
|
16
|
+
let getRandomValues;
|
|
17
|
+
const rnds8 = new Uint8Array(16);
|
|
18
|
+
function rng() {
|
|
19
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
20
|
+
if (!getRandomValues) {
|
|
21
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
22
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
23
|
+
|
|
24
|
+
if (!getRandomValues) {
|
|
25
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return getRandomValues(rnds8);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
34
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const byteToHex = [];
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < 256; ++i) {
|
|
40
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function unsafeStringify(arr, offset = 0) {
|
|
44
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
45
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
46
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function v4(options, buf, offset) {
|
|
50
|
+
if (native.randomUUID && !buf && !options) {
|
|
51
|
+
return native.randomUUID();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
options = options || {};
|
|
55
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
56
|
+
|
|
57
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
58
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
59
|
+
|
|
60
|
+
if (buf) {
|
|
61
|
+
offset = offset || 0;
|
|
62
|
+
|
|
63
|
+
for (let i = 0; i < 16; ++i) {
|
|
64
|
+
buf[offset + i] = rnds[i];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return buf;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return unsafeStringify(rnds);
|
|
71
|
+
}
|
|
72
|
+
|
|
8
73
|
/*********************************************/
|
|
9
74
|
/* 元素属性参数类型 */
|
|
10
75
|
/*********************************************/
|
|
@@ -267,6 +332,10 @@ var ItemType;
|
|
|
267
332
|
* 天空盒元素
|
|
268
333
|
*/
|
|
269
334
|
ItemType["skybox"] = "skybox";
|
|
335
|
+
/**
|
|
336
|
+
* 特效元素
|
|
337
|
+
*/
|
|
338
|
+
ItemType["effect"] = "effect";
|
|
270
339
|
})(ItemType || (ItemType = {}));
|
|
271
340
|
/**
|
|
272
341
|
* 渲染模式
|
|
@@ -379,6 +448,10 @@ var CompositionEndBehavior;
|
|
|
379
448
|
* 销毁并保留最后一帧
|
|
380
449
|
*/
|
|
381
450
|
CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
|
|
451
|
+
/**
|
|
452
|
+
* 冻结
|
|
453
|
+
*/
|
|
454
|
+
CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
|
|
382
455
|
})(CompositionEndBehavior || (CompositionEndBehavior = {}));
|
|
383
456
|
|
|
384
457
|
/*********************************************/
|
|
@@ -541,6 +614,12 @@ var ModelBoundingType;
|
|
|
541
614
|
ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
|
|
542
615
|
})(ModelBoundingType || (ModelBoundingType = {}));
|
|
543
616
|
|
|
617
|
+
var CameraType;
|
|
618
|
+
(function (CameraType) {
|
|
619
|
+
CameraType["orthographic"] = "orthographic";
|
|
620
|
+
CameraType["perspective"] = "perspective";
|
|
621
|
+
})(CameraType || (CameraType = {}));
|
|
622
|
+
|
|
544
623
|
// 材质类型
|
|
545
624
|
var MaterialType;
|
|
546
625
|
(function (MaterialType) {
|
|
@@ -763,11 +842,22 @@ function __read(o, n) {
|
|
|
763
842
|
return ar;
|
|
764
843
|
}
|
|
765
844
|
|
|
845
|
+
function __spreadArray(to, from, pack) {
|
|
846
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
847
|
+
if (ar || !(i in from)) {
|
|
848
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
849
|
+
ar[i] = from[i];
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
853
|
+
}
|
|
854
|
+
|
|
766
855
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
767
856
|
var e = new Error(message);
|
|
768
857
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
769
858
|
};
|
|
770
859
|
|
|
860
|
+
var _a;
|
|
771
861
|
function arrAdd(arr, item) {
|
|
772
862
|
if (!arr.includes(item)) {
|
|
773
863
|
arr.push(item);
|
|
@@ -1003,6 +1093,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
1003
1093
|
}
|
|
1004
1094
|
return out;
|
|
1005
1095
|
}
|
|
1096
|
+
function generateGUID() {
|
|
1097
|
+
return v4().replace(/-/g, '');
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
1101
|
+
*/
|
|
1102
|
+
function convertAnchor(anchor, particleOrigin) {
|
|
1103
|
+
if (anchor) {
|
|
1104
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
1105
|
+
}
|
|
1106
|
+
else if (particleOrigin) {
|
|
1107
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1110
|
+
return [0, 0];
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
var particleOriginTranslateMap = (_a = {},
|
|
1114
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
1115
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
1116
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
1117
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
1118
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
1119
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
1120
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
1121
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
1122
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
1123
|
+
_a);
|
|
1006
1124
|
|
|
1007
1125
|
function getStandardParticleContent(particle) {
|
|
1008
1126
|
var _a;
|
|
@@ -1414,6 +1532,309 @@ function version22Migration(json) {
|
|
|
1414
1532
|
});
|
|
1415
1533
|
return json;
|
|
1416
1534
|
}
|
|
1535
|
+
/**
|
|
1536
|
+
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
1537
|
+
*/
|
|
1538
|
+
function version30Migration(json) {
|
|
1539
|
+
var e_1, _a;
|
|
1540
|
+
var _b, _c, _d, _e;
|
|
1541
|
+
var result = Object.assign({}, json, {
|
|
1542
|
+
items: [],
|
|
1543
|
+
components: [],
|
|
1544
|
+
materials: [],
|
|
1545
|
+
shaders: [],
|
|
1546
|
+
geometries: [],
|
|
1547
|
+
});
|
|
1548
|
+
// 兼容老版本数据中不存在textures的情况
|
|
1549
|
+
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
1550
|
+
result.textures.forEach(function (textureOptions) {
|
|
1551
|
+
Object.assign(textureOptions, {
|
|
1552
|
+
id: generateGUID(),
|
|
1553
|
+
dataType: DataType.Texture,
|
|
1554
|
+
});
|
|
1555
|
+
});
|
|
1556
|
+
if (result.textures.length < result.images.length) {
|
|
1557
|
+
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
1558
|
+
result.textures.push({
|
|
1559
|
+
//@ts-expect-error
|
|
1560
|
+
id: generateGUID(),
|
|
1561
|
+
dataType: DataType.Texture,
|
|
1562
|
+
source: i,
|
|
1563
|
+
flipY: true,
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
var _loop_1 = function (composition) {
|
|
1568
|
+
var e_2, _h, e_3, _j;
|
|
1569
|
+
// composition 的 endbehaviour 兼容
|
|
1570
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
1571
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
1572
|
+
}
|
|
1573
|
+
var itemGuidMap = {};
|
|
1574
|
+
try {
|
|
1575
|
+
for (var _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1576
|
+
var item = _l.value;
|
|
1577
|
+
itemGuidMap[item.id] = generateGUID();
|
|
1578
|
+
// TODO: 编辑器测试用,上线后删除
|
|
1579
|
+
//@ts-expect-error
|
|
1580
|
+
item.oldId = item.id;
|
|
1581
|
+
item.id = itemGuidMap[item.id];
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1585
|
+
finally {
|
|
1586
|
+
try {
|
|
1587
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
1588
|
+
}
|
|
1589
|
+
finally { if (e_2) throw e_2.error; }
|
|
1590
|
+
}
|
|
1591
|
+
composition.items.forEach(function (item, index) {
|
|
1592
|
+
if (item.parentId) {
|
|
1593
|
+
if (item.parentId.includes('^')) {
|
|
1594
|
+
var parentId = (item.parentId).split('^')[0];
|
|
1595
|
+
var nodeId = (item.parentId).split('^')[1];
|
|
1596
|
+
item.parentId = itemGuidMap[parentId] + '^' + nodeId;
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
item.parentId = itemGuidMap[item.parentId];
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
// @ts-expect-error fix item type
|
|
1603
|
+
result.items.push(item);
|
|
1604
|
+
// @ts-expect-error fix item type
|
|
1605
|
+
composition.items[index] = { id: item.id };
|
|
1606
|
+
});
|
|
1607
|
+
try {
|
|
1608
|
+
for (var _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1609
|
+
var item = _o.value;
|
|
1610
|
+
// 原 texture 索引转为统一 guid 索引
|
|
1611
|
+
if (item.content) {
|
|
1612
|
+
if (item.content.renderer) {
|
|
1613
|
+
if (item.content.renderer.texture !== undefined) {
|
|
1614
|
+
var oldTextureId = item.content.renderer.texture;
|
|
1615
|
+
//@ts-expect-error
|
|
1616
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if (item.content.trails) {
|
|
1620
|
+
if (item.content.trails.texture !== undefined) {
|
|
1621
|
+
var oldTextureId = item.content.trails.texture;
|
|
1622
|
+
//@ts-expect-error
|
|
1623
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
1628
|
+
if (item.transform) {
|
|
1629
|
+
//@ts-expect-error
|
|
1630
|
+
var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
|
|
1631
|
+
//@ts-expect-error
|
|
1632
|
+
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
1633
|
+
//@ts-expect-error
|
|
1634
|
+
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
1635
|
+
Object.assign(item, {
|
|
1636
|
+
transform: {
|
|
1637
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
1638
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1639
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1640
|
+
},
|
|
1641
|
+
});
|
|
1642
|
+
// sprite 的 scale 转为 size
|
|
1643
|
+
if (item.type === ItemType.sprite) {
|
|
1644
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
1645
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
1646
|
+
}
|
|
1647
|
+
// sprite 的 anchor 修正
|
|
1648
|
+
if (item.type === ItemType.sprite) {
|
|
1649
|
+
var content = item.content;
|
|
1650
|
+
if (!content.renderer) {
|
|
1651
|
+
content.renderer = {};
|
|
1652
|
+
}
|
|
1653
|
+
var renderer = content.renderer;
|
|
1654
|
+
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1655
|
+
var startSize = item.transform.size;
|
|
1656
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
1657
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
1658
|
+
//@ts-expect-error
|
|
1659
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
1660
|
+
//@ts-expect-error
|
|
1661
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
1662
|
+
}
|
|
1663
|
+
//@ts-expect-error
|
|
1664
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
if (item.type === ItemType.particle) {
|
|
1668
|
+
var content = item.content;
|
|
1669
|
+
if (!content.renderer) {
|
|
1670
|
+
content.renderer = {};
|
|
1671
|
+
}
|
|
1672
|
+
var renderer = content.renderer;
|
|
1673
|
+
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1674
|
+
}
|
|
1675
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
1676
|
+
item.content.tracks = [];
|
|
1677
|
+
var tracks = item.content.tracks;
|
|
1678
|
+
if (item.type !== ItemType.particle) {
|
|
1679
|
+
tracks.push({
|
|
1680
|
+
clips: [
|
|
1681
|
+
{
|
|
1682
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
1683
|
+
animationClip: {
|
|
1684
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
1685
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
1686
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
1687
|
+
},
|
|
1688
|
+
},
|
|
1689
|
+
],
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
if (item.type === ItemType.sprite) {
|
|
1693
|
+
tracks.push({
|
|
1694
|
+
clips: [
|
|
1695
|
+
{
|
|
1696
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
1697
|
+
animationClip: {
|
|
1698
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
1699
|
+
startColor: item.content.options.startColor,
|
|
1700
|
+
},
|
|
1701
|
+
},
|
|
1702
|
+
],
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
1706
|
+
if (item.content.options.target) {
|
|
1707
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
1708
|
+
}
|
|
1709
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1710
|
+
var uuid = generateGUID();
|
|
1711
|
+
if (item.type === ItemType.sprite) {
|
|
1712
|
+
item.components = [];
|
|
1713
|
+
result.components.push(item.content);
|
|
1714
|
+
item.content.id = uuid;
|
|
1715
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
1716
|
+
item.content.item = { id: item.id };
|
|
1717
|
+
item.dataType = DataType.VFXItemData;
|
|
1718
|
+
//@ts-expect-error
|
|
1719
|
+
item.components.push({ id: item.content.id });
|
|
1720
|
+
}
|
|
1721
|
+
else if (item.type === ItemType.particle) {
|
|
1722
|
+
item.components = [];
|
|
1723
|
+
result.components.push(item.content);
|
|
1724
|
+
item.content.id = uuid;
|
|
1725
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
1726
|
+
item.content.item = { id: item.id };
|
|
1727
|
+
item.dataType = DataType.VFXItemData;
|
|
1728
|
+
//@ts-expect-error
|
|
1729
|
+
item.components.push({ id: item.content.id });
|
|
1730
|
+
}
|
|
1731
|
+
else if (item.type === ItemType.mesh) {
|
|
1732
|
+
item.components = [];
|
|
1733
|
+
result.components.push(item.content);
|
|
1734
|
+
item.content.id = uuid;
|
|
1735
|
+
item.content.dataType = DataType.MeshComponent;
|
|
1736
|
+
item.content.item = { id: item.id };
|
|
1737
|
+
item.dataType = DataType.VFXItemData;
|
|
1738
|
+
//@ts-expect-error
|
|
1739
|
+
item.components.push({ id: item.content.id });
|
|
1740
|
+
}
|
|
1741
|
+
else if (item.type === ItemType.skybox) {
|
|
1742
|
+
item.components = [];
|
|
1743
|
+
result.components.push(item.content);
|
|
1744
|
+
item.content.id = uuid;
|
|
1745
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
1746
|
+
item.content.item = { id: item.id };
|
|
1747
|
+
item.dataType = DataType.VFXItemData;
|
|
1748
|
+
//@ts-expect-error
|
|
1749
|
+
item.components.push({ id: item.content.id });
|
|
1750
|
+
}
|
|
1751
|
+
else if (item.type === ItemType.light) {
|
|
1752
|
+
item.components = [];
|
|
1753
|
+
result.components.push(item.content);
|
|
1754
|
+
item.content.id = uuid;
|
|
1755
|
+
item.content.dataType = DataType.LightComponent;
|
|
1756
|
+
item.content.item = { id: item.id };
|
|
1757
|
+
item.dataType = DataType.VFXItemData;
|
|
1758
|
+
//@ts-expect-error
|
|
1759
|
+
item.components.push({ id: item.content.id });
|
|
1760
|
+
}
|
|
1761
|
+
else if (item.type === 'camera') {
|
|
1762
|
+
item.components = [];
|
|
1763
|
+
result.components.push(item.content);
|
|
1764
|
+
item.content.id = uuid;
|
|
1765
|
+
item.content.dataType = DataType.CameraComponent;
|
|
1766
|
+
item.content.item = { id: item.id };
|
|
1767
|
+
item.dataType = DataType.VFXItemData;
|
|
1768
|
+
//@ts-expect-error
|
|
1769
|
+
item.components.push({ id: item.content.id });
|
|
1770
|
+
}
|
|
1771
|
+
else if (item.type === ItemType.tree) {
|
|
1772
|
+
item.components = [];
|
|
1773
|
+
result.components.push(item.content);
|
|
1774
|
+
item.content.id = uuid;
|
|
1775
|
+
item.content.dataType = DataType.TreeComponent;
|
|
1776
|
+
item.content.item = { id: item.id };
|
|
1777
|
+
item.dataType = DataType.VFXItemData;
|
|
1778
|
+
//@ts-expect-error
|
|
1779
|
+
item.components.push({ id: item.content.id });
|
|
1780
|
+
}
|
|
1781
|
+
else if (item.type === ItemType.interact) {
|
|
1782
|
+
item.components = [];
|
|
1783
|
+
result.components.push(item.content);
|
|
1784
|
+
item.content.id = uuid;
|
|
1785
|
+
item.content.dataType = DataType.InteractComponent;
|
|
1786
|
+
item.content.item = { id: item.id };
|
|
1787
|
+
item.dataType = DataType.VFXItemData;
|
|
1788
|
+
//@ts-expect-error
|
|
1789
|
+
item.components.push({ id: item.content.id });
|
|
1790
|
+
}
|
|
1791
|
+
else if (item.type === ItemType.camera) {
|
|
1792
|
+
item.components = [];
|
|
1793
|
+
result.components.push(item.content);
|
|
1794
|
+
item.content.id = uuid;
|
|
1795
|
+
item.content.dataType = DataType.CameraController;
|
|
1796
|
+
item.content.item = { id: item.id };
|
|
1797
|
+
item.dataType = DataType.VFXItemData;
|
|
1798
|
+
//@ts-expect-error
|
|
1799
|
+
item.components.push({ id: item.content.id });
|
|
1800
|
+
}
|
|
1801
|
+
else if (item.type === ItemType.text) {
|
|
1802
|
+
item.components = [];
|
|
1803
|
+
result.components.push(item.content);
|
|
1804
|
+
item.content.id = uuid;
|
|
1805
|
+
item.content.dataType = DataType.TextComponent;
|
|
1806
|
+
item.content.item = { id: item.id };
|
|
1807
|
+
item.dataType = DataType.VFXItemData;
|
|
1808
|
+
//@ts-expect-error
|
|
1809
|
+
item.components.push({ id: item.content.id });
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1814
|
+
finally {
|
|
1815
|
+
try {
|
|
1816
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
1817
|
+
}
|
|
1818
|
+
finally { if (e_3) throw e_3.error; }
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
try {
|
|
1822
|
+
// 更正Composition.endBehavior
|
|
1823
|
+
for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1824
|
+
var composition = _g.value;
|
|
1825
|
+
_loop_1(composition);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1829
|
+
finally {
|
|
1830
|
+
try {
|
|
1831
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
1832
|
+
}
|
|
1833
|
+
finally { if (e_1) throw e_1.error; }
|
|
1834
|
+
}
|
|
1835
|
+
result.version = '3.0';
|
|
1836
|
+
return result;
|
|
1837
|
+
}
|
|
1417
1838
|
|
|
1418
1839
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
1419
1840
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -1423,16 +1844,16 @@ function getStandardJSON(json) {
|
|
|
1423
1844
|
if (!json || typeof json !== 'object') {
|
|
1424
1845
|
throw Error('expect a json object');
|
|
1425
1846
|
}
|
|
1426
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
1847
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
1427
1848
|
version22Migration(json);
|
|
1428
1849
|
if (v0.test(json.version)) {
|
|
1429
1850
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
1430
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
1851
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
1431
1852
|
}
|
|
1432
1853
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
1433
1854
|
if (mainVersion) {
|
|
1434
|
-
if (Number(mainVersion) <
|
|
1435
|
-
return version21Migration(json);
|
|
1855
|
+
if (Number(mainVersion) < 3) {
|
|
1856
|
+
return version30Migration(version21Migration(json));
|
|
1436
1857
|
}
|
|
1437
1858
|
return json;
|
|
1438
1859
|
}
|
|
@@ -1702,5 +2123,5 @@ function getStandardItem(item, opt) {
|
|
|
1702
2123
|
}
|
|
1703
2124
|
}
|
|
1704
2125
|
|
|
1705
|
-
export { arrAdd, colorToArr, deleteEmptyValue, ensureColorExpression, ensureFixedNumber, ensureFixedNumberWithRandom, ensureFixedVec3, ensureGradient, ensureNumberExpression, ensureRGBAValue, ensureValueGetter, forEach, getGradientColor, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, normalizeColor, objectValueToNumber, parsePercent, quatFromXYZRotation, rotationZYXFromQuat };
|
|
2126
|
+
export { arrAdd, colorToArr, convertAnchor, deleteEmptyValue, ensureColorExpression, ensureFixedNumber, ensureFixedNumberWithRandom, ensureFixedVec3, ensureGradient, ensureNumberExpression, ensureRGBAValue, ensureValueGetter, forEach, generateGUID, getGradientColor, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, normalizeColor, objectValueToNumber, parsePercent, particleOriginTranslateMap, quatFromXYZRotation, rotationZYXFromQuat };
|
|
1706
2127
|
//# sourceMappingURL=fallback.mjs.map
|