web3dlink 2.1.1 → 2.1.3
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 +130 -28
- package/dist/web3dlink.js.map +1 -1
- package/package.json +1 -1
package/dist/web3dlink.js
CHANGED
|
@@ -185,14 +185,17 @@ var CommandManager = class {
|
|
|
185
185
|
this.transport = e, this.callbacks = {}, this.requestId = 0, this.timeout = 3e3, this.markerEventCallbacks = {
|
|
186
186
|
Hovered: {},
|
|
187
187
|
Click: {},
|
|
188
|
+
DoubleClick: {},
|
|
188
189
|
Unhovered: {}
|
|
189
190
|
}, this.secondMarkerEventCallbacks = {
|
|
190
191
|
Hovered: {},
|
|
191
192
|
Click: {},
|
|
193
|
+
DoubleClick: {},
|
|
192
194
|
Unhovered: {}
|
|
193
195
|
}, this.followMarkerEventCallbacks = {
|
|
194
196
|
Hovered: {},
|
|
195
197
|
Click: {},
|
|
198
|
+
DoubleClick: {},
|
|
196
199
|
Unhovered: {}
|
|
197
200
|
}, this.animationOnDataCallback = { Change: [] }, this.mouseClickCallback = { MouseClick: [] }, this.vtkMouseClickCallback = {}, e.bindMessageHandler((e) => {
|
|
198
201
|
this._handleRawResponse(e);
|
|
@@ -254,17 +257,17 @@ var CommandManager = class {
|
|
|
254
257
|
console.warn("注意:非常规响应", t);
|
|
255
258
|
}
|
|
256
259
|
_sendPreparePayload(e, t) {
|
|
257
|
-
if (e === "marker.iconMarker") {
|
|
258
|
-
let { onMarkerClick: e,
|
|
259
|
-
return
|
|
260
|
+
if (e === "marker.iconMarker" || e === "marker.iconUrlMarker") {
|
|
261
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
262
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.markerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.markerEventCallbacks.Click[c] = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.markerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.markerEventCallbacks.Click.__default = e), typeof s == "function" && (this.markerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.markerEventCallbacks.Unhovered.__default = a)), o;
|
|
260
263
|
}
|
|
261
264
|
if (e === "marker.secondMarker") {
|
|
262
|
-
let { onMarkerClick: e,
|
|
263
|
-
return
|
|
265
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
266
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.secondMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.secondMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.secondMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.secondMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
264
267
|
}
|
|
265
268
|
if (e === "marker.followMarker") {
|
|
266
|
-
let { onMarkerClick: e,
|
|
267
|
-
return
|
|
269
|
+
let { onMarkerClick: e, onMarkerDoubleClick: n, onMarkerDblClick: r, onMouseHover: i, onMouseLeave: a, ...o } = t || {}, s = n || r, c = o?.id;
|
|
270
|
+
return c != null && c !== "" ? (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered[c] = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click[c] = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick[c] = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered[c] = a)) : (typeof i == "function" && (this.followMarkerEventCallbacks.Hovered.__default = i), typeof e == "function" && (this.followMarkerEventCallbacks.Click.__default = e), typeof s == "function" && (this.followMarkerEventCallbacks.DoubleClick.__default = s), typeof a == "function" && (this.followMarkerEventCallbacks.Unhovered.__default = a)), o;
|
|
268
271
|
}
|
|
269
272
|
if (e === "tool.onMouseClick") {
|
|
270
273
|
let { onMouseClick: e, ...n } = t || {};
|
|
@@ -287,7 +290,7 @@ var CommandManager = class {
|
|
|
287
290
|
_processEventResponse(e) {
|
|
288
291
|
if (!e) return !1;
|
|
289
292
|
let { command: t, data: n = {} } = e;
|
|
290
|
-
if (t === "marker.iconMarker") {
|
|
293
|
+
if (t === "marker.iconMarker" || t === "marker.iconUrlMarker") {
|
|
291
294
|
if (typeof n.recordData == "string") try {
|
|
292
295
|
n.recordData = JSON.parse(n.recordData);
|
|
293
296
|
} catch {}
|
|
@@ -804,8 +807,8 @@ function flyTo(e) {
|
|
|
804
807
|
field: "pitch",
|
|
805
808
|
value: e.pitch,
|
|
806
809
|
defaultValue: 0,
|
|
807
|
-
min: -
|
|
808
|
-
max:
|
|
810
|
+
min: -90,
|
|
811
|
+
max: 90
|
|
809
812
|
})), t.push(...validateOptionalNumber({
|
|
810
813
|
normalized: n,
|
|
811
814
|
field: "yaw",
|
|
@@ -835,8 +838,8 @@ function focusToID(e) {
|
|
|
835
838
|
normalized: n,
|
|
836
839
|
field: "pitch",
|
|
837
840
|
value: e.pitch,
|
|
838
|
-
min: -
|
|
839
|
-
max:
|
|
841
|
+
min: -90,
|
|
842
|
+
max: 90
|
|
840
843
|
})), t.push(...validateOptionalNumber({
|
|
841
844
|
normalized: n,
|
|
842
845
|
field: "yaw",
|
|
@@ -869,8 +872,8 @@ function focusToPoint(e) {
|
|
|
869
872
|
field: "pitch",
|
|
870
873
|
value: e.pitch,
|
|
871
874
|
defaultValue: 0,
|
|
872
|
-
min: -
|
|
873
|
-
max:
|
|
875
|
+
min: -90,
|
|
876
|
+
max: 90
|
|
874
877
|
})), t.push(...validateOptionalNumber({
|
|
875
878
|
normalized: n,
|
|
876
879
|
field: "yaw",
|
|
@@ -942,8 +945,8 @@ function aroundMode(e = {}) {
|
|
|
942
945
|
field: "pitch",
|
|
943
946
|
value: e.pitch,
|
|
944
947
|
defaultValue: 0,
|
|
945
|
-
min: -
|
|
946
|
-
max:
|
|
948
|
+
min: -90,
|
|
949
|
+
max: 90
|
|
947
950
|
})), t.push(...validateOptionalNumber({
|
|
948
951
|
normalized: n,
|
|
949
952
|
field: "yaw",
|
|
@@ -1017,8 +1020,8 @@ function firstPersonMode(e = {}) {
|
|
|
1017
1020
|
field: "pitch",
|
|
1018
1021
|
value: e.pitch,
|
|
1019
1022
|
defaultValue: 0,
|
|
1020
|
-
min: -
|
|
1021
|
-
max:
|
|
1023
|
+
min: -90,
|
|
1024
|
+
max: 90
|
|
1022
1025
|
})), t.push(...validateOptionalNumber({
|
|
1023
1026
|
normalized: n,
|
|
1024
1027
|
field: "yaw",
|
|
@@ -1084,7 +1087,7 @@ function isEmptyValue(e) {
|
|
|
1084
1087
|
return !!(e == null || e === "" || Array.isArray(e) && e.length === 0);
|
|
1085
1088
|
}
|
|
1086
1089
|
function generateUniqueId$1() {
|
|
1087
|
-
return `marker_${Date.now()}
|
|
1090
|
+
return `marker_${Date.now()}`;
|
|
1088
1091
|
}
|
|
1089
1092
|
function ensureIconStyle(e, t, n) {
|
|
1090
1093
|
let r = e?.[t];
|
|
@@ -1221,7 +1224,39 @@ function validateConfigByMarkerType(e, t) {
|
|
|
1221
1224
|
"anchor4",
|
|
1222
1225
|
"anchor5",
|
|
1223
1226
|
"anchor6"
|
|
1224
|
-
].includes(n) ? validateAnchorConfig(r, t) : n === "html" ? validateHtmlMarkerConfig(r, t) : n === "url" ? validateUrlMarkerConfig(r, t) : validateDefaultConfig(r, t);
|
|
1227
|
+
].includes(n) ? validateAnchorConfig(r, t) : n === "html" ? validateHtmlMarkerConfig(r, t) : n === "url" ? validateUrlMarkerConfig(r, t) : n === "lod" ? validateLodConfig(r, t) : validateDefaultConfig(r, t);
|
|
1228
|
+
}
|
|
1229
|
+
function validateLodConfig(e, t) {
|
|
1230
|
+
if (ensureIconStyle(e, "iconStyle", t), ensureTextStyle(e, "textStyle", t), e.levels === void 0 || e.levels === null) {
|
|
1231
|
+
e.levels = [];
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
if (!Array.isArray(e.levels)) {
|
|
1235
|
+
t.push("[config.levels]必须是数组");
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
e.levels.forEach((e, n) => {
|
|
1239
|
+
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
1240
|
+
t.push(`[config.levels[${n}]]必须是对象`);
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
t.push(...validateOptionalArray({
|
|
1244
|
+
normalized: e,
|
|
1245
|
+
field: "distance",
|
|
1246
|
+
value: normalizeEmptyArray(e.distance),
|
|
1247
|
+
length: 2
|
|
1248
|
+
})), (!Array.isArray(e.distance) || e.distance.length !== 2) && t.push(`[config.levels[${n}].distance]必填,格式为 [min, max]`), t.push(...validateOptionalString({
|
|
1249
|
+
normalized: e,
|
|
1250
|
+
field: "text",
|
|
1251
|
+
value: e.text,
|
|
1252
|
+
defaultValue: ""
|
|
1253
|
+
})), t.push(...validateOptionalString({
|
|
1254
|
+
normalized: e,
|
|
1255
|
+
field: "iconAddress",
|
|
1256
|
+
value: e.iconAddress,
|
|
1257
|
+
defaultValue: ""
|
|
1258
|
+
})), ensureIconStyle(e, "iconStyle", t), ensureTextStyle(e, "textStyle", t);
|
|
1259
|
+
});
|
|
1225
1260
|
}
|
|
1226
1261
|
function validateHtmlMarkerConfig(e, t) {
|
|
1227
1262
|
t.push(...validateOptionalNumber({
|
|
@@ -1538,8 +1573,8 @@ function validateCaptureConfig(e, t) {
|
|
|
1538
1573
|
field: "pitch",
|
|
1539
1574
|
value: e.pitch,
|
|
1540
1575
|
defaultValue: 0,
|
|
1541
|
-
min: -
|
|
1542
|
-
max:
|
|
1576
|
+
min: -90,
|
|
1577
|
+
max: 90
|
|
1543
1578
|
})), t.push(...validateOptionalNumber({
|
|
1544
1579
|
normalized: e,
|
|
1545
1580
|
field: "yaw",
|
|
@@ -1624,7 +1659,7 @@ function iconMarker(e) {
|
|
|
1624
1659
|
defaultValue: 1,
|
|
1625
1660
|
type: "number",
|
|
1626
1661
|
list: [0, 1]
|
|
1627
|
-
})), t.push(...verifyEnumerationValue({
|
|
1662
|
+
})), e.markerState === void 0 || e.markerState === null ? n.markerState = !0 : typeof e.markerState == "boolean" ? n.markerState = e.markerState : t.push("[markerState]必须是布尔类型"), t.push(...verifyEnumerationValue({
|
|
1628
1663
|
normalized: n,
|
|
1629
1664
|
field: "markerType",
|
|
1630
1665
|
value: e.markerType,
|
|
@@ -1635,6 +1670,7 @@ function iconMarker(e) {
|
|
|
1635
1670
|
"default1",
|
|
1636
1671
|
"default2",
|
|
1637
1672
|
"default3",
|
|
1673
|
+
"lod",
|
|
1638
1674
|
"flashIcon",
|
|
1639
1675
|
"component",
|
|
1640
1676
|
"customCom",
|
|
@@ -1693,7 +1729,7 @@ function followMarker(e) {
|
|
|
1693
1729
|
defaultValue: 1,
|
|
1694
1730
|
type: "number",
|
|
1695
1731
|
list: [0, 1]
|
|
1696
|
-
})), t.push(...verifyEnumerationValue({
|
|
1732
|
+
})), e.markerState === void 0 || e.markerState === null ? n.markerState = !0 : typeof e.markerState == "boolean" ? n.markerState = e.markerState : t.push("[markerState]必须是布尔类型"), t.push(...verifyEnumerationValue({
|
|
1697
1733
|
normalized: n,
|
|
1698
1734
|
field: "markerType",
|
|
1699
1735
|
value: e.markerType,
|
|
@@ -1704,6 +1740,7 @@ function followMarker(e) {
|
|
|
1704
1740
|
"default1",
|
|
1705
1741
|
"default2",
|
|
1706
1742
|
"default3",
|
|
1743
|
+
"lod",
|
|
1707
1744
|
"flashIcon",
|
|
1708
1745
|
"component",
|
|
1709
1746
|
"customCom",
|
|
@@ -1745,6 +1782,65 @@ function removeAllMarker(e) {
|
|
|
1745
1782
|
normalized: { ...e }
|
|
1746
1783
|
};
|
|
1747
1784
|
}
|
|
1785
|
+
function removeMarker(e = {}) {
|
|
1786
|
+
let t = [], n = { ...e };
|
|
1787
|
+
return t.push(...validateOptionalArray({
|
|
1788
|
+
normalized: n,
|
|
1789
|
+
field: "groupIds",
|
|
1790
|
+
value: e.groupIds,
|
|
1791
|
+
minLength: 1
|
|
1792
|
+
})), {
|
|
1793
|
+
errors: t,
|
|
1794
|
+
normalized: n
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
function showMarker(e = {}) {
|
|
1798
|
+
let t = [], n = { ...e };
|
|
1799
|
+
return t.push(...validateOptionalArray({
|
|
1800
|
+
normalized: n,
|
|
1801
|
+
field: "groupIds",
|
|
1802
|
+
value: e.groupIds,
|
|
1803
|
+
minLength: 1
|
|
1804
|
+
})), {
|
|
1805
|
+
errors: t,
|
|
1806
|
+
normalized: n
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
function showAllMarker(e = {}) {
|
|
1810
|
+
return {
|
|
1811
|
+
errors: [],
|
|
1812
|
+
normalized: { ...e }
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
function hideMarker(e = {}) {
|
|
1816
|
+
let t = [], n = { ...e };
|
|
1817
|
+
return t.push(...validateOptionalArray({
|
|
1818
|
+
normalized: n,
|
|
1819
|
+
field: "groupIds",
|
|
1820
|
+
value: e.groupIds,
|
|
1821
|
+
minLength: 1
|
|
1822
|
+
})), {
|
|
1823
|
+
errors: t,
|
|
1824
|
+
normalized: n
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
function hideAllMarker(e = {}) {
|
|
1828
|
+
return {
|
|
1829
|
+
errors: [],
|
|
1830
|
+
normalized: { ...e }
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function iconUrlMarker(e = {}) {
|
|
1834
|
+
let t = [], n = { ...e };
|
|
1835
|
+
return t.push(...validateRequiredString({
|
|
1836
|
+
normalized: n,
|
|
1837
|
+
field: "url",
|
|
1838
|
+
value: e.url
|
|
1839
|
+
})), {
|
|
1840
|
+
errors: t,
|
|
1841
|
+
normalized: n
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1748
1844
|
function addClustering(e) {
|
|
1749
1845
|
let t = [], n = { ...e };
|
|
1750
1846
|
t.push(...verifyEnumerationValue({
|
|
@@ -1893,7 +1989,13 @@ function secondMarker(e) {
|
|
|
1893
1989
|
var validator$9 = {
|
|
1894
1990
|
iconMarker,
|
|
1895
1991
|
followMarker,
|
|
1992
|
+
removeMarker,
|
|
1896
1993
|
removeAllMarker,
|
|
1994
|
+
showMarker,
|
|
1995
|
+
showAllMarker,
|
|
1996
|
+
hideMarker,
|
|
1997
|
+
hideAllMarker,
|
|
1998
|
+
iconUrlMarker,
|
|
1897
1999
|
addClustering,
|
|
1898
2000
|
removeClustering,
|
|
1899
2001
|
secondMarker
|
|
@@ -1905,8 +2007,8 @@ var validator$9 = {
|
|
|
1905
2007
|
let n = `marker.${e}`, r = validator$9[e], i = r ? r(t) : {
|
|
1906
2008
|
errors: [],
|
|
1907
2009
|
normalized: t
|
|
1908
|
-
};
|
|
1909
|
-
return this.commandManager.sendWithDefault(i, n);
|
|
2010
|
+
}, a = e === "iconUrlMarker" ? { timeout: 12e4 } : {};
|
|
2011
|
+
return this.commandManager.sendWithDefault(i, n, a);
|
|
1910
2012
|
}
|
|
1911
2013
|
}, validateConfig = (e, t, n) => {
|
|
1912
2014
|
e && (n === "default" || n === "default1" || n === "default2" || n === "default3" || n === "default4" || n === "flashIcon") && (t.push(...validateOptionalColor({
|
|
@@ -1991,8 +2093,8 @@ function cameraFollow(e) {
|
|
|
1991
2093
|
field: "pitch",
|
|
1992
2094
|
value: e.pitch,
|
|
1993
2095
|
defaultValue: 0,
|
|
1994
|
-
min: -
|
|
1995
|
-
max:
|
|
2096
|
+
min: -90,
|
|
2097
|
+
max: 90
|
|
1996
2098
|
})), {
|
|
1997
2099
|
errors: t,
|
|
1998
2100
|
normalized: n
|