@galacean/effects-specification 1.1.0-alpha.0 → 2.0.0-alpha.1
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/index.d.ts +2 -2
- package/dist/fallback/migration.d.ts +7 -3
- package/dist/fallback/utils.d.ts +8 -1
- package/dist/fallback.js +467 -15
- package/dist/fallback.js.map +1 -1
- package/dist/fallback.mjs +465 -16
- package/dist/fallback.mjs.map +1 -1
- package/dist/index.js +64 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -12
- package/dist/index.mjs.map +1 -1
- package/dist/src/binary.d.ts +1 -1
- package/dist/src/components.d.ts +93 -0
- package/dist/src/composition.d.ts +50 -1
- package/dist/src/image.d.ts +4 -9
- package/dist/src/index.d.ts +4 -1
- package/dist/src/item/base-item.d.ts +22 -6
- 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 +11 -1
- package/dist/src/item/model/camera.d.ts +24 -1
- package/dist/src/item/model/light.d.ts +48 -1
- package/dist/src/item/model/material.d.ts +1 -1
- package/dist/src/item/model/mesh.d.ts +28 -1
- package/dist/src/item/model/skybox.d.ts +46 -1
- package/dist/src/item/model/tree.d.ts +22 -0
- package/dist/src/item/null-item.d.ts +49 -1
- package/dist/src/item/particle-item.d.ts +73 -1
- package/dist/src/item/particle-shape.d.ts +1 -1
- package/dist/src/item/sprite-item.d.ts +49 -1
- package/dist/src/item/text-item.d.ts +45 -2
- package/dist/src/scene.d.ts +102 -2
- package/dist/src/text.d.ts +1 -1
- package/dist/src/type.d.ts +6 -2
- package/dist/src/vfx-item-data.d.ts +74 -0
- package/package.json +3 -2
- /package/dist/src/{numberExpression.d.ts → number-expression.d.ts} +0 -0
package/dist/fallback/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BaseItem, Composition, CompressedImage, Image, JSONScene, ParticleItem, RenderLevel, SpriteItem, TemplateImage, FilterItem } from '../src';
|
|
1
|
+
import type { BaseItem, Composition, CompressedImage, Image, JSONScene, ParticleItem, RenderLevel, SpriteItem, TemplateImage, VideoImage, FilterItem } from '../src';
|
|
2
2
|
export * from './utils';
|
|
3
3
|
export declare function getStandardJSON(json: any): JSONScene;
|
|
4
|
-
export declare function getStandardImage(image: any, index: number, imageTags: RenderLevel[]): TemplateImage | Image | CompressedImage;
|
|
4
|
+
export declare function getStandardImage(image: any, index: number, imageTags: RenderLevel[]): TemplateImage | Image | CompressedImage | VideoImage;
|
|
5
5
|
export declare function getStandardComposition(composition: any, opt?: {
|
|
6
6
|
plugins?: string[];
|
|
7
7
|
requires?: string[];
|
|
@@ -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:
|
|
5
|
+
* Version: v2.0.0-alpha.1
|
|
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,18 +452,12 @@ 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
|
-
/**
|
|
389
|
-
* 动态换图类型
|
|
390
|
-
* @since 1.3.0
|
|
391
|
-
*/
|
|
392
|
-
var BackgroundType;
|
|
393
|
-
(function (BackgroundType) {
|
|
394
|
-
BackgroundType["video"] = "video";
|
|
395
|
-
BackgroundType["image"] = "image";
|
|
396
|
-
})(BackgroundType || (BackgroundType = {}));
|
|
397
|
-
|
|
398
461
|
/*********************************************/
|
|
399
462
|
/* 基本数值属性参数 */
|
|
400
463
|
/*********************************************/
|
|
@@ -529,6 +592,26 @@ var ShapeArcMode;
|
|
|
529
592
|
ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
|
|
530
593
|
})(ShapeArcMode || (ShapeArcMode = {}));
|
|
531
594
|
|
|
595
|
+
var LightType;
|
|
596
|
+
(function (LightType) {
|
|
597
|
+
/**
|
|
598
|
+
* 点光源
|
|
599
|
+
*/
|
|
600
|
+
LightType["point"] = "point";
|
|
601
|
+
/**
|
|
602
|
+
* 聚光灯
|
|
603
|
+
*/
|
|
604
|
+
LightType["spot"] = "spot";
|
|
605
|
+
/**
|
|
606
|
+
* 方向光
|
|
607
|
+
*/
|
|
608
|
+
LightType["directional"] = "directional";
|
|
609
|
+
/**
|
|
610
|
+
* 环境光
|
|
611
|
+
*/
|
|
612
|
+
LightType["ambient"] = "ambient";
|
|
613
|
+
})(LightType || (LightType = {}));
|
|
614
|
+
|
|
532
615
|
var ModelBoundingType;
|
|
533
616
|
(function (ModelBoundingType) {
|
|
534
617
|
ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
|
|
@@ -680,6 +763,28 @@ var FontStyle;
|
|
|
680
763
|
FontStyle["oblique"] = "oblique";
|
|
681
764
|
})(FontStyle || (FontStyle = {}));
|
|
682
765
|
|
|
766
|
+
var DataType;
|
|
767
|
+
(function (DataType) {
|
|
768
|
+
DataType["VFXItemData"] = "VFXItemData";
|
|
769
|
+
DataType["EffectComponent"] = "EffectComponent";
|
|
770
|
+
DataType["Material"] = "Material";
|
|
771
|
+
DataType["Shader"] = "Shader";
|
|
772
|
+
DataType["SpriteComponent"] = "SpriteComponent";
|
|
773
|
+
DataType["ParticleSystem"] = "ParticleSystem";
|
|
774
|
+
DataType["InteractComponent"] = "InteractComponent";
|
|
775
|
+
DataType["CameraController"] = "CameraController";
|
|
776
|
+
DataType["Geometry"] = "Geometry";
|
|
777
|
+
DataType["Texture"] = "Texture";
|
|
778
|
+
DataType["TextComponent"] = "TextComponent";
|
|
779
|
+
// FIXME: 先完成ECS的场景转换,后面移到spec中
|
|
780
|
+
DataType["MeshComponent"] = "MeshComponent";
|
|
781
|
+
DataType["SkyboxComponent"] = "SkyboxComponent";
|
|
782
|
+
DataType["LightComponent"] = "LightComponent";
|
|
783
|
+
DataType["CameraComponent"] = "CameraComponent";
|
|
784
|
+
DataType["ModelPluginComponent"] = "ModelPluginComponent";
|
|
785
|
+
DataType["TreeComponent"] = "TreeComponent";
|
|
786
|
+
})(DataType || (DataType = {}));
|
|
787
|
+
|
|
683
788
|
/******************************************************************************
|
|
684
789
|
Copyright (c) Microsoft Corporation.
|
|
685
790
|
|
|
@@ -735,11 +840,22 @@ function __read(o, n) {
|
|
|
735
840
|
return ar;
|
|
736
841
|
}
|
|
737
842
|
|
|
843
|
+
function __spreadArray(to, from, pack) {
|
|
844
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
845
|
+
if (ar || !(i in from)) {
|
|
846
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
847
|
+
ar[i] = from[i];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
851
|
+
}
|
|
852
|
+
|
|
738
853
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
739
854
|
var e = new Error(message);
|
|
740
855
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
741
856
|
};
|
|
742
857
|
|
|
858
|
+
var _a;
|
|
743
859
|
function arrAdd(arr, item) {
|
|
744
860
|
if (!arr.includes(item)) {
|
|
745
861
|
arr.push(item);
|
|
@@ -975,6 +1091,34 @@ function rotationZYXFromQuat(out, quat) {
|
|
|
975
1091
|
}
|
|
976
1092
|
return out;
|
|
977
1093
|
}
|
|
1094
|
+
function generateGUID() {
|
|
1095
|
+
return v4().replace(/-/g, '');
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* 提取并转换 JSON 数据中的 anchor 值
|
|
1099
|
+
*/
|
|
1100
|
+
function convertAnchor(anchor, particleOrigin) {
|
|
1101
|
+
if (anchor) {
|
|
1102
|
+
return [anchor[0] - 0.5, 0.5 - anchor[1]];
|
|
1103
|
+
}
|
|
1104
|
+
else if (particleOrigin) {
|
|
1105
|
+
return particleOriginTranslateMap[particleOrigin];
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
return [0, 0];
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
var particleOriginTranslateMap = (_a = {},
|
|
1112
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [0, 0],
|
|
1113
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [0, -0.5],
|
|
1114
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [0, 0.5],
|
|
1115
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [-0.5, 0.5],
|
|
1116
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [-0.5, 0],
|
|
1117
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [-0.5, -0.5],
|
|
1118
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [0.5, 0],
|
|
1119
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [0.5, -0.5],
|
|
1120
|
+
_a[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [0.5, 0.5],
|
|
1121
|
+
_a);
|
|
978
1122
|
|
|
979
1123
|
function getStandardParticleContent(particle) {
|
|
980
1124
|
var _a;
|
|
@@ -1386,6 +1530,309 @@ function version22Migration(json) {
|
|
|
1386
1530
|
});
|
|
1387
1531
|
return json;
|
|
1388
1532
|
}
|
|
1533
|
+
/**
|
|
1534
|
+
* 3.0 以下版本数据适配(runtime 2.0及以上版本支持)
|
|
1535
|
+
*/
|
|
1536
|
+
function version30Migration(json) {
|
|
1537
|
+
var e_1, _a;
|
|
1538
|
+
var _b, _c, _d, _e;
|
|
1539
|
+
var result = Object.assign({}, json, {
|
|
1540
|
+
items: [],
|
|
1541
|
+
components: [],
|
|
1542
|
+
materials: [],
|
|
1543
|
+
shaders: [],
|
|
1544
|
+
geometries: [],
|
|
1545
|
+
});
|
|
1546
|
+
// 兼容老版本数据中不存在textures的情况
|
|
1547
|
+
(_b = result.textures) !== null && _b !== void 0 ? _b : (result.textures = []);
|
|
1548
|
+
result.textures.forEach(function (textureOptions) {
|
|
1549
|
+
Object.assign(textureOptions, {
|
|
1550
|
+
id: generateGUID(),
|
|
1551
|
+
dataType: DataType.Texture,
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1554
|
+
if (result.textures.length < result.images.length) {
|
|
1555
|
+
for (var i = result.textures.length; i < result.images.length; i++) {
|
|
1556
|
+
result.textures.push({
|
|
1557
|
+
//@ts-expect-error
|
|
1558
|
+
id: generateGUID(),
|
|
1559
|
+
dataType: DataType.Texture,
|
|
1560
|
+
source: i,
|
|
1561
|
+
flipY: true,
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
var _loop_1 = function (composition) {
|
|
1566
|
+
var e_2, _h, e_3, _j;
|
|
1567
|
+
// composition 的 endbehaviour 兼容
|
|
1568
|
+
if (composition.endBehavior === END_BEHAVIOR_PAUSE_AND_DESTROY || composition.endBehavior === END_BEHAVIOR_PAUSE) {
|
|
1569
|
+
composition.endBehavior = END_BEHAVIOR_FREEZE;
|
|
1570
|
+
}
|
|
1571
|
+
var itemGuidMap = {};
|
|
1572
|
+
try {
|
|
1573
|
+
for (var _k = (e_2 = void 0, __values(composition.items)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
1574
|
+
var item = _l.value;
|
|
1575
|
+
itemGuidMap[item.id] = generateGUID();
|
|
1576
|
+
// TODO: 编辑器测试用,上线后删除
|
|
1577
|
+
//@ts-expect-error
|
|
1578
|
+
item.oldId = item.id;
|
|
1579
|
+
item.id = itemGuidMap[item.id];
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1583
|
+
finally {
|
|
1584
|
+
try {
|
|
1585
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
1586
|
+
}
|
|
1587
|
+
finally { if (e_2) throw e_2.error; }
|
|
1588
|
+
}
|
|
1589
|
+
composition.items.forEach(function (item, index) {
|
|
1590
|
+
if (item.parentId) {
|
|
1591
|
+
if (item.parentId.includes('^')) {
|
|
1592
|
+
var parentId = (item.parentId).split('^')[0];
|
|
1593
|
+
var nodeId = (item.parentId).split('^')[1];
|
|
1594
|
+
item.parentId = itemGuidMap[parentId] + '^' + nodeId;
|
|
1595
|
+
}
|
|
1596
|
+
else {
|
|
1597
|
+
item.parentId = itemGuidMap[item.parentId];
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
// @ts-expect-error fix item type
|
|
1601
|
+
result.items.push(item);
|
|
1602
|
+
// @ts-expect-error fix item type
|
|
1603
|
+
composition.items[index] = { id: item.id };
|
|
1604
|
+
});
|
|
1605
|
+
try {
|
|
1606
|
+
for (var _m = (e_3 = void 0, __values(result.items)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
1607
|
+
var item = _o.value;
|
|
1608
|
+
// 原 texture 索引转为统一 guid 索引
|
|
1609
|
+
if (item.content) {
|
|
1610
|
+
if (item.content.renderer) {
|
|
1611
|
+
if (item.content.renderer.texture !== undefined) {
|
|
1612
|
+
var oldTextureId = item.content.renderer.texture;
|
|
1613
|
+
//@ts-expect-error
|
|
1614
|
+
item.content.renderer.texture = { id: result.textures[oldTextureId].id };
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (item.content.trails) {
|
|
1618
|
+
if (item.content.trails.texture !== undefined) {
|
|
1619
|
+
var oldTextureId = item.content.trails.texture;
|
|
1620
|
+
//@ts-expect-error
|
|
1621
|
+
item.content.trails.texture = { id: result.textures[oldTextureId].id };
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
// item 的 transform 属性由数组转为 {x:n, y:n, z:n}
|
|
1626
|
+
if (item.transform) {
|
|
1627
|
+
//@ts-expect-error
|
|
1628
|
+
var position = __spreadArray([], __read((_c = item.transform.position) !== null && _c !== void 0 ? _c : [0, 0, 0]), false);
|
|
1629
|
+
//@ts-expect-error
|
|
1630
|
+
var rotation = __spreadArray([], __read((_d = item.transform.rotation) !== null && _d !== void 0 ? _d : [0, 0, 0]), false);
|
|
1631
|
+
//@ts-expect-error
|
|
1632
|
+
var scale = __spreadArray([], __read((_e = item.transform.scale) !== null && _e !== void 0 ? _e : [1, 1, 1]), false);
|
|
1633
|
+
Object.assign(item, {
|
|
1634
|
+
transform: {
|
|
1635
|
+
position: { x: position[0], y: position[1], z: position[2] },
|
|
1636
|
+
rotation: { x: rotation[0], y: rotation[1], z: rotation[2] },
|
|
1637
|
+
scale: { x: scale[0], y: scale[1], z: scale[0] },
|
|
1638
|
+
},
|
|
1639
|
+
});
|
|
1640
|
+
// sprite 的 scale 转为 size
|
|
1641
|
+
if (item.type === ItemType.sprite) {
|
|
1642
|
+
item.transform.size = { x: scale[0], y: scale[1] };
|
|
1643
|
+
item.transform.scale = { x: 1, y: 1, z: 1 };
|
|
1644
|
+
}
|
|
1645
|
+
// sprite 的 anchor 修正
|
|
1646
|
+
if (item.type === ItemType.sprite) {
|
|
1647
|
+
var content = item.content;
|
|
1648
|
+
if (!content.renderer) {
|
|
1649
|
+
content.renderer = {};
|
|
1650
|
+
}
|
|
1651
|
+
var renderer = content.renderer;
|
|
1652
|
+
var realAnchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1653
|
+
var startSize = item.transform.size;
|
|
1654
|
+
// 兼容旧JSON(anchor和particleOrigin可能同时存在)
|
|
1655
|
+
if (!renderer.anchor && renderer.particleOrigin !== undefined) {
|
|
1656
|
+
//@ts-expect-error
|
|
1657
|
+
item.transform.position.x += -realAnchor[0] * startSize.x;
|
|
1658
|
+
//@ts-expect-error
|
|
1659
|
+
item.transform.position.y += -realAnchor[1] * startSize.y;
|
|
1660
|
+
}
|
|
1661
|
+
//@ts-expect-error
|
|
1662
|
+
item.transform.anchor = { x: realAnchor[0] * startSize.x, y: realAnchor[1] * startSize.y };
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
if (item.type === ItemType.particle) {
|
|
1666
|
+
var content = item.content;
|
|
1667
|
+
if (!content.renderer) {
|
|
1668
|
+
content.renderer = {};
|
|
1669
|
+
}
|
|
1670
|
+
var renderer = content.renderer;
|
|
1671
|
+
content.renderer.anchor = convertAnchor(renderer.anchor, renderer.particleOrigin);
|
|
1672
|
+
}
|
|
1673
|
+
// 动画数据转化 TODO: 动画数据移到 TimelineComponentData
|
|
1674
|
+
item.content.tracks = [];
|
|
1675
|
+
var tracks = item.content.tracks;
|
|
1676
|
+
if (item.type !== ItemType.particle) {
|
|
1677
|
+
tracks.push({
|
|
1678
|
+
clips: [
|
|
1679
|
+
{
|
|
1680
|
+
dataType: 'TransformAnimationPlayableAsset',
|
|
1681
|
+
animationClip: {
|
|
1682
|
+
sizeOverLifetime: item.content.sizeOverLifetime,
|
|
1683
|
+
rotationOverLifetime: item.content.rotationOverLifetime,
|
|
1684
|
+
positionOverLifetime: item.content.positionOverLifetime,
|
|
1685
|
+
},
|
|
1686
|
+
},
|
|
1687
|
+
],
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
if (item.type === ItemType.sprite) {
|
|
1691
|
+
tracks.push({
|
|
1692
|
+
clips: [
|
|
1693
|
+
{
|
|
1694
|
+
dataType: 'SpriteColorAnimationPlayableAsset',
|
|
1695
|
+
animationClip: {
|
|
1696
|
+
colorOverLifetime: item.content.colorOverLifetime,
|
|
1697
|
+
startColor: item.content.options.startColor,
|
|
1698
|
+
},
|
|
1699
|
+
},
|
|
1700
|
+
],
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
// gizmo 的 target id 转换为新的 item guid
|
|
1704
|
+
if (item.content.options.target) {
|
|
1705
|
+
item.content.options.target = itemGuidMap[item.content.options.target];
|
|
1706
|
+
}
|
|
1707
|
+
// item 的 content 转为 component data 加入 JSONScene.components
|
|
1708
|
+
var uuid = generateGUID();
|
|
1709
|
+
if (item.type === ItemType.sprite) {
|
|
1710
|
+
item.components = [];
|
|
1711
|
+
result.components.push(item.content);
|
|
1712
|
+
item.content.id = uuid;
|
|
1713
|
+
item.content.dataType = DataType.SpriteComponent;
|
|
1714
|
+
item.content.item = { id: item.id };
|
|
1715
|
+
item.dataType = DataType.VFXItemData;
|
|
1716
|
+
//@ts-expect-error
|
|
1717
|
+
item.components.push({ id: item.content.id });
|
|
1718
|
+
}
|
|
1719
|
+
else if (item.type === ItemType.particle) {
|
|
1720
|
+
item.components = [];
|
|
1721
|
+
result.components.push(item.content);
|
|
1722
|
+
item.content.id = uuid;
|
|
1723
|
+
item.content.dataType = DataType.ParticleSystem;
|
|
1724
|
+
item.content.item = { id: item.id };
|
|
1725
|
+
item.dataType = DataType.VFXItemData;
|
|
1726
|
+
//@ts-expect-error
|
|
1727
|
+
item.components.push({ id: item.content.id });
|
|
1728
|
+
}
|
|
1729
|
+
else if (item.type === ItemType.mesh) {
|
|
1730
|
+
item.components = [];
|
|
1731
|
+
result.components.push(item.content);
|
|
1732
|
+
item.content.id = uuid;
|
|
1733
|
+
item.content.dataType = DataType.MeshComponent;
|
|
1734
|
+
item.content.item = { id: item.id };
|
|
1735
|
+
item.dataType = DataType.VFXItemData;
|
|
1736
|
+
//@ts-expect-error
|
|
1737
|
+
item.components.push({ id: item.content.id });
|
|
1738
|
+
}
|
|
1739
|
+
else if (item.type === ItemType.skybox) {
|
|
1740
|
+
item.components = [];
|
|
1741
|
+
result.components.push(item.content);
|
|
1742
|
+
item.content.id = uuid;
|
|
1743
|
+
item.content.dataType = DataType.SkyboxComponent;
|
|
1744
|
+
item.content.item = { id: item.id };
|
|
1745
|
+
item.dataType = DataType.VFXItemData;
|
|
1746
|
+
//@ts-expect-error
|
|
1747
|
+
item.components.push({ id: item.content.id });
|
|
1748
|
+
}
|
|
1749
|
+
else if (item.type === ItemType.light) {
|
|
1750
|
+
item.components = [];
|
|
1751
|
+
result.components.push(item.content);
|
|
1752
|
+
item.content.id = uuid;
|
|
1753
|
+
item.content.dataType = DataType.LightComponent;
|
|
1754
|
+
item.content.item = { id: item.id };
|
|
1755
|
+
item.dataType = DataType.VFXItemData;
|
|
1756
|
+
//@ts-expect-error
|
|
1757
|
+
item.components.push({ id: item.content.id });
|
|
1758
|
+
}
|
|
1759
|
+
else if (item.type === 'camera') {
|
|
1760
|
+
item.components = [];
|
|
1761
|
+
result.components.push(item.content);
|
|
1762
|
+
item.content.id = uuid;
|
|
1763
|
+
item.content.dataType = DataType.CameraComponent;
|
|
1764
|
+
item.content.item = { id: item.id };
|
|
1765
|
+
item.dataType = DataType.VFXItemData;
|
|
1766
|
+
//@ts-expect-error
|
|
1767
|
+
item.components.push({ id: item.content.id });
|
|
1768
|
+
}
|
|
1769
|
+
else if (item.type === ItemType.tree) {
|
|
1770
|
+
item.components = [];
|
|
1771
|
+
result.components.push(item.content);
|
|
1772
|
+
item.content.id = uuid;
|
|
1773
|
+
item.content.dataType = DataType.TreeComponent;
|
|
1774
|
+
item.content.item = { id: item.id };
|
|
1775
|
+
item.dataType = DataType.VFXItemData;
|
|
1776
|
+
//@ts-expect-error
|
|
1777
|
+
item.components.push({ id: item.content.id });
|
|
1778
|
+
}
|
|
1779
|
+
else if (item.type === ItemType.interact) {
|
|
1780
|
+
item.components = [];
|
|
1781
|
+
result.components.push(item.content);
|
|
1782
|
+
item.content.id = uuid;
|
|
1783
|
+
item.content.dataType = DataType.InteractComponent;
|
|
1784
|
+
item.content.item = { id: item.id };
|
|
1785
|
+
item.dataType = DataType.VFXItemData;
|
|
1786
|
+
//@ts-expect-error
|
|
1787
|
+
item.components.push({ id: item.content.id });
|
|
1788
|
+
}
|
|
1789
|
+
else if (item.type === ItemType.camera) {
|
|
1790
|
+
item.components = [];
|
|
1791
|
+
result.components.push(item.content);
|
|
1792
|
+
item.content.id = uuid;
|
|
1793
|
+
item.content.dataType = DataType.CameraController;
|
|
1794
|
+
item.content.item = { id: item.id };
|
|
1795
|
+
item.dataType = DataType.VFXItemData;
|
|
1796
|
+
//@ts-expect-error
|
|
1797
|
+
item.components.push({ id: item.content.id });
|
|
1798
|
+
}
|
|
1799
|
+
else if (item.type === ItemType.text) {
|
|
1800
|
+
item.components = [];
|
|
1801
|
+
result.components.push(item.content);
|
|
1802
|
+
item.content.id = uuid;
|
|
1803
|
+
item.content.dataType = DataType.TextComponent;
|
|
1804
|
+
item.content.item = { id: item.id };
|
|
1805
|
+
item.dataType = DataType.VFXItemData;
|
|
1806
|
+
//@ts-expect-error
|
|
1807
|
+
item.components.push({ id: item.content.id });
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1812
|
+
finally {
|
|
1813
|
+
try {
|
|
1814
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
1815
|
+
}
|
|
1816
|
+
finally { if (e_3) throw e_3.error; }
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
try {
|
|
1820
|
+
// 更正Composition.endBehavior
|
|
1821
|
+
for (var _f = __values(json.compositions), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1822
|
+
var composition = _g.value;
|
|
1823
|
+
_loop_1(composition);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1827
|
+
finally {
|
|
1828
|
+
try {
|
|
1829
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
1830
|
+
}
|
|
1831
|
+
finally { if (e_1) throw e_1.error; }
|
|
1832
|
+
}
|
|
1833
|
+
result.version = '3.0';
|
|
1834
|
+
return result;
|
|
1835
|
+
}
|
|
1389
1836
|
|
|
1390
1837
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
1391
1838
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
@@ -1395,16 +1842,16 @@ function getStandardJSON(json) {
|
|
|
1395
1842
|
if (!json || typeof json !== 'object') {
|
|
1396
1843
|
throw Error('expect a json object');
|
|
1397
1844
|
}
|
|
1398
|
-
// 修正老版本数据中,meshItem以及lightItem结束行为错误问题
|
|
1845
|
+
// 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
|
|
1399
1846
|
version22Migration(json);
|
|
1400
1847
|
if (v0.test(json.version)) {
|
|
1401
1848
|
reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
|
|
1402
|
-
return version21Migration(getStandardJSONFromV0(json));
|
|
1849
|
+
return version30Migration(version21Migration(getStandardJSONFromV0(json)));
|
|
1403
1850
|
}
|
|
1404
1851
|
var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
|
|
1405
1852
|
if (mainVersion) {
|
|
1406
|
-
if (Number(mainVersion) <
|
|
1407
|
-
return version21Migration(json);
|
|
1853
|
+
if (Number(mainVersion) < 3) {
|
|
1854
|
+
return version30Migration(version21Migration(json));
|
|
1408
1855
|
}
|
|
1409
1856
|
return json;
|
|
1410
1857
|
}
|
|
@@ -1479,9 +1926,11 @@ function getStandardImage(image, index, imageTags) {
|
|
|
1479
1926
|
else if (image.url) {
|
|
1480
1927
|
return {
|
|
1481
1928
|
url: image.url,
|
|
1929
|
+
type: image.type,
|
|
1482
1930
|
webp: image.webp,
|
|
1483
1931
|
renderLevel: renderLevel,
|
|
1484
1932
|
oriY: oriY,
|
|
1933
|
+
loop: image.loop,
|
|
1485
1934
|
};
|
|
1486
1935
|
}
|
|
1487
1936
|
else if (image && image.sourceType) {
|
|
@@ -1674,6 +2123,7 @@ function getStandardItem(item, opt) {
|
|
|
1674
2123
|
|
|
1675
2124
|
exports.arrAdd = arrAdd;
|
|
1676
2125
|
exports.colorToArr = colorToArr;
|
|
2126
|
+
exports.convertAnchor = convertAnchor;
|
|
1677
2127
|
exports.deleteEmptyValue = deleteEmptyValue;
|
|
1678
2128
|
exports.ensureColorExpression = ensureColorExpression;
|
|
1679
2129
|
exports.ensureFixedNumber = ensureFixedNumber;
|
|
@@ -1684,6 +2134,7 @@ exports.ensureNumberExpression = ensureNumberExpression;
|
|
|
1684
2134
|
exports.ensureRGBAValue = ensureRGBAValue;
|
|
1685
2135
|
exports.ensureValueGetter = ensureValueGetter;
|
|
1686
2136
|
exports.forEach = forEach;
|
|
2137
|
+
exports.generateGUID = generateGUID;
|
|
1687
2138
|
exports.getGradientColor = getGradientColor;
|
|
1688
2139
|
exports.getStandardComposition = getStandardComposition;
|
|
1689
2140
|
exports.getStandardImage = getStandardImage;
|
|
@@ -1692,6 +2143,7 @@ exports.getStandardJSON = getStandardJSON;
|
|
|
1692
2143
|
exports.normalizeColor = normalizeColor;
|
|
1693
2144
|
exports.objectValueToNumber = objectValueToNumber;
|
|
1694
2145
|
exports.parsePercent = parsePercent;
|
|
2146
|
+
exports.particleOriginTranslateMap = particleOriginTranslateMap;
|
|
1695
2147
|
exports.quatFromXYZRotation = quatFromXYZRotation;
|
|
1696
2148
|
exports.rotationZYXFromQuat = rotationZYXFromQuat;
|
|
1697
2149
|
//# sourceMappingURL=fallback.js.map
|