@aibee/crc-bmap 0.0.92 → 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 +161 -37
- 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/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 {
|
|
@@ -941,7 +941,9 @@ var Overlay = class extends EventDispatcher {
|
|
|
941
941
|
initObserver() {
|
|
942
942
|
const observer = new MutationObserver(
|
|
943
943
|
debounce(() => {
|
|
944
|
-
this.
|
|
944
|
+
if (this.div) {
|
|
945
|
+
this.usePlacement();
|
|
946
|
+
}
|
|
945
947
|
}, 100)
|
|
946
948
|
);
|
|
947
949
|
observer.observe(this.div, {
|
|
@@ -3216,10 +3218,10 @@ var Context = class extends EventDispatcher6 {
|
|
|
3216
3218
|
const boundingBox = new Box38().setFromObject(object);
|
|
3217
3219
|
this.setPolarAngle(polar, 0);
|
|
3218
3220
|
const { max, min } = boundingBox;
|
|
3219
|
-
const leftTop = new Vector313(min.x, max.y,
|
|
3220
|
-
const rightTop = new Vector313(max.x, max.y,
|
|
3221
|
-
const rightBottom = new Vector313(max.x, min.y,
|
|
3222
|
-
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);
|
|
3223
3225
|
const leftTop2d = vector3ToDevice(leftTop, this.camera, width, height);
|
|
3224
3226
|
const rightTop2d = vector3ToDevice(rightTop, this.camera, width, height);
|
|
3225
3227
|
const leftBottom2d = vector3ToDevice(leftBottom, this.camera, width, height);
|
|
@@ -3234,7 +3236,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
3234
3236
|
const xScale = (width - right - left) / size.x;
|
|
3235
3237
|
const yScale = (height - top - bottom) / size.y;
|
|
3236
3238
|
const scale = Math.min(xScale, yScale);
|
|
3237
|
-
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);
|
|
3238
3240
|
return { zoom: scale * this.camera.zoom, center: center2 };
|
|
3239
3241
|
}
|
|
3240
3242
|
/**
|
|
@@ -3410,8 +3412,11 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3410
3412
|
__publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
|
|
3411
3413
|
__publicField(this, "currentBuildGround", null);
|
|
3412
3414
|
__publicField(this, "observe", null);
|
|
3415
|
+
__publicField(this, "timer", new Timer());
|
|
3413
3416
|
__publicField(this, "onControlChange", () => {
|
|
3414
|
-
const {
|
|
3417
|
+
const {
|
|
3418
|
+
camera: { zoom }
|
|
3419
|
+
} = this.context;
|
|
3415
3420
|
if (zoom !== this.prevCameraZoom) {
|
|
3416
3421
|
this.dispatchEvent({
|
|
3417
3422
|
type: "zoom-change",
|
|
@@ -3467,8 +3472,20 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3467
3472
|
this.context.render();
|
|
3468
3473
|
}
|
|
3469
3474
|
loadGraphics(_0) {
|
|
3470
|
-
return __async(this, arguments, function* ({
|
|
3471
|
-
|
|
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;
|
|
3472
3489
|
const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
|
|
3473
3490
|
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3474
3491
|
(res || []).map((item) => item.info = JSON.parse(item.info));
|
|
@@ -3477,17 +3494,31 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3477
3494
|
return data;
|
|
3478
3495
|
});
|
|
3479
3496
|
}
|
|
3480
|
-
getBuildingKey({
|
|
3497
|
+
getBuildingKey({
|
|
3498
|
+
brand,
|
|
3499
|
+
project,
|
|
3500
|
+
phase,
|
|
3501
|
+
building
|
|
3502
|
+
}) {
|
|
3481
3503
|
const key = `${brand}-${project}-${phase}-${building}`;
|
|
3482
3504
|
return key;
|
|
3483
3505
|
}
|
|
3484
3506
|
loadBuildingGround(_0) {
|
|
3485
|
-
return __async(this, arguments, function* ({
|
|
3507
|
+
return __async(this, arguments, function* ({
|
|
3508
|
+
brand,
|
|
3509
|
+
project,
|
|
3510
|
+
phase,
|
|
3511
|
+
building
|
|
3512
|
+
}) {
|
|
3486
3513
|
const key = this.getBuildingKey({ brand, project, phase, building });
|
|
3487
3514
|
if (this.buildingGroundMap.get(key)) {
|
|
3488
3515
|
return this.buildingGroundMap.get(key) || null;
|
|
3489
3516
|
}
|
|
3490
|
-
const {
|
|
3517
|
+
const {
|
|
3518
|
+
apiDomain,
|
|
3519
|
+
apiPath: { floorRange },
|
|
3520
|
+
apiInfo
|
|
3521
|
+
} = this.config;
|
|
3491
3522
|
const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${phase}&building=${building}`;
|
|
3492
3523
|
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3493
3524
|
const data2 = (res || [])[0];
|
|
@@ -3500,24 +3531,60 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3500
3531
|
return data;
|
|
3501
3532
|
});
|
|
3502
3533
|
}
|
|
3503
|
-
getFloorKey({
|
|
3534
|
+
getFloorKey({
|
|
3535
|
+
brand,
|
|
3536
|
+
project,
|
|
3537
|
+
phase,
|
|
3538
|
+
building,
|
|
3539
|
+
floor,
|
|
3540
|
+
ts,
|
|
3541
|
+
resource_type_list
|
|
3542
|
+
}) {
|
|
3504
3543
|
const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}-${resource_type_list}`;
|
|
3505
3544
|
return floorKey;
|
|
3506
3545
|
}
|
|
3507
3546
|
load(_0) {
|
|
3508
|
-
return __async(this, arguments, function* ({
|
|
3509
|
-
|
|
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
|
+
});
|
|
3510
3565
|
if (this.floorDataMap.get(floorKey)) {
|
|
3511
3566
|
return;
|
|
3512
3567
|
}
|
|
3513
3568
|
const [data, buildGround] = yield Promise.all([
|
|
3514
|
-
this.loadGraphics({
|
|
3569
|
+
this.loadGraphics({
|
|
3570
|
+
brand,
|
|
3571
|
+
project,
|
|
3572
|
+
phase,
|
|
3573
|
+
building,
|
|
3574
|
+
floor,
|
|
3575
|
+
ts,
|
|
3576
|
+
resource_type_list
|
|
3577
|
+
}),
|
|
3515
3578
|
this.loadBuildingGround({ brand, project, phase, building })
|
|
3516
3579
|
]);
|
|
3517
3580
|
if (buildGround) {
|
|
3518
|
-
const center2 = getCenter(
|
|
3581
|
+
const center2 = getCenter(
|
|
3582
|
+
buildGround.info.geometry.cds[0]
|
|
3583
|
+
);
|
|
3519
3584
|
data.forEach((item) => {
|
|
3520
|
-
item.info.geometry.coords = JSON.parse(
|
|
3585
|
+
item.info.geometry.coords = JSON.parse(
|
|
3586
|
+
JSON.stringify(item.info.geometry.cds)
|
|
3587
|
+
);
|
|
3521
3588
|
if (item.info.geometry.type === "polygon") {
|
|
3522
3589
|
item.info.geometry.coords.map((cds) => {
|
|
3523
3590
|
if (Array.isArray(cds)) {
|
|
@@ -3590,12 +3657,33 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3590
3657
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
3591
3658
|
return { curFloor, graphics };
|
|
3592
3659
|
}
|
|
3593
|
-
switchFloor({
|
|
3594
|
-
|
|
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
|
+
});
|
|
3595
3678
|
const curFloorData = this.floorDataMap.get(floorKey);
|
|
3596
3679
|
this.context.control.removeEventListener("change", this.onControlChange);
|
|
3597
3680
|
if (curFloorData) {
|
|
3598
|
-
const buildingKey = this.getBuildingKey({
|
|
3681
|
+
const buildingKey = this.getBuildingKey({
|
|
3682
|
+
brand,
|
|
3683
|
+
project,
|
|
3684
|
+
phase,
|
|
3685
|
+
building
|
|
3686
|
+
});
|
|
3599
3687
|
this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
|
|
3600
3688
|
const createdFloor = this.createFloor(curFloorData);
|
|
3601
3689
|
if (createdFloor) {
|
|
@@ -3619,7 +3707,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3619
3707
|
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
3620
3708
|
}
|
|
3621
3709
|
} else {
|
|
3622
|
-
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
|
+
);
|
|
3623
3713
|
}
|
|
3624
3714
|
}
|
|
3625
3715
|
// 扶梯
|
|
@@ -3631,7 +3721,11 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3631
3721
|
id: graphic.options.id
|
|
3632
3722
|
}));
|
|
3633
3723
|
if (model) {
|
|
3634
|
-
const {
|
|
3724
|
+
const {
|
|
3725
|
+
facilityAngle = 0,
|
|
3726
|
+
facilityXScale = 1,
|
|
3727
|
+
facilityYScale = 1
|
|
3728
|
+
} = graphic.options.userData;
|
|
3635
3729
|
model.rotateZ((180 - facilityAngle) / 180 * Math.PI);
|
|
3636
3730
|
model.scale.set(facilityXScale, facilityYScale, 1);
|
|
3637
3731
|
}
|
|
@@ -3647,11 +3741,13 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3647
3741
|
}
|
|
3648
3742
|
/**
|
|
3649
3743
|
* 获取当前楼层全部的graphic
|
|
3650
|
-
* @returns
|
|
3744
|
+
* @returns
|
|
3651
3745
|
*/
|
|
3652
3746
|
getFloorAllGraphics() {
|
|
3653
3747
|
var _a;
|
|
3654
|
-
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
|
+
)) || [];
|
|
3655
3751
|
}
|
|
3656
3752
|
createGraphicPoi(graphic, options) {
|
|
3657
3753
|
if (this.context.currentFloor) {
|
|
@@ -3686,11 +3782,25 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3686
3782
|
*/
|
|
3687
3783
|
translateElementToCenterX(ele, duration = 500) {
|
|
3688
3784
|
return __async(this, null, function* () {
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
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);
|
|
3694
3804
|
});
|
|
3695
3805
|
}
|
|
3696
3806
|
/**
|
|
@@ -3722,9 +3832,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3722
3832
|
resetView(duration = 300) {
|
|
3723
3833
|
return __async(this, null, function* () {
|
|
3724
3834
|
const time = duration / 3;
|
|
3725
|
-
yield this.context.setAzimuthalAngle(
|
|
3835
|
+
yield this.context.setAzimuthalAngle(
|
|
3836
|
+
this.config.control.defaultAzimuthal,
|
|
3837
|
+
time
|
|
3838
|
+
);
|
|
3726
3839
|
yield this.changeMapType(this.type, time);
|
|
3727
|
-
yield this.context.fitCameraToGround(
|
|
3840
|
+
yield this.context.fitCameraToGround(
|
|
3841
|
+
this.config.defaultPadding,
|
|
3842
|
+
time,
|
|
3843
|
+
false
|
|
3844
|
+
);
|
|
3728
3845
|
});
|
|
3729
3846
|
}
|
|
3730
3847
|
/**
|
|
@@ -3789,7 +3906,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3789
3906
|
}
|
|
3790
3907
|
/**
|
|
3791
3908
|
* 测量距离
|
|
3792
|
-
* @returns
|
|
3909
|
+
* @returns
|
|
3793
3910
|
*/
|
|
3794
3911
|
measureDistance() {
|
|
3795
3912
|
return __async(this, null, function* () {
|
|
@@ -3863,9 +3980,13 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3863
3980
|
var _a;
|
|
3864
3981
|
if (!options.transformToBuildingGround) {
|
|
3865
3982
|
if (this.currentBuildGround) {
|
|
3866
|
-
const center2 = getCenter(
|
|
3983
|
+
const center2 = getCenter(
|
|
3984
|
+
this.currentBuildGround.info.geometry.cds[0]
|
|
3985
|
+
);
|
|
3867
3986
|
if (options.geometry.type === "polygon") {
|
|
3868
|
-
options.geometry.coords = JSON.parse(
|
|
3987
|
+
options.geometry.coords = JSON.parse(
|
|
3988
|
+
JSON.stringify(options.geometry.cds)
|
|
3989
|
+
);
|
|
3869
3990
|
options.geometry.coords.map((cds) => {
|
|
3870
3991
|
if (Array.isArray(cds)) {
|
|
3871
3992
|
cds.forEach((coord) => {
|
|
@@ -3892,7 +4013,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3892
4013
|
}
|
|
3893
4014
|
getPois() {
|
|
3894
4015
|
var _a;
|
|
3895
|
-
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
|
+
);
|
|
3896
4019
|
}
|
|
3897
4020
|
clearPoi() {
|
|
3898
4021
|
if (this.context.currentFloor) {
|
|
@@ -3903,6 +4026,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3903
4026
|
this.context.selection.remove(graphic);
|
|
3904
4027
|
}
|
|
3905
4028
|
dispose() {
|
|
4029
|
+
this.timer.dispose();
|
|
3906
4030
|
this.context.dispose();
|
|
3907
4031
|
this.floorDataMap.clear();
|
|
3908
4032
|
this.buildingGroundMap.clear();
|