@aibee/crc-bmap 0.0.10 → 0.0.13
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 +6 -6
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +4 -4
- package/lib/bmap.esm.js +59 -45
- package/lib/bmap.esm.js.map +4 -4
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.esm.min.js.map +4 -4
- package/lib/bmap.min.js +1 -1
- package/lib/bmap.min.js.map +4 -4
- package/lib/src/elements/floor.d.ts +4 -2
- package/lib/src/elements/shadow.d.ts +2 -2
- package/lib/src/layer/graphic-layer.d.ts +1 -0
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -178,7 +178,7 @@ function initDirectionalLight(color = 16777215, intensity = 1) {
|
|
|
178
178
|
directionalLight.castShadow = true;
|
|
179
179
|
directionalLight.shadow.radius = 8;
|
|
180
180
|
directionalLight.shadow.bias = -1e-3;
|
|
181
|
-
directionalLight.shadow.mapSize.set(
|
|
181
|
+
directionalLight.shadow.mapSize.set(256, 256);
|
|
182
182
|
directionalLight.shadow.camera.left = -200;
|
|
183
183
|
directionalLight.shadow.camera.right = 200;
|
|
184
184
|
directionalLight.shadow.camera.top = 200;
|
|
@@ -373,10 +373,10 @@ function setRectPosition(rect, x, y, w, h) {
|
|
|
373
373
|
import {
|
|
374
374
|
EventDispatcher as EventDispatcher5,
|
|
375
375
|
Box2,
|
|
376
|
-
Vector3 as
|
|
376
|
+
Vector3 as Vector38,
|
|
377
377
|
Vector2 as Vector23,
|
|
378
|
-
Raycaster as
|
|
379
|
-
Box3 as
|
|
378
|
+
Raycaster as Raycaster3,
|
|
379
|
+
Box3 as Box35,
|
|
380
380
|
Color as Color4,
|
|
381
381
|
AmbientLight as AmbientLight2
|
|
382
382
|
} from "three";
|
|
@@ -587,8 +587,12 @@ var Shadow = class extends Object3D2 {
|
|
|
587
587
|
changeLightColor(color) {
|
|
588
588
|
this.directionalLight.color = new Color3(color);
|
|
589
589
|
}
|
|
590
|
+
setPosition(position) {
|
|
591
|
+
this.position.copy(position);
|
|
592
|
+
this.directionalLight.position.set(-position.x / 2, -position.y / 2, 100);
|
|
593
|
+
}
|
|
590
594
|
// 创建平面白色
|
|
591
|
-
initPlane(width =
|
|
595
|
+
initPlane(width = 1e3, height = 1e3) {
|
|
592
596
|
const geometry = new PlaneGeometry(width, height);
|
|
593
597
|
const material = new ShadowMaterial({
|
|
594
598
|
transparent: true,
|
|
@@ -777,7 +781,10 @@ var Poi = class extends Object3D4 {
|
|
|
777
781
|
};
|
|
778
782
|
|
|
779
783
|
// src/elements/floor.ts
|
|
780
|
-
import { Object3D as Object3D7 } from "three";
|
|
784
|
+
import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector35 } from "three";
|
|
785
|
+
|
|
786
|
+
// src/layer/graphic-layer.ts
|
|
787
|
+
import { Box3 as Box33, Vector3 as Vector34 } from "three";
|
|
781
788
|
|
|
782
789
|
// src/layer/layer.ts
|
|
783
790
|
import { Object3D as Object3D5 } from "three";
|
|
@@ -797,6 +804,10 @@ var GraphicLayer = class extends Layer {
|
|
|
797
804
|
constructor(context) {
|
|
798
805
|
super(context);
|
|
799
806
|
}
|
|
807
|
+
getCenter() {
|
|
808
|
+
const box = new Box33().setFromObject(this);
|
|
809
|
+
return box.getCenter(new Vector34());
|
|
810
|
+
}
|
|
800
811
|
createGraphic(options) {
|
|
801
812
|
const graphic = new Graphic(this.context, options);
|
|
802
813
|
this.add(graphic);
|
|
@@ -1030,24 +1041,31 @@ var Floor = class extends Object3D7 {
|
|
|
1030
1041
|
this.context = context;
|
|
1031
1042
|
__publicField(this, "graphicLayer");
|
|
1032
1043
|
__publicField(this, "poiLayer");
|
|
1033
|
-
__publicField(this, "
|
|
1044
|
+
__publicField(this, "grounds", /* @__PURE__ */ new Set());
|
|
1034
1045
|
__publicField(this, "shadow", new Shadow());
|
|
1035
1046
|
__publicField(this, "heatmap");
|
|
1047
|
+
__publicField(this, "groundUpper", new Object3D7());
|
|
1036
1048
|
this.graphicLayer = new GraphicLayer(this.context);
|
|
1037
1049
|
this.poiLayer = new PoiLayer(this.context);
|
|
1038
|
-
this.add(this.graphicLayer);
|
|
1039
|
-
this.add(this.poiLayer);
|
|
1040
|
-
this.add(this.
|
|
1050
|
+
this.groundUpper.add(this.graphicLayer);
|
|
1051
|
+
this.groundUpper.add(this.poiLayer);
|
|
1052
|
+
this.add(this.groundUpper);
|
|
1053
|
+
}
|
|
1054
|
+
addGrounds(grounds) {
|
|
1055
|
+
grounds.forEach((ground) => {
|
|
1056
|
+
if (!this.grounds.has(ground)) {
|
|
1057
|
+
this.grounds.add(ground);
|
|
1058
|
+
this.groundUpper.add(ground);
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1041
1061
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
this.shadow.position.x = center2.x;
|
|
1048
|
-
this.shadow.position.y = center2.y;
|
|
1062
|
+
addShadow() {
|
|
1063
|
+
const box = new Box34().setFromObject(this.groundUpper);
|
|
1064
|
+
const center2 = box.getCenter(new Vector35());
|
|
1065
|
+
const size = box.getSize(new Vector35());
|
|
1066
|
+
this.shadow.setPosition(center2);
|
|
1049
1067
|
this.shadow.changeLightCamera(size);
|
|
1050
|
-
this.shadow
|
|
1068
|
+
this.add(this.shadow);
|
|
1051
1069
|
}
|
|
1052
1070
|
addGraphic(graphicOptions) {
|
|
1053
1071
|
return this.graphicLayer.createGraphic(graphicOptions);
|
|
@@ -1056,15 +1074,13 @@ var Floor = class extends Object3D7 {
|
|
|
1056
1074
|
return this.poiLayer.createPoi(poiOptions);
|
|
1057
1075
|
}
|
|
1058
1076
|
addHeatmap(data) {
|
|
1059
|
-
var _a, _b;
|
|
1060
1077
|
if (!this.heatmap) {
|
|
1061
1078
|
this.heatmap = new HeatmapElement(this.context);
|
|
1062
1079
|
this.add(this.heatmap);
|
|
1063
1080
|
}
|
|
1064
1081
|
this.heatmap.loadData(data);
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1082
|
+
const box = new Box34().setFromObject(this.graphicLayer);
|
|
1083
|
+
this.heatmap.position.setZ(box.max.z);
|
|
1068
1084
|
return this.heatmap;
|
|
1069
1085
|
}
|
|
1070
1086
|
removeHeatMap() {
|
|
@@ -1081,18 +1097,19 @@ var Floor = class extends Object3D7 {
|
|
|
1081
1097
|
this.shadow.visible = visible;
|
|
1082
1098
|
}
|
|
1083
1099
|
dispose() {
|
|
1084
|
-
var _a
|
|
1100
|
+
var _a;
|
|
1085
1101
|
this.shadow.dispose();
|
|
1086
1102
|
this.graphicLayer.dispose();
|
|
1087
1103
|
this.poiLayer.dispose();
|
|
1088
|
-
|
|
1089
|
-
(
|
|
1104
|
+
this.grounds.forEach((ground) => ground.dispose());
|
|
1105
|
+
(_a = this.heatmap) == null ? void 0 : _a.dispose();
|
|
1106
|
+
this.groundUpper.clear();
|
|
1090
1107
|
this.clear();
|
|
1091
1108
|
}
|
|
1092
1109
|
};
|
|
1093
1110
|
|
|
1094
1111
|
// src/elements/base-svg.ts
|
|
1095
|
-
import { EventDispatcher as EventDispatcher2, Vector3 as
|
|
1112
|
+
import { EventDispatcher as EventDispatcher2, Vector3 as Vector36 } from "three";
|
|
1096
1113
|
var BaseSvg = class extends EventDispatcher2 {
|
|
1097
1114
|
constructor(context) {
|
|
1098
1115
|
super();
|
|
@@ -1117,7 +1134,7 @@ var BaseSvg = class extends EventDispatcher2 {
|
|
|
1117
1134
|
const { clientWidth, clientHeight } = renderer.domElement;
|
|
1118
1135
|
const nx = x / clientWidth * 2 - 1;
|
|
1119
1136
|
const ny = 1 - y / clientHeight * 2;
|
|
1120
|
-
const v = new
|
|
1137
|
+
const v = new Vector36(nx, ny, 0);
|
|
1121
1138
|
return v.unproject(camera);
|
|
1122
1139
|
}
|
|
1123
1140
|
getSvgCoordinate(vector) {
|
|
@@ -1711,7 +1728,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1711
1728
|
/**
|
|
1712
1729
|
* 获取两个点之间的像素数
|
|
1713
1730
|
*/
|
|
1714
|
-
getRatio(point1 = new
|
|
1731
|
+
getRatio(point1 = new Vector38(0, 0, 0), point22 = new Vector38(100, 0, 0)) {
|
|
1715
1732
|
const { clientWidth, clientHeight } = this.container;
|
|
1716
1733
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
1717
1734
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
@@ -1732,7 +1749,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1732
1749
|
}
|
|
1733
1750
|
this.currentFloor = floor;
|
|
1734
1751
|
this.scene.add(floor);
|
|
1735
|
-
const position = (_a = floor.
|
|
1752
|
+
const position = (_a = floor.graphicLayer) == null ? void 0 : _a.getCenter();
|
|
1736
1753
|
if (position) {
|
|
1737
1754
|
this.lights.position.x = position.x;
|
|
1738
1755
|
this.lights.position.y = position.y;
|
|
@@ -1749,7 +1766,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1749
1766
|
const point3 = new Vector23();
|
|
1750
1767
|
point3.x = x / this.container.clientWidth * 2 - 1;
|
|
1751
1768
|
point3.y = y / this.container.clientHeight * -2 + 1;
|
|
1752
|
-
const raycaster = new
|
|
1769
|
+
const raycaster = new Raycaster3();
|
|
1753
1770
|
raycaster.setFromCamera(point3, this.camera);
|
|
1754
1771
|
const res = (_a = this.currentFloor) == null ? void 0 : _a.graphicLayer.getGraphicByRaycaster(raycaster);
|
|
1755
1772
|
return res || { graphics: [], position: null };
|
|
@@ -1808,7 +1825,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1808
1825
|
);
|
|
1809
1826
|
}
|
|
1810
1827
|
getCameraLookAt() {
|
|
1811
|
-
return new
|
|
1828
|
+
return new Vector38().subVectors(this.control.target, this.camera.position);
|
|
1812
1829
|
}
|
|
1813
1830
|
/**
|
|
1814
1831
|
* 按照一个中心点设置相机的放大缩小
|
|
@@ -1856,7 +1873,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1856
1873
|
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500) {
|
|
1857
1874
|
const [top, right, bottom, left] = padding;
|
|
1858
1875
|
const { clientWidth, clientHeight } = this.container;
|
|
1859
|
-
const boundingBox = new
|
|
1876
|
+
const boundingBox = new Box35().setFromObject(object);
|
|
1860
1877
|
const { max, min } = boundingBox;
|
|
1861
1878
|
const max2d = vector3ToDevice(max, this.camera, clientWidth, clientHeight);
|
|
1862
1879
|
const min2d = vector3ToDevice(min, this.camera, clientWidth, clientHeight);
|
|
@@ -1868,12 +1885,12 @@ var Context = class extends EventDispatcher5 {
|
|
|
1868
1885
|
const xScale = (clientWidth - right - left) / size.x;
|
|
1869
1886
|
const yScale = (clientHeight - top - bottom) / size.y;
|
|
1870
1887
|
const scale = Math.min(xScale, yScale);
|
|
1871
|
-
const center2 = new
|
|
1888
|
+
const center2 = new Vector38((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
1872
1889
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
1873
1890
|
}
|
|
1874
1891
|
fitCameraToGround(padding = [20, 20, 20, 20], duration = 500) {
|
|
1875
1892
|
if (this.currentFloor) {
|
|
1876
|
-
return this.fitCameraToObject(this.currentFloor.
|
|
1893
|
+
return this.fitCameraToObject(this.currentFloor.groundUpper, padding, duration);
|
|
1877
1894
|
} else {
|
|
1878
1895
|
return Promise.resolve(false);
|
|
1879
1896
|
}
|
|
@@ -2064,25 +2081,22 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2064
2081
|
});
|
|
2065
2082
|
}
|
|
2066
2083
|
createFloor(data) {
|
|
2067
|
-
if (!data.length) {
|
|
2068
|
-
return null;
|
|
2069
|
-
}
|
|
2070
2084
|
const curFloor = new Floor(this.context);
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
if (groundIndex !== -1) {
|
|
2074
|
-
const ground = data[groundIndex];
|
|
2075
|
-
const groundGraphic = new Graphic(this.context, ground.info);
|
|
2076
|
-
curFloor.addGround(groundGraphic);
|
|
2077
|
-
list.splice(groundIndex, 1);
|
|
2085
|
+
if (!data.length) {
|
|
2086
|
+
return { curFloor, graphics: [] };
|
|
2078
2087
|
}
|
|
2088
|
+
const grounds = data.filter((item) => item.info.group === "ground");
|
|
2089
|
+
const groundGraphics = grounds.map((ground) => new Graphic(this.context, ground.info));
|
|
2090
|
+
curFloor.addGrounds(groundGraphics);
|
|
2091
|
+
const graphicData = data.filter((item) => item.info.group !== "ground");
|
|
2079
2092
|
const legacyToGraphicMap = /* @__PURE__ */ new Map();
|
|
2080
|
-
const graphics =
|
|
2093
|
+
const graphics = graphicData.map((item) => {
|
|
2081
2094
|
const graphic = curFloor.addGraphic(item.info);
|
|
2082
2095
|
graphic.userData.data = item;
|
|
2083
2096
|
legacyToGraphicMap.set(item.legacy_id, graphic);
|
|
2084
2097
|
return graphic;
|
|
2085
2098
|
});
|
|
2099
|
+
curFloor.addShadow();
|
|
2086
2100
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
2087
2101
|
return { curFloor, graphics };
|
|
2088
2102
|
}
|