@aibee/crc-bmap 0.0.85 → 0.0.87
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 +27 -10
- package/example/vite.config.ts +1 -1
- package/lib/bmap.cjs.min.js +26 -1
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +212 -68
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +26 -1
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +26 -1
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/elements/floor.d.ts +1 -0
- package/lib/src/elements/graphic.d.ts +6 -4
- package/lib/src/elements/model.d.ts +1 -0
- package/lib/src/elements/overlay.d.ts +1 -0
- package/lib/src/factory/material.d.ts +12 -1
- package/lib/src/types/index.d.ts +4 -0
- package/lib/src/utils/color.d.ts +1 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -410,11 +410,20 @@ function addAlphaToHexColor(hexColor, alpha) {
|
|
|
410
410
|
let newHexColor = `#${(1 << 24 | newR << 16 | newG << 8 | newB).toString(16).slice(1)}`;
|
|
411
411
|
return newHexColor;
|
|
412
412
|
}
|
|
413
|
-
function darkenColor(hexColor) {
|
|
414
|
-
let r
|
|
415
|
-
let g
|
|
416
|
-
let b
|
|
417
|
-
|
|
413
|
+
function darkenColor(hexColor, factor = 0.85) {
|
|
414
|
+
let r;
|
|
415
|
+
let g;
|
|
416
|
+
let b;
|
|
417
|
+
if (hexColor.startsWith("#")) {
|
|
418
|
+
r = parseInt(hexColor.substring(1, 3), 16);
|
|
419
|
+
g = parseInt(hexColor.substring(3, 5), 16);
|
|
420
|
+
b = parseInt(hexColor.substring(5, 7), 16);
|
|
421
|
+
} else {
|
|
422
|
+
let numbers = hexColor.slice(4, -1).split(",");
|
|
423
|
+
r = parseInt(numbers[0].trim());
|
|
424
|
+
g = parseInt(numbers[1].trim());
|
|
425
|
+
b = parseInt(numbers[2].trim());
|
|
426
|
+
}
|
|
418
427
|
r = Math.floor(r * factor);
|
|
419
428
|
g = Math.floor(g * factor);
|
|
420
429
|
b = Math.floor(b * factor);
|
|
@@ -471,11 +480,11 @@ function isControl(key) {
|
|
|
471
480
|
import {
|
|
472
481
|
EventDispatcher as EventDispatcher6,
|
|
473
482
|
Box2,
|
|
474
|
-
Vector3 as
|
|
483
|
+
Vector3 as Vector313,
|
|
475
484
|
Vector2 as Vector23,
|
|
476
485
|
Raycaster as Raycaster3,
|
|
477
486
|
Box3 as Box38,
|
|
478
|
-
Color as
|
|
487
|
+
Color as Color5,
|
|
479
488
|
AmbientLight as AmbientLight2
|
|
480
489
|
} from "three";
|
|
481
490
|
import { Group as TweenGroup, Tween } from "@tweenjs/tween.js";
|
|
@@ -513,7 +522,7 @@ var defaultOptions = {
|
|
|
513
522
|
strokeOpacity: 1,
|
|
514
523
|
// 描边透明度
|
|
515
524
|
strokeWidth: 1,
|
|
516
|
-
// 描边宽度
|
|
525
|
+
// 描边宽度
|
|
517
526
|
doors: [],
|
|
518
527
|
// 门配置
|
|
519
528
|
locked: false,
|
|
@@ -521,6 +530,7 @@ var defaultOptions = {
|
|
|
521
530
|
geometry: {
|
|
522
531
|
type: "polygon",
|
|
523
532
|
cds: [],
|
|
533
|
+
coords: [],
|
|
524
534
|
curveCpt: [],
|
|
525
535
|
curveIndex: []
|
|
526
536
|
},
|
|
@@ -528,7 +538,9 @@ var defaultOptions = {
|
|
|
528
538
|
zIndex: 0,
|
|
529
539
|
stroke: true,
|
|
530
540
|
deltaHeight: 0,
|
|
531
|
-
userData: {}
|
|
541
|
+
userData: {},
|
|
542
|
+
gradualColor: [],
|
|
543
|
+
renderType: "single"
|
|
532
544
|
};
|
|
533
545
|
var Graphic = class extends Object3D {
|
|
534
546
|
constructor(context, options) {
|
|
@@ -541,9 +553,12 @@ var Graphic = class extends Object3D {
|
|
|
541
553
|
__publicField(this, "lineMaterial");
|
|
542
554
|
__publicField(this, "lineGeometry");
|
|
543
555
|
__publicField(this, "options");
|
|
544
|
-
this.options = proxyOptions(
|
|
556
|
+
this.options = proxyOptions(
|
|
557
|
+
__spreadValues(__spreadValues({}, defaultOptions), options),
|
|
558
|
+
this
|
|
559
|
+
);
|
|
545
560
|
if (this.options.geometry.type === "point") {
|
|
546
|
-
const [x, y] = this.options.geometry.
|
|
561
|
+
const [x, y] = this.options.geometry.coords;
|
|
547
562
|
this.position.set(x, y, this.options.height + this.options.airHeight);
|
|
548
563
|
return this;
|
|
549
564
|
}
|
|
@@ -595,6 +610,10 @@ var Graphic = class extends Object3D {
|
|
|
595
610
|
(_a = this.lineGeometry) == null ? void 0 : _a.dispose();
|
|
596
611
|
}
|
|
597
612
|
});
|
|
613
|
+
this.addEventListener("change-renderType", () => {
|
|
614
|
+
this.initMaterial();
|
|
615
|
+
this.initMesh();
|
|
616
|
+
});
|
|
598
617
|
}
|
|
599
618
|
getCenter() {
|
|
600
619
|
if (this.options.geometry.type === "point") {
|
|
@@ -634,8 +653,8 @@ var Graphic = class extends Object3D {
|
|
|
634
653
|
}
|
|
635
654
|
initGeometry() {
|
|
636
655
|
const shape = initShape(
|
|
637
|
-
this.options.geometry.
|
|
638
|
-
this.options.geometry.
|
|
656
|
+
this.options.geometry.coords[0],
|
|
657
|
+
this.options.geometry.coords.slice(1)
|
|
639
658
|
);
|
|
640
659
|
const geometry = new ExtrudeGeometry(shape, {
|
|
641
660
|
steps: 1,
|
|
@@ -645,12 +664,12 @@ var Graphic = class extends Object3D {
|
|
|
645
664
|
});
|
|
646
665
|
return geometry;
|
|
647
666
|
}
|
|
648
|
-
|
|
667
|
+
initSingleMaterial() {
|
|
649
668
|
const material = this.context.materialFactory.createMeshBasicMaterial({
|
|
650
669
|
color: this.options.fillColor,
|
|
651
670
|
opacity: this.options.fillOpacity
|
|
652
671
|
});
|
|
653
|
-
if (this.options.height <=
|
|
672
|
+
if (this.options.height <= 0.1) {
|
|
654
673
|
this.material = material;
|
|
655
674
|
return material;
|
|
656
675
|
}
|
|
@@ -661,6 +680,42 @@ var Graphic = class extends Object3D {
|
|
|
661
680
|
this.material = [material, material1];
|
|
662
681
|
return [material, material1];
|
|
663
682
|
}
|
|
683
|
+
initGradualMaterial() {
|
|
684
|
+
const { max, min } = new Box3().setFromObject(this);
|
|
685
|
+
const _max = max.clone().sub(min);
|
|
686
|
+
const maxValue = Math.max(_max.x, _max.y, _max.z) / 2;
|
|
687
|
+
const material = this.context.materialFactory.createShaderMaterial({
|
|
688
|
+
gradualColor: this.options.gradualColor,
|
|
689
|
+
center: this.getPosition(),
|
|
690
|
+
maxValue,
|
|
691
|
+
opacity: this.options.fillOpacity,
|
|
692
|
+
direction: new Vector32(-1, -1, 0),
|
|
693
|
+
max,
|
|
694
|
+
min
|
|
695
|
+
});
|
|
696
|
+
if (this.options.height <= 0.1) {
|
|
697
|
+
this.material = material;
|
|
698
|
+
return material;
|
|
699
|
+
}
|
|
700
|
+
const material1 = this.context.materialFactory.createShaderMaterial({
|
|
701
|
+
gradualColor: [darkenColor(this.options.gradualColor[0], 0.95), darkenColor(this.options.gradualColor[1], 0.95)],
|
|
702
|
+
center: this.getPosition(),
|
|
703
|
+
maxValue,
|
|
704
|
+
opacity: this.options.fillOpacity,
|
|
705
|
+
direction: new Vector32(-1, -1, 1),
|
|
706
|
+
max,
|
|
707
|
+
min
|
|
708
|
+
});
|
|
709
|
+
this.material = [material, material1];
|
|
710
|
+
return [material, material1];
|
|
711
|
+
}
|
|
712
|
+
initMaterial() {
|
|
713
|
+
if (this.options.renderType === "gradual") {
|
|
714
|
+
return this.initGradualMaterial();
|
|
715
|
+
} else {
|
|
716
|
+
return this.initSingleMaterial();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
664
719
|
initLineMaterial() {
|
|
665
720
|
const lineMaterial = this.context.materialFactory.createLineMaterial({
|
|
666
721
|
color: this.options.strokeColor,
|
|
@@ -679,9 +734,9 @@ var Graphic = class extends Object3D {
|
|
|
679
734
|
getBorderPoints() {
|
|
680
735
|
const points = [];
|
|
681
736
|
const height = this.options.height + this.options.deltaHeight;
|
|
682
|
-
const {
|
|
683
|
-
for (let j = 0; j <
|
|
684
|
-
const curCds =
|
|
737
|
+
const { coords } = this.options.geometry;
|
|
738
|
+
for (let j = 0; j < coords.length; j++) {
|
|
739
|
+
const curCds = coords[j];
|
|
685
740
|
for (let i = 0; i < curCds.length; i++) {
|
|
686
741
|
const cur = curCds[i];
|
|
687
742
|
const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
|
|
@@ -737,8 +792,8 @@ import {
|
|
|
737
792
|
PlaneGeometry,
|
|
738
793
|
Mesh as Mesh2,
|
|
739
794
|
ShadowMaterial,
|
|
740
|
-
Color as
|
|
741
|
-
DoubleSide
|
|
795
|
+
Color as Color3,
|
|
796
|
+
DoubleSide as DoubleSide2
|
|
742
797
|
} from "three";
|
|
743
798
|
var Shadow = class extends Object3D2 {
|
|
744
799
|
constructor() {
|
|
@@ -767,7 +822,7 @@ var Shadow = class extends Object3D2 {
|
|
|
767
822
|
this.directionalLight.shadow.camera.far = Math.max(x, y);
|
|
768
823
|
}
|
|
769
824
|
changeLightColor(color) {
|
|
770
|
-
this.directionalLight.color = new
|
|
825
|
+
this.directionalLight.color = new Color3(color);
|
|
771
826
|
}
|
|
772
827
|
setPosition(position) {
|
|
773
828
|
this.position.copy(position);
|
|
@@ -779,7 +834,7 @@ var Shadow = class extends Object3D2 {
|
|
|
779
834
|
const material = new ShadowMaterial({
|
|
780
835
|
transparent: true,
|
|
781
836
|
opacity: 0,
|
|
782
|
-
side:
|
|
837
|
+
side: DoubleSide2
|
|
783
838
|
});
|
|
784
839
|
const mesh = new Mesh2(geometry, material);
|
|
785
840
|
mesh.receiveShadow = true;
|
|
@@ -822,22 +877,7 @@ var Overlay = class extends EventDispatcher {
|
|
|
822
877
|
__publicField(this, "visible", true);
|
|
823
878
|
__publicField(this, "options");
|
|
824
879
|
__publicField(this, "onUpdate", () => {
|
|
825
|
-
|
|
826
|
-
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
827
|
-
const { x, y } = vector3ToDevice(vector, this.context.camera, width, height);
|
|
828
|
-
if (this.clientPos.x === x && this.clientPos.y === y) {
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
this.clientPos = { x, y };
|
|
832
|
-
if (this.options.appendToBody) {
|
|
833
|
-
this.div.style.left = `${clientX}px`;
|
|
834
|
-
this.div.style.top = `${clientY + height}px`;
|
|
835
|
-
}
|
|
836
|
-
if (this.options.autoUpdate) {
|
|
837
|
-
this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
|
|
838
|
-
} else {
|
|
839
|
-
this.dispatchEvent({ type: "update-position", x, y, width, height });
|
|
840
|
-
}
|
|
880
|
+
this.updatePosition();
|
|
841
881
|
});
|
|
842
882
|
this.options = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
843
883
|
this.registryEvent();
|
|
@@ -887,6 +927,24 @@ var Overlay = class extends EventDispatcher {
|
|
|
887
927
|
const { width, height } = this.context.clientSize;
|
|
888
928
|
return x >= 0 && x <= width && y >= 0 && y <= height;
|
|
889
929
|
}
|
|
930
|
+
updatePosition(force = false) {
|
|
931
|
+
const vector = this.getPosition();
|
|
932
|
+
const { width, height, x: clientX, y: clientY } = this.context.clientSize;
|
|
933
|
+
const { x, y } = vector3ToDevice(vector, this.context.camera, width, height);
|
|
934
|
+
if (this.clientPos.x === x && this.clientPos.y === y && !force) {
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
this.clientPos = { x, y };
|
|
938
|
+
if (this.options.appendToBody) {
|
|
939
|
+
this.div.style.left = `${clientX}px`;
|
|
940
|
+
this.div.style.top = `${clientY + height}px`;
|
|
941
|
+
}
|
|
942
|
+
if (this.options.autoUpdate) {
|
|
943
|
+
this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
|
|
944
|
+
} else {
|
|
945
|
+
this.dispatchEvent({ type: "update-position", x, y, width, height });
|
|
946
|
+
}
|
|
947
|
+
}
|
|
890
948
|
registryEvent() {
|
|
891
949
|
this.context.addEventListener("update", this.onUpdate);
|
|
892
950
|
}
|
|
@@ -933,6 +991,7 @@ var Poi = class extends EventDispatcher2 {
|
|
|
933
991
|
__publicField(this, "userData", {});
|
|
934
992
|
__publicField(this, "showTextStatus", true);
|
|
935
993
|
__publicField(this, "_changePosition", () => {
|
|
994
|
+
this.overlay.updatePosition(true);
|
|
936
995
|
});
|
|
937
996
|
this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions3), options), this);
|
|
938
997
|
this.position.set(((_a = options.position) == null ? void 0 : _a.x) || 0, ((_b = options.position) == null ? void 0 : _b.y) || 0, ((_c = options.position) == null ? void 0 : _c.z) || 0);
|
|
@@ -947,6 +1006,7 @@ var Poi = class extends EventDispatcher2 {
|
|
|
947
1006
|
if (value) {
|
|
948
1007
|
if (!this.img) {
|
|
949
1008
|
this.div.appendChild(this.initIcon());
|
|
1009
|
+
this._changePosition();
|
|
950
1010
|
} else {
|
|
951
1011
|
this.img.setAttribute("src", value);
|
|
952
1012
|
}
|
|
@@ -959,7 +1019,11 @@ var Poi = class extends EventDispatcher2 {
|
|
|
959
1019
|
});
|
|
960
1020
|
this.addEventListener("change-texts", ({ value }) => {
|
|
961
1021
|
this.div.removeChild(this.textDiv);
|
|
962
|
-
this.div.
|
|
1022
|
+
if (this.div.firstChild) {
|
|
1023
|
+
this.div.insertBefore(this.initText(), this.div.firstChild);
|
|
1024
|
+
} else {
|
|
1025
|
+
this.div.appendChild(this.initText());
|
|
1026
|
+
}
|
|
963
1027
|
this.resetSize();
|
|
964
1028
|
});
|
|
965
1029
|
this.addEventListener("change-opacity", ({ value }) => {
|
|
@@ -1324,8 +1388,9 @@ var PoiLayer = class extends Layer {
|
|
|
1324
1388
|
const pois = this.pois.filter((item) => item.visible && item.withinDisplayRange);
|
|
1325
1389
|
pois.forEach((item, index) => {
|
|
1326
1390
|
const { left, right, top, bottom } = item.getBox();
|
|
1327
|
-
if (index === 0) {
|
|
1391
|
+
if (index === 0 || !item.options.collision_enable) {
|
|
1328
1392
|
range.push({ left, right, top, bottom });
|
|
1393
|
+
item.parentSetVisible(true);
|
|
1329
1394
|
return;
|
|
1330
1395
|
}
|
|
1331
1396
|
const valid = range.some((box) => {
|
|
@@ -1360,7 +1425,7 @@ import {
|
|
|
1360
1425
|
Object3D as Object3D6,
|
|
1361
1426
|
PlaneGeometry as PlaneGeometry2,
|
|
1362
1427
|
Texture,
|
|
1363
|
-
DoubleSide as
|
|
1428
|
+
DoubleSide as DoubleSide3,
|
|
1364
1429
|
Mesh as Mesh3,
|
|
1365
1430
|
Matrix3,
|
|
1366
1431
|
Vector2 as Vector22
|
|
@@ -1403,7 +1468,7 @@ var HeatmapElement = class extends Object3D6 {
|
|
|
1403
1468
|
texture.needsUpdate = true;
|
|
1404
1469
|
const material = new MeshBasicMaterial2({
|
|
1405
1470
|
transparent: true,
|
|
1406
|
-
side:
|
|
1471
|
+
side: DoubleSide3,
|
|
1407
1472
|
map: texture
|
|
1408
1473
|
});
|
|
1409
1474
|
material.needsUpdate = true;
|
|
@@ -1510,6 +1575,7 @@ var Floor = class extends Object3D8 {
|
|
|
1510
1575
|
__publicField(this, "heatmap");
|
|
1511
1576
|
__publicField(this, "groundUpper", new Object3D8());
|
|
1512
1577
|
__publicField(this, "models", new Object3D8());
|
|
1578
|
+
__publicField(this, "modelMap", /* @__PURE__ */ new Map());
|
|
1513
1579
|
__publicField(this, "groundMaxHeight", 0);
|
|
1514
1580
|
this.graphicLayer = new GraphicLayer(this.context);
|
|
1515
1581
|
this.poiLayer = new PoiLayer(this.context);
|
|
@@ -1551,6 +1617,7 @@ var Floor = class extends Object3D8 {
|
|
|
1551
1617
|
addModel(options) {
|
|
1552
1618
|
const model = new Model(this.context, options);
|
|
1553
1619
|
this.models.add(model);
|
|
1620
|
+
this.modelMap.set(options.id, model);
|
|
1554
1621
|
return model;
|
|
1555
1622
|
}
|
|
1556
1623
|
addShadow() {
|
|
@@ -1559,7 +1626,6 @@ var Floor = class extends Object3D8 {
|
|
|
1559
1626
|
const size = box.getSize(new Vector38());
|
|
1560
1627
|
this.shadow.setPosition(center2);
|
|
1561
1628
|
this.shadow.changeLightCamera(size);
|
|
1562
|
-
this.add(this.shadow);
|
|
1563
1629
|
}
|
|
1564
1630
|
addGraphic(graphicOptions) {
|
|
1565
1631
|
return this.graphicLayer.createGraphic(graphicOptions);
|
|
@@ -1600,6 +1666,7 @@ var Floor = class extends Object3D8 {
|
|
|
1600
1666
|
this.groundUpper.clear();
|
|
1601
1667
|
this.models.children.forEach((model) => model.dispose());
|
|
1602
1668
|
this.models.clear();
|
|
1669
|
+
this.modelMap.clear();
|
|
1603
1670
|
this.clear();
|
|
1604
1671
|
}
|
|
1605
1672
|
};
|
|
@@ -2347,13 +2414,17 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2347
2414
|
};
|
|
2348
2415
|
|
|
2349
2416
|
// src/factory/material.ts
|
|
2350
|
-
import { LineBasicMaterial as LineBasicMaterial2, MeshStandardMaterial as MeshStandardMaterial2, MeshBasicMaterial as MeshBasicMaterial3 } from "three";
|
|
2417
|
+
import { Color as Color4, LineBasicMaterial as LineBasicMaterial2, MeshStandardMaterial as MeshStandardMaterial2, MeshBasicMaterial as MeshBasicMaterial3, ShaderMaterial as ShaderMaterial2, DoubleSide as DoubleSide4 } from "three";
|
|
2418
|
+
function vectorToString(vector) {
|
|
2419
|
+
return `${vector.x}-${vector.y}-${vector.z}`;
|
|
2420
|
+
}
|
|
2351
2421
|
var MaterialFactory = class {
|
|
2352
2422
|
constructor(context) {
|
|
2353
2423
|
this.context = context;
|
|
2354
2424
|
__publicField(this, "lineMaterialMap", /* @__PURE__ */ new Map());
|
|
2355
2425
|
__publicField(this, "meshStandardMaterialMap", /* @__PURE__ */ new Map());
|
|
2356
2426
|
__publicField(this, "meshBasicMaterialMap", /* @__PURE__ */ new Map());
|
|
2427
|
+
__publicField(this, "shaderMaterialMap", /* @__PURE__ */ new Map());
|
|
2357
2428
|
}
|
|
2358
2429
|
generateLineMaterialKey({ color, opacity }) {
|
|
2359
2430
|
return `${color}-${opacity}`;
|
|
@@ -2377,7 +2448,7 @@ var MaterialFactory = class {
|
|
|
2377
2448
|
return this.meshStandardMaterialMap.get(key);
|
|
2378
2449
|
}
|
|
2379
2450
|
const material = new MeshStandardMaterial2({
|
|
2380
|
-
color,
|
|
2451
|
+
color: new Color4(color).convertLinearToSRGB(),
|
|
2381
2452
|
roughness: 1,
|
|
2382
2453
|
transparent: true,
|
|
2383
2454
|
opacity,
|
|
@@ -2400,6 +2471,72 @@ var MaterialFactory = class {
|
|
|
2400
2471
|
this.meshBasicMaterialMap.set(key, material);
|
|
2401
2472
|
return material;
|
|
2402
2473
|
}
|
|
2474
|
+
createShaderMaterial({ gradualColor, center: center2, maxValue, opacity, direction, max, min }) {
|
|
2475
|
+
const key = `${gradualColor.toString()}-${vectorToString(center2)}-${maxValue}-${opacity}-${vectorToString(direction)}`;
|
|
2476
|
+
if (this.shaderMaterialMap.has(key)) {
|
|
2477
|
+
return this.shaderMaterialMap.get(key);
|
|
2478
|
+
}
|
|
2479
|
+
const vertexShader = `
|
|
2480
|
+
uniform vec3 uColor;
|
|
2481
|
+
uniform vec3 uGradualColor;
|
|
2482
|
+
uniform vec3 center;
|
|
2483
|
+
uniform vec3 uDirection;
|
|
2484
|
+
uniform vec3 uMax;
|
|
2485
|
+
uniform vec3 uMin;
|
|
2486
|
+
uniform float maxValue;
|
|
2487
|
+
varying vec3 vColor;
|
|
2488
|
+
|
|
2489
|
+
void main() {
|
|
2490
|
+
vec3 direction = normalize(uDirection);
|
|
2491
|
+
vec3 currentPosition = position - center;
|
|
2492
|
+
float colorFactor = (dot(direction, currentPosition) / maxValue) * 0.5 + 0.5;
|
|
2493
|
+
|
|
2494
|
+
vColor = mix(uColor, uGradualColor, colorFactor);
|
|
2495
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
2496
|
+
}
|
|
2497
|
+
`;
|
|
2498
|
+
const fragmentShader = `
|
|
2499
|
+
varying vec3 vColor;
|
|
2500
|
+
uniform float opacity;
|
|
2501
|
+
|
|
2502
|
+
void main() {
|
|
2503
|
+
gl_FragColor = vec4(vColor.x, vColor.y, vColor.z, opacity);
|
|
2504
|
+
}
|
|
2505
|
+
`;
|
|
2506
|
+
const material = new ShaderMaterial2({
|
|
2507
|
+
uniforms: {
|
|
2508
|
+
uColor: {
|
|
2509
|
+
value: new Color4(gradualColor[0]).convertLinearToSRGB()
|
|
2510
|
+
},
|
|
2511
|
+
uGradualColor: {
|
|
2512
|
+
value: new Color4(gradualColor[1]).convertLinearToSRGB()
|
|
2513
|
+
},
|
|
2514
|
+
center: {
|
|
2515
|
+
value: center2
|
|
2516
|
+
},
|
|
2517
|
+
maxValue: {
|
|
2518
|
+
value: maxValue
|
|
2519
|
+
},
|
|
2520
|
+
opacity: {
|
|
2521
|
+
value: opacity
|
|
2522
|
+
},
|
|
2523
|
+
uDirection: {
|
|
2524
|
+
value: direction
|
|
2525
|
+
},
|
|
2526
|
+
uMax: {
|
|
2527
|
+
value: max
|
|
2528
|
+
},
|
|
2529
|
+
uMin: {
|
|
2530
|
+
value: min
|
|
2531
|
+
}
|
|
2532
|
+
},
|
|
2533
|
+
vertexShader,
|
|
2534
|
+
fragmentShader,
|
|
2535
|
+
side: DoubleSide4
|
|
2536
|
+
});
|
|
2537
|
+
this.shaderMaterialMap.set(key, material);
|
|
2538
|
+
return material;
|
|
2539
|
+
}
|
|
2403
2540
|
dispose() {
|
|
2404
2541
|
this.lineMaterialMap.forEach((val, _) => {
|
|
2405
2542
|
val.dispose();
|
|
@@ -2413,18 +2550,22 @@ var MaterialFactory = class {
|
|
|
2413
2550
|
val.dispose();
|
|
2414
2551
|
});
|
|
2415
2552
|
this.meshBasicMaterialMap.clear();
|
|
2553
|
+
this.shaderMaterialMap.forEach((val, _) => {
|
|
2554
|
+
val.dispose();
|
|
2555
|
+
});
|
|
2556
|
+
this.shaderMaterialMap.clear();
|
|
2416
2557
|
}
|
|
2417
2558
|
};
|
|
2418
2559
|
|
|
2419
2560
|
// src/utils/camera-bound.ts
|
|
2420
|
-
import { Box3 as Box37, Vector3 as
|
|
2561
|
+
import { Box3 as Box37, Vector3 as Vector312 } from "three";
|
|
2421
2562
|
var CameraBound = class {
|
|
2422
2563
|
constructor(context) {
|
|
2423
2564
|
this.context = context;
|
|
2424
2565
|
__publicField(this, "prevCamera", {
|
|
2425
|
-
position: new
|
|
2566
|
+
position: new Vector312(),
|
|
2426
2567
|
zoom: 1,
|
|
2427
|
-
target: new
|
|
2568
|
+
target: new Vector312()
|
|
2428
2569
|
});
|
|
2429
2570
|
__publicField(this, "enable", true);
|
|
2430
2571
|
__publicField(this, "onCameraChange", () => {
|
|
@@ -2470,8 +2611,8 @@ var CameraBound = class {
|
|
|
2470
2611
|
const { min, max } = box;
|
|
2471
2612
|
const lb = vector3ToDevice(min, camera, w, h);
|
|
2472
2613
|
const rt = vector3ToDevice(max, camera, w, h);
|
|
2473
|
-
const lt = vector3ToDevice(new
|
|
2474
|
-
const rb = vector3ToDevice(new
|
|
2614
|
+
const lt = vector3ToDevice(new Vector312(min.x, max.y, max.z), camera, w, h);
|
|
2615
|
+
const rb = vector3ToDevice(new Vector312(max.x, min.y, min.z), camera, w, h);
|
|
2475
2616
|
const left = Math.min(lb.x, rt.x, lt.x, rb.x);
|
|
2476
2617
|
const right = Math.max(lb.x, rt.x, lt.x, rb.x);
|
|
2477
2618
|
const top = Math.min(lb.y, rt.y, lt.y, rb.y);
|
|
@@ -2606,7 +2747,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2606
2747
|
/**
|
|
2607
2748
|
* 获取两个点之间的像素数
|
|
2608
2749
|
*/
|
|
2609
|
-
getRatio(point1 = new
|
|
2750
|
+
getRatio(point1 = new Vector313(0, 0, 0), point22 = new Vector313(100, 0, 0)) {
|
|
2610
2751
|
const { clientWidth, clientHeight } = this.container;
|
|
2611
2752
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
2612
2753
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
@@ -2615,7 +2756,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2615
2756
|
changeAmbientLightColor(color) {
|
|
2616
2757
|
this.lights.children.forEach((item) => {
|
|
2617
2758
|
if (item instanceof AmbientLight2) {
|
|
2618
|
-
item.color = new
|
|
2759
|
+
item.color = new Color5(color);
|
|
2619
2760
|
}
|
|
2620
2761
|
});
|
|
2621
2762
|
}
|
|
@@ -2746,7 +2887,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2746
2887
|
);
|
|
2747
2888
|
}
|
|
2748
2889
|
getCameraLookAt() {
|
|
2749
|
-
return new
|
|
2890
|
+
return new Vector313().subVectors(this.control.target, this.camera.position);
|
|
2750
2891
|
}
|
|
2751
2892
|
/**
|
|
2752
2893
|
* 按照一个中心点设置相机的放大缩小
|
|
@@ -2801,10 +2942,10 @@ var Context = class extends EventDispatcher6 {
|
|
|
2801
2942
|
const boundingBox = new Box38().setFromObject(object);
|
|
2802
2943
|
this.setPolarAngle(polar, 0);
|
|
2803
2944
|
const { max, min } = boundingBox;
|
|
2804
|
-
const leftTop = new
|
|
2805
|
-
const rightTop = new
|
|
2806
|
-
const rightBottom = new
|
|
2807
|
-
const leftBottom = new
|
|
2945
|
+
const leftTop = new Vector313(min.x, max.y, min.z);
|
|
2946
|
+
const rightTop = new Vector313(max.x, max.y, min.z);
|
|
2947
|
+
const rightBottom = new Vector313(max.x, min.y, max.z);
|
|
2948
|
+
const leftBottom = new Vector313(min.x, min.y, max.z);
|
|
2808
2949
|
const leftTop2d = vector3ToDevice(leftTop, this.camera, width, height);
|
|
2809
2950
|
const rightTop2d = vector3ToDevice(rightTop, this.camera, width, height);
|
|
2810
2951
|
const leftBottom2d = vector3ToDevice(leftBottom, this.camera, width, height);
|
|
@@ -2819,7 +2960,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
2819
2960
|
const xScale = (width - right - left) / size.x;
|
|
2820
2961
|
const yScale = (height - top - bottom) / size.y;
|
|
2821
2962
|
const scale = Math.min(xScale, yScale);
|
|
2822
|
-
const center2 = new
|
|
2963
|
+
const center2 = new Vector313((max.x + min.x) / 2, (max.y + min.y) / 2, 0);
|
|
2823
2964
|
return { zoom: scale * this.camera.zoom, center: center2 };
|
|
2824
2965
|
}
|
|
2825
2966
|
/**
|
|
@@ -2942,10 +3083,10 @@ var defaultConfig = {
|
|
|
2942
3083
|
time: 100
|
|
2943
3084
|
},
|
|
2944
3085
|
ground: {
|
|
2945
|
-
color: "#
|
|
3086
|
+
color: "#E4E8E9",
|
|
2946
3087
|
opacity: 1,
|
|
2947
|
-
height: 3,
|
|
2948
|
-
stroke:
|
|
3088
|
+
height: 1e-3,
|
|
3089
|
+
stroke: false,
|
|
2949
3090
|
strokeColor: "#E6E6E6",
|
|
2950
3091
|
strokeOpacity: 1
|
|
2951
3092
|
},
|
|
@@ -3102,8 +3243,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3102
3243
|
if (buildGround) {
|
|
3103
3244
|
const center2 = getCenter(buildGround.info.geometry.cds[0]);
|
|
3104
3245
|
data.forEach((item) => {
|
|
3246
|
+
item.info.geometry.coords = JSON.parse(JSON.stringify(item.info.geometry.cds));
|
|
3105
3247
|
if (item.info.geometry.type === "polygon") {
|
|
3106
|
-
item.info.geometry.
|
|
3248
|
+
item.info.geometry.coords.map((cds) => {
|
|
3107
3249
|
if (Array.isArray(cds)) {
|
|
3108
3250
|
cds.forEach((coord) => {
|
|
3109
3251
|
coord[0] -= center2[0];
|
|
@@ -3113,7 +3255,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3113
3255
|
});
|
|
3114
3256
|
} else {
|
|
3115
3257
|
const [x, y] = item.info.geometry.cds;
|
|
3116
|
-
item.info.geometry.
|
|
3258
|
+
item.info.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3117
3259
|
}
|
|
3118
3260
|
item.info.transformToBuildingGround = true;
|
|
3119
3261
|
});
|
|
@@ -3212,7 +3354,8 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3212
3354
|
var _a;
|
|
3213
3355
|
if (graphic.options.geometry.type === "polygon") {
|
|
3214
3356
|
const model = (_a = this.context.currentFloor) == null ? void 0 : _a.addModel(__spreadProps(__spreadValues({}, options), {
|
|
3215
|
-
position: graphic.getPosition().setZ(0.1)
|
|
3357
|
+
position: graphic.getPosition().setZ(0.1),
|
|
3358
|
+
id: graphic.options.id
|
|
3216
3359
|
}));
|
|
3217
3360
|
if (model) {
|
|
3218
3361
|
const { facilityAngle = 0, facilityXScale = 1, facilityYScale = 1 } = graphic.options.userData;
|
|
@@ -3306,9 +3449,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3306
3449
|
resetView(duration = 300) {
|
|
3307
3450
|
return __async(this, null, function* () {
|
|
3308
3451
|
const time = duration / 3;
|
|
3309
|
-
yield this.context.setAzimuthalAngle(
|
|
3452
|
+
yield this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal, time);
|
|
3310
3453
|
yield this.changeMapType(this.type, time);
|
|
3311
|
-
yield this.context.fitCameraToGround(
|
|
3454
|
+
yield this.context.fitCameraToGround(this.config.defaultPadding, time, false);
|
|
3312
3455
|
});
|
|
3313
3456
|
}
|
|
3314
3457
|
/**
|
|
@@ -3449,7 +3592,8 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3449
3592
|
if (this.currentBuildGround) {
|
|
3450
3593
|
const center2 = getCenter(this.currentBuildGround.info.geometry.cds[0]);
|
|
3451
3594
|
if (options.geometry.type === "polygon") {
|
|
3452
|
-
options.geometry.
|
|
3595
|
+
options.geometry.coords = JSON.parse(JSON.stringify(options.geometry.cds));
|
|
3596
|
+
options.geometry.coords.map((cds) => {
|
|
3453
3597
|
if (Array.isArray(cds)) {
|
|
3454
3598
|
cds.forEach((coord) => {
|
|
3455
3599
|
coord[0] -= center2[0];
|
|
@@ -3459,7 +3603,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3459
3603
|
});
|
|
3460
3604
|
} else {
|
|
3461
3605
|
const [x, y] = options.geometry.cds;
|
|
3462
|
-
options.geometry.
|
|
3606
|
+
options.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3463
3607
|
}
|
|
3464
3608
|
}
|
|
3465
3609
|
}
|