gisviewer-vue3-arcgis 1.0.284 → 1.0.285

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.
Files changed (95) hide show
  1. package/es/index.mjs +6 -5
  2. package/es/src/gis-map/gis-map.vue.d.ts +124 -1
  3. package/es/src/gis-map/gis-map.vue.mjs +63 -63
  4. package/es/src/gis-map/index.d.ts +124 -1
  5. package/es/src/gis-map/utils/edpass-device-controller.mjs +278 -0
  6. package/es/src/gis-map/utils/green-wave-band-controller/index.mjs +362 -0
  7. package/es/src/gis-map/utils/holo-flow/index.mjs +101 -0
  8. package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +125 -0
  9. package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.mjs +153 -0
  10. package/es/src/gis-map/utils/holo-flow/signal-countdown-panel.vue2.mjs +4 -0
  11. package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +336 -0
  12. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +236 -0
  13. package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +106 -0
  14. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +576 -0
  15. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +386 -0
  16. package/es/src/gis-map/utils/index.mjs +2 -2
  17. package/es/src/gis-map/utils/police-jurisdiction.mjs +202 -0
  18. package/es/src/gis-map/utils/road-config-tool/cross.mjs +127 -0
  19. package/es/src/gis-map/utils/road-config-tool/entrance.mjs +79 -0
  20. package/es/src/gis-map/utils/road-config-tool/exit.mjs +86 -0
  21. package/es/src/gis-map/utils/road-config-tool/index.mjs +112 -0
  22. package/es/src/gis-map/utils/road-config-tool/indicator-area.mjs +44 -0
  23. package/es/src/gis-map/utils/road-config-tool/lane.mjs +35 -0
  24. package/es/src/gis-map/utils/road-config-tool/search-nearby-lanes.mjs +265 -0
  25. package/es/src/gis-map/utils/signal-control-area/cross-renderer.mjs +593 -0
  26. package/es/src/gis-map/utils/signal-control-area/district-controller.mjs +84 -0
  27. package/es/src/gis-map/utils/signal-control-area/district-renderer.mjs +122 -0
  28. package/es/src/gis-map/utils/signal-control-area/edit-area.mjs +550 -0
  29. package/es/src/gis-map/utils/signal-control-area/layer-symbol.mjs +984 -0
  30. package/es/src/gis-map/utils/signal-control-area/signal-area-controller.mjs +140 -0
  31. package/es/src/gis-map/utils/signal-control-area/signal-cross-controller.mjs +423 -0
  32. package/es/src/gis-map/utils/signal-control-area/signal-renderer.mjs +123 -0
  33. package/es/src/gis-map/utils/signal-control-area/sub-district-renderer.mjs +367 -0
  34. package/es/src/gis-map/utils/signal-system/signal-system-controller.mjs +137 -0
  35. package/es/src/gis-map/utils/sketchViewTool.mjs +503 -0
  36. package/es/src/gis-map-ol/gis-map-ol.vue.d.ts +50 -0
  37. package/es/src/gis-map-ol/gis-map-ol.vue.mjs +67 -0
  38. package/es/src/gis-map-ol/gis-map-ol.vue2.mjs +4 -0
  39. package/es/src/gis-map-ol/gis-map-ol.vue3.mjs +5 -0
  40. package/es/src/gis-map-ol/index.d.ts +44 -1
  41. package/es/src/gis-map-ol/index.mjs +8 -0
  42. package/es/src/gis-map-ol/utils/ol-map-initializer.d.ts +28 -0
  43. package/es/src/gis-map-ol/utils/ol-map-initializer.mjs +129 -0
  44. package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +42 -0
  45. package/es/src/gis-map-ol/utils/signal-control/signal-cross-controller.mjs +263 -0
  46. package/es/src/index.mjs +4 -4
  47. package/es/src/types/index.mjs +5 -0
  48. package/lib/index.js +1 -1
  49. package/lib/src/gis-map/gis-map.vue.d.ts +124 -1
  50. package/lib/src/gis-map/gis-map.vue.js +1 -1
  51. package/lib/src/gis-map/index.d.ts +124 -1
  52. package/lib/src/gis-map/utils/edpass-device-controller.js +1 -0
  53. package/lib/src/gis-map/utils/green-wave-band-controller/index.js +1 -0
  54. package/lib/src/gis-map/utils/holo-flow/index.js +1 -0
  55. package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.d.ts +125 -0
  56. package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue.js +1 -0
  57. package/lib/src/gis-map/utils/holo-flow/signal-countdown-panel.vue2.js +1 -0
  58. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -0
  59. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -0
  60. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +2 -0
  61. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -0
  62. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -0
  63. package/lib/src/gis-map/utils/index.js +1 -1
  64. package/lib/src/gis-map/utils/police-jurisdiction.js +1 -0
  65. package/lib/src/gis-map/utils/road-config-tool/cross.js +1 -0
  66. package/lib/src/gis-map/utils/road-config-tool/entrance.js +1 -0
  67. package/lib/src/gis-map/utils/road-config-tool/exit.js +1 -0
  68. package/lib/src/gis-map/utils/road-config-tool/index.js +1 -0
  69. package/lib/src/gis-map/utils/road-config-tool/indicator-area.js +1 -0
  70. package/lib/src/gis-map/utils/road-config-tool/lane.js +1 -0
  71. package/lib/src/gis-map/utils/road-config-tool/search-nearby-lanes.js +1 -0
  72. package/lib/src/gis-map/utils/signal-control-area/cross-renderer.js +1 -0
  73. package/lib/src/gis-map/utils/signal-control-area/district-controller.js +1 -0
  74. package/lib/src/gis-map/utils/signal-control-area/district-renderer.js +1 -0
  75. package/lib/src/gis-map/utils/signal-control-area/edit-area.js +1 -0
  76. package/lib/src/gis-map/utils/signal-control-area/layer-symbol.js +1 -0
  77. package/lib/src/gis-map/utils/signal-control-area/signal-area-controller.js +1 -0
  78. package/lib/src/gis-map/utils/signal-control-area/signal-cross-controller.js +1 -0
  79. package/lib/src/gis-map/utils/signal-control-area/signal-renderer.js +1 -0
  80. package/lib/src/gis-map/utils/signal-control-area/sub-district-renderer.js +1 -0
  81. package/lib/src/gis-map/utils/signal-system/signal-system-controller.js +1 -0
  82. package/lib/src/gis-map/utils/sketchViewTool.js +1 -0
  83. package/lib/src/gis-map-ol/gis-map-ol.vue.d.ts +50 -0
  84. package/lib/src/gis-map-ol/gis-map-ol.vue.js +1 -0
  85. package/lib/src/gis-map-ol/gis-map-ol.vue2.js +1 -0
  86. package/lib/src/gis-map-ol/gis-map-ol.vue3.js +1 -0
  87. package/lib/src/gis-map-ol/index.d.ts +44 -1
  88. package/lib/src/gis-map-ol/index.js +1 -0
  89. package/lib/src/gis-map-ol/utils/ol-map-initializer.d.ts +28 -0
  90. package/lib/src/gis-map-ol/utils/ol-map-initializer.js +1 -0
  91. package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.d.ts +42 -0
  92. package/lib/src/gis-map-ol/utils/signal-control/signal-cross-controller.js +1 -0
  93. package/lib/src/index.js +1 -1
  94. package/lib/src/types/index.js +1 -0
  95. package/package.json +1 -1
@@ -0,0 +1,576 @@
1
+ import * as v from "@arcgis/core/core/promiseUtils.js";
2
+ import * as y from "@arcgis/core/core/reactiveUtils.js";
3
+ import T from "@arcgis/core/geometry/SpatialReference";
4
+ import * as b from "@arcgis/core/views/3d/externalRenderers";
5
+ import * as a from "three";
6
+ import { DRACOLoader as C } from "three/examples/jsm/loaders/DRACOLoader";
7
+ import { GLTFLoader as f } from "three/examples/jsm/loaders/GLTFLoader";
8
+ import { MTLLoader as G } from "three/examples/jsm/loaders/MTLLoader";
9
+ import { OBJLoader as w } from "three/examples/jsm/loaders/OBJLoader";
10
+ import { toRaw as S } from "vue";
11
+ import B from "../../../stores/index.mjs";
12
+ import { EVehiclePlateState as m } from "../../../types/index.mjs";
13
+ class O {
14
+ constructor(t) {
15
+ this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new a.MeshPhongMaterial({
16
+ color: 16777215
17
+ }), this.materialMap = /* @__PURE__ */ new Map([
18
+ [1, this.createCarMaterial(16777215)],
19
+ [2, this.createCarMaterial(7833753)],
20
+ [3, this.createCarMaterial(16766720)],
21
+ [4, this.createCarMaterial(16758465)],
22
+ [5, this.createCarMaterial(14423100)],
23
+ [6, this.createCarMaterial(3329330)],
24
+ [7, this.createCarMaterial(2003183)],
25
+ [8, this.createCarMaterial(16032864)],
26
+ [9, this.createCarMaterial(2105376)],
27
+ [10, this.createCarMaterial(9662683)],
28
+ [99, this.createCarMaterial(6908265)]
29
+ ]), this.isInitialized = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.isPaused = !1, this.currentSpriteContent = m.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.tabVisible = !0, this.updateModel = !1, this.appDataStore = B.useAppDataStore, this.logTable = [
30
+ [
31
+ "ptcId",
32
+ "plateno",
33
+ "timestamp",
34
+ "localTimestamp",
35
+ "speed",
36
+ "longitude",
37
+ "latitude",
38
+ "ptcType",
39
+ "vehicleType",
40
+ "vehicleColor",
41
+ "plateColor",
42
+ "heading",
43
+ "fixAngle",
44
+ "roadLayer",
45
+ "step",
46
+ "receiveTimestamp",
47
+ "queueLength",
48
+ "status"
49
+ ]
50
+ ], this.view = t;
51
+ const s = S(this.appDataStore.mapConfig);
52
+ this.assetsRoot = s.assetsRoot, document.addEventListener(
53
+ "visibilitychange",
54
+ () => {
55
+ this.clearVehicles(), this.tabVisible = !document.hidden;
56
+ },
57
+ !1
58
+ ), y.watch(
59
+ () => this.view.camera.position.z,
60
+ (e, i) => {
61
+ (i <= this.cameraHeightThreshold && e > this.cameraHeightThreshold || i > this.cameraHeightThreshold && e <= this.cameraHeightThreshold) && (this.updateModel = !0);
62
+ }
63
+ );
64
+ }
65
+ // private readonly vehiclePool = new VehiclePool();
66
+ createCarMaterial(t) {
67
+ return new a.MeshPhongMaterial({
68
+ color: t
69
+ // // emissive: 0xc3c3c3,
70
+ // roughness: this.roughness,
71
+ // metalness: this.metalness
72
+ });
73
+ }
74
+ getLog() {
75
+ return this.logTable;
76
+ }
77
+ async init() {
78
+ await v.eachAlways([
79
+ new Promise((t) => {
80
+ const s = new C();
81
+ s.setDecoderPath(`${this.assetsRoot}/js/libs/draco/`), s.setDecoderConfig({ type: "wasm" }), s.preload();
82
+ const e = new f();
83
+ e.setDRACOLoader(s), e.load(`${this.assetsRoot}/3DModels/carDraco.glb`, (i) => {
84
+ const o = i.scene, r = new a.Box3().setFromObject(o).getSize(new a.Vector3());
85
+ this.carModel = new a.Object3D(), this.carModel.rotation.x = a.MathUtils.degToRad(90), this.carModel.add(o), o.position.set(0, 0, r.z / 2), t();
86
+ });
87
+ }),
88
+ new Promise((t) => {
89
+ new f().load(`${this.assetsRoot}/3DModels/van.glb`, (e) => {
90
+ const i = e.scene, l = new a.Box3().setFromObject(i).getSize(new a.Vector3());
91
+ this.vanModel = new a.Object3D(), this.vanModel.rotation.x = a.MathUtils.degToRad(90), this.vanModel.add(i), i.position.set(0, 0, l.z / 2), t();
92
+ });
93
+ }),
94
+ new Promise((t) => {
95
+ new f().load(`${this.assetsRoot}/3DModels/truck.glb`, (e) => {
96
+ const i = e.scene;
97
+ i.scale.set(1.2, 1, 1.5);
98
+ const l = new a.Box3().setFromObject(i).getSize(new a.Vector3());
99
+ this.truckModel = new a.Object3D(), this.truckModel.rotation.x = a.MathUtils.degToRad(90), this.truckModel.add(i), i.position.set(0, 0, l.z / 2), t();
100
+ });
101
+ }),
102
+ new Promise((t) => {
103
+ new f().load(`${this.assetsRoot}/3DModels/bus.glb`, (e) => {
104
+ const i = e.scene, l = new a.Box3().setFromObject(i).getSize(new a.Vector3());
105
+ this.busModel = new a.Object3D(), this.busModel.rotation.x = a.MathUtils.degToRad(90), this.busModel.add(i), i.position.set(0, 0, l.z / 2), t();
106
+ });
107
+ }),
108
+ new Promise((t) => {
109
+ new G().load(
110
+ `${this.assetsRoot}/3DModels/bicycle.mtl`,
111
+ (e) => {
112
+ e.preload();
113
+ const i = new w();
114
+ i.setMaterials(e), i.load(
115
+ `${this.assetsRoot}/3DModels/bicycle.obj`,
116
+ (o) => {
117
+ this.bicycleModel = o, this.bicycleModel.rotation.x = a.MathUtils.degToRad(90), t();
118
+ }
119
+ );
120
+ }
121
+ );
122
+ }),
123
+ new Promise((t) => {
124
+ new w().load(`${this.assetsRoot}/3DModels/male.obj`, (e) => {
125
+ e.scale.set(0.01, 0.01, 0.01), this.passengerModel = e, this.passengerModel.rotation.x = a.MathUtils.degToRad(90), this.passengerModel.rotation.y = a.MathUtils.degToRad(180), t();
126
+ });
127
+ }),
128
+ new Promise((t) => {
129
+ this.bluePlateBG = new Image(), this.bluePlateBG.src = `${this.assetsRoot}/Images/PlateBG/blue.png`, this.bluePlateBG.onload = () => {
130
+ t();
131
+ };
132
+ }),
133
+ new Promise((t) => {
134
+ this.yellowPlateBG = new Image(), this.yellowPlateBG.src = `${this.assetsRoot}/Images/PlateBG/yellow.png`, this.yellowPlateBG.onload = () => {
135
+ t();
136
+ };
137
+ }),
138
+ new Promise((t) => {
139
+ this.whitePlateBG = new Image(), this.whitePlateBG.src = `${this.assetsRoot}/Images/PlateBG/white.png`, this.whitePlateBG.onload = () => {
140
+ t();
141
+ };
142
+ }),
143
+ new Promise((t) => {
144
+ this.blackPlateBG = new Image(), this.blackPlateBG.src = `${this.assetsRoot}/Images/PlateBG/black.png`, this.blackPlateBG.onload = () => {
145
+ t();
146
+ };
147
+ }),
148
+ new Promise((t) => {
149
+ this.neoYellowPlateBG = new Image(), this.neoYellowPlateBG.src = `${this.assetsRoot}/Images/PlateBG/neo_yellow.png`, this.neoYellowPlateBG.onload = () => {
150
+ t();
151
+ };
152
+ }),
153
+ new Promise((t) => {
154
+ this.neoGreenPlateBG = new Image(), this.neoGreenPlateBG.src = `${this.assetsRoot}/Images/PlateBG/neo_green.png`, this.neoGreenPlateBG.onload = () => {
155
+ t();
156
+ };
157
+ }),
158
+ new Promise((t) => {
159
+ this.greyPlateBG = new Image(), this.greyPlateBG.src = `${this.assetsRoot}/Images/PlateBG/grey.png`, this.greyPlateBG.onload = () => {
160
+ t();
161
+ };
162
+ })
163
+ ]), this.isInitialized = !0;
164
+ }
165
+ setInterpolate(t) {
166
+ this.clearVehicles(), this.tabVisible = t;
167
+ }
168
+ async setup(t) {
169
+ this.context = t, this.renderer = new a.WebGLRenderer({
170
+ context: t.gl,
171
+ premultipliedAlpha: !0,
172
+ logarithmicDepthBuffer: !0,
173
+ antialias: !0,
174
+ powerPreference: "high-performance"
175
+ }), this.renderer.shadowMap.enabled = !0, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setViewport(0, 0, this.view.width, this.view.height), this.renderer.autoClearDepth = !1, this.renderer.autoClearStencil = !1, this.renderer.autoClearColor = !1;
176
+ const s = this.renderer.setRenderTarget.bind(
177
+ this.renderer
178
+ );
179
+ this.renderer.setRenderTarget = (i) => {
180
+ s(i), i == null && t.bindRenderTarget();
181
+ }, this.scene = new a.Scene();
182
+ const { camera: e } = t;
183
+ this.camera = new a.PerspectiveCamera(
184
+ e.fovY,
185
+ e.aspect,
186
+ 0.1,
187
+ 1e5
188
+ ), this.ambient = new a.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new a.DirectionalLight(16777215, 2), this.scene.add(this.sun), t.resetWebGLState();
189
+ }
190
+ async render(t) {
191
+ var i;
192
+ const s = t.camera;
193
+ if (this.camera.position.set(s.eye[0], s.eye[1], s.eye[2]), this.camera.up.set(s.up[0], s.up[1], s.up[2]), this.camera.lookAt(
194
+ new a.Vector3(s.center[0], s.center[1], s.center[2])
195
+ ), this.camera.projectionMatrix.fromArray(s.projectionMatrix), !this.isPaused && this.tabVisible)
196
+ for (const o of this.vehicleObjectMap.keys()) {
197
+ const l = (i = this.vehicleObjectMap.get(o)) == null ? void 0 : i.model;
198
+ if (!l)
199
+ continue;
200
+ const r = this.computeVehiclePosition(o);
201
+ if (r) {
202
+ const d = this.toRenderCoordinates(r);
203
+ l.position.set(d[0], d[1], d[2]), l.rotation.y = a.MathUtils.degToRad(-r[3]);
204
+ }
205
+ }
206
+ const e = t.sunLight;
207
+ this.sun.position.set(e.direction[0], e.direction[1], e.direction[2]), this.sun.intensity = e.diffuse.intensity, this.sun.color = new a.Color(
208
+ e.diffuse.color[0],
209
+ e.diffuse.color[1],
210
+ e.diffuse.color[2]
211
+ ), this.ambient.intensity = e.ambient.intensity, this.ambient.color = new a.Color(
212
+ e.ambient.color[0],
213
+ e.ambient.color[1],
214
+ e.ambient.color[2]
215
+ ), this.renderer.resetState(), t.bindRenderTarget(), this.renderer.render(this.scene, this.camera), b.requestRender(this.view), t.resetWebGLState();
216
+ }
217
+ /**
218
+ * 新增车辆
219
+ * */
220
+ async addVehicles(t) {
221
+ if (this.isPaused || !this.isInitialized || !this.tabVisible)
222
+ return;
223
+ const s = Date.now();
224
+ for (const e of t) {
225
+ if (this.historyPositionMap.has(e.vehicleId))
226
+ continue;
227
+ this.appDataStore.saveTrackLog && this.logTable.push([
228
+ e.ptcId,
229
+ e.plateNo,
230
+ e.timestamp,
231
+ e.localTimestamp,
232
+ e.speed,
233
+ e.x,
234
+ e.y,
235
+ e.ptcType,
236
+ e.vehicleType,
237
+ e.vehicleColor,
238
+ e.plateColor,
239
+ e.heading,
240
+ e.fixAngle,
241
+ e.roadLayer,
242
+ e.step,
243
+ s,
244
+ 0,
245
+ 0
246
+ ]);
247
+ const { vehicleId: i, localTimestamp: o } = e, l = Number(e.x), r = Number(e.y), d = Number(e.heading);
248
+ this.historyPositionMap.set(i, [
249
+ { pos: [l, r, 0], heading: d, time: o }
250
+ ]);
251
+ const h = this.getVehicleModel(e);
252
+ h.name = i, h.visible = !1;
253
+ try {
254
+ const n = await this.createPlateSprite(e);
255
+ n && (h.add(n), n.position.set(0, 5, -4));
256
+ } catch (n) {
257
+ console.log("createPlateSprite error:", n);
258
+ }
259
+ this.scene.add(h), this.vehicleObjectMap.set(i, {
260
+ model: h,
261
+ data: e,
262
+ waitForDelete: !1,
263
+ isMoving: !1
264
+ });
265
+ }
266
+ }
267
+ /**
268
+ * 更新车辆
269
+ * */
270
+ async updateVehicles(t) {
271
+ if (this.isPaused || !this.isInitialized || !this.tabVisible)
272
+ return;
273
+ const s = [], e = Date.now();
274
+ for (const i of t) {
275
+ const { vehicleId: o, localTimestamp: l } = i, r = Number(i.x), d = Number(i.y);
276
+ let h = Number(i.heading);
277
+ const n = this.vehicleObjectMap.get(o), p = this.historyPositionMap.get(
278
+ o
279
+ );
280
+ if (!n || !p)
281
+ s.push(i);
282
+ else {
283
+ if (this.appDataStore.saveTrackLog && this.logTable.push([
284
+ i.ptcId,
285
+ i.plateNo,
286
+ i.timestamp,
287
+ i.localTimestamp,
288
+ i.speed,
289
+ i.x,
290
+ i.y,
291
+ i.ptcType,
292
+ i.vehicleType,
293
+ i.vehicleColor,
294
+ i.plateColor,
295
+ i.heading,
296
+ i.fixAngle,
297
+ i.roadLayer,
298
+ i.step,
299
+ e,
300
+ p.length,
301
+ 1
302
+ ]), this.updateModel || n.data.vehicleColor !== i.vehicleColor || n.data.vehicleType !== i.vehicleType) {
303
+ this.scene.remove(n.model), this.disposeModel(n.model), n.model = this.getVehicleModel(i), n.model.visible = !0;
304
+ const c = await this.createPlateSprite(i);
305
+ c && (n.model.add(c), c.position.set(0, 5, -4)), this.scene.add(n.model);
306
+ }
307
+ if (n.data.showName !== i.showName || n.data.plateColor !== i.plateColor) {
308
+ const c = n.model.getObjectByName("VehiclePlate");
309
+ c && (n.model.remove(c), this.disposeModel(c));
310
+ const g = await this.createPlateSprite(i);
311
+ g && (n.model.add(g), g.position.set(0, 5, -4));
312
+ }
313
+ if (n.data = i, this.tabVisible) {
314
+ const c = p[p.length - 1];
315
+ Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), p.push({
316
+ pos: [r, d, 0],
317
+ heading: h,
318
+ time: l
319
+ });
320
+ } else {
321
+ this.historyPositionMap.set(o, [
322
+ { pos: [r, d, 0], heading: h, time: l }
323
+ ]);
324
+ const c = this.toRenderCoordinates([r, d, 0]);
325
+ n.model.position.set(c[0], c[1], c[2]), n.model.rotation.y = a.MathUtils.degToRad(-h);
326
+ }
327
+ }
328
+ }
329
+ await this.addVehicles(s), this.updateModel = !1;
330
+ }
331
+ toRenderCoordinates(t) {
332
+ const s = [0, 0, 0];
333
+ return b.toRenderCoordinates(
334
+ // @ts-ignore
335
+ this.view,
336
+ t,
337
+ 0,
338
+ T.WGS84,
339
+ s,
340
+ 0,
341
+ 1
342
+ ), s;
343
+ }
344
+ /**
345
+ * 删除车辆
346
+ * */
347
+ deleteVehicles(t) {
348
+ if (this.isPaused)
349
+ return;
350
+ const s = Date.now();
351
+ t.forEach((e) => {
352
+ if (this.appDataStore.saveTrackLog) {
353
+ const o = this.historyPositionMap.get(e);
354
+ this.logTable.push([
355
+ e,
356
+ "",
357
+ "",
358
+ "",
359
+ "",
360
+ "",
361
+ "",
362
+ "",
363
+ "",
364
+ "",
365
+ "",
366
+ "",
367
+ "",
368
+ "",
369
+ "",
370
+ s,
371
+ o ? o.length : 0,
372
+ 2
373
+ ]);
374
+ }
375
+ const i = this.vehicleObjectMap.get(e);
376
+ i && (this.tabVisible ? i.isMoving ? i.waitForDelete = !0 : this.deleteVehicle(i) : this.deleteVehicle(i));
377
+ });
378
+ }
379
+ deleteVehicle(t) {
380
+ t.model.visible = !1, this.disposeModel(t.model), this.scene.remove(t.model);
381
+ const s = t.data.vehicleId;
382
+ this.vehicleObjectMap.delete(s), this.historyPositionMap.delete(s);
383
+ }
384
+ async toggleTrafficInfo(t) {
385
+ t.name === "vehiclePlate" && (t.visible === !0 && this.currentSpriteContent === m.None ? await this.updatePanelContent(m.PlateNumber) : await this.updatePanelContent(
386
+ t.visible ? this.currentSpriteContent : m.None
387
+ ));
388
+ }
389
+ togglePause(t) {
390
+ this.isPaused = t;
391
+ }
392
+ /**
393
+ * 清除全部车辆
394
+ * */
395
+ clearVehicles() {
396
+ for (const t of this.vehicleObjectMap.values())
397
+ this.disposeModel(t.model), this.scene.remove(t.model);
398
+ this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
399
+ }
400
+ /**
401
+ * 设置号牌显示状态
402
+ * @param contentType
403
+ * @returns
404
+ */
405
+ async updatePanelContent(t) {
406
+ this.currentSpriteContent = t;
407
+ for (const s of this.vehicleObjectMap.values()) {
408
+ const e = s.model.getObjectByName("VehiclePlate");
409
+ if (e && (s.model.remove(e), this.disposeModel(e)), t !== m.None) {
410
+ const i = await this.createPlateSprite(s.data);
411
+ i && (s.model.add(i), i.position.set(0, 5, -4));
412
+ }
413
+ }
414
+ }
415
+ toggleGroundVehicle(t) {
416
+ this.showGroundVehicle = t;
417
+ }
418
+ toggleElevatedVehicle(t) {
419
+ this.showElevatedVehicle = t;
420
+ }
421
+ /**
422
+ * 释放模型资源
423
+ * */
424
+ disposeModel(t) {
425
+ t.traverse((s) => {
426
+ if (s instanceof a.Mesh)
427
+ try {
428
+ s.geometry.dispose(), s.material.dispose();
429
+ } catch {
430
+ }
431
+ });
432
+ }
433
+ /**
434
+ * 计算车辆位置
435
+ * */
436
+ computeVehiclePosition(t) {
437
+ const s = this.historyPositionMap.get(t), e = this.vehicleObjectMap.get(t);
438
+ if (!e || !s || !e.isMoving && s.length <= 2)
439
+ return;
440
+ const i = Date.now();
441
+ e.isMoving = !0, e.data.roadLayer === "1" ? e.model.visible = this.showGroundVehicle : e.model.visible = this.showElevatedVehicle, e.segmentStartTime || (e.segmentStartTime = i, e.segmentTotalTime = s[1].time - s[0].time);
442
+ const o = i - e.segmentStartTime, l = Math.min(
443
+ o / e.segmentTotalTime,
444
+ 1
445
+ );
446
+ if (l === 1)
447
+ if (s.shift(), s.length === 1) {
448
+ e.waitForDelete === !0 ? this.deleteVehicle(e) : (e.segmentStartTime = void 0, e.segmentTotalTime = void 0, e.model.visible = !1, e.isMoving = !1, console.log("hide vehicle", t));
449
+ return;
450
+ } else {
451
+ e.segmentStartTime = Date.now();
452
+ const r = o - e.segmentTotalTime;
453
+ return e.segmentTotalTime = s[1].time - s[0].time - r, Math.abs(s[1].heading - s[0].heading) > 180 && (s[1].heading > s[0].heading ? s[0].heading += 360 : s[1].heading += 360), s[0].pos.concat(s[0].heading);
454
+ }
455
+ else if (s.length >= 2) {
456
+ const r = s[0].pos[0] + (s[1].pos[0] - s[0].pos[0]) * l, d = s[0].pos[1] + (s[1].pos[1] - s[0].pos[1]) * l, h = s[0].heading + (s[1].heading - s[0].heading) * l;
457
+ return [r, d, 0, h];
458
+ } else
459
+ return;
460
+ }
461
+ /**
462
+ * 根据车辆类型、车身颜色获取模型
463
+ * */
464
+ getVehicleModel(t) {
465
+ if (this.view.camera.position.z >= this.cameraHeightThreshold) {
466
+ const s = new a.SphereGeometry(5, 32, 32), e = new a.MeshPhysicalMaterial({
467
+ color: 325253,
468
+ emissive: 0,
469
+ roughness: this.roughness,
470
+ metalness: this.metalness
471
+ });
472
+ return new a.Mesh(s, e);
473
+ } else {
474
+ let s;
475
+ if (t.ptcType === 2)
476
+ s = this.bicycleModel.clone();
477
+ else if (t.ptcType === 3)
478
+ s = this.passengerModel.clone();
479
+ else {
480
+ switch (t.vehicleType) {
481
+ case 10:
482
+ s = this.carModel.clone();
483
+ break;
484
+ case 20:
485
+ s = this.vanModel.clone();
486
+ break;
487
+ case 25:
488
+ s = this.truckModel.clone();
489
+ break;
490
+ case 50:
491
+ s = this.busModel.clone();
492
+ break;
493
+ default:
494
+ s = this.carModel.clone();
495
+ break;
496
+ }
497
+ const e = this.materialMap.get(t.vehicleColor) || this.defaultMaterial;
498
+ let i = !1;
499
+ s.traverse((o) => {
500
+ !i && o instanceof a.Mesh && (o.material = e, i = !0);
501
+ });
502
+ }
503
+ return s;
504
+ }
505
+ }
506
+ /**
507
+ * 创建号牌canvas
508
+ * */
509
+ createCanvas(t, s, e) {
510
+ const i = document.createElement("canvas"), o = t.width, l = t.height;
511
+ i.width = o, i.height = l;
512
+ const r = i.getContext("2d");
513
+ if (!r) {
514
+ console.log("canvas创建失败");
515
+ return;
516
+ }
517
+ return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, l), r.drawImage(t, 0, 0, o, l), r.beginPath(), r.translate(o / 2, l / 2), r.fillStyle = e, r.font = "bold 32px 宋体", r.textBaseline = "middle", r.textAlign = "center", r.fillText(s, 0, 0), i;
518
+ }
519
+ createPlateSprite(t) {
520
+ return new Promise((s, e) => {
521
+ var h, n;
522
+ const i = !t.plateNo || t.plateNo === "0" || t.plateNo === "000000";
523
+ if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber && i) {
524
+ s(void 0);
525
+ return;
526
+ }
527
+ let o = new Image(), l = "", r = "";
528
+ if (this.currentSpriteContent === m.PlateNumber || this.currentSpriteContent === m.Mix)
529
+ if (i)
530
+ o = this.greyPlateBG, l = t.ptcId, r = "#ffffff";
531
+ else
532
+ switch (l = ((h = t.showName) == null ? void 0 : h.substring(0, 2)) + "•" + ((n = t.showName) == null ? void 0 : n.substring(2)), t.plateColor) {
533
+ case 1:
534
+ o = this.bluePlateBG, r = "#ffffff";
535
+ break;
536
+ case 2:
537
+ o = this.yellowPlateBG, r = "#000000";
538
+ break;
539
+ case 3:
540
+ o = this.whitePlateBG, r = "#000000";
541
+ break;
542
+ case 4:
543
+ o = this.blackPlateBG, r = "#ffffff";
544
+ break;
545
+ case 5:
546
+ o = this.neoYellowPlateBG, r = "#000000";
547
+ break;
548
+ case 6:
549
+ o = this.neoGreenPlateBG, r = "#000000";
550
+ break;
551
+ default:
552
+ o = this.greyPlateBG, l = t.plateNo, r = "#ffffff";
553
+ break;
554
+ }
555
+ else
556
+ this.currentSpriteContent === m.Id && (o = this.greyPlateBG, l = t.ptcId, r = "#ffffff");
557
+ const d = this.createCanvas(o, l, r);
558
+ if (d) {
559
+ const p = new a.CanvasTexture(d), c = new a.SpriteMaterial({
560
+ map: p,
561
+ transparent: !1
562
+ }), g = new a.Sprite(c), u = 0.05, M = d.width * u, P = d.height * u;
563
+ g.scale.set(M, P, 1), g.name = "VehiclePlate", s(g);
564
+ } else {
565
+ e("canvas创建失败");
566
+ return;
567
+ }
568
+ o.onerror = (p) => {
569
+ console.log(`号牌背景加载失败: ${o.src}`, p), e(p);
570
+ };
571
+ });
572
+ }
573
+ }
574
+ export {
575
+ O as default
576
+ };