@aibee/crc-bmap 0.0.72 → 0.0.74
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 -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/bmap.d.ts +1 -1
- 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
|
}
|
|
@@ -1433,7 +1449,7 @@ var Model = class extends Object3D7 {
|
|
|
1433
1449
|
super();
|
|
1434
1450
|
this.context = context;
|
|
1435
1451
|
this.options = options;
|
|
1436
|
-
__publicField(this, "
|
|
1452
|
+
__publicField(this, "poi", null);
|
|
1437
1453
|
__publicField(this, "model", null);
|
|
1438
1454
|
this.position.copy(options.position || new Vector37(0, 0, 0));
|
|
1439
1455
|
this.loadModel();
|
|
@@ -1444,38 +1460,32 @@ var Model = class extends Object3D7 {
|
|
|
1444
1460
|
object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
|
|
1445
1461
|
this.add(object.scene);
|
|
1446
1462
|
this.model = object;
|
|
1447
|
-
this.
|
|
1463
|
+
this.initPoi();
|
|
1448
1464
|
});
|
|
1449
1465
|
}
|
|
1450
|
-
|
|
1451
|
-
var _a
|
|
1466
|
+
initPoi() {
|
|
1467
|
+
var _a;
|
|
1452
1468
|
if (!this.options.icon) {
|
|
1453
1469
|
return;
|
|
1454
1470
|
}
|
|
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;
|
|
1471
|
+
const poi = (_a = this.context.currentFloor) == null ? void 0 : _a.addPoi({
|
|
1472
|
+
icon: this.options.icon,
|
|
1473
|
+
icon_size: this.options.icon_size,
|
|
1474
|
+
built_in: true,
|
|
1475
|
+
level: 0
|
|
1476
|
+
});
|
|
1477
|
+
this.poi = poi || null;
|
|
1478
|
+
if (this.model && poi) {
|
|
1479
|
+
poi.position = new Box34().setFromObject(this).getCenter(new Vector37());
|
|
1471
1480
|
}
|
|
1472
1481
|
}
|
|
1473
1482
|
dispose() {
|
|
1483
|
+
var _a;
|
|
1474
1484
|
dispose(this);
|
|
1475
1485
|
this.model = null;
|
|
1476
|
-
if (this.
|
|
1477
|
-
this.
|
|
1478
|
-
this.
|
|
1486
|
+
if (this.poi) {
|
|
1487
|
+
(_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.removePoi(this.poi);
|
|
1488
|
+
this.poi = null;
|
|
1479
1489
|
}
|
|
1480
1490
|
}
|
|
1481
1491
|
};
|
|
@@ -2462,7 +2472,9 @@ var Context = class extends EventDispatcher6 {
|
|
|
2462
2472
|
__publicField(this, "cameraBound");
|
|
2463
2473
|
__publicField(this, "clientSize", {
|
|
2464
2474
|
width: 0,
|
|
2465
|
-
height: 0
|
|
2475
|
+
height: 0,
|
|
2476
|
+
x: 0,
|
|
2477
|
+
y: 0
|
|
2466
2478
|
});
|
|
2467
2479
|
__publicField(this, "onWindowResize", () => {
|
|
2468
2480
|
const { container, camera, renderer } = this;
|
|
@@ -2475,7 +2487,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2475
2487
|
camera.bottom = -h / 2;
|
|
2476
2488
|
camera.updateProjectionMatrix();
|
|
2477
2489
|
renderer.setSize(w, h);
|
|
2478
|
-
this.resizeClientSize(
|
|
2490
|
+
this.resizeClientSize();
|
|
2479
2491
|
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
2480
2492
|
});
|
|
2481
2493
|
__publicField(this, "onClick", (e) => {
|
|
@@ -2520,10 +2532,13 @@ var Context = class extends EventDispatcher6 {
|
|
|
2520
2532
|
this.resizeClientSize();
|
|
2521
2533
|
this.registryEvent();
|
|
2522
2534
|
}
|
|
2523
|
-
resizeClientSize(
|
|
2535
|
+
resizeClientSize() {
|
|
2536
|
+
const { x, y, width, height } = this.container.getBoundingClientRect();
|
|
2524
2537
|
this.clientSize = {
|
|
2525
2538
|
width: width || this.container.clientWidth,
|
|
2526
|
-
height: height || this.container.clientHeight
|
|
2539
|
+
height: height || this.container.clientHeight,
|
|
2540
|
+
x,
|
|
2541
|
+
y
|
|
2527
2542
|
};
|
|
2528
2543
|
}
|
|
2529
2544
|
init() {
|
|
@@ -2884,6 +2899,9 @@ var defaultConfig = {
|
|
|
2884
2899
|
},
|
|
2885
2900
|
cameraBound: {
|
|
2886
2901
|
padding: [150, 150, 150, 150]
|
|
2902
|
+
},
|
|
2903
|
+
poi: {
|
|
2904
|
+
boxScale: 1
|
|
2887
2905
|
}
|
|
2888
2906
|
};
|
|
2889
2907
|
function getConfig(config) {
|
|
@@ -3188,11 +3206,13 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3188
3206
|
* @param duration
|
|
3189
3207
|
*/
|
|
3190
3208
|
translateElementToCenterX(ele, duration = 500) {
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3209
|
+
return __async(this, null, function* () {
|
|
3210
|
+
const { y, z } = this.context.control.target;
|
|
3211
|
+
const position = ele.getPosition();
|
|
3212
|
+
position.setY(y);
|
|
3213
|
+
position.setZ(z);
|
|
3214
|
+
yield this.context.setCameraPosition(position, duration);
|
|
3215
|
+
});
|
|
3196
3216
|
}
|
|
3197
3217
|
/**
|
|
3198
3218
|
* 获取物体的屏幕坐标
|
|
@@ -3392,7 +3412,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3392
3412
|
}
|
|
3393
3413
|
getPois() {
|
|
3394
3414
|
var _a;
|
|
3395
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || [];
|
|
3415
|
+
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter((item) => !item.options.built_in);
|
|
3396
3416
|
}
|
|
3397
3417
|
clearPoi() {
|
|
3398
3418
|
if (this.context.currentFloor) {
|