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