@aibee/crc-bmap 0.0.74 → 0.0.76
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 +22 -6
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +92 -50
- 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/context.d.ts +7 -0
- package/lib/src/elements/poi.d.ts +7 -1
- package/lib/src/operations/hover/hover-helper.d.ts +2 -1
- package/lib/src/operations/selection/selection.d.ts +3 -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
|
|
47
|
+
import { EventDispatcher as EventDispatcher7 } from "three";
|
|
48
48
|
|
|
49
49
|
// src/utils/timer.ts
|
|
50
50
|
var Timer = class {
|
|
@@ -991,18 +991,13 @@ var Poi = class extends EventDispatcher2 {
|
|
|
991
991
|
return __async(this, null, function* () {
|
|
992
992
|
yield sleepOnePromise();
|
|
993
993
|
const { width, height } = this.div.getBoundingClientRect();
|
|
994
|
-
const { boxScale } = this.context.config.poi;
|
|
995
994
|
this.size = {
|
|
996
|
-
width: width
|
|
997
|
-
height: height
|
|
995
|
+
width: width + 2,
|
|
996
|
+
height: height + 2
|
|
998
997
|
};
|
|
999
998
|
});
|
|
1000
999
|
}
|
|
1001
1000
|
renderHelperBox() {
|
|
1002
|
-
const div = document.createElement("div");
|
|
1003
|
-
const box = this.getBox();
|
|
1004
|
-
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;`;
|
|
1005
|
-
this.context.container.appendChild(div);
|
|
1006
1001
|
}
|
|
1007
1002
|
get clientPos() {
|
|
1008
1003
|
return this.overlay.clientPos;
|
|
@@ -1025,7 +1020,6 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1025
1020
|
this.overlay.div.style.userSelect = `none`;
|
|
1026
1021
|
this.overlay.div.appendChild(div);
|
|
1027
1022
|
this.div = div;
|
|
1028
|
-
this._changePosition();
|
|
1029
1023
|
this.resetSize();
|
|
1030
1024
|
return div;
|
|
1031
1025
|
}
|
|
@@ -1066,7 +1060,6 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1066
1060
|
img.style.border = `${this.options.icon_border.width}px solid ${this.options.icon_border.color}`;
|
|
1067
1061
|
}
|
|
1068
1062
|
img.onload = () => {
|
|
1069
|
-
this._changePosition();
|
|
1070
1063
|
this.resetSize();
|
|
1071
1064
|
};
|
|
1072
1065
|
this.img = img;
|
|
@@ -1094,8 +1087,7 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1094
1087
|
if (this.showTextStatus === visible) {
|
|
1095
1088
|
return;
|
|
1096
1089
|
}
|
|
1097
|
-
|
|
1098
|
-
this.textDiv.style.display = visible ? "block" : "none";
|
|
1090
|
+
this.textDiv.style.visibility = visible ? "visible" : "hidden";
|
|
1099
1091
|
this.showTextStatus = visible;
|
|
1100
1092
|
}
|
|
1101
1093
|
}
|
|
@@ -1105,21 +1097,29 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1105
1097
|
}
|
|
1106
1098
|
this.changeOverlayVisible(visible);
|
|
1107
1099
|
}
|
|
1108
|
-
getBox() {
|
|
1100
|
+
getBox(boxScale = this.context.config.poi.boxScale) {
|
|
1109
1101
|
const { width, height } = this.size;
|
|
1102
|
+
const w = width * boxScale;
|
|
1103
|
+
const h = height * boxScale;
|
|
1110
1104
|
const { x, y } = this.overlay.clientPos;
|
|
1111
1105
|
return {
|
|
1112
|
-
left: x -
|
|
1113
|
-
right: x +
|
|
1114
|
-
top: this.options.icon ? y -
|
|
1115
|
-
bottom: this.options.icon ? y : y +
|
|
1106
|
+
left: x - w / 2,
|
|
1107
|
+
right: x + w / 2,
|
|
1108
|
+
top: this.options.icon ? y - h : y - h / 2,
|
|
1109
|
+
bottom: this.options.icon ? y : y + h / 2
|
|
1116
1110
|
};
|
|
1117
1111
|
}
|
|
1112
|
+
getOriginBox() {
|
|
1113
|
+
return this.getBox(1);
|
|
1114
|
+
}
|
|
1118
1115
|
isContain(x, y) {
|
|
1119
1116
|
if (!this.overlay.visible) {
|
|
1120
1117
|
return false;
|
|
1121
1118
|
}
|
|
1122
|
-
|
|
1119
|
+
if (!this.visible) {
|
|
1120
|
+
return false;
|
|
1121
|
+
}
|
|
1122
|
+
const box = this.getOriginBox();
|
|
1123
1123
|
return x >= box.left && x <= box.right && y >= box.top && y <= box.bottom;
|
|
1124
1124
|
}
|
|
1125
1125
|
dispose() {
|
|
@@ -2155,29 +2155,24 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2155
2155
|
}
|
|
2156
2156
|
}
|
|
2157
2157
|
});
|
|
2158
|
-
if (!e.ctrlKey) {
|
|
2158
|
+
if (!(isMac ? e.metaKey : e.ctrlKey)) {
|
|
2159
2159
|
this._list.clear();
|
|
2160
2160
|
}
|
|
2161
2161
|
graphics.forEach((item) => this._list.add(item));
|
|
2162
2162
|
this.selectEnd();
|
|
2163
2163
|
this.downPoint = null;
|
|
2164
2164
|
});
|
|
2165
|
+
__publicField(this, "onPointerOut", (e) => {
|
|
2166
|
+
this.disableBoxSelection();
|
|
2167
|
+
});
|
|
2165
2168
|
__publicField(this, "onKeyDown", (e) => {
|
|
2166
2169
|
if (isControl(e.key)) {
|
|
2167
|
-
this.
|
|
2168
|
-
this.boxSelection.setEnable(true);
|
|
2169
|
-
this.prevPanStatus = this.context.control.enablePan;
|
|
2170
|
-
this.prevRotateStatus = this.context.control.enableRotate;
|
|
2171
|
-
this.context.control.enablePan = false;
|
|
2172
|
-
this.context.control.enableRotate = false;
|
|
2170
|
+
this.enableBoxSelection();
|
|
2173
2171
|
}
|
|
2174
2172
|
});
|
|
2175
2173
|
__publicField(this, "onKeyUp", (e) => {
|
|
2176
2174
|
if (isControl(e.key)) {
|
|
2177
|
-
this.
|
|
2178
|
-
this.boxSelection.setEnable(false);
|
|
2179
|
-
this.context.control.enablePan = !!this.prevPanStatus;
|
|
2180
|
-
this.context.control.enableRotate = !!this.prevRotateStatus;
|
|
2175
|
+
this.disableBoxSelection();
|
|
2181
2176
|
}
|
|
2182
2177
|
});
|
|
2183
2178
|
__publicField(this, "onBoxSelected", ({ list }) => {
|
|
@@ -2194,12 +2189,33 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2194
2189
|
get list() {
|
|
2195
2190
|
return this._list;
|
|
2196
2191
|
}
|
|
2192
|
+
enableBoxSelection() {
|
|
2193
|
+
if (this.isMultipleSelect) {
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
this.isMultipleSelect = true;
|
|
2197
|
+
this.boxSelection.setEnable(true);
|
|
2198
|
+
this.prevPanStatus = this.context.control.enablePan;
|
|
2199
|
+
this.prevRotateStatus = this.context.control.enableRotate;
|
|
2200
|
+
this.context.control.enablePan = false;
|
|
2201
|
+
this.context.control.enableRotate = false;
|
|
2202
|
+
}
|
|
2203
|
+
disableBoxSelection() {
|
|
2204
|
+
if (this.isMultipleSelect) {
|
|
2205
|
+
this.isMultipleSelect = false;
|
|
2206
|
+
this.boxSelection.setEnable(false);
|
|
2207
|
+
this.context.control.enablePan = !!this.prevPanStatus;
|
|
2208
|
+
this.context.control.enableRotate = !!this.prevRotateStatus;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2197
2211
|
selectEnd() {
|
|
2198
2212
|
this.dispatchEvent({ type: "select", graphics: [...this._list], isMultipleSelect: this.isMultipleSelect });
|
|
2199
2213
|
}
|
|
2200
2214
|
registryEvent() {
|
|
2201
2215
|
this.context.container.addEventListener("pointerdown", this.onPointerDown);
|
|
2202
2216
|
this.context.container.addEventListener("pointerup", this.onPointerUp);
|
|
2217
|
+
this.context.container.addEventListener("pointerout", this.onPointerOut);
|
|
2218
|
+
this.context.container.addEventListener("pointercancel", this.onPointerOut);
|
|
2203
2219
|
window.addEventListener("keydown", this.onKeyDown);
|
|
2204
2220
|
window.addEventListener("keyup", this.onKeyUp);
|
|
2205
2221
|
this.boxSelection.addEventListener("selected", this.onBoxSelected);
|
|
@@ -2207,6 +2223,8 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2207
2223
|
unRegistryEvent() {
|
|
2208
2224
|
this.context.container.removeEventListener("pointerdown", this.onPointerDown);
|
|
2209
2225
|
this.context.container.removeEventListener("pointerup", this.onPointerUp);
|
|
2226
|
+
this.context.container.removeEventListener("pointerout", this.onPointerOut);
|
|
2227
|
+
this.context.container.removeEventListener("pointercancel", this.onPointerOut);
|
|
2210
2228
|
window.removeEventListener("keydown", this.onKeyDown);
|
|
2211
2229
|
window.removeEventListener("keyup", this.onKeyUp);
|
|
2212
2230
|
this.boxSelection.removeEventListener("selected", this.onBoxSelected);
|
|
@@ -2231,12 +2249,12 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2231
2249
|
__publicField(this, "curGraphics", /* @__PURE__ */ new Set());
|
|
2232
2250
|
__publicField(this, "timer", new Timer());
|
|
2233
2251
|
__publicField(this, "graphicTimerMap", /* @__PURE__ */ new Map());
|
|
2234
|
-
__publicField(this, "onPointerMove", ({ graphics, pois }) => {
|
|
2252
|
+
__publicField(this, "onPointerMove", ({ graphics, pois, e }) => {
|
|
2235
2253
|
const poiGraphics = pois.map((item) => {
|
|
2236
2254
|
var _a;
|
|
2237
2255
|
return (_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.graphicMap.get(item.options.id);
|
|
2238
2256
|
}).filter((graphic) => graphic && graphic.options.geometry.type === "point");
|
|
2239
|
-
if (!graphics.length && !poiGraphics && this.curGraphics.size) {
|
|
2257
|
+
if (!graphics.length && !poiGraphics.length && this.curGraphics.size) {
|
|
2240
2258
|
this.curGraphics.clear();
|
|
2241
2259
|
this.handleHoverGraphicsChange();
|
|
2242
2260
|
return;
|
|
@@ -2244,9 +2262,22 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2244
2262
|
const { time } = this.context.config.hover;
|
|
2245
2263
|
const allGraphics = new Set(graphics);
|
|
2246
2264
|
if (!allGraphics.size) {
|
|
2247
|
-
poiGraphics.
|
|
2248
|
-
allGraphics.add(
|
|
2249
|
-
})
|
|
2265
|
+
if (poiGraphics.length === 1) {
|
|
2266
|
+
allGraphics.add(poiGraphics[0]);
|
|
2267
|
+
} else if (poiGraphics.length) {
|
|
2268
|
+
let resGraphic;
|
|
2269
|
+
let distance = 1e4;
|
|
2270
|
+
poiGraphics.forEach((graphic) => {
|
|
2271
|
+
const poi = pois.find((poi2) => poi2.options.id === graphic.options.id);
|
|
2272
|
+
const { x, y } = poi.clientPos;
|
|
2273
|
+
let curDistance = Math.sqrt(__pow(x - e.offsetX, 2) + __pow(y - e.offsetY, 2));
|
|
2274
|
+
if (curDistance < distance) {
|
|
2275
|
+
distance = curDistance;
|
|
2276
|
+
resGraphic = graphic;
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
allGraphics.add(resGraphic);
|
|
2280
|
+
}
|
|
2250
2281
|
}
|
|
2251
2282
|
allGraphics.forEach((graphic) => {
|
|
2252
2283
|
if (this.graphicTimerMap.get(graphic)) {
|
|
@@ -2257,6 +2288,8 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2257
2288
|
}
|
|
2258
2289
|
const timer = this.timer.setTimeout(() => {
|
|
2259
2290
|
this.curGraphics.add(graphic);
|
|
2291
|
+
this.graphicTimerMap.delete(graphic);
|
|
2292
|
+
this.timer.clearTimeout(timer);
|
|
2260
2293
|
this.handleHoverGraphicsChange();
|
|
2261
2294
|
}, time);
|
|
2262
2295
|
this.graphicTimerMap.set(graphic, timer);
|
|
@@ -2507,12 +2540,12 @@ var Context = class extends EventDispatcher6 {
|
|
|
2507
2540
|
__publicField(this, "onPointerover", (e) => {
|
|
2508
2541
|
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
2509
2542
|
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
2510
|
-
this.dispatchEvent({ type: "pointer-over", graphics, pois, position });
|
|
2543
|
+
this.dispatchEvent({ type: "pointer-over", e, graphics, pois, position });
|
|
2511
2544
|
});
|
|
2512
2545
|
__publicField(this, "onPointermove", (e) => {
|
|
2513
2546
|
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
2514
2547
|
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
2515
|
-
this.dispatchEvent({ type: "pointer-move", graphics, pois, position });
|
|
2548
|
+
this.dispatchEvent({ type: "pointer-move", e, graphics, pois, position });
|
|
2516
2549
|
});
|
|
2517
2550
|
__publicField(this, "onPointerleave", () => {
|
|
2518
2551
|
this.dispatchEvent({ type: "pointer-level" });
|
|
@@ -2747,14 +2780,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2747
2780
|
duration + 500
|
|
2748
2781
|
);
|
|
2749
2782
|
}
|
|
2750
|
-
|
|
2751
|
-
* 放大相机到物体占全屏
|
|
2752
|
-
* @param object
|
|
2753
|
-
* @param padding
|
|
2754
|
-
* @param duration
|
|
2755
|
-
* @returns
|
|
2756
|
-
*/
|
|
2757
|
-
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
|
|
2783
|
+
getFitCameraToObjectZoom(object, padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
|
|
2758
2784
|
const [top, right, bottom, left] = padding;
|
|
2759
2785
|
const { clientSize: { width, height } } = this;
|
|
2760
2786
|
const polar = this.control.getPolarAngle();
|
|
@@ -2775,7 +2801,23 @@ var Context = class extends EventDispatcher6 {
|
|
|
2775
2801
|
const yScale = (height - top - bottom) / size.y;
|
|
2776
2802
|
const scale = Math.min(xScale, yScale);
|
|
2777
2803
|
const center2 = new Vector312((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
2778
|
-
return
|
|
2804
|
+
return { zoom: scale * this.camera.zoom, center: center2 };
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* 放大相机到物体占全屏
|
|
2808
|
+
* @param object
|
|
2809
|
+
* @param padding
|
|
2810
|
+
* @param duration
|
|
2811
|
+
* @returns
|
|
2812
|
+
*/
|
|
2813
|
+
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
|
|
2814
|
+
const { zoom, center: center2 } = this.getFitCameraToObjectZoom(object, padding, duration, force2DView);
|
|
2815
|
+
return this.setZoom(zoom, center2, duration);
|
|
2816
|
+
}
|
|
2817
|
+
getFitCameraToGroundZoom(padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
|
|
2818
|
+
if (this.currentFloor && this.currentFloor.hasElement) {
|
|
2819
|
+
return this.getFitCameraToObjectZoom(this.currentFloor.groundUpper, padding, duration, force2DView).zoom;
|
|
2820
|
+
}
|
|
2779
2821
|
}
|
|
2780
2822
|
fitCameraToGround(padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
|
|
2781
2823
|
if (this.currentFloor && this.currentFloor.hasElement) {
|
|
@@ -2974,8 +3016,8 @@ var BMap = class extends EventDispatcher7 {
|
|
|
2974
3016
|
this.context.control.maxZoom = Infinity;
|
|
2975
3017
|
this.context.camera.zoom = 1;
|
|
2976
3018
|
this.context.setAzimuthalAngle(0, 0);
|
|
2977
|
-
this.context.
|
|
2978
|
-
this.basicZoom =
|
|
3019
|
+
const basicZoom = this.context.getFitCameraToGroundZoom(void 0, 0);
|
|
3020
|
+
this.basicZoom = basicZoom || 0;
|
|
2979
3021
|
this.context.control.minZoom = this.basicZoom;
|
|
2980
3022
|
this.context.control.maxZoom = this.basicZoom * 25;
|
|
2981
3023
|
this.context.camera.zoom = zoom;
|
|
@@ -3152,9 +3194,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3152
3194
|
position: graphic.getPosition().setZ(0.1)
|
|
3153
3195
|
}));
|
|
3154
3196
|
if (model) {
|
|
3155
|
-
const
|
|
3156
|
-
|
|
3157
|
-
model.
|
|
3197
|
+
const { facilityAngle = 0, facilityXScale = 1, facilityYScale = 1 } = graphic.options.userData;
|
|
3198
|
+
model.rotateZ((180 - facilityAngle) / 180 * Math.PI);
|
|
3199
|
+
model.scale.set(facilityXScale, facilityYScale, 1);
|
|
3158
3200
|
}
|
|
3159
3201
|
}
|
|
3160
3202
|
}
|