@galacean/effects-specification 2.0.0-alpha.2 → 2.0.0-alpha.21

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.
Files changed (104) hide show
  1. package/README.md +2 -10
  2. package/es/animation-clip-data.d.ts +26 -0
  3. package/es/animation-clip-data.js +1 -0
  4. package/{dist/src → es}/binary.d.ts +9 -2
  5. package/es/binary.js +1 -0
  6. package/es/buitin-object-guid.d.ts +5 -0
  7. package/es/buitin-object-guid.js +5 -0
  8. package/es/components.d.ts +209 -0
  9. package/es/components.js +129 -0
  10. package/{dist/src → es}/composition.d.ts +28 -70
  11. package/es/composition.js +12 -0
  12. package/{dist/src → es}/constants.d.ts +23 -0
  13. package/es/constants.js +34 -0
  14. package/{dist/src → es}/image.d.ts +21 -27
  15. package/es/image.js +9 -0
  16. package/{dist/src → es}/index.d.ts +4 -2
  17. package/es/index.js +28 -0
  18. package/{dist/src → es}/item/base-item.d.ts +27 -8
  19. package/es/item/base-item.js +27 -0
  20. package/{dist/src → es}/item/camera-item.d.ts +6 -6
  21. package/es/item/camera-item.js +1 -0
  22. package/{dist/src → es}/item/composition-item.d.ts +4 -4
  23. package/es/item/composition-item.js +1 -0
  24. package/es/item/effect-item.d.ts +35 -0
  25. package/es/item/effect-item.js +1 -0
  26. package/{dist/src → es}/item/interact-item.d.ts +3 -3
  27. package/es/item/interact-item.js +1 -0
  28. package/es/item/model/binary.js +1 -0
  29. package/{dist/src → es}/item/model/camera.d.ts +2 -2
  30. package/es/item/model/camera.js +5 -0
  31. package/es/item/model/index.js +35 -0
  32. package/{dist/src → es}/item/model/light.d.ts +2 -2
  33. package/es/item/model/light.js +19 -0
  34. package/{dist/src → es}/item/model/material.d.ts +3 -3
  35. package/es/item/model/material.js +16 -0
  36. package/{dist/src → es}/item/model/mesh.d.ts +9 -8
  37. package/es/item/model/mesh.js +5 -0
  38. package/es/item/model/render.js +42 -0
  39. package/{dist/src → es}/item/model/skybox.d.ts +9 -3
  40. package/es/item/model/skybox.js +1 -0
  41. package/{dist/src → es}/item/model/tree.d.ts +10 -0
  42. package/es/item/model/tree.js +1 -0
  43. package/es/item/null-item.d.ts +46 -0
  44. package/es/item/null-item.js +1 -0
  45. package/{dist/src → es}/item/particle-item.d.ts +20 -23
  46. package/es/item/particle-item.js +14 -0
  47. package/es/item/particle-shape.js +19 -0
  48. package/{dist/src → es}/item/plugin-item.d.ts +3 -3
  49. package/es/item/plugin-item.js +1 -0
  50. package/{dist/src → es}/item/spine-item.d.ts +44 -20
  51. package/es/item/spine-item.js +1 -0
  52. package/{dist/src → es}/item/sprite-item.d.ts +3 -3
  53. package/es/item/sprite-item.js +1 -0
  54. package/{dist/src → es}/item/text-item.d.ts +3 -3
  55. package/es/item/text-item.js +1 -0
  56. package/{dist/src → es}/item.d.ts +2 -5
  57. package/es/item.js +1 -0
  58. package/{dist/src → es}/number-expression.d.ts +21 -8
  59. package/es/number-expression.js +91 -0
  60. package/{dist/src → es}/scene.d.ts +19 -19
  61. package/es/scene.js +1 -0
  62. package/{dist/src → es}/text.d.ts +3 -55
  63. package/es/text.js +84 -0
  64. package/es/timeline/index.d.ts +5 -0
  65. package/es/timeline/index.js +5 -0
  66. package/es/timeline/playables/sprite-color-playable-asset-data.d.ts +8 -0
  67. package/es/timeline/playables/sprite-color-playable-asset-data.js +1 -0
  68. package/es/timeline/playables/transform-playable-asset-data.d.ts +17 -0
  69. package/es/timeline/playables/transform-playable-asset-data.js +1 -0
  70. package/es/timeline/timeline-asset-data.d.ts +8 -0
  71. package/es/timeline/timeline-asset-data.js +1 -0
  72. package/es/timeline/timeline-clip-data.d.ts +11 -0
  73. package/es/timeline/timeline-clip-data.js +1 -0
  74. package/es/timeline/track/track-asset-data.d.ts +9 -0
  75. package/es/timeline/track/track-asset-data.js +1 -0
  76. package/{dist/src → es}/type.d.ts +45 -20
  77. package/es/type.js +342 -0
  78. package/{dist/src → es}/vfx-item-data.d.ts +10 -11
  79. package/es/vfx-item-data.js +1 -0
  80. package/package.json +26 -47
  81. package/dist/fallback/camera.d.ts +0 -2
  82. package/dist/fallback/filter.d.ts +0 -2
  83. package/dist/fallback/index.d.ts +0 -12
  84. package/dist/fallback/interact.d.ts +0 -2
  85. package/dist/fallback/migration.d.ts +0 -13
  86. package/dist/fallback/particle.d.ts +0 -2
  87. package/dist/fallback/sprite.d.ts +0 -3
  88. package/dist/fallback/utils.d.ts +0 -36
  89. package/dist/fallback.js +0 -2155
  90. package/dist/fallback.js.map +0 -1
  91. package/dist/fallback.mjs +0 -2127
  92. package/dist/fallback.mjs.map +0 -1
  93. package/dist/index.js +0 -758
  94. package/dist/index.js.map +0 -1
  95. package/dist/index.mjs +0 -743
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/src/components.d.ts +0 -93
  98. package/dist/src/item/effect-item.d.ts +0 -17
  99. package/dist/src/item/filter-item.d.ts +0 -99
  100. package/dist/src/item/null-item.d.ts +0 -94
  101. /package/{dist/src → es}/item/model/binary.d.ts +0 -0
  102. /package/{dist/src → es}/item/model/index.d.ts +0 -0
  103. /package/{dist/src → es}/item/model/render.d.ts +0 -0
  104. /package/{dist/src → es}/item/particle-shape.d.ts +0 -0
package/dist/fallback.mjs DELETED
@@ -1,2127 +0,0 @@
1
- /*!
2
- * Name: @galacean/effects-specification
3
- * Description: Galacean Effects JSON Specification
4
- * Author: Ant Group CO., Ltd.
5
- * Version: v2.0.0-alpha.2
6
- */
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
-
73
- /*********************************************/
74
- /* 元素属性参数类型 */
75
- /*********************************************/
76
- /**
77
- * 渲染等级
78
- */
79
- var RenderLevel;
80
- (function (RenderLevel) {
81
- RenderLevel["S"] = "S";
82
- RenderLevel["APlus"] = "A+";
83
- RenderLevel["A"] = "A";
84
- RenderLevel["BPlus"] = "B+";
85
- RenderLevel["B"] = "B";
86
- })(RenderLevel || (RenderLevel = {}));
87
- /**
88
- * 混合模式
89
- */
90
- var BlendingMode;
91
- (function (BlendingMode) {
92
- /**
93
- * 普通混合模式
94
- */
95
- BlendingMode[BlendingMode["ALPHA"] = 0] = "ALPHA";
96
- /**
97
- * 叠加混合模式
98
- */
99
- BlendingMode[BlendingMode["ADD"] = 1] = "ADD";
100
- /**
101
- * 相乘混合模式
102
- */
103
- BlendingMode[BlendingMode["MULTIPLY"] = 2] = "MULTIPLY";
104
- /**
105
- * 亮度混合模式
106
- */
107
- BlendingMode[BlendingMode["BRIGHTNESS"] = 3] = "BRIGHTNESS";
108
- /**
109
- * 减色混合模式
110
- */
111
- BlendingMode[BlendingMode["SUBTRACTION"] = 4] = "SUBTRACTION";
112
- /**
113
- * 强光混合模式
114
- */
115
- BlendingMode[BlendingMode["STRONG_LIGHT"] = 5] = "STRONG_LIGHT";
116
- /**
117
- * 弱光混合模式
118
- */
119
- BlendingMode[BlendingMode["WEAK_LIGHT"] = 6] = "WEAK_LIGHT";
120
- /**
121
- * 亮度叠加混合模式
122
- */
123
- BlendingMode[BlendingMode["SUPERPOSITION"] = 7] = "SUPERPOSITION";
124
- })(BlendingMode || (BlendingMode = {}));
125
- /**
126
- * 单双面模式
127
- */
128
- var SideMode;
129
- (function (SideMode) {
130
- /**
131
- * 双面模式
132
- */
133
- SideMode[SideMode["DOUBLE"] = 1032] = "DOUBLE";
134
- /**
135
- * 正面模式
136
- */
137
- SideMode[SideMode["FRONT"] = 1028] = "FRONT";
138
- /**
139
- * 背面模式
140
- */
141
- SideMode[SideMode["BACK"] = 1029] = "BACK";
142
- })(SideMode || (SideMode = {}));
143
- /**
144
- * 蒙版模式
145
- */
146
- var MaskMode;
147
- (function (MaskMode) {
148
- /**
149
- * 无蒙版
150
- */
151
- MaskMode[MaskMode["NONE"] = 0] = "NONE";
152
- /**
153
- * 蒙版
154
- */
155
- MaskMode[MaskMode["MASK"] = 1] = "MASK";
156
- /**
157
- * 被遮挡
158
- */
159
- MaskMode[MaskMode["OBSCURED"] = 2] = "OBSCURED";
160
- /**
161
- * 被反向遮挡
162
- */
163
- MaskMode[MaskMode["REVERSE_OBSCURED"] = 3] = "REVERSE_OBSCURED";
164
- })(MaskMode || (MaskMode = {}));
165
- /**
166
- * 发射器形状
167
- */
168
- var ShapeType;
169
- (function (ShapeType) {
170
- /**
171
- * 没有类型
172
- */
173
- ShapeType[ShapeType["NONE"] = 0] = "NONE";
174
- /**
175
- * 圆球
176
- */
177
- ShapeType[ShapeType["SPHERE"] = 1] = "SPHERE";
178
- /**
179
- * 圆锥
180
- */
181
- ShapeType[ShapeType["CONE"] = 2] = "CONE";
182
- /**
183
- * 半球
184
- */
185
- ShapeType[ShapeType["HEMISPHERE"] = 3] = "HEMISPHERE";
186
- /**
187
- * 圆
188
- */
189
- ShapeType[ShapeType["CIRCLE"] = 4] = "CIRCLE";
190
- /**
191
- * 圆环
192
- */
193
- ShapeType[ShapeType["DONUT"] = 5] = "DONUT";
194
- /**
195
- * 矩形
196
- */
197
- ShapeType[ShapeType["RECTANGLE"] = 6] = "RECTANGLE";
198
- /**
199
- * 矩形框
200
- */
201
- ShapeType[ShapeType["RECTANGLE_EDGE"] = 7] = "RECTANGLE_EDGE";
202
- /**
203
- * 直线
204
- */
205
- ShapeType[ShapeType["EDGE"] = 8] = "EDGE";
206
- /**
207
- * 贴图
208
- */
209
- ShapeType[ShapeType["TEXTURE"] = 9] = "TEXTURE";
210
- })(ShapeType || (ShapeType = {}));
211
- /**
212
- * 插件类型
213
- */
214
- var PluginType;
215
- (function (PluginType) {
216
- /**
217
- * 陀螺仪
218
- */
219
- PluginType[PluginType["GYROSCOPE"] = 0] = "GYROSCOPE";
220
- /**
221
- * Spine
222
- */
223
- PluginType[PluginType["SPINE"] = 1] = "SPINE";
224
- })(PluginType || (PluginType = {}));
225
- /**
226
- * 交互类型
227
- */
228
- var InteractType;
229
- (function (InteractType) {
230
- /**
231
- * 点击
232
- */
233
- InteractType[InteractType["CLICK"] = 0] = "CLICK";
234
- /**
235
- * 消息
236
- * 前端收到 onMessageItem 回调
237
- */
238
- InteractType[InteractType["MESSAGE"] = 1] = "MESSAGE";
239
- /**
240
- * 拖拽
241
- */
242
- InteractType[InteractType["DRAG"] = 2] = "DRAG";
243
- })(InteractType || (InteractType = {}));
244
- /**
245
- * 交互行为
246
- */
247
- var InteractBehavior;
248
- (function (InteractBehavior) {
249
- /**
250
- * 无
251
- */
252
- InteractBehavior[InteractBehavior["NONE"] = 0] = "NONE";
253
- /**
254
- * 通知
255
- */
256
- InteractBehavior[InteractBehavior["NOTIFY"] = 1] = "NOTIFY";
257
- /**
258
- * 重置播放器
259
- */
260
- InteractBehavior[InteractBehavior["RESUME_PLAYER"] = 2] = "RESUME_PLAYER";
261
- /**
262
- * 清除元素
263
- */
264
- InteractBehavior[InteractBehavior["REMOVE"] = 3] = "REMOVE";
265
- /**
266
- * 暂停播放器
267
- */
268
- InteractBehavior[InteractBehavior["PAUSE"] = 4] = "PAUSE";
269
- })(InteractBehavior || (InteractBehavior = {}));
270
- /**
271
- * 元素类型
272
- */
273
- var ItemType;
274
- (function (ItemType) {
275
- /**
276
- * 错误元素
277
- */
278
- ItemType["base"] = "0";
279
- /**
280
- * 图层元素
281
- */
282
- ItemType["sprite"] = "1";
283
- /**
284
- * 粒子元素
285
- */
286
- ItemType["particle"] = "2";
287
- /**
288
- * 空节点元素
289
- */
290
- ItemType["null"] = "3";
291
- /**
292
- * 交互元素
293
- */
294
- ItemType["interact"] = "4";
295
- /**
296
- * 插件元素
297
- */
298
- ItemType["plugin"] = "5";
299
- /**
300
- * 相机元素
301
- */
302
- ItemType["camera"] = "6";
303
- /**
304
- * 预合成元素
305
- */
306
- ItemType["composition"] = "7";
307
- /**
308
- * 滤镜图层
309
- */
310
- ItemType["filter"] = "8";
311
- /**
312
- * Spine 元素
313
- */
314
- ItemType["spine"] = "spine";
315
- /**
316
- * Mesh 元素
317
- */
318
- ItemType["mesh"] = "mesh";
319
- /**
320
- * 节点树元素
321
- */
322
- ItemType["tree"] = "tree";
323
- /**
324
- * 文本元素
325
- */
326
- ItemType["text"] = "text";
327
- /**
328
- * 灯光元素
329
- */
330
- ItemType["light"] = "light";
331
- /**
332
- * 天空盒元素
333
- */
334
- ItemType["skybox"] = "skybox";
335
- /**
336
- * 特效元素
337
- */
338
- ItemType["effect"] = "effect";
339
- })(ItemType || (ItemType = {}));
340
- /**
341
- * 渲染模式
342
- */
343
- var RenderMode;
344
- (function (RenderMode) {
345
- /**
346
- * 广告牌模式
347
- */
348
- RenderMode[RenderMode["BILLBOARD"] = 0] = "BILLBOARD";
349
- /**
350
- * 网格模式
351
- */
352
- RenderMode[RenderMode["MESH"] = 1] = "MESH";
353
- /**
354
- * 垂直广告牌模式
355
- */
356
- RenderMode[RenderMode["VERTICAL_BILLBOARD"] = 2] = "VERTICAL_BILLBOARD";
357
- /**
358
- * 水平广告牌模式
359
- */
360
- RenderMode[RenderMode["HORIZONTAL_BILLBOARD"] = 3] = "HORIZONTAL_BILLBOARD";
361
- })(RenderMode || (RenderMode = {}));
362
- /**
363
- * 变换中心
364
- */
365
- var ParticleOrigin;
366
- (function (ParticleOrigin) {
367
- /**
368
- * 水平和垂直中点
369
- */
370
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER"] = 0] = "PARTICLE_ORIGIN_CENTER";
371
- /**
372
- * 水平左侧 垂直顶部
373
- */
374
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_TOP"] = 1] = "PARTICLE_ORIGIN_LEFT_TOP";
375
- /**
376
- * 水平左侧 垂直中间
377
- */
378
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_CENTER"] = 2] = "PARTICLE_ORIGIN_LEFT_CENTER";
379
- /**
380
- * 水平左侧 垂直底部
381
- */
382
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_LEFT_BOTTOM"] = 3] = "PARTICLE_ORIGIN_LEFT_BOTTOM";
383
- /**
384
- * 水平中间 垂直顶部
385
- */
386
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER_TOP"] = 4] = "PARTICLE_ORIGIN_CENTER_TOP";
387
- /**
388
- * 水平中间 垂直底部
389
- */
390
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_CENTER_BOTTOM"] = 5] = "PARTICLE_ORIGIN_CENTER_BOTTOM";
391
- /**
392
- * 水平右侧 垂直顶部
393
- */
394
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_TOP"] = 6] = "PARTICLE_ORIGIN_RIGHT_TOP";
395
- /**
396
- * 水平右侧 垂直中间
397
- */
398
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_CENTER"] = 7] = "PARTICLE_ORIGIN_RIGHT_CENTER";
399
- /**
400
- * 水平右侧 垂直底部
401
- */
402
- ParticleOrigin[ParticleOrigin["PARTICLE_ORIGIN_RIGHT_BOTTOM"] = 8] = "PARTICLE_ORIGIN_RIGHT_BOTTOM";
403
- })(ParticleOrigin || (ParticleOrigin = {}));
404
-
405
- var END_BEHAVIOR_DESTROY = 0;
406
- var END_BEHAVIOR_PAUSE = 1;
407
- var END_BEHAVIOR_FORWARD = 2;
408
- var END_BEHAVIOR_PAUSE_AND_DESTROY = 3;
409
- var END_BEHAVIOR_FREEZE = 4;
410
- var END_BEHAVIOR_RESTART = 5;
411
- var END_BEHAVIOR_DESTROY_CHILDREN = 6;
412
- var CAMERA_CLIP_MODE_VERTICAL = 1;
413
- var CAMERA_CLIP_MODE_NORMAL = 0;
414
-
415
- var CameraClipMode;
416
- (function (CameraClipMode) {
417
- /**
418
- * 剪裁上下
419
- */
420
- CameraClipMode[CameraClipMode["portrait"] = CAMERA_CLIP_MODE_VERTICAL] = "portrait";
421
- /**
422
- * 剪裁左右
423
- */
424
- CameraClipMode[CameraClipMode["landscape"] = CAMERA_CLIP_MODE_NORMAL] = "landscape";
425
- })(CameraClipMode || (CameraClipMode = {}));
426
- /**
427
- * 结束行为
428
- */
429
- var CompositionEndBehavior;
430
- (function (CompositionEndBehavior) {
431
- /**
432
- * 销毁
433
- */
434
- CompositionEndBehavior[CompositionEndBehavior["destroy"] = END_BEHAVIOR_DESTROY] = "destroy";
435
- /**
436
- * 暂停
437
- */
438
- CompositionEndBehavior[CompositionEndBehavior["pause"] = END_BEHAVIOR_PAUSE] = "pause";
439
- /**
440
- * 重播
441
- */
442
- CompositionEndBehavior[CompositionEndBehavior["restart"] = END_BEHAVIOR_RESTART] = "restart";
443
- /**
444
- * 无限播放
445
- */
446
- CompositionEndBehavior[CompositionEndBehavior["forward"] = END_BEHAVIOR_FORWARD] = "forward";
447
- /**
448
- * 销毁并保留最后一帧
449
- */
450
- CompositionEndBehavior[CompositionEndBehavior["pause_destroy"] = END_BEHAVIOR_PAUSE_AND_DESTROY] = "pause_destroy";
451
- /**
452
- * 冻结
453
- */
454
- CompositionEndBehavior[CompositionEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
455
- })(CompositionEndBehavior || (CompositionEndBehavior = {}));
456
-
457
- /*********************************************/
458
- /* 基本数值属性参数 */
459
- /*********************************************/
460
- var ValueType;
461
- (function (ValueType) {
462
- /**
463
- * 常数
464
- */
465
- ValueType[ValueType["CONSTANT"] = 0] = "CONSTANT";
466
- /**
467
- * 二维常数向量
468
- */
469
- ValueType[ValueType["CONSTANT_VEC2"] = 1] = "CONSTANT_VEC2";
470
- /**
471
- * 三维常数向量
472
- */
473
- ValueType[ValueType["CONSTANT_VEC3"] = 2] = "CONSTANT_VEC3";
474
- /**
475
- * 四维常数向量
476
- */
477
- ValueType[ValueType["CONSTANT_VEC4"] = 3] = "CONSTANT_VEC4";
478
- /**
479
- * 随机数
480
- */
481
- ValueType[ValueType["RANDOM"] = 4] = "RANDOM";
482
- /**
483
- * 直线
484
- */
485
- ValueType[ValueType["LINE"] = 5] = "LINE";
486
- /**
487
- * 曲线
488
- */
489
- ValueType[ValueType["CURVE"] = 6] = "CURVE";
490
- /**
491
- * 贝塞尔路径
492
- */
493
- ValueType[ValueType["BEZIER_PATH"] = 7] = "BEZIER_PATH";
494
- /**
495
- * 颜色
496
- */
497
- ValueType[ValueType["RGBA_COLOR"] = 8] = "RGBA_COLOR";
498
- /**
499
- * 渐变色
500
- */
501
- ValueType[ValueType["GRADIENT_COLOR"] = 9] = "GRADIENT_COLOR";
502
- /**
503
- * 蒙版形状点集
504
- */
505
- ValueType[ValueType["SHAPE_POINTS"] = 10] = "SHAPE_POINTS";
506
- /**
507
- * 蒙版形状切分
508
- */
509
- ValueType[ValueType["SHAPE_SPLITS"] = 11] = "SHAPE_SPLITS";
510
- /**
511
- *直线路径
512
- */
513
- ValueType[ValueType["LINEAR_PATH"] = 12] = "LINEAR_PATH";
514
- /**
515
- * 多色
516
- */
517
- ValueType[ValueType["COLORS"] = 13] = "COLORS";
518
- /**
519
- * 二进制指针
520
- */
521
- ValueType[ValueType["BINARY"] = 20] = "BINARY";
522
- /**
523
- * 贝塞尔曲线
524
- */
525
- ValueType[ValueType["BEZIER_CURVE"] = 21] = "BEZIER_CURVE";
526
- /**
527
- * 贝塞尔曲线路径
528
- */
529
- ValueType[ValueType["BEZIER_CURVE_PATH"] = 22] = "BEZIER_CURVE_PATH";
530
- })(ValueType || (ValueType = {}));
531
- /**
532
- * 关键帧类型
533
- */
534
- var BezierKeyframeType;
535
- (function (BezierKeyframeType) {
536
- BezierKeyframeType[BezierKeyframeType["AUTO"] = 0] = "AUTO";
537
- BezierKeyframeType[BezierKeyframeType["EASE"] = 1] = "EASE";
538
- BezierKeyframeType[BezierKeyframeType["EASE_IN"] = 2] = "EASE_IN";
539
- BezierKeyframeType[BezierKeyframeType["EASE_OUT"] = 3] = "EASE_OUT";
540
- BezierKeyframeType[BezierKeyframeType["LINE"] = 4] = "LINE";
541
- BezierKeyframeType[BezierKeyframeType["HOLD"] = 5] = "HOLD";
542
- BezierKeyframeType[BezierKeyframeType["LINE_OUT"] = 6] = "LINE_OUT";
543
- })(BezierKeyframeType || (BezierKeyframeType = {}));
544
-
545
- var ItemEndBehavior;
546
- (function (ItemEndBehavior) {
547
- ItemEndBehavior[ItemEndBehavior["destroy"] = END_BEHAVIOR_DESTROY] = "destroy";
548
- ItemEndBehavior[ItemEndBehavior["loop"] = END_BEHAVIOR_RESTART] = "loop";
549
- ItemEndBehavior[ItemEndBehavior["freeze"] = END_BEHAVIOR_FREEZE] = "freeze";
550
- })(ItemEndBehavior || (ItemEndBehavior = {}));
551
- var ParentItemEndBehavior;
552
- (function (ParentItemEndBehavior) {
553
- ParentItemEndBehavior[ParentItemEndBehavior["destroyChildren"] = END_BEHAVIOR_DESTROY_CHILDREN] = "destroyChildren";
554
- })(ParentItemEndBehavior || (ParentItemEndBehavior = {}));
555
-
556
- /**
557
- * 粒子交互行为
558
- */
559
- var ParticleInteractionBehavior;
560
- (function (ParticleInteractionBehavior) {
561
- /**
562
- * 无
563
- */
564
- ParticleInteractionBehavior[ParticleInteractionBehavior["none"] = 0] = "none";
565
- /**
566
- * 移出粒子
567
- */
568
- ParticleInteractionBehavior[ParticleInteractionBehavior["removeParticle"] = 1] = "removeParticle";
569
- })(ParticleInteractionBehavior || (ParticleInteractionBehavior = {}));
570
-
571
- var ShapeArcMode;
572
- (function (ShapeArcMode) {
573
- /**
574
- * 随机
575
- */
576
- ShapeArcMode[ShapeArcMode["RANDOM"] = 0] = "RANDOM";
577
- /**
578
- * 单向循环
579
- */
580
- ShapeArcMode[ShapeArcMode["UNIDIRECTIONAL_CYCLE"] = 1] = "UNIDIRECTIONAL_CYCLE";
581
- /**
582
- * 双向循环
583
- */
584
- ShapeArcMode[ShapeArcMode["BIDIRECTIONAL_CYCLE"] = 2] = "BIDIRECTIONAL_CYCLE";
585
- /**
586
- * 均匀爆发
587
- */
588
- ShapeArcMode[ShapeArcMode["UNIFORM_BURST"] = 3] = "UNIFORM_BURST";
589
- })(ShapeArcMode || (ShapeArcMode = {}));
590
-
591
- var LightType;
592
- (function (LightType) {
593
- /**
594
- * 点光源
595
- */
596
- LightType["point"] = "point";
597
- /**
598
- * 聚光灯
599
- */
600
- LightType["spot"] = "spot";
601
- /**
602
- * 方向光
603
- */
604
- LightType["directional"] = "directional";
605
- /**
606
- * 环境光
607
- */
608
- LightType["ambient"] = "ambient";
609
- })(LightType || (LightType = {}));
610
-
611
- var ModelBoundingType;
612
- (function (ModelBoundingType) {
613
- ModelBoundingType[ModelBoundingType["box"] = 2] = "box";
614
- ModelBoundingType[ModelBoundingType["sphere"] = 3] = "sphere";
615
- })(ModelBoundingType || (ModelBoundingType = {}));
616
-
617
- var CameraType;
618
- (function (CameraType) {
619
- CameraType["orthographic"] = "orthographic";
620
- CameraType["perspective"] = "perspective";
621
- })(CameraType || (CameraType = {}));
622
-
623
- // 材质类型
624
- var MaterialType;
625
- (function (MaterialType) {
626
- MaterialType["unlit"] = "unlit";
627
- MaterialType["pbr"] = "pbr";
628
- // 头发材质,在 pbr 材质基础上扩展
629
- MaterialType["hair"] = "hair";
630
- })(MaterialType || (MaterialType = {}));
631
- // 混合模式
632
- var MaterialBlending;
633
- (function (MaterialBlending) {
634
- MaterialBlending[MaterialBlending["opaque"] = 100] = "opaque";
635
- MaterialBlending[MaterialBlending["masked"] = 101] = "masked";
636
- MaterialBlending[MaterialBlending["translucent"] = 102] = "translucent";
637
- MaterialBlending[MaterialBlending["additive"] = 103] = "additive";
638
- })(MaterialBlending || (MaterialBlending = {}));
639
-
640
- /**
641
- * 3D渲染模式:将渲染过程中的中间结果输出,主要用于排查渲染效果问题,支持 pbr 和 unlit 材质
642
- */
643
- var RenderMode3D;
644
- (function (RenderMode3D) {
645
- /**
646
- * 正常渲染
647
- */
648
- RenderMode3D["none"] = "none";
649
- /**
650
- * 纹理坐标
651
- */
652
- RenderMode3D["uv"] = "uv";
653
- /**
654
- * 世界坐标法线
655
- */
656
- RenderMode3D["normal"] = "normal";
657
- /**
658
- * 基础颜色
659
- */
660
- RenderMode3D["basecolor"] = "basecolor";
661
- /**
662
- * 基础颜色 Alpha
663
- */
664
- RenderMode3D["alpha"] = "alpha";
665
- /**
666
- * 金属度
667
- */
668
- RenderMode3D["metallic"] = "metallic";
669
- /**
670
- * 粗超度
671
- */
672
- RenderMode3D["roughness"] = "roughness";
673
- /**
674
- * 环境遮蔽
675
- */
676
- RenderMode3D["ao"] = "ao";
677
- /**
678
- * 自发光
679
- */
680
- RenderMode3D["emissive"] = "emissive";
681
- })(RenderMode3D || (RenderMode3D = {}));
682
-
683
- var TextOverflow;
684
- (function (TextOverflow) {
685
- /**
686
- * display 模式下,会显示所有文本,存在文本超过边界框的情况。
687
- */
688
- TextOverflow[TextOverflow["display"] = 0] = "display";
689
- /**
690
- * clip 模式下,当文本内容超出边界框时,多余的会被截断。
691
- */
692
- TextOverflow[TextOverflow["clip"] = 1] = "clip";
693
- /**
694
- * ellipsis 模式下,会使用(...)来代替超出边界框的内容。
695
- */
696
- TextOverflow[TextOverflow["ellipsis"] = 2] = "ellipsis";
697
- })(TextOverflow || (TextOverflow = {}));
698
- var TextBaseline;
699
- (function (TextBaseline) {
700
- /**
701
- * 文本顶对齐。
702
- */
703
- TextBaseline[TextBaseline["top"] = 0] = "top";
704
- /**
705
- * 文本垂直居中对齐。
706
- */
707
- TextBaseline[TextBaseline["middle"] = 1] = "middle";
708
- /**
709
- * 文本底对齐。
710
- */
711
- TextBaseline[TextBaseline["bottom"] = 2] = "bottom";
712
- })(TextBaseline || (TextBaseline = {}));
713
- var TextAlignment;
714
- (function (TextAlignment) {
715
- /**
716
- * text alignment starts from(x,y) to right direction
717
- * 从(x,y)开始第一个字符,向右边延伸
718
- */
719
- TextAlignment[TextAlignment["left"] = 0] = "left";
720
- /**
721
- * (x,y) is middle position of text, where (left + right)/2 =(x,y)
722
- * (x,y) 为文字中间位置,(最左位置 + 最右位置)/2 = (x,y)
723
- */
724
- TextAlignment[TextAlignment["middle"] = 1] = "middle";
725
- /**
726
- * text alignment ends with(x,y) from left direction
727
- * 从(x,y)结束最后一个字符,向左边延伸
728
- */
729
- TextAlignment[TextAlignment["right"] = 2] = "right";
730
- })(TextAlignment || (TextAlignment = {}));
731
- /**
732
- * 文本字重
733
- */
734
- var TextWeight;
735
- (function (TextWeight) {
736
- /**
737
- * 正常
738
- */
739
- TextWeight["normal"] = "normal";
740
- /**
741
- * 粗体
742
- */
743
- TextWeight["bold"] = "bold";
744
- /**
745
- * 瘦体
746
- */
747
- TextWeight["lighter"] = "lighter";
748
- })(TextWeight || (TextWeight = {}));
749
- /**
750
- * 文本样式
751
- */
752
- var FontStyle;
753
- (function (FontStyle) {
754
- /**
755
- * 正常
756
- */
757
- FontStyle["normal"] = "normal";
758
- /**
759
- * 斜体
760
- */
761
- FontStyle["italic"] = "italic";
762
- /**
763
- * 倾斜体
764
- */
765
- FontStyle["oblique"] = "oblique";
766
- })(FontStyle || (FontStyle = {}));
767
-
768
- var DataType;
769
- (function (DataType) {
770
- DataType["VFXItemData"] = "VFXItemData";
771
- DataType["EffectComponent"] = "EffectComponent";
772
- DataType["Material"] = "Material";
773
- DataType["Shader"] = "Shader";
774
- DataType["SpriteComponent"] = "SpriteComponent";
775
- DataType["ParticleSystem"] = "ParticleSystem";
776
- DataType["InteractComponent"] = "InteractComponent";
777
- DataType["CameraController"] = "CameraController";
778
- DataType["Geometry"] = "Geometry";
779
- DataType["Texture"] = "Texture";
780
- DataType["TextComponent"] = "TextComponent";
781
- // FIXME: 先完成ECS的场景转换,后面移到spec中
782
- DataType["MeshComponent"] = "MeshComponent";
783
- DataType["SkyboxComponent"] = "SkyboxComponent";
784
- DataType["LightComponent"] = "LightComponent";
785
- DataType["CameraComponent"] = "CameraComponent";
786
- DataType["ModelPluginComponent"] = "ModelPluginComponent";
787
- DataType["TreeComponent"] = "TreeComponent";
788
- })(DataType || (DataType = {}));
789
-
790
- /******************************************************************************
791
- Copyright (c) Microsoft Corporation.
792
-
793
- Permission to use, copy, modify, and/or distribute this software for any
794
- purpose with or without fee is hereby granted.
795
-
796
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
797
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
798
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
799
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
800
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
801
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
802
- PERFORMANCE OF THIS SOFTWARE.
803
- ***************************************************************************** */
804
-
805
- var __assign = function() {
806
- __assign = Object.assign || function __assign(t) {
807
- for (var s, i = 1, n = arguments.length; i < n; i++) {
808
- s = arguments[i];
809
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
810
- }
811
- return t;
812
- };
813
- return __assign.apply(this, arguments);
814
- };
815
-
816
- function __values(o) {
817
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
818
- if (m) return m.call(o);
819
- if (o && typeof o.length === "number") return {
820
- next: function () {
821
- if (o && i >= o.length) o = void 0;
822
- return { value: o && o[i++], done: !o };
823
- }
824
- };
825
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
826
- }
827
-
828
- function __read(o, n) {
829
- var m = typeof Symbol === "function" && o[Symbol.iterator];
830
- if (!m) return o;
831
- var i = m.call(o), r, ar = [], e;
832
- try {
833
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
834
- }
835
- catch (error) { e = { error: error }; }
836
- finally {
837
- try {
838
- if (r && !r.done && (m = i["return"])) m.call(i);
839
- }
840
- finally { if (e) throw e.error; }
841
- }
842
- return ar;
843
- }
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
-
855
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
856
- var e = new Error(message);
857
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
858
- };
859
-
860
- var _a;
861
- function arrAdd(arr, item) {
862
- if (!arr.includes(item)) {
863
- arr.push(item);
864
- return true;
865
- }
866
- }
867
- /**
868
- * @deprecated 请直接使用 Array.prototype.forEach 或 for...of
869
- * @param object
870
- * @param callback
871
- * @returns the mutated input object
872
- */
873
- function forEach(object, callback, thisObj) {
874
- if (object) {
875
- for (var name_1 in object) {
876
- if (Object.hasOwnProperty.call(object, name_1)) {
877
- callback.call(thisObj, object[name_1], name_1);
878
- }
879
- }
880
- }
881
- return object;
882
- }
883
- function ensureFixedNumber(a) {
884
- if (Number.isFinite(a)) {
885
- return [ValueType.CONSTANT, a];
886
- }
887
- if (a) {
888
- if (a[0] === 'lines') {
889
- return [ValueType.LINE, a[1]];
890
- }
891
- if (a[0] === 'curve') {
892
- return [ValueType.CURVE, a[1]];
893
- }
894
- if (a[0] === 'static') {
895
- return [ValueType.CONSTANT, a[1]];
896
- }
897
- }
898
- }
899
- function ensureFixedNumberWithRandom(a, p) {
900
- if (Array.isArray(a) && a[0] === 'random') {
901
- return [ValueType.CONSTANT, a[1][p]];
902
- }
903
- return ensureFixedNumber(a);
904
- }
905
- function ensureRGBAValue(a) {
906
- if (a && a[0] === 'color') {
907
- return colorToArr(a[1], true);
908
- }
909
- return [1, 1, 1, 1];
910
- }
911
- function ensureColorExpression(a, normalized) {
912
- if (a) {
913
- if (a[0] === 'colors') {
914
- return [ValueType.COLORS, a[1].map(function (color) { return colorToArr(color, normalized); })];
915
- }
916
- else if (a[0] === 'gradient') {
917
- return ensureGradient(a[1], normalized);
918
- }
919
- else if (a[0] === 'color') {
920
- return [ValueType.RGBA_COLOR, colorToArr(a[1], normalized)];
921
- }
922
- }
923
- }
924
- function ensureNumberExpression(a) {
925
- if (a && a[0] === 'random') {
926
- return [ValueType.RANDOM, a[1]];
927
- }
928
- return ensureFixedNumber(a);
929
- }
930
- function ensureValueGetter(a) {
931
- if (Array.isArray(a) && typeof a[0] === 'string') {
932
- return ensureNumberExpression(a) || ensureFixedVec3(a) || ensureColorExpression(a) || a;
933
- }
934
- return a;
935
- }
936
- function ensureGradient(a, normalized) {
937
- if (a) {
938
- var stops_1 = [];
939
- Object.getOwnPropertyNames(a).forEach(function (p) {
940
- var stop = parsePercent(p);
941
- var color = colorToArr(a[p], normalized);
942
- stops_1.push([stop, color[0], color[1], color[2], color[3]]);
943
- });
944
- stops_1 = stops_1.sort(function (a, b) { return a[0] - b[0]; });
945
- return [ValueType.GRADIENT_COLOR, stops_1];
946
- }
947
- }
948
- function colorToArr(hex, normalized) {
949
- var ret;
950
- if (typeof hex === 'string') {
951
- hex = hex.replace(/[\s\t\r\n]/g, '');
952
- var m = /rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(hex);
953
- if (m) {
954
- var a = +m[4];
955
- ret = [+m[1], +m[2], +m[3], isNaN(a) ? 255 : Math.round(a * 255)];
956
- }
957
- else if (/^#[a-f\d]{3}$/i.test(hex)) {
958
- ret = [parseInt(hex[1] + hex[1], 16), parseInt(hex[2] + hex[2], 16), parseInt(hex[3] + hex[3], 16), 255];
959
- // eslint-disable-next-line no-cond-assign
960
- }
961
- else if (m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)) {
962
- ret = [parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16), 255] || [0, 0, 0, 255];
963
- }
964
- }
965
- else if (hex instanceof Array) {
966
- ret = [hex[0], hex[1], hex[2], isNaN(hex[3]) ? 255 : Math.round(hex[3] * 255)];
967
- }
968
- if (normalized) {
969
- // @ts-expect-error
970
- ret = normalizeColor(ret);
971
- }
972
- // @ts-expect-error
973
- return ret;
974
- }
975
- function normalizeColor(a) {
976
- if (Array.isArray(a)) {
977
- return a.map(function (i) { return Number.isFinite(i / 255) ? Number((i / 255).toFixed(6)) : 0; });
978
- }
979
- }
980
- function parsePercent(c) {
981
- var match = /^(-)?([\d+.]+)%$/.exec(c);
982
- if (match) {
983
- return +match[2] / 100 * (match[1] ? -1 : 1);
984
- }
985
- return +c;
986
- }
987
- function getGradientColor(color, normalized) {
988
- if (Array.isArray(color)) {
989
- // @ts-expect-error
990
- return (color[0] === 'gradient' || color[0] === 'color') && ensureGradient(color[1], normalized);
991
- }
992
- else {
993
- return ensureGradient(color, normalized);
994
- }
995
- }
996
- function ensureFixedVec3(a) {
997
- if (a) {
998
- if (a.length === 3) {
999
- return [ValueType.CONSTANT_VEC3, a];
1000
- }
1001
- if (a[0] === 'path') {
1002
- return [ValueType.LINEAR_PATH, a[1]];
1003
- }
1004
- if (a[0] === 'bezier') {
1005
- return [ValueType.BEZIER_PATH, a[1]];
1006
- }
1007
- }
1008
- }
1009
- function objectValueToNumber(o) {
1010
- var e_1, _a;
1011
- try {
1012
- for (var _b = __values(Object.keys(o)), _c = _b.next(); !_c.done; _c = _b.next()) {
1013
- var key = _c.value;
1014
- o[key] = Number(o[key]);
1015
- }
1016
- }
1017
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1018
- finally {
1019
- try {
1020
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1021
- }
1022
- finally { if (e_1) throw e_1.error; }
1023
- }
1024
- return o;
1025
- }
1026
- function deleteEmptyValue(o) {
1027
- var e_2, _a;
1028
- try {
1029
- for (var _b = __values(Object.keys(o)), _c = _b.next(); !_c.done; _c = _b.next()) {
1030
- var key = _c.value;
1031
- if (o[key] === undefined) {
1032
- delete o[key];
1033
- }
1034
- }
1035
- }
1036
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1037
- finally {
1038
- try {
1039
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1040
- }
1041
- finally { if (e_2) throw e_2.error; }
1042
- }
1043
- return o;
1044
- }
1045
- var cos = Math.cos;
1046
- var sin = Math.sin;
1047
- var d2r = Math.PI / 180;
1048
- var r2d = 180 / Math.PI;
1049
- function quatFromXYZRotation(out, x, y, z) {
1050
- var c1 = cos((x * d2r) / 2);
1051
- var c2 = cos((y * d2r) / 2);
1052
- var c3 = cos((z * d2r) / 2);
1053
- var s1 = sin((x * d2r) / 2);
1054
- var s2 = sin((y * d2r) / 2);
1055
- var s3 = sin((z * d2r) / 2);
1056
- out[0] = s1 * c2 * c3 + c1 * s2 * s3;
1057
- out[1] = c1 * s2 * c3 - s1 * c2 * s3;
1058
- out[2] = c1 * c2 * s3 + s1 * s2 * c3;
1059
- out[3] = c1 * c2 * c3 - s1 * s2 * s3;
1060
- return out;
1061
- }
1062
- function clamp(v, min, max) {
1063
- return v > max ? max : (v < min ? min : v);
1064
- }
1065
- function rotationZYXFromQuat(out, quat) {
1066
- var x = quat[0];
1067
- var y = quat[1];
1068
- var z = quat[2];
1069
- var w = quat[3];
1070
- var x2 = x + x;
1071
- var y2 = y + y;
1072
- var z2 = z + z;
1073
- var xx = x * x2;
1074
- var yx = y * x2;
1075
- var yy = y * y2;
1076
- var zx = z * x2;
1077
- var zy = z * y2;
1078
- var zz = z * z2;
1079
- var wx = w * x2;
1080
- var wy = w * y2;
1081
- var wz = w * z2;
1082
- var m11 = 1 - yy - zz, m12 = yx - wz;
1083
- var m21 = yx + wz, m22 = 1 - xx - zz;
1084
- var m31 = zx - wy, m32 = zy + wx, m33 = 1 - xx - yy;
1085
- out[1] = Math.asin(clamp(-m31, -1, 1)) * r2d;
1086
- if (Math.abs(m31) < 0.9999999) {
1087
- out[0] = Math.atan2(m32, m33) * r2d;
1088
- out[2] = Math.atan2(m21, m11) * r2d;
1089
- }
1090
- else {
1091
- out[0] = 0;
1092
- out[2] = Math.atan2(-m12, m22) * r2d;
1093
- }
1094
- return out;
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);
1124
-
1125
- function getStandardParticleContent(particle) {
1126
- var _a;
1127
- var options = particle.options;
1128
- var transform = particle.transform;
1129
- var shape = {
1130
- type: ShapeType.NONE,
1131
- };
1132
- if (particle.shape) {
1133
- var shapeType = (_a = particle.shape.shape) === null || _a === void 0 ? void 0 : _a.replace(/([A-Z])/g, '_$1').toUpperCase().replace(/^_/, '');
1134
- shape = __assign(__assign({}, particle.shape), { type: ShapeType[shapeType] });
1135
- if (particle.shape.upDirection) {
1136
- var _b = __read(particle.shape.upDirection, 3), x = _b[0], y = _b[1], z = _b[2];
1137
- if (x === 0 && y === 0 && z === 0) {
1138
- delete shape.upDirection;
1139
- }
1140
- }
1141
- }
1142
- if (options.startTurbulence) {
1143
- shape.turbulenceX = ensureNumberExpression(options.turbulenceX);
1144
- shape.turbulenceY = ensureNumberExpression(options.turbulenceY);
1145
- shape.turbulenceZ = ensureNumberExpression(options.turbulenceZ);
1146
- }
1147
- var emission = particle.emission;
1148
- if (emission.bursts && emission.bursts.length > 0) {
1149
- emission.bursts = emission.bursts.map(function (b) { return objectValueToNumber(b); });
1150
- }
1151
- if (emission.burstOffsets && emission.burstOffsets.length > 0) {
1152
- emission.burstOffsets = emission.burstOffsets.map(function (b) { return objectValueToNumber(b); });
1153
- }
1154
- if (emission.rateOverTime) {
1155
- emission.rateOverTime = ensureNumberExpression(emission.rateOverTime);
1156
- }
1157
- var ret = {
1158
- renderer: particle.renderer,
1159
- shape: shape,
1160
- splits: particle.splits,
1161
- emission: emission,
1162
- options: {
1163
- startLifetime: ensureNumberExpression(options.startLifetime),
1164
- start3DSize: !!options.start3DSize,
1165
- startSize: ensureNumberExpression(options.startSize),
1166
- startSizeX: ensureNumberExpression(options.startSizeX),
1167
- startSizeY: ensureNumberExpression(options.startSizeY),
1168
- sizeAspect: ensureNumberExpression(options.sizeAspect),
1169
- maxCount: options.maxCount,
1170
- startDelay: ensureNumberExpression(options.startDelay),
1171
- startColor: ensureColorExpression(options.startColor, true),
1172
- startRotationZ: ensureNumberExpression(options.startRotation || options.startRotationZ),
1173
- particleFollowParent: options.particleFollowParent,
1174
- },
1175
- };
1176
- if (options.start3DRotation) {
1177
- ret.options.startRotationX = ensureNumberExpression(options.startRotationX);
1178
- ret.options.startRotationY = ensureNumberExpression(options.startRotationY);
1179
- }
1180
- if (particle.filter) {
1181
- var filter_1 = {};
1182
- forEach(particle.filter, function (val, key) {
1183
- // @ts-expect-error
1184
- filter_1[key] = ensureValueGetter(val);
1185
- });
1186
- ret.filter = filter_1;
1187
- }
1188
- if (transform && transform.path) {
1189
- ret.emitterTransform = {
1190
- path: ensureFixedVec3(transform.path),
1191
- };
1192
- }
1193
- var sizeOverLifetime = particle.sizeOverLifetime;
1194
- if (sizeOverLifetime) {
1195
- if (sizeOverLifetime.separateAxes) {
1196
- ret.sizeOverLifetime = {
1197
- separateAxes: true,
1198
- x: ensureNumberExpression(sizeOverLifetime.x),
1199
- y: ensureNumberExpression(sizeOverLifetime.y),
1200
- };
1201
- }
1202
- else {
1203
- ret.sizeOverLifetime = {
1204
- size: ensureNumberExpression(sizeOverLifetime.size),
1205
- };
1206
- }
1207
- }
1208
- var velocityOverLifetime = particle.velocityOverLifetime || {};
1209
- var sol = velocityOverLifetime.speedOverLifetime;
1210
- if (sol) {
1211
- sol = ensureFixedNumber(sol);
1212
- }
1213
- else {
1214
- sol = undefined;
1215
- }
1216
- ret.positionOverLifetime = {
1217
- gravity: options.gravity,
1218
- gravityOverLifetime: ensureFixedNumber(options.gravityModifier),
1219
- startSpeed: ensureNumberExpression(options.startSpeed),
1220
- speedOverLifetime: sol,
1221
- asMovement: velocityOverLifetime.asMovement,
1222
- linearX: ensureNumberExpression(velocityOverLifetime.linearX),
1223
- linearY: ensureNumberExpression(velocityOverLifetime.linearY),
1224
- linearZ: ensureNumberExpression(velocityOverLifetime.linearZ),
1225
- asRotation: velocityOverLifetime.asRotation,
1226
- orbCenter: velocityOverLifetime.orbCenter,
1227
- orbitalX: ensureNumberExpression(velocityOverLifetime.orbitalX),
1228
- orbitalY: ensureNumberExpression(velocityOverLifetime.orbitalY),
1229
- orbitalZ: ensureNumberExpression(velocityOverLifetime.orbitalZ),
1230
- forceTarget: velocityOverLifetime.forceTarget,
1231
- target: velocityOverLifetime.target,
1232
- forceCurve: ensureFixedNumber(velocityOverLifetime.forceCurve),
1233
- };
1234
- deleteEmptyValue(ret.positionOverLifetime);
1235
- var rotationOverLifetime = particle.rotationOverLifetime;
1236
- if (rotationOverLifetime) {
1237
- ret.rotationOverLifetime = {
1238
- separateAxes: rotationOverLifetime.separateAxes,
1239
- asRotation: rotationOverLifetime.asRotation,
1240
- z: ensureNumberExpression(rotationOverLifetime.separateAxes ? rotationOverLifetime.z : rotationOverLifetime.angularVelocity),
1241
- };
1242
- if (rotationOverLifetime.separateAxes) {
1243
- ret.rotationOverLifetime.y = ensureFixedNumber(rotationOverLifetime.y);
1244
- ret.rotationOverLifetime.x = ensureFixedNumber(rotationOverLifetime.x);
1245
- }
1246
- }
1247
- var colorOverLifetime = particle.colorOverLifetime;
1248
- if (colorOverLifetime) {
1249
- var col = ret.colorOverLifetime = {
1250
- opacity: ensureFixedNumber(colorOverLifetime.opacity),
1251
- };
1252
- if (colorOverLifetime.color) {
1253
- col.color = getGradientColor(colorOverLifetime.color);
1254
- }
1255
- }
1256
- var textureSheetAnimation = particle.textureSheetAnimation;
1257
- if (textureSheetAnimation) {
1258
- ret.textureSheetAnimation = {
1259
- row: textureSheetAnimation.row,
1260
- col: textureSheetAnimation.col,
1261
- total: textureSheetAnimation.total,
1262
- animate: textureSheetAnimation.animate,
1263
- cycles: ensureFixedNumber(textureSheetAnimation.cycles),
1264
- animationDelay: ensureFixedNumberWithRandom(textureSheetAnimation.animationDelay, 0),
1265
- animationDuration: ensureFixedNumberWithRandom(textureSheetAnimation.animationDuration, 0),
1266
- };
1267
- }
1268
- var trials = particle.trails;
1269
- if (trials) {
1270
- ret.trails = {
1271
- lifetime: ensureNumberExpression(trials.lifetime),
1272
- dieWithParticles: trials.dieWithParticles,
1273
- maxPointPerTrail: trials.maxPointPerTrail,
1274
- minimumVertexDistance: trials.minimumVertexDistance,
1275
- widthOverTrail: ensureFixedNumber(trials.widthOverTrail),
1276
- colorOverTrail: trials.colorOverTrail && getGradientColor(trials.colorOverTrail, false),
1277
- blending: trials.blending,
1278
- colorOverLifetime: trials.colorOverLifetime && getGradientColor(trials.colorOverLifetime, false),
1279
- inheritParticleColor: trials.inheritParticleColor,
1280
- occlusion: trials.occlusion,
1281
- transparentOcclusion: trials.transparentOcclusion,
1282
- orderOffset: trials.orderOffset,
1283
- sizeAffectsLifetime: trials.sizeAffectsLifetime,
1284
- sizeAffectsWidth: trials.sizeAffectsWidth,
1285
- texture: trials.texture,
1286
- parentAffectsPosition: trials.parentAffectsPosition,
1287
- opacityOverLifetime: ensureNumberExpression(trials.opacityOverLifetime),
1288
- };
1289
- }
1290
- ret.trails && deleteEmptyValue(ret.trails);
1291
- var interaction = particle.interaction;
1292
- if (interaction) {
1293
- ret.interaction = {
1294
- behavior: interaction.behavior,
1295
- radius: interaction.radius,
1296
- multiple: interaction.multiple,
1297
- };
1298
- }
1299
- return ret;
1300
- }
1301
-
1302
- function getStandardNullContent(sprite, transform) {
1303
- var _a;
1304
- var opt = sprite.options;
1305
- var velocityOverLifetime = sprite.velocityOverLifetime || {};
1306
- var positionOverLifetime = {
1307
- path: ensureFixedVec3((_a = sprite.transform) === null || _a === void 0 ? void 0 : _a.path),
1308
- gravity: opt.gravity,
1309
- gravityOverLifetime: ensureFixedNumber(opt.gravityModifier),
1310
- direction: opt.direction,
1311
- startSpeed: opt.startSpeed,
1312
- asMovement: velocityOverLifetime.asMovement,
1313
- linearX: ensureFixedNumber(velocityOverLifetime.linearX),
1314
- linearY: ensureFixedNumber(velocityOverLifetime.linearY),
1315
- linearZ: ensureFixedNumber(velocityOverLifetime.linearZ),
1316
- asRotation: velocityOverLifetime.asRotation,
1317
- orbCenter: velocityOverLifetime.orbCenter,
1318
- orbitalX: ensureFixedNumber(velocityOverLifetime.orbitalX),
1319
- orbitalY: ensureFixedNumber(velocityOverLifetime.orbitalY),
1320
- orbitalZ: ensureFixedNumber(velocityOverLifetime.orbitalZ),
1321
- speedOverLifetime: ensureFixedNumber(velocityOverLifetime.speedOverLifetime),
1322
- };
1323
- deleteEmptyValue(positionOverLifetime);
1324
- var ret = {
1325
- options: {
1326
- startColor: ensureRGBAValue(opt.startColor),
1327
- },
1328
- positionOverLifetime: positionOverLifetime,
1329
- };
1330
- if (opt.startSize) {
1331
- transform.scale = [opt.startSize, opt.startSize / (opt.sizeAspect || 1), 1];
1332
- }
1333
- if (opt.startRotation) {
1334
- if (!transform.rotation) {
1335
- transform.rotation = [0, 0, opt.startRotation];
1336
- }
1337
- else {
1338
- transform.rotation[2] += opt.startRotation;
1339
- }
1340
- }
1341
- var rotationOverLifetime = sprite.rotationOverLifetime;
1342
- if (rotationOverLifetime) {
1343
- var rot = ret.rotationOverLifetime = {
1344
- separateAxes: rotationOverLifetime.separateAxes,
1345
- asRotation: rotationOverLifetime.asRotation,
1346
- };
1347
- if (rot.separateAxes) {
1348
- rot.x = ensureFixedNumber(rotationOverLifetime.x);
1349
- rot.y = ensureFixedNumber(rotationOverLifetime.y);
1350
- rot.z = ensureFixedNumber(rotationOverLifetime.z);
1351
- }
1352
- else {
1353
- rot.z = ensureFixedNumber(rotationOverLifetime.angularVelocity);
1354
- }
1355
- }
1356
- var colorOverLifetime = sprite.colorOverLifetime;
1357
- if (colorOverLifetime) {
1358
- var col = ret.colorOverLifetime = {
1359
- opacity: ensureFixedNumber(colorOverLifetime.opacity),
1360
- };
1361
- if (colorOverLifetime.color) {
1362
- col.color = getGradientColor(colorOverLifetime.color);
1363
- }
1364
- }
1365
- var sizeOverLifetime = sprite.sizeOverLifetime;
1366
- if (sizeOverLifetime) {
1367
- ret.sizeOverLifetime = {
1368
- separateAxes: sizeOverLifetime.separateAxes,
1369
- size: ensureFixedNumber(sizeOverLifetime.size),
1370
- x: ensureFixedNumber(sizeOverLifetime.x),
1371
- y: ensureFixedNumber(sizeOverLifetime.y),
1372
- z: ensureFixedNumber(sizeOverLifetime.z),
1373
- };
1374
- }
1375
- return ret;
1376
- }
1377
- function getStandardSpriteContent(sprite, transform) {
1378
- var ret = getStandardNullContent(sprite, transform);
1379
- var texAni = sprite.textureSheetAnimation;
1380
- if (texAni) {
1381
- ret.textureSheetAnimation = {
1382
- row: texAni.row,
1383
- col: texAni.col,
1384
- total: texAni.total || undefined,
1385
- animate: texAni.animate,
1386
- };
1387
- }
1388
- ret.renderer = sprite.renderer;
1389
- if (sprite.splits) {
1390
- ret.splits = sprite.splits;
1391
- }
1392
- if (sprite.interaction) {
1393
- ret.interaction = sprite.interaction;
1394
- }
1395
- return ret;
1396
- }
1397
-
1398
- function getStandardInteractContent(ui) {
1399
- var options = ui.options;
1400
- var option;
1401
- switch (options.type) {
1402
- case 'click': {
1403
- option = {
1404
- type: InteractType.CLICK,
1405
- showPreview: options.showPreview,
1406
- previewColor: options.previewColor && ensureRGBAValue(options.previewColor),
1407
- behavior: options.behavior || InteractBehavior.NOTIFY,
1408
- };
1409
- break;
1410
- }
1411
- case 'drag': {
1412
- option = {
1413
- type: InteractType.DRAG,
1414
- enableInEditor: !!options.enableInEditor,
1415
- dxRange: options.dxRange,
1416
- dyRange: options.dyRange,
1417
- target: options.target,
1418
- };
1419
- break;
1420
- }
1421
- case 'message': {
1422
- option = {
1423
- type: InteractType.MESSAGE,
1424
- };
1425
- break;
1426
- }
1427
- }
1428
- var ret = {
1429
- // @ts-expect-error
1430
- options: option,
1431
- };
1432
- return ret;
1433
- }
1434
-
1435
- function getStandardCameraContent(model) {
1436
- var _a, _b;
1437
- var opt = model.options;
1438
- var ret = {
1439
- options: {
1440
- fov: opt.fov,
1441
- far: opt.far,
1442
- near: opt.near,
1443
- clipMode: opt.clipMode,
1444
- },
1445
- };
1446
- var velocityOverLifetime = model.velocityOverLifetime;
1447
- if (velocityOverLifetime || ((_a = model.transform) === null || _a === void 0 ? void 0 : _a.path)) {
1448
- var positionOverLifetime = {
1449
- path: ensureFixedVec3((_b = model.transform) === null || _b === void 0 ? void 0 : _b.path),
1450
- linearX: ensureFixedNumber(velocityOverLifetime === null || velocityOverLifetime === void 0 ? void 0 : velocityOverLifetime.translateX),
1451
- linearY: ensureFixedNumber(velocityOverLifetime === null || velocityOverLifetime === void 0 ? void 0 : velocityOverLifetime.translateY),
1452
- linearZ: ensureFixedNumber(velocityOverLifetime === null || velocityOverLifetime === void 0 ? void 0 : velocityOverLifetime.translateZ),
1453
- };
1454
- deleteEmptyValue(positionOverLifetime);
1455
- ret.positionOverLifetime = positionOverLifetime;
1456
- }
1457
- var rol = model.rotationOverLifetime;
1458
- if (rol) {
1459
- var rotationOverLifetime = {
1460
- separateAxes: rol.separateAxes,
1461
- x: ensureFixedNumber(rol === null || rol === void 0 ? void 0 : rol.rotateX),
1462
- y: ensureFixedNumber(rol === null || rol === void 0 ? void 0 : rol.rotateY),
1463
- z: rol.separateAxes ? ensureFixedNumber(rol === null || rol === void 0 ? void 0 : rol.rotateZ) : ensureFixedNumber(rol.rotation),
1464
- };
1465
- deleteEmptyValue(rotationOverLifetime);
1466
- ret.rotationOverLifetime = rotationOverLifetime;
1467
- }
1468
- return ret;
1469
- }
1470
-
1471
- var convertParams = [
1472
- 'strength',
1473
- 'bloomAddon',
1474
- 'colorAddon',
1475
- 'period',
1476
- 'waveMovement',
1477
- 'colorThreshold',
1478
- 'xOpacity',
1479
- 'yOpacity',
1480
- 'feather',
1481
- ];
1482
- var pathParams = [
1483
- 'path', 'position',
1484
- ];
1485
- function getStandardFilterContent(filter) {
1486
- var ret = {};
1487
- forEach(filter, function (val, key) {
1488
- if (convertParams.includes(key)) {
1489
- ret[key] = ensureFixedNumber(val);
1490
- }
1491
- else if (pathParams.includes(key)) {
1492
- ret[key] = ensureFixedVec3(val);
1493
- }
1494
- else {
1495
- ret[key] = val;
1496
- }
1497
- });
1498
- return ret;
1499
- }
1500
-
1501
- /**
1502
- * 2.1 以下版本数据适配(mars-player@2.4.0 及以上版本支持 2.1 以下数据的适配)
1503
- */
1504
- function version21Migration(json) {
1505
- json.compositions.forEach(function (composition) {
1506
- composition.items.forEach(function (item) {
1507
- if (item.type === ItemType.null) {
1508
- if (item.endBehavior === ItemEndBehavior.destroy) {
1509
- item.endBehavior = ItemEndBehavior.freeze;
1510
- }
1511
- }
1512
- });
1513
- });
1514
- json.version = '2.1';
1515
- return json;
1516
- }
1517
- /**
1518
- * 2.2 以下版本数据适配(mars-player@2.5.0 及以上版本支持 2.2 以下数据的适配)
1519
- */
1520
- function version22Migration(json) {
1521
- var _a;
1522
- var singleVersion = (_a = json.version) === null || _a === void 0 ? void 0 : _a.split('.');
1523
- if (!singleVersion || Number(singleVersion[0]) > 2 || (Number(singleVersion[0]) === 2 && Number(singleVersion[1]) >= 2)) {
1524
- return json;
1525
- }
1526
- json.compositions.forEach(function (composition) {
1527
- composition.items.forEach(function (item) {
1528
- if (item.type === ItemType.mesh || item.type === ItemType.light) {
1529
- item.endBehavior = item.endBehavior === 1 ? ItemEndBehavior.destroy : item.endBehavior;
1530
- }
1531
- });
1532
- });
1533
- return json;
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
- }
1838
-
1839
- var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
1840
- var standardVersion = /^(\d+)\.(\d+)$/;
1841
- var reverseParticle = false;
1842
- function getStandardJSON(json) {
1843
- var _a, _b;
1844
- if (!json || typeof json !== 'object') {
1845
- throw Error('expect a json object');
1846
- }
1847
- // 修正老版本数据中,meshItem 以及 lightItem 结束行为错误问题
1848
- version22Migration(json);
1849
- if (v0.test(json.version)) {
1850
- reverseParticle = ((_a = (/^(\d+)/).exec(json.version)) === null || _a === void 0 ? void 0 : _a[0]) === '0';
1851
- return version30Migration(version21Migration(getStandardJSONFromV0(json)));
1852
- }
1853
- var mainVersion = (_b = standardVersion.exec(json.version)) === null || _b === void 0 ? void 0 : _b[1];
1854
- if (mainVersion) {
1855
- if (Number(mainVersion) < 3) {
1856
- return version30Migration(version21Migration(json));
1857
- }
1858
- return json;
1859
- }
1860
- throw Error('invalid json version ' + json.version);
1861
- }
1862
- var currentVersion = '1.0';
1863
- function getStandardJSONFromV0(json) {
1864
- var _a, _b;
1865
- currentVersion = '1.0';
1866
- var plugins = json.plugins || [];
1867
- if ((_a = json.bins) === null || _a === void 0 ? void 0 : _a.length) {
1868
- currentVersion = '1.3';
1869
- }
1870
- var requires = (json.requires || []).slice();
1871
- var images = json.images.map(function (img, index) { return getStandardImage(img, index, json.imageTags || []); });
1872
- var textures = json.textures || images.map(function (img, i) { return ({ source: i, flipY: true }); });
1873
- var ret = {
1874
- plugins: plugins,
1875
- shapes: json.shapes || [],
1876
- type: 'ge',
1877
- version: currentVersion,
1878
- playerVersion: (_b = json.playerVersion) !== null && _b !== void 0 ? _b : {
1879
- web: '',
1880
- native: '',
1881
- },
1882
- compositionId: json.compositionId + '',
1883
- compositions: json.compositions.map(function (comp) { return getStandardComposition(comp, { plugins: plugins, requires: requires }); }),
1884
- images: images,
1885
- imgUsage: json._imgs,
1886
- binUsage: json.binUsage,
1887
- spines: json.spines,
1888
- requires: json.requires,
1889
- textures: textures,
1890
- bins: (json.bins || []).slice(),
1891
- };
1892
- if (json._textures) {
1893
- ret._textures = json._textures;
1894
- }
1895
- return ret;
1896
- }
1897
- function getStandardImage(image, index, imageTags) {
1898
- var renderLevel = imageTags[index];
1899
- var oriY = image.oriY;
1900
- if (typeof image === 'string') {
1901
- return {
1902
- renderLevel: renderLevel,
1903
- url: image,
1904
- oriY: oriY,
1905
- };
1906
- }
1907
- else if (image.template) {
1908
- return {
1909
- url: image.url,
1910
- template: image.template,
1911
- webp: image.webp,
1912
- renderLevel: renderLevel,
1913
- oriY: oriY,
1914
- };
1915
- }
1916
- else if (image.compressed) {
1917
- return {
1918
- url: image.url,
1919
- oriY: oriY,
1920
- compressed: {
1921
- astc: image.compressed.android,
1922
- pvrtc: image.compressed.iOS,
1923
- },
1924
- webp: image.webp,
1925
- renderLevel: renderLevel,
1926
- };
1927
- }
1928
- else if (image.url) {
1929
- return {
1930
- url: image.url,
1931
- type: image.type,
1932
- webp: image.webp,
1933
- renderLevel: renderLevel,
1934
- oriY: oriY,
1935
- loop: image.loop,
1936
- };
1937
- }
1938
- else if (image && image.sourceType) {
1939
- return image;
1940
- }
1941
- throw Error('invalid image type');
1942
- }
1943
- function getStandardComposition(composition, opt) {
1944
- var _a;
1945
- if (opt === void 0) { opt = {}; }
1946
- var ret = {
1947
- id: composition.id + '',
1948
- camera: Object.assign({ clipMode: CAMERA_CLIP_MODE_NORMAL }, composition.camera),
1949
- duration: composition.duration,
1950
- endBehavior: composition.endBehavior,
1951
- items: composition.items.map(function (item) { return getStandardItem(item, opt); }),
1952
- name: composition.name,
1953
- };
1954
- var startTime = composition.startTime || composition.st;
1955
- if (startTime) {
1956
- ret.startTime = startTime;
1957
- }
1958
- var previewSize = (_a = composition.meta) === null || _a === void 0 ? void 0 : _a.previewSize;
1959
- if (previewSize && previewSize[0] === previewSize[1] && previewSize[0] === 0) {
1960
- previewSize = undefined;
1961
- }
1962
- if (previewSize) {
1963
- ret.previewSize = previewSize;
1964
- }
1965
- return ret;
1966
- }
1967
- var tempQuat = [0, 0, 0, 1];
1968
- var stdAnchor = 0.5;
1969
- function getStandardItem(item, opt) {
1970
- var _a, _b, _c;
1971
- if (opt === void 0) { opt = {}; }
1972
- var type = ItemType.base;
1973
- var transform;
1974
- var originContent;
1975
- var content;
1976
- var endBehavior = item.endBehavior;
1977
- var renderLevel;
1978
- var pluginName;
1979
- var duration = NaN;
1980
- var pn;
1981
- if (item.content) {
1982
- type = item.type || ItemType.plugin;
1983
- pn = item.pn;
1984
- pluginName = item.pluginName;
1985
- content = item.content;
1986
- originContent = item.content;
1987
- if (isNaN(pn) && !pluginName) {
1988
- pluginName = content.options.type;
1989
- }
1990
- if (item.duration) {
1991
- duration = item.duration;
1992
- }
1993
- transform = item.transform || getTransform(originContent.transform);
1994
- if (type === ItemType.filter) {
1995
- if (currentVersion < '1.1') {
1996
- currentVersion = '1.1';
1997
- }
1998
- content = getStandardSpriteContent(originContent, transform);
1999
- // @ts-expect-error
2000
- content.filter = getStandardFilterContent(originContent.filter);
2001
- }
2002
- }
2003
- else if (item.particle) {
2004
- type = ItemType.particle;
2005
- originContent = item.particle;
2006
- transform = getTransform(originContent.transform, reverseParticle, true);
2007
- content = getStandardParticleContent(originContent);
2008
- }
2009
- else if (item.sprite) {
2010
- type = ItemType.sprite;
2011
- originContent = item.sprite;
2012
- transform = getTransform(originContent.transform, false, true);
2013
- content = getStandardSpriteContent(originContent, transform);
2014
- }
2015
- else if (item.cal) {
2016
- type = ItemType.null;
2017
- originContent = item.cal;
2018
- transform = getTransform(originContent.transform, false, true);
2019
- content = getStandardNullContent(originContent, transform);
2020
- }
2021
- else if (item.ui) {
2022
- type = ItemType.interact;
2023
- originContent = item.ui;
2024
- transform = getTransform(originContent.transform);
2025
- content = getStandardInteractContent(originContent);
2026
- transform.scale = [originContent.options.width || 1, originContent.options.height || 1, 1];
2027
- }
2028
- else if (item.model) {
2029
- originContent = item.model;
2030
- if (item.model.options.type === 1) {
2031
- type = ItemType.camera;
2032
- transform = getTransform(originContent.transform);
2033
- content = getStandardCameraContent(originContent);
2034
- }
2035
- }
2036
- if ((_a = content.renderer) === null || _a === void 0 ? void 0 : _a.anchor) {
2037
- var anchor = new Float32Array(content.renderer.anchor);
2038
- if (anchor[0] == stdAnchor && anchor[1] == stdAnchor) {
2039
- delete content.renderer.anchor;
2040
- }
2041
- else if (opt.requires) {
2042
- arrAdd(opt.requires, 'anchor');
2043
- }
2044
- }
2045
- if (originContent) {
2046
- var looping = (_b = originContent.options) === null || _b === void 0 ? void 0 : _b.looping;
2047
- if (looping) {
2048
- if (Array.isArray(looping)) {
2049
- endBehavior = looping[1] ? ItemEndBehavior.loop : ItemEndBehavior.destroy;
2050
- }
2051
- else {
2052
- endBehavior = ItemEndBehavior.loop;
2053
- }
2054
- }
2055
- else {
2056
- endBehavior = endBehavior || ((_c = originContent === null || originContent === void 0 ? void 0 : originContent.options) === null || _c === void 0 ? void 0 : _c.endBehavior) || ItemEndBehavior.destroy;
2057
- }
2058
- if (originContent.options.renderLevel) {
2059
- renderLevel = originContent.options.renderLevel;
2060
- }
2061
- if (isNaN(duration)) {
2062
- duration = originContent.options.duration;
2063
- }
2064
- }
2065
- var ret = {
2066
- type: type,
2067
- name: item.name,
2068
- delay: item.delay,
2069
- duration: duration,
2070
- id: item.id + '',
2071
- // @ts-expect-error
2072
- transform: transform,
2073
- endBehavior: endBehavior,
2074
- // @ts-expect-error
2075
- renderLevel: renderLevel,
2076
- content: content,
2077
- };
2078
- // @ts-expect-error
2079
- if (pluginName) {
2080
- if (opt.plugins) {
2081
- arrAdd(opt.plugins, pluginName);
2082
- ret.pn = opt.plugins.indexOf(pluginName);
2083
- }
2084
- else {
2085
- ret.pluginName = pluginName;
2086
- }
2087
- // @ts-expect-error
2088
- }
2089
- else if (Number.isInteger(pn)) {
2090
- // @ts-expect-error
2091
- ret.pn = pn;
2092
- }
2093
- if (item.parentId) {
2094
- ret.parentId = item.parentId + '';
2095
- }
2096
- return ret;
2097
- function getTransform(originTransform, inverseRotation, changeOrder) {
2098
- if (originTransform) {
2099
- var transform_1 = {};
2100
- var rotation = originTransform.rotation;
2101
- if (rotation) {
2102
- if (inverseRotation) {
2103
- transform_1.rotation = [-rotation[0], -rotation[1], -rotation[2]];
2104
- }
2105
- else {
2106
- transform_1.rotation = [rotation[0], rotation[1], rotation[2]];
2107
- }
2108
- if (changeOrder) {
2109
- var q = quatFromXYZRotation(tempQuat, transform_1.rotation[0], transform_1.rotation[1], transform_1.rotation[2]);
2110
- transform_1.rotation = rotationZYXFromQuat([], q);
2111
- }
2112
- }
2113
- var position = originTransform.position;
2114
- if (position) {
2115
- transform_1.position = originTransform.position;
2116
- }
2117
- if (Array.isArray(originTransform.scale)) {
2118
- transform_1.scale = [originTransform.scale[0] || 1, originTransform.scale[1] || 1, originTransform.scale[2] || 1];
2119
- }
2120
- return transform_1;
2121
- }
2122
- return {};
2123
- }
2124
- }
2125
-
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 };
2127
- //# sourceMappingURL=fallback.mjs.map