gisviewer-vue3-arcgis 1.0.170 → 1.0.172
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/es/src/gis-map/gis-map.vue.d.ts +4 -4
- package/es/src/gis-map/gis-map.vue.mjs +98 -99
- package/es/src/gis-map/index.d.ts +2 -2
- package/es/src/gis-map/utils/holo-flow/index.d.ts +3 -2
- package/es/src/gis-map/utils/holo-flow/index.mjs +9 -6
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +3 -8
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.mjs +94 -95
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +132 -125
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +19 -19
- package/lib/src/gis-map/gis-map.vue.d.ts +4 -4
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +2 -2
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +3 -2
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.d.ts +3 -8
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow-lsr.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as b from "@arcgis/core/core/promiseUtils.js";
|
|
2
2
|
import * as P from "@arcgis/core/core/reactiveUtils.js";
|
|
3
3
|
import v from "@arcgis/core/geometry/SpatialReference";
|
|
4
4
|
import * as u from "@arcgis/core/views/3d/externalRenderers";
|
|
@@ -8,7 +8,7 @@ import { toRaw as T } from "vue";
|
|
|
8
8
|
import { EVehiclePlateState as m } from "../../../types/index.mjs";
|
|
9
9
|
import C from "../../stores/index.mjs";
|
|
10
10
|
class V {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(i) {
|
|
12
12
|
this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new a.MeshPhongMaterial({
|
|
13
13
|
color: 16777215
|
|
14
14
|
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
@@ -44,19 +44,19 @@ class V {
|
|
|
44
44
|
"queueLength",
|
|
45
45
|
"status"
|
|
46
46
|
]
|
|
47
|
-
], this.view =
|
|
47
|
+
], this.view = i;
|
|
48
48
|
const e = T(this.appDataStore.mapConfig);
|
|
49
49
|
this.assetsRoot = e.assetsRoot, P.watch(
|
|
50
50
|
() => this.view.camera.position.z,
|
|
51
|
-
(t,
|
|
52
|
-
(
|
|
51
|
+
(t, s) => {
|
|
52
|
+
(s <= this.cameraHeightThreshold && t > this.cameraHeightThreshold || s > this.cameraHeightThreshold && t <= this.cameraHeightThreshold) && (this.updateModel = !0);
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
// private readonly vehiclePool = new VehiclePool();
|
|
57
|
-
createCarMaterial(
|
|
57
|
+
createCarMaterial(i) {
|
|
58
58
|
return new a.MeshPhongMaterial({
|
|
59
|
-
color:
|
|
59
|
+
color: i
|
|
60
60
|
// // emissive: 0xc3c3c3,
|
|
61
61
|
// roughness: this.roughness,
|
|
62
62
|
// metalness: this.metalness
|
|
@@ -66,39 +66,44 @@ class V {
|
|
|
66
66
|
return this.logTable;
|
|
67
67
|
}
|
|
68
68
|
async init() {
|
|
69
|
-
const
|
|
70
|
-
await
|
|
69
|
+
const i = new y();
|
|
70
|
+
await b.eachAlways([
|
|
71
71
|
new Promise((e) => {
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
this.carModel = new a.Object3D(), this.carModel.rotation.x = a.MathUtils.degToRad(90), this.carModel.add(
|
|
72
|
+
i.load(`${this.assetsRoot}/3DModels/car.glb`, (t) => {
|
|
73
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
74
|
+
this.carModel = new a.Object3D(), this.carModel.rotation.x = a.MathUtils.degToRad(90), this.carModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
75
75
|
});
|
|
76
76
|
}),
|
|
77
77
|
new Promise((e) => {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
this.vanModel = new a.Object3D(), this.vanModel.rotation.x = a.MathUtils.degToRad(90), this.vanModel.add(
|
|
78
|
+
i.load(`${this.assetsRoot}/3DModels/van.glb`, (t) => {
|
|
79
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
80
|
+
this.vanModel = new a.Object3D(), this.vanModel.rotation.x = a.MathUtils.degToRad(90), this.vanModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
81
81
|
});
|
|
82
82
|
}),
|
|
83
83
|
new Promise((e) => {
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const n = new a.Box3().setFromObject(
|
|
88
|
-
this.truckModel = new a.Object3D(), this.truckModel.rotation.x = a.MathUtils.degToRad(90), this.truckModel.add(
|
|
84
|
+
i.load(`${this.assetsRoot}/3DModels/truck.glb`, (t) => {
|
|
85
|
+
const s = t.scene;
|
|
86
|
+
s.scale.set(1.2, 1, 1.5);
|
|
87
|
+
const n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
88
|
+
this.truckModel = new a.Object3D(), this.truckModel.rotation.x = a.MathUtils.degToRad(90), this.truckModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
89
89
|
});
|
|
90
90
|
}),
|
|
91
91
|
new Promise((e) => {
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
this.busModel = new a.Object3D(), this.busModel.rotation.x = a.MathUtils.degToRad(90), this.busModel.add(
|
|
92
|
+
i.load(`${this.assetsRoot}/3DModels/bus.glb`, (t) => {
|
|
93
|
+
const s = t.scene, n = new a.Box3().setFromObject(s).getSize(new a.Vector3());
|
|
94
|
+
this.busModel = new a.Object3D(), this.busModel.rotation.x = a.MathUtils.degToRad(90), this.busModel.add(s), s.position.set(0, 0, n.z / 2), e();
|
|
95
95
|
});
|
|
96
96
|
}),
|
|
97
97
|
new Promise((e) => {
|
|
98
|
-
|
|
98
|
+
i.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (t) => {
|
|
99
99
|
this.bicycleModel = t.scene, this.bicycleModel.rotation.x = a.MathUtils.degToRad(90), this.bicycleModel.rotation.y = a.MathUtils.degToRad(180), e();
|
|
100
100
|
});
|
|
101
101
|
}),
|
|
102
|
+
new Promise((e) => {
|
|
103
|
+
i.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (t) => {
|
|
104
|
+
this.passengerModel = t.scene, this.passengerModel.rotation.x = a.MathUtils.degToRad(90), this.passengerModel.rotation.y = a.MathUtils.degToRad(180), e();
|
|
105
|
+
});
|
|
106
|
+
}),
|
|
102
107
|
new Promise((e) => {
|
|
103
108
|
this.bluePlateBG = new Image(), this.bluePlateBG.src = `${this.assetsRoot}/Images/PlateBG/blue.png`, this.bluePlateBG.onload = () => {
|
|
104
109
|
e();
|
|
@@ -136,12 +141,12 @@ class V {
|
|
|
136
141
|
})
|
|
137
142
|
]), this.isInitialized = !0;
|
|
138
143
|
}
|
|
139
|
-
setInterpolate(
|
|
140
|
-
this.clearVehicles(), this.needInterpolate =
|
|
144
|
+
setInterpolate(i) {
|
|
145
|
+
this.clearVehicles(), this.needInterpolate = i;
|
|
141
146
|
}
|
|
142
|
-
async setup(
|
|
143
|
-
this.context =
|
|
144
|
-
context:
|
|
147
|
+
async setup(i) {
|
|
148
|
+
this.context = i, this.renderer = new a.WebGLRenderer({
|
|
149
|
+
context: i.gl,
|
|
145
150
|
premultipliedAlpha: !0,
|
|
146
151
|
logarithmicDepthBuffer: !0,
|
|
147
152
|
antialias: !0,
|
|
@@ -150,25 +155,25 @@ class V {
|
|
|
150
155
|
const e = this.renderer.setRenderTarget.bind(
|
|
151
156
|
this.renderer
|
|
152
157
|
);
|
|
153
|
-
this.renderer.setRenderTarget = (
|
|
154
|
-
e(
|
|
158
|
+
this.renderer.setRenderTarget = (s) => {
|
|
159
|
+
e(s), s == null && i.bindRenderTarget();
|
|
155
160
|
}, this.scene = new a.Scene();
|
|
156
|
-
const { camera: t } =
|
|
161
|
+
const { camera: t } = i;
|
|
157
162
|
this.camera = new a.PerspectiveCamera(
|
|
158
163
|
t.fovY,
|
|
159
164
|
t.aspect,
|
|
160
165
|
0.1,
|
|
161
166
|
1e5
|
|
162
|
-
), this.ambient = new a.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new a.DirectionalLight(16777215, 2), this.scene.add(this.sun),
|
|
167
|
+
), this.ambient = new a.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new a.DirectionalLight(16777215, 2), this.scene.add(this.sun), i.resetWebGLState();
|
|
163
168
|
}
|
|
164
|
-
async render(
|
|
165
|
-
var
|
|
166
|
-
const e =
|
|
169
|
+
async render(i) {
|
|
170
|
+
var s;
|
|
171
|
+
const e = i.camera;
|
|
167
172
|
if (this.camera.position.set(e.eye[0], e.eye[1], e.eye[2]), this.camera.up.set(e.up[0], e.up[1], e.up[2]), this.camera.lookAt(
|
|
168
173
|
new a.Vector3(e.center[0], e.center[1], e.center[2])
|
|
169
174
|
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
|
|
170
175
|
for (const o of this.vehicleObjectMap.keys()) {
|
|
171
|
-
const n = (
|
|
176
|
+
const n = (s = this.vehicleObjectMap.get(o)) == null ? void 0 : s.model;
|
|
172
177
|
if (!n)
|
|
173
178
|
continue;
|
|
174
179
|
const r = this.computeVehiclePosition(o);
|
|
@@ -177,7 +182,7 @@ class V {
|
|
|
177
182
|
n.position.set(d[0], d[1], d[2]), n.rotation.y = a.MathUtils.degToRad(-r[3]);
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
|
-
const t =
|
|
185
|
+
const t = i.sunLight;
|
|
181
186
|
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new a.Color(
|
|
182
187
|
t.diffuse.color[0],
|
|
183
188
|
t.diffuse.color[1],
|
|
@@ -186,16 +191,16 @@ class V {
|
|
|
186
191
|
t.ambient.color[0],
|
|
187
192
|
t.ambient.color[1],
|
|
188
193
|
t.ambient.color[2]
|
|
189
|
-
), this.renderer.resetState(),
|
|
194
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), u.requestRender(this.view), i.resetWebGLState();
|
|
190
195
|
}
|
|
191
196
|
/**
|
|
192
197
|
* 新增车辆
|
|
193
198
|
* */
|
|
194
|
-
async addVehicles(
|
|
199
|
+
async addVehicles(i) {
|
|
195
200
|
if (this.isPaused || !this.isInitialized)
|
|
196
201
|
return;
|
|
197
202
|
const e = Date.now();
|
|
198
|
-
for (const t of
|
|
203
|
+
for (const t of i) {
|
|
199
204
|
this.appDataStore.saveTrackLog && this.logTable.push([
|
|
200
205
|
t.ptcId,
|
|
201
206
|
t.plateNo,
|
|
@@ -216,19 +221,19 @@ class V {
|
|
|
216
221
|
0,
|
|
217
222
|
0
|
|
218
223
|
]);
|
|
219
|
-
const { vehicleId:
|
|
220
|
-
this.historyPositionMap.set(
|
|
224
|
+
const { vehicleId: s, localTimestamp: o } = t, n = Number(t.x), r = Number(t.y), d = Number(t.heading);
|
|
225
|
+
this.historyPositionMap.set(s, [
|
|
221
226
|
{ pos: [n, r, 0], heading: d, time: o }
|
|
222
227
|
]);
|
|
223
228
|
const h = this.getVehicleModel(t);
|
|
224
|
-
h.name =
|
|
229
|
+
h.name = s, h.visible = !1;
|
|
225
230
|
try {
|
|
226
231
|
const l = await this.createPlateSprite(t);
|
|
227
232
|
l && (h.add(l), l.position.set(0, 5, -4));
|
|
228
233
|
} catch (l) {
|
|
229
234
|
console.log("createPlateSprite error:", l);
|
|
230
235
|
}
|
|
231
|
-
this.scene.add(h), this.vehicleObjectMap.set(
|
|
236
|
+
this.scene.add(h), this.vehicleObjectMap.set(s, {
|
|
232
237
|
model: h,
|
|
233
238
|
data: t,
|
|
234
239
|
waitForDelete: !1,
|
|
@@ -239,50 +244,50 @@ class V {
|
|
|
239
244
|
/**
|
|
240
245
|
* 更新车辆
|
|
241
246
|
* */
|
|
242
|
-
async updateVehicles(
|
|
247
|
+
async updateVehicles(i) {
|
|
243
248
|
if (this.isPaused || !this.isInitialized)
|
|
244
249
|
return;
|
|
245
250
|
const e = [], t = Date.now();
|
|
246
|
-
for (const
|
|
247
|
-
const { vehicleId: o, localTimestamp: n } =
|
|
248
|
-
let h = Number(
|
|
251
|
+
for (const s of i) {
|
|
252
|
+
const { vehicleId: o, localTimestamp: n } = s, r = Number(s.x), d = Number(s.y);
|
|
253
|
+
let h = Number(s.heading);
|
|
249
254
|
const l = this.vehicleObjectMap.get(o), p = this.historyPositionMap.get(
|
|
250
255
|
o
|
|
251
256
|
);
|
|
252
257
|
if (!l || !p)
|
|
253
|
-
e.push(
|
|
258
|
+
e.push(s);
|
|
254
259
|
else {
|
|
255
260
|
if (this.appDataStore.saveTrackLog && this.logTable.push([
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
261
|
+
s.ptcId,
|
|
262
|
+
s.plateNo,
|
|
263
|
+
s.timestamp,
|
|
264
|
+
s.localTimestamp,
|
|
265
|
+
s.speed,
|
|
266
|
+
s.x,
|
|
267
|
+
s.y,
|
|
268
|
+
s.ptcType,
|
|
269
|
+
s.vehicleType,
|
|
270
|
+
s.vehicleColor,
|
|
271
|
+
s.plateColor,
|
|
272
|
+
s.heading,
|
|
273
|
+
s.fixAngle,
|
|
274
|
+
s.roadLayer,
|
|
275
|
+
s.step,
|
|
271
276
|
t,
|
|
272
277
|
p.length,
|
|
273
278
|
1
|
|
274
|
-
]), this.updateModel || l.data.vehicleColor !==
|
|
275
|
-
this.scene.remove(l.model), this.disposeModel(l.model), l.model = this.getVehicleModel(
|
|
276
|
-
const c = await this.createPlateSprite(
|
|
279
|
+
]), this.updateModel || l.data.vehicleColor !== s.vehicleColor || l.data.vehicleType !== s.vehicleType) {
|
|
280
|
+
this.scene.remove(l.model), this.disposeModel(l.model), l.model = this.getVehicleModel(s), l.model.visible = !0;
|
|
281
|
+
const c = await this.createPlateSprite(s);
|
|
277
282
|
c && (l.model.add(c), c.position.set(0, 5, -4)), this.scene.add(l.model);
|
|
278
283
|
}
|
|
279
|
-
if (l.data.showName !==
|
|
284
|
+
if (l.data.showName !== s.showName || l.data.plateColor !== s.plateColor) {
|
|
280
285
|
const c = l.model.getObjectByName("VehiclePlate");
|
|
281
286
|
c && (l.model.remove(c), this.disposeModel(c));
|
|
282
|
-
const g = await this.createPlateSprite(
|
|
287
|
+
const g = await this.createPlateSprite(s);
|
|
283
288
|
g && (l.model.add(g), g.position.set(0, 5, -4));
|
|
284
289
|
}
|
|
285
|
-
if (l.data =
|
|
290
|
+
if (l.data = s, this.needInterpolate) {
|
|
286
291
|
const c = p[p.length - 1];
|
|
287
292
|
Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), p.push({
|
|
288
293
|
pos: [r, d, 0],
|
|
@@ -300,12 +305,12 @@ class V {
|
|
|
300
305
|
}
|
|
301
306
|
await this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
302
307
|
}
|
|
303
|
-
toRenderCoordinates(
|
|
308
|
+
toRenderCoordinates(i) {
|
|
304
309
|
const e = [0, 0, 0];
|
|
305
310
|
return u.toRenderCoordinates(
|
|
306
311
|
// @ts-ignore
|
|
307
312
|
this.view,
|
|
308
|
-
|
|
313
|
+
i,
|
|
309
314
|
0,
|
|
310
315
|
v.WGS84,
|
|
311
316
|
e,
|
|
@@ -316,11 +321,11 @@ class V {
|
|
|
316
321
|
/**
|
|
317
322
|
* 删除车辆
|
|
318
323
|
* */
|
|
319
|
-
deleteVehicles(
|
|
324
|
+
deleteVehicles(i) {
|
|
320
325
|
if (this.isPaused)
|
|
321
326
|
return;
|
|
322
327
|
const e = Date.now();
|
|
323
|
-
|
|
328
|
+
i.forEach((t) => {
|
|
324
329
|
if (this.appDataStore.saveTrackLog) {
|
|
325
330
|
const o = this.historyPositionMap.get(t);
|
|
326
331
|
this.logTable.push([
|
|
@@ -344,29 +349,29 @@ class V {
|
|
|
344
349
|
2
|
|
345
350
|
]);
|
|
346
351
|
}
|
|
347
|
-
const
|
|
348
|
-
|
|
352
|
+
const s = this.vehicleObjectMap.get(t);
|
|
353
|
+
s && (this.needInterpolate ? s.isMoving ? s.waitForDelete = !0 : this.deleteVehicle(s) : this.deleteVehicle(s));
|
|
349
354
|
});
|
|
350
355
|
}
|
|
351
|
-
deleteVehicle(
|
|
352
|
-
this.scene.remove(
|
|
353
|
-
const e =
|
|
356
|
+
deleteVehicle(i) {
|
|
357
|
+
this.scene.remove(i.model), this.disposeModel(i.model);
|
|
358
|
+
const e = i.data.vehicleId;
|
|
354
359
|
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
355
360
|
}
|
|
356
|
-
async toggleTrafficInfo(
|
|
357
|
-
|
|
358
|
-
|
|
361
|
+
async toggleTrafficInfo(i) {
|
|
362
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === m.None ? await this.updatePanelContent(m.PlateNumber) : await this.updatePanelContent(
|
|
363
|
+
i.visible ? this.currentSpriteContent : m.None
|
|
359
364
|
));
|
|
360
365
|
}
|
|
361
|
-
togglePause(
|
|
362
|
-
this.isPaused =
|
|
366
|
+
togglePause(i) {
|
|
367
|
+
this.isPaused = i;
|
|
363
368
|
}
|
|
364
369
|
/**
|
|
365
370
|
* 清除全部车辆
|
|
366
371
|
* */
|
|
367
372
|
clearVehicles() {
|
|
368
|
-
for (const
|
|
369
|
-
const e = this.vehicleObjectMap.get(
|
|
373
|
+
for (const i of this.vehicleObjectMap.keys()) {
|
|
374
|
+
const e = this.vehicleObjectMap.get(i);
|
|
370
375
|
e && (this.scene.remove(e.model), this.disposeModel(e.model));
|
|
371
376
|
}
|
|
372
377
|
this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
|
|
@@ -376,14 +381,14 @@ class V {
|
|
|
376
381
|
* @param contentType
|
|
377
382
|
* @returns
|
|
378
383
|
*/
|
|
379
|
-
async updatePanelContent(
|
|
380
|
-
if (
|
|
381
|
-
this.currentSpriteContent =
|
|
384
|
+
async updatePanelContent(i) {
|
|
385
|
+
if (i !== this.currentSpriteContent) {
|
|
386
|
+
this.currentSpriteContent = i;
|
|
382
387
|
for (const e of this.vehicleObjectMap.keys()) {
|
|
383
388
|
const t = this.vehicleObjectMap.get(e);
|
|
384
389
|
if (t) {
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
390
|
+
const s = t.model.getObjectByName("VehiclePlate");
|
|
391
|
+
if (s && (t.model.remove(s), this.disposeModel(s)), i !== m.None) {
|
|
387
392
|
const o = await this.createPlateSprite(t.data);
|
|
388
393
|
o && (t.model.add(o), o.position.set(0, 5, -4));
|
|
389
394
|
}
|
|
@@ -391,36 +396,36 @@ class V {
|
|
|
391
396
|
}
|
|
392
397
|
}
|
|
393
398
|
}
|
|
394
|
-
toggleGroundVehicle(
|
|
395
|
-
console.log("toggleGroundVehicle",
|
|
399
|
+
toggleGroundVehicle(i) {
|
|
400
|
+
console.log("toggleGroundVehicle", i), this.showGroundVehicle = i;
|
|
396
401
|
}
|
|
397
|
-
toggleElevatedVehicle(
|
|
398
|
-
this.showElevatedVehicle =
|
|
402
|
+
toggleElevatedVehicle(i) {
|
|
403
|
+
this.showElevatedVehicle = i;
|
|
399
404
|
}
|
|
400
405
|
/**
|
|
401
406
|
* 释放模型资源
|
|
402
407
|
* */
|
|
403
|
-
disposeModel(
|
|
404
|
-
|
|
408
|
+
disposeModel(i) {
|
|
409
|
+
i.traverse((e) => {
|
|
405
410
|
e instanceof a.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
406
411
|
});
|
|
407
412
|
}
|
|
408
413
|
/**
|
|
409
414
|
* 计算车辆位置
|
|
410
415
|
* */
|
|
411
|
-
computeVehiclePosition(
|
|
412
|
-
const e = this.historyPositionMap.get(
|
|
416
|
+
computeVehiclePosition(i) {
|
|
417
|
+
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
413
418
|
if (!t || !e || !t.isMoving && e.length <= 2)
|
|
414
419
|
return;
|
|
415
|
-
const
|
|
416
|
-
t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime =
|
|
417
|
-
const o =
|
|
420
|
+
const s = Date.now();
|
|
421
|
+
t.isMoving = !0, t.data.roadLayer === "1" ? t.model.visible = this.showGroundVehicle : t.model.visible = this.showElevatedVehicle, t.segmentStartTime || (t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time);
|
|
422
|
+
const o = s - t.segmentStartTime, n = Math.min(
|
|
418
423
|
o / t.segmentTotalTime,
|
|
419
424
|
1
|
|
420
425
|
);
|
|
421
426
|
if (n === 1)
|
|
422
427
|
if (e.shift(), e.length === 1) {
|
|
423
|
-
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("hide vehicle",
|
|
428
|
+
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("hide vehicle", i));
|
|
424
429
|
return;
|
|
425
430
|
} else {
|
|
426
431
|
t.segmentStartTime = Date.now();
|
|
@@ -436,7 +441,7 @@ class V {
|
|
|
436
441
|
/**
|
|
437
442
|
* 根据车辆类型、车身颜色获取模型
|
|
438
443
|
* */
|
|
439
|
-
getVehicleModel(
|
|
444
|
+
getVehicleModel(i) {
|
|
440
445
|
if (this.view.camera.position.z >= this.cameraHeightThreshold) {
|
|
441
446
|
const e = new a.SphereGeometry(5, 32, 32), t = new a.MeshPhysicalMaterial({
|
|
442
447
|
color: 325253,
|
|
@@ -447,10 +452,12 @@ class V {
|
|
|
447
452
|
return new a.Mesh(e, t);
|
|
448
453
|
} else {
|
|
449
454
|
let e;
|
|
450
|
-
if (
|
|
455
|
+
if (i.ptcType === 2)
|
|
451
456
|
e = this.bicycleModel.clone();
|
|
457
|
+
else if (i.ptcType === 3)
|
|
458
|
+
e = this.passengerModel.clone();
|
|
452
459
|
else {
|
|
453
|
-
switch (
|
|
460
|
+
switch (i.vehicleType) {
|
|
454
461
|
case 10:
|
|
455
462
|
e = this.carModel.clone();
|
|
456
463
|
break;
|
|
@@ -467,10 +474,10 @@ class V {
|
|
|
467
474
|
e = this.carModel.clone();
|
|
468
475
|
break;
|
|
469
476
|
}
|
|
470
|
-
const t = this.materialMap.get(
|
|
471
|
-
let
|
|
477
|
+
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
478
|
+
let s = !1;
|
|
472
479
|
e.traverse((o) => {
|
|
473
|
-
!
|
|
480
|
+
!s && o instanceof a.Mesh && (o.material = t, s = !0);
|
|
474
481
|
});
|
|
475
482
|
}
|
|
476
483
|
return e;
|
|
@@ -479,30 +486,30 @@ class V {
|
|
|
479
486
|
/**
|
|
480
487
|
* 创建号牌canvas
|
|
481
488
|
* */
|
|
482
|
-
createCanvas(
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
const r =
|
|
489
|
+
createCanvas(i, e, t) {
|
|
490
|
+
const s = document.createElement("canvas"), o = i.width, n = i.height;
|
|
491
|
+
s.width = o, s.height = n;
|
|
492
|
+
const r = s.getContext("2d");
|
|
486
493
|
if (!r) {
|
|
487
494
|
console.log("canvas创建失败");
|
|
488
495
|
return;
|
|
489
496
|
}
|
|
490
|
-
return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, n), r.drawImage(
|
|
497
|
+
return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, n), r.drawImage(i, 0, 0, o, n), r.beginPath(), r.translate(o / 2, n / 2), r.fillStyle = t, r.font = "bold 32px 宋体", r.textBaseline = "middle", r.textAlign = "center", r.fillText(e, 0, 0), s;
|
|
491
498
|
}
|
|
492
|
-
createPlateSprite(
|
|
499
|
+
createPlateSprite(i) {
|
|
493
500
|
return new Promise((e, t) => {
|
|
494
501
|
var h, l;
|
|
495
|
-
const
|
|
496
|
-
if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber &&
|
|
502
|
+
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
503
|
+
if (this.currentSpriteContent === m.None || this.currentSpriteContent === m.PlateNumber && s) {
|
|
497
504
|
e(void 0);
|
|
498
505
|
return;
|
|
499
506
|
}
|
|
500
507
|
let o = new Image(), n = "", r = "";
|
|
501
508
|
if (this.currentSpriteContent === m.PlateNumber || this.currentSpriteContent === m.Mix)
|
|
502
|
-
if (
|
|
503
|
-
o = this.greyPlateBG, n =
|
|
509
|
+
if (s)
|
|
510
|
+
o = this.greyPlateBG, n = i.ptcId, r = "#ffffff";
|
|
504
511
|
else
|
|
505
|
-
switch (n = ((h =
|
|
512
|
+
switch (n = ((h = i.showName) == null ? void 0 : h.substring(0, 2)) + "•" + ((l = i.showName) == null ? void 0 : l.substring(2)), i.plateColor) {
|
|
506
513
|
case 1:
|
|
507
514
|
o = this.bluePlateBG, r = "#ffffff";
|
|
508
515
|
break;
|
|
@@ -522,18 +529,18 @@ class V {
|
|
|
522
529
|
o = this.neoGreenPlateBG, r = "#000000";
|
|
523
530
|
break;
|
|
524
531
|
default:
|
|
525
|
-
o = this.greyPlateBG, n =
|
|
532
|
+
o = this.greyPlateBG, n = i.plateNo, r = "#ffffff";
|
|
526
533
|
break;
|
|
527
534
|
}
|
|
528
535
|
else
|
|
529
|
-
this.currentSpriteContent === m.Id && (o = this.greyPlateBG, n =
|
|
536
|
+
this.currentSpriteContent === m.Id && (o = this.greyPlateBG, n = i.ptcId, r = "#ffffff");
|
|
530
537
|
const d = this.createCanvas(o, n, r);
|
|
531
538
|
if (d) {
|
|
532
539
|
const p = new a.CanvasTexture(d), c = new a.SpriteMaterial({
|
|
533
540
|
map: p,
|
|
534
541
|
transparent: !1
|
|
535
|
-
}), g = new a.Sprite(c), f = 0.05, w = d.width * f,
|
|
536
|
-
g.scale.set(w,
|
|
542
|
+
}), g = new a.Sprite(c), f = 0.05, w = d.width * f, M = d.height * f;
|
|
543
|
+
g.scale.set(w, M, 1), g.name = "VehiclePlate", e(g);
|
|
537
544
|
} else {
|
|
538
545
|
t("canvas创建失败");
|
|
539
546
|
return;
|
|
@@ -323,7 +323,7 @@ class O {
|
|
|
323
323
|
* @returns
|
|
324
324
|
*/
|
|
325
325
|
async showOpenDriveFromFile(e) {
|
|
326
|
-
var
|
|
326
|
+
var f, m;
|
|
327
327
|
this.openDriveClickCallback = e.selectedCallback, this.scaleWatch = $.watch(
|
|
328
328
|
() => this.view.scale,
|
|
329
329
|
(h, p) => {
|
|
@@ -381,7 +381,7 @@ class O {
|
|
|
381
381
|
const a = await (await fetch(c)).arrayBuffer(), n = G.inflate(a, { to: "string" }), l = JSON.parse(n);
|
|
382
382
|
await this.showAllLanes(
|
|
383
383
|
l,
|
|
384
|
-
((
|
|
384
|
+
((f = e.options) == null ? void 0 : f.showJunctionLane) || !1,
|
|
385
385
|
((m = e.options) == null ? void 0 : m.showRoadName) || !0
|
|
386
386
|
);
|
|
387
387
|
const d = o.data.result.junctions;
|
|
@@ -438,7 +438,7 @@ class O {
|
|
|
438
438
|
const { id: l, refLine: d } = n;
|
|
439
439
|
let u = n.name;
|
|
440
440
|
u.includes("(") && (u = u.slice(0, u.indexOf("("))), u = u.replace(/(.)/g, "$1 ");
|
|
441
|
-
const
|
|
441
|
+
const f = new g({
|
|
442
442
|
geometry: {
|
|
443
443
|
type: "polyline",
|
|
444
444
|
paths: [d]
|
|
@@ -449,21 +449,21 @@ class O {
|
|
|
449
449
|
roadName: u
|
|
450
450
|
}
|
|
451
451
|
});
|
|
452
|
-
this.allRefLineGraphics.push(
|
|
452
|
+
this.allRefLineGraphics.push(f), n.laneSections.sort((m, h) => Number(m.id) - Number(h.id));
|
|
453
453
|
for (let m = 0; m < n.laneSections.length; m++) {
|
|
454
454
|
const h = n.laneSections[m], p = Number(h.id);
|
|
455
|
-
for (const
|
|
456
|
-
const v = Number(
|
|
455
|
+
for (const y of h.lanePaths) {
|
|
456
|
+
const v = Number(y.id);
|
|
457
457
|
if (v === 0)
|
|
458
458
|
continue;
|
|
459
|
-
const I =
|
|
459
|
+
const I = y.type, M = [...y.outerPath], A = y.innerPath.concat(
|
|
460
460
|
M.reverse()
|
|
461
461
|
);
|
|
462
462
|
if (A.length <= 3) {
|
|
463
463
|
console.warn(`lane ${v} has less than 3 points`);
|
|
464
464
|
continue;
|
|
465
465
|
}
|
|
466
|
-
A.push(
|
|
466
|
+
A.push(y.innerPath[0]);
|
|
467
467
|
const N = new L({
|
|
468
468
|
rings: [A]
|
|
469
469
|
});
|
|
@@ -483,8 +483,8 @@ class O {
|
|
|
483
483
|
type: I,
|
|
484
484
|
sumoId: "",
|
|
485
485
|
// 记录左右边线的起始点,用于按长度高亮车道的一部分
|
|
486
|
-
leftLine:
|
|
487
|
-
rightLine:
|
|
486
|
+
leftLine: y.innerPath,
|
|
487
|
+
rightLine: y.outerPath
|
|
488
488
|
}
|
|
489
489
|
});
|
|
490
490
|
this.allLaneGraphics.push(j), r.push(j);
|
|
@@ -573,7 +573,7 @@ class O {
|
|
|
573
573
|
(p) => `${p.attributes.roadId}+${p.attributes.sectionId}` === r
|
|
574
574
|
), l = S.union(
|
|
575
575
|
n.map((p) => p.geometry)
|
|
576
|
-
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"),
|
|
576
|
+
), d = this.hitGraphic.getAttribute("fromNode"), u = this.hitGraphic.getAttribute("toNode"), f = this.junctionNames.get(d) || d, m = this.junctionNames.get(u) || u, h = new g({
|
|
577
577
|
geometry: l,
|
|
578
578
|
symbol: {
|
|
579
579
|
type: "simple-fill",
|
|
@@ -588,7 +588,7 @@ class O {
|
|
|
588
588
|
type: "OpenDriveSection",
|
|
589
589
|
id: r,
|
|
590
590
|
selected: !1,
|
|
591
|
-
fromNodeName:
|
|
591
|
+
fromNodeName: f,
|
|
592
592
|
toNodeName: m,
|
|
593
593
|
laneCount: n.length
|
|
594
594
|
},
|
|
@@ -985,13 +985,13 @@ class O {
|
|
|
985
985
|
type: "edge",
|
|
986
986
|
id: d
|
|
987
987
|
});
|
|
988
|
-
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`,
|
|
988
|
+
const u = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, f = await b.get(u, {
|
|
989
989
|
params: {
|
|
990
990
|
id: `${n}+${a.getAttribute("sectionId")}`,
|
|
991
991
|
projectName: this.projectName
|
|
992
992
|
}
|
|
993
993
|
});
|
|
994
|
-
|
|
994
|
+
f.status === 200 && f.data.status === 0 && i.push(f.data.result);
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
const c = this.junctionLayer.graphics.filter((a) => {
|
|
@@ -1036,17 +1036,17 @@ class O {
|
|
|
1036
1036
|
);
|
|
1037
1037
|
if (!l)
|
|
1038
1038
|
return { status: -1, message: "未找到车道" };
|
|
1039
|
-
const d = e.start || 0, u = e.end || 100,
|
|
1039
|
+
const d = e.start || 0, u = e.end || 100, f = D.lineString(l.getAttribute("leftLine")), m = x(f, d, u, {
|
|
1040
1040
|
units: "meters"
|
|
1041
1041
|
}), h = D.lineString(l.getAttribute("rightLine")), p = x(h, d, u, {
|
|
1042
1042
|
units: "meters"
|
|
1043
|
-
}),
|
|
1043
|
+
}), y = m.geometry.coordinates.concat(
|
|
1044
1044
|
p.geometry.coordinates.reverse()
|
|
1045
1045
|
);
|
|
1046
|
-
|
|
1046
|
+
y.push(y[y.length - 1]);
|
|
1047
1047
|
const v = new g({
|
|
1048
1048
|
geometry: new L({
|
|
1049
|
-
rings: [
|
|
1049
|
+
rings: [y]
|
|
1050
1050
|
}),
|
|
1051
1051
|
attributes: {
|
|
1052
1052
|
ObjectID: l.getAttribute("ObjectID"),
|
|
@@ -1071,7 +1071,7 @@ class O {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
});
|
|
1074
|
-
return this.splitLaneLayer.add(v), this.view.goTo(v), { status: 0, message: "ok", result:
|
|
1074
|
+
return this.splitLaneLayer.add(v), this.view.goTo(v), { status: 0, message: "ok", result: { coordinates: y } };
|
|
1075
1075
|
}
|
|
1076
1076
|
clearSplitLane() {
|
|
1077
1077
|
this.splitLaneLayer.removeAll();
|