@aibee/crc-bmap 0.0.72 → 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/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +65 -41
- 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 +1 -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
|
};
|
|
@@ -902,7 +912,8 @@ var defaultOptions3 = {
|
|
|
902
912
|
icon_opacity: 1,
|
|
903
913
|
icon_border: { color: "#586EE0", width: 0 },
|
|
904
914
|
background: "",
|
|
905
|
-
collision_hide_icon: true
|
|
915
|
+
collision_hide_icon: true,
|
|
916
|
+
built_in: false
|
|
906
917
|
};
|
|
907
918
|
var Poi = class extends EventDispatcher2 {
|
|
908
919
|
constructor(context, options) {
|
|
@@ -980,9 +991,10 @@ var Poi = class extends EventDispatcher2 {
|
|
|
980
991
|
return __async(this, null, function* () {
|
|
981
992
|
yield sleepOnePromise();
|
|
982
993
|
const { width, height } = this.div.getBoundingClientRect();
|
|
994
|
+
const { boxScale } = this.context.config.poi;
|
|
983
995
|
this.size = {
|
|
984
|
-
width: width
|
|
985
|
-
height: height
|
|
996
|
+
width: width * boxScale,
|
|
997
|
+
height: height * boxScale
|
|
986
998
|
};
|
|
987
999
|
});
|
|
988
1000
|
}
|
|
@@ -1214,10 +1226,14 @@ var PoiLayer = class extends Layer {
|
|
|
1214
1226
|
this.registryEvent();
|
|
1215
1227
|
this.debounceCollisionDetection = debounce(this.collisionDetection, 10);
|
|
1216
1228
|
}
|
|
1217
|
-
clear() {
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
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);
|
|
1221
1237
|
return this;
|
|
1222
1238
|
}
|
|
1223
1239
|
createPoi(options) {
|
|
@@ -1265,7 +1281,7 @@ var PoiLayer = class extends Layer {
|
|
|
1265
1281
|
this.pois.unshift(poi);
|
|
1266
1282
|
return;
|
|
1267
1283
|
}
|
|
1268
|
-
if (poi.options.level ===
|
|
1284
|
+
if (poi.options.level === 0) {
|
|
1269
1285
|
this.pois.push(poi);
|
|
1270
1286
|
return;
|
|
1271
1287
|
}
|
|
@@ -1292,7 +1308,13 @@ var PoiLayer = class extends Layer {
|
|
|
1292
1308
|
*/
|
|
1293
1309
|
collisionDetection() {
|
|
1294
1310
|
const range = [];
|
|
1295
|
-
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
|
+
});
|
|
1296
1318
|
pois.forEach((item, index) => {
|
|
1297
1319
|
const { left, right, top, bottom } = item.getBox();
|
|
1298
1320
|
if (index === 0) {
|
|
@@ -1433,7 +1455,7 @@ var Model = class extends Object3D7 {
|
|
|
1433
1455
|
super();
|
|
1434
1456
|
this.context = context;
|
|
1435
1457
|
this.options = options;
|
|
1436
|
-
__publicField(this, "
|
|
1458
|
+
__publicField(this, "poi", null);
|
|
1437
1459
|
__publicField(this, "model", null);
|
|
1438
1460
|
this.position.copy(options.position || new Vector37(0, 0, 0));
|
|
1439
1461
|
this.loadModel();
|
|
@@ -1444,38 +1466,32 @@ var Model = class extends Object3D7 {
|
|
|
1444
1466
|
object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
|
|
1445
1467
|
this.add(object.scene);
|
|
1446
1468
|
this.model = object;
|
|
1447
|
-
this.
|
|
1469
|
+
this.initPoi();
|
|
1448
1470
|
});
|
|
1449
1471
|
}
|
|
1450
|
-
|
|
1451
|
-
var _a
|
|
1472
|
+
initPoi() {
|
|
1473
|
+
var _a;
|
|
1452
1474
|
if (!this.options.icon) {
|
|
1453
1475
|
return;
|
|
1454
1476
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
img.src = this.options.icon;
|
|
1465
|
-
img.style.width = `${w}px`;
|
|
1466
|
-
img.style.height = `${h}px`;
|
|
1467
|
-
overlay.div.appendChild(img);
|
|
1468
|
-
const center2 = box.getCenter(new Vector37());
|
|
1469
|
-
overlay.position = center2;
|
|
1470
|
-
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());
|
|
1471
1486
|
}
|
|
1472
1487
|
}
|
|
1473
1488
|
dispose() {
|
|
1489
|
+
var _a;
|
|
1474
1490
|
dispose(this);
|
|
1475
1491
|
this.model = null;
|
|
1476
|
-
if (this.
|
|
1477
|
-
this.
|
|
1478
|
-
this.
|
|
1492
|
+
if (this.poi) {
|
|
1493
|
+
(_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.removePoi(this.poi);
|
|
1494
|
+
this.poi = null;
|
|
1479
1495
|
}
|
|
1480
1496
|
}
|
|
1481
1497
|
};
|
|
@@ -2462,7 +2478,9 @@ var Context = class extends EventDispatcher6 {
|
|
|
2462
2478
|
__publicField(this, "cameraBound");
|
|
2463
2479
|
__publicField(this, "clientSize", {
|
|
2464
2480
|
width: 0,
|
|
2465
|
-
height: 0
|
|
2481
|
+
height: 0,
|
|
2482
|
+
x: 0,
|
|
2483
|
+
y: 0
|
|
2466
2484
|
});
|
|
2467
2485
|
__publicField(this, "onWindowResize", () => {
|
|
2468
2486
|
const { container, camera, renderer } = this;
|
|
@@ -2475,7 +2493,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2475
2493
|
camera.bottom = -h / 2;
|
|
2476
2494
|
camera.updateProjectionMatrix();
|
|
2477
2495
|
renderer.setSize(w, h);
|
|
2478
|
-
this.resizeClientSize(
|
|
2496
|
+
this.resizeClientSize();
|
|
2479
2497
|
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
2480
2498
|
});
|
|
2481
2499
|
__publicField(this, "onClick", (e) => {
|
|
@@ -2520,10 +2538,13 @@ var Context = class extends EventDispatcher6 {
|
|
|
2520
2538
|
this.resizeClientSize();
|
|
2521
2539
|
this.registryEvent();
|
|
2522
2540
|
}
|
|
2523
|
-
resizeClientSize(
|
|
2541
|
+
resizeClientSize() {
|
|
2542
|
+
const { x, y, width, height } = this.container.getBoundingClientRect();
|
|
2524
2543
|
this.clientSize = {
|
|
2525
2544
|
width: width || this.container.clientWidth,
|
|
2526
|
-
height: height || this.container.clientHeight
|
|
2545
|
+
height: height || this.container.clientHeight,
|
|
2546
|
+
x,
|
|
2547
|
+
y
|
|
2527
2548
|
};
|
|
2528
2549
|
}
|
|
2529
2550
|
init() {
|
|
@@ -2884,6 +2905,9 @@ var defaultConfig = {
|
|
|
2884
2905
|
},
|
|
2885
2906
|
cameraBound: {
|
|
2886
2907
|
padding: [150, 150, 150, 150]
|
|
2908
|
+
},
|
|
2909
|
+
poi: {
|
|
2910
|
+
boxScale: 1
|
|
2887
2911
|
}
|
|
2888
2912
|
};
|
|
2889
2913
|
function getConfig(config) {
|
|
@@ -3392,7 +3416,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3392
3416
|
}
|
|
3393
3417
|
getPois() {
|
|
3394
3418
|
var _a;
|
|
3395
|
-
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);
|
|
3396
3420
|
}
|
|
3397
3421
|
clearPoi() {
|
|
3398
3422
|
if (this.context.currentFloor) {
|