@aibee/crc-bmap 0.0.16 → 0.0.17

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
@@ -442,7 +442,6 @@ var Graphic = class extends Object3D {
442
442
  if (this.options.geometry.type === "point") {
443
443
  const [x, y] = this.options.geometry.cds;
444
444
  this.position.set(x, y, this.options.height + this.options.airHeight);
445
- console.log(this.options);
446
445
  return this;
447
446
  }
448
447
  this.init();
@@ -2048,6 +2047,8 @@ var BMap = class extends EventDispatcher6 {
2048
2047
  __publicField(this, "svgPolygon");
2049
2048
  __publicField(this, "basicZoom", 1);
2050
2049
  __publicField(this, "floorDataMap", /* @__PURE__ */ new Map());
2050
+ __publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
2051
+ __publicField(this, "currentBuildGround", null);
2051
2052
  __publicField(this, "onKeydown", (e) => {
2052
2053
  if (this.polarKeys.includes(e.code)) {
2053
2054
  this.context.control.maxPolarAngle = this.config.control.maxPolar;
@@ -2086,8 +2087,16 @@ var BMap = class extends EventDispatcher6 {
2086
2087
  return data;
2087
2088
  });
2088
2089
  }
2090
+ getBuildingKey({ brand, project, phase, building }) {
2091
+ const key = `${brand}-${project}-${phase}-${building}`;
2092
+ return key;
2093
+ }
2089
2094
  loadBuildingGround(_0) {
2090
2095
  return __async(this, arguments, function* ({ brand, project, phase, building }) {
2096
+ const key = this.getBuildingKey({ brand, project, phase, building });
2097
+ if (this.buildingGroundMap.get(key)) {
2098
+ return this.buildingGroundMap.get(key) || null;
2099
+ }
2091
2100
  const { apiDomain, apiPath: { floorRange }, apiInfo } = this.config;
2092
2101
  const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${phase}&building=${building}`;
2093
2102
  const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
@@ -2097,12 +2106,18 @@ var BMap = class extends EventDispatcher6 {
2097
2106
  }
2098
2107
  return data2;
2099
2108
  });
2109
+ this.buildingGroundMap.set(key, data);
2100
2110
  return data;
2101
2111
  });
2102
2112
  }
2113
+ getFloorKey({ brand, project, phase, building, floor, ts }) {
2114
+ const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}`;
2115
+ return floorKey;
2116
+ }
2103
2117
  load(_0) {
2104
2118
  return __async(this, arguments, function* ({ brand, project, phase, building, floor, ts }) {
2105
- if (this.floorDataMap.get(floor)) {
2119
+ const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts });
2120
+ if (this.floorDataMap.get(floorKey)) {
2106
2121
  return;
2107
2122
  }
2108
2123
  const [data, buildGround] = yield Promise.all([
@@ -2130,7 +2145,7 @@ var BMap = class extends EventDispatcher6 {
2130
2145
  if (!this.config.useFloorCache) {
2131
2146
  this.floorDataMap.clear();
2132
2147
  }
2133
- this.floorDataMap.set(floor, data);
2148
+ this.floorDataMap.set(floorKey, data);
2134
2149
  return data;
2135
2150
  });
2136
2151
  }
@@ -2154,13 +2169,18 @@ var BMap = class extends EventDispatcher6 {
2154
2169
  curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
2155
2170
  return { curFloor, graphics };
2156
2171
  }
2157
- switchFloor(floor) {
2158
- return __async(this, null, function* () {
2159
- const curFloorData = this.floorDataMap.get(floor);
2172
+ 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 });
2175
+ const curFloorData = this.floorDataMap.get(floorKey);
2160
2176
  if (curFloorData) {
2177
+ const buildingKey = this.getBuildingKey({ brand, project, phase, building });
2178
+ this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
2161
2179
  const createdFloor = this.createFloor(curFloorData);
2162
2180
  if (createdFloor) {
2163
2181
  this.context.switchFloor(createdFloor.curFloor);
2182
+ this.context.control.minZoom = 0;
2183
+ this.context.control.maxZoom = Infinity;
2164
2184
  yield this.context.fitCameraToGround(void 0, 0);
2165
2185
  this.basicZoom = this.context.camera.zoom;
2166
2186
  this.context.control.minZoom = this.basicZoom;
@@ -2369,6 +2389,22 @@ var BMap = class extends EventDispatcher6 {
2369
2389
  }
2370
2390
  createGraphicByOptions(options) {
2371
2391
  var _a;
2392
+ if (this.currentBuildGround) {
2393
+ const center2 = getCenter(this.currentBuildGround.info.geometry.cds[0]);
2394
+ if (options.geometry.type === "polygon") {
2395
+ options.geometry.cds.map((cds) => {
2396
+ if (Array.isArray(cds)) {
2397
+ cds.forEach((coord) => {
2398
+ coord[0] -= center2[0];
2399
+ coord[1] -= center2[1];
2400
+ });
2401
+ }
2402
+ });
2403
+ } else {
2404
+ const [x, y] = options.geometry.cds;
2405
+ options.geometry.cds = [x - center2[0], y - center2[1]];
2406
+ }
2407
+ }
2372
2408
  return (_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.createGraphic(options);
2373
2409
  }
2374
2410
  dispose() {