web3dlink 2.1.9 → 2.1.11

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/web3dlink.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region \0rolldown/runtime.js
2
- var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), name = "web3dlink", version$1 = "2.1.9", description = "LarkSR / ZS 推流 GameAPI SDK", type = "module", main = "./dist/web3dlink.js", module$1 = "./dist/web3dlink.js", exports$1 = { ".": {
2
+ var __commonJSMin = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), name = "web3dlink", version$1 = "2.1.11", description = "LarkSR / ZS 推流 GameAPI SDK", type = "module", main = "./dist/web3dlink.js", module$1 = "./dist/web3dlink.js", exports$1 = { ".": {
3
3
  import: "./dist/web3dlink.js",
4
4
  default: "./dist/web3dlink.js"
5
5
  } }, files = ["dist"], scripts = {
@@ -173,6 +173,20 @@ console.log(`[web3dlink] version: ${version}`), (function(e) {
173
173
  })(typeof window < "u" ? window : globalThis);
174
174
  //#endregion
175
175
  //#region ../baseConfig/responses.js
176
+ function normalizeMessageList(e) {
177
+ return (Array.isArray(e) ? e : [e]).map((e) => {
178
+ if (typeof e == "string") return e;
179
+ if (e && typeof e == "object") {
180
+ if (typeof e.message == "string" && e.message) return e.message;
181
+ try {
182
+ return JSON.stringify(e);
183
+ } catch {
184
+ return String(e);
185
+ }
186
+ }
187
+ return e == null ? "" : String(e);
188
+ }).filter((e) => e !== "");
189
+ }
176
190
  function createSuccessResponse(e, t, n) {
177
191
  return {
178
192
  success: !0,
@@ -184,7 +198,7 @@ function createSuccessResponse(e, t, n) {
184
198
  function createErrorResponse(e, t, n) {
185
199
  let r = {
186
200
  success: !1,
187
- message: e,
201
+ message: normalizeMessageList(e),
188
202
  params: t,
189
203
  command: n
190
204
  };
@@ -193,7 +207,7 @@ function createErrorResponse(e, t, n) {
193
207
  function createWarnResponse(e, t, n) {
194
208
  let r = {
195
209
  success: !1,
196
- message: e,
210
+ message: normalizeMessageList(e),
197
211
  params: t,
198
212
  command: n
199
213
  };
@@ -769,7 +783,7 @@ function verifyEnumerationValue(e) {
769
783
  }
770
784
  //#endregion
771
785
  //#region ../api/camera/validate.js
772
- function validateOptionalBoolean(e, t, n, r, i) {
786
+ function validateOptionalBoolean$1(e, t, n, r, i) {
773
787
  if (n == null || n === "") {
774
788
  e[t] = i;
775
789
  return;
@@ -984,6 +998,12 @@ function aroundMode(e = {}) {
984
998
  defaultValue: 0,
985
999
  min: -180,
986
1000
  max: 180
1001
+ })), t.push(...validateOptionalNumber({
1002
+ normalized: n,
1003
+ field: "duration",
1004
+ value: e.duration,
1005
+ defaultValue: 2,
1006
+ min: 0
987
1007
  })), t.push(...validateOptionalNumber({
988
1008
  normalized: n,
989
1009
  field: "minDistanceToTarget",
@@ -1026,7 +1046,7 @@ function aroundMode(e = {}) {
1026
1046
  value: e.y_AnimSpeed,
1027
1047
  defaultValue: 5,
1028
1048
  min: 0
1029
- })), validateOptionalBoolean(n, "isCheckCollision", e.isCheckCollision, t, !1), validateOptionalBoolean(n, "isIgnoreAttachedActors", e.isIgnoreAttachedActors, t, !0), t.push(...validateOptionalNumber({
1049
+ })), validateOptionalBoolean$1(n, "isCheckCollision", e.isCheckCollision, t, !1), validateOptionalBoolean$1(n, "isIgnoreAttachedActors", e.isIgnoreAttachedActors, t, !0), t.push(...validateOptionalNumber({
1030
1050
  normalized: n,
1031
1051
  field: "collisionOffset",
1032
1052
  value: e.collisionOffset,
@@ -1071,14 +1091,14 @@ function firstPersonMode(e = {}) {
1071
1091
  value: e.speed,
1072
1092
  defaultValue: 2,
1073
1093
  min: 0
1074
- })), validateOptionalBoolean(n, "collision", e.collision, t, !0), {
1094
+ })), validateOptionalBoolean$1(n, "collision", e.collision, t, !0), {
1075
1095
  errors: t,
1076
1096
  normalized: n
1077
1097
  };
1078
1098
  }
1079
1099
  function viewLock(e = {}) {
1080
1100
  let t = [], n = { ...e };
1081
- return validateOptionalBoolean(n, "state", e.state, t, !1), {
1101
+ return validateOptionalBoolean$1(n, "state", e.state, t, !1), {
1082
1102
  errors: t,
1083
1103
  normalized: n
1084
1104
  };
@@ -1679,6 +1699,28 @@ function validatePopupCustom1Config(e, t) {
1679
1699
  }
1680
1700
  //#endregion
1681
1701
  //#region ../api/marker/validate.js
1702
+ var DEFAULT_VISIBLE_RANGE = [0, 2147483647];
1703
+ function validateVisibleRange(e, t, n, r = "visibleRange") {
1704
+ n.push(...validateOptionalArray({
1705
+ normalized: t,
1706
+ field: r,
1707
+ value: e[r],
1708
+ length: 2,
1709
+ defaultValue: [...DEFAULT_VISIBLE_RANGE]
1710
+ }));
1711
+ let i = t[r];
1712
+ if (!Array.isArray(i) || i.length !== 2) return;
1713
+ let a = Number(i[0]), o = Number(i[1]);
1714
+ if (!Number.isFinite(a) || !Number.isFinite(o)) {
1715
+ n.push(`[${r}]元素必须是数字`);
1716
+ return;
1717
+ }
1718
+ if (a > o) {
1719
+ n.push(`[${r}]最小值不能大于最大值`);
1720
+ return;
1721
+ }
1722
+ t[r] = [a, o];
1723
+ }
1682
1724
  var MARKER_TYPE_LIST = [
1683
1725
  "default",
1684
1726
  "default1",
@@ -1706,13 +1748,7 @@ function iconMarker(e) {
1706
1748
  normalized: n,
1707
1749
  field: "groupId",
1708
1750
  value: e.groupId
1709
- })), t.push(...validateOptionalArray({
1710
- normalized: n,
1711
- field: "visibleRange",
1712
- value: e.visibleRange,
1713
- length: 2,
1714
- defaultValue: [0, 2147483647]
1715
- })), t.push(...verifyEnumerationValue({
1751
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1716
1752
  normalized: n,
1717
1753
  field: "isScreenSpace",
1718
1754
  value: e.isScreenSpace,
@@ -1728,17 +1764,11 @@ function iconMarker(e) {
1728
1764
  list: MARKER_TYPE_LIST
1729
1765
  })), e.recordData !== void 0) {
1730
1766
  let r = e.recordData;
1731
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1732
- field: "recordData",
1733
- message: "[recordData] 必须是对象类型"
1734
- });
1767
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1735
1768
  else try {
1736
1769
  n.recordData = JSON.stringify(r);
1737
1770
  } catch {
1738
- t.push({
1739
- field: "recordData",
1740
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1741
- });
1771
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
1742
1772
  }
1743
1773
  }
1744
1774
  return validateConfigByMarkerType(n, t), {
@@ -1756,13 +1786,7 @@ function followMarker(e) {
1756
1786
  normalized: n,
1757
1787
  field: "groupId",
1758
1788
  value: e.groupId
1759
- })), t.push(...validateOptionalArray({
1760
- normalized: n,
1761
- field: "visibleRange",
1762
- value: e.visibleRange,
1763
- length: 2,
1764
- defaultValue: [0, 2147483647]
1765
- })), t.push(...verifyEnumerationValue({
1789
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1766
1790
  normalized: n,
1767
1791
  field: "isScreenSpace",
1768
1792
  value: e.isScreenSpace,
@@ -1778,17 +1802,11 @@ function followMarker(e) {
1778
1802
  list: MARKER_TYPE_LIST
1779
1803
  })), e.recordData !== void 0) {
1780
1804
  let r = e.recordData;
1781
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1782
- field: "recordData",
1783
- message: "[recordData] 必须是对象类型"
1784
- });
1805
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1785
1806
  else try {
1786
1807
  n.recordData = JSON.stringify(r);
1787
1808
  } catch {
1788
- t.push({
1789
- field: "recordData",
1790
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1791
- });
1809
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
1792
1810
  }
1793
1811
  }
1794
1812
  return validateConfigByMarkerType(n, t), {
@@ -1935,23 +1953,14 @@ function secondMarker(e) {
1935
1953
  normalized: n,
1936
1954
  field: "groupId",
1937
1955
  value: e.groupId
1938
- })), t.push(...validateOptionalArray({
1939
- normalized: n,
1940
- field: "visibleRange",
1941
- value: e.visibleRange,
1942
- length: 2,
1943
- defaultValue: [0, 2147483647]
1944
- })), t.push(...verifyEnumerationValue({
1956
+ })), validateVisibleRange(e, n, t), t.push(...verifyEnumerationValue({
1945
1957
  normalized: n,
1946
1958
  field: "isScreenSpace",
1947
1959
  value: e.isScreenSpace,
1948
1960
  defaultValue: 1,
1949
1961
  type: "number",
1950
1962
  list: [0, 1]
1951
- })), typeof e.isInitSecond == "boolean" ? n.isInitSecond = e.isInitSecond : e.isInitSecond === void 0 ? n.isInitSecond = !1 : t.push({
1952
- field: "isInitSecond",
1953
- message: "isInitSecond must be boolean"
1954
- }), t.push(...verifyEnumerationValue({
1963
+ })), typeof e.isInitSecond == "boolean" ? n.isInitSecond = e.isInitSecond : e.isInitSecond === void 0 ? n.isInitSecond = !1 : t.push("[isInitSecond]必须是布尔类型"), t.push(...verifyEnumerationValue({
1955
1964
  normalized: n,
1956
1965
  field: "triggerType",
1957
1966
  value: e.triggerType,
@@ -1986,17 +1995,11 @@ function secondMarker(e) {
1986
1995
  value: e.value ?? ""
1987
1996
  })) : r.dataTexts = []), e.recordData !== void 0) {
1988
1997
  let r = e.recordData;
1989
- if (typeof r != "object" || !r || Array.isArray(r)) t.push({
1990
- field: "recordData",
1991
- message: "[recordData] 必须是对象类型"
1992
- });
1998
+ if (typeof r != "object" || !r || Array.isArray(r)) t.push("[recordData] 必须是对象类型");
1993
1999
  else try {
1994
2000
  n.recordData = JSON.stringify(r);
1995
2001
  } catch {
1996
- t.push({
1997
- field: "recordData",
1998
- message: "[recordData] 序列化失败,请检查是否包含循环引用"
1999
- });
2002
+ t.push("[recordData] 序列化失败,请检查是否包含循环引用");
2000
2003
  }
2001
2004
  }
2002
2005
  return {
@@ -3432,6 +3435,157 @@ function offMouseClick(e = {}) {
3432
3435
  normalized: n
3433
3436
  };
3434
3437
  }
3438
+ function validateOptionalBoolean(e, t, n, r, i) {
3439
+ let a = e[t];
3440
+ if (a == null || a === "") {
3441
+ i[t] = n;
3442
+ return;
3443
+ }
3444
+ if (typeof a != "boolean") {
3445
+ r.push(`[${t}]必须是布尔类型`);
3446
+ return;
3447
+ }
3448
+ i[t] = a;
3449
+ }
3450
+ function validateOptionalCoordinates(e, t, n) {
3451
+ let r = e.coordinates;
3452
+ if (r == null || r === "" || Array.isArray(r) && r.length === 0) {
3453
+ n.coordinates = [];
3454
+ return;
3455
+ }
3456
+ t.push(...validateCoordinatesRequired(r)), Array.isArray(r) && r.length >= 3 && (n.coordinates = r.slice(0, 3).map(Number));
3457
+ }
3458
+ function playSequence(e = {}) {
3459
+ let t = [], n = { ...e };
3460
+ t.push(...validateRequiredString({
3461
+ normalized: n,
3462
+ field: "id",
3463
+ value: e.id
3464
+ })), t.push(...validateRequiredString({
3465
+ normalized: n,
3466
+ field: "fieldName",
3467
+ value: e.fieldName
3468
+ })), t.push(...validateOptionalString({
3469
+ normalized: n,
3470
+ field: "sequenceDirectory",
3471
+ value: e.sequenceDirectory,
3472
+ defaultValue: ""
3473
+ })), t.push(...validateOptionalArray({
3474
+ normalized: n,
3475
+ field: "sequenceFiles",
3476
+ value: e.sequenceFiles,
3477
+ defaultValue: []
3478
+ })), Array.isArray(n.sequenceFiles) && (n.sequenceFiles = n.sequenceFiles.map((e) => String(e ?? "").trim()).filter(Boolean));
3479
+ let r = typeof n.sequenceDirectory == "string" && n.sequenceDirectory.trim() !== "", i = Array.isArray(n.sequenceFiles) && n.sequenceFiles.length > 0;
3480
+ return i && r ? t.push("[sequenceFiles]与[sequenceDirectory]二选一,不能同时填写(设置 sequenceDirectory 时 sequenceFiles 必须为空)") : i ? n.sequenceDirectory = "" : r ? (n.sequenceDirectory = n.sequenceDirectory.trim(), n.sequenceFiles = []) : t.push("[sequenceFiles]与[sequenceDirectory]二选一,必须填写其中一个(设置 sequenceDirectory 时 sequenceFiles 必须为空)"), t.push(...validateOptionalNumber({
3481
+ normalized: n,
3482
+ field: "frameIndex",
3483
+ value: e.frameIndex,
3484
+ defaultValue: 0,
3485
+ min: 0
3486
+ })), t.push(...validateOptionalNumber({
3487
+ normalized: n,
3488
+ field: "playbackSpeed",
3489
+ value: e.playbackSpeed,
3490
+ defaultValue: 1,
3491
+ min: 0
3492
+ })), typeof n.playbackSpeed == "number" && n.playbackSpeed <= 0 && t.push("[playbackSpeed]取值必须大于0"), validateOptionalCoordinates(e, t, n), t.push(...validateOptionalVector3Array({
3493
+ normalized: n,
3494
+ field: "rotation",
3495
+ value: e.rotation,
3496
+ defaultValue: [
3497
+ 0,
3498
+ 0,
3499
+ 0
3500
+ ]
3501
+ })), t.push(...validateOptionalVector3Array({
3502
+ normalized: n,
3503
+ field: "scale",
3504
+ value: e.scale,
3505
+ defaultValue: [
3506
+ 1,
3507
+ 1,
3508
+ 1
3509
+ ]
3510
+ })), {
3511
+ errors: t,
3512
+ normalized: n
3513
+ };
3514
+ }
3515
+ function pauseSequence(e = {}) {
3516
+ let t = [], n = { ...e };
3517
+ return t.push(...validateRequiredString({
3518
+ normalized: n,
3519
+ field: "id",
3520
+ value: e.id
3521
+ })), {
3522
+ errors: t,
3523
+ normalized: n
3524
+ };
3525
+ }
3526
+ function stopSequence(e = {}) {
3527
+ let t = [], n = { ...e };
3528
+ return t.push(...validateRequiredString({
3529
+ normalized: n,
3530
+ field: "id",
3531
+ value: e.id
3532
+ })), {
3533
+ errors: t,
3534
+ normalized: n
3535
+ };
3536
+ }
3537
+ function setFrame(e = {}) {
3538
+ let t = [], n = { ...e };
3539
+ return t.push(...validateRequiredString({
3540
+ normalized: n,
3541
+ field: "id",
3542
+ value: e.id
3543
+ })), t.push(...validateOptionalNumber({
3544
+ normalized: n,
3545
+ field: "frameIndex",
3546
+ value: e.frameIndex,
3547
+ defaultValue: 0,
3548
+ min: 0
3549
+ })), {
3550
+ errors: t,
3551
+ normalized: n
3552
+ };
3553
+ }
3554
+ function setPlaybackSpeed(e = {}) {
3555
+ let t = [], n = { ...e };
3556
+ return t.push(...validateRequiredString({
3557
+ normalized: n,
3558
+ field: "id",
3559
+ value: e.id
3560
+ })), t.push(...validateOptionalNumber({
3561
+ normalized: n,
3562
+ field: "playbackSpeed",
3563
+ value: e.playbackSpeed,
3564
+ defaultValue: 4,
3565
+ min: 0
3566
+ })), typeof n.playbackSpeed == "number" && n.playbackSpeed <= 0 && t.push("[playbackSpeed]取值必须大于0"), {
3567
+ errors: t,
3568
+ normalized: n
3569
+ };
3570
+ }
3571
+ function clearSequence(e = {}) {
3572
+ let t = [], n = { ...e };
3573
+ return t.push(...validateRequiredString({
3574
+ normalized: n,
3575
+ field: "id",
3576
+ value: e.id
3577
+ })), validateOptionalBoolean(e, "isClearCache", !0, t, n), {
3578
+ errors: t,
3579
+ normalized: n
3580
+ };
3581
+ }
3582
+ function clearAllSequence(e = {}) {
3583
+ let t = [], n = { ...e };
3584
+ return validateOptionalBoolean(e, "isClearCache", !0, t, n), {
3585
+ errors: t,
3586
+ normalized: n
3587
+ };
3588
+ }
3435
3589
  //#endregion
3436
3590
  //#region ../api/vtk/vtkApi.js
3437
3591
  var validator = {
@@ -3447,7 +3601,14 @@ var validator = {
3447
3601
  setDisplacementScale,
3448
3602
  closeDisplacementScale,
3449
3603
  onMouseClick,
3450
- offMouseClick
3604
+ offMouseClick,
3605
+ playSequence,
3606
+ pauseSequence,
3607
+ stopSequence,
3608
+ setFrame,
3609
+ setPlaybackSpeed,
3610
+ clearSequence,
3611
+ clearAllSequence
3451
3612
  }, VtkApi = class {
3452
3613
  constructor(e) {
3453
3614
  this.commandManager = e;