@vvfx/sdk 0.0.0-alpha.27 → 0.0.0-alpha.29

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.cts CHANGED
@@ -46,782 +46,828 @@ type SetItemPropertyValueParam = {
46
46
  }[keyof PageFormTypeAndPropertyReference[T]];
47
47
  }[keyof PageFormTypeAndPropertyReference];
48
48
 
49
- type BaseFormProperty = {
50
- position: [number, number, number];
51
- rotation: [number, number, number];
52
- size: [number, number];
53
- visible: boolean;
54
- keyPropertyEditing: boolean;
55
- };
56
- type SpriteFormProperty = BaseFormProperty & {
57
- image: string;
58
- };
59
- type TextFormProperty = BaseFormProperty & {
60
- font: string;
61
- color: [number, number, number, number];
62
- weight: spec.TextWeight;
63
- text: string;
64
- alignment: spec.TextAlignment;
65
- };
66
- /**
67
- * @description 页面表单类型和属性引用
68
- */
69
- type PageFormTypeAndPropertyReference = {
70
- [spec.ItemType.base]: BaseFormProperty;
71
- [spec.ItemType.sprite]: SpriteFormProperty;
72
- [spec.ItemType.particle]: BaseFormProperty;
73
- [spec.ItemType.null]: BaseFormProperty;
74
- [spec.ItemType.interact]: BaseFormProperty;
75
- [spec.ItemType.plugin]: BaseFormProperty;
76
- [spec.ItemType.camera]: BaseFormProperty;
77
- [spec.ItemType.composition]: BaseFormProperty;
78
- [spec.ItemType.spine]: BaseFormProperty;
79
- [spec.ItemType.mesh]: BaseFormProperty;
80
- [spec.ItemType.tree]: BaseFormProperty;
81
- [spec.ItemType.text]: TextFormProperty;
82
- [spec.ItemType.light]: BaseFormProperty;
83
- [spec.ItemType.skybox]: BaseFormProperty;
84
- [spec.ItemType.effect]: BaseFormProperty;
85
- [spec.ItemType.shape]: BaseFormProperty;
86
- [spec.ItemType.postProcessVolume]: BaseFormProperty;
87
- [spec.ItemType.node]: BaseFormProperty;
88
- [spec.ItemType.video]: BaseFormProperty;
89
- [spec.ItemType.audio]: BaseFormProperty;
90
- [spec.ItemType.richtext]: TextFormProperty;
49
+ declare const MEDIA_TYPE: {
50
+ readonly APNG: "APNG";
51
+ readonly MP4: "MP4";
52
+ readonly WebM: "WebM";
53
+ readonly Images: "Images";
54
+ readonly WebP: "WebP";
55
+ readonly GIF: "GIF";
56
+ readonly AlphaMaskVideo: "AlphaMaskVideo";
91
57
  };
92
- type SpecificPageFormProps<T extends keyof PageFormTypeAndPropertyReference> = {
93
- type: T;
94
- property: PageFormTypeAndPropertyReference[T];
95
- onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[T]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[T][N]) => void;
58
+
59
+ declare global {
60
+ interface Window {
61
+ /**
62
+ * @description 创建 WebP Core 实例
63
+ */
64
+ createWebPCore: (config: any) => Promise<Img2WebPCore>;
65
+ }
66
+ }
67
+ type FileBuffer = ArrayBuffer | Uint8Array;
68
+ type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
69
+ type FS = {
70
+ writeFile: (path: string, data: Uint8Array | string) => void;
71
+ readFile(path: string, opts: {
72
+ encoding: 'binary';
73
+ flags?: string | undefined;
74
+ }): Uint8Array;
75
+ readFile(path: string, opts: {
76
+ encoding: 'utf8';
77
+ flags?: string | undefined;
78
+ }): string;
79
+ readFile(path: string, opts?: {
80
+ flags?: string | undefined;
81
+ }): Uint8Array;
82
+ unlink: (path: string) => void;
83
+ quit: () => void;
96
84
  };
97
- type SDKOptions = {
98
- /** 导出视频时,是否开启转码日志 */
99
- loggerInExportVideoTranscoding?: boolean;
85
+ type Pointer = number;
86
+ type Img2WebPCore = {
87
+ FS: FS;
88
+ run: (...args: string[]) => number;
89
+ cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
90
+ _malloc: (size: number) => Pointer;
91
+ writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
92
+ setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
100
93
  };
101
- /**
102
- * @description SDK入参
103
- */
104
- type SDKInputParam = {
105
- /**
106
- * @description JSON地址
107
- */
108
- scene: string | spec.JSONScene;
109
- /**
110
- * @description 视图参数
111
- */
112
- viewParams: ViewParam[];
94
+ type ExportMediaInitOptions = {
113
95
  /**
114
- * @description 页面属性
96
+ * 导出类型
115
97
  */
116
- options: PageOptions;
117
- };
118
- /**
119
- * @description 页面属性
120
- */
121
- type PageOptions = {
98
+ mediaType: MediaType;
122
99
  /**
123
- * @description 同步模式开关
100
+ * 额外画布,导出透明视频时使用
124
101
  */
125
- asyncMode: boolean;
102
+ extraCanvas?: HTMLCanvasElement | null;
126
103
  /**
127
- * @description 安全区展示开关
104
+ * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
105
+ * 供开发调试使用
128
106
  */
129
- safeAreaPreview: boolean;
107
+ loggerInTranscoding?: boolean;
130
108
  /**
131
- * @description 吸附开关
109
+ * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
132
110
  */
133
- adsorption: boolean;
111
+ multiThreading?: boolean;
134
112
  };
135
- /**
136
- * @description 页面数据
137
- */
138
- type PageData = {
113
+ type ExportMediaItemOptions = {
139
114
  /**
140
- * @description 基础场景数据
115
+ * 尺寸
141
116
  */
142
- scene: spec.JSONScene;
117
+ size: [number, number];
143
118
  /**
144
- * @description 页面属性
119
+ * 动效资源
145
120
  */
146
- property: PageProperty;
121
+ scene: spec.JSONScene;
147
122
  /**
148
- * @description 视图属性
123
+ * 视频时长,目前仅在导出 MP4 / AlphaMaskVideo 时有效,默认取动效资源时长
149
124
  */
150
- viewProperties: ViewProperty[];
125
+ time?: number;
151
126
  /**
152
- * @description 活跃数据
127
+ * 是否生成音轨,默认 false,仅在导出 MP4 时有效
153
128
  */
154
- activeData: ActiveData;
129
+ audioEnable?: boolean;
155
130
  /**
156
- * @description 元素数据
131
+ * 帧率, 默认 30
157
132
  */
158
- items: ViewItem[];
133
+ fps?: number;
159
134
  /**
160
- * @description 视图当前时间
135
+ * 是否循环,默认 true
161
136
  */
162
- time: number;
137
+ loop?: boolean;
163
138
  /**
164
- * @description 是否处于播放态
139
+ * 视频背景颜色,默认 #000000
165
140
  */
166
- playing: boolean;
141
+ backgroundColor?: string;
167
142
  };
143
+
168
144
  /**
169
- * @description 页面配置
145
+ * @description SDK功能配置
170
146
  */
171
- type PageConfig$1 = {
147
+ type SDKConfig = {
172
148
  /**
173
- * @description 出血区域展示开关
149
+ * @description 页面功能配置
174
150
  */
175
- safeAreaPreview: boolean;
151
+ pageConfig: PageConfig$1;
176
152
  /**
177
- * @description 缩放值
153
+ * @description 截图功能配置
178
154
  */
179
- zoom: number;
155
+ screenShotConfig: ScreenShotConfig;
180
156
  /**
181
- * @description 吸附开关
157
+ * @description 导出视频功能配置
182
158
  */
183
- adsorption: boolean;
159
+ exportVideoConfig: VideoExportConfig;
184
160
  /**
185
- * @description 同步开关
161
+ * @description 尺寸自适应功能开关
186
162
  */
187
- asyncMode: boolean;
163
+ sizeAdaptConfig: SizeAdaptConfig;
164
+ /**
165
+ * @description 辅助面板功能配置
166
+ */
167
+ gestureHandlerConfig: {
168
+ enabled: boolean;
169
+ adsorptionGizmoEnabled: boolean;
170
+ adsorptionGizmoConfig: AdsorptionGizmoConfig;
171
+ controlGizmoEnabled: boolean;
172
+ controlGizmoConfig: ControlGizmoConfig;
173
+ preferenceGizmoEnabled: boolean;
174
+ preferenceGizmoConfig: PreferenceGizmoConfig;
175
+ selectorGizmoEnabled: boolean;
176
+ selectorGizmoConfig: SelectorGizmoConfig;
177
+ transformGizmoEnabled: boolean;
178
+ transformGizmoConfig: TransformGizmoConfig;
179
+ };
188
180
  };
189
181
  /**
190
- * @description 页面属性
182
+ * @description 页面功能配置
191
183
  */
192
- type PageProperty = {
184
+ type PageConfig$1 = {
193
185
  /**
194
- * @description 出血区域展示开关
186
+ * @description 同步修改功能开关
195
187
  */
196
- safeAreaPreview: boolean;
188
+ asncMode: boolean;
197
189
  /**
198
- * @description 缩放值
190
+ * @description 静态预览【视图只提供播放预览功能】功能开关
199
191
  */
200
- zoom: number;
192
+ staticPreview: boolean;
201
193
  /**
202
- * @description 偏移值
194
+ * @description 静态预览视图名称
203
195
  */
204
- translation: [number, number];
196
+ staticPreviewName: string;
205
197
  /**
206
- * @description 吸附开关
198
+ * @description 需过滤的元素名称
207
199
  */
208
- adsorption: boolean;
200
+ filterItemNames: string[];
209
201
  /**
210
- * @description 同步开关
202
+ * @description 成组操作元素显隐
211
203
  */
212
- asyncMode: boolean;
204
+ groupVisible: boolean;
213
205
  };
214
206
  /**
215
- * @description 视图创建参数
207
+ * @description 视频导出功能配置
216
208
  */
217
- type ViewParam = {
209
+ type VideoExportConfig = {
210
+ enabled: boolean;
211
+ } & ExportMediaInitOptions;
212
+ /**
213
+ * @description 截图功能配置
214
+ */
215
+ type ScreenShotConfig = {
216
+ enabled: boolean;
217
+ };
218
+ /**
219
+ * @description 尺寸自适应功能配置
220
+ */
221
+ type SizeAdaptConfig = {
222
+ enabled: boolean;
223
+ };
224
+ /**
225
+ * @description 对齐吸附功能参数
226
+ */
227
+ type AdsorptionGizmoConfig = {
218
228
  /**
219
- * @description 页面尺寸
220
- */
221
- size: [number, number];
229
+ * @description 对齐吸附线宽
230
+ */
231
+ lineWidth: number;
222
232
  /**
223
- * @description 出血区参数
233
+ * @description 对齐线颜色
224
234
  */
225
- safeArea?: [number, number, number, number];
235
+ lineColor: number;
226
236
  /**
227
- * @description 自定义出血区 - 用于展示
237
+ * @description 对齐吸附距离
228
238
  */
229
- previewSafeAreas?: PreviewSafeAreaParam[];
239
+ distance: number;
240
+ };
241
+ /**
242
+ * @description 视图控制功能参数
243
+ */
244
+ type ControlGizmoConfig = {
230
245
  /**
231
- * @description 导出参数
246
+ * @description 缩放步长
232
247
  */
233
- export: ExportParam;
248
+ zoomStep: number;
234
249
  };
235
250
  /**
236
- * @description 导出参数
251
+ * @description 视口展示功能参数
237
252
  */
238
- type ExportParam = {
253
+ type PreferenceGizmoConfig = {
239
254
  /**
240
- * @description 导出视频时长
255
+ * @description 视口窗包围盒颜色
256
+ */
257
+ boxColor: number;
258
+ /**
259
+ * @description 视口窗包围盒宽度
241
260
  */
242
- time?: number;
261
+ boxWidth: number;
243
262
  /**
244
- * @description 导出大小上限 - 单位kb
263
+ * @description 视口区域外遮罩颜色
245
264
  */
246
- fileSizeLimit: number;
265
+ markColor: number;
247
266
  /**
248
- * @description 是否开启音轨
267
+ * @description 视口区域外遮罩透明度
249
268
  */
250
- audioEnable: boolean;
269
+ markAlpha: number;
251
270
  /**
252
- * @description 视频fps - 默认 30
271
+ * @description 出血区预览开关
253
272
  */
254
- fps?: number;
273
+ safeAreaEnabled: boolean;
255
274
  /**
256
- * @description 导出视频类型 - 预留参数
275
+ * @description 出血区颜色
257
276
  */
258
- type?: string;
277
+ safeAreaBoxColor: number;
259
278
  /**
260
- * @description 视频名称
279
+ * @description 出血区透明度
261
280
  */
262
- name?: string;
281
+ safeAreaBoxAlpha: number;
263
282
  };
264
283
  /**
265
- * @description 视图属性
284
+ * @description 选择功能参数
266
285
  */
267
- type ViewProperty = {
286
+ type SelectorGizmoConfig = {
268
287
  /**
269
- * @description 视图ID
288
+ * @description 预选框线宽
270
289
  */
271
- id: number;
290
+ preSelectedWidth: number;
272
291
  /**
273
- * @description 视图宽高
292
+ * @description 预选框颜色
274
293
  */
275
- size: [number, number];
294
+ preSelectedColor: number;
276
295
  /**
277
- * @description 出血区数据
296
+ * @description 框选区域颜色
278
297
  */
279
- safeArea: [number, number, number, number];
298
+ regionBoxColor: number;
280
299
  /**
281
- * @description 自定义出血区数据
300
+ * @description 框选区域透明度
282
301
  */
283
- previewSafeAreas: PreviewSafeAreaParam[];
302
+ regionBoxAlpha: number;
284
303
  /**
285
- * @description 视图场景数据
304
+ * @description 框选区域包围框颜色
286
305
  */
287
- scene: spec.JSONScene;
306
+ regionWireframeColor: number;
288
307
  /**
289
- * @description 导出参数
308
+ * @description 框选区域包围框透明度
290
309
  */
291
- export: ExportParam;
310
+ regionWireframeAlpha: number;
292
311
  /**
293
- * @description 忽略交互 - 仅供展示
312
+ * @description 框选区域包围框宽度
294
313
  */
295
- ignoreInteraction: boolean;
314
+ regionWireframeWidth: number;
296
315
  };
297
316
  /**
298
- * @description 自定义出血区数据
317
+ * @description 变换功能参数
299
318
  */
300
- type PreviewSafeAreaParam = {
319
+ type TransformGizmoConfig = {
301
320
  /**
302
- * @description 出血区包围盒 [left top width height]
321
+ * @description 变换交互框颜色
303
322
  */
304
- box: [number, number, number, number];
323
+ wireframeColor: number;
305
324
  /**
306
- * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
325
+ * @description 变换交互框透明度
307
326
  */
308
- color?: [number, number, number, number];
309
- };
310
- /**
311
- * @description 页面活跃数据
312
- */
313
- type ActiveData = {
327
+ wireframeAlpha: number;
314
328
  /**
315
- * @description 视图ID
329
+ * @description 变换交互框宽度
316
330
  */
317
- view?: number;
331
+ wireframeWidth: number;
318
332
  /**
319
- * @description 选中元素
333
+ * @description 变换交互框角点填充色
320
334
  */
321
- selectedItems: string[];
335
+ cornerFillColor: number;
322
336
  /**
323
- * @description 预选中元素
337
+ * @description 变换交互框角点线框色
324
338
  */
325
- preSelectedItem?: string;
339
+ cornerLineColor: number;
340
+ /**
341
+ * @description 变换交互框角点线框宽度
342
+ */
343
+ cornerLineWidth: number;
344
+ /**
345
+ * @description 变换交互框角点线框透明度
346
+ */
347
+ cornerLineAlpha: number;
348
+ /**
349
+ * @description 交互框缩放圆半径
350
+ */
351
+ scaleCircleSize: number;
352
+ /**
353
+ * @description 交互框旋转圆半径
354
+ */
355
+ rotationCircleSize: number;
326
356
  };
327
- /**
328
- * @description 视图元素
329
- */
330
- type ViewItem = {
357
+
358
+ type SDKEvents = {
359
+ 'selectedItemChange': [id: string[]];
360
+ 'preSelectedItemChange': [id: string | undefined];
361
+ 'selectedViewChange': [id: number];
362
+ 'pageDataChange': [pageData: PageData];
363
+ 'zoomChange': [zoom: number];
364
+ 'progress': [{
365
+ duration: number;
366
+ time: number;
367
+ end: boolean;
368
+ paused: boolean;
369
+ }];
370
+ 'itemPropertyChange': [{
371
+ id: string;
372
+ property: string;
373
+ }];
374
+ 'exportProgress': [progress?: number];
375
+ 'exportDone': [item: ExportMediaItemOptions | undefined, success: boolean, buffer?: FileBuffer];
376
+ 'exportComplete': [success: boolean];
377
+ 'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
378
+ };
379
+ declare class SDK {
380
+ static config: SDKConfig;
381
+ private _eventEmitter;
382
+ private _pageData;
383
+ private _screenShot;
384
+ private _exporter?;
385
+ private _pageDataUtils;
386
+ private _sizeAdapt;
387
+ private _gestureHandler;
388
+ private disposables;
389
+ private _isSwitchScene;
390
+ player: Player;
391
+ private _playerContainer;
392
+ constructor(container: HTMLElement);
393
+ get pageData(): PageData | undefined;
394
+ get exportStatus(): string | undefined;
395
+ private get exportOptions();
396
+ dispose(): void;
397
+ on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
398
+ private getInitParam;
399
+ private initExporter;
400
+ private initSDK;
401
+ run(param: SDKInputParam): Promise<void>;
402
+ getPageData(): PageData;
403
+ getActiveItems(): string[];
404
+ setPreSelectedItem(id: string): void;
405
+ getPreSelectedItem(): string;
406
+ setSelectedItems(itemIds: string[]): void;
331
407
  /**
332
- * @description 元素ID
408
+ * @description 获取目标元素的所有属性
409
+ * @param param 元素ID、类型
410
+ * @returns 元素属性
333
411
  */
334
- id: string;
412
+ getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
335
413
  /**
336
- * @description 元素名称
414
+ * @description 获取目标元素的指定属性
415
+ * @param param 元素ID、类型、属性名
416
+ * @returns 元素属性值
337
417
  */
338
- name: string;
418
+ getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
419
+ setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
420
+ generateScreenShot(id: number, size?: [number, number], tick?: number): Promise<string | undefined>;
339
421
  /**
340
- * @description 元素父节点ID
422
+ * @description 切换场景
423
+ * @param index 场景索引
341
424
  */
342
- parentId?: string;
425
+ switchScene(index: number): Promise<void>;
343
426
  /**
344
- * @description 子元素
427
+ * @description 获取页面的 safeAreaPreview、zoom、adsorption 值
428
+ * @returns 页面的 safeAreaPreview、zoom、adsorption 值
345
429
  */
346
- children: string[];
430
+ getConfig(): PageConfig;
347
431
  /**
348
- * @description 元素生命周期
432
+ * 设置页面的 safeAreaPreview、zoom、adsorption 值
433
+ * @param pageProperty 设置
349
434
  */
350
- duration: number;
435
+ setConfig(pageConfig: PageConfig): void;
351
436
  /**
352
- * @description 元素生命周期延时
437
+ * @description 设置播放进度
438
+ * @param progress 播放进度 0-100
353
439
  */
354
- delay: number;
440
+ setPlayProgress(progress: number): Promise<void>;
441
+ getViewItems(): ViewItem[];
442
+ setPlayState(playState: 'play' | 'pause'): Promise<void>;
355
443
  /**
356
- * @description 元素结束行为
444
+ * @description 获取场景预览图
445
+ * @returns 视图预览图
357
446
  */
358
- endBehavior: spec.EndBehavior;
359
- } & ViewItemTypedProperty;
360
-
361
- declare const MEDIA_TYPE: {
362
- readonly APNG: "APNG";
363
- readonly MP4: "MP4";
364
- readonly WebM: "WebM";
365
- readonly Images: "Images";
366
- readonly WebP: "WebP";
367
- readonly GIF: "GIF";
368
- readonly AlphaMaskVideo: "AlphaMaskVideo";
369
- };
370
-
371
- declare global {
372
- interface Window {
373
- /**
374
- * @description 创建 WebP Core 实例
375
- */
376
- createWebPCore: (config: any) => Promise<Img2WebPCore>;
377
- }
378
- }
379
- type MediaType = typeof MEDIA_TYPE[keyof typeof MEDIA_TYPE];
380
- type FS = {
381
- writeFile: (path: string, data: Uint8Array | string) => void;
382
- readFile(path: string, opts: {
383
- encoding: 'binary';
384
- flags?: string | undefined;
385
- }): Uint8Array;
386
- readFile(path: string, opts: {
387
- encoding: 'utf8';
388
- flags?: string | undefined;
389
- }): string;
390
- readFile(path: string, opts?: {
391
- flags?: string | undefined;
392
- }): Uint8Array;
393
- unlink: (path: string) => void;
394
- quit: () => void;
395
- };
396
- type Pointer = number;
397
- type Img2WebPCore = {
398
- FS: FS;
399
- run: (...args: string[]) => number;
400
- cwrap: (ident: string, returnType: string, argTypes: string[]) => ((argc: number, argv: Pointer) => number);
401
- _malloc: (size: number) => Pointer;
402
- writeAsciiToMemory: (str: string, buffer: number, dontAddNull?: boolean) => void;
403
- setValue: (ptr: number, value: any, type: string, noSafe?: boolean) => void;
404
- };
405
- type ExportMediaInitOptions = {
447
+ getViewThumbnail(): {
448
+ id: number;
449
+ thumbnail: Promise<string | undefined>;
450
+ }[];
406
451
  /**
407
- * 导出类型
452
+ * @description 获取视图JSON产物
453
+ * @returns 当前所有视图JSON产物
408
454
  */
409
- mediaType: MediaType;
455
+ getViewScene(): {
456
+ id: number;
457
+ thumbnail: spec.JSONScene;
458
+ }[];
459
+ private destroyCompositions;
410
460
  /**
411
- * 额外画布,导出透明视频时使用
461
+ * @description 导出,支持导出媒体或其他,如MP4,未来支持 JSON 等;
462
+ */
463
+ onExport(): void;
464
+ /**
465
+ * @description 取消导出
466
+ */
467
+ cancelExport(): void;
468
+ loadPageData(data: PageData): Promise<void>;
469
+ runByPageData(data: PageData): Promise<void>;
470
+ reloadPageDataByScene(scene: string | spec.JSONScene): Promise<void>;
471
+ addViewParams(viewParams: ViewParam[]): Promise<void>;
472
+ deleteViewParams(ids: number[]): Promise<void>;
473
+ setExportParam(exportParam: ExportParam, id?: number): void;
474
+ /**
475
+ * @description 设置视图缩放
476
+ * @param zoom 缩放值
477
+ */
478
+ setPageZoom(zoom: number): void;
479
+ /**
480
+ * @description 设置静态预览功能开关
481
+ * @param enabled 功能开关
482
+ */
483
+ setStaticPreviewEnabled(enabled: boolean): void;
484
+ /**
485
+ * @description 设置静态预览视图名称
486
+ * @param name 视图名称
412
487
  */
413
- extraCanvas?: HTMLCanvasElement | null;
488
+ setStaticPreviewName(name: string): void;
414
489
  /**
415
- * 是否打印转码过程中的日志,仅在导出 MP4/AlphaMaskVideo 时有效, 默认 false
416
- * 供开发调试使用
490
+ * @description 设置同步修改功能开关
491
+ * @param enabled 功能开关
417
492
  */
418
- loggerInTranscoding?: boolean;
493
+ setAsyncEnabled(enabled: boolean): void;
419
494
  /**
420
- * ffmpeg 转码是否开启多线程,默认 false,确保环境支持 SharedArrayBuffer
495
+ * @description 设置 成组显影 开关
421
496
  */
422
- multiThreading?: boolean;
423
- };
424
-
425
- /**
426
- * @description SDK功能配置
427
- */
428
- type SDKConfig = {
497
+ setGroupVisibleEnabled(enabled: boolean): void;
429
498
  /**
430
- * @description 页面功能配置
499
+ * @description 新增过滤元素名称
500
+ * @param itemNames 过滤元素名称
431
501
  */
432
- pageConfig: PageConfig;
502
+ addFilterItemNames(itemNames: string[] | string): void;
433
503
  /**
434
- * @description 截图功能配置
504
+ * @description 设置预览辅助层颜色
505
+ * @param color 色值
435
506
  */
436
- screenShotConfig: ScreenShotConfig;
507
+ setPreferenceBackgroundColor(color: [number, number, number, number]): void;
437
508
  /**
438
- * @description 导出视频功能配置
509
+ * @description 设置出血区颜色
510
+ * @param color 色值
439
511
  */
440
- exportVideoConfig: VideoExportConfig;
512
+ setSafeAreaColor(color: [number, number, number, number]): void;
441
513
  /**
442
- * @description 尺寸自适应功能开关
514
+ * @description 设置 尺寸自适应拓展 功能开关
515
+ * @param enabled 功能开关
443
516
  */
444
- sizeAdaptConfig: SizeAdaptConfig;
517
+ setSizeAdaptEnabled(enabled: boolean): void;
445
518
  /**
446
- * @description 辅助面板功能配置
519
+ * @description 设置 截图 功能开关
520
+ * @param enabled 功能开关
447
521
  */
448
- gestureHandlerConfig: {
449
- enabled: boolean;
450
- adsorptionGizmoEnabled: boolean;
451
- adsorptionGizmoConfig: AdsorptionGizmoConfig;
452
- controlGizmoEnabled: boolean;
453
- controlGizmoConfig: ControlGizmoConfig;
454
- preferenceGizmoEnabled: boolean;
455
- preferenceGizmoConfig: PreferenceGizmoConfig;
456
- selectorGizmoEnabled: boolean;
457
- selectorGizmoConfig: SelectorGizmoConfig;
458
- transformGizmoEnabled: boolean;
459
- transformGizmoConfig: TransformGizmoConfig;
460
- };
461
- };
462
- /**
463
- * @description 页面功能配置
464
- */
465
- type PageConfig = {
522
+ setScreenShotEnabled(enabled: boolean): void;
466
523
  /**
467
- * @description 同步修改功能开关
524
+ * @description 设置 导出 功能开关
525
+ * @param enabled
468
526
  */
469
- asncMode: boolean;
527
+ setExportVideoEnabled(enabled: boolean): void;
470
528
  /**
471
- * @description 静态预览【视图只提供播放预览功能】功能开关
529
+ * @description 设置预选框参数
530
+ * @param preSelectedColor 预选框颜色
531
+ * @param preSelectedWidth 预选框线框宽度
472
532
  */
473
- staticPreview: boolean;
533
+ setSelectorGizmoPreSelectConfig(preSelectedColor?: number, preSelectedWidth?: number): void;
474
534
  /**
475
- * @description 静态预览视图名称
535
+ * @description 设置 变换控制器 交互框参数
536
+ * @param config 参数
476
537
  */
477
- staticPreviewName: string;
538
+ setTranformGizmoWireframeConfig(config: {
539
+ wireframeColor?: number;
540
+ wireframeAlpha?: number;
541
+ wireframeWidth?: number;
542
+ }): void;
478
543
  /**
479
- * @description 需过滤的元素名称
544
+ * @description 获取 SDK 配置参数
545
+ * @returns SDK 配置参数
480
546
  */
481
- filterItemNames: string[];
547
+ getSDKConfig(): SDKConfig;
482
548
  /**
483
- * @description 成组操作元素显隐
549
+ * @description 设置 SDK 配置参数
550
+ * @param config SDK 配置参数
484
551
  */
485
- groupVisible: boolean;
552
+ setSDKConfig(config: SDKConfig): void;
553
+ }
554
+
555
+ type SizeAdaptDirection = 'x' | 'y';
556
+
557
+ type BaseFormProperty = {
558
+ position: [number, number, number];
559
+ rotation: [number, number, number];
560
+ size: [number, number];
561
+ visible: boolean;
562
+ keyPropertyEditing: boolean;
486
563
  };
487
- /**
488
- * @description 视频导出功能配置
489
- */
490
- type VideoExportConfig = {
491
- enabled: boolean;
492
- } & ExportMediaInitOptions;
493
- /**
494
- * @description 截图功能配置
495
- */
496
- type ScreenShotConfig = {
497
- enabled: boolean;
564
+ type SpriteFormProperty = BaseFormProperty & {
565
+ image: string;
566
+ };
567
+ type TextFormProperty = BaseFormProperty & {
568
+ font: string;
569
+ color: [number, number, number, number];
570
+ weight: spec.TextWeight;
571
+ text: string;
572
+ alignment: spec.TextAlignment;
498
573
  };
499
574
  /**
500
- * @description 尺寸自适应功能配置
575
+ * @description 页面表单类型和属性引用
501
576
  */
502
- type SizeAdaptConfig = {
503
- enabled: boolean;
577
+ type PageFormTypeAndPropertyReference = {
578
+ [spec.ItemType.base]: BaseFormProperty;
579
+ [spec.ItemType.sprite]: SpriteFormProperty;
580
+ [spec.ItemType.particle]: BaseFormProperty;
581
+ [spec.ItemType.null]: BaseFormProperty;
582
+ [spec.ItemType.interact]: BaseFormProperty;
583
+ [spec.ItemType.plugin]: BaseFormProperty;
584
+ [spec.ItemType.camera]: BaseFormProperty;
585
+ [spec.ItemType.composition]: BaseFormProperty;
586
+ [spec.ItemType.spine]: BaseFormProperty;
587
+ [spec.ItemType.mesh]: BaseFormProperty;
588
+ [spec.ItemType.tree]: BaseFormProperty;
589
+ [spec.ItemType.text]: TextFormProperty;
590
+ [spec.ItemType.light]: BaseFormProperty;
591
+ [spec.ItemType.skybox]: BaseFormProperty;
592
+ [spec.ItemType.effect]: BaseFormProperty;
593
+ [spec.ItemType.shape]: BaseFormProperty;
594
+ [spec.ItemType.postProcessVolume]: BaseFormProperty;
595
+ [spec.ItemType.node]: BaseFormProperty;
596
+ [spec.ItemType.video]: BaseFormProperty;
597
+ [spec.ItemType.audio]: BaseFormProperty;
598
+ [spec.ItemType.richtext]: TextFormProperty;
599
+ };
600
+ type SpecificPageFormProps<T extends keyof PageFormTypeAndPropertyReference> = {
601
+ type: T;
602
+ property: PageFormTypeAndPropertyReference[T];
603
+ onPropertyValueChange: <N extends keyof PageFormTypeAndPropertyReference[T]>(propertyName: N, propertyValue: PageFormTypeAndPropertyReference[T][N]) => void;
604
+ };
605
+ type SDKOptions = {
606
+ /** 导出视频时,是否开启转码日志 */
607
+ loggerInExportVideoTranscoding?: boolean;
504
608
  };
505
609
  /**
506
- * @description 对齐吸附功能参数
610
+ * @description SDK入参
507
611
  */
508
- type AdsorptionGizmoConfig = {
612
+ type SDKInputParam = {
509
613
  /**
510
- * @description 对齐吸附线宽
511
- */
512
- lineWidth: number;
614
+ * @description JSON地址
615
+ */
616
+ scene: string | spec.JSONScene;
513
617
  /**
514
- * @description 对齐线颜色
618
+ * @description 视图参数
515
619
  */
516
- lineColor: number;
620
+ viewParams: ViewParam[];
517
621
  /**
518
- * @description 对齐吸附距离
622
+ * @description 页面属性
519
623
  */
520
- distance: number;
624
+ options: PageOptions;
521
625
  };
522
626
  /**
523
- * @description 视图控制功能参数
627
+ * @description 页面属性
524
628
  */
525
- type ControlGizmoConfig = {
629
+ type PageOptions = {
526
630
  /**
527
- * @description 缩放步长
631
+ * @description 同步模式开关
528
632
  */
529
- zoomStep: number;
633
+ asyncMode: boolean;
634
+ /**
635
+ * @description 安全区展示开关
636
+ */
637
+ safeAreaPreview: boolean;
638
+ /**
639
+ * @description 吸附开关
640
+ */
641
+ adsorption: boolean;
530
642
  };
531
643
  /**
532
- * @description 视口展示功能参数
644
+ * @description 页面数据
533
645
  */
534
- type PreferenceGizmoConfig = {
646
+ type PageData = {
535
647
  /**
536
- * @description 视口窗包围盒颜色
537
- */
538
- boxColor: number;
648
+ * @description 基础场景数据
649
+ */
650
+ scene: spec.JSONScene;
539
651
  /**
540
- * @description 视口窗包围盒宽度
652
+ * @description 页面属性
541
653
  */
542
- boxWidth: number;
654
+ property: PageProperty;
543
655
  /**
544
- * @description 视口区域外遮罩颜色
656
+ * @description 视图属性
545
657
  */
546
- markColor: number;
658
+ viewProperties: ViewProperty[];
547
659
  /**
548
- * @description 视口区域外遮罩透明度
660
+ * @description 活跃数据
549
661
  */
550
- markAlpha: number;
662
+ activeData: ActiveData;
551
663
  /**
552
- * @description 出血区预览开关
664
+ * @description 元素数据
553
665
  */
554
- safeAreaEnabled: boolean;
666
+ items: ViewItem[];
555
667
  /**
556
- * @description 出血区颜色
668
+ * @description 视图当前时间
557
669
  */
558
- safeAreaBoxColor: number;
670
+ time: number;
559
671
  /**
560
- * @description 出血区透明度
672
+ * @description 是否处于播放态
561
673
  */
562
- safeAreaBoxAlpha: number;
674
+ playing: boolean;
563
675
  };
564
676
  /**
565
- * @description 选择功能参数
677
+ * @description 页面配置
566
678
  */
567
- type SelectorGizmoConfig = {
568
- /**
569
- * @description 预选框线宽
570
- */
571
- preSelectedWidth: number;
572
- /**
573
- * @description 预选框颜色
574
- */
575
- preSelectedColor: number;
576
- /**
577
- * @description 框选区域颜色
578
- */
579
- regionBoxColor: number;
679
+ type PageConfig = {
580
680
  /**
581
- * @description 框选区域透明度
681
+ * @description 出血区域展示开关
582
682
  */
583
- regionBoxAlpha: number;
683
+ safeAreaPreview: boolean;
584
684
  /**
585
- * @description 框选区域包围框颜色
685
+ * @description 缩放值
586
686
  */
587
- regionWireframeColor: number;
687
+ zoom: number;
588
688
  /**
589
- * @description 框选区域包围框透明度
689
+ * @description 吸附开关
590
690
  */
591
- regionWireframeAlpha: number;
691
+ adsorption: boolean;
592
692
  /**
593
- * @description 框选区域包围框宽度
693
+ * @description 同步开关
594
694
  */
595
- regionWireframeWidth: number;
695
+ asyncMode: boolean;
596
696
  };
597
697
  /**
598
- * @description 变换功能参数
698
+ * @description 页面属性
599
699
  */
600
- type TransformGizmoConfig = {
700
+ type PageProperty = {
601
701
  /**
602
- * @description 变换交互框颜色
702
+ * @description 出血区域展示开关
603
703
  */
604
- wireframeColor: number;
704
+ safeAreaPreview: boolean;
605
705
  /**
606
- * @description 变换交互框透明度
706
+ * @description 缩放值
607
707
  */
608
- wireframeAlpha: number;
708
+ zoom: number;
609
709
  /**
610
- * @description 变换交互框宽度
710
+ * @description 偏移值
611
711
  */
612
- wireframeWidth: number;
712
+ translation: [number, number];
613
713
  /**
614
- * @description 变换交互框角点填充色
714
+ * @description 吸附开关
615
715
  */
616
- cornerFillColor: number;
716
+ adsorption: boolean;
617
717
  /**
618
- * @description 变换交互框角点线框色
718
+ * @description 同步开关
619
719
  */
620
- cornerLineColor: number;
720
+ asyncMode: boolean;
721
+ };
722
+ /**
723
+ * @description 视图创建参数
724
+ */
725
+ type ViewParam = {
621
726
  /**
622
- * @description 变换交互框角点线框宽度
727
+ * @description 页面尺寸
623
728
  */
624
- cornerLineWidth: number;
729
+ size?: [number, number];
625
730
  /**
626
- * @description 变换交互框角点线框透明度
731
+ * @description 出血区参数
627
732
  */
628
- cornerLineAlpha: number;
733
+ safeArea?: [number, number, number, number];
629
734
  /**
630
- * @description 交互框缩放圆半径
735
+ * @description 自适应方向 - 默认根据视图宽高决定
631
736
  */
632
- scaleCircleSize: number;
737
+ adaptionDirection?: SizeAdaptDirection;
633
738
  /**
634
- * @description 交互框旋转圆半径
739
+ * @description 自定义出血区 - 用于展示
635
740
  */
636
- rotationCircleSize: number;
637
- };
638
-
639
- type SDKEvents = {
640
- 'selectedItemChange': [id: string[]];
641
- 'preSelectedItemChange': [id: string | undefined];
642
- 'selectedViewChange': [id: number];
643
- 'pageDataChange': [pageData: PageData];
644
- 'zoomChange': [zoom: number];
645
- 'progress': [{
646
- duration: number;
647
- time: number;
648
- end: boolean;
649
- paused: boolean;
650
- }];
651
- 'itemPropertyChange': [{
652
- id: string;
653
- property: string;
654
- }];
655
- 'exportProgress': [progress?: number];
656
- 'exportComplete': [success: boolean];
657
- 'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
741
+ previewSafeAreas?: PreviewSafeAreaParam[];
742
+ /**
743
+ * @description 导出参数
744
+ */
745
+ export: ExportParam;
658
746
  };
659
- declare class SDK {
660
- static config: SDKConfig;
661
- private _eventEmitter;
662
- private _pageData;
663
- private _screenShot;
664
- private _exporter?;
665
- private _pageDataUtils;
666
- private _sizeAdapt;
667
- private _gestureHandler;
668
- private disposables;
669
- private _isSwitchScene;
670
- player: Player;
671
- private _playerContainer;
672
- constructor(container: HTMLElement);
673
- get pageData(): PageData | undefined;
674
- get exportStatus(): string | undefined;
675
- private get exportOptions();
676
- dispose(): void;
677
- on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportComplete" | "sdkConfigChange">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
678
- private getInitParam;
679
- private initExporter;
680
- private initSDK;
681
- run(param: SDKInputParam): Promise<void>;
682
- getPageData(): PageData;
683
- getActiveItems(): string[];
684
- setPreSelectedItem(id: string): void;
685
- getPreSelectedItem(): string;
686
- setSelectedItems(itemIds: string[]): void;
747
+ /**
748
+ * @description 导出参数
749
+ */
750
+ type ExportParam = {
687
751
  /**
688
- * @description 获取目标元素的所有属性
689
- * @param param 元素ID、类型
690
- * @returns 元素属性
752
+ * @description 导出视频时长
691
753
  */
692
- getItemProperty<T extends keyof PageFormTypeAndPropertyReference>(param: GetItemPropertyParam<T>): GetItemPropertyResult<T> | undefined;
754
+ time?: number;
693
755
  /**
694
- * @description 获取目标元素的指定属性
695
- * @param param 元素ID、类型、属性名
696
- * @returns 元素属性值
756
+ * @description 导出大小上限 - 单位kb
697
757
  */
698
- getItemPropertyValue<T extends keyof PageFormTypeAndPropertyReference, N extends keyof PageFormTypeAndPropertyReference[T]>(param: GetItemPropertyValueParam<T, N>): GetItemPropertyValueResult<T, N> | undefined;
699
- setItemPropertyValue(param: SetItemPropertyValueParam): Promise<void>;
700
- generateScreenShot(id: number, size?: [number, number], tick?: number): Promise<string | undefined>;
758
+ fileSizeLimit: number;
701
759
  /**
702
- * @description 切换场景
703
- * @param index 场景索引
760
+ * @description 是否开启音轨
704
761
  */
705
- switchScene(index: number): Promise<void>;
762
+ audioEnable: boolean;
706
763
  /**
707
- * @description 获取页面的 safeAreaPreview、zoom、adsorption
708
- * @returns 页面的 safeAreaPreview、zoom、adsorption 值
764
+ * @description 视频fps - 默认 30
709
765
  */
710
- getConfig(): PageConfig$1;
766
+ fps?: number;
711
767
  /**
712
- * 设置页面的 safeAreaPreview、zoom、adsorption
713
- * @param pageProperty 设置
768
+ * @description 导出视频类型 - 预留参数
714
769
  */
715
- setConfig(pageConfig: PageConfig$1): void;
770
+ type?: string;
716
771
  /**
717
- * @description 设置播放进度
718
- * @param progress 播放进度 0-100
772
+ * @description 视频名称
719
773
  */
720
- setPlayProgress(progress: number): Promise<void>;
721
- getViewItems(): ViewItem[];
722
- setPlayState(playState: 'play' | 'pause'): Promise<void>;
774
+ name?: string;
775
+ };
776
+ /**
777
+ * @description 视图属性
778
+ */
779
+ type ViewProperty = {
723
780
  /**
724
- * @description 获取场景预览图
725
- * @returns 视图预览图
781
+ * @description 视图ID
726
782
  */
727
- getViewThumbnail(): {
728
- id: number;
729
- thumbnail: Promise<string | undefined>;
730
- }[];
731
- private destroyCompositions;
783
+ id: number;
732
784
  /**
733
- * @description 导出,支持导出媒体或其他,如MP4,未来支持 JSON 等;
785
+ * @description 视图宽高
734
786
  */
735
- onExport(): void;
787
+ size: [number, number];
736
788
  /**
737
- * @description 取消导出
789
+ * @description 出血区数据
738
790
  */
739
- cancelExport(): void;
740
- loadPageData(data: PageData): Promise<void>;
741
- runByPageData(data: PageData): Promise<void>;
742
- reloadPageDataByScene(scene: string | spec.JSONScene): Promise<void>;
743
- addViewParams(viewParams: ViewParam[]): Promise<void>;
744
- deleteViewParams(ids: number[]): void;
745
- setExportParam(exportParam: ExportParam, id?: number): void;
791
+ safeArea: [number, number, number, number];
746
792
  /**
747
- * @description 设置视图缩放
748
- * @param zoom 缩放值
793
+ * @description 自定义出血区数据
749
794
  */
750
- setPageZoom(zoom: number): void;
795
+ previewSafeAreas: PreviewSafeAreaParam[];
751
796
  /**
752
- * @description 设置静态预览功能开关
753
- * @param enabled 功能开关
797
+ * @description 视图场景数据
754
798
  */
755
- setStaticPreviewEnabled(enabled: boolean): void;
799
+ scene: spec.JSONScene;
756
800
  /**
757
- * @description 设置静态预览视图名称
758
- * @param name 视图名称
801
+ * @description 导出参数
759
802
  */
760
- setStaticPreviewName(name: string): void;
803
+ export: ExportParam;
761
804
  /**
762
- * @description 设置同步修改功能开关
763
- * @param enabled 功能开关
805
+ * @description 忽略交互 - 仅供展示
764
806
  */
765
- setAsyncEnabled(enabled: boolean): void;
807
+ ignoreInteraction: boolean;
808
+ };
809
+ /**
810
+ * @description 自定义出血区数据
811
+ */
812
+ type PreviewSafeAreaParam = {
766
813
  /**
767
- * @description 设置 成组显影 开关
814
+ * @description 出血区包围盒 [left top width height]
768
815
  */
769
- setGroupVisibleEnabled(enabled: boolean): void;
816
+ box: [number, number, number, number];
770
817
  /**
771
- * @description 新增过滤元素名称
772
- * @param itemNames 过滤元素名称
818
+ * @description 出血区色块颜色 默认为 [255, 255, 255, 0.3]
773
819
  */
774
- addFilterItemNames(itemNames: string[] | string): void;
820
+ color?: [number, number, number, number];
821
+ };
822
+ /**
823
+ * @description 页面活跃数据
824
+ */
825
+ type ActiveData = {
775
826
  /**
776
- * @description 设置预览辅助层颜色
777
- * @param color 色值
827
+ * @description 视图ID
778
828
  */
779
- setPreferenceBackgroundColor(color: [number, number, number, number]): void;
829
+ view?: number;
780
830
  /**
781
- * @description 设置出血区颜色
782
- * @param color 色值
831
+ * @description 选中元素
783
832
  */
784
- setSafeAreaColor(color: [number, number, number, number]): void;
833
+ selectedItems: string[];
785
834
  /**
786
- * @description 设置 尺寸自适应拓展 功能开关
787
- * @param enabled 功能开关
835
+ * @description 预选中元素
788
836
  */
789
- setSizeAdaptEnabled(enabled: boolean): void;
837
+ preSelectedItem?: string;
838
+ };
839
+ /**
840
+ * @description 视图元素
841
+ */
842
+ type ViewItem = {
790
843
  /**
791
- * @description 设置 截图 功能开关
792
- * @param enabled 功能开关
844
+ * @description 元素ID
793
845
  */
794
- setScreenShotEnabled(enabled: boolean): void;
846
+ id: string;
795
847
  /**
796
- * @description 设置 导出 功能开关
797
- * @param enabled
848
+ * @description 元素名称
798
849
  */
799
- setExportVideoEnabled(enabled: boolean): void;
850
+ name: string;
800
851
  /**
801
- * @description 设置预选框参数
802
- * @param preSelectedColor 预选框颜色
803
- * @param preSelectedWidth 预选框线框宽度
852
+ * @description 元素父节点ID
804
853
  */
805
- setSelectorGizmoPreSelectConfig(preSelectedColor?: number, preSelectedWidth?: number): void;
854
+ parentId?: string;
806
855
  /**
807
- * @description 设置 变换控制器 交互框参数
808
- * @param config 参数
856
+ * @description 子元素
809
857
  */
810
- setTranformGizmoWireframeConfig(config: {
811
- wireframeColor?: number;
812
- wireframeAlpha?: number;
813
- wireframeWidth?: number;
814
- }): void;
858
+ children: string[];
815
859
  /**
816
- * @description 获取 SDK 配置参数
817
- * @returns SDK 配置参数
860
+ * @description 元素生命周期
818
861
  */
819
- getSDKConfig(): SDKConfig;
862
+ duration: number;
820
863
  /**
821
- * @description 设置 SDK 配置参数
822
- * @param config SDK 配置参数
864
+ * @description 元素生命周期延时
823
865
  */
824
- setSDKConfig(config: SDKConfig): void;
825
- }
866
+ delay: number;
867
+ /**
868
+ * @description 元素结束行为
869
+ */
870
+ endBehavior: spec.EndBehavior;
871
+ } & ViewItemTypedProperty;
826
872
 
827
873
  export { type ActiveData, type BaseFormProperty, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SpecificPageFormProps, type SpriteFormProperty, type TextFormProperty, type ViewItem, type ViewParam, type ViewProperty };