@aibee/crc-bmap 0.0.46 → 0.0.47
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 -8
- package/lib/bmap.cjs.min.js +1 -2
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +67 -31
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +1 -2
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +1 -2
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/bmap.d.ts +2 -2
- package/lib/src/context.d.ts +3 -3
- package/lib/src/elements/graphic.d.ts +1 -0
- package/lib/src/elements/poi.d.ts +6 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -112,7 +112,6 @@ import {
|
|
|
112
112
|
Scene,
|
|
113
113
|
WebGLRenderer,
|
|
114
114
|
OrthographicCamera,
|
|
115
|
-
HemisphereLight,
|
|
116
115
|
Shape,
|
|
117
116
|
PCFSoftShadowMap,
|
|
118
117
|
Group,
|
|
@@ -146,12 +145,7 @@ function initCamera(width, height) {
|
|
|
146
145
|
}
|
|
147
146
|
function initLight() {
|
|
148
147
|
const lights = new Group();
|
|
149
|
-
const
|
|
150
|
-
hemisphereLight.intensity = 1;
|
|
151
|
-
hemisphereLight.position.set(0, 0, 10);
|
|
152
|
-
hemisphereLight.up.set(0, 0, 1);
|
|
153
|
-
lights.add(hemisphereLight);
|
|
154
|
-
const ambientLight = new AmbientLight(16777215, 1);
|
|
148
|
+
const ambientLight = new AmbientLight(16777215, 2.6);
|
|
155
149
|
lights.add(ambientLight);
|
|
156
150
|
return lights;
|
|
157
151
|
}
|
|
@@ -176,7 +170,7 @@ function initDirectionalLight(color = 16777215, intensity = 1) {
|
|
|
176
170
|
directionalLight.castShadow = true;
|
|
177
171
|
directionalLight.shadow.radius = 8;
|
|
178
172
|
directionalLight.shadow.bias = -1e-3;
|
|
179
|
-
directionalLight.shadow.mapSize.set(
|
|
173
|
+
directionalLight.shadow.mapSize.set(256, 256);
|
|
180
174
|
directionalLight.shadow.camera.left = -200;
|
|
181
175
|
directionalLight.shadow.camera.right = 200;
|
|
182
176
|
directionalLight.shadow.camera.top = 200;
|
|
@@ -401,7 +395,6 @@ import {
|
|
|
401
395
|
Mesh,
|
|
402
396
|
Color as Color2,
|
|
403
397
|
Box3,
|
|
404
|
-
EdgesGeometry,
|
|
405
398
|
Vector3
|
|
406
399
|
} from "three";
|
|
407
400
|
import { merge } from "lodash";
|
|
@@ -428,7 +421,7 @@ var defaultOptions = {
|
|
|
428
421
|
strokeOpacity: 1,
|
|
429
422
|
// 描边透明度
|
|
430
423
|
strokeWidth: 1,
|
|
431
|
-
// 描边宽度
|
|
424
|
+
// 描边宽度
|
|
432
425
|
doors: [],
|
|
433
426
|
// 门配置
|
|
434
427
|
locked: false,
|
|
@@ -560,11 +553,42 @@ var Graphic = class extends Object3D {
|
|
|
560
553
|
initMesh() {
|
|
561
554
|
return new Mesh(this.geometry, this.material);
|
|
562
555
|
}
|
|
556
|
+
getBorderPoints() {
|
|
557
|
+
const points = [];
|
|
558
|
+
const height = this.options.height;
|
|
559
|
+
const { cds, curveIndex } = this.options.geometry;
|
|
560
|
+
for (let j = 0; j < cds.length; j++) {
|
|
561
|
+
const curCds = cds[j];
|
|
562
|
+
for (let i = 0; i < curCds.length; i++) {
|
|
563
|
+
const cur = curCds[i];
|
|
564
|
+
const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
|
|
565
|
+
points.push(cur[0], cur[1], 0);
|
|
566
|
+
points.push(next[0], next[1], 0);
|
|
567
|
+
points.push(cur[0], cur[1], height);
|
|
568
|
+
points.push(next[0], next[1], height);
|
|
569
|
+
if (j > 0) {
|
|
570
|
+
points.push(cur[0], cur[1], 0);
|
|
571
|
+
points.push(cur[0], cur[1], height);
|
|
572
|
+
} else {
|
|
573
|
+
if (curveIndex.length) {
|
|
574
|
+
if (curveIndex.includes(i)) {
|
|
575
|
+
points.push(cur[0], cur[1], 0);
|
|
576
|
+
points.push(cur[0], cur[1], height);
|
|
577
|
+
}
|
|
578
|
+
} else {
|
|
579
|
+
points.push(cur[0], cur[1], 0);
|
|
580
|
+
points.push(cur[0], cur[1], height);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return points;
|
|
586
|
+
}
|
|
563
587
|
createBorder() {
|
|
564
588
|
const material = this.initLineMaterial();
|
|
565
|
-
const
|
|
589
|
+
const points = this.getBorderPoints();
|
|
566
590
|
const lineGeometry = new LineSegmentsGeometry();
|
|
567
|
-
lineGeometry.
|
|
591
|
+
lineGeometry.setPositions(points);
|
|
568
592
|
const line = new LineSegments2(lineGeometry, material);
|
|
569
593
|
line.position.z = this.options.airHeight;
|
|
570
594
|
return line;
|
|
@@ -603,13 +627,13 @@ var Shadow = class extends Object3D2 {
|
|
|
603
627
|
super();
|
|
604
628
|
__publicField(this, "directionalLight");
|
|
605
629
|
__publicField(this, "plane");
|
|
606
|
-
__publicField(this, "basicOpacity", 0.
|
|
630
|
+
__publicField(this, "basicOpacity", 0.07);
|
|
607
631
|
this.directionalLight = this.initLight();
|
|
608
632
|
this.initPlane();
|
|
609
633
|
}
|
|
610
634
|
// 创建光源
|
|
611
635
|
initLight() {
|
|
612
|
-
const directionalLight = initDirectionalLight(16777215,
|
|
636
|
+
const directionalLight = initDirectionalLight(16777215, 0.5);
|
|
613
637
|
directionalLight.position.set(0, 0, 100);
|
|
614
638
|
this.add(directionalLight);
|
|
615
639
|
return directionalLight;
|
|
@@ -745,7 +769,7 @@ var Overlay = class extends EventDispatcher {
|
|
|
745
769
|
|
|
746
770
|
// src/elements/poi.ts
|
|
747
771
|
var defaultOptions2 = {
|
|
748
|
-
text: "",
|
|
772
|
+
texts: [{ text: "" }],
|
|
749
773
|
level: 1,
|
|
750
774
|
collision_enable: true,
|
|
751
775
|
opacity: 1,
|
|
@@ -784,7 +808,7 @@ var Poi = class extends Object3D4 {
|
|
|
784
808
|
this.resetSize();
|
|
785
809
|
}
|
|
786
810
|
});
|
|
787
|
-
this.addEventListener("change-
|
|
811
|
+
this.addEventListener("change-texts", ({ value }) => {
|
|
788
812
|
this.overlay.div.removeChild(this.textDiv);
|
|
789
813
|
this.overlay.div.appendChild(this.initText());
|
|
790
814
|
this.resetSize();
|
|
@@ -827,7 +851,8 @@ var Poi = class extends Object3D4 {
|
|
|
827
851
|
if (this.options.icon) {
|
|
828
852
|
div.appendChild(this.initIcon());
|
|
829
853
|
}
|
|
830
|
-
div.style.fontSize = `
|
|
854
|
+
div.style.fontSize = `14px`;
|
|
855
|
+
div.style.textShadow = `#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0`;
|
|
831
856
|
div.style.display = `flex`;
|
|
832
857
|
div.style.flexDirection = `column`;
|
|
833
858
|
div.style.justifyContent = `center`;
|
|
@@ -844,18 +869,27 @@ var Poi = class extends Object3D4 {
|
|
|
844
869
|
initText() {
|
|
845
870
|
const textDiv = document.createElement("div");
|
|
846
871
|
textDiv.appendChild(this.createTextFragment());
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
872
|
+
if (this.options.texts.length > 1) {
|
|
873
|
+
textDiv.style.background = "rgba(255, 255, 255, .7)";
|
|
874
|
+
textDiv.style.padding = "2px 4px";
|
|
875
|
+
textDiv.style.borderRadius = "4px";
|
|
876
|
+
textDiv.style.fontSize = "12px";
|
|
877
|
+
textDiv.style.lineHeight = "16px";
|
|
878
|
+
}
|
|
850
879
|
this.textDiv = textDiv;
|
|
851
880
|
return textDiv;
|
|
852
881
|
}
|
|
853
882
|
createTextFragment() {
|
|
854
883
|
const f = document.createDocumentFragment();
|
|
855
|
-
this.options.
|
|
884
|
+
this.options.texts.forEach((item) => {
|
|
856
885
|
const div = document.createElement("div");
|
|
857
886
|
div.style.whiteSpace = "nowrap";
|
|
858
|
-
|
|
887
|
+
if (item.styles) {
|
|
888
|
+
for (let [key, value] of Object.entries(item.styles)) {
|
|
889
|
+
div.style[key] = value;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
div.textContent = item.text;
|
|
859
893
|
f.appendChild(div);
|
|
860
894
|
});
|
|
861
895
|
return f;
|
|
@@ -1234,7 +1268,7 @@ var Floor = class extends Object3D7 {
|
|
|
1234
1268
|
addGrounds(grounds) {
|
|
1235
1269
|
grounds.forEach((ground) => {
|
|
1236
1270
|
if (!this.grounds.has(ground)) {
|
|
1237
|
-
ground.options.height += ground.options.zIndex /
|
|
1271
|
+
ground.options.height += ground.options.zIndex / 1e4;
|
|
1238
1272
|
this.grounds.add(ground);
|
|
1239
1273
|
this.groundUpper.add(ground);
|
|
1240
1274
|
}
|
|
@@ -1261,7 +1295,7 @@ var Floor = class extends Object3D7 {
|
|
|
1261
1295
|
this.add(this.shadow);
|
|
1262
1296
|
}
|
|
1263
1297
|
addGraphic(graphicOptions) {
|
|
1264
|
-
graphicOptions.height +=
|
|
1298
|
+
graphicOptions.height += this.graphicLayer.graphicMap.size * 1e-5;
|
|
1265
1299
|
return this.graphicLayer.createGraphic(graphicOptions);
|
|
1266
1300
|
}
|
|
1267
1301
|
addPoi(poiOptions) {
|
|
@@ -2245,9 +2279,11 @@ var Context = class extends EventDispatcher5 {
|
|
|
2245
2279
|
target: this.control.target.clone()
|
|
2246
2280
|
};
|
|
2247
2281
|
if (!duration) {
|
|
2248
|
-
this.camera.position.copy(
|
|
2249
|
-
this.control.target.copy(
|
|
2250
|
-
this.camera.zoom =
|
|
2282
|
+
this.camera.position.copy(center2.clone().sub(lookAtVector));
|
|
2283
|
+
this.control.target.copy(center2);
|
|
2284
|
+
this.camera.zoom = zoom;
|
|
2285
|
+
this.control.update();
|
|
2286
|
+
return;
|
|
2251
2287
|
}
|
|
2252
2288
|
return timeoutPromise(
|
|
2253
2289
|
new Promise((resolve) => {
|
|
@@ -2540,7 +2576,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2540
2576
|
}
|
|
2541
2577
|
const grounds = data.filter((item) => item.info.group === "ground");
|
|
2542
2578
|
grounds.forEach((item) => {
|
|
2543
|
-
item.info.fillColor = "#
|
|
2579
|
+
item.info.fillColor = "#F2F6FC";
|
|
2544
2580
|
item.info.fillOpacity = 1;
|
|
2545
2581
|
item.info.strokeOpacity = 0;
|
|
2546
2582
|
item.info.height = 5;
|
|
@@ -2548,9 +2584,6 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2548
2584
|
const groundGraphics = grounds.map((ground) => new Graphic(this.context, ground.info));
|
|
2549
2585
|
curFloor.addGrounds(groundGraphics);
|
|
2550
2586
|
const graphicData = data.filter((item) => item.info.group !== "ground");
|
|
2551
|
-
graphicData.forEach((item, index) => {
|
|
2552
|
-
item.info.height = 5;
|
|
2553
|
-
});
|
|
2554
2587
|
const legacyToGraphicMap = /* @__PURE__ */ new Map();
|
|
2555
2588
|
const graphics = graphicData.map((item) => {
|
|
2556
2589
|
const graphic = curFloor.addGraphic(item.info);
|
|
@@ -2574,6 +2607,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2574
2607
|
this.context.switchFloor(createdFloor.curFloor);
|
|
2575
2608
|
this.context.control.minZoom = 0;
|
|
2576
2609
|
this.context.control.maxZoom = Infinity;
|
|
2610
|
+
this.context.camera.zoom = 1;
|
|
2577
2611
|
this.context.setAzimuthalAngle(0, 0);
|
|
2578
2612
|
this.context.fitCameraToGround(void 0, 0);
|
|
2579
2613
|
this.basicZoom = this.context.camera.zoom;
|
|
@@ -2833,6 +2867,8 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2833
2867
|
}
|
|
2834
2868
|
dispose() {
|
|
2835
2869
|
this.context.dispose();
|
|
2870
|
+
this.floorDataMap.clear();
|
|
2871
|
+
this.buildingGroundMap.clear();
|
|
2836
2872
|
clearTextTexture();
|
|
2837
2873
|
clearCanvas();
|
|
2838
2874
|
this.unRegistryEvent();
|