@aibee/crc-bmap 0.0.91 → 0.0.93
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/index.css +8 -12
- package/example/index.html +3 -3
- package/example/src/main.ts +0 -1
- package/lib/bmap.cjs.min.js +2 -2
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +355 -51
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +2 -2
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +2 -2
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/bmap.d.ts +8 -6
- package/lib/src/elements/overlay.d.ts +26 -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 EventDispatcher7 } from "three";
|
|
47
|
+
import { EventDispatcher as EventDispatcher7, Vector3 as Vector314 } from "three";
|
|
48
48
|
|
|
49
49
|
// src/utils/timer.ts
|
|
50
50
|
var Timer = class {
|
|
@@ -904,9 +904,11 @@ import { EventDispatcher as EventDispatcher2, Vector3 as Vector35 } from "three"
|
|
|
904
904
|
|
|
905
905
|
// src/elements/overlay.ts
|
|
906
906
|
import { Box3 as Box32, EventDispatcher, Vector3 as Vector34 } from "three";
|
|
907
|
+
import { debounce } from "lodash";
|
|
907
908
|
var defaultOptions2 = {
|
|
908
909
|
autoUpdate: true,
|
|
909
|
-
appendToBody: false
|
|
910
|
+
appendToBody: false,
|
|
911
|
+
autoChangePlacement: false
|
|
910
912
|
};
|
|
911
913
|
var Overlay = class extends EventDispatcher {
|
|
912
914
|
constructor(context, options = {}) {
|
|
@@ -918,8 +920,14 @@ var Overlay = class extends EventDispatcher {
|
|
|
918
920
|
__publicField(this, "clientPos", { x: 0, y: 0 });
|
|
919
921
|
__publicField(this, "visible", true);
|
|
920
922
|
__publicField(this, "options");
|
|
923
|
+
__publicField(this, "placement", "top");
|
|
924
|
+
__publicField(this, "observer", null);
|
|
921
925
|
__publicField(this, "onUpdate", () => {
|
|
922
|
-
this.
|
|
926
|
+
if (this.options.autoChangePlacement) {
|
|
927
|
+
this.usePlacement();
|
|
928
|
+
} else {
|
|
929
|
+
this.updatePosition();
|
|
930
|
+
}
|
|
923
931
|
});
|
|
924
932
|
this.options = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
925
933
|
this.registryEvent();
|
|
@@ -930,13 +938,177 @@ var Overlay = class extends EventDispatcher {
|
|
|
930
938
|
this.context.container.appendChild(this.div);
|
|
931
939
|
}
|
|
932
940
|
}
|
|
941
|
+
initObserver() {
|
|
942
|
+
const observer = new MutationObserver(
|
|
943
|
+
debounce(() => {
|
|
944
|
+
if (this.div) {
|
|
945
|
+
this.usePlacement();
|
|
946
|
+
}
|
|
947
|
+
}, 100)
|
|
948
|
+
);
|
|
949
|
+
observer.observe(this.div, {
|
|
950
|
+
childList: true,
|
|
951
|
+
subtree: true,
|
|
952
|
+
attributes: true
|
|
953
|
+
});
|
|
954
|
+
this.observer = observer;
|
|
955
|
+
}
|
|
956
|
+
getPlacementPosition() {
|
|
957
|
+
const { max, min } = new Box32().setFromObject(this.element);
|
|
958
|
+
const centerX = (max.x + min.x) / 2;
|
|
959
|
+
const centerY = (max.y + min.y) / 2;
|
|
960
|
+
return {
|
|
961
|
+
left: new Vector34(min.x, centerY, max.z),
|
|
962
|
+
leftTop: new Vector34(min.x, max.y, max.z),
|
|
963
|
+
top: new Vector34(centerX, max.y, max.z),
|
|
964
|
+
rightTop: new Vector34(max.x, max.y, max.z),
|
|
965
|
+
right: new Vector34(max.x, centerY, max.z),
|
|
966
|
+
rightBottom: new Vector34(max.x, min.y, max.z),
|
|
967
|
+
bottom: new Vector34(centerX, min.y, max.z),
|
|
968
|
+
leftBottom: new Vector34(min.x, min.y, max.z),
|
|
969
|
+
center: new Vector34(centerX, centerY, max.z)
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
getPlacementScreenPosition() {
|
|
973
|
+
const { width, height } = this.context.clientSize;
|
|
974
|
+
const positions = this.getPlacementPosition();
|
|
975
|
+
return Object.keys(positions).reduce((obj, key) => {
|
|
976
|
+
const { x, y } = vector3ToDevice(
|
|
977
|
+
positions[key],
|
|
978
|
+
this.context.camera,
|
|
979
|
+
width,
|
|
980
|
+
height
|
|
981
|
+
);
|
|
982
|
+
obj[key] = { x, y };
|
|
983
|
+
return obj;
|
|
984
|
+
}, {});
|
|
985
|
+
}
|
|
986
|
+
// 检查是不是溢出了context.container
|
|
987
|
+
// @return true 表示没有溢出
|
|
988
|
+
checkOverflow(max, min) {
|
|
989
|
+
const { width, height } = this.context.clientSize;
|
|
990
|
+
return min.x > 0 && max.x < width && min.y < height && max.y > 0;
|
|
991
|
+
}
|
|
992
|
+
// 计算适用的placement
|
|
993
|
+
getPlacement() {
|
|
994
|
+
const { clientWidth, clientHeight } = this.div;
|
|
995
|
+
const positions = this.getPlacementScreenPosition();
|
|
996
|
+
const halfWidth = clientWidth / 2;
|
|
997
|
+
const halfHeight = clientHeight / 2;
|
|
998
|
+
const placements = [
|
|
999
|
+
{
|
|
1000
|
+
type: "center",
|
|
1001
|
+
getBox(x, y) {
|
|
1002
|
+
return {
|
|
1003
|
+
max: { x: halfWidth + x, y: y - clientHeight },
|
|
1004
|
+
min: { x: x - halfWidth, y }
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
type: "left",
|
|
1010
|
+
getBox(x, y) {
|
|
1011
|
+
return {
|
|
1012
|
+
max: { x, y: y - halfHeight },
|
|
1013
|
+
min: { x: x - clientWidth, y: y + halfHeight }
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
type: "leftTop",
|
|
1019
|
+
getBox(x, y) {
|
|
1020
|
+
return {
|
|
1021
|
+
max: { x, y: y - clientHeight },
|
|
1022
|
+
min: { x: x - clientWidth, y }
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
type: "top",
|
|
1028
|
+
getBox(x, y) {
|
|
1029
|
+
return {
|
|
1030
|
+
max: { x: x + halfWidth, y: y - clientHeight },
|
|
1031
|
+
min: { x: x - halfWidth, y }
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
type: "rightTop",
|
|
1037
|
+
getBox(x, y) {
|
|
1038
|
+
return {
|
|
1039
|
+
max: { x: x + clientWidth, y: y - clientHeight },
|
|
1040
|
+
min: { x, y }
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
{
|
|
1045
|
+
type: "right",
|
|
1046
|
+
getBox(x, y) {
|
|
1047
|
+
return {
|
|
1048
|
+
max: { x: x + clientWidth, y: y - halfHeight },
|
|
1049
|
+
min: { x, y: y + halfHeight }
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
type: "rightBottom",
|
|
1055
|
+
getBox(x, y) {
|
|
1056
|
+
return {
|
|
1057
|
+
max: { x: x + clientWidth, y },
|
|
1058
|
+
min: { x, y: y + clientHeight }
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
type: "bottom",
|
|
1064
|
+
getBox(x, y) {
|
|
1065
|
+
return {
|
|
1066
|
+
max: { x: x + halfWidth, y },
|
|
1067
|
+
min: { x: x - halfWidth, y: y + clientHeight }
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
type: "leftBottom",
|
|
1073
|
+
getBox(x, y) {
|
|
1074
|
+
return {
|
|
1075
|
+
max: { x, y },
|
|
1076
|
+
min: { x: x - clientWidth, y: y + halfHeight }
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
];
|
|
1081
|
+
for (let i = 0; i < placements.length; i++) {
|
|
1082
|
+
const placement = placements[i];
|
|
1083
|
+
const position = positions[placement.type];
|
|
1084
|
+
const { max, min } = placement.getBox(position.x, position.y);
|
|
1085
|
+
if (this.checkOverflow(max, min)) {
|
|
1086
|
+
return {
|
|
1087
|
+
type: placement.type,
|
|
1088
|
+
position
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return {
|
|
1093
|
+
type: "center",
|
|
1094
|
+
position: positions.center
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
933
1097
|
initDiv() {
|
|
934
1098
|
const div = document.createElement("div");
|
|
935
1099
|
div.style.position = "absolute";
|
|
936
1100
|
return div;
|
|
937
1101
|
}
|
|
1102
|
+
usePlacement() {
|
|
1103
|
+
const placement = this.getPlacement();
|
|
1104
|
+
this.div.className = `overlay_${placement.type}`;
|
|
1105
|
+
this._updatePosition(placement.position.x, placement.position.y);
|
|
1106
|
+
}
|
|
938
1107
|
bindElement(element) {
|
|
939
1108
|
this.element = element;
|
|
1109
|
+
if (this.options.autoChangePlacement) {
|
|
1110
|
+
this.initObserver();
|
|
1111
|
+
}
|
|
940
1112
|
this.onUpdate();
|
|
941
1113
|
}
|
|
942
1114
|
unBindElement() {
|
|
@@ -969,14 +1141,9 @@ var Overlay = class extends EventDispatcher {
|
|
|
969
1141
|
const { width, height } = this.context.clientSize;
|
|
970
1142
|
return x >= 0 && x <= width && y >= 0 && y <= height;
|
|
971
1143
|
}
|
|
972
|
-
|
|
973
|
-
const vector = this.getPosition();
|
|
974
|
-
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
975
|
-
const { x, y } = vector3ToDevice(vector, this.context.camera, width, height);
|
|
976
|
-
if (this.clientPos.x === x && this.clientPos.y === y && !force) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
1144
|
+
_updatePosition(x, y) {
|
|
979
1145
|
this.clientPos = { x, y };
|
|
1146
|
+
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
980
1147
|
if (this.options.appendToBody) {
|
|
981
1148
|
this.div.style.left = `${clientX}px`;
|
|
982
1149
|
this.div.style.top = `${clientY + height}px`;
|
|
@@ -987,6 +1154,20 @@ var Overlay = class extends EventDispatcher {
|
|
|
987
1154
|
this.dispatchEvent({ type: "update-position", x, y, width, height });
|
|
988
1155
|
}
|
|
989
1156
|
}
|
|
1157
|
+
updatePosition(force = false) {
|
|
1158
|
+
const vector = this.getPosition();
|
|
1159
|
+
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
1160
|
+
const { x, y } = vector3ToDevice(
|
|
1161
|
+
vector,
|
|
1162
|
+
this.context.camera,
|
|
1163
|
+
width,
|
|
1164
|
+
height
|
|
1165
|
+
);
|
|
1166
|
+
if (this.clientPos.x === x && this.clientPos.y === y && !force) {
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
this._updatePosition(x, y);
|
|
1170
|
+
}
|
|
990
1171
|
registryEvent() {
|
|
991
1172
|
this.context.addEventListener("update", this.onUpdate);
|
|
992
1173
|
}
|
|
@@ -994,10 +1175,11 @@ var Overlay = class extends EventDispatcher {
|
|
|
994
1175
|
this.context.removeEventListener("update", this.onUpdate);
|
|
995
1176
|
}
|
|
996
1177
|
dispose() {
|
|
997
|
-
var _a;
|
|
1178
|
+
var _a, _b;
|
|
998
1179
|
this.unRegistryEvent();
|
|
999
1180
|
this.unBindElement();
|
|
1000
|
-
(_a = this.
|
|
1181
|
+
(_a = this.observer) == null ? void 0 : _a.disconnect();
|
|
1182
|
+
(_b = this.div) == null ? void 0 : _b.remove();
|
|
1001
1183
|
this.div = null;
|
|
1002
1184
|
}
|
|
1003
1185
|
};
|
|
@@ -1353,7 +1535,7 @@ var GraphicLayer = class extends Layer {
|
|
|
1353
1535
|
};
|
|
1354
1536
|
|
|
1355
1537
|
// src/layer/poi-layer.ts
|
|
1356
|
-
import { debounce } from "lodash";
|
|
1538
|
+
import { debounce as debounce2 } from "lodash";
|
|
1357
1539
|
var PoiLayer = class extends Layer {
|
|
1358
1540
|
constructor(context) {
|
|
1359
1541
|
super(context);
|
|
@@ -1366,7 +1548,7 @@ var PoiLayer = class extends Layer {
|
|
|
1366
1548
|
});
|
|
1367
1549
|
});
|
|
1368
1550
|
this.registryEvent();
|
|
1369
|
-
this.debounceCollisionDetection =
|
|
1551
|
+
this.debounceCollisionDetection = debounce2(this.collisionDetection, 10);
|
|
1370
1552
|
}
|
|
1371
1553
|
clear(force = false) {
|
|
1372
1554
|
this.pois.forEach((item) => {
|
|
@@ -3036,10 +3218,10 @@ var Context = class extends EventDispatcher6 {
|
|
|
3036
3218
|
const boundingBox = new Box38().setFromObject(object);
|
|
3037
3219
|
this.setPolarAngle(polar, 0);
|
|
3038
3220
|
const { max, min } = boundingBox;
|
|
3039
|
-
const leftTop = new Vector313(min.x, max.y,
|
|
3040
|
-
const rightTop = new Vector313(max.x, max.y,
|
|
3041
|
-
const rightBottom = new Vector313(max.x, min.y,
|
|
3042
|
-
const leftBottom = new Vector313(min.x, min.y,
|
|
3221
|
+
const leftTop = new Vector313(min.x, max.y, max.z);
|
|
3222
|
+
const rightTop = new Vector313(max.x, max.y, max.z);
|
|
3223
|
+
const rightBottom = new Vector313(max.x, min.y, min.z);
|
|
3224
|
+
const leftBottom = new Vector313(min.x, min.y, min.z);
|
|
3043
3225
|
const leftTop2d = vector3ToDevice(leftTop, this.camera, width, height);
|
|
3044
3226
|
const rightTop2d = vector3ToDevice(rightTop, this.camera, width, height);
|
|
3045
3227
|
const leftBottom2d = vector3ToDevice(leftBottom, this.camera, width, height);
|
|
@@ -3054,7 +3236,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
3054
3236
|
const xScale = (width - right - left) / size.x;
|
|
3055
3237
|
const yScale = (height - top - bottom) / size.y;
|
|
3056
3238
|
const scale = Math.min(xScale, yScale);
|
|
3057
|
-
const center2 = new Vector313((max.x + min.x) / 2, (max.y + min.y) / 2,
|
|
3239
|
+
const center2 = new Vector313((max.x + min.x) / 2, (max.y + min.y) / 2, (max.z + min.z) / 2);
|
|
3058
3240
|
return { zoom: scale * this.camera.zoom, center: center2 };
|
|
3059
3241
|
}
|
|
3060
3242
|
/**
|
|
@@ -3207,7 +3389,7 @@ function getConfig(config) {
|
|
|
3207
3389
|
}
|
|
3208
3390
|
|
|
3209
3391
|
// src/bmap.ts
|
|
3210
|
-
import { debounce as
|
|
3392
|
+
import { debounce as debounce3 } from "lodash";
|
|
3211
3393
|
var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
3212
3394
|
MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
|
|
3213
3395
|
MapTypePolar2[MapTypePolar2["D3"] = 1.1] = "D3";
|
|
@@ -3230,8 +3412,11 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3230
3412
|
__publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
|
|
3231
3413
|
__publicField(this, "currentBuildGround", null);
|
|
3232
3414
|
__publicField(this, "observe", null);
|
|
3415
|
+
__publicField(this, "timer", new Timer());
|
|
3233
3416
|
__publicField(this, "onControlChange", () => {
|
|
3234
|
-
const {
|
|
3417
|
+
const {
|
|
3418
|
+
camera: { zoom }
|
|
3419
|
+
} = this.context;
|
|
3235
3420
|
if (zoom !== this.prevCameraZoom) {
|
|
3236
3421
|
this.dispatchEvent({
|
|
3237
3422
|
type: "zoom-change",
|
|
@@ -3287,8 +3472,20 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3287
3472
|
this.context.render();
|
|
3288
3473
|
}
|
|
3289
3474
|
loadGraphics(_0) {
|
|
3290
|
-
return __async(this, arguments, function* ({
|
|
3291
|
-
|
|
3475
|
+
return __async(this, arguments, function* ({
|
|
3476
|
+
brand,
|
|
3477
|
+
project,
|
|
3478
|
+
phase,
|
|
3479
|
+
building,
|
|
3480
|
+
floor,
|
|
3481
|
+
ts,
|
|
3482
|
+
resource_type_list
|
|
3483
|
+
}) {
|
|
3484
|
+
const {
|
|
3485
|
+
apiDomain,
|
|
3486
|
+
apiPath: { floorGraphic },
|
|
3487
|
+
apiInfo
|
|
3488
|
+
} = this.config;
|
|
3292
3489
|
const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
|
|
3293
3490
|
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3294
3491
|
(res || []).map((item) => item.info = JSON.parse(item.info));
|
|
@@ -3297,17 +3494,31 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3297
3494
|
return data;
|
|
3298
3495
|
});
|
|
3299
3496
|
}
|
|
3300
|
-
getBuildingKey({
|
|
3497
|
+
getBuildingKey({
|
|
3498
|
+
brand,
|
|
3499
|
+
project,
|
|
3500
|
+
phase,
|
|
3501
|
+
building
|
|
3502
|
+
}) {
|
|
3301
3503
|
const key = `${brand}-${project}-${phase}-${building}`;
|
|
3302
3504
|
return key;
|
|
3303
3505
|
}
|
|
3304
3506
|
loadBuildingGround(_0) {
|
|
3305
|
-
return __async(this, arguments, function* ({
|
|
3507
|
+
return __async(this, arguments, function* ({
|
|
3508
|
+
brand,
|
|
3509
|
+
project,
|
|
3510
|
+
phase,
|
|
3511
|
+
building
|
|
3512
|
+
}) {
|
|
3306
3513
|
const key = this.getBuildingKey({ brand, project, phase, building });
|
|
3307
3514
|
if (this.buildingGroundMap.get(key)) {
|
|
3308
3515
|
return this.buildingGroundMap.get(key) || null;
|
|
3309
3516
|
}
|
|
3310
|
-
const {
|
|
3517
|
+
const {
|
|
3518
|
+
apiDomain,
|
|
3519
|
+
apiPath: { floorRange },
|
|
3520
|
+
apiInfo
|
|
3521
|
+
} = this.config;
|
|
3311
3522
|
const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${phase}&building=${building}`;
|
|
3312
3523
|
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3313
3524
|
const data2 = (res || [])[0];
|
|
@@ -3320,24 +3531,60 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3320
3531
|
return data;
|
|
3321
3532
|
});
|
|
3322
3533
|
}
|
|
3323
|
-
getFloorKey({
|
|
3534
|
+
getFloorKey({
|
|
3535
|
+
brand,
|
|
3536
|
+
project,
|
|
3537
|
+
phase,
|
|
3538
|
+
building,
|
|
3539
|
+
floor,
|
|
3540
|
+
ts,
|
|
3541
|
+
resource_type_list
|
|
3542
|
+
}) {
|
|
3324
3543
|
const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}-${resource_type_list}`;
|
|
3325
3544
|
return floorKey;
|
|
3326
3545
|
}
|
|
3327
3546
|
load(_0) {
|
|
3328
|
-
return __async(this, arguments, function* ({
|
|
3329
|
-
|
|
3547
|
+
return __async(this, arguments, function* ({
|
|
3548
|
+
brand,
|
|
3549
|
+
project,
|
|
3550
|
+
phase,
|
|
3551
|
+
building,
|
|
3552
|
+
floor,
|
|
3553
|
+
ts,
|
|
3554
|
+
resource_type_list
|
|
3555
|
+
}) {
|
|
3556
|
+
const floorKey = this.getFloorKey({
|
|
3557
|
+
brand,
|
|
3558
|
+
project,
|
|
3559
|
+
phase,
|
|
3560
|
+
building,
|
|
3561
|
+
floor,
|
|
3562
|
+
ts,
|
|
3563
|
+
resource_type_list
|
|
3564
|
+
});
|
|
3330
3565
|
if (this.floorDataMap.get(floorKey)) {
|
|
3331
3566
|
return;
|
|
3332
3567
|
}
|
|
3333
3568
|
const [data, buildGround] = yield Promise.all([
|
|
3334
|
-
this.loadGraphics({
|
|
3569
|
+
this.loadGraphics({
|
|
3570
|
+
brand,
|
|
3571
|
+
project,
|
|
3572
|
+
phase,
|
|
3573
|
+
building,
|
|
3574
|
+
floor,
|
|
3575
|
+
ts,
|
|
3576
|
+
resource_type_list
|
|
3577
|
+
}),
|
|
3335
3578
|
this.loadBuildingGround({ brand, project, phase, building })
|
|
3336
3579
|
]);
|
|
3337
3580
|
if (buildGround) {
|
|
3338
|
-
const center2 = getCenter(
|
|
3581
|
+
const center2 = getCenter(
|
|
3582
|
+
buildGround.info.geometry.cds[0]
|
|
3583
|
+
);
|
|
3339
3584
|
data.forEach((item) => {
|
|
3340
|
-
item.info.geometry.coords = JSON.parse(
|
|
3585
|
+
item.info.geometry.coords = JSON.parse(
|
|
3586
|
+
JSON.stringify(item.info.geometry.cds)
|
|
3587
|
+
);
|
|
3341
3588
|
if (item.info.geometry.type === "polygon") {
|
|
3342
3589
|
item.info.geometry.coords.map((cds) => {
|
|
3343
3590
|
if (Array.isArray(cds)) {
|
|
@@ -3410,12 +3657,33 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3410
3657
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
3411
3658
|
return { curFloor, graphics };
|
|
3412
3659
|
}
|
|
3413
|
-
switchFloor({
|
|
3414
|
-
|
|
3660
|
+
switchFloor({
|
|
3661
|
+
brand,
|
|
3662
|
+
project,
|
|
3663
|
+
phase,
|
|
3664
|
+
building,
|
|
3665
|
+
floor,
|
|
3666
|
+
ts,
|
|
3667
|
+
resource_type_list
|
|
3668
|
+
}) {
|
|
3669
|
+
const floorKey = this.getFloorKey({
|
|
3670
|
+
brand,
|
|
3671
|
+
project,
|
|
3672
|
+
phase,
|
|
3673
|
+
building,
|
|
3674
|
+
floor,
|
|
3675
|
+
ts,
|
|
3676
|
+
resource_type_list
|
|
3677
|
+
});
|
|
3415
3678
|
const curFloorData = this.floorDataMap.get(floorKey);
|
|
3416
3679
|
this.context.control.removeEventListener("change", this.onControlChange);
|
|
3417
3680
|
if (curFloorData) {
|
|
3418
|
-
const buildingKey = this.getBuildingKey({
|
|
3681
|
+
const buildingKey = this.getBuildingKey({
|
|
3682
|
+
brand,
|
|
3683
|
+
project,
|
|
3684
|
+
phase,
|
|
3685
|
+
building
|
|
3686
|
+
});
|
|
3419
3687
|
this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
|
|
3420
3688
|
const createdFloor = this.createFloor(curFloorData);
|
|
3421
3689
|
if (createdFloor) {
|
|
@@ -3439,7 +3707,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3439
3707
|
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
3440
3708
|
}
|
|
3441
3709
|
} else {
|
|
3442
|
-
console.warn(
|
|
3710
|
+
console.warn(
|
|
3711
|
+
"[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42"
|
|
3712
|
+
);
|
|
3443
3713
|
}
|
|
3444
3714
|
}
|
|
3445
3715
|
// 扶梯
|
|
@@ -3451,7 +3721,11 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3451
3721
|
id: graphic.options.id
|
|
3452
3722
|
}));
|
|
3453
3723
|
if (model) {
|
|
3454
|
-
const {
|
|
3724
|
+
const {
|
|
3725
|
+
facilityAngle = 0,
|
|
3726
|
+
facilityXScale = 1,
|
|
3727
|
+
facilityYScale = 1
|
|
3728
|
+
} = graphic.options.userData;
|
|
3455
3729
|
model.rotateZ((180 - facilityAngle) / 180 * Math.PI);
|
|
3456
3730
|
model.scale.set(facilityXScale, facilityYScale, 1);
|
|
3457
3731
|
}
|
|
@@ -3467,11 +3741,13 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3467
3741
|
}
|
|
3468
3742
|
/**
|
|
3469
3743
|
* 获取当前楼层全部的graphic
|
|
3470
|
-
* @returns
|
|
3744
|
+
* @returns
|
|
3471
3745
|
*/
|
|
3472
3746
|
getFloorAllGraphics() {
|
|
3473
3747
|
var _a;
|
|
3474
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.children.filter(
|
|
3748
|
+
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.children.filter(
|
|
3749
|
+
(item) => item instanceof Graphic
|
|
3750
|
+
)) || [];
|
|
3475
3751
|
}
|
|
3476
3752
|
createGraphicPoi(graphic, options) {
|
|
3477
3753
|
if (this.context.currentFloor) {
|
|
@@ -3506,11 +3782,25 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3506
3782
|
*/
|
|
3507
3783
|
translateElementToCenterX(ele, duration = 500) {
|
|
3508
3784
|
return __async(this, null, function* () {
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3785
|
+
return timeoutPromise(new Promise((resolve) => {
|
|
3786
|
+
const target = this.context.control.target.clone();
|
|
3787
|
+
const position = ele.getPosition();
|
|
3788
|
+
this.timer.requestAnimationFrame(() => {
|
|
3789
|
+
const {
|
|
3790
|
+
clientSize: { width, height },
|
|
3791
|
+
camera
|
|
3792
|
+
} = this.context;
|
|
3793
|
+
console.log("width", width, height);
|
|
3794
|
+
const device = vector3ToDevice(position, camera, width, height);
|
|
3795
|
+
const offsetX = device.x - width / 2;
|
|
3796
|
+
const v3 = new Vector314();
|
|
3797
|
+
v3.setFromMatrixColumn(this.context.camera.matrix, 0);
|
|
3798
|
+
v3.normalize();
|
|
3799
|
+
v3.multiplyScalar(offsetX / this.context.camera.zoom);
|
|
3800
|
+
target.add(v3);
|
|
3801
|
+
this.context.setCameraPosition(target, duration).then(resolve);
|
|
3802
|
+
});
|
|
3803
|
+
}), duration + 500);
|
|
3514
3804
|
});
|
|
3515
3805
|
}
|
|
3516
3806
|
/**
|
|
@@ -3542,9 +3832,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3542
3832
|
resetView(duration = 300) {
|
|
3543
3833
|
return __async(this, null, function* () {
|
|
3544
3834
|
const time = duration / 3;
|
|
3545
|
-
yield this.context.setAzimuthalAngle(
|
|
3835
|
+
yield this.context.setAzimuthalAngle(
|
|
3836
|
+
this.config.control.defaultAzimuthal,
|
|
3837
|
+
time
|
|
3838
|
+
);
|
|
3546
3839
|
yield this.changeMapType(this.type, time);
|
|
3547
|
-
yield this.context.fitCameraToGround(
|
|
3840
|
+
yield this.context.fitCameraToGround(
|
|
3841
|
+
this.config.defaultPadding,
|
|
3842
|
+
time,
|
|
3843
|
+
false
|
|
3844
|
+
);
|
|
3548
3845
|
});
|
|
3549
3846
|
}
|
|
3550
3847
|
/**
|
|
@@ -3579,7 +3876,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3579
3876
|
window.addEventListener("keydown", this.onKeydown);
|
|
3580
3877
|
window.addEventListener("keyup", this.onKeyUp);
|
|
3581
3878
|
if (this.config.resizeObserver) {
|
|
3582
|
-
const observe = new ResizeObserver(
|
|
3879
|
+
const observe = new ResizeObserver(debounce3(this.resize, 5));
|
|
3583
3880
|
observe.observe(this.container);
|
|
3584
3881
|
this.observe = observe;
|
|
3585
3882
|
}
|
|
@@ -3609,7 +3906,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3609
3906
|
}
|
|
3610
3907
|
/**
|
|
3611
3908
|
* 测量距离
|
|
3612
|
-
* @returns
|
|
3909
|
+
* @returns
|
|
3613
3910
|
*/
|
|
3614
3911
|
measureDistance() {
|
|
3615
3912
|
return __async(this, null, function* () {
|
|
@@ -3683,9 +3980,13 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3683
3980
|
var _a;
|
|
3684
3981
|
if (!options.transformToBuildingGround) {
|
|
3685
3982
|
if (this.currentBuildGround) {
|
|
3686
|
-
const center2 = getCenter(
|
|
3983
|
+
const center2 = getCenter(
|
|
3984
|
+
this.currentBuildGround.info.geometry.cds[0]
|
|
3985
|
+
);
|
|
3687
3986
|
if (options.geometry.type === "polygon") {
|
|
3688
|
-
options.geometry.coords = JSON.parse(
|
|
3987
|
+
options.geometry.coords = JSON.parse(
|
|
3988
|
+
JSON.stringify(options.geometry.cds)
|
|
3989
|
+
);
|
|
3689
3990
|
options.geometry.coords.map((cds) => {
|
|
3690
3991
|
if (Array.isArray(cds)) {
|
|
3691
3992
|
cds.forEach((coord) => {
|
|
@@ -3712,7 +4013,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3712
4013
|
}
|
|
3713
4014
|
getPois() {
|
|
3714
4015
|
var _a;
|
|
3715
|
-
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter(
|
|
4016
|
+
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter(
|
|
4017
|
+
(item) => !item.options.built_in
|
|
4018
|
+
);
|
|
3716
4019
|
}
|
|
3717
4020
|
clearPoi() {
|
|
3718
4021
|
if (this.context.currentFloor) {
|
|
@@ -3723,6 +4026,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3723
4026
|
this.context.selection.remove(graphic);
|
|
3724
4027
|
}
|
|
3725
4028
|
dispose() {
|
|
4029
|
+
this.timer.dispose();
|
|
3726
4030
|
this.context.dispose();
|
|
3727
4031
|
this.floorDataMap.clear();
|
|
3728
4032
|
this.buildingGroundMap.clear();
|