@aibee/crc-bmap 0.0.14 → 0.0.16

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
@@ -159,8 +159,6 @@ function initControl(camera, domElement) {
159
159
  control.minPolarAngle = 0;
160
160
  control.maxAzimuthAngle = 0;
161
161
  control.minAzimuthAngle = 0;
162
- control.minZoom = 1;
163
- control.maxZoom = 100;
164
162
  return control;
165
163
  }
166
164
  function initShape(path, holePath = []) {
@@ -441,6 +439,12 @@ var Graphic = class extends Object3D {
441
439
  __publicField(this, "line");
442
440
  __publicField(this, "options");
443
441
  this.options = proxyOptions(merge({}, defaultOptions, options), this);
442
+ if (this.options.geometry.type === "point") {
443
+ const [x, y] = this.options.geometry.cds;
444
+ this.position.set(x, y, this.options.height + this.options.airHeight);
445
+ console.log(this.options);
446
+ return this;
447
+ }
444
448
  this.init();
445
449
  this.visible = this.options.visible;
446
450
  this.addEventListener("change-fillColor", ({ value }) => {
@@ -467,6 +471,9 @@ var Graphic = class extends Object3D {
467
471
  });
468
472
  }
469
473
  getCenter() {
474
+ if (this.options.geometry.type === "point") {
475
+ return this.position;
476
+ }
470
477
  const center2 = new Vector3();
471
478
  const box = new Box3();
472
479
  box.setFromObject(this);
@@ -474,6 +481,9 @@ var Graphic = class extends Object3D {
474
481
  return center2;
475
482
  }
476
483
  getSize() {
484
+ if (this.options.geometry.type === "point") {
485
+ return new Vector3(0, 0, 0);
486
+ }
477
487
  const box = new Box3();
478
488
  const size = new Vector3();
479
489
  box.setFromObject(this);
@@ -494,7 +504,10 @@ var Graphic = class extends Object3D {
494
504
  this.add(this.line);
495
505
  }
496
506
  initGeometry() {
497
- const shape = initShape(this.options.geometry.cds[0], this.options.geometry.cds.slice(1));
507
+ const shape = initShape(
508
+ this.options.geometry.cds[0],
509
+ this.options.geometry.cds.slice(1)
510
+ );
498
511
  const geometry = new ExtrudeGeometry(shape, {
499
512
  steps: 1,
500
513
  bevelEnabled: false,
@@ -536,6 +549,9 @@ var Graphic = class extends Object3D {
536
549
  if (!this.visible) {
537
550
  return false;
538
551
  }
552
+ if (this.options.geometry.type === "point") {
553
+ return false;
554
+ }
539
555
  const intersects = raycaster.intersectObject(this.mesh);
540
556
  if (intersects[0]) {
541
557
  const { point: position, distance } = intersects[0];
@@ -823,6 +839,7 @@ var Layer = class extends Object3D5 {
823
839
  var GraphicLayer = class extends Layer {
824
840
  constructor(context) {
825
841
  super(context);
842
+ __publicField(this, "graphicMap", /* @__PURE__ */ new Map());
826
843
  }
827
844
  getCenter() {
828
845
  const box = new Box33().setFromObject(this);
@@ -831,6 +848,7 @@ var GraphicLayer = class extends Layer {
831
848
  createGraphic(options) {
832
849
  const graphic = new Graphic(this.context, options);
833
850
  this.add(graphic);
851
+ this.graphicMap.set(options.id, graphic);
834
852
  return graphic;
835
853
  }
836
854
  /**
@@ -2094,14 +2112,19 @@ var BMap = class extends EventDispatcher6 {
2094
2112
  if (buildGround) {
2095
2113
  const center2 = getCenter(buildGround.info.geometry.cds[0]);
2096
2114
  data.forEach((item) => {
2097
- item.info.geometry.cds.map((cds) => {
2098
- if (Array.isArray(cds)) {
2099
- cds.forEach((coord) => {
2100
- coord[0] -= center2[0];
2101
- coord[1] -= center2[1];
2102
- });
2103
- }
2104
- });
2115
+ if (item.info.geometry.type === "polygon") {
2116
+ item.info.geometry.cds.map((cds) => {
2117
+ if (Array.isArray(cds)) {
2118
+ cds.forEach((coord) => {
2119
+ coord[0] -= center2[0];
2120
+ coord[1] -= center2[1];
2121
+ });
2122
+ }
2123
+ });
2124
+ } else {
2125
+ const [x, y] = item.info.geometry.cds;
2126
+ item.info.geometry.cds = [x - center2[0], y - center2[1]];
2127
+ }
2105
2128
  });
2106
2129
  }
2107
2130
  if (!this.config.useFloorCache) {
@@ -2140,6 +2163,8 @@ var BMap = class extends EventDispatcher6 {
2140
2163
  this.context.switchFloor(createdFloor.curFloor);
2141
2164
  yield this.context.fitCameraToGround(void 0, 0);
2142
2165
  this.basicZoom = this.context.camera.zoom;
2166
+ this.context.control.minZoom = this.basicZoom;
2167
+ this.context.control.maxZoom = this.basicZoom * 25;
2143
2168
  } else {
2144
2169
  console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
2145
2170
  }
@@ -2326,6 +2351,26 @@ var BMap = class extends EventDispatcher6 {
2326
2351
  this.context.control.enableRotate = true;
2327
2352
  }
2328
2353
  }
2354
+ /**
2355
+ * 根据nodeId 获取graphic
2356
+ */
2357
+ getGraphicByNodeId(nodeId) {
2358
+ if (this.context.currentFloor) {
2359
+ return this.context.currentFloor.graphicLayer.graphicMap.get(nodeId) || null;
2360
+ }
2361
+ return null;
2362
+ }
2363
+ deleteGraphic(graphic) {
2364
+ if (this.context.currentFloor) {
2365
+ this.context.currentFloor.graphicLayer.remove(graphic);
2366
+ graphic.dispose();
2367
+ this.context.currentFloor.graphicLayer.graphicMap.delete(graphic.options.id);
2368
+ }
2369
+ }
2370
+ createGraphicByOptions(options) {
2371
+ var _a;
2372
+ return (_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.createGraphic(options);
2373
+ }
2329
2374
  dispose() {
2330
2375
  this.context.dispose();
2331
2376
  clearTextTexture();