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

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
@@ -47,7 +47,7 @@ type SetItemPropertyValueParam = {
47
47
  }[keyof PageFormTypeAndPropertyReference] | {
48
48
  itemId: string;
49
49
  type: spec.ItemType;
50
- propertyName: 'position';
50
+ propertyName: 'position' | 'size';
51
51
  propertyValue: spec.vec2 | spec.vec3;
52
52
  };
53
53
 
@@ -159,6 +159,18 @@ declare class Vector2 extends math.Vector2 {
159
159
  d: number;
160
160
  t: number;
161
161
  };
162
+ /**
163
+ * 二维向量与x轴夹角
164
+ * @returns {number} 弧度值
165
+ */
166
+ angle(): number;
167
+ /**
168
+ * 二维点绕点旋转
169
+ * @param {Vec2} center 旋转中心
170
+ * @param {number} angle 旋转角度
171
+ * @returns {Vec2} 旋转结果
172
+ */
173
+ rotateAround(center: Vector2, angle: number): this;
162
174
  }
163
175
 
164
176
  /**
@@ -190,6 +202,10 @@ declare class Box2 {
190
202
  * @returns {Box2} 二维包围盒
191
203
  */
192
204
  setFromVec2Array(vecArray: Vector2[]): this;
205
+ /**
206
+ * 通过屏幕坐标点设置二维包围盒 - 点为屏幕坐标点,x正方向为右,y正方向为向上
207
+ * @param vecArray 屏幕坐标点
208
+ */
193
209
  setFromVec2ArrayWithOutCorners(vecArray: Vector2[]): this;
194
210
  /**
195
211
  * 通过中心与大小设置二维包围盒
@@ -319,6 +335,7 @@ declare class Box2 {
319
335
  * @returns {boolean} 相交判断结果
320
336
  */
321
337
  intersectsBox(box: Box2, isOrthogonal?: boolean): boolean;
338
+ rotate(angle: number, center?: Vector2): this;
322
339
  }
323
340
 
324
341
  declare const MEDIA_TYPE: {
@@ -519,6 +536,12 @@ type SDKConfig = {
519
536
  transformGizmoConfig: TransformGizmoConfig;
520
537
  pictureCutGizmoEnabled: boolean;
521
538
  pictureCutGizmoConfig: PictureCutGizmoConfig;
539
+ pictureExpandGizmoEnabled: boolean;
540
+ pictureExpandGizmoConfig: PictureExpandGizmoConfig;
541
+ textGizmoEnbaled: boolean;
542
+ textGizmoConfig: TextGizmoConfig;
543
+ maskGizmoEnabled: boolean;
544
+ maskGizmoConfig: MaskGizmoConfig;
522
545
  };
523
546
  };
524
547
  /**
@@ -762,8 +785,136 @@ type PictureCutGizmoConfig = {
762
785
  */
763
786
  directionScaleInteractionDistance: number;
764
787
  };
788
+ /**
789
+ * @description 图片扩边参数
790
+ */
791
+ type PictureExpandGizmoConfig = {
792
+ /**
793
+ * @description 蒙版颜色
794
+ */
795
+ maskColor: number;
796
+ /**
797
+ * @description 蒙版透明度
798
+ */
799
+ maskAlpha: number;
800
+ /**
801
+ * @description 扩边包围盒线框宽度
802
+ */
803
+ expandBoxLineWidth: number;
804
+ /**
805
+ * @description 扩边包围盒线框颜色
806
+ */
807
+ expandBoxLineColor: number;
808
+ /**
809
+ * @description 扩边包围盒线框透明度
810
+ */
811
+ expandBoxLineAlpha: number;
812
+ /**
813
+ * @description 扩边包围盒角度半径
814
+ */
815
+ expandBoxCornerRadius: number;
816
+ /**
817
+ * @description 扩边包围盒角点宽度
818
+ */
819
+ expandBoxCornerLineWidth: number;
820
+ /**
821
+ * @description 扩边包围盒角点颜色
822
+ */
823
+ expandBoxCornerLineColor: number;
824
+ /**
825
+ * @description 扩边包围盒角点透明度
826
+ */
827
+ expandBoxCornerLineAlpha: number;
828
+ /**
829
+ * @description 扩边包围盒角点填充色
830
+ */
831
+ expandBoxCornerFillColor: number;
832
+ /**
833
+ * @description 缩放判断距离
834
+ */
835
+ scaleInteractionDistance: number;
836
+ /**
837
+ * @description 单向缩放判断距离
838
+ */
839
+ directionScaleInteractionDistance: number;
840
+ };
841
+ /**
842
+ * @description 文本交互控制器参数
843
+ */
844
+ type TextGizmoConfig = {
845
+ /**
846
+ * @description 包围盒线宽
847
+ */
848
+ boxLineWidth: number;
849
+ /**
850
+ * @description 包围盒线色
851
+ */
852
+ boxLineColor: number;
853
+ /**
854
+ * @description 缩放交互点半径
855
+ */
856
+ scaleCornerRadius: number;
857
+ /**
858
+ * @description 旋转交互点边长
859
+ */
860
+ rotationCornerWidth: number;
861
+ /**
862
+ * @description 旋转交互贴图地址
863
+ */
864
+ rotationCornerTexture: string;
865
+ /**
866
+ * @description 缩放交互点填充色
867
+ */
868
+ scaleCornerFillColor: number;
869
+ /**
870
+ * @description 缩放交互点描边宽度
871
+ */
872
+ scaleCornerStrokeWidth: number;
873
+ /**
874
+ * @description 缩放交互点描边颜色
875
+ */
876
+ scaleCornerStrokeColor: number;
877
+ };
878
+ /**
879
+ * @description 蒙版参数
880
+ */
881
+ type MaskGizmoConfig = {
882
+ /**
883
+ * @description 画笔大小
884
+ */
885
+ brushSize: number;
886
+ /**
887
+ * @description 笔刷颜色
888
+ */
889
+ brushColor: number;
890
+ /**
891
+ * @description 笔刷透明度
892
+ */
893
+ brushAlpha: number;
894
+ /**
895
+ * @description 蒙版颜色
896
+ */
897
+ maskColor: number;
898
+ /**
899
+ * @description 蒙版透明度
900
+ */
901
+ maskAlpha: number;
902
+ /**
903
+ * @description 元素包围盒线框宽度
904
+ */
905
+ boxLineWidth: number;
906
+ /**
907
+ * @description 元素包围盒线框颜色
908
+ */
909
+ boxLineColor: number;
910
+ /**
911
+ * @description 元素包围盒线框透明度
912
+ */
913
+ boxLineAlpha: number;
914
+ };
765
915
 
766
916
  type SDKEvents = {
917
+ 'loadingItemChange': [id: string[]];
767
918
  'selectedItemChange': [id: string[]];
768
919
  'preSelectedItemChange': [id: string | undefined];
769
920
  'selectedViewChange': [id: number];
@@ -784,6 +935,11 @@ type SDKEvents = {
784
935
  'exportComplete': [success: boolean, taskInfos: ExportMediaItemOptions[], buffers?: FileBuffer[]];
785
936
  'sdkConfigChange': [preSDKConfig: SDKConfig, curSDKConfig: SDKConfig];
786
937
  'cutBoxChange': [box: Box2];
938
+ 'expandBoxChange': [box: Box2];
939
+ 'textInput': [{
940
+ text: string;
941
+ fontFamily: string;
942
+ }];
787
943
  };
788
944
  declare class SDK {
789
945
  static config: SDKConfig;
@@ -800,11 +956,12 @@ declare class SDK {
800
956
  _container: HTMLElement;
801
957
  private _playerContainer;
802
958
  constructor(container: HTMLElement);
959
+ get container(): HTMLElement;
803
960
  get pageData(): PageData | undefined;
804
961
  get exportStatus(): string | undefined;
805
962
  private get exportOptions();
806
963
  dispose(): 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;
964
+ on: <E extends "progress" | "loadingItemChange" | "selectedItemChange" | "preSelectedItemChange" | "selectedViewChange" | "pageDataChange" | "zoomChange" | "itemPropertyChange" | "exportProgress" | "exportDone" | "exportComplete" | "sdkConfigChange" | "cutBoxChange" | "expandBoxChange" | "textInput">(eventName: E, listener: _galacean_effects.EventEmitterListener<SDKEvents[E]>, options?: _galacean_effects.EventEmitterOptions) => () => void;
808
965
  private getInitParam;
809
966
  /**
810
967
  * 检测导出是否需要重新初始化
@@ -976,15 +1133,48 @@ declare class SDK {
976
1133
  * @description 创建图层元素
977
1134
  * @param spriteInfo 图层元素信息
978
1135
  */
979
- addSpriteItem(spriteInfo: SpriteCreateInfo): Promise<void>;
1136
+ addSpriteItem(spriteInfo: SpriteCreateInfo): Promise<string | undefined>;
980
1137
  openPictureCutGizmo(): void;
981
1138
  closePictureCutGizmo(): void;
1139
+ getCutInfo(): {
1140
+ cutBox: Box2;
1141
+ itemBox: Box2;
1142
+ } | undefined;
1143
+ setCutBox(min: Vector2, max: Vector2): Box2 | undefined;
1144
+ openPictureExpandGizmo(): void;
1145
+ closePictureExpandGizmo(): void;
1146
+ getExpandInfo(): {
1147
+ expandBox: Box2;
1148
+ itemBox: Box2;
1149
+ } | undefined;
1150
+ setExpandBox(min: Vector2, max: Vector2): Box2 | undefined;
1151
+ openMaskGizmo(brushSize: number): void;
1152
+ closeMaskGizmo(): void;
1153
+ getMask(): string | undefined;
1154
+ openLoadingGizmo(id: string): void;
1155
+ closeLoadingGizmo(id: string): void;
982
1156
  /**
983
1157
  * @description 元素打组
984
1158
  * @param children 子元素ID
985
1159
  */
986
- groupItems(nullInfo: NullCreateInfo): void;
1160
+ groupItems(nullInfo: NullCreateInfo): string | undefined;
1161
+ addTextItem(textInfo: TextCreateInfo): Promise<void>;
987
1162
  deleteItems(idInfo: string | string[]): void;
1163
+ getItemCreateInfo(idInfo: string | string[]): ItemCreateInfo[];
1164
+ createScreenShotSceneByIds(idInfo: string | string[], time?: number): Promise<string | undefined>;
1165
+ getChildrenIds(id: string): string[];
1166
+ /**
1167
+ * @description 更新元素在图层中的顺序
1168
+ * @param id 元素ID
1169
+ * @param action 排序操作:BringToFront(置于顶层)、SendToBack(置于底层)、BringForward(上移一层)、SendBackward(下移一层)
1170
+ */
1171
+ updateItemOrder(id: string, action: ItemOrderAction): void;
1172
+ /**
1173
+ * @description 导出JSON
1174
+ * @param idInfo 视图序号信息
1175
+ * @returns JSON数组
1176
+ */
1177
+ exportJSON(idInfo?: number | number[]): spec.JSONScene[];
988
1178
  }
989
1179
 
990
1180
  type SizeAdaptDirection = 'x' | 'y';
@@ -1000,11 +1190,17 @@ type SpriteFormProperty = BaseFormProperty & {
1000
1190
  image: string;
1001
1191
  };
1002
1192
  type TextFormProperty = BaseFormProperty & {
1003
- font: string;
1004
- color: [number, number, number, number];
1005
- weight: spec.TextWeight;
1193
+ fontFamily: string;
1194
+ textColor: [number, number, number, number];
1195
+ fontWeight: spec.TextWeight;
1006
1196
  text: string;
1007
- alignment: spec.TextAlignment;
1197
+ textAlign: spec.TextAlignment;
1198
+ fontSize: number;
1199
+ fontStyle: spec.FontStyle;
1200
+ textWidth: number;
1201
+ lineHeight: number;
1202
+ outlineColor?: spec.vec4;
1203
+ outlineWidth?: number;
1008
1204
  };
1009
1205
  /**
1010
1206
  * @description 页面表单类型和属性引用
@@ -1261,6 +1457,10 @@ type ActiveData = {
1261
1457
  * @description 预选中元素
1262
1458
  */
1263
1459
  preSelectedItem?: string;
1460
+ /**
1461
+ * @description 执行中元素
1462
+ */
1463
+ loadingItems?: string[];
1264
1464
  };
1265
1465
  /**
1266
1466
  * @description 视图元素
@@ -1300,6 +1500,7 @@ type SDKBackgroundType = 'color' | 'image' | 'chess-board';
1300
1500
  * @description 图层创建信息
1301
1501
  */
1302
1502
  type SpriteCreateInfo = {
1503
+ type: 'sprite';
1303
1504
  /**
1304
1505
  * @description 图层名称
1305
1506
  */
@@ -1308,6 +1509,10 @@ type SpriteCreateInfo = {
1308
1509
  * @description 元素id
1309
1510
  */
1310
1511
  id?: string;
1512
+ /**
1513
+ * @description 父节点id
1514
+ */
1515
+ parentId?: string;
1311
1516
  /**
1312
1517
  * @description 图片资源地址
1313
1518
  */
@@ -1333,10 +1538,15 @@ type SpriteCreateInfo = {
1333
1538
  * @description 空节点创建信息
1334
1539
  */
1335
1540
  type NullCreateInfo = {
1541
+ type: 'null';
1336
1542
  /**
1337
1543
  * @description 元素id
1338
1544
  */
1339
1545
  id?: string;
1546
+ /**
1547
+ * @description 父节点id
1548
+ */
1549
+ parentId?: string;
1340
1550
  /**
1341
1551
  * @description 元素名称
1342
1552
  */
@@ -1356,7 +1566,92 @@ type NullCreateInfo = {
1356
1566
  /**
1357
1567
  * @description 空节点位移
1358
1568
  */
1359
- translation?: spec.vec2;
1569
+ position?: spec.vec2;
1360
1570
  };
1571
+ /**
1572
+ * @description 文本创建信息
1573
+ */
1574
+ type TextCreateInfo = {
1575
+ type: 'text';
1576
+ /**
1577
+ * @description 元素id
1578
+ */
1579
+ id?: string;
1580
+ /**
1581
+ * @description 父节点id
1582
+ */
1583
+ parentId?: string;
1584
+ /**
1585
+ * @description 元素名称
1586
+ */
1587
+ name?: string;
1588
+ /**
1589
+ * @description 单行高度
1590
+ */
1591
+ lineHeight: number;
1592
+ /**
1593
+ * @description 文本高度
1594
+ */
1595
+ textHeight?: number;
1596
+ /**
1597
+ * @description 宽度
1598
+ */
1599
+ textWidth: number;
1600
+ /**
1601
+ * @description 字体名称
1602
+ */
1603
+ fontFamily: string;
1604
+ /**
1605
+ * @description 文本位置
1606
+ */
1607
+ position?: spec.vec2;
1608
+ /**
1609
+ * @description 文本旋转
1610
+ */
1611
+ rotation?: number;
1612
+ /**
1613
+ * @description 文字大小
1614
+ */
1615
+ fontSize: number;
1616
+ /**
1617
+ * @description 字重
1618
+ */
1619
+ fontWeight?: spec.TextWeight;
1620
+ /**
1621
+ * @description 字体格式
1622
+ */
1623
+ fontStyle?: spec.FontStyle;
1624
+ /**
1625
+ * @description 对齐方式
1626
+ */
1627
+ textAlign?: spec.TextAlignment;
1628
+ /**
1629
+ * @description 文本信息
1630
+ */
1631
+ text: string;
1632
+ /**
1633
+ * @description 填充色
1634
+ */
1635
+ textColor: spec.vec4;
1636
+ /**
1637
+ * @description 描边色
1638
+ */
1639
+ outlineColor?: spec.vec4;
1640
+ /**
1641
+ * @description 描边宽度
1642
+ */
1643
+ outlineWidth?: number;
1644
+ /**
1645
+ * @description 字体文件地址
1646
+ */
1647
+ url?: string;
1648
+ };
1649
+ type ItemCreateInfo = NullCreateInfo | SpriteCreateInfo | TextCreateInfo;
1650
+ declare enum ItemOrderAction {
1651
+ BringToFront = 0,
1652
+ SendToBack = 1,
1653
+ BringForward = 2,
1654
+ SendBackward = 3
1655
+ }
1361
1656
 
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 };
1657
+ export { type ActiveData, type BaseFormProperty, Box2, ItemOrderAction, type NullCreateInfo, type PageData, type PageFormTypedProperty, type PageProperty, SDK, type SDKEvents, type SDKInputParam, type SDKOptions, type SpecificPageFormProps, type SpriteCreateInfo, type SpriteFormProperty, type TextCreateInfo, type TextFormProperty, Vector2, type ViewItem, type ViewItemTypedProperty, type ViewParam, type ViewProperty };