@aibee/crc-bmap 0.0.13 → 0.0.15
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 +21 -12
- package/lib/bmap.cjs.min.js +2 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +109 -50
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +2 -1
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +2 -1
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/bmap.d.ts +2 -2
- package/lib/src/elements/floor.d.ts +3 -1
- package/lib/src/elements/graphic.d.ts +4 -1
- package/lib/src/elements/overlay.d.ts +1 -0
- package/lib/src/elements/poi.d.ts +4 -2
- package/lib/src/types/index.d.ts +13 -6
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -159,8 +159,6 @@ function initControl(camera, domElement) {
|
|
|
159
159
|
control.minPolarAngle = 0;
|
|
160
160
|
control.maxAzimuthAngle = 0;
|
|
161
161
|
control.minAzimuthAngle = 0;
|
|
162
|
-
control.minZoom = 1;
|
|
163
|
-
control.maxZoom = 100;
|
|
164
162
|
return control;
|
|
165
163
|
}
|
|
166
164
|
function initShape(path, holePath = []) {
|
|
@@ -441,6 +439,12 @@ var Graphic = class extends Object3D {
|
|
|
441
439
|
__publicField(this, "line");
|
|
442
440
|
__publicField(this, "options");
|
|
443
441
|
this.options = proxyOptions(merge({}, defaultOptions, options), this);
|
|
442
|
+
if (this.options.geometry.type === "point") {
|
|
443
|
+
const [x, y] = this.options.geometry.cds;
|
|
444
|
+
this.position.set(x, y, this.options.height + this.options.airHeight);
|
|
445
|
+
console.log(this.options);
|
|
446
|
+
return this;
|
|
447
|
+
}
|
|
444
448
|
this.init();
|
|
445
449
|
this.visible = this.options.visible;
|
|
446
450
|
this.addEventListener("change-fillColor", ({ value }) => {
|
|
@@ -467,6 +471,9 @@ var Graphic = class extends Object3D {
|
|
|
467
471
|
});
|
|
468
472
|
}
|
|
469
473
|
getCenter() {
|
|
474
|
+
if (this.options.geometry.type === "point") {
|
|
475
|
+
return this.position;
|
|
476
|
+
}
|
|
470
477
|
const center2 = new Vector3();
|
|
471
478
|
const box = new Box3();
|
|
472
479
|
box.setFromObject(this);
|
|
@@ -474,6 +481,9 @@ var Graphic = class extends Object3D {
|
|
|
474
481
|
return center2;
|
|
475
482
|
}
|
|
476
483
|
getSize() {
|
|
484
|
+
if (this.options.geometry.type === "point") {
|
|
485
|
+
return new Vector3(0, 0, 0);
|
|
486
|
+
}
|
|
477
487
|
const box = new Box3();
|
|
478
488
|
const size = new Vector3();
|
|
479
489
|
box.setFromObject(this);
|
|
@@ -494,7 +504,10 @@ var Graphic = class extends Object3D {
|
|
|
494
504
|
this.add(this.line);
|
|
495
505
|
}
|
|
496
506
|
initGeometry() {
|
|
497
|
-
const shape = initShape(
|
|
507
|
+
const shape = initShape(
|
|
508
|
+
this.options.geometry.cds[0],
|
|
509
|
+
this.options.geometry.cds.slice(1)
|
|
510
|
+
);
|
|
498
511
|
const geometry = new ExtrudeGeometry(shape, {
|
|
499
512
|
steps: 1,
|
|
500
513
|
bevelEnabled: false,
|
|
@@ -536,10 +549,13 @@ var Graphic = class extends Object3D {
|
|
|
536
549
|
if (!this.visible) {
|
|
537
550
|
return false;
|
|
538
551
|
}
|
|
552
|
+
if (this.options.geometry.type === "point") {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
539
555
|
const intersects = raycaster.intersectObject(this.mesh);
|
|
540
556
|
if (intersects[0]) {
|
|
541
|
-
const position = intersects[0]
|
|
542
|
-
return position;
|
|
557
|
+
const { point: position, distance } = intersects[0];
|
|
558
|
+
return { position, distance };
|
|
543
559
|
}
|
|
544
560
|
return false;
|
|
545
561
|
}
|
|
@@ -658,6 +674,9 @@ var Overlay = class extends EventDispatcher {
|
|
|
658
674
|
setVisible(visible, display = "block") {
|
|
659
675
|
this.div.style.display = visible ? display : "none";
|
|
660
676
|
}
|
|
677
|
+
setOpacity(opacity) {
|
|
678
|
+
this.div.style.opacity = `${opacity}`;
|
|
679
|
+
}
|
|
661
680
|
getPosition() {
|
|
662
681
|
if (this.element) {
|
|
663
682
|
if (typeof this.element.getPosition === "function") {
|
|
@@ -688,13 +707,14 @@ var Overlay = class extends EventDispatcher {
|
|
|
688
707
|
var defaultOptions2 = {
|
|
689
708
|
text: "",
|
|
690
709
|
level: 1,
|
|
691
|
-
collision_enable: true
|
|
710
|
+
collision_enable: true,
|
|
711
|
+
opacity: 1
|
|
692
712
|
};
|
|
693
713
|
var Poi = class extends Object3D4 {
|
|
694
714
|
constructor(context, options) {
|
|
695
715
|
super();
|
|
696
716
|
this.context = context;
|
|
697
|
-
__publicField(this, "
|
|
717
|
+
__publicField(this, "textDiv");
|
|
698
718
|
__publicField(this, "img");
|
|
699
719
|
__publicField(this, "overlay");
|
|
700
720
|
__publicField(this, "options");
|
|
@@ -720,7 +740,11 @@ var Poi = class extends Object3D4 {
|
|
|
720
740
|
}
|
|
721
741
|
});
|
|
722
742
|
this.addEventListener("change-text", ({ value }) => {
|
|
723
|
-
this.
|
|
743
|
+
this.overlay.div.removeChild(this.textDiv);
|
|
744
|
+
this.overlay.div.appendChild(this.initText());
|
|
745
|
+
});
|
|
746
|
+
this.addEventListener("change-opacity", ({ value }) => {
|
|
747
|
+
this.overlay.setOpacity(value);
|
|
724
748
|
});
|
|
725
749
|
}
|
|
726
750
|
initDiv() {
|
|
@@ -741,11 +765,23 @@ var Poi = class extends Object3D4 {
|
|
|
741
765
|
return this.position;
|
|
742
766
|
}
|
|
743
767
|
initText() {
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
768
|
+
const textDiv = document.createElement("div");
|
|
769
|
+
textDiv.appendChild(this.createTextFragment());
|
|
770
|
+
textDiv.style.background = "rgba(255, 255, 255, .7)";
|
|
771
|
+
textDiv.style.padding = "2px";
|
|
772
|
+
textDiv.style.borderRadius = "4px";
|
|
773
|
+
this.textDiv = textDiv;
|
|
774
|
+
return textDiv;
|
|
775
|
+
}
|
|
776
|
+
createTextFragment() {
|
|
777
|
+
const f = document.createDocumentFragment();
|
|
778
|
+
this.options.text.split("\r\n").forEach((item) => {
|
|
779
|
+
const div = document.createElement("div");
|
|
780
|
+
div.style.whiteSpace = "nowrap";
|
|
781
|
+
div.textContent = item;
|
|
782
|
+
f.appendChild(div);
|
|
783
|
+
});
|
|
784
|
+
return f;
|
|
749
785
|
}
|
|
750
786
|
initIcon() {
|
|
751
787
|
var _a, _b;
|
|
@@ -774,9 +810,9 @@ var Poi = class extends Object3D4 {
|
|
|
774
810
|
}
|
|
775
811
|
dispose() {
|
|
776
812
|
this.unRegistryEvent();
|
|
777
|
-
this.
|
|
778
|
-
this.span = null;
|
|
813
|
+
this.textDiv = null;
|
|
779
814
|
this.img = void 0;
|
|
815
|
+
this.overlay.dispose();
|
|
780
816
|
}
|
|
781
817
|
};
|
|
782
818
|
|
|
@@ -818,23 +854,29 @@ var GraphicLayer = class extends Layer {
|
|
|
818
854
|
* @param raycaster
|
|
819
855
|
*/
|
|
820
856
|
getGraphicByRaycaster(raycaster) {
|
|
821
|
-
|
|
822
|
-
const
|
|
857
|
+
const initData = { distance: 1e4, graphic: null, position: null };
|
|
858
|
+
const data = this.children.reduce((res, item) => {
|
|
823
859
|
if (item instanceof Graphic) {
|
|
824
860
|
const pos = item.raycast(raycaster);
|
|
825
861
|
if (pos) {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
862
|
+
const { distance } = pos;
|
|
863
|
+
if (distance < res.distance) {
|
|
864
|
+
return {
|
|
865
|
+
distance: res.distance,
|
|
866
|
+
position: res.position,
|
|
867
|
+
graphic: item
|
|
868
|
+
};
|
|
832
869
|
}
|
|
833
870
|
}
|
|
834
|
-
return
|
|
871
|
+
return res;
|
|
872
|
+
} else {
|
|
873
|
+
return res;
|
|
835
874
|
}
|
|
836
|
-
});
|
|
837
|
-
|
|
875
|
+
}, initData);
|
|
876
|
+
if (data === initData) {
|
|
877
|
+
return { graphics: [], position: null };
|
|
878
|
+
}
|
|
879
|
+
return { graphics: [data.graphic], position: data.position };
|
|
838
880
|
}
|
|
839
881
|
};
|
|
840
882
|
|
|
@@ -1059,6 +1101,12 @@ var Floor = class extends Object3D7 {
|
|
|
1059
1101
|
}
|
|
1060
1102
|
});
|
|
1061
1103
|
}
|
|
1104
|
+
get hasElement() {
|
|
1105
|
+
return !!(this.grounds.size || this.graphicLayer.children.length);
|
|
1106
|
+
}
|
|
1107
|
+
getCenter() {
|
|
1108
|
+
return new Box34().setFromObject(this.groundUpper).getCenter(new Vector35());
|
|
1109
|
+
}
|
|
1062
1110
|
addShadow() {
|
|
1063
1111
|
const box = new Box34().setFromObject(this.groundUpper);
|
|
1064
1112
|
const center2 = box.getCenter(new Vector35());
|
|
@@ -1668,7 +1716,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1668
1716
|
camera.top = h / 2;
|
|
1669
1717
|
camera.bottom = -h / 2;
|
|
1670
1718
|
camera.updateProjectionMatrix();
|
|
1671
|
-
renderer.setSize(
|
|
1719
|
+
renderer.setSize(w, h);
|
|
1672
1720
|
});
|
|
1673
1721
|
__publicField(this, "onClick", (e) => {
|
|
1674
1722
|
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
@@ -1742,14 +1790,13 @@ var Context = class extends EventDispatcher5 {
|
|
|
1742
1790
|
});
|
|
1743
1791
|
}
|
|
1744
1792
|
switchFloor(floor) {
|
|
1745
|
-
var _a;
|
|
1746
1793
|
if (this.currentFloor) {
|
|
1747
1794
|
this.scene.remove(this.currentFloor);
|
|
1748
1795
|
this.currentFloor.dispose();
|
|
1749
1796
|
}
|
|
1750
1797
|
this.currentFloor = floor;
|
|
1751
1798
|
this.scene.add(floor);
|
|
1752
|
-
const position =
|
|
1799
|
+
const position = floor.getCenter();
|
|
1753
1800
|
if (position) {
|
|
1754
1801
|
this.lights.position.x = position.x;
|
|
1755
1802
|
this.lights.position.y = position.y;
|
|
@@ -1889,7 +1936,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1889
1936
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
1890
1937
|
}
|
|
1891
1938
|
fitCameraToGround(padding = [20, 20, 20, 20], duration = 500) {
|
|
1892
|
-
if (this.currentFloor) {
|
|
1939
|
+
if (this.currentFloor && this.currentFloor.hasElement) {
|
|
1893
1940
|
return this.fitCameraToObject(this.currentFloor.groundUpper, padding, duration);
|
|
1894
1941
|
} else {
|
|
1895
1942
|
return Promise.resolve(false);
|
|
@@ -2063,14 +2110,19 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2063
2110
|
if (buildGround) {
|
|
2064
2111
|
const center2 = getCenter(buildGround.info.geometry.cds[0]);
|
|
2065
2112
|
data.forEach((item) => {
|
|
2066
|
-
item.info.geometry.
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
coord
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2113
|
+
if (item.info.geometry.type === "polygon") {
|
|
2114
|
+
item.info.geometry.cds.map((cds) => {
|
|
2115
|
+
if (Array.isArray(cds)) {
|
|
2116
|
+
cds.forEach((coord) => {
|
|
2117
|
+
coord[0] -= center2[0];
|
|
2118
|
+
coord[1] -= center2[1];
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
} else {
|
|
2123
|
+
const [x, y] = item.info.geometry.cds;
|
|
2124
|
+
item.info.geometry.cds = [x - center2[0], y - center2[1]];
|
|
2125
|
+
}
|
|
2074
2126
|
});
|
|
2075
2127
|
}
|
|
2076
2128
|
if (!this.config.useFloorCache) {
|
|
@@ -2101,19 +2153,23 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2101
2153
|
return { curFloor, graphics };
|
|
2102
2154
|
}
|
|
2103
2155
|
switchFloor(floor) {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2156
|
+
return __async(this, null, function* () {
|
|
2157
|
+
const curFloorData = this.floorDataMap.get(floor);
|
|
2158
|
+
if (curFloorData) {
|
|
2159
|
+
const createdFloor = this.createFloor(curFloorData);
|
|
2160
|
+
if (createdFloor) {
|
|
2161
|
+
this.context.switchFloor(createdFloor.curFloor);
|
|
2162
|
+
yield this.context.fitCameraToGround(void 0, 0);
|
|
2163
|
+
this.basicZoom = this.context.camera.zoom;
|
|
2164
|
+
this.context.control.minZoom = this.basicZoom;
|
|
2165
|
+
this.context.control.maxZoom = this.basicZoom * 25;
|
|
2166
|
+
} else {
|
|
2167
|
+
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
2168
|
+
}
|
|
2111
2169
|
} else {
|
|
2112
|
-
console.warn("[switchFloor error]
|
|
2170
|
+
console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42");
|
|
2113
2171
|
}
|
|
2114
|
-
}
|
|
2115
|
-
console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42");
|
|
2116
|
-
}
|
|
2172
|
+
});
|
|
2117
2173
|
}
|
|
2118
2174
|
addHeatmap(data) {
|
|
2119
2175
|
var _a;
|
|
@@ -2134,8 +2190,11 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2134
2190
|
createGraphicPoi(graphic, options) {
|
|
2135
2191
|
if (this.context.currentFloor) {
|
|
2136
2192
|
const poi = this.context.currentFloor.addPoi(options);
|
|
2137
|
-
|
|
2193
|
+
const position = graphic.getCenter();
|
|
2194
|
+
position.z += graphic.options.height / 2;
|
|
2195
|
+
poi.position.copy(position);
|
|
2138
2196
|
poi.position.z = poi.position.z + graphic.options.height / 2;
|
|
2197
|
+
return poi;
|
|
2139
2198
|
}
|
|
2140
2199
|
return null;
|
|
2141
2200
|
}
|