@aibee/crc-bmap 0.0.48 → 0.0.50
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 +38 -6
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +69 -53
- 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 +4 -2
- package/lib/src/context.d.ts +1 -1
- package/lib/src/elements/poi.d.ts +6 -3
- package/lib/src/layer/poi-layer.d.ts +1 -1
- package/lib/src/utils/sleep.d.ts +1 -0
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -44,7 +44,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/bmap.ts
|
|
47
|
-
import { EventDispatcher as
|
|
47
|
+
import { EventDispatcher as EventDispatcher7 } from "three";
|
|
48
48
|
|
|
49
49
|
// src/utils/timer.ts
|
|
50
50
|
var Timer = class {
|
|
@@ -372,6 +372,11 @@ function setRectPosition(rect, x, y, w, h) {
|
|
|
372
372
|
function sleepOnePromise() {
|
|
373
373
|
return Promise.resolve();
|
|
374
374
|
}
|
|
375
|
+
function sleepOneRf() {
|
|
376
|
+
return new Promise((resolve) => {
|
|
377
|
+
requestAnimationFrame(resolve);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
375
380
|
|
|
376
381
|
// src/utils/color.ts
|
|
377
382
|
function strToNumber(str) {
|
|
@@ -390,9 +395,9 @@ function addAlphaToHexColor(hexColor, alpha) {
|
|
|
390
395
|
|
|
391
396
|
// src/context.ts
|
|
392
397
|
import {
|
|
393
|
-
EventDispatcher as
|
|
398
|
+
EventDispatcher as EventDispatcher6,
|
|
394
399
|
Box2,
|
|
395
|
-
Vector3 as
|
|
400
|
+
Vector3 as Vector39,
|
|
396
401
|
Vector2 as Vector23,
|
|
397
402
|
Raycaster as Raycaster3,
|
|
398
403
|
Box3 as Box36,
|
|
@@ -402,7 +407,7 @@ import {
|
|
|
402
407
|
import { Group as TweenGroup, Tween } from "@tweenjs/tween.js";
|
|
403
408
|
|
|
404
409
|
// src/operations/selection/selection.ts
|
|
405
|
-
import { EventDispatcher as
|
|
410
|
+
import { EventDispatcher as EventDispatcher4 } from "three";
|
|
406
411
|
|
|
407
412
|
// src/elements/graphic.ts
|
|
408
413
|
import {
|
|
@@ -482,10 +487,16 @@ var Graphic = class extends Object3D {
|
|
|
482
487
|
this.init();
|
|
483
488
|
});
|
|
484
489
|
this.addEventListener("change-strokeColor", ({ value }) => {
|
|
490
|
+
if (!this.options.stroke) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
485
493
|
this.initLineMaterial();
|
|
486
494
|
this.createBorder();
|
|
487
495
|
});
|
|
488
496
|
this.addEventListener("change-strokeOpacity", ({ value }) => {
|
|
497
|
+
if (!this.options.stroke) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
489
500
|
this.initLineMaterial();
|
|
490
501
|
this.createBorder();
|
|
491
502
|
});
|
|
@@ -709,7 +720,7 @@ var Shadow = class extends Object3D2 {
|
|
|
709
720
|
};
|
|
710
721
|
|
|
711
722
|
// src/elements/poi.ts
|
|
712
|
-
import {
|
|
723
|
+
import { EventDispatcher as EventDispatcher2, Vector3 as Vector34 } from "three";
|
|
713
724
|
|
|
714
725
|
// src/elements/overlay.ts
|
|
715
726
|
import { Box3 as Box32, EventDispatcher, Vector3 as Vector33 } from "three";
|
|
@@ -730,8 +741,7 @@ var Overlay = class extends EventDispatcher {
|
|
|
730
741
|
return;
|
|
731
742
|
}
|
|
732
743
|
this.clientPos = { x, y };
|
|
733
|
-
this.div.style.
|
|
734
|
-
this.div.style.top = `${y}px`;
|
|
744
|
+
this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
|
|
735
745
|
});
|
|
736
746
|
this.registryEvent();
|
|
737
747
|
this.div = this.initDiv();
|
|
@@ -799,18 +809,20 @@ var defaultOptions2 = {
|
|
|
799
809
|
id: "",
|
|
800
810
|
position: { x: 0, y: 0, z: 0 }
|
|
801
811
|
};
|
|
802
|
-
var Poi = class extends
|
|
812
|
+
var Poi = class extends EventDispatcher2 {
|
|
803
813
|
constructor(context, options) {
|
|
804
814
|
var _a, _b, _c;
|
|
805
815
|
super();
|
|
806
816
|
this.context = context;
|
|
817
|
+
__publicField(this, "div");
|
|
807
818
|
__publicField(this, "textDiv");
|
|
808
819
|
__publicField(this, "img");
|
|
809
820
|
__publicField(this, "overlay");
|
|
810
821
|
__publicField(this, "options");
|
|
811
822
|
__publicField(this, "size", { width: 0, height: 0 });
|
|
823
|
+
__publicField(this, "position", new Vector34());
|
|
812
824
|
__publicField(this, "_changePosition", () => {
|
|
813
|
-
this.
|
|
825
|
+
this.div.style.transform = `translate3d(-50%, ${this.options.icon ? "-100%" : "-50%"}, 0)`;
|
|
814
826
|
});
|
|
815
827
|
this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions2), options), this);
|
|
816
828
|
this.position.set(((_a = options.position) == null ? void 0 : _a.x) || 0, ((_b = options.position) == null ? void 0 : _b.y) || 0, ((_c = options.position) == null ? void 0 : _c.z) || 0);
|
|
@@ -821,19 +833,20 @@ var Poi = class extends Object3D4 {
|
|
|
821
833
|
this.addEventListener("change-icon", ({ value }) => {
|
|
822
834
|
if (value) {
|
|
823
835
|
if (!this.img) {
|
|
824
|
-
this.
|
|
836
|
+
this.div.appendChild(this.initIcon());
|
|
825
837
|
} else {
|
|
826
838
|
this.img.setAttribute("src", value);
|
|
827
839
|
}
|
|
828
840
|
} else {
|
|
829
|
-
this.img && this.
|
|
841
|
+
this.img && this.div.removeChild(this.img);
|
|
830
842
|
this.img = void 0;
|
|
843
|
+
this._changePosition();
|
|
831
844
|
this.resetSize();
|
|
832
845
|
}
|
|
833
846
|
});
|
|
834
847
|
this.addEventListener("change-texts", ({ value }) => {
|
|
835
|
-
this.
|
|
836
|
-
this.
|
|
848
|
+
this.div.removeChild(this.textDiv);
|
|
849
|
+
this.div.appendChild(this.initText());
|
|
837
850
|
this.resetSize();
|
|
838
851
|
});
|
|
839
852
|
this.addEventListener("change-opacity", ({ value }) => {
|
|
@@ -852,24 +865,25 @@ var Poi = class extends Object3D4 {
|
|
|
852
865
|
}
|
|
853
866
|
resetSize() {
|
|
854
867
|
return __async(this, null, function* () {
|
|
855
|
-
const visible = this.overlay.visible;
|
|
856
|
-
this.setVisible(true);
|
|
857
868
|
yield sleepOnePromise();
|
|
858
|
-
const { width, height } = this.
|
|
869
|
+
const { width, height } = this.div.getBoundingClientRect();
|
|
859
870
|
this.size = {
|
|
860
|
-
width,
|
|
861
|
-
height
|
|
871
|
+
width: width + 4,
|
|
872
|
+
height: height + 4
|
|
862
873
|
};
|
|
863
|
-
yield sleepOnePromise();
|
|
864
|
-
this._changePosition();
|
|
865
|
-
this.setVisible(visible);
|
|
866
874
|
});
|
|
867
875
|
}
|
|
876
|
+
renderHelperBox() {
|
|
877
|
+
const div = document.createElement("div");
|
|
878
|
+
const box = this.getBox();
|
|
879
|
+
div.style.cssText = `position: absolute; top: ${box.top}px;left: ${box.left}px;width: ${box.right - box.left}px;height: ${box.bottom - box.top}px;border: 1px solid red;`;
|
|
880
|
+
this.context.container.appendChild(div);
|
|
881
|
+
}
|
|
868
882
|
get clientPos() {
|
|
869
883
|
return this.overlay.clientPos;
|
|
870
884
|
}
|
|
871
885
|
initDiv() {
|
|
872
|
-
const div =
|
|
886
|
+
const div = document.createElement("div");
|
|
873
887
|
div.appendChild(this.initText());
|
|
874
888
|
if (this.options.icon) {
|
|
875
889
|
div.appendChild(this.initIcon());
|
|
@@ -880,9 +894,12 @@ var Poi = class extends Object3D4 {
|
|
|
880
894
|
div.style.flexDirection = `column`;
|
|
881
895
|
div.style.justifyContent = `center`;
|
|
882
896
|
div.style.alignItems = `center`;
|
|
883
|
-
div.style.pointerEvents = `none`;
|
|
884
|
-
div.style.userSelect = `none`;
|
|
885
897
|
this.overlay.setOpacity(this.options.opacity);
|
|
898
|
+
this.overlay.div.style.pointerEvents = `none`;
|
|
899
|
+
this.overlay.div.style.userSelect = `none`;
|
|
900
|
+
this.overlay.div.appendChild(div);
|
|
901
|
+
this.div = div;
|
|
902
|
+
this._changePosition();
|
|
886
903
|
this.resetSize();
|
|
887
904
|
return div;
|
|
888
905
|
}
|
|
@@ -893,11 +910,6 @@ var Poi = class extends Object3D4 {
|
|
|
893
910
|
const textDiv = document.createElement("div");
|
|
894
911
|
textDiv.appendChild(this.createTextFragment());
|
|
895
912
|
if (this.options.texts.length > 1) {
|
|
896
|
-
textDiv.style.background = "rgba(255, 255, 255, .7)";
|
|
897
|
-
textDiv.style.padding = "2px 4px";
|
|
898
|
-
textDiv.style.borderRadius = "4px";
|
|
899
|
-
textDiv.style.fontSize = "12px";
|
|
900
|
-
textDiv.style.lineHeight = "16px";
|
|
901
913
|
}
|
|
902
914
|
this.textDiv = textDiv;
|
|
903
915
|
return textDiv;
|
|
@@ -924,6 +936,7 @@ var Poi = class extends Object3D4 {
|
|
|
924
936
|
img.style.width = `${((_a = this.options.icon_size) == null ? void 0 : _a[0]) || 32}px`;
|
|
925
937
|
img.style.height = `${((_b = this.options.icon_size) == null ? void 0 : _b[1]) || 32}px`;
|
|
926
938
|
img.onload = () => {
|
|
939
|
+
this._changePosition();
|
|
927
940
|
this.resetSize();
|
|
928
941
|
};
|
|
929
942
|
this.img = img;
|
|
@@ -934,7 +947,11 @@ var Poi = class extends Object3D4 {
|
|
|
934
947
|
unRegistryEvent() {
|
|
935
948
|
}
|
|
936
949
|
setVisible(visible) {
|
|
937
|
-
this.overlay.
|
|
950
|
+
if (visible === this.overlay.visible) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
this.overlay.visible = visible;
|
|
954
|
+
this.overlay.div.style.visibility = visible ? "visible" : "hidden";
|
|
938
955
|
}
|
|
939
956
|
getBox() {
|
|
940
957
|
const { width, height } = this.size;
|
|
@@ -955,6 +972,7 @@ var Poi = class extends Object3D4 {
|
|
|
955
972
|
}
|
|
956
973
|
dispose() {
|
|
957
974
|
this.unRegistryEvent();
|
|
975
|
+
this.div = null;
|
|
958
976
|
this.textDiv = null;
|
|
959
977
|
this.img = void 0;
|
|
960
978
|
this.overlay.dispose();
|
|
@@ -962,10 +980,10 @@ var Poi = class extends Object3D4 {
|
|
|
962
980
|
};
|
|
963
981
|
|
|
964
982
|
// src/elements/floor.ts
|
|
965
|
-
import { Box3 as Box34, Object3D as Object3D7, Vector3 as
|
|
983
|
+
import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector36 } from "three";
|
|
966
984
|
|
|
967
985
|
// src/layer/graphic-layer.ts
|
|
968
|
-
import { Box3 as Box33, Vector3 as
|
|
986
|
+
import { Box3 as Box33, Vector3 as Vector35 } from "three";
|
|
969
987
|
|
|
970
988
|
// src/layer/layer.ts
|
|
971
989
|
import { Object3D as Object3D5 } from "three";
|
|
@@ -988,7 +1006,7 @@ var GraphicLayer = class extends Layer {
|
|
|
988
1006
|
}
|
|
989
1007
|
getCenter() {
|
|
990
1008
|
const box = new Box33().setFromObject(this);
|
|
991
|
-
return box.getCenter(new
|
|
1009
|
+
return box.getCenter(new Vector35());
|
|
992
1010
|
}
|
|
993
1011
|
createGraphic(options) {
|
|
994
1012
|
const graphic = new Graphic(this.context, options);
|
|
@@ -1063,7 +1081,6 @@ var PoiLayer = class extends Layer {
|
|
|
1063
1081
|
}
|
|
1064
1082
|
createPoi(options) {
|
|
1065
1083
|
const poi = new Poi(this.context, options);
|
|
1066
|
-
this.add(poi);
|
|
1067
1084
|
this.pushPoi(poi);
|
|
1068
1085
|
poi.addEventListener("change-level", () => this.changePoiLevelOrCollisionEnable(poi));
|
|
1069
1086
|
poi.addEventListener("change-collision_enable", () => this.changePoiLevelOrCollisionEnable(poi));
|
|
@@ -1086,7 +1103,6 @@ var PoiLayer = class extends Layer {
|
|
|
1086
1103
|
return;
|
|
1087
1104
|
}
|
|
1088
1105
|
this.pois.splice(index, 1);
|
|
1089
|
-
this.remove(poi);
|
|
1090
1106
|
poi.dispose();
|
|
1091
1107
|
}
|
|
1092
1108
|
removePoiById(id) {
|
|
@@ -1125,7 +1141,7 @@ var PoiLayer = class extends Layer {
|
|
|
1125
1141
|
this.pois.push(poi);
|
|
1126
1142
|
}
|
|
1127
1143
|
getPoiByDeviceXy(x, y) {
|
|
1128
|
-
const pois = this.
|
|
1144
|
+
const pois = this.pois.filter((item) => {
|
|
1129
1145
|
return item instanceof Poi && item.isContain(x, y);
|
|
1130
1146
|
});
|
|
1131
1147
|
return pois;
|
|
@@ -1134,7 +1150,6 @@ var PoiLayer = class extends Layer {
|
|
|
1134
1150
|
* 碰撞检测
|
|
1135
1151
|
*/
|
|
1136
1152
|
collisionDetection() {
|
|
1137
|
-
const { clientSize: { width, height } } = this.context;
|
|
1138
1153
|
const range = [];
|
|
1139
1154
|
const pois = this.pois.filter((item) => item.withinDisplayRange);
|
|
1140
1155
|
pois.forEach((item, index) => {
|
|
@@ -1308,12 +1323,12 @@ var Floor = class extends Object3D7 {
|
|
|
1308
1323
|
return !!(this.grounds.size || this.graphicLayer.children.length);
|
|
1309
1324
|
}
|
|
1310
1325
|
getCenter() {
|
|
1311
|
-
return new Box34().setFromObject(this.groundUpper).getCenter(new
|
|
1326
|
+
return new Box34().setFromObject(this.groundUpper).getCenter(new Vector36());
|
|
1312
1327
|
}
|
|
1313
1328
|
addShadow() {
|
|
1314
1329
|
const box = new Box34().setFromObject(this.groundUpper);
|
|
1315
|
-
const center2 = box.getCenter(new
|
|
1316
|
-
const size = box.getSize(new
|
|
1330
|
+
const center2 = box.getCenter(new Vector36());
|
|
1331
|
+
const size = box.getSize(new Vector36());
|
|
1317
1332
|
this.shadow.setPosition(center2);
|
|
1318
1333
|
this.shadow.changeLightCamera(size);
|
|
1319
1334
|
this.add(this.shadow);
|
|
@@ -1361,8 +1376,8 @@ var Floor = class extends Object3D7 {
|
|
|
1361
1376
|
};
|
|
1362
1377
|
|
|
1363
1378
|
// src/elements/base-svg.ts
|
|
1364
|
-
import { EventDispatcher as
|
|
1365
|
-
var BaseSvg = class extends
|
|
1379
|
+
import { EventDispatcher as EventDispatcher3, Vector3 as Vector37 } from "three";
|
|
1380
|
+
var BaseSvg = class extends EventDispatcher3 {
|
|
1366
1381
|
constructor(context) {
|
|
1367
1382
|
super();
|
|
1368
1383
|
this.context = context;
|
|
@@ -1386,7 +1401,7 @@ var BaseSvg = class extends EventDispatcher2 {
|
|
|
1386
1401
|
const { clientWidth, clientHeight } = renderer.domElement;
|
|
1387
1402
|
const nx = x / clientWidth * 2 - 1;
|
|
1388
1403
|
const ny = 1 - y / clientHeight * 2;
|
|
1389
|
-
const v = new
|
|
1404
|
+
const v = new Vector37(nx, ny, 0);
|
|
1390
1405
|
return v.unproject(camera);
|
|
1391
1406
|
}
|
|
1392
1407
|
getSvgCoordinate(vector) {
|
|
@@ -1874,7 +1889,7 @@ var BoxSelection = class extends BaseSvg {
|
|
|
1874
1889
|
};
|
|
1875
1890
|
|
|
1876
1891
|
// src/operations/selection/selection.ts
|
|
1877
|
-
var Selection = class extends
|
|
1892
|
+
var Selection = class extends EventDispatcher4 {
|
|
1878
1893
|
constructor(context) {
|
|
1879
1894
|
super();
|
|
1880
1895
|
this.context = context;
|
|
@@ -1974,8 +1989,8 @@ var Selection = class extends EventDispatcher3 {
|
|
|
1974
1989
|
};
|
|
1975
1990
|
|
|
1976
1991
|
// src/operations/hover/hover-helper.ts
|
|
1977
|
-
import { EventDispatcher as
|
|
1978
|
-
var HoverHelper = class extends
|
|
1992
|
+
import { EventDispatcher as EventDispatcher5 } from "three";
|
|
1993
|
+
var HoverHelper = class extends EventDispatcher5 {
|
|
1979
1994
|
constructor(context) {
|
|
1980
1995
|
super();
|
|
1981
1996
|
this.context = context;
|
|
@@ -2096,7 +2111,7 @@ var MaterialFactory = class {
|
|
|
2096
2111
|
};
|
|
2097
2112
|
|
|
2098
2113
|
// src/context.ts
|
|
2099
|
-
var Context = class extends
|
|
2114
|
+
var Context = class extends EventDispatcher6 {
|
|
2100
2115
|
constructor(container, config) {
|
|
2101
2116
|
super();
|
|
2102
2117
|
this.container = container;
|
|
@@ -2198,7 +2213,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
2198
2213
|
/**
|
|
2199
2214
|
* 获取两个点之间的像素数
|
|
2200
2215
|
*/
|
|
2201
|
-
getRatio(point1 = new
|
|
2216
|
+
getRatio(point1 = new Vector39(0, 0, 0), point22 = new Vector39(100, 0, 0)) {
|
|
2202
2217
|
const { clientWidth, clientHeight } = this.container;
|
|
2203
2218
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
2204
2219
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
@@ -2338,7 +2353,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
2338
2353
|
);
|
|
2339
2354
|
}
|
|
2340
2355
|
getCameraLookAt() {
|
|
2341
|
-
return new
|
|
2356
|
+
return new Vector39().subVectors(this.control.target, this.camera.position);
|
|
2342
2357
|
}
|
|
2343
2358
|
/**
|
|
2344
2359
|
* 按照一个中心点设置相机的放大缩小
|
|
@@ -2408,7 +2423,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
2408
2423
|
const xScale = (width - right - left) / size.x;
|
|
2409
2424
|
const yScale = (height - top - bottom) / size.y;
|
|
2410
2425
|
const scale = Math.min(xScale, yScale);
|
|
2411
|
-
const center2 = new
|
|
2426
|
+
const center2 = new Vector39((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
2412
2427
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
2413
2428
|
}
|
|
2414
2429
|
fitCameraToGround(padding = [20, 20, 20, 20], duration = 500) {
|
|
@@ -2509,7 +2524,7 @@ var defaultConfig = {
|
|
|
2509
2524
|
ground: {
|
|
2510
2525
|
color: "#ffffff",
|
|
2511
2526
|
opacity: 1,
|
|
2512
|
-
height:
|
|
2527
|
+
height: 3,
|
|
2513
2528
|
stroke: true,
|
|
2514
2529
|
strokeColor: "#E6E6E6",
|
|
2515
2530
|
strokeOpacity: 1
|
|
@@ -2533,7 +2548,7 @@ var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
|
2533
2548
|
MapTypePolar2[MapTypePolar2["D3"] = 0.9] = "D3";
|
|
2534
2549
|
return MapTypePolar2;
|
|
2535
2550
|
})(MapTypePolar || {});
|
|
2536
|
-
var BMap = class extends
|
|
2551
|
+
var BMap = class extends EventDispatcher7 {
|
|
2537
2552
|
constructor(container, config = {}) {
|
|
2538
2553
|
super();
|
|
2539
2554
|
this.container = container;
|
|
@@ -2768,7 +2783,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2768
2783
|
* @param duration
|
|
2769
2784
|
*/
|
|
2770
2785
|
translateElementToCenter(ele, duration = 500) {
|
|
2771
|
-
const position = ele.
|
|
2786
|
+
const position = ele.getPosition();
|
|
2772
2787
|
return this.context.setCameraPosition(position, duration);
|
|
2773
2788
|
}
|
|
2774
2789
|
/**
|
|
@@ -3030,6 +3045,7 @@ export {
|
|
|
3030
3045
|
setLineStartEnd,
|
|
3031
3046
|
setRectPosition,
|
|
3032
3047
|
sleepOnePromise,
|
|
3048
|
+
sleepOneRf,
|
|
3033
3049
|
strToNumber,
|
|
3034
3050
|
timeoutPromise,
|
|
3035
3051
|
vector3ToDevice
|