@vvfx/sdk 0.0.0-alpha.41 → 0.0.0-alpha.42

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,5 +1,5 @@
1
1
  import * as _galacean_effects from '@galacean/effects';
2
- import { spec, Player } from '@galacean/effects';
2
+ import { spec, math, Player } from '@galacean/effects';
3
3
  export { generateGUID, spec } from '@galacean/effects';
4
4
 
5
5
  type ViewItemTypedProperty = {
@@ -44,7 +44,282 @@ 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';
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): Vector2;
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
+
164
+ /**
165
+ * @class 二维包围盒
166
+ */
167
+ declare class Box2 {
168
+ /**
169
+ * @member {Vector2[]} corners 二维包围盒角点
170
+ */
171
+ corners: Vector2[];
172
+ min: Vector2;
173
+ max: Vector2;
174
+ /**
175
+ * 构造函数,传入值为空时表示空包围盒
176
+ * @param {Vector2} [min=new Vector2(Infinity, Infinity)] 最小点
177
+ * @param {Vector2} [max=new Vector2(-Infinity, -Infinity)] 最大点
178
+ */
179
+ constructor(min?: Vector2, max?: Vector2);
180
+ /**
181
+ * 通过最大最小点设置二维包围盒
182
+ * @param {Vector2} min 最小点
183
+ * @param {Vector2} max 最大点
184
+ * @returns {Box2} 二维包围盒
185
+ */
186
+ set(min: Vector2, max: Vector2): this;
187
+ /**
188
+ * 通过角点设置二维包围盒
189
+ * @param {Vector2[]} vecArray 二维空间点数组
190
+ * @returns {Box2} 二维包围盒
191
+ */
192
+ setFromVec2Array(vecArray: Vector2[]): this;
193
+ setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
194
+ /**
195
+ * 通过中心与大小设置二维包围盒
196
+ * @param {Vector2} center 二维中心点
197
+ * @param {Vector2} size 二维大小
198
+ * @returns {Box2} 二维包围盒
199
+ */
200
+ setFromCenterAndSize(center: Vector2, size: Vector2): this;
201
+ /**
202
+ * 克隆二维包围盒
203
+ * @returns {Box2} 克隆结果
204
+ */
205
+ clone(): Box2;
206
+ /**
207
+ * 复制二维包围盒
208
+ * @param {Box2} box 二维包围盒
209
+ * @returns {Box2} 复制结果
210
+ */
211
+ copyFrom(box: Box2): this;
212
+ /**
213
+ * 二维包围盒置空
214
+ * @returns {Box2} 置空结果
215
+ */
216
+ makeEmpty(): this;
217
+ /**
218
+ * 二维包围盒判空
219
+ * @returns {boolean} 判空结果
220
+ */
221
+ isEmpty(): boolean;
222
+ /**
223
+ * 获取二维包围盒角点
224
+ * @returns {Vector2[]} 二维包围盒角点
225
+ */
226
+ getCorners(): Vector2[];
227
+ /**
228
+ * 获取二维包围盒中心点
229
+ * @param {Vector2} [target=new Vector2()] 目标点(用以存放二维包围盒中心点)
230
+ * @returns {Vector2} 二维包围盒中心点
231
+ */
232
+ getCenter(target?: Vector2): Vector2;
233
+ /**
234
+ * 获取二维包围盒大小
235
+ * @param {Vector2} [target=new Vector2()] 目标向量(用以存放二维包围盒大小)
236
+ * @returns {Vector2} 二维包围盒大小
237
+ */
238
+ getSize(target?: Vector2): Vector2;
239
+ /**
240
+ * 通过二维空间点扩展二维包围盒
241
+ * @param {Vector2} point 二维空间点
242
+ * @returns {Box2} 扩展包围盒
243
+ */
244
+ expandByPoint(point: Vector2): this;
245
+ /**
246
+ * 通过向量扩展二维包围盒
247
+ * @param {Vector2} vector 二维向量
248
+ * @returns {Box2} 扩展结果
249
+ */
250
+ expandByVector(vector: Vector2): this;
251
+ /**
252
+ * 通过大小扩展二维包围盒
253
+ * @param {number} scalar 扩展大小
254
+ * @returns {Box2} 扩展结果
255
+ */
256
+ expandByScalar(scalar: number): this;
257
+ /**
258
+ * 判断二维包围盒是否包含二维空间点
259
+ * @param {Vector2} point 二维空间点
260
+ * @param {boolean} [isOrthogonal=true] 包围盒正交判断(默认为true)
261
+ * @returns {boolean} 点包含判断结果
262
+ */
263
+ containsPoint(point: Vector2, isOrthogonal?: boolean): boolean;
264
+ /**
265
+ * 判断二维包围盒包含关系(if this contains other)
266
+ * @param {Box2} box 其它包围盒
267
+ * @returns {boolean} 二维包围盒包含判断结果
268
+ */
269
+ containsBox(box: Box2): boolean;
270
+ /**
271
+ * 获取点以包围盒左上角顶点为原点的相对位置
272
+ * @param {Vector2} point 指定二维空间点
273
+ * @param {Vector2} [target=new Vector2()] 目标空间点
274
+ * @returns {Vector2} 计算结果空间点
275
+ */
276
+ getParameter(point: Vector2, target?: Vector2): Vector2;
277
+ /**
278
+ * 求点与二维包围盒的最近点
279
+ * @param {Vector2} point 二维空间点
280
+ * @param {Vector2} [target=new Vector2()] 结果点
281
+ * @returns {Vector2} 二维空间点
282
+ */
283
+ clampPoint(point: Vector2, target?: Vector2): Vector2;
284
+ /**
285
+ * 求点到二维包围盒的距离
286
+ * @param {Vector2} point 二维空间点
287
+ * @returns {number} 距离
288
+ */
289
+ distanceToPoint(point: Vector2): number;
290
+ /**
291
+ * 二维包围盒求交集
292
+ * @param {Box2} box 二维包围盒
293
+ * @returns {Box2} 求交结果
294
+ */
295
+ intersect(box: Box2): this;
296
+ /**
297
+ * 二维包围盒求并集
298
+ * @param {Box2} box 二维包围盒
299
+ * @returns {Box2} 求并结果
300
+ */
301
+ union(box: Box2): this;
302
+ /**
303
+ * 二维包围盒位移
304
+ * @param {Vector2} offset 位移向量
305
+ * @returns {Box2} 位移结果
306
+ */
307
+ translate(offset: Vector2): this;
308
+ scale(scalar: number, center?: Vector2): this;
309
+ /**
310
+ * 二维包围盒判等
311
+ * @param {Box2} box 二维包围盒
312
+ * @returns {boolean} 判等结果
313
+ */
314
+ equals(box: Box2): boolean;
315
+ /**
316
+ * 判断二维包围盒相交关系(if this intersect other)
317
+ * @param {Box2} box 二维包围盒
318
+ * @param {boolean} [isOrthogonal=true] 正交判断(当前包围盒)
319
+ * @returns {boolean} 相交判断结果
320
+ */
321
+ intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
322
+ }
48
323
 
49
324
  declare const MEDIA_TYPE: {
50
325
  readonly APNG: "APNG";
@@ -202,7 +477,7 @@ type ExportMediaItemOptions = {
202
477
  apngConfig?: ApngConfig;
203
478
  };
204
479
 
205
- type SDKMode = 'product' | 'template';
480
+ type SDKMode = 'editor' | 'template';
206
481
  /**
207
482
  * @description SDK功能配置
208
483
  */
@@ -242,6 +517,8 @@ type SDKConfig = {
242
517
  selectorGizmoConfig: SelectorGizmoConfig;
243
518
  transformGizmoEnabled: boolean;
244
519
  transformGizmoConfig: TransformGizmoConfig;
520
+ pictureCutGizmoEnabled: boolean;
521
+ pictureCutGizmoConfig: PictureCutGizmoConfig;
245
522
  };
246
523
  };
247
524
  /**
@@ -420,6 +697,71 @@ type TransformGizmoConfig = {
420
697
  */
421
698
  rotationCircleSize: number;
422
699
  };
700
+ /**
701
+ * @description 图片裁切参数
702
+ */
703
+ type PictureCutGizmoConfig = {
704
+ /**
705
+ * @description 蒙版颜色
706
+ */
707
+ maskColor: number;
708
+ /**
709
+ * @description 蒙版透明度
710
+ */
711
+ maskAlpha: number;
712
+ /**
713
+ * @description 裁切包围盒线框宽度
714
+ */
715
+ cutBoxLineWidth: number;
716
+ /**
717
+ * @description 裁切包围盒线框颜色
718
+ */
719
+ cutBoxLineColor: number;
720
+ /**
721
+ * @description 裁切包围盒线框透明度
722
+ */
723
+ cutBoxLineAlpha: number;
724
+ /**
725
+ * @description 元素包围盒线框宽度
726
+ */
727
+ itemBoxLineWidth: number;
728
+ /**
729
+ * @description 元素包围盒线框颜色
730
+ */
731
+ itemBoxLineColor: number;
732
+ /**
733
+ * @description 元素包围盒线框透明度
734
+ */
735
+ itemBoxLineAlpha: number;
736
+ /**
737
+ * @description 裁切包围盒角度半径
738
+ */
739
+ cutBoxCornerRadius: number;
740
+ /**
741
+ * @description 裁切包围盒角点宽度
742
+ */
743
+ cutBoxCornerLineWidth: number;
744
+ /**
745
+ * @description 裁切包围盒角点颜色
746
+ */
747
+ cutBoxCornerLineColor: number;
748
+ /**
749
+ * @description 裁切包围盒角点透明度
750
+ */
751
+ cutBoxCornerLineAlpha: number;
752
+ /**
753
+ * @description 裁切包围盒角点填充色
754
+ */
755
+ cutBoxCornerFillColor: number;
756
+ /**
757
+ * @description 缩放判断距离
758
+ */
759
+ scaleInteractionDistance: number;
760
+ /**
761
+ * @description 单向缩放判断距离
762
+ */
763
+ directionScaleInteractionDistance: number;
764
+ };
423
765
 
424
766
  type SDKEvents = {
425
767
  'selectedItemChange': [id: string[]];
@@ -441,6 +783,7 @@ type SDKEvents = {
441
783
  'exportDone': [item: ExportMediaItemOptions | undefined, success: boolean, buffer?: FileBuffer];
442
784
  'exportComplete': [success: boolean, taskInfos: ExportMediaItemOptions[], buffers?: FileBuffer[]];
443
785
  'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
786
+ 'cutBoxChange': [box: Box2];
444
787
  };
445
788
  declare class SDK {
446
789
  static config: SDKConfig;
@@ -461,7 +804,7 @@ declare class SDK {
461
804
  get exportStatus(): string | undefined;
462
805
  private get exportOptions();
463
806
  dispose(): void;
464
- 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;
807
+ on: <E extends "progress" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
465
808
  private getInitParam;
466
809
  /**
467
810
  * 检测导出是否需要重新初始化
@@ -597,7 +940,7 @@ declare class SDK {
597
940
  * @description 设置导出功能初始化配置
598
941
  * @param exportConfig
599
942
  */
600
- setExportConfig(exportConfig: ExportConfig): void;
943
+ setExportConfig(exportConfig: Partial<ExportConfig>): void;
601
944
  /**
602
945
  * @description 设置预选框参数
603
946
  * @param preSelectedColor 预选框颜色
@@ -634,12 +977,20 @@ declare class SDK {
634
977
  * @param spriteInfo 图层元素信息
635
978
  */
636
979
  addSpriteItem(spriteInfo: SpriteCreateInfo): Promise<void>;
980
+ openPictureCutGizmo(): void;
981
+ closePictureCutGizmo(): void;
982
+ /**
983
+ * @description 元素打组
984
+ * @param children 子元素ID
985
+ */
986
+ groupItems(nullInfo: NullCreateInfo): void;
987
+ deleteItems(idInfo: string | string[]): void;
637
988
  }
638
989
 
639
990
  type SizeAdaptDirection = 'x' | 'y';
640
991
 
641
992
  type BaseFormProperty = {
642
- position: [number, number, number];
993
+ position: [number, number];
643
994
  rotation: [number, number, number];
644
995
  size: [number, number];
645
996
  visible: boolean;
@@ -978,5 +1329,34 @@ type SpriteCreateInfo = {
978
1329
  */
979
1330
  position: spec.vec2;
980
1331
  };
1332
+ /**
1333
+ * @description 空节点创建信息
1334
+ */
1335
+ type NullCreateInfo = {
1336
+ /**
1337
+ * @description 元素id
1338
+ */
1339
+ id?: string;
1340
+ /**
1341
+ * @description 元素名称
1342
+ */
1343
+ name?: string;
1344
+ /**
1345
+ * @description 空节点缩放
1346
+ */
1347
+ scale?: spec.vec2;
1348
+ /**
1349
+ * @description 子元素id
1350
+ */
1351
+ children: string[];
1352
+ /**
1353
+ * @description 空节点旋转
1354
+ */
1355
+ rotation?: number;
1356
+ /**
1357
+ * @description 空节点位移
1358
+ */
1359
+ translation?: spec.vec2;
1360
+ };
981
1361
 
982
- export { type ActiveData, type BaseFormProperty, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextFormProperty, type ViewItem, type ViewParam, type ViewProperty };
1362
+ export { type ActiveData, type BaseFormProperty, Box2, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextFormProperty, type ViewItem, type ViewParam, type ViewProperty };