@aibee/crc-bmap 0.0.12 → 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 +3 -3
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +47 -40
- 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/elements/floor.d.ts +4 -2
- package/lib/src/elements/shadow.d.ts +2 -2
- 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
378
|
Raycaster as Raycaster3,
|
|
379
|
-
Box3 as
|
|
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,7 @@ 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";
|
|
781
785
|
|
|
782
786
|
// src/layer/graphic-layer.ts
|
|
783
787
|
import { Box3 as Box33, Vector3 as Vector34 } from "three";
|
|
@@ -1037,24 +1041,31 @@ var Floor = class extends Object3D7 {
|
|
|
1037
1041
|
this.context = context;
|
|
1038
1042
|
__publicField(this, "graphicLayer");
|
|
1039
1043
|
__publicField(this, "poiLayer");
|
|
1040
|
-
__publicField(this, "
|
|
1044
|
+
__publicField(this, "grounds", /* @__PURE__ */ new Set());
|
|
1041
1045
|
__publicField(this, "shadow", new Shadow());
|
|
1042
1046
|
__publicField(this, "heatmap");
|
|
1047
|
+
__publicField(this, "groundUpper", new Object3D7());
|
|
1043
1048
|
this.graphicLayer = new GraphicLayer(this.context);
|
|
1044
1049
|
this.poiLayer = new PoiLayer(this.context);
|
|
1045
|
-
this.add(this.graphicLayer);
|
|
1046
|
-
this.add(this.poiLayer);
|
|
1047
|
-
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
|
+
});
|
|
1048
1061
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
this.shadow.position.x = center2.x;
|
|
1055
|
-
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);
|
|
1056
1067
|
this.shadow.changeLightCamera(size);
|
|
1057
|
-
this.shadow
|
|
1068
|
+
this.add(this.shadow);
|
|
1058
1069
|
}
|
|
1059
1070
|
addGraphic(graphicOptions) {
|
|
1060
1071
|
return this.graphicLayer.createGraphic(graphicOptions);
|
|
@@ -1063,15 +1074,13 @@ var Floor = class extends Object3D7 {
|
|
|
1063
1074
|
return this.poiLayer.createPoi(poiOptions);
|
|
1064
1075
|
}
|
|
1065
1076
|
addHeatmap(data) {
|
|
1066
|
-
var _a, _b;
|
|
1067
1077
|
if (!this.heatmap) {
|
|
1068
1078
|
this.heatmap = new HeatmapElement(this.context);
|
|
1069
1079
|
this.add(this.heatmap);
|
|
1070
1080
|
}
|
|
1071
1081
|
this.heatmap.loadData(data);
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
}
|
|
1082
|
+
const box = new Box34().setFromObject(this.graphicLayer);
|
|
1083
|
+
this.heatmap.position.setZ(box.max.z);
|
|
1075
1084
|
return this.heatmap;
|
|
1076
1085
|
}
|
|
1077
1086
|
removeHeatMap() {
|
|
@@ -1088,18 +1097,19 @@ var Floor = class extends Object3D7 {
|
|
|
1088
1097
|
this.shadow.visible = visible;
|
|
1089
1098
|
}
|
|
1090
1099
|
dispose() {
|
|
1091
|
-
var _a
|
|
1100
|
+
var _a;
|
|
1092
1101
|
this.shadow.dispose();
|
|
1093
1102
|
this.graphicLayer.dispose();
|
|
1094
1103
|
this.poiLayer.dispose();
|
|
1095
|
-
|
|
1096
|
-
(
|
|
1104
|
+
this.grounds.forEach((ground) => ground.dispose());
|
|
1105
|
+
(_a = this.heatmap) == null ? void 0 : _a.dispose();
|
|
1106
|
+
this.groundUpper.clear();
|
|
1097
1107
|
this.clear();
|
|
1098
1108
|
}
|
|
1099
1109
|
};
|
|
1100
1110
|
|
|
1101
1111
|
// src/elements/base-svg.ts
|
|
1102
|
-
import { EventDispatcher as EventDispatcher2, Vector3 as
|
|
1112
|
+
import { EventDispatcher as EventDispatcher2, Vector3 as Vector36 } from "three";
|
|
1103
1113
|
var BaseSvg = class extends EventDispatcher2 {
|
|
1104
1114
|
constructor(context) {
|
|
1105
1115
|
super();
|
|
@@ -1124,7 +1134,7 @@ var BaseSvg = class extends EventDispatcher2 {
|
|
|
1124
1134
|
const { clientWidth, clientHeight } = renderer.domElement;
|
|
1125
1135
|
const nx = x / clientWidth * 2 - 1;
|
|
1126
1136
|
const ny = 1 - y / clientHeight * 2;
|
|
1127
|
-
const v = new
|
|
1137
|
+
const v = new Vector36(nx, ny, 0);
|
|
1128
1138
|
return v.unproject(camera);
|
|
1129
1139
|
}
|
|
1130
1140
|
getSvgCoordinate(vector) {
|
|
@@ -1718,7 +1728,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1718
1728
|
/**
|
|
1719
1729
|
* 获取两个点之间的像素数
|
|
1720
1730
|
*/
|
|
1721
|
-
getRatio(point1 = new
|
|
1731
|
+
getRatio(point1 = new Vector38(0, 0, 0), point22 = new Vector38(100, 0, 0)) {
|
|
1722
1732
|
const { clientWidth, clientHeight } = this.container;
|
|
1723
1733
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
1724
1734
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
@@ -1815,7 +1825,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1815
1825
|
);
|
|
1816
1826
|
}
|
|
1817
1827
|
getCameraLookAt() {
|
|
1818
|
-
return new
|
|
1828
|
+
return new Vector38().subVectors(this.control.target, this.camera.position);
|
|
1819
1829
|
}
|
|
1820
1830
|
/**
|
|
1821
1831
|
* 按照一个中心点设置相机的放大缩小
|
|
@@ -1863,7 +1873,7 @@ var Context = class extends EventDispatcher5 {
|
|
|
1863
1873
|
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500) {
|
|
1864
1874
|
const [top, right, bottom, left] = padding;
|
|
1865
1875
|
const { clientWidth, clientHeight } = this.container;
|
|
1866
|
-
const boundingBox = new
|
|
1876
|
+
const boundingBox = new Box35().setFromObject(object);
|
|
1867
1877
|
const { max, min } = boundingBox;
|
|
1868
1878
|
const max2d = vector3ToDevice(max, this.camera, clientWidth, clientHeight);
|
|
1869
1879
|
const min2d = vector3ToDevice(min, this.camera, clientWidth, clientHeight);
|
|
@@ -1875,12 +1885,12 @@ var Context = class extends EventDispatcher5 {
|
|
|
1875
1885
|
const xScale = (clientWidth - right - left) / size.x;
|
|
1876
1886
|
const yScale = (clientHeight - top - bottom) / size.y;
|
|
1877
1887
|
const scale = Math.min(xScale, yScale);
|
|
1878
|
-
const center2 = new
|
|
1888
|
+
const center2 = new Vector38((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
1879
1889
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
1880
1890
|
}
|
|
1881
1891
|
fitCameraToGround(padding = [20, 20, 20, 20], duration = 500) {
|
|
1882
1892
|
if (this.currentFloor) {
|
|
1883
|
-
return this.fitCameraToObject(this.currentFloor.
|
|
1893
|
+
return this.fitCameraToObject(this.currentFloor.groundUpper, padding, duration);
|
|
1884
1894
|
} else {
|
|
1885
1895
|
return Promise.resolve(false);
|
|
1886
1896
|
}
|
|
@@ -2075,21 +2085,18 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2075
2085
|
if (!data.length) {
|
|
2076
2086
|
return { curFloor, graphics: [] };
|
|
2077
2087
|
}
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
const groundGraphic = new Graphic(this.context, ground.info);
|
|
2083
|
-
curFloor.addGround(groundGraphic);
|
|
2084
|
-
list.splice(groundIndex, 1);
|
|
2085
|
-
}
|
|
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");
|
|
2086
2092
|
const legacyToGraphicMap = /* @__PURE__ */ new Map();
|
|
2087
|
-
const graphics =
|
|
2093
|
+
const graphics = graphicData.map((item) => {
|
|
2088
2094
|
const graphic = curFloor.addGraphic(item.info);
|
|
2089
2095
|
graphic.userData.data = item;
|
|
2090
2096
|
legacyToGraphicMap.set(item.legacy_id, graphic);
|
|
2091
2097
|
return graphic;
|
|
2092
2098
|
});
|
|
2099
|
+
curFloor.addShadow();
|
|
2093
2100
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
2094
2101
|
return { curFloor, graphics };
|
|
2095
2102
|
}
|