@vvfx/sdk 0.0.0-alpha.7 → 0.0.0-alpha.70

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { spec, Player } from '@galacean/effects';
2
- export { spec } from '@galacean/effects';
3
- import * as _galacean_effects_weapp from '@galacean/effects/weapp';
1
+ import * as _galacean_effects from '@galacean/effects';
2
+ import { spec, math, Player } from '@galacean/effects';
3
+ export { generateGUID, spec } from '@galacean/effects';
4
4
 
5
5
  type ViewItemTypedProperty = {
6
6
  [K in keyof PageFormTypeAndPropertyReference]: {
@@ -44,23 +44,1316 @@ type SetItemPropertyValueParam = {
44
44
  propertyValue: PageFormTypeAndPropertyReference[T][N];
45
45
  };
46
46
  }[keyof PageFormTypeAndPropertyReference[T]];
47
- }[keyof PageFormTypeAndPropertyReference];
47
+ }[keyof PageFormTypeAndPropertyReference] | {
48
+ itemId: string;
49
+ type: spec.ItemType;
50
+ propertyName: 'position' | 'size';
51
+ propertyValue: spec.vec2 | spec.vec3;
52
+ };
53
+
54
+ /**
55
+ * @class 二维线段
56
+ */
57
+ declare class Line2 {
58
+ start: Vector2;
59
+ end: Vector2;
60
+ constructor(start?: Vector2, end?: Vector2);
61
+ /**
62
+ * 设置二维线段
63
+ * @param {Vector2} start 线段起点
64
+ * @param {Vector2} end 线段终点
65
+ * @returns {Line2} 二维线段
66
+ */
67
+ set(start: Vector2, end: Vector2): this;
68
+ /**
69
+ * 复制二维线段
70
+ * @param {Line2} line 复制对象
71
+ * @returns {Line2} 复制结果
72
+ */
73
+ copyFrom(line: Line2): this;
74
+ /**
75
+ * 二维线段求方向
76
+ * @returns {Vector2} 二维线段方向
77
+ */
78
+ direction(): Vector2;
79
+ /**
80
+ * 二维线段求中点
81
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
82
+ * @returns {Vector2} 二维线段中点
83
+ */
84
+ getCenter(target?: Vector2): Vector2;
85
+ /**
86
+ * 二维线段向量值
87
+ * @param {Vector2} [target=new Vector2()] 目标保存对象
88
+ * @returns {Vector2} 二维线段向量值
89
+ */
90
+ delta(target?: Vector2): Vector2;
91
+ /**
92
+ * 二维线段欧式距离平方(应用于计算)
93
+ * @returns {number} 计算结果
94
+ */
95
+ distanceSq(): number;
96
+ /**
97
+ * 二维线段欧式距离
98
+ * @returns {number} 计算结果
99
+ */
100
+ distance(): number;
101
+ /**
102
+ * 求二维线段比例点
103
+ * @param {number} t 比例值
104
+ * @param {Vector2} target 目标保存对象
105
+ * @returns {Vector2} 比例点结果
106
+ */
107
+ at(t: number, target?: Vector2): Vector2;
108
+ /**
109
+ * 求点与线段的最短距离
110
+ * @param {Vector2} point 二维空间点
111
+ * @param {boolean} clampToLine 是否限制于线段内
112
+ * @returns {number} 距离结果
113
+ */
114
+ closestPointToPointParameter(point: Vector2, clampToLine: boolean): number;
115
+ /**
116
+ * 求点与线段的最近交点
117
+ * @param {Vector2} point 二维空间点
118
+ * @param {boolean} clampToLine 是否限制于线段内
119
+ * @param {Vector2} target 目标保存对象
120
+ * @returns {Vector2} 最近交点
121
+ */
122
+ closestPointToPoint(point: Vector2, clampToLine: boolean, target?: Vector2): Vector2;
123
+ /**
124
+ * 二维线段判等
125
+ * @param {Line2} line 二维线段
126
+ * @returns {boolean} 判等结果
127
+ */
128
+ equals(line: Line2): boolean;
129
+ /**
130
+ * 克隆二维线段
131
+ * @returns {Line2} 克隆结果
132
+ */
133
+ clone(): Line2;
134
+ /**
135
+ * 二维线段求长度
136
+ * @returns {number} 长度
137
+ */
138
+ length(): number;
139
+ /**
140
+ * 二维线段判断相交
141
+ * @param {Line2} other 二维线段
142
+ * @returns {boolean} 相交判断结果
143
+ */
144
+ crossWithLine(other: Line2): boolean;
145
+ }
146
+
147
+ declare class Vector2 extends math.Vector2 {
148
+ subtract(other: Vector2): this;
149
+ toViewCoordinate(width: number, height: number): this;
150
+ clone(): Vector2;
151
+ distanceTo(other: Vector2): number;
152
+ scaleByCenter(scalar: Vector2, anchor?: Vector2): this;
153
+ round(precision?: number): this;
154
+ /**
155
+ * 点到直线的最短距离
156
+ * @returns {{d: number, t: number}} d表示距离,t表示最近点在直线的比例
157
+ */
158
+ distanceToLine(line: Line2): {
159
+ d: number;
160
+ t: number;
161
+ };
162
+ /**
163
+ * 二维向量与x轴夹角
164
+ * @returns {number} 弧度值
165
+ */
166
+ angle(): number;
167
+ /**
168
+ * 二维点绕点旋转
169
+ * @param {Vec2} center 旋转中心
170
+ * @param {number} angle 旋转角度
171
+ * @returns {Vec2} 旋转结果
172
+ */
173
+ rotateAround(center: Vector2, angle: number): this;
174
+ }
175
+
176
+ /**
177
+ * @class 二维包围盒
178
+ */
179
+ declare class Box2 {
180
+ /**
181
+ * @member {Vector2[]} corners 二维包围盒角点
182
+ */
183
+ corners: Vector2[];
184
+ min: Vector2;
185
+ max: Vector2;
186
+ /**
187
+ * 构造函数,传入值为空时表示空包围盒
188
+ * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
189
+ * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
190
+ */
191
+ constructor(min?: Vector2, max?: Vector2);
192
+ /**
193
+ * 通过最大最小点设置二维包围盒
194
+ * @param {Vector2} min 最小点
195
+ * @param {Vector2} max 最大点
196
+ * @returns {Box2} 二维包围盒
197
+ */
198
+ set(min: Vector2, max: Vector2): this;
199
+ /**
200
+ * 通过角点设置二维包围盒
201
+ * @param {Vector2[]} vecArray 二维空间点数组
202
+ * @returns {Box2} 二维包围盒
203
+ */
204
+ setFromVec2Array(vecArray: Vector2[]): this;
205
+ /**
206
+ * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
207
+ * @param vecArray 屏幕坐标点
208
+ */
209
+ setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
210
+ /**
211
+ * 通过中心与大小设置二维包围盒
212
+ * @param {Vector2} center 二维中心点
213
+ * @param {Vector2} size 二维大小
214
+ * @returns {Box2} 二维包围盒
215
+ */
216
+ setFromCenterAndSize(center: Vector2, size: Vector2): this;
217
+ /**
218
+ * 克隆二维包围盒
219
+ * @returns {Box2} 克隆结果
220
+ */
221
+ clone(): Box2;
222
+ /**
223
+ * 复制二维包围盒
224
+ * @param {Box2} box 二维包围盒
225
+ * @returns {Box2} 复制结果
226
+ */
227
+ copyFrom(box: Box2): this;
228
+ /**
229
+ * 二维包围盒置空
230
+ * @returns {Box2} 置空结果
231
+ */
232
+ makeEmpty(): this;
233
+ /**
234
+ * 二维包围盒判空
235
+ * @returns {boolean} 判空结果
236
+ */
237
+ isEmpty(): boolean;
238
+ /**
239
+ * 获取二维包围盒角点
240
+ * @returns {Vector2[]} 二维包围盒角点
241
+ */
242
+ getCorners(): Vector2[];
243
+ /**
244
+ * 获取二维包围盒中心点
245
+ * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
246
+ * @returns {Vector2} 二维包围盒中心点
247
+ */
248
+ getCenter(target?: Vector2): Vector2;
249
+ /**
250
+ * 获取二维包围盒大小
251
+ * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
252
+ * @returns {Vector2} 二维包围盒大小
253
+ */
254
+ getSize(target?: Vector2): Vector2;
255
+ /**
256
+ * 通过二维空间点扩展二维包围盒
257
+ * @param {Vector2} point 二维空间点
258
+ * @returns {Box2} 扩展包围盒
259
+ */
260
+ expandByPoint(point: Vector2): this;
261
+ /**
262
+ * 通过向量扩展二维包围盒
263
+ * @param {Vector2} vector 二维向量
264
+ * @returns {Box2} 扩展结果
265
+ */
266
+ expandByVector(vector: Vector2): this;
267
+ /**
268
+ * 通过大小扩展二维包围盒
269
+ * @param {number} scalar 扩展大小
270
+ * @returns {Box2} 扩展结果
271
+ */
272
+ expandByScalar(scalar: number): this;
273
+ /**
274
+ * 判断二维包围盒是否包含二维空间点
275
+ * @param {Vector2} point 二维空间点
276
+ * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
277
+ * @returns {boolean} 点包含判断结果
278
+ */
279
+ containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
280
+ /**
281
+ * 判断二维包围盒包含关系(if this contains other)
282
+ * @param {Box2} box 其它包围盒
283
+ * @returns {boolean} 二维包围盒包含判断结果
284
+ */
285
+ containsBox(box: Box2): boolean;
286
+ /**
287
+ * 获取点以包围盒左上角顶点为原点的相对位置
288
+ * @param {Vector2} point 指定二维空间点
289
+ * @param {Vector2} [target=new Vector2()] 目标空间点
290
+ * @returns {Vector2} 计算结果空间点
291
+ */
292
+ getParameter(point: Vector2, target?: Vector2): Vector2;
293
+ /**
294
+ * 求点与二维包围盒的最近点
295
+ * @param {Vector2} point 二维空间点
296
+ * @param {Vector2} [target=new Vector2()] 结果点
297
+ * @returns {Vector2} 二维空间点
298
+ */
299
+ clampPoint(point: Vector2, target?: Vector2): Vector2;
300
+ /**
301
+ * 求点到二维包围盒的距离
302
+ * @param {Vector2} point 二维空间点
303
+ * @returns {number} 距离
304
+ */
305
+ distanceToPoint(point: Vector2): number;
306
+ /**
307
+ * 二维包围盒求交集
308
+ * @param {Box2} box 二维包围盒
309
+ * @returns {Box2} 求交结果
310
+ */
311
+ intersect(box: Box2): this;
312
+ /**
313
+ * 二维包围盒求并集
314
+ * @param {Box2} box 二维包围盒
315
+ * @returns {Box2} 求并结果
316
+ */
317
+ union(box: Box2): this;
318
+ /**
319
+ * 二维包围盒位移
320
+ * @param {Vector2} offset 位移向量
321
+ * @returns {Box2} 位移结果
322
+ */
323
+ translate(offset: Vector2): this;
324
+ scale(scalar: number | Vector2, anchor?: Vector2): this;
325
+ /**
326
+ * 二维包围盒判等
327
+ * @param {Box2} box 二维包围盒
328
+ * @returns {boolean} 判等结果
329
+ */
330
+ equals(box: Box2): boolean;
331
+ /**
332
+ * 判断二维包围盒相交关系(if this intersect other)
333
+ * @param {Box2} box 二维包围盒
334
+ * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
335
+ * @returns {boolean} 相交判断结果
336
+ */
337
+ intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
338
+ rotate(angle: number, center?: Vector2): this;
339
+ }
340
+
341
+ type CreateOperation = {
342
+ type: 'create';
343
+ newData: ItemCreateInfo[];
344
+ };
345
+ type DeleteOperation = {
346
+ type: 'delete';
347
+ oldData: ItemCreateInfo[];
348
+ };
349
+ type UpdateOperation = {
350
+ type: 'update';
351
+ newData: ItemCreateInfo[];
352
+ oldData: ItemCreateInfo[];
353
+ };
354
+ type Operation = CreateOperation | UpdateOperation | DeleteOperation;
355
+ declare class UndoRedo {
356
+ private index;
357
+ private operations;
358
+ get canUndo(): boolean;
359
+ get canRedo(): boolean;
360
+ oldData?: ItemCreateInfo[];
361
+ push(operation: Operation): void;
362
+ undo(): Operation | undefined;
363
+ redo(): Operation | undefined;
364
+ clear(): void;
365
+ }
366
+
367
+ declare const MEDIA_TYPE: {
368
+ readonly APNG: "APNG";
369
+ readonly MP4: "MP4";
370
+ readonly WebM: "WebM";
371
+ readonly Images: "Images";
372
+ readonly WebP: "WebP";
373
+ readonly GIF: "GIF";
374
+ readonly AlphaMaskVideo: "AlphaMaskVideo";
375
+ };
376
+ /**
377
+ * GIF 压缩参数
378
+ * 核心通过参数 flags + palettegen + paletteuse 实现
379
+ * highest: lanczos + max_colors=256 + dither=bayer
380
+ * high: bicubic + max_colors=200 + dither=bayer
381
+ * medium: bilinear + max_colors=64 + dither=bayer
382
+ * low: neighbor + max_colors=32 + dither=none
383
+ */
384
+ declare const GIF_QUALITY_TO_FFMPEG_ARGS: {
385
+ highest: string;
386
+ high: string;
387
+ medium: string;
388
+ low: string;
389
+ };
390
+
391
+ declare global {
392
+ interface Window {
393
+ /**
394
+ * @description 创建 WebP Core 实例
395
+ */
396
+ createWebPCore: (config: any) => Promise<Img2WebPCore>;
397
+ }
398
+ }
399
+ type FileBuffer = ArrayBuffer | Uint8Array;
400
+ type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
401
+ type FS = {
402
+ writeFile: (path: string, data: Uint8Array | string) => void;
403
+ readFile(path: string, opts: {
404
+ encoding: 'binary';
405
+ flags?: string | undefined;
406
+ }): Uint8Array;
407
+ readFile(path: string, opts: {
408
+ encoding: 'utf8';
409
+ flags?: string | undefined;
410
+ }): string;
411
+ readFile(path: string, opts?: {
412
+ flags?: string | undefined;
413
+ }): Uint8Array;
414
+ unlink: (path: string) => void;
415
+ quit: () => void;
416
+ };
417
+ type Pointer = number;
418
+ type Img2WebPCore = {
419
+ FS: FS;
420
+ run: (...args: string[]) => number;
421
+ cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
422
+ _malloc: (size: number) => Pointer;
423
+ writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
424
+ setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
425
+ };
426
+ type ExportMediaInitOptions = {
427
+ /**
428
+ * 导出类型
429
+ */
430
+ mediaType: MediaType;
431
+ /**
432
+ * 额外画布,导出透明视频时使用
433
+ */
434
+ extraCanvas?: HTMLCanvasElement | null;
435
+ /**
436
+ * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
437
+ * 供开发调试使用
438
+ */
439
+ loggerInTranscoding?: boolean;
440
+ /**
441
+ * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
442
+ */
443
+ multiThreading?: boolean;
444
+ /**
445
+ * 是否输出 buffer,默认 false
446
+ */
447
+ isOutputBuffer?: boolean;
448
+ };
449
+ type MP4Config = {
450
+ /**
451
+ * @description MP4 导出时是否需要导出最后一帧 PNG
452
+ */
453
+ isExportLastFramePNG?: boolean;
454
+ };
455
+ type GifConfig = {
456
+ /**
457
+ * @description GIF 导出时的帧率
458
+ */
459
+ fps?: number;
460
+ /**
461
+ * @description GIF 导出时的缩放比例
462
+ * 默认 '-1:-1', 表示不缩放
463
+ * 例如 '100:-1', 表示宽度 100,高度自动
464
+ * 例如 '-1:100', 表示宽度自动,高度 100
465
+ */
466
+ scale?: string;
467
+ /**
468
+ * @description GIF 导出时的质量
469
+ * 默认 'highest'
470
+ * 可选 'highest', 'high', 'medium', 'low'
471
+ */
472
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
473
+ };
474
+ type ApngConfig = {
475
+ /**
476
+ * @description APNG 导出时的帧率
477
+ */
478
+ fps?: number;
479
+ /**
480
+ * @description APNG 导出时的缩放比例
481
+ * 默认 '-1:-1', 表示不缩放
482
+ * 例如 '100:-1', 表示宽度 100,高度自动
483
+ * 例如 '-1:100', 表示宽度自动,高度 100
484
+ */
485
+ scale?: string;
486
+ /**
487
+ * @description APNG 导出时的质量
488
+ * 默认 'highest'
489
+ * 可选 'highest', 'high', 'medium', 'low'
490
+ */
491
+ quality?: keyof typeof GIF_QUALITY_TO_FFMPEG_ARGS;
492
+ };
493
+ type ExportMediaItemOptions = {
494
+ /**
495
+ * 尺寸
496
+ */
497
+ size: [number, number];
498
+ /**
499
+ * 动效资源
500
+ */
501
+ scene: spec.JSONScene;
502
+ /**
503
+ * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
504
+ */
505
+ time?: number;
506
+ /**
507
+ * 是否生成音轨,默认 false,仅在导出 MP4 时有效
508
+ */
509
+ audioEnable?: boolean;
510
+ /**
511
+ * 帧率, 默认 30
512
+ */
513
+ fps?: number;
514
+ /**
515
+ * 是否循环,默认 true
516
+ */
517
+ loop?: boolean;
518
+ /**
519
+ * 视频背景颜色,默认 #000000
520
+ */
521
+ backgroundColor?: string;
522
+ /**
523
+ * 导出 MP4 时,设置的导出配置
524
+ */
525
+ mp4Config?: MP4Config;
526
+ /**
527
+ * 导出 GIF 时,设置的导出配置
528
+ */
529
+ gifConfig?: GifConfig;
530
+ /**
531
+ * 导出 APNG 时,设置的导出配置
532
+ */
533
+ apngConfig?: ApngConfig;
534
+ };
535
+
536
+ type SDKMode = 'editor' | 'template';
537
+ /**
538
+ * @description SDK功能配置
539
+ */
540
+ type SDKConfig = {
541
+ /**
542
+ * @description SDK编辑模式 - 模板编辑 | 产物编辑
543
+ */
544
+ mode: SDKMode;
545
+ /**
546
+ * @description 页面功能配置
547
+ */
548
+ pageConfig: PageConfig$1;
549
+ /**
550
+ * @description 截图功能配置
551
+ */
552
+ screenShotConfig: ScreenShotConfig;
553
+ /**
554
+ * @description 导出视频功能配置
555
+ */
556
+ exportConfig: ExportConfig;
557
+ /**
558
+ * @description 尺寸自适应功能开关
559
+ */
560
+ sizeAdaptConfig: SizeAdaptConfig;
561
+ /**
562
+ * @description 辅助面板功能配置
563
+ */
564
+ gestureHandlerConfig: {
565
+ enabled: boolean;
566
+ adsorptionGizmoEnabled: boolean;
567
+ adsorptionGizmoConfig: AdsorptionGizmoConfig;
568
+ controlGizmoEnabled: boolean;
569
+ controlGizmoConfig: ControlGizmoConfig;
570
+ preferenceGizmoEnabled: boolean;
571
+ preferenceGizmoConfig: PreferenceGizmoConfig;
572
+ selectorGizmoEnabled: boolean;
573
+ selectorGizmoConfig: SelectorGizmoConfig;
574
+ transformGizmoEnabled: boolean;
575
+ transformGizmoConfig: TransformGizmoConfig;
576
+ pictureCutGizmoEnabled: boolean;
577
+ pictureCutGizmoConfig: PictureCutGizmoConfig;
578
+ pictureExpandGizmoEnabled: boolean;
579
+ pictureExpandGizmoConfig: PictureExpandGizmoConfig;
580
+ textGizmoEnbaled: boolean;
581
+ textGizmoConfig: TextGizmoConfig;
582
+ maskGizmoEnabled: boolean;
583
+ maskGizmoConfig: MaskGizmoConfig;
584
+ };
585
+ };
586
+ /**
587
+ * @description 页面功能配置
588
+ */
589
+ type PageConfig$1 = {
590
+ /**
591
+ * @description 同步修改功能开关
592
+ */
593
+ asncMode: boolean;
594
+ /**
595
+ * @description 静态预览【视图只提供播放预览功能】功能开关
596
+ */
597
+ staticPreview: boolean;
598
+ /**
599
+ * @description 静态预览视图名称
600
+ */
601
+ staticPreviewName: string;
602
+ /**
603
+ * @description 需过滤的元素名称
604
+ */
605
+ filterItemNames: string[];
606
+ /**
607
+ * @description 成组操作元素显隐
608
+ */
609
+ groupVisible: boolean;
610
+ /**
611
+ * @description 缩放最大值
612
+ */
613
+ maxZoom: number;
614
+ /**
615
+ * @description 缩放最小值
616
+ */
617
+ minZoom: number;
618
+ };
619
+ /**
620
+ * @description 视频导出功能配置
621
+ */
622
+ type ExportConfig = {
623
+ enabled: boolean;
624
+ } & ExportMediaInitOptions;
625
+ /**
626
+ * @description 截图功能配置
627
+ */
628
+ type ScreenShotConfig = {
629
+ enabled: boolean;
630
+ };
631
+ /**
632
+ * @description 尺寸自适应功能配置
633
+ */
634
+ type SizeAdaptConfig = {
635
+ enabled: boolean;
636
+ };
637
+ /**
638
+ * @description 对齐吸附功能参数
639
+ */
640
+ type AdsorptionGizmoConfig = {
641
+ /**
642
+ * @description 对齐吸附线宽
643
+ */
644
+ lineWidth: number;
645
+ /**
646
+ * @description 对齐线颜色
647
+ */
648
+ lineColor: number;
649
+ /**
650
+ * @description 对齐吸附距离
651
+ */
652
+ distance: number;
653
+ };
654
+ /**
655
+ * @description 视图控制功能参数
656
+ */
657
+ type ControlGizmoConfig = {
658
+ /**
659
+ * @description 缩放步长
660
+ */
661
+ zoomStep: number;
662
+ };
663
+ /**
664
+ * @description 视口展示功能参数
665
+ */
666
+ type PreferenceGizmoConfig = {
667
+ /**
668
+ * @description 视口窗包围盒颜色
669
+ */
670
+ boxColor: number;
671
+ /**
672
+ * @description 视口窗包围盒宽度
673
+ */
674
+ boxWidth: number;
675
+ /**
676
+ * @description 视口区域外遮罩颜色
677
+ */
678
+ markColor: number;
679
+ /**
680
+ * @description 视口区域外遮罩透明度
681
+ */
682
+ markAlpha: number;
683
+ /**
684
+ * @description 出血区预览开关
685
+ */
686
+ safeAreaEnabled: boolean;
687
+ /**
688
+ * @description 出血区颜色
689
+ */
690
+ safeAreaBoxColor: number;
691
+ /**
692
+ * @description 出血区透明度
693
+ */
694
+ safeAreaBoxAlpha: number;
695
+ };
696
+ /**
697
+ * @description 选择功能参数
698
+ */
699
+ type SelectorGizmoConfig = {
700
+ /**
701
+ * @description 预选框线宽
702
+ */
703
+ preSelectedWidth: number;
704
+ /**
705
+ * @description 预选框颜色
706
+ */
707
+ preSelectedColor: number;
708
+ /**
709
+ * @description 框选区域颜色
710
+ */
711
+ regionBoxColor: number;
712
+ /**
713
+ * @description 框选区域透明度
714
+ */
715
+ regionBoxAlpha: number;
716
+ /**
717
+ * @description 框选区域包围框颜色
718
+ */
719
+ regionWireframeColor: number;
720
+ /**
721
+ * @description 框选区域包围框透明度
722
+ */
723
+ regionWireframeAlpha: number;
724
+ /**
725
+ * @description 框选区域包围框宽度
726
+ */
727
+ regionWireframeWidth: number;
728
+ };
729
+ /**
730
+ * @description 变换功能参数
731
+ */
732
+ type TransformGizmoConfig = {
733
+ /**
734
+ * @description 变换交互框颜色
735
+ */
736
+ wireframeColor: number;
737
+ /**
738
+ * @description 变换交互框透明度
739
+ */
740
+ wireframeAlpha: number;
741
+ /**
742
+ * @description 变换交互框宽度
743
+ */
744
+ wireframeWidth: number;
745
+ /**
746
+ * @description 变换交互框角点填充色
747
+ */
748
+ cornerFillColor: number;
749
+ /**
750
+ * @description 变换交互框角点线框色
751
+ */
752
+ cornerLineColor: number;
753
+ /**
754
+ * @description 变换交互框角点线框宽度
755
+ */
756
+ cornerLineWidth: number;
757
+ /**
758
+ * @description 变换交互框角点线框透明度
759
+ */
760
+ cornerLineAlpha: number;
761
+ /**
762
+ * @description 交互框缩放圆半径
763
+ */
764
+ scaleCircleSize: number;
765
+ /**
766
+ * @description 交互框旋转圆半径
767
+ */
768
+ rotationCircleSize: number;
769
+ /**
770
+ * @description 图片Logo地址
771
+ */
772
+ pictureLogoUrl: string;
773
+ /**
774
+ * @description
775
+ */
776
+ nullLogoUrl: string;
777
+ /**
778
+ * @description 大小文字颜色
779
+ */
780
+ sizeTextColor: number;
781
+ /**
782
+ * @description 名称文字颜色
783
+ */
784
+ nameTextColor: number;
785
+ };
786
+ /**
787
+ * @description 图片裁切参数
788
+ */
789
+ type PictureCutGizmoConfig = {
790
+ /**
791
+ * @description 蒙版颜色
792
+ */
793
+ maskColor: number;
794
+ /**
795
+ * @description 蒙版透明度
796
+ */
797
+ maskAlpha: number;
798
+ /**
799
+ * @description 裁切包围盒线框宽度
800
+ */
801
+ cutBoxLineWidth: number;
802
+ /**
803
+ * @description 裁切包围盒线框颜色
804
+ */
805
+ cutBoxLineColor: number;
806
+ /**
807
+ * @description 裁切包围盒线框透明度
808
+ */
809
+ cutBoxLineAlpha: number;
810
+ /**
811
+ * @description 元素包围盒线框宽度
812
+ */
813
+ itemBoxLineWidth: number;
814
+ /**
815
+ * @description 元素包围盒线框颜色
816
+ */
817
+ itemBoxLineColor: number;
818
+ /**
819
+ * @description 元素包围盒线框透明度
820
+ */
821
+ itemBoxLineAlpha: number;
822
+ /**
823
+ * @description 裁切包围盒角度半径
824
+ */
825
+ cutBoxCornerRadius: number;
826
+ /**
827
+ * @description 裁切包围盒角点宽度
828
+ */
829
+ cutBoxCornerLineWidth: number;
830
+ /**
831
+ * @description 裁切包围盒角点颜色
832
+ */
833
+ cutBoxCornerLineColor: number;
834
+ /**
835
+ * @description 裁切包围盒角点透明度
836
+ */
837
+ cutBoxCornerLineAlpha: number;
838
+ /**
839
+ * @description 裁切包围盒角点填充色
840
+ */
841
+ cutBoxCornerFillColor: number;
842
+ /**
843
+ * @description 缩放判断距离
844
+ */
845
+ scaleInteractionDistance: number;
846
+ /**
847
+ * @description 单向缩放判断距离
848
+ */
849
+ directionScaleInteractionDistance: number;
850
+ };
851
+ /**
852
+ * @description 图片扩边参数
853
+ */
854
+ type PictureExpandGizmoConfig = {
855
+ /**
856
+ * @description 蒙版颜色
857
+ */
858
+ maskColor: number;
859
+ /**
860
+ * @description 蒙版透明度
861
+ */
862
+ maskAlpha: number;
863
+ /**
864
+ * @description 扩边包围盒线框宽度
865
+ */
866
+ expandBoxLineWidth: number;
867
+ /**
868
+ * @description 扩边包围盒线框颜色
869
+ */
870
+ expandBoxLineColor: number;
871
+ /**
872
+ * @description 扩边包围盒线框透明度
873
+ */
874
+ expandBoxLineAlpha: number;
875
+ /**
876
+ * @description 扩边包围盒角度半径
877
+ */
878
+ expandBoxCornerRadius: number;
879
+ /**
880
+ * @description 扩边包围盒角点宽度
881
+ */
882
+ expandBoxCornerLineWidth: number;
883
+ /**
884
+ * @description 扩边包围盒角点颜色
885
+ */
886
+ expandBoxCornerLineColor: number;
887
+ /**
888
+ * @description 扩边包围盒角点透明度
889
+ */
890
+ expandBoxCornerLineAlpha: number;
891
+ /**
892
+ * @description 扩边包围盒角点填充色
893
+ */
894
+ expandBoxCornerFillColor: number;
895
+ /**
896
+ * @description 缩放判断距离
897
+ */
898
+ scaleInteractionDistance: number;
899
+ /**
900
+ * @description 单向缩放判断距离
901
+ */
902
+ directionScaleInteractionDistance: number;
903
+ };
904
+ /**
905
+ * @description 文本交互控制器旋转交互模式
906
+ * 'corner': 角点旋转
907
+ * 'top-center': 顶部中心旋转
908
+ */
909
+ type TextGizmoRotateInteractMode = 'corner' | 'top-center';
910
+ /**
911
+ * @description 文本交互控制器参数
912
+ */
913
+ type TextGizmoConfig = {
914
+ /**
915
+ * @description 旋转交互模式
916
+ */
917
+ rotateInteractMode: TextGizmoRotateInteractMode;
918
+ /**
919
+ * @description 包围盒线宽
920
+ */
921
+ boxLineWidth: number;
922
+ /**
923
+ * @description 包围盒线色
924
+ */
925
+ boxLineColor: number;
926
+ /**
927
+ * @description 旋转交互点边长 - 用于 top-center 交互模式
928
+ */
929
+ rotationCornerWidth: number;
930
+ /**
931
+ * @description 旋转交互贴图地址
932
+ */
933
+ rotationCornerTexture: string;
934
+ /**
935
+ * @description 旋转交互点半径
936
+ */
937
+ rotationCornerRadius: number;
938
+ /**
939
+ * @description top-center 模式旋转交互距离
940
+ */
941
+ rotationTopCenterInteractionDistance: number;
942
+ /**
943
+ * @description 旋转交互点填充色
944
+ */
945
+ rotationCornerFillColor: number;
946
+ /**
947
+ * @description 旋转交互点描边宽度
948
+ */
949
+ rotationCornerStrokeWidth: number;
950
+ /**
951
+ * @description 旋转交互点描边颜色
952
+ */
953
+ rotationCornerStrokeColor: number;
954
+ /**
955
+ * @description Corner 模式旋转交互距离
956
+ */
957
+ rotationCornerInteractionDistance: number;
958
+ /**
959
+ * @description 缩放交互点半径
960
+ */
961
+ scaleCornerRadius: number;
962
+ /**
963
+ * @description 缩放交互点填充色
964
+ */
965
+ scaleCornerFillColor: number;
966
+ /**
967
+ * @description 缩放交互点描边宽度
968
+ */
969
+ scaleCornerStrokeWidth: number;
970
+ /**
971
+ * @description 缩放交互点描边颜色
972
+ */
973
+ scaleCornerStrokeColor: number;
974
+ /**
975
+ * @description 出发缩放交互的距离
976
+ */
977
+ scaleInteractionDistance: number;
978
+ };
979
+ /**
980
+ * @description 蒙版参数
981
+ */
982
+ type MaskGizmoConfig = {
983
+ /**
984
+ * @description 画笔大小
985
+ */
986
+ brushSize: number;
987
+ /**
988
+ * @description 笔刷颜色
989
+ */
990
+ brushColor: number;
991
+ /**
992
+ * @description 笔刷透明度
993
+ */
994
+ brushAlpha: number;
995
+ /**
996
+ * @description 蒙版颜色
997
+ */
998
+ maskColor: number;
999
+ /**
1000
+ * @description 蒙版透明度
1001
+ */
1002
+ maskAlpha: number;
1003
+ /**
1004
+ * @description 元素包围盒线框宽度
1005
+ */
1006
+ boxLineWidth: number;
1007
+ /**
1008
+ * @description 元素包围盒线框颜色
1009
+ */
1010
+ boxLineColor: number;
1011
+ /**
1012
+ * @description 元素包围盒线框透明度
1013
+ */
1014
+ boxLineAlpha: number;
1015
+ };
1016
+
1017
+ type SDKEvents = {
1018
+ 'loadingItemChange': [id: string[]];
1019
+ 'selectedItemChange': [id: string[]];
1020
+ 'preSelectedItemChange': [id: string | undefined];
1021
+ 'selectedViewChange': [id: number];
1022
+ 'pageDataChange': [pageData: PageData];
1023
+ 'zoomChange': [zoom: number];
1024
+ 'progress': [{
1025
+ duration: number;
1026
+ time: number;
1027
+ end: boolean;
1028
+ paused: boolean;
1029
+ }];
1030
+ 'itemPropertyChange': [{
1031
+ id: string;
1032
+ property: string;
1033
+ }];
1034
+ 'exportProgress': [progress?: number];
1035
+ 'exportDone': [item: ExportMediaItemOptions | undefined, success: boolean, buffer?: FileBuffer];
1036
+ 'exportComplete': [success: boolean, taskInfos: ExportMediaItemOptions[], buffers?: FileBuffer[]];
1037
+ 'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
1038
+ 'cutBoxChange': [box: Box2];
1039
+ 'expandBoxChange': [box: Box2];
1040
+ 'textInput': [{
1041
+ itemId: string;
1042
+ text: string;
1043
+ fontFamily: string;
1044
+ }];
1045
+ 'undoRedoChange': [Operation];
1046
+ 'viewportTransform': [{
1047
+ zoom: number;
1048
+ translation: [number, number];
1049
+ }];
1050
+ };
1051
+ declare class SDK {
1052
+ static config: SDKConfig;
1053
+ private _eventEmitter;
1054
+ private _pageData;
1055
+ private _screenShot;
1056
+ private _exporter?;
1057
+ private _pageDataUtils;
1058
+ private _sizeAdapt;
1059
+ private _gestureHandler;
1060
+ private disposables;
1061
+ private _isSwitchScene;
1062
+ private _undoRedo;
1063
+ player: Player;
1064
+ _container: HTMLElement;
1065
+ private _playerContainer;
1066
+ constructor(container: HTMLElement, mode?: SDKMode);
1067
+ get container(): HTMLElement;
1068
+ get pageData(): PageData | undefined;
1069
+ get exportStatus(): string | undefined;
1070
+ get undoRedo(): UndoRedo;
1071
+ private get exportOptions();
1072
+ dispose(): void;
1073
+ on: <E extends "progress" | "loadingItemChange" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange" | "expandBoxChange" | "textInput" | "undoRedoChange" | "viewportTransform">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
1074
+ setSDKMode(mode: SDKMode): void;
1075
+ private getInitParam;
1076
+ /**
1077
+ * 检测导出是否需要重新初始化
1078
+ * @param preExportVideoConfig
1079
+ * @param curExportVideoConfig
1080
+ */
1081
+ private checkExporter;
1082
+ private initExporter;
1083
+ private initSDK;
1084
+ run(param: SDKInputParam): Promise<void>;
1085
+ getPageData(): PageData;
1086
+ getActiveItems(): string[];
1087
+ setPreSelectedItem(id: string): void;
1088
+ getPreSelectedItem(): string;
1089
+ setSelectedItems(itemIds: string[]): void;
1090
+ /**
1091
+ * @description 获取目标元素的所有属性
1092
+ * @param param 元素ID、类型
1093
+ * @returns 元素属性
1094
+ */
1095
+ getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
1096
+ /**
1097
+ * @description 获取目标元素的指定属性
1098
+ * @param param 元素ID、类型、属性名
1099
+ * @returns 元素属性值
1100
+ */
1101
+ getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
1102
+ setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
1103
+ generateScreenShot(id: number, size?: [number, number], tick?: number, backgroundColor?: spec.vec4): Promise<string | undefined>;
1104
+ /**
1105
+ * @description 切换场景
1106
+ * @param index 场景索引
1107
+ */
1108
+ switchScene(index: number): Promise<void>;
1109
+ /**
1110
+ * @description 获取页面的 safeAreaPreview、zoom、adsorption、translation 值
1111
+ * @returns 页面的 safeAreaPreview、zoom、adsorption、translation 值
1112
+ */
1113
+ getPageConfig(): PageConfig;
1114
+ /**
1115
+ * 设置页面的 safeAreaPreview、zoom、adsorption 值
1116
+ * @param pageProperty 设置
1117
+ */
1118
+ setPageConfig(pageConfig: PageConfig): void;
1119
+ /**
1120
+ * @description 设置播放进度
1121
+ * @param progress 播放进度 0-100
1122
+ */
1123
+ setPlayProgress(progress: number): Promise<void>;
1124
+ getViewItems(): ViewItem[];
1125
+ setPlayState(playState: 'play' | 'pause'): Promise<void>;
1126
+ /**
1127
+ * @description 获取场景预览图
1128
+ * @returns 视图预览图
1129
+ */
1130
+ getViewThumbnail(): Promise<{
1131
+ id: number;
1132
+ thumbnail: string | undefined;
1133
+ }>[];
1134
+ /**
1135
+ * @description 获取视图JSON产物
1136
+ * @returns 当前所有视图JSON产物
1137
+ */
1138
+ getViewScene(): {
1139
+ id: number;
1140
+ thumbnail: spec.JSONScene;
1141
+ }[];
1142
+ private destroyCompositions;
1143
+ /**
1144
+ * @description 导出,支持导出媒体或其他,如MP4,未来支持 JSON 等;
1145
+ */
1146
+ onExport(): void;
1147
+ /**
1148
+ * @description 取消导出
1149
+ */
1150
+ cancelExport(): void;
1151
+ loadPageData(data: PageData): Promise<void>;
1152
+ runByPageData(data: PageData): Promise<void>;
1153
+ reloadPageDataByScene(scene: string | spec.JSONScene): Promise<void>;
1154
+ addViewParams(viewParams: ViewParam[]): Promise<void>;
1155
+ deleteViewParams(ids: number[]): Promise<void>;
1156
+ setExportParam(exportParam: Partial<ExportParam>, id?: number): void;
1157
+ /**
1158
+ * @description 设置视图缩放
1159
+ * @param zoom 缩放值
1160
+ * @param center 缩放中心
1161
+ * @param ignoreClamp 是否忽视约束
1162
+ */
1163
+ setPageZoom(zoom: number, center?: Vector2, ignoreClamp?: boolean): void;
1164
+ /**
1165
+ * @description 设置元素移动
1166
+ * @param targetTranslation 目标移动值
1167
+ */
1168
+ setPageMove(targetTranslation: Vector2): void;
1169
+ /**
1170
+ * @description 设置静态预览功能开关
1171
+ * @param enabled 功能开关
1172
+ */
1173
+ setStaticPreviewEnabled(enabled: boolean): void;
1174
+ /**
1175
+ * @description 设置静态预览视图名称
1176
+ * @param name 视图名称
1177
+ */
1178
+ setStaticPreviewName(name: string): void;
1179
+ /**
1180
+ * @description 设置同步修改功能开关
1181
+ * @param enabled 功能开关
1182
+ */
1183
+ setAsyncEnabled(enabled: boolean): void;
1184
+ /**
1185
+ * @description 设置 成组显影 开关
1186
+ */
1187
+ setGroupVisibleEnabled(enabled: boolean): void;
1188
+ /**
1189
+ * @description 新增过滤元素名称
1190
+ * @param itemNames 过滤元素名称
1191
+ */
1192
+ addFilterItemNames(itemNames: string[] | string): void;
1193
+ /**
1194
+ * @description 设置预览辅助层颜色
1195
+ * @param color 色值
1196
+ */
1197
+ setPreferenceBackgroundColor(color: [number, number, number, number]): void;
1198
+ /**
1199
+ * @description 设置出血区颜色
1200
+ * @param color 色值
1201
+ */
1202
+ setSafeAreaColor(color: [number, number, number, number]): void;
1203
+ /**
1204
+ * @description 设置 尺寸自适应拓展 功能开关
1205
+ * @param enabled 功能开关
1206
+ */
1207
+ setSizeAdaptEnabled(enabled: boolean): void;
1208
+ /**
1209
+ * @description 设置 截图 功能开关
1210
+ * @param enabled 功能开关
1211
+ */
1212
+ setScreenShotEnabled(enabled: boolean): void;
1213
+ /**
1214
+ * @description 设置导出功能初始化配置
1215
+ * @param exportConfig
1216
+ */
1217
+ setExportConfig(exportConfig: Partial<ExportConfig>): void;
1218
+ /**
1219
+ * @description 设置预选框参数
1220
+ * @param preSelectedColor 预选框颜色
1221
+ * @param preSelectedWidth 预选框线框宽度
1222
+ */
1223
+ setSelectorGizmoPreSelectConfig(preSelectedColor?: number, preSelectedWidth?: number): void;
1224
+ /**
1225
+ * @description 设置 变换控制器 交互框参数
1226
+ * @param config 参数
1227
+ */
1228
+ setTranformGizmoWireframeConfig(config: {
1229
+ wireframeColor?: number;
1230
+ wireframeAlpha?: number;
1231
+ wireframeWidth?: number;
1232
+ }): void;
1233
+ /**
1234
+ * @description 获取 SDK 配置参数
1235
+ * @returns SDK 配置参数
1236
+ */
1237
+ getSDKConfig(): SDKConfig;
1238
+ /**
1239
+ * @description 设置 SDK 配置参数
1240
+ * @param config SDK 配置参数
1241
+ */
1242
+ setSDKConfig(config: SDKConfig): void;
1243
+ /**
1244
+ * @description 设置SDK背景
1245
+ * @param type 背景类型
1246
+ * @param value 值
1247
+ */
1248
+ setSDKBackground(type: SDKBackgroundType, value?: string): void;
1249
+ /**
1250
+ * @description 创建图层元素
1251
+ * @param spriteInfo 图层元素信息
1252
+ */
1253
+ addSpriteItem(spriteInfo: SpriteCreateInfo, scene?: spec.JSONScene): Promise<string | undefined>;
1254
+ openPictureCutGizmo(): void;
1255
+ closePictureCutGizmo(): void;
1256
+ getCutInfo(): {
1257
+ cutBox: Box2;
1258
+ itemBox: Box2;
1259
+ } | undefined;
1260
+ setCutBox(min: Vector2, max: Vector2): Box2 | undefined;
1261
+ openPictureExpandGizmo(): void;
1262
+ closePictureExpandGizmo(): void;
1263
+ getExpandInfo(): {
1264
+ expandBox: Box2;
1265
+ itemBox: Box2;
1266
+ } | undefined;
1267
+ setExpandBox(min: Vector2, max: Vector2): Box2 | undefined;
1268
+ openMaskGizmo(brushSize: number): void;
1269
+ clearMaskGizmo(): void;
1270
+ closeMaskGizmo(): void;
1271
+ getMask(): string | null | undefined;
1272
+ setMaskGizmoConfig(config: Partial<MaskGizmoConfig>): void;
1273
+ openLoadingGizmo(id: string): void;
1274
+ closeLoadingGizmo(id: string): void;
1275
+ /**
1276
+ * @description 元素打组
1277
+ * @param children 子元素ID
1278
+ */
1279
+ groupItems(nullInfo: NullCreateInfo, scene?: spec.JSONScene): string | undefined;
1280
+ addTextItem(textInfo: TextCreateInfo, scene?: spec.JSONScene): Promise<void>;
1281
+ deleteItems(idInfo: string | string[]): void;
1282
+ getItemCreateInfo(idInfo: string | string[]): ItemCreateInfo[];
1283
+ createScreenShotSceneByIds(idInfo: string | string[], time?: number): Promise<string | undefined>;
1284
+ getChildrenIds(id: string): string[];
1285
+ /**
1286
+ * @description 更新元素在图层中的顺序
1287
+ * @param id 元素ID
1288
+ * @param action 排序操作:BringToFront(置于顶层)、SendToBack(置于底层)、BringForward(上移一层)、SendBackward(下移一层)
1289
+ */
1290
+ updateItemOrder(id: string, action: ItemOrderAction): void;
1291
+ /**
1292
+ * @description 导出JSON
1293
+ * @param idInfo 视图序号信息
1294
+ * @returns JSON数组
1295
+ */
1296
+ exportJSON(idInfo?: number | number[]): spec.JSONScene[];
1297
+ getViewBoxById(id: string): Box2;
1298
+ getViewItemById(id: string): ViewItem | undefined;
1299
+ getViewProperty(id: number): ViewProperty | undefined;
1300
+ pageMove(shift: [number, number]): void;
1301
+ pageZoom(shift: number, center?: [number, number]): void;
1302
+ /**
1303
+ * @description 设置视图缩放工具锁定缩放比例开关
1304
+ * @param state 缩放比例开关
1305
+ */
1306
+ setPictureCutGizmoLockScale(state: boolean): void;
1307
+ /**
1308
+ * @description 设置视图扩展工具锁定缩放比例开关
1309
+ * @param state 缩放比例开关
1310
+ */
1311
+ setPictureExpandGizmoLockScale(state: boolean): void;
1312
+ /**
1313
+ * @description 视图缩放函数
1314
+ * @param shiftParam 视图偏移值
1315
+ */
1316
+ viewportFit(shiftParam?: ViewportFitShiftParam): void;
1317
+ /**
1318
+ * @description 获取元素包围盒
1319
+ * @param idInfo 元素Id
1320
+ * @returns 元素包围盒
1321
+ */
1322
+ getItemBoxById(idInfo: string): Box2;
1323
+ /**
1324
+ * @description 设置元素字体
1325
+ * @param id 元素Id
1326
+ * @param fontFamilyName 字体名称
1327
+ * @param url 字体地址
1328
+ */
1329
+ setItemFontFamily(id: string, fontFamilyName: string, url: string): Promise<void>;
1330
+ createSceneByCreateInfos(createInfos: ItemCreateInfo[], sceneInfo: SceneCreaetInfo): spec.JSONScene;
1331
+ }
1332
+
1333
+ type SizeAdaptDirection = 'x' | 'y';
48
1334
 
49
1335
  type BaseFormProperty = {
50
- position: [number, number, number];
1336
+ position: [number, number];
51
1337
  rotation: [number, number, number];
52
- scale: [number, number, number];
1338
+ size: [number, number];
1339
+ visible: boolean;
53
1340
  keyPropertyEditing: boolean;
54
1341
  };
55
1342
  type SpriteFormProperty = BaseFormProperty & {
56
1343
  image: string;
57
1344
  };
58
1345
  type TextFormProperty = BaseFormProperty & {
59
- font: string;
60
- color: [number, number, number, number];
61
- weight: spec.TextWeight;
1346
+ fontFamily: string;
1347
+ textColor: [number, number, number, number];
1348
+ fontWeight: spec.TextWeight;
62
1349
  text: string;
63
- alignment: spec.TextAlignment;
1350
+ textAlign: spec.TextAlignment;
1351
+ fontSize: number;
1352
+ fontStyle: spec.FontStyle;
1353
+ textWidth: number;
1354
+ lineHeight: number;
1355
+ outlineColor?: spec.vec4;
1356
+ outlineWidth?: number;
64
1357
  };
65
1358
  /**
66
1359
  * @description 页面表单类型和属性引用
@@ -93,26 +1386,37 @@ type SpecificPageFormProps<T extends keyof PageFormTypeAndPropertyReference> = {
93
1386
  property: PageFormTypeAndPropertyReference[T];
94
1387
  onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[T]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[T][N]) => void;
95
1388
  };
1389
+ type SDKOptions = {
1390
+ /** 导出视频时,是否开启转码日志 */
1391
+ loggerInExportVideoTranscoding?: boolean;
1392
+ };
1393
+ type SDKInputParam = SDKTemplateInputParam | SDKEditorInputParam;
96
1394
  /**
97
1395
  * @description SDK入参
98
1396
  */
99
- type SDKInputParam = {
1397
+ type SDKTemplateInputParam = {
100
1398
  /**
101
1399
  * @description JSON地址
102
1400
  */
103
1401
  scene: string | spec.JSONScene;
1402
+ /**
1403
+ * @description SDK模式 - 模板编辑模式
1404
+ */
1405
+ mode: 'template';
104
1406
  /**
105
1407
  * @description 视图参数
106
1408
  */
107
- viewParams: ViewParam[];
1409
+ viewParams?: ViewParam[];
108
1410
  /**
109
1411
  * @description 页面属性
110
1412
  */
111
1413
  options: PageOptions;
1414
+ };
1415
+ type SDKEditorInputParam = {
112
1416
  /**
113
- * @description 是否开启出血区强制变换
1417
+ * @description SDK模式 - 编辑器模式
114
1418
  */
115
- keepSafe: boolean;
1419
+ mode: 'editor';
116
1420
  };
117
1421
  /**
118
1422
  * @description 页面属性
@@ -135,6 +1439,10 @@ type PageOptions = {
135
1439
  * @description 页面数据
136
1440
  */
137
1441
  type PageData = {
1442
+ /**
1443
+ * @description 基础场景数据
1444
+ */
1445
+ scene: spec.JSONScene;
138
1446
  /**
139
1447
  * @description 页面属性
140
1448
  */
@@ -180,6 +1488,10 @@ type PageConfig = {
180
1488
  * @description 同步开关
181
1489
  */
182
1490
  asyncMode: boolean;
1491
+ /**
1492
+ * @description 画布移动
1493
+ */
1494
+ translation: spec.vec2;
183
1495
  };
184
1496
  /**
185
1497
  * @description 页面属性
@@ -213,11 +1525,19 @@ type ViewParam = {
213
1525
  /**
214
1526
  * @description 页面尺寸
215
1527
  */
216
- size: [number, number];
1528
+ size?: [number, number];
217
1529
  /**
218
1530
  * @description 出血区参数
219
1531
  */
220
- safeArea: [number, number, number, number];
1532
+ safeArea?: [number, number, number, number];
1533
+ /**
1534
+ * @description 自适应方向 - 默认根据视图宽高决定
1535
+ */
1536
+ adaptionDirection?: SizeAdaptDirection;
1537
+ /**
1538
+ * @description 自定义出血区 - 用于展示
1539
+ */
1540
+ previewSafeAreas?: PreviewSafeAreaParam[];
221
1541
  /**
222
1542
  * @description 导出参数
223
1543
  */
@@ -228,22 +1548,10 @@ type ViewParam = {
228
1548
  */
229
1549
  type ExportParam = {
230
1550
  /**
231
- * @description 导出视频时长
232
- */
233
- time: number;
234
- /**
235
- * @description 导出大小上限 - 单位kb
236
- */
237
- fileSizeLimit: number;
238
- /**
239
- * @description 是否开启音轨
240
- */
241
- audioEnable: boolean;
242
- /**
243
- * @description 导出视频类型 - 预留参数
1551
+ * @description 视频名称
244
1552
  */
245
- type?: string;
246
- };
1553
+ name?: string;
1554
+ } & Omit<ExportMediaItemOptions, 'scene' | 'size'>;
247
1555
  /**
248
1556
  * @description 视图属性
249
1557
  */
@@ -261,13 +1569,13 @@ type ViewProperty = {
261
1569
  */
262
1570
  safeArea: [number, number, number, number];
263
1571
  /**
264
- * @description 视图场景数据
1572
+ * @description 自定义出血区数据
265
1573
  */
266
- scene: spec.JSONScene;
1574
+ previewSafeAreas: PreviewSafeAreaParam[];
267
1575
  /**
268
- * @description 预览图数据
1576
+ * @description 视图场景数据
269
1577
  */
270
- thumbnail: string;
1578
+ scene: spec.JSONScene;
271
1579
  /**
272
1580
  * @description 导出参数
273
1581
  */
@@ -277,6 +1585,19 @@ type ViewProperty = {
277
1585
  */
278
1586
  ignoreInteraction: boolean;
279
1587
  };
1588
+ /**
1589
+ * @description 自定义出血区数据
1590
+ */
1591
+ type PreviewSafeAreaParam = {
1592
+ /**
1593
+ * @description 出血区包围盒 [left top width height]
1594
+ */
1595
+ box: [number, number, number, number];
1596
+ /**
1597
+ * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
1598
+ */
1599
+ color?: [number, number, number, number];
1600
+ };
280
1601
  /**
281
1602
  * @description 页面活跃数据
282
1603
  */
@@ -293,6 +1614,10 @@ type ActiveData = {
293
1614
  * @description 预选中元素
294
1615
  */
295
1616
  preSelectedItem?: string;
1617
+ /**
1618
+ * @description 执行中元素
1619
+ */
1620
+ loadingItems?: string[];
296
1621
  };
297
1622
  /**
298
1623
  * @description 视图元素
@@ -327,113 +1652,197 @@ type ViewItem = {
327
1652
  */
328
1653
  endBehavior: spec.EndBehavior;
329
1654
  } & ViewItemTypedProperty;
330
-
331
- declare const ExportStatusMap: {
332
- readonly DEFAULT: "default";
333
- readonly EXPORTING: "exporting";
334
- readonly SUCCESS: "success";
335
- readonly ERROR: "error";
1655
+ type SDKBackgroundType = 'color' | 'image' | 'chess-board';
1656
+ /**
1657
+ * @description 图层创建信息
1658
+ */
1659
+ type SpriteCreateInfo = {
1660
+ type: 'sprite';
1661
+ /**
1662
+ * @description 图层名称
1663
+ */
1664
+ name?: string;
1665
+ /**
1666
+ * @description 元素id
1667
+ */
1668
+ id?: string;
1669
+ /**
1670
+ * @description 父节点id
1671
+ */
1672
+ parentId?: string;
1673
+ /**
1674
+ * @description 图片资源地址
1675
+ */
1676
+ url: string;
1677
+ /**
1678
+ * @description 图层元素像素大小
1679
+ */
1680
+ size: spec.vec2;
1681
+ /**
1682
+ * @description 图层元素缩放
1683
+ */
1684
+ scale?: spec.vec2;
1685
+ /**
1686
+ * @description 图层元素旋转
1687
+ */
1688
+ rotation?: number;
1689
+ /**
1690
+ * @description 图层元素二维位置
1691
+ */
1692
+ position: spec.vec2;
336
1693
  };
337
- type ExportStatus = typeof ExportStatusMap[keyof typeof ExportStatusMap];
338
- type SDKEvents = {
339
- 'selectedItemChange': [id: string[]];
340
- 'preSelectedItemChange': [id: string | undefined];
341
- 'selectedViewChange': [id: number];
342
- 'pageDataChange': [pageData: PageData];
343
- 'zoomChange': [zoom: number];
344
- 'progress': [{
345
- duration: number;
346
- time: number;
347
- end: boolean;
348
- paused: boolean;
349
- }];
350
- 'itemPropertyChange': [{
351
- id: string;
352
- property: string;
353
- }];
354
- 'exportProgress': [progress?: number];
355
- 'exportComplete': [success: boolean];
1694
+ /**
1695
+ * @description 空节点创建信息
1696
+ */
1697
+ type NullCreateInfo = {
1698
+ type: 'null';
1699
+ /**
1700
+ * @description 元素id
1701
+ */
1702
+ id?: string;
1703
+ /**
1704
+ * @description 父节点id
1705
+ */
1706
+ parentId?: string;
1707
+ /**
1708
+ * @description 元素名称
1709
+ */
1710
+ name?: string;
1711
+ /**
1712
+ * @description 空节点缩放
1713
+ */
1714
+ scale?: spec.vec2;
1715
+ /**
1716
+ * @description 子元素id
1717
+ */
1718
+ children: string[];
1719
+ /**
1720
+ * @description 空节点旋转
1721
+ */
1722
+ rotation?: number;
1723
+ /**
1724
+ * @description 空节点位移
1725
+ */
1726
+ position?: spec.vec2;
356
1727
  };
357
- declare class SDK {
358
- private _eventEmitter;
359
- private _pageData;
360
- private _screenShotContainer;
361
- private _screenShotPlayer;
362
- private _SDKUtils;
363
- private _ExportVideo;
364
- private _gestureHandler;
365
- private _playerContainer;
366
- private _exportStatus;
367
- private disposables;
368
- player: Player;
369
- constructor(container: HTMLElement);
370
- get pageData(): PageData | undefined;
371
- get exportStatus(): ExportStatus;
372
- private get exportOptions();
373
- dispose(): void;
374
- on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportComplete">(eventName: E, listener: _galacean_effects_weapp.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects_weapp.EventEmitterOptions) => () => void;
375
- private getInitParam;
376
- private initSDK;
377
- run(param: SDKInputParam): Promise<void>;
378
- getPageData(): PageData;
379
- getActiveItems(): string[];
380
- setPreSelectedItem(id: string): void;
381
- getPreSelectedItem(): string;
382
- setSelectedItems(itemIds: string[]): void;
1728
+ /**
1729
+ * @description 文本创建信息
1730
+ */
1731
+ type TextCreateInfo = {
1732
+ type: 'text';
383
1733
  /**
384
- * @description 获取目标元素的所有属性
385
- * @param param 元素ID、类型
386
- * @returns 元素属性
1734
+ * @description 元素id
387
1735
  */
388
- getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
1736
+ id?: string;
389
1737
  /**
390
- * @description 获取目标元素的指定属性
391
- * @param param 元素ID、类型、属性名
392
- * @returns 元素属性值
1738
+ * @description 父节点id
393
1739
  */
394
- getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
395
- setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
396
- generateScreenShot(id: number): Promise<string>;
1740
+ parentId?: string;
397
1741
  /**
398
- * @description 切换场景
399
- * @param index 场景索引
1742
+ * @description 元素名称
400
1743
  */
401
- switchScene(index: number): Promise<void>;
1744
+ name?: string;
402
1745
  /**
403
- * @description 获取页面的 safeAreaPreview、zoom、adsorption 值
404
- * @returns 页面的 safeAreaPreview、zoom、adsorption 值
1746
+ * @description 单行高度
405
1747
  */
406
- getConfig(): PageConfig;
1748
+ lineHeight: number;
407
1749
  /**
408
- * 设置页面的 safeAreaPreview、zoom、adsorption 值
409
- * @param pageProperty 设置
1750
+ * @description 文本高度
410
1751
  */
411
- setConfig(pageConfig: PageConfig): void;
1752
+ textHeight?: number;
412
1753
  /**
413
- * @description 设置播放进度
414
- * @param progress 播放进度 0-100
1754
+ * @description 宽度
415
1755
  */
416
- setPlayProgress(progress: number): Promise<void>;
417
- getViewItems(): ViewItem[];
418
- setPlayState(playState: 'play' | 'pause'): void;
1756
+ textWidth: number;
419
1757
  /**
420
- * @description 获取场景预览图
421
- * @returns 视图预览图
1758
+ * @description 字体名称
422
1759
  */
423
- getViewThumbnail(): {
424
- id: number;
425
- thumbnail: string;
426
- }[];
427
- private onExportProgress;
428
- private onExportFinish;
429
- private onExportError;
1760
+ fontFamily: string;
430
1761
  /**
431
- * @description 导出视频
1762
+ * @description 文本位置
432
1763
  */
433
- exportAllVideos(): void;
434
- cancelExportAllVideos(): void;
435
- loadPageData(data: PageData): Promise<void>;
436
- runByPageData(data: PageData): Promise<void>;
1764
+ position?: spec.vec2;
1765
+ /**
1766
+ * @description 文本旋转
1767
+ */
1768
+ rotation?: number;
1769
+ /**
1770
+ * @description 文字大小
1771
+ */
1772
+ fontSize: number;
1773
+ /**
1774
+ * @description 字重
1775
+ */
1776
+ fontWeight?: spec.TextWeight;
1777
+ /**
1778
+ * @description 字体格式
1779
+ */
1780
+ fontStyle?: spec.FontStyle;
1781
+ /**
1782
+ * @description 对齐方式
1783
+ */
1784
+ textAlign?: spec.TextAlignment;
1785
+ /**
1786
+ * @description 文本信息
1787
+ */
1788
+ text: string;
1789
+ /**
1790
+ * @description 填充色
1791
+ */
1792
+ textColor: spec.vec4;
1793
+ /**
1794
+ * @description 描边色
1795
+ */
1796
+ outlineColor?: spec.vec4;
1797
+ /**
1798
+ * @description 描边宽度
1799
+ */
1800
+ outlineWidth?: number;
1801
+ /**
1802
+ * @description 字体文件地址
1803
+ */
1804
+ url?: string;
1805
+ };
1806
+ type ItemCreateInfo = NullCreateInfo | SpriteCreateInfo | TextCreateInfo;
1807
+ /**
1808
+ * @description 场景创建信息
1809
+ */
1810
+ type SceneCreaetInfo = {
1811
+ /**
1812
+ * @description 场景名称
1813
+ */
1814
+ name: string;
1815
+ /**
1816
+ * @description 场景大小
1817
+ */
1818
+ size: spec.vec2;
1819
+ };
1820
+ declare enum ItemOrderAction {
1821
+ BringToFront = 0,
1822
+ SendToBack = 1,
1823
+ BringForward = 2,
1824
+ SendBackward = 3
437
1825
  }
1826
+ /**
1827
+ * @description 视图自适应偏移参数
1828
+ */
1829
+ type ViewportFitShiftParam = {
1830
+ /**
1831
+ * @description 左偏移
1832
+ */
1833
+ left?: number;
1834
+ /**
1835
+ * @description 右偏移
1836
+ */
1837
+ right?: number;
1838
+ /**
1839
+ * @description 上偏移
1840
+ */
1841
+ top?: number;
1842
+ /**
1843
+ * @description 下偏移
1844
+ */
1845
+ bottom?: number;
1846
+ };
438
1847
 
439
- export { type ActiveData, type BaseFormProperty, type ExportStatus, ExportStatusMap, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SpecificPageFormProps, type SpriteFormProperty, type TextFormProperty, type ViewItem, type ViewParam, type ViewProperty };
1848
+ export { type ActiveData, type BaseFormProperty, Box2, type CreateOperation, type DeleteOperation, type ItemCreateInfo, ItemOrderAction, type NullCreateInfo, type Operation, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SetItemPropertyValueParam, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextCreateInfo, type TextFormProperty, type UpdateOperation, Vector2, type ViewItem, type ViewItemTypedProperty, type ViewParam, type ViewProperty };