@aibee/crc-bmap 0.0.71 → 0.0.73
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/example/src/main.ts +2 -2
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +79 -45
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +1 -1
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/config.d.ts +3 -0
- package/lib/src/context.d.ts +3 -1
- package/lib/src/elements/model.d.ts +3 -3
- package/lib/src/elements/overlay.d.ts +1 -0
- package/lib/src/elements/poi.d.ts +3 -0
- package/lib/src/layer/poi-layer.d.ts +1 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -807,7 +807,8 @@ import { EventDispatcher as EventDispatcher2, Vector3 as Vector35 } from "three"
|
|
|
807
807
|
// src/elements/overlay.ts
|
|
808
808
|
import { Box3 as Box32, EventDispatcher, Vector3 as Vector34 } from "three";
|
|
809
809
|
var defaultOptions2 = {
|
|
810
|
-
autoUpdate: true
|
|
810
|
+
autoUpdate: true,
|
|
811
|
+
appendToBody: false
|
|
811
812
|
};
|
|
812
813
|
var Overlay = class extends EventDispatcher {
|
|
813
814
|
constructor(context, options = {}) {
|
|
@@ -821,12 +822,16 @@ var Overlay = class extends EventDispatcher {
|
|
|
821
822
|
__publicField(this, "options");
|
|
822
823
|
__publicField(this, "onUpdate", () => {
|
|
823
824
|
const vector = this.getPosition();
|
|
824
|
-
const { width, height } = this.context.clientSize;
|
|
825
|
+
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
825
826
|
const { x, y } = vector3ToDevice(vector, this.context.camera, width, height);
|
|
826
827
|
if (this.clientPos.x === x && this.clientPos.y === y) {
|
|
827
828
|
return;
|
|
828
829
|
}
|
|
829
830
|
this.clientPos = { x, y };
|
|
831
|
+
if (this.options.appendToBody) {
|
|
832
|
+
this.div.style.left = `${clientX}px`;
|
|
833
|
+
this.div.style.top = `${clientY + height}px`;
|
|
834
|
+
}
|
|
830
835
|
if (this.options.autoUpdate) {
|
|
831
836
|
this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
|
|
832
837
|
} else {
|
|
@@ -836,7 +841,11 @@ var Overlay = class extends EventDispatcher {
|
|
|
836
841
|
this.options = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
837
842
|
this.registryEvent();
|
|
838
843
|
this.div = this.initDiv();
|
|
839
|
-
this.
|
|
844
|
+
if (this.options.appendToBody) {
|
|
845
|
+
document.body.appendChild(this.div);
|
|
846
|
+
} else {
|
|
847
|
+
this.context.container.appendChild(this.div);
|
|
848
|
+
}
|
|
840
849
|
}
|
|
841
850
|
initDiv() {
|
|
842
851
|
const div = document.createElement("div");
|
|
@@ -884,9 +893,10 @@ var Overlay = class extends EventDispatcher {
|
|
|
884
893
|
this.context.removeEventListener("update", this.onUpdate);
|
|
885
894
|
}
|
|
886
895
|
dispose() {
|
|
896
|
+
var _a;
|
|
887
897
|
this.unRegistryEvent();
|
|
888
898
|
this.unBindElement();
|
|
889
|
-
this.div
|
|
899
|
+
(_a = this.div) == null ? void 0 : _a.remove();
|
|
890
900
|
this.div = null;
|
|
891
901
|
}
|
|
892
902
|
};
|
|
@@ -901,7 +911,9 @@ var defaultOptions3 = {
|
|
|
901
911
|
position: { x: 0, y: 0, z: 0 },
|
|
902
912
|
icon_opacity: 1,
|
|
903
913
|
icon_border: { color: "#586EE0", width: 0 },
|
|
904
|
-
background: ""
|
|
914
|
+
background: "",
|
|
915
|
+
collision_hide_icon: true,
|
|
916
|
+
built_in: false
|
|
905
917
|
};
|
|
906
918
|
var Poi = class extends EventDispatcher2 {
|
|
907
919
|
constructor(context, options) {
|
|
@@ -917,6 +929,7 @@ var Poi = class extends EventDispatcher2 {
|
|
|
917
929
|
__publicField(this, "size", { width: 0, height: 0 });
|
|
918
930
|
__publicField(this, "position", new Vector35());
|
|
919
931
|
__publicField(this, "userData", {});
|
|
932
|
+
__publicField(this, "showTextStatus", true);
|
|
920
933
|
__publicField(this, "_changePosition", () => {
|
|
921
934
|
});
|
|
922
935
|
this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions3), options), this);
|
|
@@ -965,7 +978,6 @@ var Poi = class extends EventDispatcher2 {
|
|
|
965
978
|
this.addEventListener("change-icon_border", ({ value }) => {
|
|
966
979
|
if (this.img) {
|
|
967
980
|
this.img.style.border = `${value.width}px solid ${value.color}`;
|
|
968
|
-
this.resetSize();
|
|
969
981
|
}
|
|
970
982
|
});
|
|
971
983
|
this.addEventListener("change-background", ({ value }) => {
|
|
@@ -979,9 +991,10 @@ var Poi = class extends EventDispatcher2 {
|
|
|
979
991
|
return __async(this, null, function* () {
|
|
980
992
|
yield sleepOnePromise();
|
|
981
993
|
const { width, height } = this.div.getBoundingClientRect();
|
|
994
|
+
const { boxScale } = this.context.config.poi;
|
|
982
995
|
this.size = {
|
|
983
|
-
width: width
|
|
984
|
-
height: height
|
|
996
|
+
width: width * boxScale,
|
|
997
|
+
height: height * boxScale
|
|
985
998
|
};
|
|
986
999
|
});
|
|
987
1000
|
}
|
|
@@ -1071,11 +1084,20 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1071
1084
|
this.changeOverlayVisible(visible);
|
|
1072
1085
|
}
|
|
1073
1086
|
changeOverlayVisible(visible) {
|
|
1074
|
-
if (visible === this.overlay.visible) {
|
|
1087
|
+
if (visible === this.overlay.visible && this.options.collision_hide_icon) {
|
|
1075
1088
|
return;
|
|
1076
1089
|
}
|
|
1077
|
-
this.
|
|
1078
|
-
|
|
1090
|
+
if (this.options.collision_hide_icon) {
|
|
1091
|
+
this.overlay.visible = visible;
|
|
1092
|
+
this.overlay.div.style.visibility = visible ? "visible" : "hidden";
|
|
1093
|
+
} else {
|
|
1094
|
+
if (this.showTextStatus === visible) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
console.log("visible", visible);
|
|
1098
|
+
this.textDiv.style.display = visible ? "block" : "none";
|
|
1099
|
+
this.showTextStatus = visible;
|
|
1100
|
+
}
|
|
1079
1101
|
}
|
|
1080
1102
|
parentSetVisible(visible) {
|
|
1081
1103
|
if (!this.visible) {
|
|
@@ -1204,10 +1226,14 @@ var PoiLayer = class extends Layer {
|
|
|
1204
1226
|
this.registryEvent();
|
|
1205
1227
|
this.debounceCollisionDetection = debounce(this.collisionDetection, 10);
|
|
1206
1228
|
}
|
|
1207
|
-
clear() {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1229
|
+
clear(force = false) {
|
|
1230
|
+
this.pois.forEach((item) => {
|
|
1231
|
+
if (item.options.built_in && !force) {
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
item.dispose();
|
|
1235
|
+
});
|
|
1236
|
+
this.pois = force ? [] : this.pois.filter((item) => item.options.built_in);
|
|
1211
1237
|
return this;
|
|
1212
1238
|
}
|
|
1213
1239
|
createPoi(options) {
|
|
@@ -1255,7 +1281,7 @@ var PoiLayer = class extends Layer {
|
|
|
1255
1281
|
this.pois.unshift(poi);
|
|
1256
1282
|
return;
|
|
1257
1283
|
}
|
|
1258
|
-
if (poi.options.level ===
|
|
1284
|
+
if (poi.options.level === 0) {
|
|
1259
1285
|
this.pois.push(poi);
|
|
1260
1286
|
return;
|
|
1261
1287
|
}
|
|
@@ -1282,7 +1308,13 @@ var PoiLayer = class extends Layer {
|
|
|
1282
1308
|
*/
|
|
1283
1309
|
collisionDetection() {
|
|
1284
1310
|
const range = [];
|
|
1285
|
-
const pois = this.pois.filter((item) =>
|
|
1311
|
+
const pois = this.pois.filter((item) => {
|
|
1312
|
+
if (item.visible && item.withinDisplayRange) {
|
|
1313
|
+
return true;
|
|
1314
|
+
} else {
|
|
1315
|
+
item.parentSetVisible(false);
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1286
1318
|
pois.forEach((item, index) => {
|
|
1287
1319
|
const { left, right, top, bottom } = item.getBox();
|
|
1288
1320
|
if (index === 0) {
|
|
@@ -1423,7 +1455,7 @@ var Model = class extends Object3D7 {
|
|
|
1423
1455
|
super();
|
|
1424
1456
|
this.context = context;
|
|
1425
1457
|
this.options = options;
|
|
1426
|
-
__publicField(this, "
|
|
1458
|
+
__publicField(this, "poi", null);
|
|
1427
1459
|
__publicField(this, "model", null);
|
|
1428
1460
|
this.position.copy(options.position || new Vector37(0, 0, 0));
|
|
1429
1461
|
this.loadModel();
|
|
@@ -1434,38 +1466,32 @@ var Model = class extends Object3D7 {
|
|
|
1434
1466
|
object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
|
|
1435
1467
|
this.add(object.scene);
|
|
1436
1468
|
this.model = object;
|
|
1437
|
-
this.
|
|
1469
|
+
this.initPoi();
|
|
1438
1470
|
});
|
|
1439
1471
|
}
|
|
1440
|
-
|
|
1441
|
-
var _a
|
|
1472
|
+
initPoi() {
|
|
1473
|
+
var _a;
|
|
1442
1474
|
if (!this.options.icon) {
|
|
1443
1475
|
return;
|
|
1444
1476
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
img.src = this.options.icon;
|
|
1455
|
-
img.style.width = `${w}px`;
|
|
1456
|
-
img.style.height = `${h}px`;
|
|
1457
|
-
overlay.div.appendChild(img);
|
|
1458
|
-
const center2 = box.getCenter(new Vector37());
|
|
1459
|
-
overlay.position = center2;
|
|
1460
|
-
this.overlay = overlay;
|
|
1477
|
+
const poi = (_a = this.context.currentFloor) == null ? void 0 : _a.addPoi({
|
|
1478
|
+
icon: this.options.icon,
|
|
1479
|
+
icon_size: this.options.icon_size,
|
|
1480
|
+
built_in: true,
|
|
1481
|
+
level: 0
|
|
1482
|
+
});
|
|
1483
|
+
this.poi = poi || null;
|
|
1484
|
+
if (this.model && poi) {
|
|
1485
|
+
poi.position = new Box34().setFromObject(this).getCenter(new Vector37());
|
|
1461
1486
|
}
|
|
1462
1487
|
}
|
|
1463
1488
|
dispose() {
|
|
1489
|
+
var _a;
|
|
1464
1490
|
dispose(this);
|
|
1465
1491
|
this.model = null;
|
|
1466
|
-
if (this.
|
|
1467
|
-
this.
|
|
1468
|
-
this.
|
|
1492
|
+
if (this.poi) {
|
|
1493
|
+
(_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.removePoi(this.poi);
|
|
1494
|
+
this.poi = null;
|
|
1469
1495
|
}
|
|
1470
1496
|
}
|
|
1471
1497
|
};
|
|
@@ -2452,7 +2478,9 @@ var Context = class extends EventDispatcher6 {
|
|
|
2452
2478
|
__publicField(this, "cameraBound");
|
|
2453
2479
|
__publicField(this, "clientSize", {
|
|
2454
2480
|
width: 0,
|
|
2455
|
-
height: 0
|
|
2481
|
+
height: 0,
|
|
2482
|
+
x: 0,
|
|
2483
|
+
y: 0
|
|
2456
2484
|
});
|
|
2457
2485
|
__publicField(this, "onWindowResize", () => {
|
|
2458
2486
|
const { container, camera, renderer } = this;
|
|
@@ -2465,7 +2493,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2465
2493
|
camera.bottom = -h / 2;
|
|
2466
2494
|
camera.updateProjectionMatrix();
|
|
2467
2495
|
renderer.setSize(w, h);
|
|
2468
|
-
this.resizeClientSize(
|
|
2496
|
+
this.resizeClientSize();
|
|
2469
2497
|
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
2470
2498
|
});
|
|
2471
2499
|
__publicField(this, "onClick", (e) => {
|
|
@@ -2510,10 +2538,13 @@ var Context = class extends EventDispatcher6 {
|
|
|
2510
2538
|
this.resizeClientSize();
|
|
2511
2539
|
this.registryEvent();
|
|
2512
2540
|
}
|
|
2513
|
-
resizeClientSize(
|
|
2541
|
+
resizeClientSize() {
|
|
2542
|
+
const { x, y, width, height } = this.container.getBoundingClientRect();
|
|
2514
2543
|
this.clientSize = {
|
|
2515
2544
|
width: width || this.container.clientWidth,
|
|
2516
|
-
height: height || this.container.clientHeight
|
|
2545
|
+
height: height || this.container.clientHeight,
|
|
2546
|
+
x,
|
|
2547
|
+
y
|
|
2517
2548
|
};
|
|
2518
2549
|
}
|
|
2519
2550
|
init() {
|
|
@@ -2874,6 +2905,9 @@ var defaultConfig = {
|
|
|
2874
2905
|
},
|
|
2875
2906
|
cameraBound: {
|
|
2876
2907
|
padding: [150, 150, 150, 150]
|
|
2908
|
+
},
|
|
2909
|
+
poi: {
|
|
2910
|
+
boxScale: 1
|
|
2877
2911
|
}
|
|
2878
2912
|
};
|
|
2879
2913
|
function getConfig(config) {
|
|
@@ -3382,7 +3416,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3382
3416
|
}
|
|
3383
3417
|
getPois() {
|
|
3384
3418
|
var _a;
|
|
3385
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || [];
|
|
3419
|
+
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter((item) => !item.options.built_in);
|
|
3386
3420
|
}
|
|
3387
3421
|
clearPoi() {
|
|
3388
3422
|
if (this.context.currentFloor) {
|