@aibee/crc-bmap 0.0.17 → 0.0.20

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/lib/bmap.esm.js CHANGED
@@ -374,7 +374,7 @@ import {
374
374
  Vector3 as Vector38,
375
375
  Vector2 as Vector23,
376
376
  Raycaster as Raycaster3,
377
- Box3 as Box35,
377
+ Box3 as Box36,
378
378
  Color as Color4,
379
379
  AmbientLight as AmbientLight2
380
380
  } from "three";
@@ -1435,6 +1435,103 @@ var SvgPolygon = class extends BaseSvg {
1435
1435
  }
1436
1436
  };
1437
1437
 
1438
+ // src/elements/select-box.ts
1439
+ import { Box3 as Box35 } from "three";
1440
+ var SelectBox = class extends BaseSvg {
1441
+ constructor(context) {
1442
+ super(context);
1443
+ this.context = context;
1444
+ __publicField(this, "rect");
1445
+ __publicField(this, "cornerRect", []);
1446
+ // 四个角上的方块
1447
+ __publicField(this, "centerRect", []);
1448
+ // 四个线中间的方块
1449
+ __publicField(this, "graphic");
1450
+ __publicField(this, "onUpdate", () => {
1451
+ if (!this.graphic) {
1452
+ setRectPosition(this.rect, 0, 0, 0, 0);
1453
+ for (let i = 0; i < this.cornerRect.length; i++) {
1454
+ setRectPosition(this.cornerRect[i], 0, 0, 0, 0);
1455
+ setRectPosition(this.centerRect[i], 0, 0, 0, 0);
1456
+ }
1457
+ } else {
1458
+ const box = new Box35().setFromObject(this.graphic);
1459
+ const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
1460
+ const { min, max } = box;
1461
+ const leftBottom = vector3ToDevice(min, camera, w, h);
1462
+ const rightTop = vector3ToDevice(max, camera, w, h);
1463
+ setRectPosition(this.rect, leftBottom.x, rightTop.y, Math.abs(rightTop.x - leftBottom.x), Math.abs(rightTop.y - leftBottom.y));
1464
+ const { x: left, y: bottom } = leftBottom;
1465
+ const { x: right, y: top } = rightTop;
1466
+ const halfWidth = 5;
1467
+ const corners = [
1468
+ { x: left - halfWidth, y: top - halfWidth },
1469
+ // 左上角
1470
+ { x: right - halfWidth, y: top - halfWidth },
1471
+ // 右上角
1472
+ { x: left - halfWidth, y: bottom - halfWidth },
1473
+ // 左下角
1474
+ { x: right - halfWidth, y: bottom - halfWidth }
1475
+ // 右下角
1476
+ ];
1477
+ for (let i = 0; i < corners.length; i++) {
1478
+ setRectPosition(this.cornerRect[i], corners[i].x, corners[i].y, halfWidth * 2, halfWidth * 2);
1479
+ }
1480
+ const centerHalfWidth = 4;
1481
+ const centerX = (left + right) / 2;
1482
+ const centerY = (bottom + top) / 2;
1483
+ const centers = [
1484
+ { x: centerX - centerHalfWidth, y: top - centerHalfWidth },
1485
+ // 上
1486
+ { x: left - centerHalfWidth, y: centerY - centerHalfWidth },
1487
+ // 左
1488
+ { x: right - centerHalfWidth, y: centerY - centerHalfWidth },
1489
+ // 右
1490
+ { x: centerX - centerHalfWidth, y: bottom - centerHalfWidth }
1491
+ // 下
1492
+ ];
1493
+ for (let i = 0; i < centers.length; i++) {
1494
+ setRectPosition(this.centerRect[i], centers[i].x, centers[i].y, centerHalfWidth * 2, centerHalfWidth * 2);
1495
+ }
1496
+ }
1497
+ });
1498
+ const { config: { svg: { line } } } = context;
1499
+ this.rect = createRect(line.stroke, "transparent");
1500
+ this.svg.appendChild(this.rect);
1501
+ for (let i = 0; i < 4; i++) {
1502
+ this.cornerRect[i] = createRect(line.stroke, "#ffffff");
1503
+ this.centerRect[i] = createRect(line.stroke, "#ffffff");
1504
+ this.svg.appendChild(this.cornerRect[i]);
1505
+ this.svg.appendChild(this.centerRect[i]);
1506
+ }
1507
+ this.registryEvent();
1508
+ }
1509
+ setEnable(enable) {
1510
+ super.setEnable(enable);
1511
+ if (enable) {
1512
+ this.registryEvent();
1513
+ } else {
1514
+ this.unRegistryEvent();
1515
+ }
1516
+ }
1517
+ registryEvent() {
1518
+ this.context.addEventListener("update", this.onUpdate);
1519
+ }
1520
+ unRegistryEvent() {
1521
+ this.context.removeEventListener("update", this.onUpdate);
1522
+ }
1523
+ selectGraphic(graphic) {
1524
+ this.graphic = graphic;
1525
+ }
1526
+ dispose() {
1527
+ super.dispose();
1528
+ this.unRegistryEvent();
1529
+ this.rect = null;
1530
+ this.cornerRect = [];
1531
+ this.centerRect = [];
1532
+ }
1533
+ };
1534
+
1438
1535
  // src/operations/selection/box-selection.ts
1439
1536
  import { Frustum } from "three";
1440
1537
  var BoxSelection = class extends BaseSvg {
@@ -1921,7 +2018,7 @@ var Context = class extends EventDispatcher5 {
1921
2018
  fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500) {
1922
2019
  const [top, right, bottom, left] = padding;
1923
2020
  const { clientWidth, clientHeight } = this.container;
1924
- const boundingBox = new Box35().setFromObject(object);
2021
+ const boundingBox = new Box36().setFromObject(object);
1925
2022
  const { max, min } = boundingBox;
1926
2023
  const max2d = vector3ToDevice(max, this.camera, clientWidth, clientHeight);
1927
2024
  const min2d = vector3ToDevice(min, this.camera, clientWidth, clientHeight);
@@ -2077,9 +2174,9 @@ var BMap = class extends EventDispatcher6 {
2077
2174
  this.context.render();
2078
2175
  }
2079
2176
  loadGraphics(_0) {
2080
- return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts }) {
2177
+ return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts, resource_type_list }) {
2081
2178
  const { apiDomain, apiPath: { floorGraphic }, apiInfo } = this.config;
2082
- const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=`;
2179
+ const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
2083
2180
  const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
2084
2181
  (res || []).map((item) => item.info = JSON.parse(item.info));
2085
2182
  return res || [];
@@ -2110,18 +2207,18 @@ var BMap = class extends EventDispatcher6 {
2110
2207
  return data;
2111
2208
  });
2112
2209
  }
2113
- getFloorKey({ brand, project, phase, building, floor, ts }) {
2114
- const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}`;
2210
+ getFloorKey({ brand, project, phase, building, floor, ts, resource_type_list }) {
2211
+ const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}-${resource_type_list}`;
2115
2212
  return floorKey;
2116
2213
  }
2117
2214
  load(_0) {
2118
- return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts }) {
2119
- const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts });
2215
+ return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts, resource_type_list }) {
2216
+ const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts, resource_type_list });
2120
2217
  if (this.floorDataMap.get(floorKey)) {
2121
2218
  return;
2122
2219
  }
2123
2220
  const [data, buildGround] = yield Promise.all([
2124
- this.loadGraphics({ brand, project, phase, building, floor, ts }),
2221
+ this.loadGraphics({ brand, project, phase, building, floor, ts, resource_type_list }),
2125
2222
  this.loadBuildingGround({ brand, project, phase, building })
2126
2223
  ]);
2127
2224
  if (buildGround) {
@@ -2170,8 +2267,8 @@ var BMap = class extends EventDispatcher6 {
2170
2267
  return { curFloor, graphics };
2171
2268
  }
2172
2269
  switchFloor(_0) {
2173
- return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts }) {
2174
- const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts });
2270
+ return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts, resource_type_list }) {
2271
+ const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts, resource_type_list });
2175
2272
  const curFloorData = this.floorDataMap.get(floorKey);
2176
2273
  if (curFloorData) {
2177
2274
  const buildingKey = this.getBuildingKey({ brand, project, phase, building });
@@ -2427,6 +2524,7 @@ export {
2427
2524
  Overlay,
2428
2525
  Poi,
2429
2526
  PoiLayer,
2527
+ SelectBox,
2430
2528
  Selection,
2431
2529
  Shadow,
2432
2530
  SvgLine,