@aibee/crc-bmap 0.0.93 → 0.0.94
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 +24 -5
- 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 +970 -857
- 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/bmap.d.ts +7 -1
- package/lib/src/config.d.ts +1 -0
- package/lib/src/index.d.ts +1 -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 +2 -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/utils/event-name.d.ts +4 -0
- package/lib/src/utils/events.d.ts +17 -0
- package/lib/src/utils/index.d.ts +2 -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,76 @@ 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 EventName = /* @__PURE__ */ ((EventName2) => {
|
|
496
|
+
EventName2["SWITCH_FLOOR_BEFORE"] = "switch_floor_before";
|
|
497
|
+
EventName2["SWITCH_FLOOR_AFTER"] = "switch_floor_after";
|
|
498
|
+
return EventName2;
|
|
499
|
+
})(EventName || {});
|
|
500
|
+
|
|
479
501
|
// src/context.ts
|
|
480
502
|
import {
|
|
481
503
|
EventDispatcher as EventDispatcher6,
|
|
@@ -548,15 +570,8 @@ var Graphic = class extends Object3D {
|
|
|
548
570
|
constructor(context, options) {
|
|
549
571
|
super();
|
|
550
572
|
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
573
|
this.options = proxyOptions(
|
|
559
|
-
|
|
574
|
+
{ ...defaultOptions, ...options },
|
|
560
575
|
this
|
|
561
576
|
);
|
|
562
577
|
if (this.options.geometry.type === "point") {
|
|
@@ -599,7 +614,6 @@ var Graphic = class extends Object3D {
|
|
|
599
614
|
this.visible = value;
|
|
600
615
|
});
|
|
601
616
|
this.addEventListener("change-stroke", ({ value }) => {
|
|
602
|
-
var _a;
|
|
603
617
|
if (value) {
|
|
604
618
|
if (this.line) {
|
|
605
619
|
return;
|
|
@@ -609,7 +623,7 @@ var Graphic = class extends Object3D {
|
|
|
609
623
|
this.createBorder();
|
|
610
624
|
} else if (this.line) {
|
|
611
625
|
this.remove(this.line);
|
|
612
|
-
|
|
626
|
+
this.lineGeometry?.dispose();
|
|
613
627
|
}
|
|
614
628
|
});
|
|
615
629
|
this.addEventListener("change-renderType", () => {
|
|
@@ -621,6 +635,13 @@ var Graphic = class extends Object3D {
|
|
|
621
635
|
this.initMesh();
|
|
622
636
|
});
|
|
623
637
|
}
|
|
638
|
+
geometry;
|
|
639
|
+
material;
|
|
640
|
+
mesh;
|
|
641
|
+
line;
|
|
642
|
+
lineMaterial;
|
|
643
|
+
lineGeometry;
|
|
644
|
+
options;
|
|
624
645
|
getCenter() {
|
|
625
646
|
if (this.options.geometry.type === "point") {
|
|
626
647
|
return this.position.clone();
|
|
@@ -821,9 +842,8 @@ var Graphic = class extends Object3D {
|
|
|
821
842
|
return false;
|
|
822
843
|
}
|
|
823
844
|
dispose() {
|
|
824
|
-
var _a;
|
|
825
845
|
this.geometry.dispose();
|
|
826
|
-
|
|
846
|
+
this.line?.geometry.dispose();
|
|
827
847
|
this.clear();
|
|
828
848
|
}
|
|
829
849
|
};
|
|
@@ -838,11 +858,11 @@ import {
|
|
|
838
858
|
DoubleSide as DoubleSide2
|
|
839
859
|
} from "three";
|
|
840
860
|
var Shadow = class extends Object3D2 {
|
|
861
|
+
directionalLight;
|
|
862
|
+
plane;
|
|
863
|
+
basicOpacity = 0.07;
|
|
841
864
|
constructor() {
|
|
842
865
|
super();
|
|
843
|
-
__publicField(this, "directionalLight");
|
|
844
|
-
__publicField(this, "plane");
|
|
845
|
-
__publicField(this, "basicOpacity", 0.07);
|
|
846
866
|
this.directionalLight = this.initLight();
|
|
847
867
|
this.initPlane();
|
|
848
868
|
}
|
|
@@ -914,22 +934,7 @@ var Overlay = class extends EventDispatcher {
|
|
|
914
934
|
constructor(context, options = {}) {
|
|
915
935
|
super();
|
|
916
936
|
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);
|
|
937
|
+
this.options = { ...defaultOptions2, ...options };
|
|
933
938
|
this.registryEvent();
|
|
934
939
|
this.div = this.initDiv();
|
|
935
940
|
if (this.options.appendToBody) {
|
|
@@ -938,6 +943,14 @@ var Overlay = class extends EventDispatcher {
|
|
|
938
943
|
this.context.container.appendChild(this.div);
|
|
939
944
|
}
|
|
940
945
|
}
|
|
946
|
+
div;
|
|
947
|
+
element;
|
|
948
|
+
position = new Vector34();
|
|
949
|
+
clientPos = { x: 0, y: 0 };
|
|
950
|
+
visible = true;
|
|
951
|
+
options;
|
|
952
|
+
placement = "top";
|
|
953
|
+
observer = null;
|
|
941
954
|
initObserver() {
|
|
942
955
|
const observer = new MutationObserver(
|
|
943
956
|
debounce(() => {
|
|
@@ -1168,6 +1181,13 @@ var Overlay = class extends EventDispatcher {
|
|
|
1168
1181
|
}
|
|
1169
1182
|
this._updatePosition(x, y);
|
|
1170
1183
|
}
|
|
1184
|
+
onUpdate = () => {
|
|
1185
|
+
if (this.options.autoChangePlacement) {
|
|
1186
|
+
this.usePlacement();
|
|
1187
|
+
} else {
|
|
1188
|
+
this.updatePosition();
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1171
1191
|
registryEvent() {
|
|
1172
1192
|
this.context.addEventListener("update", this.onUpdate);
|
|
1173
1193
|
}
|
|
@@ -1175,11 +1195,10 @@ var Overlay = class extends EventDispatcher {
|
|
|
1175
1195
|
this.context.removeEventListener("update", this.onUpdate);
|
|
1176
1196
|
}
|
|
1177
1197
|
dispose() {
|
|
1178
|
-
var _a, _b;
|
|
1179
1198
|
this.unRegistryEvent();
|
|
1180
1199
|
this.unBindElement();
|
|
1181
|
-
|
|
1182
|
-
|
|
1200
|
+
this.observer?.disconnect();
|
|
1201
|
+
this.div?.remove();
|
|
1183
1202
|
this.div = null;
|
|
1184
1203
|
}
|
|
1185
1204
|
};
|
|
@@ -1202,24 +1221,10 @@ var defaultOptions3 = {
|
|
|
1202
1221
|
};
|
|
1203
1222
|
var Poi = class extends EventDispatcher2 {
|
|
1204
1223
|
constructor(context, options) {
|
|
1205
|
-
var _a, _b, _c;
|
|
1206
1224
|
super();
|
|
1207
1225
|
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);
|
|
1226
|
+
this.options = proxyOptions({ ...defaultOptions3, ...options }, this);
|
|
1227
|
+
this.position.set(options.position?.x || 0, options.position?.y || 0, options.position?.z || 0);
|
|
1223
1228
|
this.overlay = new Overlay(this.context, { autoUpdate: false });
|
|
1224
1229
|
this.overlay.addEventListener("update-position", ({ x, y, height }) => {
|
|
1225
1230
|
this.overlay.div.style.transform = `translate3d(calc(${x}px - 50%), calc(${-height + y}px - ${this.options.icon ? "100%" : "50%"}), 0)`;
|
|
@@ -1252,8 +1257,8 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1252
1257
|
});
|
|
1253
1258
|
this.addEventListener("change-icon_size", ({ value }) => {
|
|
1254
1259
|
if (this.img) {
|
|
1255
|
-
this.img.style.width = `${
|
|
1256
|
-
this.img.style.height = `${
|
|
1260
|
+
this.img.style.width = `${value?.[0] || 32}px`;
|
|
1261
|
+
this.img.style.height = `${value?.[1] || 32}px`;
|
|
1257
1262
|
this.resetSize();
|
|
1258
1263
|
}
|
|
1259
1264
|
});
|
|
@@ -1271,29 +1276,37 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1271
1276
|
this.div.style.background = value;
|
|
1272
1277
|
});
|
|
1273
1278
|
}
|
|
1279
|
+
div;
|
|
1280
|
+
textDiv;
|
|
1281
|
+
img;
|
|
1282
|
+
overlay;
|
|
1283
|
+
options;
|
|
1284
|
+
visible = true;
|
|
1285
|
+
size = { width: 0, height: 0 };
|
|
1286
|
+
position = new Vector35();
|
|
1287
|
+
userData = {};
|
|
1288
|
+
showTextStatus = true;
|
|
1274
1289
|
get withinDisplayRange() {
|
|
1275
1290
|
return this.overlay.withinDisplayRange;
|
|
1276
1291
|
}
|
|
1277
|
-
resetSize() {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
if (this.
|
|
1281
|
-
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
const { width, height } = this.img.getBoundingClientRect();
|
|
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
|
-
};
|
|
1292
|
+
async resetSize() {
|
|
1293
|
+
await sleepOnePromise();
|
|
1294
|
+
if (this.options.box_only_icon) {
|
|
1295
|
+
if (!this.img) {
|
|
1296
|
+
return;
|
|
1295
1297
|
}
|
|
1296
|
-
|
|
1298
|
+
const { width, height } = this.img.getBoundingClientRect();
|
|
1299
|
+
this.size = {
|
|
1300
|
+
width: width + 2,
|
|
1301
|
+
height: height + 2
|
|
1302
|
+
};
|
|
1303
|
+
} else {
|
|
1304
|
+
const { width, height } = this.div.getBoundingClientRect();
|
|
1305
|
+
this.size = {
|
|
1306
|
+
width: width + 2,
|
|
1307
|
+
height: height + 2
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1297
1310
|
}
|
|
1298
1311
|
renderHelperBox() {
|
|
1299
1312
|
}
|
|
@@ -1373,11 +1386,10 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1373
1386
|
return f;
|
|
1374
1387
|
}
|
|
1375
1388
|
initIcon() {
|
|
1376
|
-
var _a, _b;
|
|
1377
1389
|
const img = document.createElement("img");
|
|
1378
1390
|
img.setAttribute("src", this.options.icon);
|
|
1379
|
-
img.style.width = `${
|
|
1380
|
-
img.style.height = `${
|
|
1391
|
+
img.style.width = `${this.options.icon_size?.[0] || 32}px`;
|
|
1392
|
+
img.style.height = `${this.options.icon_size?.[1] || 32}px`;
|
|
1381
1393
|
img.style.opacity = `${this.options.icon_opacity}px`;
|
|
1382
1394
|
img.style.borderRadius = "50%";
|
|
1383
1395
|
if (this.options.icon_border.width) {
|
|
@@ -1389,6 +1401,9 @@ var Poi = class extends EventDispatcher2 {
|
|
|
1389
1401
|
this.img = img;
|
|
1390
1402
|
return img;
|
|
1391
1403
|
}
|
|
1404
|
+
_changePosition = () => {
|
|
1405
|
+
this.overlay.updatePosition(true);
|
|
1406
|
+
};
|
|
1392
1407
|
registryEvent() {
|
|
1393
1408
|
}
|
|
1394
1409
|
unRegistryEvent() {
|
|
@@ -1476,9 +1491,9 @@ var Layer = class extends Object3D5 {
|
|
|
1476
1491
|
|
|
1477
1492
|
// src/layer/graphic-layer.ts
|
|
1478
1493
|
var GraphicLayer = class extends Layer {
|
|
1494
|
+
graphicMap = /* @__PURE__ */ new Map();
|
|
1479
1495
|
constructor(context) {
|
|
1480
1496
|
super(context);
|
|
1481
|
-
__publicField(this, "graphicMap", /* @__PURE__ */ new Map());
|
|
1482
1497
|
}
|
|
1483
1498
|
getCenter() {
|
|
1484
1499
|
const box = new Box33().setFromObject(this);
|
|
@@ -1537,16 +1552,11 @@ var GraphicLayer = class extends Layer {
|
|
|
1537
1552
|
// src/layer/poi-layer.ts
|
|
1538
1553
|
import { debounce as debounce2 } from "lodash";
|
|
1539
1554
|
var PoiLayer = class extends Layer {
|
|
1555
|
+
pois = [];
|
|
1556
|
+
debounceCollisionDetection;
|
|
1557
|
+
timer = new Timer();
|
|
1540
1558
|
constructor(context) {
|
|
1541
1559
|
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
1560
|
this.registryEvent();
|
|
1551
1561
|
this.debounceCollisionDetection = debounce2(this.collisionDetection, 10);
|
|
1552
1562
|
}
|
|
@@ -1627,6 +1637,11 @@ var PoiLayer = class extends Layer {
|
|
|
1627
1637
|
});
|
|
1628
1638
|
return pois;
|
|
1629
1639
|
}
|
|
1640
|
+
onUpdate = () => {
|
|
1641
|
+
this.timer.requestAnimationFrame(() => {
|
|
1642
|
+
this.collisionDetection();
|
|
1643
|
+
});
|
|
1644
|
+
};
|
|
1630
1645
|
/**
|
|
1631
1646
|
* 碰撞检测
|
|
1632
1647
|
*/
|
|
@@ -1683,11 +1698,11 @@ var HeatmapElement = class extends Object3D6 {
|
|
|
1683
1698
|
constructor(context) {
|
|
1684
1699
|
super();
|
|
1685
1700
|
this.context = context;
|
|
1686
|
-
__publicField(this, "heatmap");
|
|
1687
|
-
__publicField(this, "div");
|
|
1688
|
-
__publicField(this, "plane");
|
|
1689
1701
|
this.div = document.createElement("div");
|
|
1690
1702
|
}
|
|
1703
|
+
heatmap;
|
|
1704
|
+
div;
|
|
1705
|
+
plane;
|
|
1691
1706
|
clearHeatmap() {
|
|
1692
1707
|
if (this.div.firstChild) {
|
|
1693
1708
|
this.div.removeChild(this.div.firstChild);
|
|
@@ -1697,11 +1712,12 @@ var HeatmapElement = class extends Object3D6 {
|
|
|
1697
1712
|
loadData(data) {
|
|
1698
1713
|
this.clearHeatmap();
|
|
1699
1714
|
const { width, height, leftTop, center: center2 } = this.getBox(data);
|
|
1700
|
-
this.heatmap = create(
|
|
1715
|
+
this.heatmap = create({
|
|
1701
1716
|
width,
|
|
1702
1717
|
height,
|
|
1703
|
-
container: this.div
|
|
1704
|
-
|
|
1718
|
+
container: this.div,
|
|
1719
|
+
...this.context.config.heatMap
|
|
1720
|
+
});
|
|
1705
1721
|
this.heatmap.setData(this.transformData(data, leftTop));
|
|
1706
1722
|
this.initPlane(width, height);
|
|
1707
1723
|
this.position.set(center2[0], center2[1], this.position.z);
|
|
@@ -1769,26 +1785,23 @@ var Model = class extends Object3D7 {
|
|
|
1769
1785
|
super();
|
|
1770
1786
|
this.context = context;
|
|
1771
1787
|
this.options = options;
|
|
1772
|
-
__publicField(this, "poi", null);
|
|
1773
|
-
__publicField(this, "model", null);
|
|
1774
1788
|
this.position.copy(options.position || new Vector37(0, 0, 0));
|
|
1775
1789
|
this.loadModel();
|
|
1776
1790
|
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1791
|
+
poi = null;
|
|
1792
|
+
model = null;
|
|
1793
|
+
async loadModel() {
|
|
1794
|
+
const object = await loadModel(this.options.modelUrl);
|
|
1795
|
+
object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
|
|
1796
|
+
this.add(object.scene);
|
|
1797
|
+
this.model = object;
|
|
1798
|
+
this.initPoi();
|
|
1785
1799
|
}
|
|
1786
1800
|
initPoi() {
|
|
1787
|
-
var _a;
|
|
1788
1801
|
if (!this.options.icon) {
|
|
1789
1802
|
return;
|
|
1790
1803
|
}
|
|
1791
|
-
const poi =
|
|
1804
|
+
const poi = this.context.currentFloor?.addPoi({
|
|
1792
1805
|
icon: this.options.icon,
|
|
1793
1806
|
icon_size: this.options.icon_size,
|
|
1794
1807
|
built_in: true,
|
|
@@ -1800,11 +1813,10 @@ var Model = class extends Object3D7 {
|
|
|
1800
1813
|
}
|
|
1801
1814
|
}
|
|
1802
1815
|
dispose() {
|
|
1803
|
-
var _a;
|
|
1804
1816
|
dispose(this);
|
|
1805
1817
|
this.model = null;
|
|
1806
1818
|
if (this.poi) {
|
|
1807
|
-
|
|
1819
|
+
this.context.currentFloor?.poiLayer.removePoi(this.poi);
|
|
1808
1820
|
this.poi = null;
|
|
1809
1821
|
}
|
|
1810
1822
|
}
|
|
@@ -1815,15 +1827,6 @@ var Floor = class extends Object3D8 {
|
|
|
1815
1827
|
constructor(context) {
|
|
1816
1828
|
super();
|
|
1817
1829
|
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
1830
|
this.graphicLayer = new GraphicLayer(this.context);
|
|
1828
1831
|
this.poiLayer = new PoiLayer(this.context);
|
|
1829
1832
|
this.groundUpper.add(this.graphicLayer);
|
|
@@ -1831,6 +1834,15 @@ var Floor = class extends Object3D8 {
|
|
|
1831
1834
|
this.add(this.groundUpper);
|
|
1832
1835
|
this.add(this.models);
|
|
1833
1836
|
}
|
|
1837
|
+
graphicLayer;
|
|
1838
|
+
poiLayer;
|
|
1839
|
+
grounds = /* @__PURE__ */ new Set();
|
|
1840
|
+
shadow = new Shadow();
|
|
1841
|
+
heatmap;
|
|
1842
|
+
groundUpper = new Object3D8();
|
|
1843
|
+
models = new Object3D8();
|
|
1844
|
+
modelMap = /* @__PURE__ */ new Map();
|
|
1845
|
+
groundMaxHeight = 0;
|
|
1834
1846
|
getPosition() {
|
|
1835
1847
|
const box = new Box35().setFromObject(this.groundUpper);
|
|
1836
1848
|
return box.getCenter(new Vector38());
|
|
@@ -1904,12 +1916,11 @@ var Floor = class extends Object3D8 {
|
|
|
1904
1916
|
this.shadow.visible = visible;
|
|
1905
1917
|
}
|
|
1906
1918
|
dispose() {
|
|
1907
|
-
var _a;
|
|
1908
1919
|
this.shadow.dispose();
|
|
1909
1920
|
this.graphicLayer.dispose();
|
|
1910
1921
|
this.poiLayer.dispose();
|
|
1911
1922
|
this.grounds.forEach((ground) => ground.dispose());
|
|
1912
|
-
|
|
1923
|
+
this.heatmap?.dispose();
|
|
1913
1924
|
this.groundUpper.clear();
|
|
1914
1925
|
this.models.children.forEach((model) => model.dispose());
|
|
1915
1926
|
this.models.clear();
|
|
@@ -1924,19 +1935,19 @@ var BaseSvg = class extends EventDispatcher3 {
|
|
|
1924
1935
|
constructor(context) {
|
|
1925
1936
|
super();
|
|
1926
1937
|
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
1938
|
this.svg = createSvg(`${context.container.clientWidth}`, `${context.container.clientHeight}`);
|
|
1937
1939
|
context.container.appendChild(this.svg);
|
|
1938
1940
|
this._registryEvent();
|
|
1939
1941
|
}
|
|
1942
|
+
points = [];
|
|
1943
|
+
svg;
|
|
1944
|
+
enable = true;
|
|
1945
|
+
_onResize = ({ width, height }) => {
|
|
1946
|
+
if (this.svg) {
|
|
1947
|
+
this.svg.setAttribute("width", `${width}`);
|
|
1948
|
+
this.svg.setAttribute("height", `${height}`);
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1940
1951
|
_registryEvent() {
|
|
1941
1952
|
this.context.addEventListener("resize", this._onResize);
|
|
1942
1953
|
}
|
|
@@ -1977,48 +1988,6 @@ var SvgLine = class extends BaseSvg {
|
|
|
1977
1988
|
constructor(context) {
|
|
1978
1989
|
super(context);
|
|
1979
1990
|
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
1991
|
const { config: { svg: { circle, line } } } = context;
|
|
2023
1992
|
this.circles = [createCircle(circle.radius, circle.fill), createCircle(circle.radius, circle.fill)];
|
|
2024
1993
|
this.line = createLine(line.stroke);
|
|
@@ -2027,6 +1996,8 @@ var SvgLine = class extends BaseSvg {
|
|
|
2027
1996
|
this.svg.appendChild(this.line);
|
|
2028
1997
|
this.registryEvent();
|
|
2029
1998
|
}
|
|
1999
|
+
circles;
|
|
2000
|
+
line;
|
|
2030
2001
|
setEnable(enable) {
|
|
2031
2002
|
super.setEnable(enable);
|
|
2032
2003
|
if (enable) {
|
|
@@ -2049,6 +2020,46 @@ var SvgLine = class extends BaseSvg {
|
|
|
2049
2020
|
this.context.container.removeEventListener("pointerdown", this.onPointerdown);
|
|
2050
2021
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2051
2022
|
}
|
|
2023
|
+
onUpdate = () => {
|
|
2024
|
+
if (this.points[0]) {
|
|
2025
|
+
const point1 = this.getSvgCoordinate(this.points[0]);
|
|
2026
|
+
setCirclePosition(this.circles[0], point1.x, point1.y);
|
|
2027
|
+
setLineStartEnd(this.line, point1);
|
|
2028
|
+
}
|
|
2029
|
+
if (this.points[1]) {
|
|
2030
|
+
const point22 = this.getSvgCoordinate(this.points[1]);
|
|
2031
|
+
setCirclePosition(this.circles[1], point22.x, point22.y);
|
|
2032
|
+
setLineStartEnd(this.line, void 0, point22);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
onPointermove = (e) => {
|
|
2036
|
+
if (this.points.length !== 1) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
this.line.style.display = "block";
|
|
2040
|
+
setLineStartEnd(this.line, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2041
|
+
};
|
|
2042
|
+
onPointerleave = () => {
|
|
2043
|
+
if (this.points[1]) {
|
|
2044
|
+
return;
|
|
2045
|
+
}
|
|
2046
|
+
this.line.style.display = "none";
|
|
2047
|
+
};
|
|
2048
|
+
onPointerdown = (e) => {
|
|
2049
|
+
if (this.points[1]) {
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2053
|
+
if (point3) {
|
|
2054
|
+
const { offsetX: x, offsetY: y } = e;
|
|
2055
|
+
const circle = this.circles[this.points.length];
|
|
2056
|
+
setCirclePosition(circle, x, y);
|
|
2057
|
+
if (!this.points.length) {
|
|
2058
|
+
setLineStartEnd(this.line, { x, y }, { x, y });
|
|
2059
|
+
}
|
|
2060
|
+
this.addPoint(point3);
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2052
2063
|
addPoint(vector) {
|
|
2053
2064
|
this.points.push(vector);
|
|
2054
2065
|
if (this.points.length >= 2) {
|
|
@@ -2061,7 +2072,7 @@ var SvgLine = class extends BaseSvg {
|
|
|
2061
2072
|
*/
|
|
2062
2073
|
calculatedDistance() {
|
|
2063
2074
|
const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = this.points;
|
|
2064
|
-
return Math.sqrt(
|
|
2075
|
+
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
|
2065
2076
|
}
|
|
2066
2077
|
dispose() {
|
|
2067
2078
|
super.dispose();
|
|
@@ -2073,69 +2084,11 @@ var SvgLine = class extends BaseSvg {
|
|
|
2073
2084
|
|
|
2074
2085
|
// src/elements/svg-polygon.ts
|
|
2075
2086
|
var SvgPolygon = class extends BaseSvg {
|
|
2087
|
+
circles = [];
|
|
2088
|
+
lines = [];
|
|
2089
|
+
isClose = false;
|
|
2076
2090
|
constructor(context) {
|
|
2077
2091
|
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
2092
|
this.registryEvent();
|
|
2140
2093
|
}
|
|
2141
2094
|
setEnable(enable) {
|
|
@@ -2171,6 +2124,64 @@ var SvgPolygon = class extends BaseSvg {
|
|
|
2171
2124
|
this.context.container.removeEventListener("pointerdown", this.onPointerdown);
|
|
2172
2125
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2173
2126
|
}
|
|
2127
|
+
onUpdate = () => {
|
|
2128
|
+
if (this.points.length) {
|
|
2129
|
+
this.points.forEach((point3, index) => {
|
|
2130
|
+
const devicePoint = this.getSvgCoordinate(point3);
|
|
2131
|
+
if (this.circles[index]) {
|
|
2132
|
+
setCirclePosition(this.circles[index], devicePoint.x, devicePoint.y);
|
|
2133
|
+
}
|
|
2134
|
+
if (index !== 0) {
|
|
2135
|
+
setLineStartEnd(this.lines[index - 1], void 0, devicePoint);
|
|
2136
|
+
}
|
|
2137
|
+
if (this.lines[index]) {
|
|
2138
|
+
setLineStartEnd(this.lines[index], devicePoint);
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
onPointermove = (e) => {
|
|
2144
|
+
if (!this.lastLine || this.isClose) {
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
this.lastLine.style.display = "block";
|
|
2148
|
+
setLineStartEnd(this.lastLine, void 0, { x: e.offsetX, y: e.offsetY });
|
|
2149
|
+
};
|
|
2150
|
+
onPointerleave = () => {
|
|
2151
|
+
if (this.isClose) {
|
|
2152
|
+
return;
|
|
2153
|
+
}
|
|
2154
|
+
this.lastLine.style.display = "none";
|
|
2155
|
+
};
|
|
2156
|
+
onPointerdown = (e) => {
|
|
2157
|
+
if (this.isClose) {
|
|
2158
|
+
return;
|
|
2159
|
+
}
|
|
2160
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2161
|
+
if (point3) {
|
|
2162
|
+
const { offsetX: x, offsetY: y } = e;
|
|
2163
|
+
if (this.checkAdsorb(x, y)) {
|
|
2164
|
+
this.isClose = true;
|
|
2165
|
+
this.addPoint(this.points[0]);
|
|
2166
|
+
} else {
|
|
2167
|
+
this.addPoint(point3);
|
|
2168
|
+
}
|
|
2169
|
+
const { circle: { fill, radius }, line: { stroke } } = this.context.config.svg;
|
|
2170
|
+
if (!this.isClose) {
|
|
2171
|
+
const circle = createCircle(radius, fill);
|
|
2172
|
+
setCirclePosition(circle, x, y);
|
|
2173
|
+
this.addCircle(circle);
|
|
2174
|
+
}
|
|
2175
|
+
if (this.lines.length) {
|
|
2176
|
+
setLineStartEnd(this.lastLine, void 0, { x, y });
|
|
2177
|
+
}
|
|
2178
|
+
if (!this.isClose) {
|
|
2179
|
+
const line = createLine(stroke);
|
|
2180
|
+
setLineStartEnd(line, { x, y }, { x, y });
|
|
2181
|
+
this.addLine(line);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2174
2185
|
/**
|
|
2175
2186
|
* 检测是否可以吸附
|
|
2176
2187
|
* 坐标点最少3个 传入的坐标点和第一个坐标的像素相差不超过5个像素
|
|
@@ -2182,7 +2193,7 @@ var SvgPolygon = class extends BaseSvg {
|
|
|
2182
2193
|
const circle = this.circles[0];
|
|
2183
2194
|
const cx = +circle.getAttribute("cx");
|
|
2184
2195
|
const cy = +circle.getAttribute("cy");
|
|
2185
|
-
return Math.sqrt(
|
|
2196
|
+
return Math.sqrt((x - cx) ** 2 + (y - cy) ** 2) <= 5;
|
|
2186
2197
|
}
|
|
2187
2198
|
addPoint(vector) {
|
|
2188
2199
|
this.points.push(vector);
|
|
@@ -2216,60 +2227,6 @@ var SelectBox = class extends BaseSvg {
|
|
|
2216
2227
|
constructor(context) {
|
|
2217
2228
|
super(context);
|
|
2218
2229
|
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
2230
|
const { config: { svg: { line } } } = context;
|
|
2274
2231
|
this.rect = createRect(line.stroke, "transparent");
|
|
2275
2232
|
this.svg.appendChild(this.rect);
|
|
@@ -2281,6 +2238,12 @@ var SelectBox = class extends BaseSvg {
|
|
|
2281
2238
|
}
|
|
2282
2239
|
this.registryEvent();
|
|
2283
2240
|
}
|
|
2241
|
+
rect;
|
|
2242
|
+
cornerRect = [];
|
|
2243
|
+
// 四个角上的方块
|
|
2244
|
+
centerRect = [];
|
|
2245
|
+
// 四个线中间的方块
|
|
2246
|
+
graphic;
|
|
2284
2247
|
setEnable(enable) {
|
|
2285
2248
|
super.setEnable(enable);
|
|
2286
2249
|
if (enable) {
|
|
@@ -2295,6 +2258,54 @@ var SelectBox = class extends BaseSvg {
|
|
|
2295
2258
|
unRegistryEvent() {
|
|
2296
2259
|
this.context.removeEventListener("update", this.onUpdate);
|
|
2297
2260
|
}
|
|
2261
|
+
onUpdate = () => {
|
|
2262
|
+
if (!this.graphic) {
|
|
2263
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2264
|
+
for (let i = 0; i < this.cornerRect.length; i++) {
|
|
2265
|
+
setRectPosition(this.cornerRect[i], 0, 0, 0, 0);
|
|
2266
|
+
setRectPosition(this.centerRect[i], 0, 0, 0, 0);
|
|
2267
|
+
}
|
|
2268
|
+
} else {
|
|
2269
|
+
const box = new Box36().setFromObject(this.graphic);
|
|
2270
|
+
const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
|
|
2271
|
+
const { min, max } = box;
|
|
2272
|
+
const leftBottom = vector3ToDevice(min, camera, w, h);
|
|
2273
|
+
const rightTop = vector3ToDevice(max, camera, w, h);
|
|
2274
|
+
setRectPosition(this.rect, leftBottom.x, rightTop.y, Math.abs(rightTop.x - leftBottom.x), Math.abs(rightTop.y - leftBottom.y));
|
|
2275
|
+
const { x: left, y: bottom } = leftBottom;
|
|
2276
|
+
const { x: right, y: top } = rightTop;
|
|
2277
|
+
const halfWidth = 5;
|
|
2278
|
+
const corners = [
|
|
2279
|
+
{ x: left - halfWidth, y: top - halfWidth },
|
|
2280
|
+
// 左上角
|
|
2281
|
+
{ x: right - halfWidth, y: top - halfWidth },
|
|
2282
|
+
// 右上角
|
|
2283
|
+
{ x: left - halfWidth, y: bottom - halfWidth },
|
|
2284
|
+
// 左下角
|
|
2285
|
+
{ x: right - halfWidth, y: bottom - halfWidth }
|
|
2286
|
+
// 右下角
|
|
2287
|
+
];
|
|
2288
|
+
for (let i = 0; i < corners.length; i++) {
|
|
2289
|
+
setRectPosition(this.cornerRect[i], corners[i].x, corners[i].y, halfWidth * 2, halfWidth * 2);
|
|
2290
|
+
}
|
|
2291
|
+
const centerHalfWidth = 4;
|
|
2292
|
+
const centerX = (left + right) / 2;
|
|
2293
|
+
const centerY = (bottom + top) / 2;
|
|
2294
|
+
const centers = [
|
|
2295
|
+
{ x: centerX - centerHalfWidth, y: top - centerHalfWidth },
|
|
2296
|
+
// 上
|
|
2297
|
+
{ x: left - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2298
|
+
// 左
|
|
2299
|
+
{ x: right - centerHalfWidth, y: centerY - centerHalfWidth },
|
|
2300
|
+
// 右
|
|
2301
|
+
{ x: centerX - centerHalfWidth, y: bottom - centerHalfWidth }
|
|
2302
|
+
// 下
|
|
2303
|
+
];
|
|
2304
|
+
for (let i = 0; i < centers.length; i++) {
|
|
2305
|
+
setRectPosition(this.centerRect[i], centers[i].x, centers[i].y, centerHalfWidth * 2, centerHalfWidth * 2);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2298
2309
|
selectGraphic(graphic) {
|
|
2299
2310
|
this.graphic = graphic;
|
|
2300
2311
|
}
|
|
@@ -2310,57 +2321,12 @@ var SelectBox = class extends BaseSvg {
|
|
|
2310
2321
|
// src/operations/selection/box-selection.ts
|
|
2311
2322
|
import { Frustum } from "three";
|
|
2312
2323
|
var BoxSelection = class extends BaseSvg {
|
|
2324
|
+
startPoint;
|
|
2325
|
+
endPoint;
|
|
2326
|
+
rect;
|
|
2327
|
+
frustum = new Frustum();
|
|
2313
2328
|
constructor(context) {
|
|
2314
2329
|
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
2330
|
const { config: { selectBox: { fill, stroke } } } = context;
|
|
2365
2331
|
this.rect = createRect(stroke, fill);
|
|
2366
2332
|
this.svg.appendChild(this.rect);
|
|
@@ -2376,6 +2342,51 @@ var BoxSelection = class extends BaseSvg {
|
|
|
2376
2342
|
this.unRegistryEvent();
|
|
2377
2343
|
}
|
|
2378
2344
|
}
|
|
2345
|
+
onPointerDown = (e) => {
|
|
2346
|
+
if (!this.enable) {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2350
|
+
if (point3) {
|
|
2351
|
+
this.startPoint = point3;
|
|
2352
|
+
}
|
|
2353
|
+
this.endPoint = void 0;
|
|
2354
|
+
};
|
|
2355
|
+
onPointerMove = (e) => {
|
|
2356
|
+
if (!this.enable || !this.startPoint) {
|
|
2357
|
+
return;
|
|
2358
|
+
}
|
|
2359
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2360
|
+
if (point3) {
|
|
2361
|
+
this.endPoint = point3;
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
onPointerUp = (e) => {
|
|
2365
|
+
if (!this.enable) {
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
2369
|
+
if (point3) {
|
|
2370
|
+
this.endPoint = point3;
|
|
2371
|
+
}
|
|
2372
|
+
this.doSelect();
|
|
2373
|
+
this.startPoint = void 0;
|
|
2374
|
+
};
|
|
2375
|
+
onUpdate = () => {
|
|
2376
|
+
if (this.startPoint) {
|
|
2377
|
+
const startPoint = this.getSvgCoordinate(this.startPoint);
|
|
2378
|
+
let endPoint = { ...startPoint };
|
|
2379
|
+
if (this.endPoint) {
|
|
2380
|
+
endPoint = this.getSvgCoordinate(this.endPoint);
|
|
2381
|
+
}
|
|
2382
|
+
const leftTop = { x: Math.min(startPoint.x, endPoint.x), y: Math.min(startPoint.y, endPoint.y) };
|
|
2383
|
+
const width = Math.abs(endPoint.x - startPoint.x);
|
|
2384
|
+
const height = Math.abs(endPoint.y - startPoint.y);
|
|
2385
|
+
setRectPosition(this.rect, leftTop.x, leftTop.y, width, height);
|
|
2386
|
+
} else {
|
|
2387
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2379
2390
|
registryEvent() {
|
|
2380
2391
|
this.context.container.addEventListener("pointerdown", this.onPointerDown);
|
|
2381
2392
|
this.context.container.addEventListener("pointermove", this.onPointerMove);
|
|
@@ -2404,11 +2415,10 @@ var BoxSelection = class extends BaseSvg {
|
|
|
2404
2415
|
}
|
|
2405
2416
|
}
|
|
2406
2417
|
searchMapInFrustum(leftTop, rightBottom) {
|
|
2407
|
-
var _a;
|
|
2408
2418
|
const { context } = this;
|
|
2409
|
-
return
|
|
2419
|
+
return context.currentFloor?.graphicLayer.children.filter((item) => {
|
|
2410
2420
|
return item instanceof Graphic && this.searchChildInFrustum(item, leftTop, rightBottom);
|
|
2411
|
-
})
|
|
2421
|
+
}) || [];
|
|
2412
2422
|
}
|
|
2413
2423
|
searchChildInFrustum(object, leftTop, rightBottom) {
|
|
2414
2424
|
const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
|
|
@@ -2450,68 +2460,16 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2450
2460
|
constructor(context) {
|
|
2451
2461
|
super();
|
|
2452
2462
|
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
2463
|
this.boxSelection = new BoxSelection(context);
|
|
2512
2464
|
this.boxSelection.setEnable(false);
|
|
2513
2465
|
this.registryEvent();
|
|
2514
2466
|
}
|
|
2467
|
+
_list = /* @__PURE__ */ new Set();
|
|
2468
|
+
boxSelection;
|
|
2469
|
+
prevPanStatus;
|
|
2470
|
+
prevRotateStatus;
|
|
2471
|
+
downPoint = null;
|
|
2472
|
+
isMultipleSelect = false;
|
|
2515
2473
|
get list() {
|
|
2516
2474
|
return this._list;
|
|
2517
2475
|
}
|
|
@@ -2534,6 +2492,57 @@ var Selection = class extends EventDispatcher4 {
|
|
|
2534
2492
|
this.context.control.enableRotate = !!this.prevRotateStatus;
|
|
2535
2493
|
}
|
|
2536
2494
|
}
|
|
2495
|
+
onPointerDown = (e) => {
|
|
2496
|
+
this.downPoint = { x: e.offsetX, y: e.offsetY };
|
|
2497
|
+
};
|
|
2498
|
+
onPointerUp = (e) => {
|
|
2499
|
+
if (!this.downPoint) {
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
const { offsetX, offsetY } = e;
|
|
2503
|
+
const { x, y } = this.downPoint;
|
|
2504
|
+
if (Math.sqrt((x - offsetX) ** 2 + (y - offsetY) ** 2) > 3) {
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
const { graphics } = this.context.getGraphicsByDeviceXy(offsetX, offsetY);
|
|
2508
|
+
const graphicIdSet = new Set(graphics.map((item) => item.options.id));
|
|
2509
|
+
const pois = this.context.getPoisByDeviceXy(offsetX, offsetY);
|
|
2510
|
+
pois.forEach((item) => {
|
|
2511
|
+
if (!graphicIdSet.has(item.options.id)) {
|
|
2512
|
+
const graphic = this.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id) || null;
|
|
2513
|
+
if (graphic && graphic.options.geometry.type === "point") {
|
|
2514
|
+
graphics.push(graphic);
|
|
2515
|
+
graphicIdSet.add(item.options.id);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
});
|
|
2519
|
+
if (!(isMac ? e.metaKey : e.ctrlKey)) {
|
|
2520
|
+
this._list.clear();
|
|
2521
|
+
}
|
|
2522
|
+
graphics.forEach((item) => this._list.add(item));
|
|
2523
|
+
this.selectEnd();
|
|
2524
|
+
this.downPoint = null;
|
|
2525
|
+
};
|
|
2526
|
+
onPointerOut = (e) => {
|
|
2527
|
+
this.disableBoxSelection();
|
|
2528
|
+
};
|
|
2529
|
+
onKeyDown = (e) => {
|
|
2530
|
+
if (isControl(e.key)) {
|
|
2531
|
+
this.enableBoxSelection();
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
onKeyUp = (e) => {
|
|
2535
|
+
if (isControl(e.key)) {
|
|
2536
|
+
this.disableBoxSelection();
|
|
2537
|
+
}
|
|
2538
|
+
};
|
|
2539
|
+
onBoxSelected = ({ list }) => {
|
|
2540
|
+
this._list.clear();
|
|
2541
|
+
list.forEach((item) => {
|
|
2542
|
+
this._list.add(item);
|
|
2543
|
+
});
|
|
2544
|
+
this.selectEnd();
|
|
2545
|
+
};
|
|
2537
2546
|
selectEnd() {
|
|
2538
2547
|
this.dispatchEvent({ type: "select", graphics: [...this._list], isMultipleSelect: this.isMultipleSelect });
|
|
2539
2548
|
}
|
|
@@ -2572,75 +2581,72 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2572
2581
|
constructor(context) {
|
|
2573
2582
|
super();
|
|
2574
2583
|
this.context = context;
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2584
|
+
this.registryEvent();
|
|
2585
|
+
}
|
|
2586
|
+
curGraphics = /* @__PURE__ */ new Set();
|
|
2587
|
+
timer = new Timer();
|
|
2588
|
+
graphicTimerMap = /* @__PURE__ */ new Map();
|
|
2589
|
+
onPointerMove = ({ graphics, pois, e }) => {
|
|
2590
|
+
const poiGraphics = pois.map((item) => this.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id)).filter((graphic) => graphic && graphic.options.geometry.type === "point");
|
|
2591
|
+
if (!graphics.length && !poiGraphics.length && this.curGraphics.size) {
|
|
2592
|
+
this.curGraphics.clear();
|
|
2593
|
+
this.handleHoverGraphicsChange();
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
const { time } = this.context.config.hover;
|
|
2597
|
+
const allGraphics = /* @__PURE__ */ new Set();
|
|
2598
|
+
if (poiGraphics.length) {
|
|
2599
|
+
let resGraphic;
|
|
2600
|
+
let distance = 1e4;
|
|
2601
|
+
poiGraphics.forEach((graphic) => {
|
|
2602
|
+
const poi = pois.find((poi2) => poi2.options.id === graphic.options.id);
|
|
2603
|
+
const { x, y } = poi.clientPos;
|
|
2604
|
+
let curDistance = Math.sqrt((x - e.offsetX) ** 2 + (y - e.offsetY) ** 2);
|
|
2605
|
+
if (curDistance < distance) {
|
|
2606
|
+
distance = curDistance;
|
|
2607
|
+
resGraphic = graphic;
|
|
2608
|
+
}
|
|
2609
|
+
});
|
|
2610
|
+
allGraphics.add(resGraphic);
|
|
2611
|
+
}
|
|
2612
|
+
if (!allGraphics.size) {
|
|
2613
|
+
graphics.forEach((graphic) => allGraphics.add(graphic));
|
|
2614
|
+
}
|
|
2615
|
+
allGraphics.forEach((graphic) => {
|
|
2616
|
+
if (this.graphicTimerMap.get(graphic)) {
|
|
2586
2617
|
return;
|
|
2587
2618
|
}
|
|
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));
|
|
2619
|
+
if (this.curGraphics.has(graphic)) {
|
|
2620
|
+
return;
|
|
2606
2621
|
}
|
|
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) {
|
|
2622
|
+
const timer = this.timer.setTimeout(() => {
|
|
2623
|
+
this.curGraphics.add(graphic);
|
|
2624
|
+
this.graphicTimerMap.delete(graphic);
|
|
2625
|
+
this.timer.clearTimeout(timer);
|
|
2635
2626
|
this.handleHoverGraphicsChange();
|
|
2627
|
+
}, time);
|
|
2628
|
+
this.graphicTimerMap.set(graphic, timer);
|
|
2629
|
+
});
|
|
2630
|
+
this.graphicTimerMap.forEach((timer, graphic) => {
|
|
2631
|
+
if (!allGraphics.has(graphic)) {
|
|
2632
|
+
this.timer.clearTimeout(timer);
|
|
2633
|
+
this.graphicTimerMap.delete(graphic);
|
|
2636
2634
|
}
|
|
2637
2635
|
});
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2636
|
+
const size = this.curGraphics.size;
|
|
2637
|
+
this.curGraphics.forEach((graphic) => {
|
|
2638
|
+
if (!allGraphics.has(graphic)) {
|
|
2639
|
+
this.curGraphics.delete(graphic);
|
|
2640
|
+
}
|
|
2641
2641
|
});
|
|
2642
|
-
this.
|
|
2643
|
-
|
|
2642
|
+
if (size !== this.curGraphics.size) {
|
|
2643
|
+
this.handleHoverGraphicsChange();
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
onPointerLevel = () => {
|
|
2647
|
+
this.curGraphics.clear();
|
|
2648
|
+
this.handleHoverGraphicsChange();
|
|
2649
|
+
};
|
|
2644
2650
|
handleHoverGraphicsChange(graphics = this.curGraphics) {
|
|
2645
2651
|
this.dispatchEvent({ type: "hover-change", graphics: Array.from(graphics) });
|
|
2646
2652
|
}
|
|
@@ -2675,11 +2681,11 @@ function vectorToString(vector) {
|
|
|
2675
2681
|
var MaterialFactory = class {
|
|
2676
2682
|
constructor(context) {
|
|
2677
2683
|
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
2684
|
}
|
|
2685
|
+
lineMaterialMap = /* @__PURE__ */ new Map();
|
|
2686
|
+
meshStandardMaterialMap = /* @__PURE__ */ new Map();
|
|
2687
|
+
meshBasicMaterialMap = /* @__PURE__ */ new Map();
|
|
2688
|
+
shaderMaterialMap = /* @__PURE__ */ new Map();
|
|
2683
2689
|
generateLineMaterialKey({ color, opacity }) {
|
|
2684
2690
|
return `${color}-${opacity}`;
|
|
2685
2691
|
}
|
|
@@ -2838,17 +2844,15 @@ import { Box3 as Box37, Vector3 as Vector312 } from "three";
|
|
|
2838
2844
|
var CameraBound = class {
|
|
2839
2845
|
constructor(context) {
|
|
2840
2846
|
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
2847
|
this.registryEvent();
|
|
2850
2848
|
this.changePrevCamera();
|
|
2851
2849
|
}
|
|
2850
|
+
prevCamera = {
|
|
2851
|
+
position: new Vector312(),
|
|
2852
|
+
zoom: 1,
|
|
2853
|
+
target: new Vector312()
|
|
2854
|
+
};
|
|
2855
|
+
enable = true;
|
|
2852
2856
|
setEnable(enable) {
|
|
2853
2857
|
this.enable = enable;
|
|
2854
2858
|
if (enable) {
|
|
@@ -2905,6 +2909,8 @@ var CameraBound = class {
|
|
|
2905
2909
|
const [pt, pr, pb, pl] = this.context.config.cameraBound.padding;
|
|
2906
2910
|
return left <= pl && width - right <= pr && top <= pt && height - bottom <= pb;
|
|
2907
2911
|
}
|
|
2912
|
+
onCameraChange = () => {
|
|
2913
|
+
};
|
|
2908
2914
|
dispose() {
|
|
2909
2915
|
this.unRegistryEvent();
|
|
2910
2916
|
}
|
|
@@ -2916,74 +2922,6 @@ var Context = class extends EventDispatcher6 {
|
|
|
2916
2922
|
super();
|
|
2917
2923
|
this.container = container;
|
|
2918
2924
|
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
2925
|
this.container.style.position = "relative";
|
|
2988
2926
|
this.container.style.overflow = "hidden";
|
|
2989
2927
|
this.init();
|
|
@@ -2993,6 +2931,27 @@ var Context = class extends EventDispatcher6 {
|
|
|
2993
2931
|
this.resizeClientSize();
|
|
2994
2932
|
this.registryEvent();
|
|
2995
2933
|
}
|
|
2934
|
+
scene = initScene();
|
|
2935
|
+
renderer = initRenderer();
|
|
2936
|
+
camera;
|
|
2937
|
+
control;
|
|
2938
|
+
lights = initLight();
|
|
2939
|
+
// 管理任务,防止内存泄漏
|
|
2940
|
+
timer = new Timer();
|
|
2941
|
+
tweenGroup = new TweenGroup();
|
|
2942
|
+
currentFloor;
|
|
2943
|
+
selection;
|
|
2944
|
+
hoverHelper;
|
|
2945
|
+
basicRatio;
|
|
2946
|
+
// zoom=1的时候,100M对应的像素个数
|
|
2947
|
+
materialFactory;
|
|
2948
|
+
cameraBound;
|
|
2949
|
+
clientSize = {
|
|
2950
|
+
width: 0,
|
|
2951
|
+
height: 0,
|
|
2952
|
+
x: 0,
|
|
2953
|
+
y: 0
|
|
2954
|
+
};
|
|
2996
2955
|
resizeClientSize() {
|
|
2997
2956
|
const { x, y, width, height } = this.container.getBoundingClientRect();
|
|
2998
2957
|
this.clientSize = {
|
|
@@ -3012,9 +2971,8 @@ var Context = class extends EventDispatcher6 {
|
|
|
3012
2971
|
this.scene.add(this.lights);
|
|
3013
2972
|
this.basicRatio = this.getRatio();
|
|
3014
2973
|
this.control.addEventListener("change", () => {
|
|
3015
|
-
var _a;
|
|
3016
2974
|
const polarAngle = this.control.getPolarAngle();
|
|
3017
|
-
|
|
2975
|
+
this.currentFloor?.setShadowOpacity(polarAngle / this.config.control.maxPolar);
|
|
3018
2976
|
this.dispatchEvent({ type: "change-ratio", px: (this.basicRatio || 0) * this.camera.zoom });
|
|
3019
2977
|
this.dispatchEvent({ type: "control-change" });
|
|
3020
2978
|
});
|
|
@@ -3027,7 +2985,7 @@ var Context = class extends EventDispatcher6 {
|
|
|
3027
2985
|
const { clientWidth, clientHeight } = this.container;
|
|
3028
2986
|
const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
|
|
3029
2987
|
const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
|
|
3030
|
-
return Math.ceil(Math.sqrt(
|
|
2988
|
+
return Math.ceil(Math.sqrt((device2.x - device1.x) ** 2 + (device2.y - device1.y) ** 2));
|
|
3031
2989
|
}
|
|
3032
2990
|
changeAmbientLightColor(color) {
|
|
3033
2991
|
this.lights.children.forEach((item) => {
|
|
@@ -3049,6 +3007,34 @@ var Context = class extends EventDispatcher6 {
|
|
|
3049
3007
|
this.lights.position.y = position.y;
|
|
3050
3008
|
}
|
|
3051
3009
|
}
|
|
3010
|
+
onWindowResize = () => {
|
|
3011
|
+
const { container, camera, renderer } = this;
|
|
3012
|
+
let { clientWidth: w, clientHeight: h } = container;
|
|
3013
|
+
w = Math.max(1, w);
|
|
3014
|
+
h = Math.max(1, h);
|
|
3015
|
+
camera.left = -w / 2;
|
|
3016
|
+
camera.right = w / 2;
|
|
3017
|
+
camera.top = h / 2;
|
|
3018
|
+
camera.bottom = -h / 2;
|
|
3019
|
+
camera.updateProjectionMatrix();
|
|
3020
|
+
renderer.setSize(w, h);
|
|
3021
|
+
this.resizeClientSize();
|
|
3022
|
+
this.dispatchEvent({ type: "resize", width: w, height: h });
|
|
3023
|
+
};
|
|
3024
|
+
onClick = (e) => {
|
|
3025
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3026
|
+
if (graphics.length) {
|
|
3027
|
+
this.dispatchEvent({
|
|
3028
|
+
type: "graphic-click",
|
|
3029
|
+
graphics,
|
|
3030
|
+
position
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3034
|
+
if (pois.length) {
|
|
3035
|
+
this.dispatchEvent({ type: "poi-click", pois });
|
|
3036
|
+
}
|
|
3037
|
+
};
|
|
3052
3038
|
/**
|
|
3053
3039
|
* 获取屏幕坐标对应的graphic
|
|
3054
3040
|
* @param x
|
|
@@ -3056,13 +3042,12 @@ var Context = class extends EventDispatcher6 {
|
|
|
3056
3042
|
* @returns
|
|
3057
3043
|
*/
|
|
3058
3044
|
getGraphicsByDeviceXy(x, y) {
|
|
3059
|
-
var _a;
|
|
3060
3045
|
const point3 = new Vector23();
|
|
3061
3046
|
point3.x = x / this.clientSize.width * 2 - 1;
|
|
3062
3047
|
point3.y = y / this.clientSize.height * -2 + 1;
|
|
3063
3048
|
const raycaster = new Raycaster3();
|
|
3064
3049
|
raycaster.setFromCamera(point3, this.camera);
|
|
3065
|
-
const res =
|
|
3050
|
+
const res = this.currentFloor?.graphicLayer.getGraphicByRaycaster(raycaster);
|
|
3066
3051
|
return res || { graphics: [], position: null };
|
|
3067
3052
|
}
|
|
3068
3053
|
/**
|
|
@@ -3072,10 +3057,28 @@ var Context = class extends EventDispatcher6 {
|
|
|
3072
3057
|
* @returns
|
|
3073
3058
|
*/
|
|
3074
3059
|
getPoisByDeviceXy(x, y) {
|
|
3075
|
-
|
|
3076
|
-
const pois = (_a = this.currentFloor) == null ? void 0 : _a.poiLayer.getPoiByDeviceXy(x, y);
|
|
3060
|
+
const pois = this.currentFloor?.poiLayer.getPoiByDeviceXy(x, y);
|
|
3077
3061
|
return pois || [];
|
|
3078
3062
|
}
|
|
3063
|
+
onPointerover = (e) => {
|
|
3064
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3065
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3066
|
+
this.dispatchEvent({ type: "pointer-over", e, graphics, pois, position });
|
|
3067
|
+
};
|
|
3068
|
+
onPointermove = (e) => {
|
|
3069
|
+
const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
|
|
3070
|
+
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3071
|
+
this.dispatchEvent({ type: "pointer-move", e, graphics, pois, position });
|
|
3072
|
+
};
|
|
3073
|
+
onPointerleave = () => {
|
|
3074
|
+
this.dispatchEvent({ type: "pointer-level" });
|
|
3075
|
+
};
|
|
3076
|
+
onSelectionSelect = ({ graphics, isMultipleSelect }) => {
|
|
3077
|
+
this.dispatchEvent({ type: "select-graphic", graphics, isMultipleSelect });
|
|
3078
|
+
};
|
|
3079
|
+
onHoverChange = ({ graphics }) => {
|
|
3080
|
+
this.dispatchEvent({ type: "hover", graphics });
|
|
3081
|
+
};
|
|
3079
3082
|
registryEvent() {
|
|
3080
3083
|
window.addEventListener("resize", this.onWindowResize);
|
|
3081
3084
|
this.container.addEventListener("click", this.onClick);
|
|
@@ -3323,7 +3326,8 @@ var defaultConfig = {
|
|
|
3323
3326
|
apiInfo: {},
|
|
3324
3327
|
apiPath: {
|
|
3325
3328
|
floorGraphic: "/api/inception-map/floor/get",
|
|
3326
|
-
floorRange: "/api/inception-map/range/get"
|
|
3329
|
+
floorRange: "/api/inception-map/range/get",
|
|
3330
|
+
equipmentList: "/api/inception-map/equipment/get"
|
|
3327
3331
|
},
|
|
3328
3332
|
resizeObserver: false,
|
|
3329
3333
|
initTransToMark: false,
|
|
@@ -3390,6 +3394,118 @@ function getConfig(config) {
|
|
|
3390
3394
|
|
|
3391
3395
|
// src/bmap.ts
|
|
3392
3396
|
import { debounce as debounce3 } from "lodash";
|
|
3397
|
+
|
|
3398
|
+
// src/plugins/base.ts
|
|
3399
|
+
var Plugin = class {
|
|
3400
|
+
bmap;
|
|
3401
|
+
constructor(bmap) {
|
|
3402
|
+
this.bmap = bmap;
|
|
3403
|
+
}
|
|
3404
|
+
dispose() {
|
|
3405
|
+
}
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3408
|
+
// src/plugins/equipment/equipment.ts
|
|
3409
|
+
var Equipment = class extends Plugin {
|
|
3410
|
+
equipmentList = [];
|
|
3411
|
+
equipmentMap = /* @__PURE__ */ new Map();
|
|
3412
|
+
constructor(bmap) {
|
|
3413
|
+
super(bmap);
|
|
3414
|
+
this.fetchEquipment();
|
|
3415
|
+
this.bmap.event.on("switch_floor_after" /* SWITCH_FLOOR_AFTER */, this.onSwitchFloor);
|
|
3416
|
+
}
|
|
3417
|
+
async fetchEquipment() {
|
|
3418
|
+
const {
|
|
3419
|
+
apiDomain,
|
|
3420
|
+
apiPath: { equipmentList },
|
|
3421
|
+
apiInfo
|
|
3422
|
+
} = this.bmap.config;
|
|
3423
|
+
const url = `${apiDomain}${equipmentList}`;
|
|
3424
|
+
await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3425
|
+
this.equipmentList = res;
|
|
3426
|
+
this.equipmentMap = new Map(
|
|
3427
|
+
res.map((item) => [item.equipment_id, item])
|
|
3428
|
+
);
|
|
3429
|
+
});
|
|
3430
|
+
if (this.bmap.context.currentFloor) {
|
|
3431
|
+
this.changeGraphicToEquipment(
|
|
3432
|
+
this.bmap.context.currentFloor.graphicLayer.children
|
|
3433
|
+
);
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
onSwitchFloor = (floor) => {
|
|
3437
|
+
if (!this.equipmentList.length) {
|
|
3438
|
+
return;
|
|
3439
|
+
}
|
|
3440
|
+
this.changeGraphicToEquipment(floor.graphics);
|
|
3441
|
+
};
|
|
3442
|
+
getGraphicEquipment(graphic) {
|
|
3443
|
+
return graphic.userData.data.info.userData.equipment;
|
|
3444
|
+
}
|
|
3445
|
+
changeGraphicToEquipment(graphics) {
|
|
3446
|
+
console.log(graphics);
|
|
3447
|
+
graphics.filter((graphic) => {
|
|
3448
|
+
const equipment = this.getGraphicEquipment(graphic);
|
|
3449
|
+
return equipment && this.equipmentMap.has(equipment);
|
|
3450
|
+
}).forEach((graphic) => {
|
|
3451
|
+
const equipment = this.equipmentMap.get(
|
|
3452
|
+
this.getGraphicEquipment(graphic)
|
|
3453
|
+
);
|
|
3454
|
+
const poi = this.bmap.createGraphicPoi(graphic, {
|
|
3455
|
+
icon: equipment?.equipment_icon,
|
|
3456
|
+
built_in: true,
|
|
3457
|
+
icon_size: [14, 14]
|
|
3458
|
+
});
|
|
3459
|
+
});
|
|
3460
|
+
}
|
|
3461
|
+
dispose() {
|
|
3462
|
+
this.bmap.event.off("switch_floor_after" /* SWITCH_FLOOR_AFTER */, this.onSwitchFloor);
|
|
3463
|
+
}
|
|
3464
|
+
};
|
|
3465
|
+
|
|
3466
|
+
// src/plugins/navigation/path.worker.ts
|
|
3467
|
+
var workerCode = `
|
|
3468
|
+
self.onmessage = (e) => {
|
|
3469
|
+
console.log(e.data)
|
|
3470
|
+
loadRoad("");
|
|
3471
|
+
getPath("", "")
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
function loadRoad(project) {
|
|
3475
|
+
// \u8BF7\u6C42\u5168\u90E8\u697C\u5C42\u7684\u8DEF\u7F51
|
|
3476
|
+
console.log(project)
|
|
3477
|
+
self.postMessage("project")
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
function getPath(start, end) {
|
|
3481
|
+
// \u89C4\u5212\u8DEF\u7EBF
|
|
3482
|
+
console.log(start, end)
|
|
3483
|
+
self.postMessage("getPath")
|
|
3484
|
+
}
|
|
3485
|
+
`;
|
|
3486
|
+
var path_worker_default = workerCode;
|
|
3487
|
+
|
|
3488
|
+
// src/plugins/navigation/navigation.ts
|
|
3489
|
+
var Navigation = class extends Plugin {
|
|
3490
|
+
worker_url = window.URL.createObjectURL(new Blob([path_worker_default], { type: "text/javascript" }));
|
|
3491
|
+
worker = new Worker(this.worker_url);
|
|
3492
|
+
constructor(bmap) {
|
|
3493
|
+
super(bmap);
|
|
3494
|
+
console.log(this.worker);
|
|
3495
|
+
this.worker.postMessage("initial");
|
|
3496
|
+
this.worker.onmessage = (e) => {
|
|
3497
|
+
console.log("onmessage", e.data);
|
|
3498
|
+
};
|
|
3499
|
+
}
|
|
3500
|
+
fetchRoad() {
|
|
3501
|
+
}
|
|
3502
|
+
dispose() {
|
|
3503
|
+
this.worker.terminate();
|
|
3504
|
+
window.URL.revokeObjectURL(this.worker_url);
|
|
3505
|
+
}
|
|
3506
|
+
};
|
|
3507
|
+
|
|
3508
|
+
// src/bmap.ts
|
|
3393
3509
|
var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
3394
3510
|
MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
|
|
3395
3511
|
MapTypePolar2[MapTypePolar2["D3"] = 1.1] = "D3";
|
|
@@ -3399,100 +3515,47 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3399
3515
|
constructor(container, config = {}) {
|
|
3400
3516
|
super();
|
|
3401
3517
|
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
3518
|
this.config = getConfig(config);
|
|
3470
3519
|
this.context = new Context(container, this.config);
|
|
3471
3520
|
this.registryEvent();
|
|
3472
3521
|
this.context.render();
|
|
3473
3522
|
}
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3523
|
+
config;
|
|
3524
|
+
context;
|
|
3525
|
+
polarKeys = [];
|
|
3526
|
+
azimuthalKeys = [];
|
|
3527
|
+
svgLine;
|
|
3528
|
+
svgPolygon;
|
|
3529
|
+
basicZoom = 1;
|
|
3530
|
+
prevCameraZoom = 1;
|
|
3531
|
+
type = "2d";
|
|
3532
|
+
floorDataMap = /* @__PURE__ */ new Map();
|
|
3533
|
+
buildingGroundMap = /* @__PURE__ */ new Map();
|
|
3534
|
+
currentBuildGround = null;
|
|
3535
|
+
observe = null;
|
|
3536
|
+
event = new Events();
|
|
3537
|
+
timer = new Timer();
|
|
3538
|
+
plugins = [];
|
|
3539
|
+
async loadGraphics({
|
|
3540
|
+
brand,
|
|
3541
|
+
project,
|
|
3542
|
+
phase,
|
|
3543
|
+
building,
|
|
3544
|
+
floor,
|
|
3545
|
+
ts,
|
|
3546
|
+
resource_type_list
|
|
3547
|
+
}) {
|
|
3548
|
+
const {
|
|
3549
|
+
apiDomain,
|
|
3550
|
+
apiPath: { floorGraphic },
|
|
3551
|
+
apiInfo
|
|
3552
|
+
} = this.config;
|
|
3553
|
+
const url = `${apiDomain}${floorGraphic}?brand=${brand}&project=${project}&phase=${phase}&building=${building}&floor=${floor}&ts=${ts}&resource_type_list=${resource_type_list}`;
|
|
3554
|
+
const data = await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3555
|
+
(res || []).map((item) => item.info = JSON.parse(item.info));
|
|
3556
|
+
return res || [];
|
|
3495
3557
|
});
|
|
3558
|
+
return data;
|
|
3496
3559
|
}
|
|
3497
3560
|
getBuildingKey({
|
|
3498
3561
|
brand,
|
|
@@ -3503,33 +3566,31 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3503
3566
|
const key = `${brand}-${project}-${phase}-${building}`;
|
|
3504
3567
|
return key;
|
|
3505
3568
|
}
|
|
3506
|
-
loadBuildingGround(
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
})
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3569
|
+
async loadBuildingGround({
|
|
3570
|
+
brand,
|
|
3571
|
+
project,
|
|
3572
|
+
phase,
|
|
3573
|
+
building
|
|
3574
|
+
}) {
|
|
3575
|
+
const key = this.getBuildingKey({ brand, project, phase, building });
|
|
3576
|
+
if (this.buildingGroundMap.get(key)) {
|
|
3577
|
+
return this.buildingGroundMap.get(key) || null;
|
|
3578
|
+
}
|
|
3579
|
+
const {
|
|
3580
|
+
apiDomain,
|
|
3581
|
+
apiPath: { floorRange },
|
|
3582
|
+
apiInfo
|
|
3583
|
+
} = this.config;
|
|
3584
|
+
const url = `${apiDomain}${floorRange}?brand=${brand}&project=${project}&phase=${phase}&building=${building}`;
|
|
3585
|
+
const data = await fetch(url, apiInfo).then((res) => res.json()).then((res) => res.data).then((res) => {
|
|
3586
|
+
const data2 = (res || [])[0];
|
|
3587
|
+
if (data2) {
|
|
3588
|
+
data2.info = JSON.parse(data2.info);
|
|
3516
3589
|
}
|
|
3517
|
-
|
|
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;
|
|
3590
|
+
return data2;
|
|
3532
3591
|
});
|
|
3592
|
+
this.buildingGroundMap.set(key, data);
|
|
3593
|
+
return data;
|
|
3533
3594
|
}
|
|
3534
3595
|
getFloorKey({
|
|
3535
3596
|
brand,
|
|
@@ -3543,8 +3604,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3543
3604
|
const floorKey = `${brand}-${project}-${phase}-${building}-${floor}-${ts}-${resource_type_list}`;
|
|
3544
3605
|
return floorKey;
|
|
3545
3606
|
}
|
|
3546
|
-
load(
|
|
3547
|
-
|
|
3607
|
+
async load({
|
|
3608
|
+
brand,
|
|
3609
|
+
project,
|
|
3610
|
+
phase,
|
|
3611
|
+
building,
|
|
3612
|
+
floor,
|
|
3613
|
+
ts,
|
|
3614
|
+
resource_type_list
|
|
3615
|
+
}) {
|
|
3616
|
+
const floorKey = this.getFloorKey({
|
|
3548
3617
|
brand,
|
|
3549
3618
|
project,
|
|
3550
3619
|
phase,
|
|
@@ -3552,8 +3621,12 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3552
3621
|
floor,
|
|
3553
3622
|
ts,
|
|
3554
3623
|
resource_type_list
|
|
3555
|
-
})
|
|
3556
|
-
|
|
3624
|
+
});
|
|
3625
|
+
if (this.floorDataMap.get(floorKey)) {
|
|
3626
|
+
return;
|
|
3627
|
+
}
|
|
3628
|
+
const [data, buildGround] = await Promise.all([
|
|
3629
|
+
this.loadGraphics({
|
|
3557
3630
|
brand,
|
|
3558
3631
|
project,
|
|
3559
3632
|
phase,
|
|
@@ -3561,81 +3634,77 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3561
3634
|
floor,
|
|
3562
3635
|
ts,
|
|
3563
3636
|
resource_type_list
|
|
3564
|
-
})
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
if (buildGround) {
|
|
3581
|
-
const center2 = getCenter(
|
|
3582
|
-
buildGround.info.geometry.cds[0]
|
|
3583
|
-
);
|
|
3584
|
-
data.forEach((item) => {
|
|
3585
|
-
item.info.geometry.coords = JSON.parse(
|
|
3586
|
-
JSON.stringify(item.info.geometry.cds)
|
|
3587
|
-
);
|
|
3588
|
-
if (item.info.geometry.type === "polygon") {
|
|
3589
|
-
item.info.geometry.coords.map((cds) => {
|
|
3590
|
-
if (Array.isArray(cds)) {
|
|
3591
|
-
cds.forEach((coord) => {
|
|
3592
|
-
coord[0] -= center2[0];
|
|
3593
|
-
coord[1] -= center2[1];
|
|
3594
|
-
});
|
|
3595
|
-
}
|
|
3637
|
+
}),
|
|
3638
|
+
this.loadBuildingGround({ brand, project, phase, building })
|
|
3639
|
+
]);
|
|
3640
|
+
const center2 = buildGround ? getCenter(
|
|
3641
|
+
buildGround.info.geometry.cds[0]
|
|
3642
|
+
) : [0, 0];
|
|
3643
|
+
data.forEach((item) => {
|
|
3644
|
+
item.info.geometry.coords = JSON.parse(
|
|
3645
|
+
JSON.stringify(item.info.geometry.cds)
|
|
3646
|
+
);
|
|
3647
|
+
if (item.info.geometry.type === "polygon") {
|
|
3648
|
+
item.info.geometry.coords.map((cds) => {
|
|
3649
|
+
if (Array.isArray(cds)) {
|
|
3650
|
+
cds.forEach((coord) => {
|
|
3651
|
+
coord[0] -= center2[0];
|
|
3652
|
+
coord[1] -= center2[1];
|
|
3596
3653
|
});
|
|
3597
|
-
} else {
|
|
3598
|
-
const [x, y] = item.info.geometry.cds;
|
|
3599
|
-
item.info.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3600
3654
|
}
|
|
3601
|
-
item.info.transformToBuildingGround = true;
|
|
3602
3655
|
});
|
|
3656
|
+
} else {
|
|
3657
|
+
const [x, y] = item.info.geometry.cds;
|
|
3658
|
+
item.info.geometry.coords = [x - center2[0], y - center2[1]];
|
|
3603
3659
|
}
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3660
|
+
item.info.transformToBuildingGround = !!buildGround;
|
|
3661
|
+
});
|
|
3662
|
+
const { ground, markGraphic, graphic } = this.config;
|
|
3663
|
+
for (let i = 0; i < data.length; i++) {
|
|
3664
|
+
const item = data[i];
|
|
3665
|
+
item.info.deltaHeight = 1e-5 * (i + 1);
|
|
3666
|
+
if (item.info.group === "ground") {
|
|
3667
|
+
item.info.fillColor = ground.color;
|
|
3668
|
+
item.info.fillOpacity = ground.opacity;
|
|
3669
|
+
item.info.height = ground.height;
|
|
3670
|
+
item.info.stroke = ground.stroke;
|
|
3671
|
+
item.info.strokeColor = ground.strokeColor;
|
|
3672
|
+
item.info.strokeOpacity = ground.strokeOpacity;
|
|
3673
|
+
} else if (item.info.userData.mark) {
|
|
3674
|
+
item.info.height = markGraphic.height;
|
|
3675
|
+
item.info.fillColor = markGraphic.color;
|
|
3676
|
+
item.info.fillOpacity = markGraphic.opacity;
|
|
3677
|
+
item.info.stroke = markGraphic.stroke;
|
|
3678
|
+
item.info.strokeColor = markGraphic.strokeColor;
|
|
3679
|
+
item.info.strokeOpacity = markGraphic.strokeOpacity;
|
|
3680
|
+
} else {
|
|
3681
|
+
item.info.fillOpacity = graphic.fillOpacity;
|
|
3682
|
+
if (this.config.initTransToMark) {
|
|
3616
3683
|
item.info.height = markGraphic.height;
|
|
3617
3684
|
item.info.fillColor = markGraphic.color;
|
|
3618
|
-
item.info.fillOpacity = markGraphic.opacity;
|
|
3619
3685
|
item.info.stroke = markGraphic.stroke;
|
|
3620
3686
|
item.info.strokeColor = markGraphic.strokeColor;
|
|
3621
3687
|
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
3688
|
}
|
|
3632
3689
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3690
|
+
}
|
|
3691
|
+
if (!this.config.useFloorCache) {
|
|
3692
|
+
this.floorDataMap.clear();
|
|
3693
|
+
}
|
|
3694
|
+
this.floorDataMap.set(floorKey, data);
|
|
3695
|
+
return data;
|
|
3696
|
+
}
|
|
3697
|
+
loadEquipment() {
|
|
3698
|
+
const equipment = new Equipment(this);
|
|
3699
|
+
this.plugins.push(equipment);
|
|
3700
|
+
}
|
|
3701
|
+
use(plugin) {
|
|
3702
|
+
plugin.bmap = this;
|
|
3703
|
+
this.plugins.push(plugin);
|
|
3704
|
+
}
|
|
3705
|
+
loadNavigation() {
|
|
3706
|
+
const navigation = new Navigation(this);
|
|
3707
|
+
this.plugins.push(navigation);
|
|
3639
3708
|
}
|
|
3640
3709
|
createFloor(data) {
|
|
3641
3710
|
const curFloor = new Floor(this.context);
|
|
@@ -3687,6 +3756,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3687
3756
|
this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
|
|
3688
3757
|
const createdFloor = this.createFloor(curFloorData);
|
|
3689
3758
|
if (createdFloor) {
|
|
3759
|
+
this.event.emit("switch_floor_before" /* SWITCH_FLOOR_BEFORE */, createdFloor);
|
|
3690
3760
|
this.context.cameraBound.setEnable(false);
|
|
3691
3761
|
this.context.switchFloor(createdFloor.curFloor);
|
|
3692
3762
|
this.context.control.minZoom = 0;
|
|
@@ -3703,6 +3773,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3703
3773
|
}
|
|
3704
3774
|
this.onControlChange();
|
|
3705
3775
|
this.context.cameraBound.setEnable(true);
|
|
3776
|
+
this.event.emit("switch_floor_after" /* SWITCH_FLOOR_AFTER */, createdFloor);
|
|
3706
3777
|
} else {
|
|
3707
3778
|
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
3708
3779
|
}
|
|
@@ -3712,14 +3783,27 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3712
3783
|
);
|
|
3713
3784
|
}
|
|
3714
3785
|
}
|
|
3786
|
+
onControlChange = () => {
|
|
3787
|
+
const {
|
|
3788
|
+
camera: { zoom }
|
|
3789
|
+
} = this.context;
|
|
3790
|
+
if (zoom !== this.prevCameraZoom) {
|
|
3791
|
+
this.dispatchEvent({
|
|
3792
|
+
type: "zoom-change",
|
|
3793
|
+
basicZoom: this.basicZoom,
|
|
3794
|
+
cameraZoom: this.context.camera.zoom
|
|
3795
|
+
});
|
|
3796
|
+
this.prevCameraZoom = zoom;
|
|
3797
|
+
}
|
|
3798
|
+
};
|
|
3715
3799
|
// 扶梯
|
|
3716
3800
|
addModel(graphic, options) {
|
|
3717
|
-
var _a;
|
|
3718
3801
|
if (graphic.options.geometry.type === "polygon") {
|
|
3719
|
-
const model =
|
|
3802
|
+
const model = this.context.currentFloor?.addModel({
|
|
3803
|
+
...options,
|
|
3720
3804
|
position: graphic.getPosition().setZ(0.1),
|
|
3721
3805
|
id: graphic.options.id
|
|
3722
|
-
})
|
|
3806
|
+
});
|
|
3723
3807
|
if (model) {
|
|
3724
3808
|
const {
|
|
3725
3809
|
facilityAngle = 0,
|
|
@@ -3732,22 +3816,19 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3732
3816
|
}
|
|
3733
3817
|
}
|
|
3734
3818
|
addHeatmap(data) {
|
|
3735
|
-
|
|
3736
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.addHeatmap(data);
|
|
3819
|
+
return this.context.currentFloor?.addHeatmap(data);
|
|
3737
3820
|
}
|
|
3738
3821
|
getLegacyToGraphicMap() {
|
|
3739
|
-
|
|
3740
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.userData.legacyToGraphicMap) || /* @__PURE__ */ new Map();
|
|
3822
|
+
return this.context.currentFloor?.userData.legacyToGraphicMap || /* @__PURE__ */ new Map();
|
|
3741
3823
|
}
|
|
3742
3824
|
/**
|
|
3743
3825
|
* 获取当前楼层全部的graphic
|
|
3744
3826
|
* @returns
|
|
3745
3827
|
*/
|
|
3746
3828
|
getFloorAllGraphics() {
|
|
3747
|
-
|
|
3748
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.children.filter(
|
|
3829
|
+
return this.context.currentFloor?.graphicLayer.children.filter(
|
|
3749
3830
|
(item) => item instanceof Graphic
|
|
3750
|
-
)
|
|
3831
|
+
) || [];
|
|
3751
3832
|
}
|
|
3752
3833
|
createGraphicPoi(graphic, options) {
|
|
3753
3834
|
if (this.context.currentFloor) {
|
|
@@ -3755,16 +3836,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3755
3836
|
options.id = graphic.options.id;
|
|
3756
3837
|
}
|
|
3757
3838
|
const position = graphic.getCenter();
|
|
3758
|
-
const poi = this.context.currentFloor.addPoi(
|
|
3759
|
-
|
|
3760
|
-
|
|
3839
|
+
const poi = this.context.currentFloor.addPoi({
|
|
3840
|
+
...options,
|
|
3841
|
+
position: { ...position, z: position.z + graphic.options.height / 2 }
|
|
3842
|
+
});
|
|
3761
3843
|
return poi;
|
|
3762
3844
|
}
|
|
3763
3845
|
return null;
|
|
3764
3846
|
}
|
|
3765
3847
|
removeHeatMap() {
|
|
3766
|
-
|
|
3767
|
-
(_a = this.context.currentFloor) == null ? void 0 : _a.removeHeatMap();
|
|
3848
|
+
this.context.currentFloor?.removeHeatMap();
|
|
3768
3849
|
}
|
|
3769
3850
|
/**
|
|
3770
3851
|
* 移动相机位置让选中的元素居中显示
|
|
@@ -3780,28 +3861,26 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3780
3861
|
* @param ele { Graphic | Poi }
|
|
3781
3862
|
* @param duration
|
|
3782
3863
|
*/
|
|
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
|
-
});
|
|
3864
|
+
async translateElementToCenterX(ele, duration = 500) {
|
|
3865
|
+
return timeoutPromise(new Promise((resolve) => {
|
|
3866
|
+
const target = this.context.control.target.clone();
|
|
3867
|
+
const position = ele.getPosition();
|
|
3868
|
+
this.timer.requestAnimationFrame(() => {
|
|
3869
|
+
const {
|
|
3870
|
+
clientSize: { width, height },
|
|
3871
|
+
camera
|
|
3872
|
+
} = this.context;
|
|
3873
|
+
console.log("width", width, height);
|
|
3874
|
+
const device = vector3ToDevice(position, camera, width, height);
|
|
3875
|
+
const offsetX = device.x - width / 2;
|
|
3876
|
+
const v3 = new Vector314();
|
|
3877
|
+
v3.setFromMatrixColumn(this.context.camera.matrix, 0);
|
|
3878
|
+
v3.normalize();
|
|
3879
|
+
v3.multiplyScalar(offsetX / this.context.camera.zoom);
|
|
3880
|
+
target.add(v3);
|
|
3881
|
+
this.context.setCameraPosition(target, duration).then(resolve);
|
|
3882
|
+
});
|
|
3883
|
+
}), duration + 500);
|
|
3805
3884
|
}
|
|
3806
3885
|
/**
|
|
3807
3886
|
* 获取物体的屏幕坐标
|
|
@@ -3829,20 +3908,18 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3829
3908
|
return this.context.setPolarAngle(1.1 /* D3 */, duration);
|
|
3830
3909
|
}
|
|
3831
3910
|
}
|
|
3832
|
-
resetView(duration = 300) {
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
);
|
|
3845
|
-
});
|
|
3911
|
+
async resetView(duration = 300) {
|
|
3912
|
+
const time = duration / 3;
|
|
3913
|
+
await this.context.setAzimuthalAngle(
|
|
3914
|
+
this.config.control.defaultAzimuthal,
|
|
3915
|
+
time
|
|
3916
|
+
);
|
|
3917
|
+
await this.changeMapType(this.type, time);
|
|
3918
|
+
await this.context.fitCameraToGround(
|
|
3919
|
+
this.config.defaultPadding,
|
|
3920
|
+
time,
|
|
3921
|
+
false
|
|
3922
|
+
);
|
|
3846
3923
|
}
|
|
3847
3924
|
/**
|
|
3848
3925
|
* 缩小地图
|
|
@@ -3872,6 +3949,28 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3872
3949
|
duration
|
|
3873
3950
|
);
|
|
3874
3951
|
}
|
|
3952
|
+
onKeydown = (e) => {
|
|
3953
|
+
if (this.polarKeys.includes(e.code)) {
|
|
3954
|
+
this.context.control.maxPolarAngle = this.config.control.maxPolar;
|
|
3955
|
+
this.context.control.minPolarAngle = 0;
|
|
3956
|
+
}
|
|
3957
|
+
if (this.azimuthalKeys.includes(e.code)) {
|
|
3958
|
+
this.context.control.maxAzimuthAngle = Infinity;
|
|
3959
|
+
this.context.control.minAzimuthAngle = Infinity;
|
|
3960
|
+
}
|
|
3961
|
+
};
|
|
3962
|
+
onKeyUp = (e) => {
|
|
3963
|
+
if (this.polarKeys.includes(e.code)) {
|
|
3964
|
+
const polar = this.context.control.getPolarAngle();
|
|
3965
|
+
this.context.control.maxPolarAngle = polar;
|
|
3966
|
+
this.context.control.minPolarAngle = polar;
|
|
3967
|
+
}
|
|
3968
|
+
if (this.azimuthalKeys.includes(e.code)) {
|
|
3969
|
+
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
3970
|
+
this.context.control.maxAzimuthAngle = azimuthal;
|
|
3971
|
+
this.context.control.minAzimuthAngle = azimuthal;
|
|
3972
|
+
}
|
|
3973
|
+
};
|
|
3875
3974
|
registryEvent() {
|
|
3876
3975
|
window.addEventListener("keydown", this.onKeydown);
|
|
3877
3976
|
window.addEventListener("keyup", this.onKeyUp);
|
|
@@ -3882,10 +3981,9 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3882
3981
|
}
|
|
3883
3982
|
}
|
|
3884
3983
|
unRegistryEvent() {
|
|
3885
|
-
var _a;
|
|
3886
3984
|
window.removeEventListener("keydown", this.onKeydown);
|
|
3887
3985
|
window.removeEventListener("keyup", this.onKeyUp);
|
|
3888
|
-
|
|
3986
|
+
this.observe?.disconnect();
|
|
3889
3987
|
this.observe = null;
|
|
3890
3988
|
}
|
|
3891
3989
|
/**
|
|
@@ -3908,21 +4006,19 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3908
4006
|
* 测量距离
|
|
3909
4007
|
* @returns
|
|
3910
4008
|
*/
|
|
3911
|
-
measureDistance() {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
resolve(distance);
|
|
3925
|
-
});
|
|
4009
|
+
async measureDistance() {
|
|
4010
|
+
this.cancelDistance();
|
|
4011
|
+
return new Promise((resolve, reject) => {
|
|
4012
|
+
this.changeMapType("2d", 0);
|
|
4013
|
+
this.context.control.enableRotate = false;
|
|
4014
|
+
this.svgLine = new SvgLine(this.context);
|
|
4015
|
+
const dispose2 = this.svgLine.dispose.bind(this.svgLine);
|
|
4016
|
+
this.svgLine.dispose = function() {
|
|
4017
|
+
dispose2();
|
|
4018
|
+
reject("cancel");
|
|
4019
|
+
};
|
|
4020
|
+
this.svgLine.addEventListener("distance", ({ distance }) => {
|
|
4021
|
+
resolve(distance);
|
|
3926
4022
|
});
|
|
3927
4023
|
});
|
|
3928
4024
|
}
|
|
@@ -3969,15 +4065,12 @@ var BMap = class extends EventDispatcher7 {
|
|
|
3969
4065
|
* 根据nodeId 获取graphic
|
|
3970
4066
|
*/
|
|
3971
4067
|
getGraphicByNodeId(nodeId) {
|
|
3972
|
-
|
|
3973
|
-
return ((_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.getGraphicByNodeId(nodeId)) || null;
|
|
4068
|
+
return this.context.currentFloor?.graphicLayer.getGraphicByNodeId(nodeId) || null;
|
|
3974
4069
|
}
|
|
3975
4070
|
deleteGraphic(graphic) {
|
|
3976
|
-
|
|
3977
|
-
(_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.removeGraphic(graphic);
|
|
4071
|
+
this.context.currentFloor?.graphicLayer.removeGraphic(graphic);
|
|
3978
4072
|
}
|
|
3979
4073
|
createGraphicByOptions(options) {
|
|
3980
|
-
var _a;
|
|
3981
4074
|
if (!options.transformToBuildingGround) {
|
|
3982
4075
|
if (this.currentBuildGround) {
|
|
3983
4076
|
const center2 = getCenter(
|
|
@@ -4001,19 +4094,16 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4001
4094
|
}
|
|
4002
4095
|
}
|
|
4003
4096
|
}
|
|
4004
|
-
return
|
|
4097
|
+
return this.context.currentFloor?.graphicLayer.createGraphic(options);
|
|
4005
4098
|
}
|
|
4006
4099
|
removePoiById(id) {
|
|
4007
|
-
|
|
4008
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.removePoiById(id);
|
|
4100
|
+
return this.context.currentFloor?.poiLayer.removePoiById(id);
|
|
4009
4101
|
}
|
|
4010
4102
|
getPoiById(id) {
|
|
4011
|
-
|
|
4012
|
-
return (_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.getPoiById(id);
|
|
4103
|
+
return this.context.currentFloor?.poiLayer.getPoiById(id);
|
|
4013
4104
|
}
|
|
4014
4105
|
getPois() {
|
|
4015
|
-
|
|
4016
|
-
return (((_a = this.context.currentFloor) == null ? void 0 : _a.poiLayer.pois) || []).filter(
|
|
4106
|
+
return (this.context.currentFloor?.poiLayer.pois || []).filter(
|
|
4017
4107
|
(item) => !item.options.built_in
|
|
4018
4108
|
);
|
|
4019
4109
|
}
|
|
@@ -4025,8 +4115,27 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4025
4115
|
removeSelectGraphic(graphic) {
|
|
4026
4116
|
this.context.selection.remove(graphic);
|
|
4027
4117
|
}
|
|
4118
|
+
resize = () => {
|
|
4119
|
+
this.context.cameraBound.setEnable(false);
|
|
4120
|
+
this.context.onWindowResize();
|
|
4121
|
+
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
4122
|
+
const zoom = this.context.camera.zoom;
|
|
4123
|
+
this.context.control.minZoom = 0;
|
|
4124
|
+
this.context.control.maxZoom = Infinity;
|
|
4125
|
+
this.context.camera.zoom = 1;
|
|
4126
|
+
this.context.setAzimuthalAngle(0, 0);
|
|
4127
|
+
const basicZoom = this.context.getFitCameraToGroundZoom(void 0, 0);
|
|
4128
|
+
this.basicZoom = basicZoom || 0;
|
|
4129
|
+
this.context.control.minZoom = this.basicZoom;
|
|
4130
|
+
this.context.control.maxZoom = this.basicZoom * 25;
|
|
4131
|
+
this.context.camera.zoom = zoom;
|
|
4132
|
+
this.context.control.addEventListener("change", this.onControlChange);
|
|
4133
|
+
this.context.setAzimuthalAngle(azimuthal, 0);
|
|
4134
|
+
this.context.cameraBound.setEnable(true);
|
|
4135
|
+
};
|
|
4028
4136
|
dispose() {
|
|
4029
4137
|
this.timer.dispose();
|
|
4138
|
+
this.plugins.forEach((plugin) => plugin.dispose());
|
|
4030
4139
|
this.context.dispose();
|
|
4031
4140
|
this.floorDataMap.clear();
|
|
4032
4141
|
this.buildingGroundMap.clear();
|
|
@@ -4040,6 +4149,9 @@ export {
|
|
|
4040
4149
|
BMap,
|
|
4041
4150
|
BaseSvg,
|
|
4042
4151
|
Context,
|
|
4152
|
+
Equipment,
|
|
4153
|
+
EventName,
|
|
4154
|
+
Events,
|
|
4043
4155
|
Floor,
|
|
4044
4156
|
Graphic,
|
|
4045
4157
|
GraphicLayer,
|
|
@@ -4048,6 +4160,7 @@ export {
|
|
|
4048
4160
|
Layer,
|
|
4049
4161
|
MapTypePolar,
|
|
4050
4162
|
Model,
|
|
4163
|
+
Navigation,
|
|
4051
4164
|
Overlay,
|
|
4052
4165
|
Poi,
|
|
4053
4166
|
PoiLayer,
|