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

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