@aibee/crc-bmap 0.0.93 → 0.0.95
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/a.json +5688 -0
- package/example/src/main.ts +392 -328
- package/example/vite.config.ts +1 -1
- package/lib/bmap.cjs.min.js +21 -3
- package/lib/bmap.cjs.min.js.map +4 -4
- package/lib/bmap.esm.js +1100 -903
- package/lib/bmap.esm.js.map +4 -4
- package/lib/bmap.esm.min.js +21 -3
- package/lib/bmap.esm.min.js.map +4 -4
- package/lib/bmap.min.js +21 -3
- package/lib/bmap.min.js.map +4 -4
- package/lib/src/api/floor.d.ts +15 -0
- package/lib/src/api/index.d.ts +1 -0
- package/lib/src/bmap.d.ts +18 -18
- package/lib/src/config.d.ts +1 -0
- package/lib/src/elements/floor.d.ts +1 -0
- package/lib/src/elements/poi.d.ts +1 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/plugins/base.d.ts +6 -0
- package/lib/src/plugins/equipment/equipment.d.ts +21 -0
- package/lib/src/plugins/equipment/index.d.ts +1 -0
- package/lib/src/plugins/index.d.ts +3 -0
- package/lib/src/plugins/navigation/index.d.ts +1 -0
- package/lib/src/plugins/navigation/navigation.d.ts +9 -0
- package/lib/src/plugins/navigation/path.worker.d.ts +2 -0
- package/lib/src/plugins/split-load/index.d.ts +1 -0
- package/lib/src/plugins/split-load/split-load.d.ts +14 -0
- package/lib/src/types/index.d.ts +7 -0
- package/lib/src/utils/coordinate.d.ts +2 -2
- package/lib/src/utils/event-name.d.ts +4 -0
- package/lib/src/utils/events.d.ts +17 -0
- package/lib/src/utils/index.d.ts +3 -0
- package/lib/src/utils/obj-utils.d.ts +6 -0
- package/package.json +5 -4
package/lib/bmap.esm.js
CHANGED
|
@@ -1,60 +1,13 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __pow = Math.pow;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __publicField = (obj, key, value) => {
|
|
22
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
23
|
-
return value;
|
|
24
|
-
};
|
|
25
|
-
var __async = (__this, __arguments, generator) => {
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
var fulfilled = (value) => {
|
|
28
|
-
try {
|
|
29
|
-
step(generator.next(value));
|
|
30
|
-
} catch (e) {
|
|
31
|
-
reject(e);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var rejected = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.throw(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
42
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
1
|
// src/bmap.ts
|
|
47
2
|
import { EventDispatcher as EventDispatcher7, Vector3 as Vector314 } from "three";
|
|
48
3
|
|
|
49
4
|
// src/utils/timer.ts
|
|
50
5
|
var Timer = class {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
}
|
|
6
|
+
tasks = {
|
|
7
|
+
requestAnimation: /* @__PURE__ */ new Set(),
|
|
8
|
+
timeout: /* @__PURE__ */ new Set(),
|
|
9
|
+
interval: /* @__PURE__ */ new Set()
|
|
10
|
+
};
|
|
58
11
|
requestAnimationFrame(fn) {
|
|
59
12
|
const timer = window.requestAnimationFrame(() => {
|
|
60
13
|
this.tasks.requestAnimation.delete(timer);
|
|
@@ -187,7 +140,6 @@ function initDirectionalLight(color = 16777215, intensity = 1) {
|
|
|
187
140
|
|
|
188
141
|
// src/utils/dispose.ts
|
|
189
142
|
function dispose(o, recursive) {
|
|
190
|
-
var _a;
|
|
191
143
|
if (recursive && o.children && o.children.length) {
|
|
192
144
|
o.children.forEach((child) => {
|
|
193
145
|
dispose(child, recursive);
|
|
@@ -208,7 +160,7 @@ function dispose(o, recursive) {
|
|
|
208
160
|
}
|
|
209
161
|
}
|
|
210
162
|
if (o.isLight) {
|
|
211
|
-
|
|
163
|
+
o.dispose?.();
|
|
212
164
|
}
|
|
213
165
|
}
|
|
214
166
|
|
|
@@ -476,6 +428,81 @@ function isControl(key) {
|
|
|
476
428
|
return key === "Control";
|
|
477
429
|
}
|
|
478
430
|
|
|
431
|
+
// src/utils/events.ts
|
|
432
|
+
var oncePrefix = "__once__";
|
|
433
|
+
var Events = class {
|
|
434
|
+
events = /* @__PURE__ */ new Map();
|
|
435
|
+
on(type, callback) {
|
|
436
|
+
if (typeof callback !== "function")
|
|
437
|
+
return void 0;
|
|
438
|
+
const events = this.events.get(type);
|
|
439
|
+
if (events) {
|
|
440
|
+
return events.add(callback);
|
|
441
|
+
}
|
|
442
|
+
return this.events.set(type, /* @__PURE__ */ new Set([callback]));
|
|
443
|
+
}
|
|
444
|
+
once(type, callback) {
|
|
445
|
+
if (typeof callback !== "function")
|
|
446
|
+
return void 0;
|
|
447
|
+
const event = `${oncePrefix}${type}`;
|
|
448
|
+
const events = this.events.get(event);
|
|
449
|
+
if (events) {
|
|
450
|
+
return events.add(callback);
|
|
451
|
+
}
|
|
452
|
+
return this.events.set(event, /* @__PURE__ */ new Set([callback]));
|
|
453
|
+
}
|
|
454
|
+
off(type, callback) {
|
|
455
|
+
const events = this.events.get(type);
|
|
456
|
+
const onceEvents = this.events.get(`${oncePrefix}${type}`);
|
|
457
|
+
if (!events && !onceEvents) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (callback === void 0) {
|
|
461
|
+
events?.clear();
|
|
462
|
+
onceEvents?.clear();
|
|
463
|
+
}
|
|
464
|
+
if (events?.has(callback)) {
|
|
465
|
+
events.delete(callback);
|
|
466
|
+
}
|
|
467
|
+
if (onceEvents?.has(callback)) {
|
|
468
|
+
onceEvents.delete(callback);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
offAll() {
|
|
472
|
+
this.events.clear();
|
|
473
|
+
}
|
|
474
|
+
emit(type, ...args) {
|
|
475
|
+
const events = this.events.get(type);
|
|
476
|
+
const onceEvents = this.events.get(`${oncePrefix}${type}`);
|
|
477
|
+
if (!events && !onceEvents) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
events?.forEach((fn) => {
|
|
481
|
+
if (typeof fn === "function") {
|
|
482
|
+
fn(...args);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
onceEvents?.forEach((fn) => {
|
|
486
|
+
if (typeof fn === "function") {
|
|
487
|
+
fn(...args);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
onceEvents?.clear();
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// src/utils/event-name.ts
|
|
495
|
+
var HooksName = /* @__PURE__ */ ((HooksName2) => {
|
|
496
|
+
HooksName2["SWITCH_FLOOR_BEFORE"] = "switch_floor_before";
|
|
497
|
+
HooksName2["SWITCH_FLOOR_AFTER"] = "switch_floor_after";
|
|
498
|
+
return HooksName2;
|
|
499
|
+
})(HooksName || {});
|
|
500
|
+
|
|
501
|
+
// src/utils/obj-utils.ts
|
|
502
|
+
function generatorKeyByObj(obj) {
|
|
503
|
+
return Object.keys(obj).sort().map((key) => `${key}=${obj[key]}`).join("&");
|
|
504
|
+
}
|
|
505
|
+
|
|
479
506
|
// src/context.ts
|
|
480
507
|
import {
|
|
481
508
|
EventDispatcher as EventDispatcher6,
|
|
@@ -548,15 +575,8 @@ var Graphic = class extends Object3D {
|
|
|
548
575
|
constructor(context, options) {
|
|
549
576
|
super();
|
|
550
577
|
this.context = context;
|
|
551
|
-
__publicField(this, "geometry");
|
|
552
|
-
__publicField(this, "material");
|
|
553
|
-
__publicField(this, "mesh");
|
|
554
|
-
__publicField(this, "line");
|
|
555
|
-
__publicField(this, "lineMaterial");
|
|
556
|
-
__publicField(this, "lineGeometry");
|
|
557
|
-
__publicField(this, "options");
|
|
558
578
|
this.options = proxyOptions(
|
|
559
|
-
|
|
579
|
+
{ ...defaultOptions, ...options },
|
|
560
580
|
this
|
|
561
581
|
);
|
|
562
582
|
if (this.options.geometry.type === "point") {
|
|
@@ -599,7 +619,6 @@ var Graphic = class extends Object3D {
|
|
|
599
619
|
this.visible = value;
|
|
600
620
|
});
|
|
601
621
|
this.addEventListener("change-stroke", ({ value }) => {
|
|
602
|
-
var _a;
|
|
603
622
|
if (value) {
|
|
604
623
|
if (this.line) {
|
|
605
624
|
return;
|
|
@@ -609,7 +628,7 @@ var Graphic = class extends Object3D {
|
|
|
609
628
|
this.createBorder();
|
|
610
629
|
} else if (this.line) {
|
|
611
630
|
this.remove(this.line);
|
|
612
|
-
|
|
631
|
+
this.lineGeometry?.dispose();
|
|
613
632
|
}
|
|
614
633
|
});
|
|
615
634
|
this.addEventListener("change-renderType", () => {
|
|
@@ -621,6 +640,13 @@ var Graphic = class extends Object3D {
|
|
|
621
640
|
this.initMesh();
|
|
622
641
|
});
|
|
623
642
|
}
|
|
643
|
+
geometry;
|
|
644
|
+
material;
|
|
645
|
+
mesh;
|
|
646
|
+
line;
|
|
647
|
+
lineMaterial;
|
|
648
|
+
lineGeometry;
|
|
649
|
+
options;
|
|
624
650
|
getCenter() {
|
|
625
651
|
if (this.options.geometry.type === "point") {
|
|
626
652
|
return this.position.clone();
|
|
@@ -821,9 +847,8 @@ var Graphic = class extends Object3D {
|
|
|
821
847
|
return false;
|
|
822
848
|
}
|
|
823
849
|
dispose() {
|
|
824
|
-
var _a;
|
|
825
850
|
this.geometry.dispose();
|
|
826
|
-
|
|
851
|
+
this.line?.geometry.dispose();
|
|
827
852
|
this.clear();
|
|
828
853
|
}
|
|
829
854
|
};
|
|
@@ -838,11 +863,11 @@ import {
|
|
|
838
863
|
DoubleSide as DoubleSide2
|
|
839
864
|
} from "three";
|
|
840
865
|
var Shadow = class extends Object3D2 {
|
|
866
|
+
directionalLight;
|
|
867
|
+
plane;
|
|
868
|
+
basicOpacity = 0.07;
|
|
841
869
|
constructor() {
|
|
842
870
|
super();
|
|
843
|
-
__publicField(this, "directionalLight");
|
|
844
|
-
__publicField(this, "plane");
|
|
845
|
-
__publicField(this, "basicOpacity", 0.07);
|
|
846
871
|
this.directionalLight = this.initLight();
|
|
847
872
|
this.initPlane();
|
|
848
873
|
}
|
|
@@ -914,22 +939,7 @@ var Overlay = class extends EventDispatcher {
|
|
|
914
939
|
constructor(context, options = {}) {
|
|
915
940
|
super();
|
|
916
941
|
this.context = context;
|
|
917
|
-
|
|
918
|
-
__publicField(this, "element");
|
|
919
|
-
__publicField(this, "position", new Vector34());
|
|
920
|
-
__publicField(this, "clientPos", { x: 0, y: 0 });
|
|
921
|
-
__publicField(this, "visible", true);
|
|
922
|
-
__publicField(this, "options");
|
|
923
|
-
__publicField(this, "placement", "top");
|
|
924
|
-
__publicField(this, "observer", null);
|
|
925
|
-
__publicField(this, "onUpdate", () => {
|
|
926
|
-
if (this.options.autoChangePlacement) {
|
|
927
|
-
this.usePlacement();
|
|
928
|
-
} else {
|
|
929
|
-
this.updatePosition();
|
|
930
|
-
}
|
|
931
|
-
});
|
|
932
|
-
this.options = __spreadValues(__spreadValues({}, defaultOptions2), options);
|
|
942
|
+
this.options = { ...defaultOptions2, ...options };
|
|
933
943
|
this.registryEvent();
|
|
934
944
|
this.div = this.initDiv();
|
|
935
945
|
if (this.options.appendToBody) {
|
|
@@ -938,6 +948,14 @@ var Overlay = class extends EventDispatcher {
|
|
|
938
948
|
this.context.container.appendChild(this.div);
|
|
939
949
|
}
|
|
940
950
|
}
|
|
951
|
+
div;
|
|
952
|
+
element;
|
|
953
|
+
position = new Vector34();
|
|
954
|
+
clientPos = { x: 0, y: 0 };
|
|
955
|
+
visible = true;
|
|
956
|
+
options;
|
|
957
|
+
placement = "top";
|
|
958
|
+
observer = null;
|
|
941
959
|
initObserver() {
|
|
942
960
|
const observer = new MutationObserver(
|
|
943
961
|
debounce(() => {
|
|
@@ -1168,6 +1186,13 @@ var Overlay = class extends EventDispatcher {
|
|
|
1168
1186
|
}
|
|
1169
1187
|
this._updatePosition(x, y);
|
|
1170
1188
|
}
|
|
1189
|
+
onUpdate = () => {
|
|
1190
|
+
if (this.options.autoChangePlacement) {
|
|
1191
|
+
this.usePlacement();
|
|
1192
|
+
} else {
|
|
1193
|
+
this.updatePosition();
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1171
1196
|
registryEvent() {
|
|
1172
1197
|
this.context.addEventListener("update", this.onUpdate);
|
|
1173
1198
|
}
|
|
@@ -1175,11 +1200,10 @@ var Overlay = class extends EventDispatcher {
|
|
|
1175
1200
|
this.context.removeEventListener("update", this.onUpdate);
|
|
1176
1201
|
}
|
|
1177
1202
|
dispose() {
|
|
1178
|
-
var _a, _b;
|
|
1179
1203
|
this.unRegistryEvent();
|
|
1180
1204
|
this.unBindElement();
|
|
1181
|
-
|
|
1182
|
-
|
|
1205
|
+
this.observer?.disconnect();
|
|
1206
|
+
this.div?.remove();
|
|
1183
1207
|
this.div = null;
|
|
1184
1208
|
}
|
|
1185
1209
|
};
|
|
@@ -1202,24 +1226,10 @@ var defaultOptions3 = {
|
|
|
1202
1226
|
};
|
|
1203
1227
|
var Poi = class extends EventDispatcher2 {
|
|
1204
1228
|
constructor(context, options) {
|
|
1205
|
-
var _a, _b, _c;
|
|
1206
1229
|
super();
|
|
1207
1230
|
this.context = context;
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
__publicField(this, "img");
|
|
1211
|
-
__publicField(this, "overlay");
|
|
1212
|
-
__publicField(this, "options");
|
|
1213
|
-
__publicField(this, "visible", true);
|
|
1214
|
-
__publicField(this, "size", { width: 0, height: 0 });
|
|
1215
|
-
__publicField(this, "position", new Vector35());
|
|
1216
|
-
__publicField(this, "userData", {});
|
|
1217
|
-
__publicField(this, "showTextStatus", true);
|
|
1218
|
-
__publicField(this, "_changePosition", () => {
|
|
1219
|
-
this.overlay.updatePosition(true);
|
|
1220
|
-
});
|
|
1221
|
-
this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions3), options), this);
|
|
1222
|
-
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);
|
|
1231
|
+
this.options = proxyOptions({ ...defaultOptions3, ...options }, this);
|
|
1232
|
+
this.position.set(options.position?.x || 0, options.position?.y || 0, options.position?.z || 0);
|
|
1223
1233
|
this.overlay = new Overlay(this.context, { autoUpdate: false });
|
|
1224
1234
|
this.overlay.addEventListener("update-position", ({ x, y, height }) => {
|
|
1225
1235
|
this.overlay.div.style.transform = `translate3d(calc(${x}px - 50%), calc(${-height + y}px - ${this.options.icon ? "100%" : "50%"}), 0)`;
|
|
@@ -1252,8 +1262,8 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1252
1262
|
});
|
|
1253
1263
|
this.addEventListener("change-icon_size", ({ value }) => {
|
|
1254
1264
|
if (this.img) {
|
|
1255
|
-
this.img.style.width = `${
|
|
1256
|
-
this.img.style.height = `${
|
|
1265
|
+
this.img.style.width = `${value?.[0] || 32}px`;
|
|
1266
|
+
this.img.style.height = `${value?.[1] || 32}px`;
|
|
1257
1267
|
this.resetSize();
|
|
1258
1268
|
}
|
|
1259
1269
|
});
|
|
@@ -1271,29 +1281,41 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1271
1281
|
this.div.style.background = value;
|
|
1272
1282
|
});
|
|
1273
1283
|
}
|
|
1284
|
+
div;
|
|
1285
|
+
textDiv;
|
|
1286
|
+
img;
|
|
1287
|
+
overlay;
|
|
1288
|
+
options;
|
|
1289
|
+
visible = true;
|
|
1290
|
+
size = { width: 0, height: 0 };
|
|
1291
|
+
position = new Vector35();
|
|
1292
|
+
userData = {};
|
|
1293
|
+
showTextStatus = true;
|
|
1294
|
+
disposed = false;
|
|
1274
1295
|
get withinDisplayRange() {
|
|
1275
1296
|
return this.overlay.withinDisplayRange;
|
|
1276
1297
|
}
|
|
1277
|
-
resetSize() {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
this.size = {
|
|
1286
|
-
width: width + 2,
|
|
1287
|
-
height: height + 2
|
|
1288
|
-
};
|
|
1289
|
-
} else {
|
|
1290
|
-
const { width, height } = this.div.getBoundingClientRect();
|
|
1291
|
-
this.size = {
|
|
1292
|
-
width: width + 2,
|
|
1293
|
-
height: height + 2
|
|
1294
|
-
};
|
|
1298
|
+
async resetSize() {
|
|
1299
|
+
if (this.disposed) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
await sleepOnePromise();
|
|
1303
|
+
if (this.options.box_only_icon) {
|
|
1304
|
+
if (!this.img) {
|
|
1305
|
+
return;
|
|
1295
1306
|
}
|
|
1296
|
-
|
|
1307
|
+
const { width, height } = this.img.getBoundingClientRect();
|
|
1308
|
+
this.size = {
|
|
1309
|
+
width: width + 2,
|
|
1310
|
+
height: height + 2
|
|
1311
|
+
};
|
|
1312
|
+
} else {
|
|
1313
|
+
const { width, height } = this.div.getBoundingClientRect();
|
|
1314
|
+
this.size = {
|
|
1315
|
+
width: width + 2,
|
|
1316
|
+
height: height + 2
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1297
1319
|
}
|
|
1298
1320
|
renderHelperBox() {
|
|
1299
1321
|
}
|
|
@@ -1373,11 +1395,10 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1373
1395
|
return f;
|
|
1374
1396
|
}
|
|
1375
1397
|
initIcon() {
|
|
1376
|
-
var _a, _b;
|
|
1377
1398
|
const img = document.createElement("img");
|
|
1378
1399
|
img.setAttribute("src", this.options.icon);
|
|
1379
|
-
img.style.width = `${
|
|
1380
|
-
img.style.height = `${
|
|
1400
|
+
img.style.width = `${this.options.icon_size?.[0] || 32}px`;
|
|
1401
|
+
img.style.height = `${this.options.icon_size?.[1] || 32}px`;
|
|
1381
1402
|
img.style.opacity = `${this.options.icon_opacity}px`;
|
|
1382
1403
|
img.style.borderRadius = "50%";
|
|
1383
1404
|
if (this.options.icon_border.width) {
|
|
@@ -1389,6 +1410,9 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1389
1410
|
this.img = img;
|
|
1390
1411
|
return img;
|
|
1391
1412
|
}
|
|
1413
|
+
_changePosition = () => {
|
|
1414
|
+
this.overlay.updatePosition(true);
|
|
1415
|
+
};
|
|
1392
1416
|
registryEvent() {
|
|
1393
1417
|
}
|
|
1394
1418
|
unRegistryEvent() {
|
|
@@ -1452,6 +1476,7 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1452
1476
|
this.textDiv = null;
|
|
1453
1477
|
this.img = void 0;
|
|
1454
1478
|
this.overlay.dispose();
|
|
1479
|
+
this.disposed = true;
|
|
1455
1480
|
}
|
|
1456
1481
|
};
|
|
1457
1482
|
|
|
@@ -1476,9 +1501,9 @@ var Layer = class extends Object3D5 {
|
|
|
1476
1501
|
|
|
1477
1502
|
// src/layer/graphic-layer.ts
|
|
1478
1503
|
var GraphicLayer = class extends Layer {
|
|
1504
|
+
graphicMap = /* @__PURE__ */ new Map();
|
|
1479
1505
|
constructor(context) {
|
|
1480
1506
|
super(context);
|
|
1481
|
-
__publicField(this, "graphicMap", /* @__PURE__ */ new Map());
|
|
1482
1507
|
}
|
|
1483
1508
|
getCenter() {
|
|
1484
1509
|
const box = new Box33().setFromObject(this);
|
|
@@ -1537,16 +1562,11 @@ var GraphicLayer = class extends Layer {
|
|
|
1537
1562
|
// src/layer/poi-layer.ts
|
|
1538
1563
|
import { debounce as debounce2 } from "lodash";
|
|
1539
1564
|
var PoiLayer = class extends Layer {
|
|
1565
|
+
pois = [];
|
|
1566
|
+
debounceCollisionDetection;
|
|
1567
|
+
timer = new Timer();
|
|
1540
1568
|
constructor(context) {
|
|
1541
1569
|
super(context);
|
|
1542
|
-
__publicField(this, "pois", []);
|
|
1543
|
-
__publicField(this, "debounceCollisionDetection");
|
|
1544
|
-
__publicField(this, "timer", new Timer());
|
|
1545
|
-
__publicField(this, "onUpdate", () => {
|
|
1546
|
-
this.timer.requestAnimationFrame(() => {
|
|
1547
|
-
this.collisionDetection();
|
|
1548
|
-
});
|
|
1549
|
-
});
|
|
1550
1570
|
this.registryEvent();
|
|
1551
1571
|
this.debounceCollisionDetection = debounce2(this.collisionDetection, 10);
|
|
1552
1572
|
}
|
|
@@ -1627,6 +1647,11 @@ var PoiLayer = class extends Layer {
|
|
|
1627
1647
|
});
|
|
1628
1648
|
return pois;
|
|
1629
1649
|
}
|
|
1650
|
+
onUpdate = () => {
|
|
1651
|
+
this.timer.requestAnimationFrame(() => {
|
|
1652
|
+
this.collisionDetection();
|
|
1653
|
+
});
|
|
1654
|
+
};
|
|
1630
1655
|
/**
|
|
1631
1656
|
* 碰撞检测
|
|
1632
1657
|
*/
|
|
@@ -1683,11 +1708,11 @@ var HeatmapElement = class extends Object3D6 {
|
|
|
1683
1708
|
constructor(context) {
|
|
1684
1709
|
super();
|
|
1685
1710
|
this.context = context;
|
|
1686
|
-
__publicField(this, "heatmap");
|
|
1687
|
-
__publicField(this, "div");
|
|
1688
|
-
__publicField(this, "plane");
|
|
1689
1711
|
this.div = document.createElement("div");
|
|
1690
1712
|
}
|
|
1713
|
+
heatmap;
|
|
1714
|
+
div;
|
|
1715
|
+
plane;
|
|
1691
1716
|
clearHeatmap() {
|
|
1692
1717
|
if (this.div.firstChild) {
|
|
1693
1718
|
this.div.removeChild(this.div.firstChild);
|
|
@@ -1697,11 +1722,12 @@ var HeatmapElement = class extends Object3D6 {
|
|
|
1697
1722
|
loadData(data) {
|
|
1698
1723
|
this.clearHeatmap();
|
|
1699
1724
|
const { width, height, leftTop, center: center2 } = this.getBox(data);
|
|
1700
|
-
this.heatmap = create(
|
|
1725
|
+
this.heatmap = create({
|
|
1701
1726
|
width,
|
|
1702
1727
|
height,
|
|
1703
|
-
container: this.div
|
|
1704
|
-
|
|
1728
|
+
container: this.div,
|
|
1729
|
+
...this.context.config.heatMap
|
|
1730
|
+
});
|
|
1705
1731
|
this.heatmap.setData(this.transformData(data, leftTop));
|
|
1706
1732
|
this.initPlane(width, height);
|
|
1707
1733
|
this.position.set(center2[0], center2[1], this.position.z);
|
|
@@ -1769,26 +1795,23 @@ var Model = class extends Object3D7 {
|
|
|
1769
1795
|
super();
|
|
1770
1796
|
this.context = context;
|
|
1771
1797
|
this.options = options;
|
|
1772
|
-
__publicField(this, "poi", null);
|
|
1773
|
-
__publicField(this, "model", null);
|
|
1774
1798
|
this.position.copy(options.position || new Vector37(0, 0, 0));
|
|
1775
1799
|
this.loadModel();
|
|
1776
1800
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1801
|
+
poi = null;
|
|
1802
|
+
model = null;
|
|
1803
|
+
async loadModel() {
|
|
1804
|
+
const object = await loadModel(this.options.modelUrl);
|
|
1805
|
+
object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
|
|
1806
|
+
this.add(object.scene);
|
|
1807
|
+
this.model = object;
|
|
1808
|
+
this.initPoi();
|
|
1785
1809
|
}
|
|
1786
1810
|
initPoi() {
|
|
1787
|
-
var _a;
|
|
1788
1811
|
if (!this.options.icon) {
|
|
1789
1812
|
return;
|
|
1790
1813
|
}
|
|
1791
|
-
const poi =
|
|
1814
|
+
const poi = this.context.currentFloor?.addPoi({
|
|
1792
1815
|
icon: this.options.icon,
|
|
1793
1816
|
icon_size: this.options.icon_size,
|
|
1794
1817
|
built_in: true,
|
|
@@ -1800,11 +1823,10 @@ var Model = class extends Object3D7 {
|
|
|
1800
1823
|
}
|
|
1801
1824
|
}
|
|
1802
1825
|
dispose() {
|
|
1803
|
-
var _a;
|
|
1804
1826
|
dispose(this);
|
|
1805
1827
|
this.model = null;
|
|
1806
1828
|
if (this.poi) {
|
|
1807
|
-
|
|
1829
|
+
this.context.currentFloor?.poiLayer.removePoi(this.poi);
|
|
1808
1830
|
this.poi = null;
|
|
1809
1831
|
}
|
|
1810
1832
|
}
|
|
@@ -1815,15 +1837,6 @@ var Floor = class extends Object3D8 {
|
|
|
1815
1837
|
constructor(context) {
|
|
1816
1838
|
super();
|
|
1817
1839
|
this.context = context;
|
|
1818
|
-
__publicField(this, "graphicLayer");
|
|
1819
|
-
__publicField(this, "poiLayer");
|
|
1820
|
-
__publicField(this, "grounds", /* @__PURE__ */ new Set());
|
|
1821
|
-
__publicField(this, "shadow", new Shadow());
|
|
1822
|
-
__publicField(this, "heatmap");
|
|
1823
|
-
__publicField(this, "groundUpper", new Object3D8());
|
|
1824
|
-
__publicField(this, "models", new Object3D8());
|
|
1825
|
-
__publicField(this, "modelMap", /* @__PURE__ */ new Map());
|
|
1826
|
-
__publicField(this, "groundMaxHeight", 0);
|
|
1827
1840
|
this.graphicLayer = new GraphicLayer(this.context);
|
|
1828
1841
|
this.poiLayer = new PoiLayer(this.context);
|
|
1829
1842
|
this.groundUpper.add(this.graphicLayer);
|
|
@@ -1831,6 +1844,16 @@ var Floor = class extends Object3D8 {
|
|
|
1831
1844
|
this.add(this.groundUpper);
|
|
1832
1845
|
this.add(this.models);
|
|
1833
1846
|
}
|
|
1847
|
+
graphicLayer;
|
|
1848
|
+
poiLayer;
|
|
1849
|
+
grounds = /* @__PURE__ */ new Set();
|
|
1850
|
+
shadow = new Shadow();
|
|
1851
|
+
heatmap;
|
|
1852
|
+
groundUpper = new Object3D8();
|
|
1853
|
+
models = new Object3D8();
|
|
1854
|
+
modelMap = /* @__PURE__ */ new Map();
|
|
1855
|
+
groundMaxHeight = 0;
|
|
1856
|
+
name = "";
|
|
1834
1857
|
getPosition() {
|
|
1835
1858
|
const box = new Box35().setFromObject(this.groundUpper);
|
|
1836
1859
|
return box.getCenter(new Vector38());
|
|
@@ -1904,12 +1927,11 @@ var Floor = class extends Object3D8 {
|
|
|
1904
1927
|
this.shadow.visible = visible;
|
|
1905
1928
|
}
|
|
1906
1929
|
dispose() {
|
|
1907
|
-
var _a;
|
|
1908
1930
|
this.shadow.dispose();
|
|
1909
1931
|
this.graphicLayer.dispose();
|
|
1910
1932
|
this.poiLayer.dispose();
|
|
1911
1933
|
this.grounds.forEach((ground) => ground.dispose());
|
|
1912
|
-
|
|
1934
|
+
this.heatmap?.dispose();
|
|
1913
1935
|
this.groundUpper.clear();
|
|
1914
1936
|
this.models.children.forEach((model) => model.dispose());
|
|
1915
1937
|
this.models.clear();
|
|
@@ -1924,19 +1946,19 @@ var BaseSvg = class extends EventDispatcher3 {
|
|
|
1924
1946
|
constructor(context) {
|
|
1925
1947
|
super();
|
|
1926
1948
|
this.context = context;
|
|
1927
|
-
__publicField(this, "points", []);
|
|
1928
|
-
__publicField(this, "svg");
|
|
1929
|
-
__publicField(this, "enable", true);
|
|
1930
|
-
__publicField(this, "_onResize", ({ width, height }) => {
|
|
1931
|
-
if (this.svg) {
|
|
1932
|
-
this.svg.setAttribute("width", `${width}`);
|
|
1933
|
-
this.svg.setAttribute("height", `${height}`);
|
|
1934
|
-
}
|
|
1935
|
-
});
|
|
1936
1949
|
this.svg = createSvg(`${context.container.clientWidth}`, `${context.container.clientHeight}`);
|
|
1937
1950
|
context.container.appendChild(this.svg);
|
|
1938
1951
|
this._registryEvent();
|
|
1939
1952
|
}
|
|
1953
|
+
points = [];
|
|
1954
|
+
svg;
|
|
1955
|
+
enable = true;
|
|
1956
|
+
_onResize = ({ width, height }) => {
|
|
1957
|
+
if (this.svg) {
|
|
1958
|
+
this.svg.setAttribute("width", `${width}`);
|
|
1959
|
+
this.svg.setAttribute("height", `${height}`);
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1940
1962
|
_registryEvent() {
|
|
1941
1963
|
this.context.addEventListener("resize", this._onResize);
|
|
1942
1964
|
}
|
|
@@ -1977,48 +1999,6 @@ var SvgLine = class extends BaseSvg {
|
|
|
1977
1999
|
constructor(context) {
|
|
1978
2000
|
super(context);
|
|
1979
2001
|
this.context = context;
|
|
1980
|
-
__publicField(this, "circles");
|
|
1981
|
-
__publicField(this, "line");
|
|
1982
|
-
__publicField(this, "onUpdate", () => {
|
|
1983
|
-
if (this.points[0]) {
|
|
1984
|
-
const point1 = this.getSvgCoordinate(this.points[0]);
|
|
1985
|
-
setCirclePosition(this.circles[0], point1.x, point1.y);
|
|
1986
|
-
setLineStartEnd(this.line, point1);
|
|
1987
|
-
}
|
|
1988
|
-
if (this.points[1]) {
|
|
1989
|
-
const point22 = this.getSvgCoordinate(this.points[1]);
|
|
1990
|
-
setCirclePosition(this.circles[1], point22.x, point22.y);
|
|
1991
|
-
setLineStartEnd(this.line, void 0, point22);
|
|
1992
|
-
}
|
|
1993
|
-
});
|
|
1994
|
-
__publicField(this, "onPointermove", (e) => {
|
|
1995
|
-
if (this.points.length !== 1) {
|
|
1996
|
-
return;
|
|
1997
|
-
}
|
|
1998
|
-
this.line.style.display = "block";
|
|
1999
|
-
setLineStartEnd(this.line, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2000
|
-
});
|
|
2001
|
-
__publicField(this, "onPointerleave", () => {
|
|
2002
|
-
if (this.points[1]) {
|
|
2003
|
-
return;
|
|
2004
|
-
}
|
|
2005
|
-
this.line.style.display = "none";
|
|
2006
|
-
});
|
|
2007
|
-
__publicField(this, "onPointerdown", (e) => {
|
|
2008
|
-
if (this.points[1]) {
|
|
2009
|
-
return;
|
|
2010
|
-
}
|
|
2011
|
-
const point3 = this.getIntersectByPointerEvent(e);
|
|
2012
|
-
if (point3) {
|
|
2013
|
-
const { offsetX: x, offsetY: y } = e;
|
|
2014
|
-
const circle = this.circles[this.points.length];
|
|
2015
|
-
setCirclePosition(circle, x, y);
|
|
2016
|
-
if (!this.points.length) {
|
|
2017
|
-
setLineStartEnd(this.line, { x, y }, { x, y });
|
|
2018
|
-
}
|
|
2019
|
-
this.addPoint(point3);
|
|
2020
|
-
}
|
|
2021
|
-
});
|
|
2022
2002
|
const { config: { svg: { circle, line } } } = context;
|
|
2023
2003
|
this.circles = [createCircle(circle.radius, circle.fill), createCircle(circle.radius, circle.fill)];
|
|
2024
2004
|
this.line = createLine(line.stroke);
|
|
@@ -2027,6 +2007,8 @@ var SvgLine = class extends BaseSvg {
|
|
|
2027
2007
|
this.svg.appendChild(this.line);
|
|
2028
2008
|
this.registryEvent();
|
|
2029
2009
|
}
|
|
2010
|
+
circles;
|
|
2011
|
+
line;
|
|
2030
2012
|
setEnable(enable) {
|
|
2031
2013
|
super.setEnable(enable);
|
|
2032
2014
|
if (enable) {
|
|
@@ -2049,6 +2031,46 @@ var SvgLine = class extends BaseSvg {
|
|
|
2049
2031
|
this.context.container.removeEventListener("pointerdown", this.onPointerdown);
|
|
2050
2032
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2051
2033
|
}
|
|
2034
|
+
onUpdate = () => {
|
|
2035
|
+
if (this.points[0]) {
|
|
2036
|
+
const point1 = this.getSvgCoordinate(this.points[0]);
|
|
2037
|
+
setCirclePosition(this.circles[0], point1.x, point1.y);
|
|
2038
|
+
setLineStartEnd(this.line, point1);
|
|
2039
|
+
}
|
|
2040
|
+
if (this.points[1]) {
|
|
2041
|
+
const point22 = this.getSvgCoordinate(this.points[1]);
|
|
2042
|
+
setCirclePosition(this.circles[1], point22.x, point22.y);
|
|
2043
|
+
setLineStartEnd(this.line, void 0, point22);
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
onPointermove = (e) => {
|
|
2047
|
+
if (this.points.length !== 1) {
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
this.line.style.display = "block";
|
|
2051
|
+
setLineStartEnd(this.line, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2052
|
+
};
|
|
2053
|
+
onPointerleave = () => {
|
|
2054
|
+
if (this.points[1]) {
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
this.line.style.display = "none";
|
|
2058
|
+
};
|
|
2059
|
+
onPointerdown = (e) => {
|
|
2060
|
+
if (this.points[1]) {
|
|
2061
|
+
return;
|
|
2062
|
+
}
|
|
2063
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2064
|
+
if (point3) {
|
|
2065
|
+
const { offsetX: x, offsetY: y } = e;
|
|
2066
|
+
const circle = this.circles[this.points.length];
|
|
2067
|
+
setCirclePosition(circle, x, y);
|
|
2068
|
+
if (!this.points.length) {
|
|
2069
|
+
setLineStartEnd(this.line, { x, y }, { x, y });
|
|
2070
|
+
}
|
|
2071
|
+
this.addPoint(point3);
|
|
2072
|
+
}
|
|
2073
|
+
};
|
|
2052
2074
|
addPoint(vector) {
|
|
2053
2075
|
this.points.push(vector);
|
|
2054
2076
|
if (this.points.length >= 2) {
|
|
@@ -2061,7 +2083,7 @@ var SvgLine = class extends BaseSvg {
|
|
|
2061
2083
|
*/
|
|
2062
2084
|
calculatedDistance() {
|
|
2063
2085
|
const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = this.points;
|
|
2064
|
-
return Math.sqrt(
|
|
2086
|
+
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
|
2065
2087
|
}
|
|
2066
2088
|
dispose() {
|
|
2067
2089
|
super.dispose();
|
|
@@ -2073,69 +2095,11 @@ var SvgLine = class extends BaseSvg {
|
|
|
2073
2095
|
|
|
2074
2096
|
// src/elements/svg-polygon.ts
|
|
2075
2097
|
var SvgPolygon = class extends BaseSvg {
|
|
2098
|
+
circles = [];
|
|
2099
|
+
lines = [];
|
|
2100
|
+
isClose = false;
|
|
2076
2101
|
constructor(context) {
|
|
2077
2102
|
super(context);
|
|
2078
|
-
__publicField(this, "circles", []);
|
|
2079
|
-
__publicField(this, "lines", []);
|
|
2080
|
-
__publicField(this, "isClose", false);
|
|
2081
|
-
__publicField(this, "onUpdate", () => {
|
|
2082
|
-
if (this.points.length) {
|
|
2083
|
-
this.points.forEach((point3, index) => {
|
|
2084
|
-
const devicePoint = this.getSvgCoordinate(point3);
|
|
2085
|
-
if (this.circles[index]) {
|
|
2086
|
-
setCirclePosition(this.circles[index], devicePoint.x, devicePoint.y);
|
|
2087
|
-
}
|
|
2088
|
-
if (index !== 0) {
|
|
2089
|
-
setLineStartEnd(this.lines[index - 1], void 0, devicePoint);
|
|
2090
|
-
}
|
|
2091
|
-
if (this.lines[index]) {
|
|
2092
|
-
setLineStartEnd(this.lines[index], devicePoint);
|
|
2093
|
-
}
|
|
2094
|
-
});
|
|
2095
|
-
}
|
|
2096
|
-
});
|
|
2097
|
-
__publicField(this, "onPointermove", (e) => {
|
|
2098
|
-
if (!this.lastLine || this.isClose) {
|
|
2099
|
-
return;
|
|
2100
|
-
}
|
|
2101
|
-
this.lastLine.style.display = "block";
|
|
2102
|
-
setLineStartEnd(this.lastLine, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2103
|
-
});
|
|
2104
|
-
__publicField(this, "onPointerleave", () => {
|
|
2105
|
-
if (this.isClose) {
|
|
2106
|
-
return;
|
|
2107
|
-
}
|
|
2108
|
-
this.lastLine.style.display = "none";
|
|
2109
|
-
});
|
|
2110
|
-
__publicField(this, "onPointerdown", (e) => {
|
|
2111
|
-
if (this.isClose) {
|
|
2112
|
-
return;
|
|
2113
|
-
}
|
|
2114
|
-
const point3 = this.getIntersectByPointerEvent(e);
|
|
2115
|
-
if (point3) {
|
|
2116
|
-
const { offsetX: x, offsetY: y } = e;
|
|
2117
|
-
if (this.checkAdsorb(x, y)) {
|
|
2118
|
-
this.isClose = true;
|
|
2119
|
-
this.addPoint(this.points[0]);
|
|
2120
|
-
} else {
|
|
2121
|
-
this.addPoint(point3);
|
|
2122
|
-
}
|
|
2123
|
-
const { circle: { fill, radius }, line: { stroke } } = this.context.config.svg;
|
|
2124
|
-
if (!this.isClose) {
|
|
2125
|
-
const circle = createCircle(radius, fill);
|
|
2126
|
-
setCirclePosition(circle, x, y);
|
|
2127
|
-
this.addCircle(circle);
|
|
2128
|
-
}
|
|
2129
|
-
if (this.lines.length) {
|
|
2130
|
-
setLineStartEnd(this.lastLine, void 0, { x, y });
|
|
2131
|
-
}
|
|
2132
|
-
if (!this.isClose) {
|
|
2133
|
-
const line = createLine(stroke);
|
|
2134
|
-
setLineStartEnd(line, { x, y }, { x, y });
|
|
2135
|
-
this.addLine(line);
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
});
|
|
2139
2103
|
this.registryEvent();
|
|
2140
2104
|
}
|
|
2141
2105
|
setEnable(enable) {
|
|
@@ -2171,6 +2135,64 @@ var SvgPolygon = class extends BaseSvg {
|
|
|
2171
2135
|
this.context.container.removeEventListener("pointerdown", this.onPointerdown);
|
|
2172
2136
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2173
2137
|
}
|
|
2138
|
+
onUpdate = () => {
|
|
2139
|
+
if (this.points.length) {
|
|
2140
|
+
this.points.forEach((point3, index) => {
|
|
2141
|
+
const devicePoint = this.getSvgCoordinate(point3);
|
|
2142
|
+
if (this.circles[index]) {
|
|
2143
|
+
setCirclePosition(this.circles[index], devicePoint.x, devicePoint.y);
|
|
2144
|
+
}
|
|
2145
|
+
if (index !== 0) {
|
|
2146
|
+
setLineStartEnd(this.lines[index - 1], void 0, devicePoint);
|
|
2147
|
+
}
|
|
2148
|
+
if (this.lines[index]) {
|
|
2149
|
+
setLineStartEnd(this.lines[index], devicePoint);
|
|
2150
|
+
}
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
onPointermove = (e) => {
|
|
2155
|
+
if (!this.lastLine || this.isClose) {
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
this.lastLine.style.display = "block";
|
|
2159
|
+
setLineStartEnd(this.lastLine, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2160
|
+
};
|
|
2161
|
+
onPointerleave = () => {
|
|
2162
|
+
if (this.isClose) {
|
|
2163
|
+
return;
|
|
2164
|
+
}
|
|
2165
|
+
this.lastLine.style.display = "none";
|
|
2166
|
+
};
|
|
2167
|
+
onPointerdown = (e) => {
|
|
2168
|
+
if (this.isClose) {
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2172
|
+
if (point3) {
|
|
2173
|
+
const { offsetX: x, offsetY: y } = e;
|
|
2174
|
+
if (this.checkAdsorb(x, y)) {
|
|
2175
|
+
this.isClose = true;
|
|
2176
|
+
this.addPoint(this.points[0]);
|
|
2177
|
+
} else {
|
|
2178
|
+
this.addPoint(point3);
|
|
2179
|
+
}
|
|
2180
|
+
const { circle: { fill, radius }, line: { stroke } } = this.context.config.svg;
|
|
2181
|
+
if (!this.isClose) {
|
|
2182
|
+
const circle = createCircle(radius, fill);
|
|
2183
|
+
setCirclePosition(circle, x, y);
|
|
2184
|
+
this.addCircle(circle);
|
|
2185
|
+
}
|
|
2186
|
+
if (this.lines.length) {
|
|
2187
|
+
setLineStartEnd(this.lastLine, void 0, { x, y });
|
|
2188
|
+
}
|
|
2189
|
+
if (!this.isClose) {
|
|
2190
|
+
const line = createLine(stroke);
|
|
2191
|
+
setLineStartEnd(line, { x, y }, { x, y });
|
|
2192
|
+
this.addLine(line);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2174
2196
|
/**
|
|
2175
2197
|
* 检测是否可以吸附
|
|
2176
2198
|
* 坐标点最少3个 传入的坐标点和第一个坐标的像素相差不超过5个像素
|
|
@@ -2182,7 +2204,7 @@ var SvgPolygon = class extends BaseSvg {
|
|
|
2182
2204
|
const circle = this.circles[0];
|
|
2183
2205
|
const cx = +circle.getAttribute("cx");
|
|
2184
2206
|
const cy = +circle.getAttribute("cy");
|
|
2185
|
-
return Math.sqrt(
|
|
2207
|
+
return Math.sqrt((x - cx) ** 2 + (y - cy) ** 2) <= 5;
|
|
2186
2208
|
}
|
|
2187
2209
|
addPoint(vector) {
|
|
2188
2210
|
this.points.push(vector);
|
|
@@ -2216,60 +2238,6 @@ var SelectBox = class extends BaseSvg {
|
|
|
2216
2238
|
constructor(context) {
|
|
2217
2239
|
super(context);
|
|
2218
2240
|
this.context = context;
|
|
2219
|
-
__publicField(this, "rect");
|
|
2220
|
-
__publicField(this, "cornerRect", []);
|
|
2221
|
-
// 四个角上的方块
|
|
2222
|
-
__publicField(this, "centerRect", []);
|
|
2223
|
-
// 四个线中间的方块
|
|
2224
|
-
__publicField(this, "graphic");
|
|
2225
|
-
__publicField(this, "onUpdate", () => {
|
|
2226
|
-
if (!this.graphic) {
|
|
2227
|
-
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2228
|
-
for (let i = 0; i < this.cornerRect.length; i++) {
|
|
2229
|
-
setRectPosition(this.cornerRect[i], 0, 0, 0, 0);
|
|
2230
|
-
setRectPosition(this.centerRect[i], 0, 0, 0, 0);
|
|
2231
|
-
}
|
|
2232
|
-
} else {
|
|
2233
|
-
const box = new Box36().setFromObject(this.graphic);
|
|
2234
|
-
const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
|
|
2235
|
-
const { min, max } = box;
|
|
2236
|
-
const leftBottom = vector3ToDevice(min, camera, w, h);
|
|
2237
|
-
const rightTop = vector3ToDevice(max, camera, w, h);
|
|
2238
|
-
setRectPosition(this.rect, leftBottom.x, rightTop.y, Math.abs(rightTop.x - leftBottom.x), Math.abs(rightTop.y - leftBottom.y));
|
|
2239
|
-
const { x: left, y: bottom } = leftBottom;
|
|
2240
|
-
const { x: right, y: top } = rightTop;
|
|
2241
|
-
const halfWidth = 5;
|
|
2242
|
-
const corners = [
|
|
2243
|
-
{ x: left - halfWidth, y: top - halfWidth },
|
|
2244
|
-
// 左上角
|
|
2245
|
-
{ x: right - halfWidth, y: top - halfWidth },
|
|
2246
|
-
// 右上角
|
|
2247
|
-
{ x: left - halfWidth, y: bottom - halfWidth },
|
|
2248
|
-
// 左下角
|
|
2249
|
-
{ x: right - halfWidth, y: bottom - halfWidth }
|
|
2250
|
-
// 右下角
|
|
2251
|
-
];
|
|
2252
|
-
for (let i = 0; i < corners.length; i++) {
|
|
2253
|
-
setRectPosition(this.cornerRect[i], corners[i].x, corners[i].y, halfWidth * 2, halfWidth * 2);
|
|
2254
|
-
}
|
|
2255
|
-
const centerHalfWidth = 4;
|
|
2256
|
-
const centerX = (left + right) / 2;
|
|
2257
|
-
const centerY = (bottom + top) / 2;
|
|
2258
|
-
const centers = [
|
|
2259
|
-
{ x: centerX - centerHalfWidth, y: top - centerHalfWidth },
|
|
2260
|
-
// 上
|
|
2261
|
-
{ x: left - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2262
|
-
// 左
|
|
2263
|
-
{ x: right - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2264
|
-
// 右
|
|
2265
|
-
{ x: centerX - centerHalfWidth, y: bottom - centerHalfWidth }
|
|
2266
|
-
// 下
|
|
2267
|
-
];
|
|
2268
|
-
for (let i = 0; i < centers.length; i++) {
|
|
2269
|
-
setRectPosition(this.centerRect[i], centers[i].x, centers[i].y, centerHalfWidth * 2, centerHalfWidth * 2);
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
});
|
|
2273
2241
|
const { config: { svg: { line } } } = context;
|
|
2274
2242
|
this.rect = createRect(line.stroke, "transparent");
|
|
2275
2243
|
this.svg.appendChild(this.rect);
|
|
@@ -2281,6 +2249,12 @@ var SelectBox = class extends BaseSvg {
|
|
|
2281
2249
|
}
|
|
2282
2250
|
this.registryEvent();
|
|
2283
2251
|
}
|
|
2252
|
+
rect;
|
|
2253
|
+
cornerRect = [];
|
|
2254
|
+
// 四个角上的方块
|
|
2255
|
+
centerRect = [];
|
|
2256
|
+
// 四个线中间的方块
|
|
2257
|
+
graphic;
|
|
2284
2258
|
setEnable(enable) {
|
|
2285
2259
|
super.setEnable(enable);
|
|
2286
2260
|
if (enable) {
|
|
@@ -2295,6 +2269,54 @@ var SelectBox = class extends BaseSvg {
|
|
|
2295
2269
|
unRegistryEvent() {
|
|
2296
2270
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2297
2271
|
}
|
|
2272
|
+
onUpdate = () => {
|
|
2273
|
+
if (!this.graphic) {
|
|
2274
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2275
|
+
for (let i = 0; i < this.cornerRect.length; i++) {
|
|
2276
|
+
setRectPosition(this.cornerRect[i], 0, 0, 0, 0);
|
|
2277
|
+
setRectPosition(this.centerRect[i], 0, 0, 0, 0);
|
|
2278
|
+
}
|
|
2279
|
+
} else {
|
|
2280
|
+
const box = new Box36().setFromObject(this.graphic);
|
|
2281
|
+
const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
|
|
2282
|
+
const { min, max } = box;
|
|
2283
|
+
const leftBottom = vector3ToDevice(min, camera, w, h);
|
|
2284
|
+
const rightTop = vector3ToDevice(max, camera, w, h);
|
|
2285
|
+
setRectPosition(this.rect, leftBottom.x, rightTop.y, Math.abs(rightTop.x - leftBottom.x), Math.abs(rightTop.y - leftBottom.y));
|
|
2286
|
+
const { x: left, y: bottom } = leftBottom;
|
|
2287
|
+
const { x: right, y: top } = rightTop;
|
|
2288
|
+
const halfWidth = 5;
|
|
2289
|
+
const corners = [
|
|
2290
|
+
{ x: left - halfWidth, y: top - halfWidth },
|
|
2291
|
+
// 左上角
|
|
2292
|
+
{ x: right - halfWidth, y: top - halfWidth },
|
|
2293
|
+
// 右上角
|
|
2294
|
+
{ x: left - halfWidth, y: bottom - halfWidth },
|
|
2295
|
+
// 左下角
|
|
2296
|
+
{ x: right - halfWidth, y: bottom - halfWidth }
|
|
2297
|
+
// 右下角
|
|
2298
|
+
];
|
|
2299
|
+
for (let i = 0; i < corners.length; i++) {
|
|
2300
|
+
setRectPosition(this.cornerRect[i], corners[i].x, corners[i].y, halfWidth * 2, halfWidth * 2);
|
|
2301
|
+
}
|
|
2302
|
+
const centerHalfWidth = 4;
|
|
2303
|
+
const centerX = (left + right) / 2;
|
|
2304
|
+
const centerY = (bottom + top) / 2;
|
|
2305
|
+
const centers = [
|
|
2306
|
+
{ x: centerX - centerHalfWidth, y: top - centerHalfWidth },
|
|
2307
|
+
// 上
|
|
2308
|
+
{ x: left - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2309
|
+
// 左
|
|
2310
|
+
{ x: right - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2311
|
+
// 右
|
|
2312
|
+
{ x: centerX - centerHalfWidth, y: bottom - centerHalfWidth }
|
|
2313
|
+
// 下
|
|
2314
|
+
];
|
|
2315
|
+
for (let i = 0; i < centers.length; i++) {
|
|
2316
|
+
setRectPosition(this.centerRect[i], centers[i].x, centers[i].y, centerHalfWidth * 2, centerHalfWidth * 2);
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2298
2320
|
selectGraphic(graphic) {
|
|
2299
2321
|
this.graphic = graphic;
|
|
2300
2322
|
}
|
|
@@ -2310,57 +2332,12 @@ var SelectBox = class extends BaseSvg {
|
|
|
2310
2332
|
// src/operations/selection/box-selection.ts
|
|
2311
2333
|
import { Frustum } from "three";
|
|
2312
2334
|
var BoxSelection = class extends BaseSvg {
|
|
2335
|
+
startPoint;
|
|
2336
|
+
endPoint;
|
|
2337
|
+
rect;
|
|
2338
|
+
frustum = new Frustum();
|
|
2313
2339
|
constructor(context) {
|
|
2314
2340
|
super(context);
|
|
2315
|
-
__publicField(this, "startPoint");
|
|
2316
|
-
__publicField(this, "endPoint");
|
|
2317
|
-
__publicField(this, "rect");
|
|
2318
|
-
__publicField(this, "frustum", new Frustum());
|
|
2319
|
-
__publicField(this, "onPointerDown", (e) => {
|
|
2320
|
-
if (!this.enable) {
|
|
2321
|
-
return;
|
|
2322
|
-
}
|
|
2323
|
-
const point3 = this.getIntersectByPointerEvent(e);
|
|
2324
|
-
if (point3) {
|
|
2325
|
-
this.startPoint = point3;
|
|
2326
|
-
}
|
|
2327
|
-
this.endPoint = void 0;
|
|
2328
|
-
});
|
|
2329
|
-
__publicField(this, "onPointerMove", (e) => {
|
|
2330
|
-
if (!this.enable || !this.startPoint) {
|
|
2331
|
-
return;
|
|
2332
|
-
}
|
|
2333
|
-
const point3 = this.getIntersectByPointerEvent(e);
|
|
2334
|
-
if (point3) {
|
|
2335
|
-
this.endPoint = point3;
|
|
2336
|
-
}
|
|
2337
|
-
});
|
|
2338
|
-
__publicField(this, "onPointerUp", (e) => {
|
|
2339
|
-
if (!this.enable) {
|
|
2340
|
-
return;
|
|
2341
|
-
}
|
|
2342
|
-
const point3 = this.getIntersectByPointerEvent(e);
|
|
2343
|
-
if (point3) {
|
|
2344
|
-
this.endPoint = point3;
|
|
2345
|
-
}
|
|
2346
|
-
this.doSelect();
|
|
2347
|
-
this.startPoint = void 0;
|
|
2348
|
-
});
|
|
2349
|
-
__publicField(this, "onUpdate", () => {
|
|
2350
|
-
if (this.startPoint) {
|
|
2351
|
-
const startPoint = this.getSvgCoordinate(this.startPoint);
|
|
2352
|
-
let endPoint = __spreadValues({}, startPoint);
|
|
2353
|
-
if (this.endPoint) {
|
|
2354
|
-
endPoint = this.getSvgCoordinate(this.endPoint);
|
|
2355
|
-
}
|
|
2356
|
-
const leftTop = { x: Math.min(startPoint.x, endPoint.x), y: Math.min(startPoint.y, endPoint.y) };
|
|
2357
|
-
const width = Math.abs(endPoint.x - startPoint.x);
|
|
2358
|
-
const height = Math.abs(endPoint.y - startPoint.y);
|
|
2359
|
-
setRectPosition(this.rect, leftTop.x, leftTop.y, width, height);
|
|
2360
|
-
} else {
|
|
2361
|
-
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2362
|
-
}
|
|
2363
|
-
});
|
|
2364
2341
|
const { config: { selectBox: { fill, stroke } } } = context;
|
|
2365
2342
|
this.rect = createRect(stroke, fill);
|
|
2366
2343
|
this.svg.appendChild(this.rect);
|
|
@@ -2376,6 +2353,51 @@ var BoxSelection = class extends BaseSvg {
|
|
|
2376
2353
|
this.unRegistryEvent();
|
|
2377
2354
|
}
|
|
2378
2355
|
}
|
|
2356
|
+
onPointerDown = (e) => {
|
|
2357
|
+
if (!this.enable) {
|
|
2358
|
+
return;
|
|
2359
|
+
}
|
|
2360
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2361
|
+
if (point3) {
|
|
2362
|
+
this.startPoint = point3;
|
|
2363
|
+
}
|
|
2364
|
+
this.endPoint = void 0;
|
|
2365
|
+
};
|
|
2366
|
+
onPointerMove = (e) => {
|
|
2367
|
+
if (!this.enable || !this.startPoint) {
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2371
|
+
if (point3) {
|
|
2372
|
+
this.endPoint = point3;
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
onPointerUp = (e) => {
|
|
2376
|
+
if (!this.enable) {
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2380
|
+
if (point3) {
|
|
2381
|
+
this.endPoint = point3;
|
|
2382
|
+
}
|
|
2383
|
+
this.doSelect();
|
|
2384
|
+
this.startPoint = void 0;
|
|
2385
|
+
};
|
|
2386
|
+
onUpdate = () => {
|
|
2387
|
+
if (this.startPoint) {
|
|
2388
|
+
const startPoint = this.getSvgCoordinate(this.startPoint);
|
|
2389
|
+
let endPoint = { ...startPoint };
|
|
2390
|
+
if (this.endPoint) {
|
|
2391
|
+
endPoint = this.getSvgCoordinate(this.endPoint);
|
|
2392
|
+
}
|
|
2393
|
+
const leftTop = { x: Math.min(startPoint.x, endPoint.x), y: Math.min(startPoint.y, endPoint.y) };
|
|
2394
|
+
const width = Math.abs(endPoint.x - startPoint.x);
|
|
2395
|
+
const height = Math.abs(endPoint.y - startPoint.y);
|
|
2396
|
+
setRectPosition(this.rect, leftTop.x, leftTop.y, width, height);
|
|
2397
|
+
} else {
|
|
2398
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2379
2401
|
registryEvent() {
|
|
2380
2402
|
this.context.container.addEventListener("pointerdown", this.onPointerDown);
|
|
2381
2403
|
this.context.container.addEventListener("pointermove", this.onPointerMove);
|
|
@@ -2404,11 +2426,10 @@ var BoxSelection = class extends BaseSvg {
|
|
|
2404
2426
|
}
|
|
2405
2427
|
}
|
|
2406
2428
|
searchMapInFrustum(leftTop, rightBottom) {
|
|
2407
|
-
var _a;
|
|
2408
2429
|
const { context } = this;
|
|
2409
|
-
return
|
|
2430
|
+
return context.currentFloor?.graphicLayer.children.filter((item) => {
|
|
2410
2431
|
return item instanceof Graphic && this.searchChildInFrustum(item, leftTop, rightBottom);
|
|
2411
|
-
})
|
|
2432
|
+
}) || [];
|
|
2412
2433
|
}
|
|
2413
2434
|
searchChildInFrustum(object, leftTop, rightBottom) {
|
|
2414
2435
|
const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
|
|
@@ -2450,68 +2471,16 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2450
2471
|
constructor(context) {
|
|
2451
2472
|
super();
|
|
2452
2473
|
this.context = context;
|
|
2453
|
-
__publicField(this, "_list", /* @__PURE__ */ new Set());
|
|
2454
|
-
__publicField(this, "boxSelection");
|
|
2455
|
-
__publicField(this, "prevPanStatus");
|
|
2456
|
-
__publicField(this, "prevRotateStatus");
|
|
2457
|
-
__publicField(this, "downPoint", null);
|
|
2458
|
-
__publicField(this, "isMultipleSelect", false);
|
|
2459
|
-
__publicField(this, "onPointerDown", (e) => {
|
|
2460
|
-
this.downPoint = { x: e.offsetX, y: e.offsetY };
|
|
2461
|
-
});
|
|
2462
|
-
__publicField(this, "onPointerUp", (e) => {
|
|
2463
|
-
if (!this.downPoint) {
|
|
2464
|
-
return;
|
|
2465
|
-
}
|
|
2466
|
-
const { offsetX, offsetY } = e;
|
|
2467
|
-
const { x, y } = this.downPoint;
|
|
2468
|
-
if (Math.sqrt(__pow(x - offsetX, 2) + __pow(y - offsetY, 2)) > 3) {
|
|
2469
|
-
return;
|
|
2470
|
-
}
|
|
2471
|
-
const { graphics } = this.context.getGraphicsByDeviceXy(offsetX, offsetY);
|
|
2472
|
-
const graphicIdSet = new Set(graphics.map((item) => item.options.id));
|
|
2473
|
-
const pois = this.context.getPoisByDeviceXy(offsetX, offsetY);
|
|
2474
|
-
pois.forEach((item) => {
|
|
2475
|
-
var _a;
|
|
2476
|
-
if (!graphicIdSet.has(item.options.id)) {
|
|
2477
|
-
const graphic = ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.graphicMap.get(item.options.id)) || null;
|
|
2478
|
-
if (graphic && graphic.options.geometry.type === "point") {
|
|
2479
|
-
graphics.push(graphic);
|
|
2480
|
-
graphicIdSet.add(item.options.id);
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
});
|
|
2484
|
-
if (!(isMac ? e.metaKey : e.ctrlKey)) {
|
|
2485
|
-
this._list.clear();
|
|
2486
|
-
}
|
|
2487
|
-
graphics.forEach((item) => this._list.add(item));
|
|
2488
|
-
this.selectEnd();
|
|
2489
|
-
this.downPoint = null;
|
|
2490
|
-
});
|
|
2491
|
-
__publicField(this, "onPointerOut", (e) => {
|
|
2492
|
-
this.disableBoxSelection();
|
|
2493
|
-
});
|
|
2494
|
-
__publicField(this, "onKeyDown", (e) => {
|
|
2495
|
-
if (isControl(e.key)) {
|
|
2496
|
-
this.enableBoxSelection();
|
|
2497
|
-
}
|
|
2498
|
-
});
|
|
2499
|
-
__publicField(this, "onKeyUp", (e) => {
|
|
2500
|
-
if (isControl(e.key)) {
|
|
2501
|
-
this.disableBoxSelection();
|
|
2502
|
-
}
|
|
2503
|
-
});
|
|
2504
|
-
__publicField(this, "onBoxSelected", ({ list }) => {
|
|
2505
|
-
this._list.clear();
|
|
2506
|
-
list.forEach((item) => {
|
|
2507
|
-
this._list.add(item);
|
|
2508
|
-
});
|
|
2509
|
-
this.selectEnd();
|
|
2510
|
-
});
|
|
2511
2474
|
this.boxSelection = new BoxSelection(context);
|
|
2512
2475
|
this.boxSelection.setEnable(false);
|
|
2513
2476
|
this.registryEvent();
|
|
2514
2477
|
}
|
|
2478
|
+
_list = /* @__PURE__ */ new Set();
|
|
2479
|
+
boxSelection;
|
|
2480
|
+
prevPanStatus;
|
|
2481
|
+
prevRotateStatus;
|
|
2482
|
+
downPoint = null;
|
|
2483
|
+
isMultipleSelect = false;
|
|
2515
2484
|
get list() {
|
|
2516
2485
|
return this._list;
|
|
2517
2486
|
}
|
|
@@ -2534,6 +2503,57 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2534
2503
|
this.context.control.enableRotate = !!this.prevRotateStatus;
|
|
2535
2504
|
}
|
|
2536
2505
|
}
|
|
2506
|
+
onPointerDown = (e) => {
|
|
2507
|
+
this.downPoint = { x: e.offsetX, y: e.offsetY };
|
|
2508
|
+
};
|
|
2509
|
+
onPointerUp = (e) => {
|
|
2510
|
+
if (!this.downPoint) {
|
|
2511
|
+
return;
|
|
2512
|
+
}
|
|
2513
|
+
const { offsetX, offsetY } = e;
|
|
2514
|
+
const { x, y } = this.downPoint;
|
|
2515
|
+
if (Math.sqrt((x - offsetX) ** 2 + (y - offsetY) ** 2) > 3) {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
const { graphics } = this.context.getGraphicsByDeviceXy(offsetX, offsetY);
|
|
2519
|
+
const graphicIdSet = new Set(graphics.map((item) => item.options.id));
|
|
2520
|
+
const pois = this.context.getPoisByDeviceXy(offsetX, offsetY);
|
|
2521
|
+
pois.forEach((item) => {
|
|
2522
|
+
if (!graphicIdSet.has(item.options.id)) {
|
|
2523
|
+
const graphic = this.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id) || null;
|
|
2524
|
+
if (graphic && graphic.options.geometry.type === "point") {
|
|
2525
|
+
graphics.push(graphic);
|
|
2526
|
+
graphicIdSet.add(item.options.id);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
});
|
|
2530
|
+
if (!(isMac ? e.metaKey : e.ctrlKey)) {
|
|
2531
|
+
this._list.clear();
|
|
2532
|
+
}
|
|
2533
|
+
graphics.forEach((item) => this._list.add(item));
|
|
2534
|
+
this.selectEnd();
|
|
2535
|
+
this.downPoint = null;
|
|
2536
|
+
};
|
|
2537
|
+
onPointerOut = (e) => {
|
|
2538
|
+
this.disableBoxSelection();
|
|
2539
|
+
};
|
|
2540
|
+
onKeyDown = (e) => {
|
|
2541
|
+
if (isControl(e.key)) {
|
|
2542
|
+
this.enableBoxSelection();
|
|
2543
|
+
}
|
|
2544
|
+
};
|
|
2545
|
+
onKeyUp = (e) => {
|
|
2546
|
+
if (isControl(e.key)) {
|
|
2547
|
+
this.disableBoxSelection();
|
|
2548
|
+
}
|
|
2549
|
+
};
|
|
2550
|
+
onBoxSelected = ({ list }) => {
|
|
2551
|
+
this._list.clear();
|
|
2552
|
+
list.forEach((item) => {
|
|
2553
|
+
this._list.add(item);
|
|
2554
|
+
});
|
|
2555
|
+
this.selectEnd();
|
|
2556
|
+
};
|
|
2537
2557
|
selectEnd() {
|
|
2538
2558
|
this.dispatchEvent({ type: "select", graphics: [...this._list], isMultipleSelect: this.isMultipleSelect });
|
|
2539
2559
|
}
|
|
@@ -2572,75 +2592,72 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2572
2592
|
constructor(context) {
|
|
2573
2593
|
super();
|
|
2574
2594
|
this.context = context;
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2595
|
+
this.registryEvent();
|
|
2596
|
+
}
|
|
2597
|
+
curGraphics = /* @__PURE__ */ new Set();
|
|
2598
|
+
timer = new Timer();
|
|
2599
|
+
graphicTimerMap = /* @__PURE__ */ new Map();
|
|
2600
|
+
onPointerMove = ({ graphics, pois, e }) => {
|
|
2601
|
+
const poiGraphics = pois.map((item) => this.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id)).filter((graphic) => graphic && graphic.options.geometry.type === "point");
|
|
2602
|
+
if (!graphics.length && !poiGraphics.length && this.curGraphics.size) {
|
|
2603
|
+
this.curGraphics.clear();
|
|
2604
|
+
this.handleHoverGraphicsChange();
|
|
2605
|
+
return;
|
|
2606
|
+
}
|
|
2607
|
+
const { time } = this.context.config.hover;
|
|
2608
|
+
const allGraphics = /* @__PURE__ */ new Set();
|
|
2609
|
+
if (poiGraphics.length) {
|
|
2610
|
+
let resGraphic;
|
|
2611
|
+
let distance = 1e4;
|
|
2612
|
+
poiGraphics.forEach((graphic) => {
|
|
2613
|
+
const poi = pois.find((poi2) => poi2.options.id === graphic.options.id);
|
|
2614
|
+
const { x, y } = poi.clientPos;
|
|
2615
|
+
let curDistance = Math.sqrt((x - e.offsetX) ** 2 + (y - e.offsetY) ** 2);
|
|
2616
|
+
if (curDistance < distance) {
|
|
2617
|
+
distance = curDistance;
|
|
2618
|
+
resGraphic = graphic;
|
|
2619
|
+
}
|
|
2620
|
+
});
|
|
2621
|
+
allGraphics.add(resGraphic);
|
|
2622
|
+
}
|
|
2623
|
+
if (!allGraphics.size) {
|
|
2624
|
+
graphics.forEach((graphic) => allGraphics.add(graphic));
|
|
2625
|
+
}
|
|
2626
|
+
allGraphics.forEach((graphic) => {
|
|
2627
|
+
if (this.graphicTimerMap.get(graphic)) {
|
|
2586
2628
|
return;
|
|
2587
2629
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
if (poiGraphics.length) {
|
|
2591
|
-
let resGraphic;
|
|
2592
|
-
let distance = 1e4;
|
|
2593
|
-
poiGraphics.forEach((graphic) => {
|
|
2594
|
-
const poi = pois.find((poi2) => poi2.options.id === graphic.options.id);
|
|
2595
|
-
const { x, y } = poi.clientPos;
|
|
2596
|
-
let curDistance = Math.sqrt(__pow(x - e.offsetX, 2) + __pow(y - e.offsetY, 2));
|
|
2597
|
-
if (curDistance < distance) {
|
|
2598
|
-
distance = curDistance;
|
|
2599
|
-
resGraphic = graphic;
|
|
2600
|
-
}
|
|
2601
|
-
});
|
|
2602
|
-
allGraphics.add(resGraphic);
|
|
2603
|
-
}
|
|
2604
|
-
if (!allGraphics.size) {
|
|
2605
|
-
graphics.forEach((graphic) => allGraphics.add(graphic));
|
|
2630
|
+
if (this.curGraphics.has(graphic)) {
|
|
2631
|
+
return;
|
|
2606
2632
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
if (this.curGraphics.has(graphic)) {
|
|
2612
|
-
return;
|
|
2613
|
-
}
|
|
2614
|
-
const timer = this.timer.setTimeout(() => {
|
|
2615
|
-
this.curGraphics.add(graphic);
|
|
2616
|
-
this.graphicTimerMap.delete(graphic);
|
|
2617
|
-
this.timer.clearTimeout(timer);
|
|
2618
|
-
this.handleHoverGraphicsChange();
|
|
2619
|
-
}, time);
|
|
2620
|
-
this.graphicTimerMap.set(graphic, timer);
|
|
2621
|
-
});
|
|
2622
|
-
this.graphicTimerMap.forEach((timer, graphic) => {
|
|
2623
|
-
if (!allGraphics.has(graphic)) {
|
|
2624
|
-
this.timer.clearTimeout(timer);
|
|
2625
|
-
this.graphicTimerMap.delete(graphic);
|
|
2626
|
-
}
|
|
2627
|
-
});
|
|
2628
|
-
const size = this.curGraphics.size;
|
|
2629
|
-
this.curGraphics.forEach((graphic) => {
|
|
2630
|
-
if (!allGraphics.has(graphic)) {
|
|
2631
|
-
this.curGraphics.delete(graphic);
|
|
2632
|
-
}
|
|
2633
|
-
});
|
|
2634
|
-
if (size !== this.curGraphics.size) {
|
|
2633
|
+
const timer = this.timer.setTimeout(() => {
|
|
2634
|
+
this.curGraphics.add(graphic);
|
|
2635
|
+
this.graphicTimerMap.delete(graphic);
|
|
2636
|
+
this.timer.clearTimeout(timer);
|
|
2635
2637
|
this.handleHoverGraphicsChange();
|
|
2638
|
+
}, time);
|
|
2639
|
+
this.graphicTimerMap.set(graphic, timer);
|
|
2640
|
+
});
|
|
2641
|
+
this.graphicTimerMap.forEach((timer, graphic) => {
|
|
2642
|
+
if (!allGraphics.has(graphic)) {
|
|
2643
|
+
this.timer.clearTimeout(timer);
|
|
2644
|
+
this.graphicTimerMap.delete(graphic);
|
|
2636
2645
|
}
|
|
2637
2646
|
});
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2647
|
+
const size = this.curGraphics.size;
|
|
2648
|
+
this.curGraphics.forEach((graphic) => {
|
|
2649
|
+
if (!allGraphics.has(graphic)) {
|
|
2650
|
+
this.curGraphics.delete(graphic);
|
|
2651
|
+
}
|
|
2641
2652
|
});
|
|
2642
|
-
this.
|
|
2643
|
-
|
|
2653
|
+
if (size !== this.curGraphics.size) {
|
|
2654
|
+
this.handleHoverGraphicsChange();
|
|
2655
|
+
}
|
|
2656
|
+
};
|
|
2657
|
+
onPointerLevel = () => {
|
|
2658
|
+
this.curGraphics.clear();
|
|
2659
|
+
this.handleHoverGraphicsChange();
|
|
2660
|
+
};
|
|
2644
2661
|
handleHoverGraphicsChange(graphics = this.curGraphics) {
|
|
2645
2662
|
this.dispatchEvent({ type: "hover-change", graphics: Array.from(graphics) });
|
|
2646
2663
|
}
|
|
@@ -2675,11 +2692,11 @@ function vectorToString(vector) {
|
|
|
2675
2692
|
var MaterialFactory = class {
|
|
2676
2693
|
constructor(context) {
|
|
2677
2694
|
this.context = context;
|
|
2678
|
-
__publicField(this, "lineMaterialMap", /* @__PURE__ */ new Map());
|
|
2679
|
-
__publicField(this, "meshStandardMaterialMap", /* @__PURE__ */ new Map());
|
|
2680
|
-
__publicField(this, "meshBasicMaterialMap", /* @__PURE__ */ new Map());
|
|
2681
|
-
__publicField(this, "shaderMaterialMap", /* @__PURE__ */ new Map());
|
|
2682
2695
|
}
|
|
2696
|
+
lineMaterialMap = /* @__PURE__ */ new Map();
|
|
2697
|
+
meshStandardMaterialMap = /* @__PURE__ */ new Map();
|
|
2698
|
+
meshBasicMaterialMap = /* @__PURE__ */ new Map();
|
|
2699
|
+
shaderMaterialMap = /* @__PURE__ */ new Map();
|
|
2683
2700
|
generateLineMaterialKey({ color, opacity }) {
|
|
2684
2701
|
return `${color}-${opacity}`;
|
|
2685
2702
|
}
|
|
@@ -2838,17 +2855,15 @@ import { Box3 as Box37, Vector3 as Vector312 } from "three";
|
|
|
2838
2855
|
var CameraBound = class {
|
|
2839
2856
|
constructor(context) {
|
|
2840
2857
|
this.context = context;
|
|
2841
|
-
__publicField(this, "prevCamera", {
|
|
2842
|
-
position: new Vector312(),
|
|
2843
|
-
zoom: 1,
|
|
2844
|
-
target: new Vector312()
|
|
2845
|
-
});
|
|
2846
|
-
__publicField(this, "enable", true);
|
|
2847
|
-
__publicField(this, "onCameraChange", () => {
|
|
2848
|
-
});
|
|
2849
2858
|
this.registryEvent();
|
|
2850
2859
|
this.changePrevCamera();
|
|
2851
2860
|
}
|
|
2861
|
+
prevCamera = {
|
|
2862
|
+
position: new Vector312(),
|
|
2863
|
+
zoom: 1,
|
|
2864
|
+
target: new Vector312()
|
|
2865
|
+
};
|
|
2866
|
+
enable = true;
|
|
2852
2867
|
setEnable(enable) {
|
|
2853
2868
|
this.enable = enable;
|
|
2854
2869
|
if (enable) {
|
|
@@ -2905,6 +2920,8 @@ var CameraBound = class {
|
|
|
2905
2920
|
const [pt, pr, pb, pl] = this.context.config.cameraBound.padding;
|
|
2906
2921
|
return left <= pl && width - right <= pr && top <= pt && height - bottom <= pb;
|
|
2907
2922
|
}
|
|
2923
|
+
onCameraChange = () => {
|
|
2924
|
+
};
|
|
2908
2925
|
dispose() {
|
|
2909
2926
|
this.unRegistryEvent();
|
|
2910
2927
|
}
|
|
@@ -2916,74 +2933,6 @@ var Context = class extends EventDispatcher6 {
|
|
|
2916
2933
|
super();
|
|
2917
2934
|
this.container = container;
|
|
2918
2935
|
this.config = config;
|
|
2919
|
-
__publicField(this, "scene", initScene());
|
|
2920
|
-
__publicField(this, "renderer", initRenderer());
|
|
2921
|
-
__publicField(this, "camera");
|
|
2922
|
-
__publicField(this, "control");
|
|
2923
|
-
__publicField(this, "lights", initLight());
|
|
2924
|
-
// 管理任务,防止内存泄漏
|
|
2925
|
-
__publicField(this, "timer", new Timer());
|
|
2926
|
-
__publicField(this, "tweenGroup", new TweenGroup());
|
|
2927
|
-
__publicField(this, "currentFloor");
|
|
2928
|
-
__publicField(this, "selection");
|
|
2929
|
-
__publicField(this, "hoverHelper");
|
|
2930
|
-
__publicField(this, "basicRatio");
|
|
2931
|
-
// zoom=1的时候,100M对应的像素个数
|
|
2932
|
-
__publicField(this, "materialFactory");
|
|
2933
|
-
__publicField(this, "cameraBound");
|
|
2934
|
-
__publicField(this, "clientSize", {
|
|
2935
|
-
width: 0,
|
|
2936
|
-
height: 0,
|
|
2937
|
-
x: 0,
|
|
2938
|
-
y: 0
|
|
2939
|
-
});
|
|
2940
|
-
__publicField(this, "onWindowResize", () => {
|
|
2941
|
-
const { container, camera, renderer } = this;
|
|
2942
|
-
let { clientWidth: w, clientHeight: h } = container;
|
|
2943
|
-
w = Math.max(1, w);
|
|
2944
|
-
h = Math.max(1, h);
|
|
2945
|
-
camera.left = -w / 2;
|
|
2946
|
-
camera.right = w / 2;
|
|
2947
|
-
camera.top = h / 2;
|
|
2948
|
-
camera.bottom = -h / 2;
|
|
2949
|
-
camera.updateProjectionMatrix();
|
|
2950
|
-
renderer.setSize(w, h);
|
|
2951
|
-
this.resizeClientSize();
|
|
2952
|
-
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
2953
|
-
});
|
|
2954
|
-
__publicField(this, "onClick", (e) => {
|
|
2955
|
-
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
2956
|
-
if (graphics.length) {
|
|
2957
|
-
this.dispatchEvent({
|
|
2958
|
-
type: "graphic-click",
|
|
2959
|
-
graphics,
|
|
2960
|
-
position
|
|
2961
|
-
});
|
|
2962
|
-
}
|
|
2963
|
-
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
2964
|
-
if (pois.length) {
|
|
2965
|
-
this.dispatchEvent({ type: "poi-click", pois });
|
|
2966
|
-
}
|
|
2967
|
-
});
|
|
2968
|
-
__publicField(this, "onPointerover", (e) => {
|
|
2969
|
-
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
2970
|
-
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
2971
|
-
this.dispatchEvent({ type: "pointer-over", e, graphics, pois, position });
|
|
2972
|
-
});
|
|
2973
|
-
__publicField(this, "onPointermove", (e) => {
|
|
2974
|
-
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
2975
|
-
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
2976
|
-
this.dispatchEvent({ type: "pointer-move", e, graphics, pois, position });
|
|
2977
|
-
});
|
|
2978
|
-
__publicField(this, "onPointerleave", () => {
|
|
2979
|
-
this.dispatchEvent({ type: "pointer-level" });
|
|
2980
|
-
});
|
|
2981
|
-
__publicField(this, "onSelectionSelect", ({ graphics, isMultipleSelect }) => {
|
|
2982
|
-
this.dispatchEvent({ type: "select-graphic", graphics, isMultipleSelect });
|
|
2983
|
-
});
|
|
2984
|
-
__publicField(this, "onHoverChange", ({ graphics }) => {
|
|
2985
|
-
this.dispatchEvent({ type: "hover", graphics });
|
|
2986
|
-
});
|
|
2987
2936
|
this.container.style.position = "relative";
|
|
2988
2937
|
this.container.style.overflow = "hidden";
|
|
2989
2938
|
this.init();
|
|
@@ -2993,6 +2942,27 @@ var Context = class extends EventDispatcher6 {
|
|
|
2993
2942
|
this.resizeClientSize();
|
|
2994
2943
|
this.registryEvent();
|
|
2995
2944
|
}
|
|
2945
|
+
scene = initScene();
|
|
2946
|
+
renderer = initRenderer();
|
|
2947
|
+
camera;
|
|
2948
|
+
control;
|
|
2949
|
+
lights = initLight();
|
|
2950
|
+
// 管理任务,防止内存泄漏
|
|
2951
|
+
timer = new Timer();
|
|
2952
|
+
tweenGroup = new TweenGroup();
|
|
2953
|
+
currentFloor;
|
|
2954
|
+
selection;
|
|
2955
|
+
hoverHelper;
|
|
2956
|
+
basicRatio;
|
|
2957
|
+
// zoom=1的时候,100M对应的像素个数
|
|
2958
|
+
materialFactory;
|
|
2959
|
+
cameraBound;
|
|
2960
|
+
clientSize = {
|
|
2961
|
+
width: 0,
|
|
2962
|
+
height: 0,
|
|
2963
|
+
x: 0,
|
|
2964
|
+
y: 0
|
|
2965
|
+
};
|
|
2996
2966
|
resizeClientSize() {
|
|
2997
2967
|
const { x, y, width, height } = this.container.getBoundingClientRect();
|
|
2998
2968
|
this.clientSize = {
|
|
@@ -3012,9 +2982,8 @@ var Context = class extends EventDispatcher6 {
|
|
|
3012
2982
|
this.scene.add(this.lights);
|
|
3013
2983
|
this.basicRatio = this.getRatio();
|
|
3014
2984
|
this.control.addEventListener("change", () => {
|
|
3015
|
-
var _a;
|
|
3016
2985
|
const polarAngle = this.control.getPolarAngle();
|
|
3017
|
-
|
|
2986
|
+
this.currentFloor?.setShadowOpacity(polarAngle / this.config.control.maxPolar);
|
|
3018
2987
|
this.dispatchEvent({ type: "change-ratio", px: (this.basicRatio || 0) * this.camera.zoom });
|
|
3019
2988
|
this.dispatchEvent({ type: "control-change" });
|
|
3020
2989
|
});
|
|
@@ -3027,7 +2996,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
3027
2996
|
const { clientWidth, clientHeight } = this.container;
|
|
3028
2997
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
3029
2998
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
3030
|
-
return Math.ceil(Math.sqrt(
|
|
2999
|
+
return Math.ceil(Math.sqrt((device2.x - device1.x) ** 2 + (device2.y - device1.y) ** 2));
|
|
3031
3000
|
}
|
|
3032
3001
|
changeAmbientLightColor(color) {
|
|
3033
3002
|
this.lights.children.forEach((item) => {
|
|
@@ -3049,6 +3018,34 @@ var Context = class extends EventDispatcher6 {
|
|
|
3049
3018
|
this.lights.position.y = position.y;
|
|
3050
3019
|
}
|
|
3051
3020
|
}
|
|
3021
|
+
onWindowResize = () => {
|
|
3022
|
+
const { container, camera, renderer } = this;
|
|
3023
|
+
let { clientWidth: w, clientHeight: h } = container;
|
|
3024
|
+
w = Math.max(1, w);
|
|
3025
|
+
h = Math.max(1, h);
|
|
3026
|
+
camera.left = -w / 2;
|
|
3027
|
+
camera.right = w / 2;
|
|
3028
|
+
camera.top = h / 2;
|
|
3029
|
+
camera.bottom = -h / 2;
|
|
3030
|
+
camera.updateProjectionMatrix();
|
|
3031
|
+
renderer.setSize(w, h);
|
|
3032
|
+
this.resizeClientSize();
|
|
3033
|
+
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
3034
|
+
};
|
|
3035
|
+
onClick = (e) => {
|
|
3036
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3037
|
+
if (graphics.length) {
|
|
3038
|
+
this.dispatchEvent({
|
|
3039
|
+
type: "graphic-click",
|
|
3040
|
+
graphics,
|
|
3041
|
+
position
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3045
|
+
if (pois.length) {
|
|
3046
|
+
this.dispatchEvent({ type: "poi-click", pois });
|
|
3047
|
+
}
|
|
3048
|
+
};
|
|
3052
3049
|
/**
|
|
3053
3050
|
* 获取屏幕坐标对应的graphic
|
|
3054
3051
|
* @param x
|
|
@@ -3056,13 +3053,12 @@ var Context = class extends EventDispatcher6 {
|
|
|
3056
3053
|
* @returns
|
|
3057
3054
|
*/
|
|
3058
3055
|
getGraphicsByDeviceXy(x, y) {
|
|
3059
|
-
var _a;
|
|
3060
3056
|
const point3 = new Vector23();
|
|
3061
3057
|
point3.x = x / this.clientSize.width * 2 - 1;
|
|
3062
3058
|
point3.y = y / this.clientSize.height * -2 + 1;
|
|
3063
3059
|
const raycaster = new Raycaster3();
|
|
3064
3060
|
raycaster.setFromCamera(point3, this.camera);
|
|
3065
|
-
const res =
|
|
3061
|
+
const res = this.currentFloor?.graphicLayer.getGraphicByRaycaster(raycaster);
|
|
3066
3062
|
return res || { graphics: [], position: null };
|
|
3067
3063
|
}
|
|
3068
3064
|
/**
|
|
@@ -3072,10 +3068,28 @@ var Context = class extends EventDispatcher6 {
|
|
|
3072
3068
|
* @returns
|
|
3073
3069
|
*/
|
|
3074
3070
|
getPoisByDeviceXy(x, y) {
|
|
3075
|
-
|
|
3076
|
-
const pois = (_a = this.currentFloor) == null ? void 0 : _a.poiLayer.getPoiByDeviceXy(x, y);
|
|
3071
|
+
const pois = this.currentFloor?.poiLayer.getPoiByDeviceXy(x, y);
|
|
3077
3072
|
return pois || [];
|
|
3078
3073
|
}
|
|
3074
|
+
onPointerover = (e) => {
|
|
3075
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3076
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3077
|
+
this.dispatchEvent({ type: "pointer-over", e, graphics, pois, position });
|
|
3078
|
+
};
|
|
3079
|
+
onPointermove = (e) => {
|
|
3080
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3081
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3082
|
+
this.dispatchEvent({ type: "pointer-move", e, graphics, pois, position });
|
|
3083
|
+
};
|
|
3084
|
+
onPointerleave = () => {
|
|
3085
|
+
this.dispatchEvent({ type: "pointer-level" });
|
|
3086
|
+
};
|
|
3087
|
+
onSelectionSelect = ({ graphics, isMultipleSelect }) => {
|
|
3088
|
+
this.dispatchEvent({ type: "select-graphic", graphics, isMultipleSelect });
|
|
3089
|
+
};
|
|
3090
|
+
onHoverChange = ({ graphics }) => {
|
|
3091
|
+
this.dispatchEvent({ type: "hover", graphics });
|
|
3092
|
+
};
|
|
3079
3093
|
registryEvent() {
|
|
3080
3094
|
window.addEventListener("resize", this.onWindowResize);
|
|
3081
3095
|
this.container.addEventListener("click", this.onClick);
|
|
@@ -3323,7 +3337,8 @@ var defaultConfig = {
|
|
|
3323
3337
|
apiInfo: {},
|
|
3324
3338
|
apiPath: {
|
|
3325
3339
|
floorGraphic: "/api/inception-map/floor/get",
|
|
3326
|
-
floorRange: "/api/inception-map/range/get"
|
|
3340
|
+
floorRange: "/api/inception-map/range/get",
|
|
3341
|
+
equipmentList: "/api/inception-map/equipment/get"
|
|
3327
3342
|
},
|
|
3328
3343
|
resizeObserver: false,
|
|
3329
3344
|
initTransToMark: false,
|
|
@@ -3390,6 +3405,112 @@ function getConfig(config) {
|
|
|
3390
3405
|
|
|
3391
3406
|
// src/bmap.ts
|
|
3392
3407
|
import { debounce as debounce3 } from "lodash";
|
|
3408
|
+
|
|
3409
|
+
// src/plugins/base.ts
|
|
3410
|
+
var Plugin = class {
|
|
3411
|
+
bmap;
|
|
3412
|
+
constructor(bmap) {
|
|
3413
|
+
this.bmap = bmap;
|
|
3414
|
+
}
|
|
3415
|
+
dispose() {
|
|
3416
|
+
}
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
// src/plugins/equipment/equipment.ts
|
|
3420
|
+
var Equipment = class extends Plugin {
|
|
3421
|
+
equipmentList = [];
|
|
3422
|
+
equipmentMap = /* @__PURE__ */ new Map();
|
|
3423
|
+
constructor(bmap) {
|
|
3424
|
+
super(bmap);
|
|
3425
|
+
this.fetchEquipment();
|
|
3426
|
+
this.bmap.event.on("switch_floor_after" /* SWITCH_FLOOR_AFTER */, this.onSwitchFloor);
|
|
3427
|
+
}
|
|
3428
|
+
async fetchEquipment() {
|
|
3429
|
+
const {
|
|
3430
|
+
apiDomain,
|
|
3431
|
+
apiPath: { equipmentList },
|
|
3432
|
+
apiInfo
|
|
3433
|
+
} = this.bmap.config;
|
|
3434
|
+
const url = `${apiDomain}${equipmentList}`;
|
|
3435
|
+
await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3436
|
+
this.equipmentList = res;
|
|
3437
|
+
this.equipmentMap = new Map(
|
|
3438
|
+
res.map((item) => [item.equipment_id, item])
|
|
3439
|
+
);
|
|
3440
|
+
});
|
|
3441
|
+
if (this.bmap.context.currentFloor) {
|
|
3442
|
+
this.changeGraphicToEquipment(
|
|
3443
|
+
this.bmap.context.currentFloor.graphicLayer.children
|
|
3444
|
+
);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
onSwitchFloor = (floor) => {
|
|
3448
|
+
if (!this.equipmentList.length) {
|
|
3449
|
+
return;
|
|
3450
|
+
}
|
|
3451
|
+
this.changeGraphicToEquipment(floor.graphics);
|
|
3452
|
+
};
|
|
3453
|
+
getGraphicEquipment(graphic) {
|
|
3454
|
+
return graphic.userData.data.info.userData.equipment;
|
|
3455
|
+
}
|
|
3456
|
+
changeGraphicToEquipment(graphics) {
|
|
3457
|
+
graphics.filter((graphic) => {
|
|
3458
|
+
const equipment = this.getGraphicEquipment(graphic);
|
|
3459
|
+
return equipment && this.equipmentMap.has(equipment);
|
|
3460
|
+
}).forEach((graphic) => {
|
|
3461
|
+
const equipment = this.equipmentMap.get(
|
|
3462
|
+
this.getGraphicEquipment(graphic)
|
|
3463
|
+
);
|
|
3464
|
+
const poi = this.bmap.createGraphicPoi(graphic, {
|
|
3465
|
+
icon: equipment?.equipment_icon,
|
|
3466
|
+
built_in: true,
|
|
3467
|
+
icon_size: [14, 14]
|
|
3468
|
+
});
|
|
3469
|
+
});
|
|
3470
|
+
}
|
|
3471
|
+
dispose() {
|
|
3472
|
+
this.bmap.event.off("switch_floor_after" /* SWITCH_FLOOR_AFTER */, this.onSwitchFloor);
|
|
3473
|
+
}
|
|
3474
|
+
};
|
|
3475
|
+
|
|
3476
|
+
// src/api/floor.ts
|
|
3477
|
+
async function loadBuildingGround({ brand, project }, config) {
|
|
3478
|
+
const {
|
|
3479
|
+
apiDomain,
|
|
3480
|
+
apiPath: { floorRange },
|
|
3481
|
+
apiInfo
|
|
3482
|
+
} = config;
|
|
3483
|
+
const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${project}&building=${project}`;
|
|
3484
|
+
const data = await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3485
|
+
const data2 = (res || [])[0];
|
|
3486
|
+
if (data2) {
|
|
3487
|
+
data2.info = JSON.parse(data2.info);
|
|
3488
|
+
}
|
|
3489
|
+
return data2;
|
|
3490
|
+
});
|
|
3491
|
+
return data;
|
|
3492
|
+
}
|
|
3493
|
+
async function loadGraphics({
|
|
3494
|
+
brand,
|
|
3495
|
+
project,
|
|
3496
|
+
floor,
|
|
3497
|
+
ts,
|
|
3498
|
+
resource_type_list
|
|
3499
|
+
}, config) {
|
|
3500
|
+
const {
|
|
3501
|
+
apiDomain,
|
|
3502
|
+
apiPath: { floorGraphic },
|
|
3503
|
+
apiInfo
|
|
3504
|
+
} = config;
|
|
3505
|
+
const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${project}&building=${project}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
|
|
3506
|
+
const data = await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3507
|
+
(res || []).map((item) => item.info = JSON.parse(item.info));
|
|
3508
|
+
return res || [];
|
|
3509
|
+
});
|
|
3510
|
+
return data;
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
// src/bmap.ts
|
|
3393
3514
|
var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
3394
3515
|
MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
|
|
3395
3516
|
MapTypePolar2[MapTypePolar2["D3"] = 1.1] = "D3";
|
|
@@ -3399,243 +3520,145 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3399
3520
|
constructor(container, config = {}) {
|
|
3400
3521
|
super();
|
|
3401
3522
|
this.container = container;
|
|
3402
|
-
__publicField(this, "config");
|
|
3403
|
-
__publicField(this, "context");
|
|
3404
|
-
__publicField(this, "polarKeys", []);
|
|
3405
|
-
__publicField(this, "azimuthalKeys", []);
|
|
3406
|
-
__publicField(this, "svgLine");
|
|
3407
|
-
__publicField(this, "svgPolygon");
|
|
3408
|
-
__publicField(this, "basicZoom", 1);
|
|
3409
|
-
__publicField(this, "prevCameraZoom", 1);
|
|
3410
|
-
__publicField(this, "type", "2d");
|
|
3411
|
-
__publicField(this, "floorDataMap", /* @__PURE__ */ new Map());
|
|
3412
|
-
__publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
|
|
3413
|
-
__publicField(this, "currentBuildGround", null);
|
|
3414
|
-
__publicField(this, "observe", null);
|
|
3415
|
-
__publicField(this, "timer", new Timer());
|
|
3416
|
-
__publicField(this, "onControlChange", () => {
|
|
3417
|
-
const {
|
|
3418
|
-
camera: { zoom }
|
|
3419
|
-
} = this.context;
|
|
3420
|
-
if (zoom !== this.prevCameraZoom) {
|
|
3421
|
-
this.dispatchEvent({
|
|
3422
|
-
type: "zoom-change",
|
|
3423
|
-
basicZoom: this.basicZoom,
|
|
3424
|
-
cameraZoom: this.context.camera.zoom
|
|
3425
|
-
});
|
|
3426
|
-
this.prevCameraZoom = zoom;
|
|
3427
|
-
}
|
|
3428
|
-
});
|
|
3429
|
-
__publicField(this, "onKeydown", (e) => {
|
|
3430
|
-
if (this.polarKeys.includes(e.code)) {
|
|
3431
|
-
this.context.control.maxPolarAngle = this.config.control.maxPolar;
|
|
3432
|
-
this.context.control.minPolarAngle = 0;
|
|
3433
|
-
}
|
|
3434
|
-
if (this.azimuthalKeys.includes(e.code)) {
|
|
3435
|
-
this.context.control.maxAzimuthAngle = Infinity;
|
|
3436
|
-
this.context.control.minAzimuthAngle = Infinity;
|
|
3437
|
-
}
|
|
3438
|
-
});
|
|
3439
|
-
__publicField(this, "onKeyUp", (e) => {
|
|
3440
|
-
if (this.polarKeys.includes(e.code)) {
|
|
3441
|
-
const polar = this.context.control.getPolarAngle();
|
|
3442
|
-
this.context.control.maxPolarAngle = polar;
|
|
3443
|
-
this.context.control.minPolarAngle = polar;
|
|
3444
|
-
}
|
|
3445
|
-
if (this.azimuthalKeys.includes(e.code)) {
|
|
3446
|
-
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
3447
|
-
this.context.control.maxAzimuthAngle = azimuthal;
|
|
3448
|
-
this.context.control.minAzimuthAngle = azimuthal;
|
|
3449
|
-
}
|
|
3450
|
-
});
|
|
3451
|
-
__publicField(this, "resize", () => {
|
|
3452
|
-
this.context.cameraBound.setEnable(false);
|
|
3453
|
-
this.context.onWindowResize();
|
|
3454
|
-
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
3455
|
-
const zoom = this.context.camera.zoom;
|
|
3456
|
-
this.context.control.minZoom = 0;
|
|
3457
|
-
this.context.control.maxZoom = Infinity;
|
|
3458
|
-
this.context.camera.zoom = 1;
|
|
3459
|
-
this.context.setAzimuthalAngle(0, 0);
|
|
3460
|
-
const basicZoom = this.context.getFitCameraToGroundZoom(void 0, 0);
|
|
3461
|
-
this.basicZoom = basicZoom || 0;
|
|
3462
|
-
this.context.control.minZoom = this.basicZoom;
|
|
3463
|
-
this.context.control.maxZoom = this.basicZoom * 25;
|
|
3464
|
-
this.context.camera.zoom = zoom;
|
|
3465
|
-
this.context.control.addEventListener("change", this.onControlChange);
|
|
3466
|
-
this.context.setAzimuthalAngle(azimuthal, 0);
|
|
3467
|
-
this.context.cameraBound.setEnable(true);
|
|
3468
|
-
});
|
|
3469
3523
|
this.config = getConfig(config);
|
|
3470
3524
|
this.context = new Context(container, this.config);
|
|
3471
3525
|
this.registryEvent();
|
|
3472
3526
|
this.context.render();
|
|
3473
3527
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3528
|
+
config;
|
|
3529
|
+
context;
|
|
3530
|
+
polarKeys = [];
|
|
3531
|
+
azimuthalKeys = [];
|
|
3532
|
+
svgLine;
|
|
3533
|
+
svgPolygon;
|
|
3534
|
+
basicZoom = 1;
|
|
3535
|
+
prevCameraZoom = 1;
|
|
3536
|
+
type = "2d";
|
|
3537
|
+
floorDataMap = /* @__PURE__ */ new Map();
|
|
3538
|
+
buildingGroundMap = /* @__PURE__ */ new Map();
|
|
3539
|
+
currentBuildGround = null;
|
|
3540
|
+
observe = null;
|
|
3541
|
+
event = new Events();
|
|
3542
|
+
timer = new Timer();
|
|
3543
|
+
plugins = [];
|
|
3544
|
+
async loadGraphics({
|
|
3545
|
+
brand,
|
|
3546
|
+
project,
|
|
3547
|
+
floor,
|
|
3548
|
+
ts,
|
|
3549
|
+
resource_type_list
|
|
3550
|
+
}) {
|
|
3551
|
+
const data = await loadGraphics({
|
|
3476
3552
|
brand,
|
|
3477
3553
|
project,
|
|
3478
|
-
phase,
|
|
3479
|
-
building,
|
|
3480
3554
|
floor,
|
|
3481
3555
|
ts,
|
|
3482
3556
|
resource_type_list
|
|
3483
|
-
})
|
|
3484
|
-
|
|
3485
|
-
apiDomain,
|
|
3486
|
-
apiPath: { floorGraphic },
|
|
3487
|
-
apiInfo
|
|
3488
|
-
} = this.config;
|
|
3489
|
-
const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
|
|
3490
|
-
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3491
|
-
(res || []).map((item) => item.info = JSON.parse(item.info));
|
|
3492
|
-
return res || [];
|
|
3493
|
-
});
|
|
3494
|
-
return data;
|
|
3495
|
-
});
|
|
3557
|
+
}, this.config);
|
|
3558
|
+
return data;
|
|
3496
3559
|
}
|
|
3497
|
-
|
|
3560
|
+
async loadBuildingGround({
|
|
3498
3561
|
brand,
|
|
3499
|
-
project
|
|
3500
|
-
phase,
|
|
3501
|
-
building
|
|
3562
|
+
project
|
|
3502
3563
|
}) {
|
|
3503
|
-
const key =
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
phase,
|
|
3511
|
-
building
|
|
3512
|
-
}) {
|
|
3513
|
-
const key = this.getBuildingKey({ brand, project, phase, building });
|
|
3514
|
-
if (this.buildingGroundMap.get(key)) {
|
|
3515
|
-
return this.buildingGroundMap.get(key) || null;
|
|
3516
|
-
}
|
|
3517
|
-
const {
|
|
3518
|
-
apiDomain,
|
|
3519
|
-
apiPath: { floorRange },
|
|
3520
|
-
apiInfo
|
|
3521
|
-
} = this.config;
|
|
3522
|
-
const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${phase}&building=${building}`;
|
|
3523
|
-
const data = yield fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3524
|
-
const data2 = (res || [])[0];
|
|
3525
|
-
if (data2) {
|
|
3526
|
-
data2.info = JSON.parse(data2.info);
|
|
3527
|
-
}
|
|
3528
|
-
return data2;
|
|
3529
|
-
});
|
|
3530
|
-
this.buildingGroundMap.set(key, data);
|
|
3531
|
-
return data;
|
|
3532
|
-
});
|
|
3564
|
+
const key = generatorKeyByObj({ brand, project });
|
|
3565
|
+
if (this.buildingGroundMap.get(key)) {
|
|
3566
|
+
return this.buildingGroundMap.get(key) || null;
|
|
3567
|
+
}
|
|
3568
|
+
const data = await loadBuildingGround({ brand, project }, this.config);
|
|
3569
|
+
this.buildingGroundMap.set(key, data);
|
|
3570
|
+
return data;
|
|
3533
3571
|
}
|
|
3534
|
-
|
|
3572
|
+
async load({
|
|
3535
3573
|
brand,
|
|
3536
3574
|
project,
|
|
3537
|
-
phase,
|
|
3538
|
-
building,
|
|
3539
3575
|
floor,
|
|
3540
3576
|
ts,
|
|
3541
3577
|
resource_type_list
|
|
3542
3578
|
}) {
|
|
3543
|
-
const floorKey =
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
project,
|
|
3550
|
-
phase,
|
|
3551
|
-
building,
|
|
3552
|
-
floor,
|
|
3553
|
-
ts,
|
|
3554
|
-
resource_type_list
|
|
3555
|
-
}) {
|
|
3556
|
-
const floorKey = this.getFloorKey({
|
|
3579
|
+
const floorKey = generatorKeyByObj({ brand, project, floor, ts, resource_type_list });
|
|
3580
|
+
if (this.floorDataMap.has(floorKey)) {
|
|
3581
|
+
return this.floorDataMap.get(floorKey);
|
|
3582
|
+
}
|
|
3583
|
+
const [data, buildGround] = await Promise.all([
|
|
3584
|
+
this.loadGraphics({
|
|
3557
3585
|
brand,
|
|
3558
3586
|
project,
|
|
3559
|
-
phase,
|
|
3560
|
-
building,
|
|
3561
3587
|
floor,
|
|
3562
3588
|
ts,
|
|
3563
3589
|
resource_type_list
|
|
3564
|
-
})
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
)
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
)
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
cds.forEach((coord) => {
|
|
3592
|
-
coord[0] -= center2[0];
|
|
3593
|
-
coord[1] -= center2[1];
|
|
3594
|
-
});
|
|
3595
|
-
}
|
|
3590
|
+
}),
|
|
3591
|
+
this.loadBuildingGround({ brand, project })
|
|
3592
|
+
]);
|
|
3593
|
+
const center2 = buildGround ? getCenter(
|
|
3594
|
+
buildGround.info.geometry.cds[0]
|
|
3595
|
+
) : [0, 0];
|
|
3596
|
+
this.transformGraphicData(data, center2);
|
|
3597
|
+
data.forEach((item) => {
|
|
3598
|
+
item.info.transformToBuildingGround = !!buildGround;
|
|
3599
|
+
});
|
|
3600
|
+
if (!this.config.useFloorCache) {
|
|
3601
|
+
this.floorDataMap.clear();
|
|
3602
|
+
}
|
|
3603
|
+
this.floorDataMap.set(floorKey, data);
|
|
3604
|
+
return data;
|
|
3605
|
+
}
|
|
3606
|
+
transformGraphicData(data, center2) {
|
|
3607
|
+
data.forEach((item) => {
|
|
3608
|
+
item.info.geometry.coords = JSON.parse(
|
|
3609
|
+
JSON.stringify(item.info.geometry.cds)
|
|
3610
|
+
);
|
|
3611
|
+
if (item.info.geometry.type === "polygon") {
|
|
3612
|
+
item.info.geometry.coords.map((cds) => {
|
|
3613
|
+
if (Array.isArray(cds)) {
|
|
3614
|
+
cds.forEach((coord) => {
|
|
3615
|
+
coord[0] -= center2[0];
|
|
3616
|
+
coord[1] -= center2[1];
|
|
3596
3617
|
});
|
|
3597
|
-
} else {
|
|
3598
|
-
const [x, y] = item.info.geometry.cds;
|
|
3599
|
-
item.info.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3600
3618
|
}
|
|
3601
|
-
item.info.transformToBuildingGround = true;
|
|
3602
3619
|
});
|
|
3620
|
+
} else {
|
|
3621
|
+
const [x, y] = item.info.geometry.cds;
|
|
3622
|
+
item.info.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3603
3623
|
}
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3624
|
+
});
|
|
3625
|
+
const { ground, markGraphic, graphic } = this.config;
|
|
3626
|
+
for (let i = 0; i < data.length; i++) {
|
|
3627
|
+
const item = data[i];
|
|
3628
|
+
item.info.deltaHeight = 1e-5 * (i + 1);
|
|
3629
|
+
if (item.info.group === "ground") {
|
|
3630
|
+
item.info.fillColor = ground.color;
|
|
3631
|
+
item.info.fillOpacity = ground.opacity;
|
|
3632
|
+
item.info.height = ground.height;
|
|
3633
|
+
item.info.stroke = ground.stroke;
|
|
3634
|
+
item.info.strokeColor = ground.strokeColor;
|
|
3635
|
+
item.info.strokeOpacity = ground.strokeOpacity;
|
|
3636
|
+
} else if (item.info.userData.mark) {
|
|
3637
|
+
item.info.height = markGraphic.height;
|
|
3638
|
+
item.info.fillColor = markGraphic.color;
|
|
3639
|
+
item.info.fillOpacity = markGraphic.opacity;
|
|
3640
|
+
item.info.stroke = markGraphic.stroke;
|
|
3641
|
+
item.info.strokeColor = markGraphic.strokeColor;
|
|
3642
|
+
item.info.strokeOpacity = markGraphic.strokeOpacity;
|
|
3643
|
+
} else {
|
|
3644
|
+
item.info.fillOpacity = graphic.fillOpacity;
|
|
3645
|
+
if (this.config.initTransToMark) {
|
|
3616
3646
|
item.info.height = markGraphic.height;
|
|
3617
3647
|
item.info.fillColor = markGraphic.color;
|
|
3618
|
-
item.info.fillOpacity = markGraphic.opacity;
|
|
3619
3648
|
item.info.stroke = markGraphic.stroke;
|
|
3620
3649
|
item.info.strokeColor = markGraphic.strokeColor;
|
|
3621
3650
|
item.info.strokeOpacity = markGraphic.strokeOpacity;
|
|
3622
|
-
} else {
|
|
3623
|
-
item.info.fillOpacity = graphic.fillOpacity;
|
|
3624
|
-
if (this.config.initTransToMark) {
|
|
3625
|
-
item.info.height = markGraphic.height;
|
|
3626
|
-
item.info.fillColor = markGraphic.color;
|
|
3627
|
-
item.info.stroke = markGraphic.stroke;
|
|
3628
|
-
item.info.strokeColor = markGraphic.strokeColor;
|
|
3629
|
-
item.info.strokeOpacity = markGraphic.strokeOpacity;
|
|
3630
|
-
}
|
|
3631
3651
|
}
|
|
3632
3652
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
loadEquipment() {
|
|
3656
|
+
const equipment = new Equipment(this);
|
|
3657
|
+
this.plugins.push(equipment);
|
|
3658
|
+
}
|
|
3659
|
+
use(plugin) {
|
|
3660
|
+
plugin.bmap = this;
|
|
3661
|
+
this.plugins.push(plugin);
|
|
3639
3662
|
}
|
|
3640
3663
|
createFloor(data) {
|
|
3641
3664
|
const curFloor = new Floor(this.context);
|
|
@@ -3657,20 +3680,19 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3657
3680
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
3658
3681
|
return { curFloor, graphics };
|
|
3659
3682
|
}
|
|
3683
|
+
triggerHooks(hooks, ...args) {
|
|
3684
|
+
this.event.emit(hooks, ...args);
|
|
3685
|
+
}
|
|
3660
3686
|
switchFloor({
|
|
3661
3687
|
brand,
|
|
3662
3688
|
project,
|
|
3663
|
-
phase,
|
|
3664
|
-
building,
|
|
3665
3689
|
floor,
|
|
3666
3690
|
ts,
|
|
3667
3691
|
resource_type_list
|
|
3668
3692
|
}) {
|
|
3669
|
-
const floorKey =
|
|
3693
|
+
const floorKey = generatorKeyByObj({
|
|
3670
3694
|
brand,
|
|
3671
3695
|
project,
|
|
3672
|
-
phase,
|
|
3673
|
-
building,
|
|
3674
3696
|
floor,
|
|
3675
3697
|
ts,
|
|
3676
3698
|
resource_type_list
|
|
@@ -3678,31 +3700,14 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3678
3700
|
const curFloorData = this.floorDataMap.get(floorKey);
|
|
3679
3701
|
this.context.control.removeEventListener("change", this.onControlChange);
|
|
3680
3702
|
if (curFloorData) {
|
|
3681
|
-
const buildingKey =
|
|
3682
|
-
brand,
|
|
3683
|
-
project,
|
|
3684
|
-
phase,
|
|
3685
|
-
building
|
|
3686
|
-
});
|
|
3703
|
+
const buildingKey = generatorKeyByObj({ brand, project });
|
|
3687
3704
|
this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
|
|
3688
3705
|
const createdFloor = this.createFloor(curFloorData);
|
|
3689
3706
|
if (createdFloor) {
|
|
3690
|
-
this.
|
|
3707
|
+
this.triggerHooks("switch_floor_before" /* SWITCH_FLOOR_BEFORE */, createdFloor);
|
|
3691
3708
|
this.context.switchFloor(createdFloor.curFloor);
|
|
3692
|
-
this.
|
|
3693
|
-
this.
|
|
3694
|
-
this.context.camera.zoom = 1;
|
|
3695
|
-
this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal, 0);
|
|
3696
|
-
this.context.fitCameraToGround(void 0, 0);
|
|
3697
|
-
this.basicZoom = this.context.camera.zoom;
|
|
3698
|
-
this.context.control.minZoom = this.basicZoom;
|
|
3699
|
-
this.context.control.maxZoom = this.basicZoom * 25;
|
|
3700
|
-
this.context.control.addEventListener("change", this.onControlChange);
|
|
3701
|
-
if (this.type === "3d") {
|
|
3702
|
-
this.context.fitCameraToGround(this.config.defaultPadding, 0, false);
|
|
3703
|
-
}
|
|
3704
|
-
this.onControlChange();
|
|
3705
|
-
this.context.cameraBound.setEnable(true);
|
|
3709
|
+
this.initialFloorCamera();
|
|
3710
|
+
this.triggerHooks("switch_floor_after" /* SWITCH_FLOOR_AFTER */, createdFloor);
|
|
3706
3711
|
} else {
|
|
3707
3712
|
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
3708
3713
|
}
|
|
@@ -3712,14 +3717,45 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3712
3717
|
);
|
|
3713
3718
|
}
|
|
3714
3719
|
}
|
|
3720
|
+
// 切换楼层后初始化相机
|
|
3721
|
+
initialFloorCamera() {
|
|
3722
|
+
this.context.cameraBound.setEnable(false);
|
|
3723
|
+
this.context.control.minZoom = 0;
|
|
3724
|
+
this.context.control.maxZoom = Infinity;
|
|
3725
|
+
this.context.camera.zoom = 1;
|
|
3726
|
+
this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal, 0);
|
|
3727
|
+
this.context.fitCameraToGround(void 0, 0);
|
|
3728
|
+
this.basicZoom = this.context.camera.zoom;
|
|
3729
|
+
this.context.control.minZoom = this.basicZoom;
|
|
3730
|
+
this.context.control.maxZoom = this.basicZoom * 25;
|
|
3731
|
+
this.context.control.addEventListener("change", this.onControlChange);
|
|
3732
|
+
if (this.type === "3d") {
|
|
3733
|
+
this.context.fitCameraToGround(this.config.defaultPadding, 0, false);
|
|
3734
|
+
}
|
|
3735
|
+
this.onControlChange();
|
|
3736
|
+
this.context.cameraBound.setEnable(true);
|
|
3737
|
+
}
|
|
3738
|
+
onControlChange = () => {
|
|
3739
|
+
const {
|
|
3740
|
+
camera: { zoom }
|
|
3741
|
+
} = this.context;
|
|
3742
|
+
if (zoom !== this.prevCameraZoom) {
|
|
3743
|
+
this.dispatchEvent({
|
|
3744
|
+
type: "zoom-change",
|
|
3745
|
+
basicZoom: this.basicZoom,
|
|
3746
|
+
cameraZoom: this.context.camera.zoom
|
|
3747
|
+
});
|
|
3748
|
+
this.prevCameraZoom = zoom;
|
|
3749
|
+
}
|
|
3750
|
+
};
|
|
3715
3751
|
// 扶梯
|
|
3716
3752
|
addModel(graphic, options) {
|
|
3717
|
-
var _a;
|
|
3718
3753
|
if (graphic.options.geometry.type === "polygon") {
|
|
3719
|
-
const model =
|
|
3754
|
+
const model = this.context.currentFloor?.addModel({
|
|
3755
|
+
...options,
|
|
3720
3756
|
position: graphic.getPosition().setZ(0.1),
|
|
3721
3757
|
id: graphic.options.id
|
|
3722
|
-
})
|
|
3758
|
+
});
|
|
3723
3759
|
if (model) {
|
|
3724
3760
|
const {
|
|
3725
3761
|
facilityAngle = 0,
|
|
@@ -3732,22 +3768,19 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3732
3768
|
}
|
|
3733
3769
|
}
|
|
3734
3770
|
addHeatmap(data) {
|
|
3735
|
-
|
|
3736
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.addHeatmap(data);
|
|
3771
|
+
return this.context.currentFloor?.addHeatmap(data);
|
|
3737
3772
|
}
|
|
3738
3773
|
getLegacyToGraphicMap() {
|
|
3739
|
-
|
|
3740
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.userData.legacyToGraphicMap) || /* @__PURE__ */ new Map();
|
|
3774
|
+
return this.context.currentFloor?.userData.legacyToGraphicMap || /* @__PURE__ */ new Map();
|
|
3741
3775
|
}
|
|
3742
3776
|
/**
|
|
3743
3777
|
* 获取当前楼层全部的graphic
|
|
3744
3778
|
* @returns
|
|
3745
3779
|
*/
|
|
3746
3780
|
getFloorAllGraphics() {
|
|
3747
|
-
|
|
3748
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.children.filter(
|
|
3781
|
+
return this.context.currentFloor?.graphicLayer.children.filter(
|
|
3749
3782
|
(item) => item instanceof Graphic
|
|
3750
|
-
)
|
|
3783
|
+
) || [];
|
|
3751
3784
|
}
|
|
3752
3785
|
createGraphicPoi(graphic, options) {
|
|
3753
3786
|
if (this.context.currentFloor) {
|
|
@@ -3755,16 +3788,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3755
3788
|
options.id = graphic.options.id;
|
|
3756
3789
|
}
|
|
3757
3790
|
const position = graphic.getCenter();
|
|
3758
|
-
const poi = this.context.currentFloor.addPoi(
|
|
3759
|
-
|
|
3760
|
-
|
|
3791
|
+
const poi = this.context.currentFloor.addPoi({
|
|
3792
|
+
...options,
|
|
3793
|
+
position: { ...position, z: position.z + graphic.options.height / 2 }
|
|
3794
|
+
});
|
|
3761
3795
|
return poi;
|
|
3762
3796
|
}
|
|
3763
3797
|
return null;
|
|
3764
3798
|
}
|
|
3765
3799
|
removeHeatMap() {
|
|
3766
|
-
|
|
3767
|
-
(_a = this.context.currentFloor) == null ? void 0 : _a.removeHeatMap();
|
|
3800
|
+
this.context.currentFloor?.removeHeatMap();
|
|
3768
3801
|
}
|
|
3769
3802
|
/**
|
|
3770
3803
|
* 移动相机位置让选中的元素居中显示
|
|
@@ -3780,28 +3813,26 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3780
3813
|
* @param ele { Graphic | Poi }
|
|
3781
3814
|
* @param duration
|
|
3782
3815
|
*/
|
|
3783
|
-
translateElementToCenterX(ele, duration = 500) {
|
|
3784
|
-
return
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
}), duration + 500);
|
|
3804
|
-
});
|
|
3816
|
+
async translateElementToCenterX(ele, duration = 500) {
|
|
3817
|
+
return timeoutPromise(new Promise((resolve) => {
|
|
3818
|
+
const target = this.context.control.target.clone();
|
|
3819
|
+
const position = ele.getPosition();
|
|
3820
|
+
this.timer.requestAnimationFrame(() => {
|
|
3821
|
+
const {
|
|
3822
|
+
clientSize: { width, height },
|
|
3823
|
+
camera
|
|
3824
|
+
} = this.context;
|
|
3825
|
+
console.log("width", width, height);
|
|
3826
|
+
const device = vector3ToDevice(position, camera, width, height);
|
|
3827
|
+
const offsetX = device.x - width / 2;
|
|
3828
|
+
const v3 = new Vector314();
|
|
3829
|
+
v3.setFromMatrixColumn(this.context.camera.matrix, 0);
|
|
3830
|
+
v3.normalize();
|
|
3831
|
+
v3.multiplyScalar(offsetX / this.context.camera.zoom);
|
|
3832
|
+
target.add(v3);
|
|
3833
|
+
this.context.setCameraPosition(target, duration).then(resolve);
|
|
3834
|
+
});
|
|
3835
|
+
}), duration + 500);
|
|
3805
3836
|
}
|
|
3806
3837
|
/**
|
|
3807
3838
|
* 获取物体的屏幕坐标
|
|
@@ -3829,20 +3860,18 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3829
3860
|
return this.context.setPolarAngle(1.1 /* D3 */, duration);
|
|
3830
3861
|
}
|
|
3831
3862
|
}
|
|
3832
|
-
resetView(duration = 300) {
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
);
|
|
3845
|
-
});
|
|
3863
|
+
async resetView(duration = 300) {
|
|
3864
|
+
const time = duration / 3;
|
|
3865
|
+
await this.context.setAzimuthalAngle(
|
|
3866
|
+
this.config.control.defaultAzimuthal,
|
|
3867
|
+
time
|
|
3868
|
+
);
|
|
3869
|
+
await this.changeMapType(this.type, time);
|
|
3870
|
+
await this.context.fitCameraToGround(
|
|
3871
|
+
this.config.defaultPadding,
|
|
3872
|
+
time,
|
|
3873
|
+
false
|
|
3874
|
+
);
|
|
3846
3875
|
}
|
|
3847
3876
|
/**
|
|
3848
3877
|
* 缩小地图
|
|
@@ -3872,6 +3901,28 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3872
3901
|
duration
|
|
3873
3902
|
);
|
|
3874
3903
|
}
|
|
3904
|
+
onKeydown = (e) => {
|
|
3905
|
+
if (this.polarKeys.includes(e.code)) {
|
|
3906
|
+
this.context.control.maxPolarAngle = this.config.control.maxPolar;
|
|
3907
|
+
this.context.control.minPolarAngle = 0;
|
|
3908
|
+
}
|
|
3909
|
+
if (this.azimuthalKeys.includes(e.code)) {
|
|
3910
|
+
this.context.control.maxAzimuthAngle = Infinity;
|
|
3911
|
+
this.context.control.minAzimuthAngle = Infinity;
|
|
3912
|
+
}
|
|
3913
|
+
};
|
|
3914
|
+
onKeyUp = (e) => {
|
|
3915
|
+
if (this.polarKeys.includes(e.code)) {
|
|
3916
|
+
const polar = this.context.control.getPolarAngle();
|
|
3917
|
+
this.context.control.maxPolarAngle = polar;
|
|
3918
|
+
this.context.control.minPolarAngle = polar;
|
|
3919
|
+
}
|
|
3920
|
+
if (this.azimuthalKeys.includes(e.code)) {
|
|
3921
|
+
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
3922
|
+
this.context.control.maxAzimuthAngle = azimuthal;
|
|
3923
|
+
this.context.control.minAzimuthAngle = azimuthal;
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3875
3926
|
registryEvent() {
|
|
3876
3927
|
window.addEventListener("keydown", this.onKeydown);
|
|
3877
3928
|
window.addEventListener("keyup", this.onKeyUp);
|
|
@@ -3882,10 +3933,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3882
3933
|
}
|
|
3883
3934
|
}
|
|
3884
3935
|
unRegistryEvent() {
|
|
3885
|
-
var _a;
|
|
3886
3936
|
window.removeEventListener("keydown", this.onKeydown);
|
|
3887
3937
|
window.removeEventListener("keyup", this.onKeyUp);
|
|
3888
|
-
|
|
3938
|
+
this.observe?.disconnect();
|
|
3889
3939
|
this.observe = null;
|
|
3890
3940
|
}
|
|
3891
3941
|
/**
|
|
@@ -3908,21 +3958,19 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3908
3958
|
* 测量距离
|
|
3909
3959
|
* @returns
|
|
3910
3960
|
*/
|
|
3911
|
-
measureDistance() {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
resolve(distance);
|
|
3925
|
-
});
|
|
3961
|
+
async measureDistance() {
|
|
3962
|
+
this.cancelDistance();
|
|
3963
|
+
return new Promise((resolve, reject) => {
|
|
3964
|
+
this.changeMapType("2d", 0);
|
|
3965
|
+
this.context.control.enableRotate = false;
|
|
3966
|
+
this.svgLine = new SvgLine(this.context);
|
|
3967
|
+
const dispose2 = this.svgLine.dispose.bind(this.svgLine);
|
|
3968
|
+
this.svgLine.dispose = function() {
|
|
3969
|
+
dispose2();
|
|
3970
|
+
reject("cancel");
|
|
3971
|
+
};
|
|
3972
|
+
this.svgLine.addEventListener("distance", ({ distance }) => {
|
|
3973
|
+
resolve(distance);
|
|
3926
3974
|
});
|
|
3927
3975
|
});
|
|
3928
3976
|
}
|
|
@@ -3969,15 +4017,12 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3969
4017
|
* 根据nodeId 获取graphic
|
|
3970
4018
|
*/
|
|
3971
4019
|
getGraphicByNodeId(nodeId) {
|
|
3972
|
-
|
|
3973
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.getGraphicByNodeId(nodeId)) || null;
|
|
4020
|
+
return this.context.currentFloor?.graphicLayer.getGraphicByNodeId(nodeId) || null;
|
|
3974
4021
|
}
|
|
3975
4022
|
deleteGraphic(graphic) {
|
|
3976
|
-
|
|
3977
|
-
(_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.removeGraphic(graphic);
|
|
4023
|
+
this.context.currentFloor?.graphicLayer.removeGraphic(graphic);
|
|
3978
4024
|
}
|
|
3979
4025
|
createGraphicByOptions(options) {
|
|
3980
|
-
var _a;
|
|
3981
4026
|
if (!options.transformToBuildingGround) {
|
|
3982
4027
|
if (this.currentBuildGround) {
|
|
3983
4028
|
const center2 = getCenter(
|
|
@@ -4001,19 +4046,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4001
4046
|
}
|
|
4002
4047
|
}
|
|
4003
4048
|
}
|
|
4004
|
-
return
|
|
4049
|
+
return this.context.currentFloor?.graphicLayer.createGraphic(options);
|
|
4005
4050
|
}
|
|
4006
4051
|
removePoiById(id) {
|
|
4007
|
-
|
|
4008
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.removePoiById(id);
|
|
4052
|
+
return this.context.currentFloor?.poiLayer.removePoiById(id);
|
|
4009
4053
|
}
|
|
4010
4054
|
getPoiById(id) {
|
|
4011
|
-
|
|
4012
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.getPoiById(id);
|
|
4055
|
+
return this.context.currentFloor?.poiLayer.getPoiById(id);
|
|
4013
4056
|
}
|
|
4014
4057
|
getPois() {
|
|
4015
|
-
|
|
4016
|
-
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter(
|
|
4058
|
+
return (this.context.currentFloor?.poiLayer.pois || []).filter(
|
|
4017
4059
|
(item) => !item.options.built_in
|
|
4018
4060
|
);
|
|
4019
4061
|
}
|
|
@@ -4025,8 +4067,27 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4025
4067
|
removeSelectGraphic(graphic) {
|
|
4026
4068
|
this.context.selection.remove(graphic);
|
|
4027
4069
|
}
|
|
4070
|
+
resize = () => {
|
|
4071
|
+
this.context.cameraBound.setEnable(false);
|
|
4072
|
+
this.context.onWindowResize();
|
|
4073
|
+
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
4074
|
+
const zoom = this.context.camera.zoom;
|
|
4075
|
+
this.context.control.minZoom = 0;
|
|
4076
|
+
this.context.control.maxZoom = Infinity;
|
|
4077
|
+
this.context.camera.zoom = 1;
|
|
4078
|
+
this.context.setAzimuthalAngle(0, 0);
|
|
4079
|
+
const basicZoom = this.context.getFitCameraToGroundZoom(void 0, 0);
|
|
4080
|
+
this.basicZoom = basicZoom || 0;
|
|
4081
|
+
this.context.control.minZoom = this.basicZoom;
|
|
4082
|
+
this.context.control.maxZoom = this.basicZoom * 25;
|
|
4083
|
+
this.context.camera.zoom = zoom;
|
|
4084
|
+
this.context.control.addEventListener("change", this.onControlChange);
|
|
4085
|
+
this.context.setAzimuthalAngle(azimuthal, 0);
|
|
4086
|
+
this.context.cameraBound.setEnable(true);
|
|
4087
|
+
};
|
|
4028
4088
|
dispose() {
|
|
4029
4089
|
this.timer.dispose();
|
|
4090
|
+
this.plugins.forEach((plugin) => plugin.dispose());
|
|
4030
4091
|
this.context.dispose();
|
|
4031
4092
|
this.floorDataMap.clear();
|
|
4032
4093
|
this.buildingGroundMap.clear();
|
|
@@ -4036,24 +4097,157 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4036
4097
|
this.unRegistryEvent();
|
|
4037
4098
|
}
|
|
4038
4099
|
};
|
|
4100
|
+
|
|
4101
|
+
// src/plugins/navigation/path.worker.ts
|
|
4102
|
+
var workerCode = `
|
|
4103
|
+
self.onmessage = (e) => {
|
|
4104
|
+
console.log(e.data)
|
|
4105
|
+
loadRoad("");
|
|
4106
|
+
getPath("", "")
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
function loadRoad(project) {
|
|
4110
|
+
// \u8BF7\u6C42\u5168\u90E8\u697C\u5C42\u7684\u8DEF\u7F51
|
|
4111
|
+
console.log(project)
|
|
4112
|
+
self.postMessage("project")
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
function getPath(start, end) {
|
|
4116
|
+
// \u89C4\u5212\u8DEF\u7EBF
|
|
4117
|
+
console.log(start, end)
|
|
4118
|
+
self.postMessage("getPath")
|
|
4119
|
+
}
|
|
4120
|
+
`;
|
|
4121
|
+
var path_worker_default = workerCode;
|
|
4122
|
+
|
|
4123
|
+
// src/plugins/navigation/navigation.ts
|
|
4124
|
+
var Navigation = class extends Plugin {
|
|
4125
|
+
worker_url = window.URL.createObjectURL(new Blob([path_worker_default], { type: "text/javascript" }));
|
|
4126
|
+
worker = new Worker(this.worker_url);
|
|
4127
|
+
constructor(bmap) {
|
|
4128
|
+
super(bmap);
|
|
4129
|
+
console.log(this.worker);
|
|
4130
|
+
this.worker.postMessage("initial");
|
|
4131
|
+
this.worker.onmessage = (e) => {
|
|
4132
|
+
console.log("onmessage", e.data);
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
fetchRoad() {
|
|
4136
|
+
}
|
|
4137
|
+
dispose() {
|
|
4138
|
+
this.worker.terminate();
|
|
4139
|
+
window.URL.revokeObjectURL(this.worker_url);
|
|
4140
|
+
}
|
|
4141
|
+
};
|
|
4142
|
+
|
|
4143
|
+
// src/plugins/split-load/split-load.ts
|
|
4144
|
+
var SplitLoad = class extends Plugin {
|
|
4145
|
+
cacheData = /* @__PURE__ */ new Map();
|
|
4146
|
+
async load(query) {
|
|
4147
|
+
const cacheKey = generatorKeyByObj(query);
|
|
4148
|
+
if (this.cacheData.has(cacheKey)) {
|
|
4149
|
+
return this.cacheData.get(cacheKey);
|
|
4150
|
+
}
|
|
4151
|
+
console.time("floor/get\u8BF7\u6C42" + query.resource_type_list);
|
|
4152
|
+
const data = await loadGraphics(query, this.bmap.config);
|
|
4153
|
+
console.timeEnd("floor/get\u8BF7\u6C42" + query.resource_type_list);
|
|
4154
|
+
this.bmap.transformGraphicData(data, [0, 0]);
|
|
4155
|
+
data.forEach((item) => item.info.transformToBuildingGround = false);
|
|
4156
|
+
this.cacheData.set(cacheKey, data);
|
|
4157
|
+
return data;
|
|
4158
|
+
}
|
|
4159
|
+
isSameFloor(query) {
|
|
4160
|
+
return this.bmap.context.currentFloor?.name === generatorKeyByObj(query);
|
|
4161
|
+
}
|
|
4162
|
+
switchFloorByData(data, query) {
|
|
4163
|
+
if (!this.isSameFloor(query)) {
|
|
4164
|
+
const floorName = generatorKeyByObj(query);
|
|
4165
|
+
const { curFloor, graphics } = this.bmap.createFloor(data);
|
|
4166
|
+
curFloor.name = floorName;
|
|
4167
|
+
const graphicMap = /* @__PURE__ */ new Map();
|
|
4168
|
+
data.forEach((graphicInfo) => {
|
|
4169
|
+
graphicMap.set(graphicInfo.element_uuid, graphicInfo);
|
|
4170
|
+
});
|
|
4171
|
+
curFloor.userData.graphicMap = graphicMap;
|
|
4172
|
+
this.bmap.triggerHooks("switch_floor_before" /* SWITCH_FLOOR_BEFORE */, { curFloor, graphics });
|
|
4173
|
+
this.bmap.context.switchFloor(curFloor);
|
|
4174
|
+
this.bmap.initialFloorCamera();
|
|
4175
|
+
this.bmap.triggerHooks("switch_floor_after" /* SWITCH_FLOOR_AFTER */, { curFloor, graphics });
|
|
4176
|
+
} else {
|
|
4177
|
+
if (!data.length) {
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
const curFloor = this.bmap.context.currentFloor;
|
|
4181
|
+
const legacyToGraphicMap = curFloor.userData.legacyToGraphicMap;
|
|
4182
|
+
const graphicMap = curFloor.userData.graphicMap;
|
|
4183
|
+
const graphics = [];
|
|
4184
|
+
for (const item of data) {
|
|
4185
|
+
if (item.info.group === "ground") {
|
|
4186
|
+
curFloor.createGround(item.info);
|
|
4187
|
+
} else {
|
|
4188
|
+
const graphic = curFloor.addGraphic(item.info);
|
|
4189
|
+
graphic.userData.data = item;
|
|
4190
|
+
legacyToGraphicMap.set(item.legacy_id, graphic);
|
|
4191
|
+
graphics.push(graphic);
|
|
4192
|
+
}
|
|
4193
|
+
graphicMap.set(item.element_uuid, item);
|
|
4194
|
+
}
|
|
4195
|
+
this.bmap.triggerHooks("switch_floor_before" /* SWITCH_FLOOR_BEFORE */, { curFloor, graphics });
|
|
4196
|
+
this.bmap.initialFloorCamera();
|
|
4197
|
+
this.bmap.triggerHooks("switch_floor_after" /* SWITCH_FLOOR_AFTER */, { curFloor, graphics });
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
filterData(data, query) {
|
|
4201
|
+
if (!this.isSameFloor(query)) {
|
|
4202
|
+
return data;
|
|
4203
|
+
}
|
|
4204
|
+
const graphicMap = this.bmap.context.currentFloor.userData.graphicMap;
|
|
4205
|
+
return data.filter((graphic) => !graphicMap.has(graphic.element_uuid));
|
|
4206
|
+
}
|
|
4207
|
+
async switchFloorByStoreData(query) {
|
|
4208
|
+
const storeData = await this.load({ ...query, resource_type_list: "6" });
|
|
4209
|
+
const filterData = this.filterData(storeData, query);
|
|
4210
|
+
this.switchFloorByData(filterData, query);
|
|
4211
|
+
}
|
|
4212
|
+
async switchFloorByOtherData(query) {
|
|
4213
|
+
const otherData = await this.load({
|
|
4214
|
+
...query,
|
|
4215
|
+
resource_type_list: "1,2,3,4"
|
|
4216
|
+
});
|
|
4217
|
+
const filterData = this.filterData(otherData, query);
|
|
4218
|
+
this.switchFloorByData(filterData, query);
|
|
4219
|
+
}
|
|
4220
|
+
async changeFloor(query) {
|
|
4221
|
+
await Promise.all([
|
|
4222
|
+
this.switchFloorByStoreData(query),
|
|
4223
|
+
this.switchFloorByOtherData(query)
|
|
4224
|
+
]);
|
|
4225
|
+
return Array.from(this.bmap.context.currentFloor.userData.graphicMap.values());
|
|
4226
|
+
}
|
|
4227
|
+
};
|
|
4039
4228
|
export {
|
|
4040
4229
|
BMap,
|
|
4041
4230
|
BaseSvg,
|
|
4042
4231
|
Context,
|
|
4232
|
+
Equipment,
|
|
4233
|
+
Events,
|
|
4043
4234
|
Floor,
|
|
4044
4235
|
Graphic,
|
|
4045
4236
|
GraphicLayer,
|
|
4046
4237
|
HeatmapElement,
|
|
4238
|
+
HooksName,
|
|
4047
4239
|
HoverHelper,
|
|
4048
4240
|
Layer,
|
|
4049
4241
|
MapTypePolar,
|
|
4050
4242
|
Model,
|
|
4243
|
+
Navigation,
|
|
4051
4244
|
Overlay,
|
|
4052
4245
|
Poi,
|
|
4053
4246
|
PoiLayer,
|
|
4054
4247
|
SelectBox,
|
|
4055
4248
|
Selection,
|
|
4056
4249
|
Shadow,
|
|
4250
|
+
SplitLoad,
|
|
4057
4251
|
SvgLine,
|
|
4058
4252
|
SvgPolygon,
|
|
4059
4253
|
Timer,
|
|
@@ -4070,6 +4264,7 @@ export {
|
|
|
4070
4264
|
defaultConfig,
|
|
4071
4265
|
dispose,
|
|
4072
4266
|
disposeLoader,
|
|
4267
|
+
generatorKeyByObj,
|
|
4073
4268
|
getCenter,
|
|
4074
4269
|
getConfig,
|
|
4075
4270
|
getLongestSideDir,
|
|
@@ -4086,6 +4281,8 @@ export {
|
|
|
4086
4281
|
isContain,
|
|
4087
4282
|
isControl,
|
|
4088
4283
|
isMac,
|
|
4284
|
+
loadBuildingGround,
|
|
4285
|
+
loadGraphics,
|
|
4089
4286
|
loadModel,
|
|
4090
4287
|
proxyOptions,
|
|
4091
4288
|
setCirclePosition,
|