@aibee/crc-bmap 0.0.19 → 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);
@@ -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,