gisviewer-vue3-arcgis 1.0.100 → 1.0.102
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 +1 -0
- package/es/src/gis-map/gis-map.vue.mjs +57 -54
- package/es/src/gis-map/index.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/index.d.ts +2 -0
- package/es/src/gis-map/utils/holo-flow/index.mjs +18 -10
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +7 -1
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +50 -43
- package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.d.ts → trace-renderer-layer.d.ts} +8 -2
- package/es/src/gis-map/utils/holo-flow/{trace-layer-renderer.mjs → trace-renderer-layer.mjs} +39 -32
- package/es/src/gis-map/utils/holo-flow/{trace-external-renderer.d.ts → trace-renderer-webgl.d.ts} +9 -2
- package/es/src/gis-map/utils/holo-flow/trace-renderer-webgl.mjs +343 -0
- package/es/src/types/index.d.ts +3 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +1 -0
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/index.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +2 -0
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +7 -1
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/{trace-layer-renderer.d.ts → trace-renderer-layer.d.ts} +8 -2
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/{trace-external-renderer.d.ts → trace-renderer-webgl.d.ts} +9 -2
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-webgl.js +1 -0
- package/lib/src/types/index.d.ts +3 -0
- package/package.json +1 -1
- package/es/src/gis-map/utils/holo-flow/trace-external-renderer.mjs +0 -320
- package/lib/src/gis-map/utils/holo-flow/trace-external-renderer.js +0 -1
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.js +0 -1
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import b from "@arcgis/core/geometry/SpatialReference";
|
|
2
|
-
import * as u from "@arcgis/core/views/3d/externalRenderers";
|
|
3
|
-
import * as o from "three";
|
|
4
|
-
import { GLTFLoader as v } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
|
-
import { EVehiclePlateState as M } from "../../../types/index.mjs";
|
|
6
|
-
import w from "../../stores/index.mjs";
|
|
7
|
-
class k {
|
|
8
|
-
constructor(i) {
|
|
9
|
-
this.defaultMaterial = new o.MeshBasicMaterial({
|
|
10
|
-
color: 6908265
|
|
11
|
-
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
12
|
-
[1, new o.MeshBasicMaterial({ color: 16777215 })],
|
|
13
|
-
[2, new o.MeshBasicMaterial({ color: 7833753 })],
|
|
14
|
-
[3, new o.MeshBasicMaterial({ color: 16766720 })],
|
|
15
|
-
[4, new o.MeshBasicMaterial({ color: 16758465 })],
|
|
16
|
-
[5, new o.MeshBasicMaterial({ color: 14423100 })],
|
|
17
|
-
[6, new o.MeshBasicMaterial({ color: 3329330 })],
|
|
18
|
-
[7, new o.MeshBasicMaterial({ color: 2003183 })],
|
|
19
|
-
[8, new o.MeshBasicMaterial({ color: 16032864 })],
|
|
20
|
-
[9, new o.MeshBasicMaterial({ color: 2105376 })],
|
|
21
|
-
[10, new o.MeshBasicMaterial({ color: 9662683 })],
|
|
22
|
-
[99, new o.MeshBasicMaterial({ color: 6908265 })]
|
|
23
|
-
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.currentSpriteContent = M.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map();
|
|
24
|
-
const e = w.useAppDataStore;
|
|
25
|
-
this.assetsRoot = JSON.parse(
|
|
26
|
-
JSON.stringify(e.mapConfig)
|
|
27
|
-
).assetsRoot, this.view = i;
|
|
28
|
-
const t = new v();
|
|
29
|
-
t.load(`${this.assetsRoot}/3DModels/car.glb`, (s) => {
|
|
30
|
-
this.carModel = s.scene, this.carModel.rotation.x = o.MathUtils.degToRad(90), this.carModelReady = !0;
|
|
31
|
-
}), t.load(`${this.assetsRoot}/3DModels/van.glb`, (s) => {
|
|
32
|
-
this.vanModel = s.scene, this.vanModel.rotation.x = o.MathUtils.degToRad(90), this.vanModelReady = !0;
|
|
33
|
-
}), t.load(`${this.assetsRoot}/3DModels/truck.glb`, (s) => {
|
|
34
|
-
this.truckModel = s.scene, this.truckModel.scale.set(1.2, 1, 1.5), this.truckModel.rotation.x = o.MathUtils.degToRad(90), this.truckModelReady = !0;
|
|
35
|
-
}), t.load(`${this.assetsRoot}/3DModels/bus.glb`, (s) => {
|
|
36
|
-
this.busModel = s.scene, this.busModel.rotation.x = o.MathUtils.degToRad(90), this.busModelReady = !0;
|
|
37
|
-
}), t.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (s) => {
|
|
38
|
-
this.bicycleModel = s.scene, this.bicycleModel.rotation.x = o.MathUtils.degToRad(90), this.bicycleModel.rotation.y = o.MathUtils.degToRad(180), this.bicycleModelReady = !0;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
async setup(i) {
|
|
42
|
-
this.renderer = new o.WebGLRenderer({
|
|
43
|
-
context: i.gl,
|
|
44
|
-
premultipliedAlpha: !1,
|
|
45
|
-
antialias: !0
|
|
46
|
-
}), 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;
|
|
47
|
-
const e = this.renderer.setRenderTarget.bind(
|
|
48
|
-
this.renderer
|
|
49
|
-
);
|
|
50
|
-
this.renderer.setRenderTarget = (t) => {
|
|
51
|
-
e(t), t == null && i.bindRenderTarget();
|
|
52
|
-
}, this.scene = new o.Scene(), this.camera = new o.PerspectiveCamera(), this.ambient = new o.AmbientLight(16777215, 0.5), this.scene.add(this.ambient), this.sun = new o.DirectionalLight(16777215, 0.5), this.scene.add(this.sun), i.resetWebGLState();
|
|
53
|
-
}
|
|
54
|
-
async render(i) {
|
|
55
|
-
var s;
|
|
56
|
-
const e = i.camera;
|
|
57
|
-
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(
|
|
58
|
-
new o.Vector3(e.center[0], e.center[1], e.center[2])
|
|
59
|
-
), this.camera.projectionMatrix.fromArray(e.projectionMatrix);
|
|
60
|
-
for (const r of this.vehicleObjectMap.keys()) {
|
|
61
|
-
const l = (s = this.vehicleObjectMap.get(r)) == null ? void 0 : s.model;
|
|
62
|
-
if (!l)
|
|
63
|
-
continue;
|
|
64
|
-
const a = this.computeVehiclePosition(r);
|
|
65
|
-
if (a) {
|
|
66
|
-
const c = [0, 0, 0];
|
|
67
|
-
u.toRenderCoordinates(
|
|
68
|
-
this.view,
|
|
69
|
-
a,
|
|
70
|
-
0,
|
|
71
|
-
b.WGS84,
|
|
72
|
-
c,
|
|
73
|
-
0,
|
|
74
|
-
1
|
|
75
|
-
), l.position.set(c[0], c[1], c[2]), l.rotation.y = o.MathUtils.degToRad(-a[3]);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const t = i.sunLight;
|
|
79
|
-
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new o.Color(
|
|
80
|
-
t.diffuse.color[0],
|
|
81
|
-
t.diffuse.color[1],
|
|
82
|
-
t.diffuse.color[2]
|
|
83
|
-
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new o.Color(
|
|
84
|
-
t.ambient.color[0],
|
|
85
|
-
t.ambient.color[1],
|
|
86
|
-
t.ambient.color[2]
|
|
87
|
-
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), u.requestRender(this.view), i.resetWebGLState();
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 新增车辆
|
|
91
|
-
* */
|
|
92
|
-
addVehicles(i) {
|
|
93
|
-
!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady || i.forEach((e) => {
|
|
94
|
-
const { crossId: t, ptcId: s, localTimestamp: r } = e, l = Number(e.x), a = Number(e.y), c = Number(e.heading), h = `${t}-${s}`;
|
|
95
|
-
this.historyPositionMap.set(h, [
|
|
96
|
-
{ pos: [l, a, 0], heading: c, time: r }
|
|
97
|
-
]);
|
|
98
|
-
const n = this.getVehicleModel(e);
|
|
99
|
-
n.name = h, n.visible = !1, this.createPlateSprite(e, (d) => {
|
|
100
|
-
n.add(d), d.position.set(0, 5, -4);
|
|
101
|
-
}), this.scene.add(n), this.vehicleObjectMap.set(h, {
|
|
102
|
-
model: n,
|
|
103
|
-
data: e
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* 更新车辆
|
|
109
|
-
* */
|
|
110
|
-
updateVehicles(i) {
|
|
111
|
-
!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady || i.forEach((e) => {
|
|
112
|
-
const { crossId: t, ptcId: s, localTimestamp: r } = e, l = Number(e.x), a = Number(e.y);
|
|
113
|
-
let c = Number(e.heading);
|
|
114
|
-
const h = `${t}-${s}`, n = this.vehicleObjectMap.get(h);
|
|
115
|
-
if (n) {
|
|
116
|
-
if ((n.data.vehicleColor !== e.vehicleColor || n.data.vehicleType !== e.vehicleType) && (this.scene.remove(n.model), this.disposeModel(n.model), n.model = this.getVehicleModel(e), this.scene.add(n.model)), n.data.showName !== e.showName || n.data.plateColor !== e.plateColor) {
|
|
117
|
-
const m = n.model.getObjectByName("VehiclePlate");
|
|
118
|
-
m && (n.model.remove(m), this.disposeModel(m)), this.createPlateSprite(e, (g) => {
|
|
119
|
-
n.model.add(g), g.position.set(0, 5, -4);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
n.data = e;
|
|
123
|
-
const d = this.historyPositionMap.get(
|
|
124
|
-
h
|
|
125
|
-
), p = d[d.length - 1];
|
|
126
|
-
Math.abs(c - p.heading) >= 180 && (c > p.heading ? p.heading += 360 : c += 360), d.push({
|
|
127
|
-
pos: [l, a, 0],
|
|
128
|
-
heading: c,
|
|
129
|
-
time: r
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
this.historyPositionMap.set(h, [
|
|
133
|
-
{ pos: [l, a, 0], heading: c, time: r }
|
|
134
|
-
]);
|
|
135
|
-
const d = this.getVehicleModel(e);
|
|
136
|
-
d.name = h, d.visible = !1, this.createPlateSprite(e, (p) => {
|
|
137
|
-
d.add(p), p.position.set(0, 5, -4);
|
|
138
|
-
}), this.scene.add(d), this.vehicleObjectMap.set(h, {
|
|
139
|
-
model: d,
|
|
140
|
-
data: e
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* 删除车辆
|
|
147
|
-
* */
|
|
148
|
-
deleteVehicles(i) {
|
|
149
|
-
i.forEach((e) => {
|
|
150
|
-
const t = this.vehicleObjectMap.get(e);
|
|
151
|
-
t && (this.disposeModel(t.model), this.scene.remove(t.model), this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e));
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* 清除全部车辆
|
|
156
|
-
* */
|
|
157
|
-
clearVehicles() {
|
|
158
|
-
for (const i of this.vehicleObjectMap.keys()) {
|
|
159
|
-
const e = this.vehicleObjectMap.get(i);
|
|
160
|
-
e && (this.disposeModel(e.model), this.scene.remove(e.model));
|
|
161
|
-
}
|
|
162
|
-
this.vehicleObjectMap.clear(), this.historyPositionMap.clear();
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* 设置号牌显示状态
|
|
166
|
-
* @param contentType
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
updatePanelContent(i) {
|
|
170
|
-
if (i !== this.currentSpriteContent) {
|
|
171
|
-
this.currentSpriteContent = i;
|
|
172
|
-
for (const e of this.vehicleObjectMap.keys()) {
|
|
173
|
-
const t = this.vehicleObjectMap.get(e);
|
|
174
|
-
if (t) {
|
|
175
|
-
const s = t.model.getObjectByName("VehiclePlate");
|
|
176
|
-
s && (t.model.remove(s), this.disposeModel(s)), i !== M.None && this.createPlateSprite(t.data, (r) => {
|
|
177
|
-
t.model.add(r), r.position.set(0, 5, -4);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
toggleGroundVehicle(i) {
|
|
184
|
-
}
|
|
185
|
-
toggleElevatedVehicle(i) {
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* 释放模型资源
|
|
189
|
-
* */
|
|
190
|
-
disposeModel(i) {
|
|
191
|
-
i.traverse((e) => {
|
|
192
|
-
e instanceof o.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* 计算车辆位置
|
|
197
|
-
* */
|
|
198
|
-
computeVehiclePosition(i) {
|
|
199
|
-
const e = this.historyPositionMap.get(i), t = this.vehicleObjectMap.get(i);
|
|
200
|
-
if (!t || !e)
|
|
201
|
-
return [0, 0, 0, 0];
|
|
202
|
-
if (e.length === 0)
|
|
203
|
-
return [0, 0, 0, 0];
|
|
204
|
-
if (e.length <= 2)
|
|
205
|
-
return [...e[0].pos, e[0].heading];
|
|
206
|
-
const s = Date.now();
|
|
207
|
-
t.model.visible = !0, t.segmentStartTime || (t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time);
|
|
208
|
-
const r = s - t.segmentStartTime, l = Math.min(
|
|
209
|
-
r / t.segmentTotalTime,
|
|
210
|
-
1
|
|
211
|
-
);
|
|
212
|
-
if (l === 1)
|
|
213
|
-
if (e.shift(), e.length === 1) {
|
|
214
|
-
t.segmentStartTime = void 0;
|
|
215
|
-
return;
|
|
216
|
-
} else
|
|
217
|
-
return t.segmentStartTime = s, t.segmentTotalTime = e[1].time - e[0].time, Math.abs(
|
|
218
|
-
e[1].heading - e[0].heading
|
|
219
|
-
) >= 180 && (e[1].heading > e[0].heading ? e[0].heading += 360 : e[1].heading += 360), [...e[0].pos, e[0].heading];
|
|
220
|
-
else {
|
|
221
|
-
const a = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * l, c = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * l, h = e[0].heading + (e[1].heading - e[0].heading) * l;
|
|
222
|
-
return [a, c, 0, h];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 根据车辆类型、车身颜色获取模型
|
|
227
|
-
* */
|
|
228
|
-
getVehicleModel(i) {
|
|
229
|
-
let e;
|
|
230
|
-
if (i.ptcType === 2)
|
|
231
|
-
e = this.bicycleModel.clone();
|
|
232
|
-
else {
|
|
233
|
-
switch (i.vehicleType) {
|
|
234
|
-
case 10:
|
|
235
|
-
e = this.carModel.clone();
|
|
236
|
-
break;
|
|
237
|
-
case 20:
|
|
238
|
-
e = this.vanModel.clone();
|
|
239
|
-
break;
|
|
240
|
-
case 25:
|
|
241
|
-
e = this.truckModel.clone();
|
|
242
|
-
break;
|
|
243
|
-
case 50:
|
|
244
|
-
e = this.busModel.clone();
|
|
245
|
-
break;
|
|
246
|
-
default:
|
|
247
|
-
e = this.carModel.clone();
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
251
|
-
let s = !1;
|
|
252
|
-
e.traverse((r) => {
|
|
253
|
-
!s && r instanceof o.Mesh && (r.material = t, s = !0);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return e;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* 创建号牌canvas
|
|
260
|
-
* */
|
|
261
|
-
createCanvas(i, e, t) {
|
|
262
|
-
const s = document.createElement("canvas"), r = i.width, l = i.height;
|
|
263
|
-
s.width = r, s.height = l;
|
|
264
|
-
const a = s.getContext("2d");
|
|
265
|
-
if (!a) {
|
|
266
|
-
console.log("canvas创建失败");
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
return a.fillStyle = "rgba(0,0,0,0.0)", a.fillRect(0, 0, r, l), a.drawImage(i, 0, 0, r, l), a.beginPath(), a.translate(r / 2, l / 2), a.fillStyle = t, a.font = "bold 32px 宋体", a.textBaseline = "middle", a.textAlign = "center", a.fillText(e, 0, 0), s;
|
|
270
|
-
}
|
|
271
|
-
createPlateSprite(i, e) {
|
|
272
|
-
var c, h;
|
|
273
|
-
const t = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
274
|
-
if (this.currentSpriteContent === M.None || this.currentSpriteContent === M.PlateNumber && t)
|
|
275
|
-
return;
|
|
276
|
-
const s = new Image();
|
|
277
|
-
let r = "", l = "", a = "";
|
|
278
|
-
if (this.currentSpriteContent === M.PlateNumber || this.currentSpriteContent === M.Mix)
|
|
279
|
-
if (t)
|
|
280
|
-
r = "grey", l = i.ptcId, a = "#ffffff";
|
|
281
|
-
else
|
|
282
|
-
switch (l = ((c = i.showName) == null ? void 0 : c.substring(0, 2)) + "•" + ((h = i.showName) == null ? void 0 : h.substring(2)), i.plateColor) {
|
|
283
|
-
case 1:
|
|
284
|
-
r = "blue", a = "#ffffff";
|
|
285
|
-
break;
|
|
286
|
-
case 2:
|
|
287
|
-
r = "yellow", a = "#000000";
|
|
288
|
-
break;
|
|
289
|
-
case 3:
|
|
290
|
-
r = "white", a = "#000000";
|
|
291
|
-
break;
|
|
292
|
-
case 4:
|
|
293
|
-
r = "black";
|
|
294
|
-
break;
|
|
295
|
-
case 5:
|
|
296
|
-
r = "neo_yellow", a = "#000000";
|
|
297
|
-
break;
|
|
298
|
-
case 6:
|
|
299
|
-
r = "neo_green", a = "#000000";
|
|
300
|
-
break;
|
|
301
|
-
default:
|
|
302
|
-
r = "grey", l = i.plateNo, a = "#ffffff";
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
else
|
|
306
|
-
this.currentSpriteContent === M.Id && (r = "grey", l = i.ptcId, a = "#ffffff");
|
|
307
|
-
s.src = `${this.assetsRoot}/Images/PlateBG/${r}.png`, s.onload = () => {
|
|
308
|
-
const n = this.createCanvas(s, l, a);
|
|
309
|
-
if (!n)
|
|
310
|
-
return;
|
|
311
|
-
const d = new o.CanvasTexture(n), p = new o.SpriteMaterial({
|
|
312
|
-
map: d
|
|
313
|
-
}), f = new o.Sprite(p), m = 0.05, g = n.width * m, y = n.height * m;
|
|
314
|
-
f.scale.set(g, y, 1), f.name = "VehiclePlate", e(f);
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
export {
|
|
319
|
-
k as default
|
|
320
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("@arcgis/core/geometry/SpatialReference"),R=require("@arcgis/core/views/3d/externalRenderers"),S=require("three"),P=require("three/examples/jsm/loaders/GLTFLoader.js"),p=require("../../../types/index.js"),T=require("../../stores/index.js");function b(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>u[e]})}}return i.default=u,Object.freeze(i)}const y=b(R),o=b(S);class C{constructor(i){this.defaultMaterial=new o.MeshBasicMaterial({color:6908265}),this.materialMap=new Map([[1,new o.MeshBasicMaterial({color:16777215})],[2,new o.MeshBasicMaterial({color:7833753})],[3,new o.MeshBasicMaterial({color:16766720})],[4,new o.MeshBasicMaterial({color:16758465})],[5,new o.MeshBasicMaterial({color:14423100})],[6,new o.MeshBasicMaterial({color:3329330})],[7,new o.MeshBasicMaterial({color:2003183})],[8,new o.MeshBasicMaterial({color:16032864})],[9,new o.MeshBasicMaterial({color:2105376})],[10,new o.MeshBasicMaterial({color:9662683})],[99,new o.MeshBasicMaterial({color:6908265})]]),this.carModelReady=!1,this.vanModelReady=!1,this.truckModelReady=!1,this.busModelReady=!1,this.bicycleModelReady=!1,this.currentSpriteContent=p.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map;const e=T.default.useAppDataStore;this.assetsRoot=JSON.parse(JSON.stringify(e.mapConfig)).assetsRoot,this.view=i;const t=new P.GLTFLoader;t.load(`${this.assetsRoot}/3DModels/car.glb`,s=>{this.carModel=s.scene,this.carModel.rotation.x=o.MathUtils.degToRad(90),this.carModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/van.glb`,s=>{this.vanModel=s.scene,this.vanModel.rotation.x=o.MathUtils.degToRad(90),this.vanModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/truck.glb`,s=>{this.truckModel=s.scene,this.truckModel.scale.set(1.2,1,1.5),this.truckModel.rotation.x=o.MathUtils.degToRad(90),this.truckModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/bus.glb`,s=>{this.busModel=s.scene,this.busModel.rotation.x=o.MathUtils.degToRad(90),this.busModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/bicycle.glb`,s=>{this.bicycleModel=s.scene,this.bicycleModel.rotation.x=o.MathUtils.degToRad(90),this.bicycleModel.rotation.y=o.MathUtils.degToRad(180),this.bicycleModelReady=!0})}async setup(i){this.renderer=new o.WebGLRenderer({context:i.gl,premultipliedAlpha:!1,antialias:!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;const e=this.renderer.setRenderTarget.bind(this.renderer);this.renderer.setRenderTarget=t=>{e(t),t==null&&i.bindRenderTarget()},this.scene=new o.Scene,this.camera=new o.PerspectiveCamera,this.ambient=new o.AmbientLight(16777215,.5),this.scene.add(this.ambient),this.sun=new o.DirectionalLight(16777215,.5),this.scene.add(this.sun),i.resetWebGLState()}async render(i){var s;const e=i.camera;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(new o.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix);for(const r of this.vehicleObjectMap.keys()){const l=(s=this.vehicleObjectMap.get(r))==null?void 0:s.model;if(!l)continue;const a=this.computeVehiclePosition(r);if(a){const c=[0,0,0];y.toRenderCoordinates(this.view,a,0,w.WGS84,c,0,1),l.position.set(c[0],c[1],c[2]),l.rotation.y=o.MathUtils.degToRad(-a[3])}}const t=i.sunLight;this.sun.position.set(t.direction[0],t.direction[1],t.direction[2]),this.sun.intensity=t.diffuse.intensity,this.sun.color=new o.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new o.Color(t.ambient.color[0],t.ambient.color[1],t.ambient.color[2]),this.renderer.resetState(),i.bindRenderTarget(),this.renderer.render(this.scene,this.camera),y.requestRender(this.view),i.resetWebGLState()}addVehicles(i){!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady||i.forEach(e=>{const{crossId:t,ptcId:s,localTimestamp:r}=e,l=Number(e.x),a=Number(e.y),c=Number(e.heading),h=`${t}-${s}`;this.historyPositionMap.set(h,[{pos:[l,a,0],heading:c,time:r}]);const n=this.getVehicleModel(e);n.name=h,n.visible=!1,this.createPlateSprite(e,d=>{n.add(d),d.position.set(0,5,-4)}),this.scene.add(n),this.vehicleObjectMap.set(h,{model:n,data:e})})}updateVehicles(i){!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady||i.forEach(e=>{const{crossId:t,ptcId:s,localTimestamp:r}=e,l=Number(e.x),a=Number(e.y);let c=Number(e.heading);const h=`${t}-${s}`,n=this.vehicleObjectMap.get(h);if(n){if((n.data.vehicleColor!==e.vehicleColor||n.data.vehicleType!==e.vehicleType)&&(this.scene.remove(n.model),this.disposeModel(n.model),n.model=this.getVehicleModel(e),this.scene.add(n.model)),n.data.showName!==e.showName||n.data.plateColor!==e.plateColor){const f=n.model.getObjectByName("VehiclePlate");f&&(n.model.remove(f),this.disposeModel(f)),this.createPlateSprite(e,g=>{n.model.add(g),g.position.set(0,5,-4)})}n.data=e;const d=this.historyPositionMap.get(h),M=d[d.length-1];Math.abs(c-M.heading)>=180&&(c>M.heading?M.heading+=360:c+=360),d.push({pos:[l,a,0],heading:c,time:r})}else{this.historyPositionMap.set(h,[{pos:[l,a,0],heading:c,time:r}]);const d=this.getVehicleModel(e);d.name=h,d.visible=!1,this.createPlateSprite(e,M=>{d.add(M),M.position.set(0,5,-4)}),this.scene.add(d),this.vehicleObjectMap.set(h,{model:d,data:e})}})}deleteVehicles(i){i.forEach(e=>{const t=this.vehicleObjectMap.get(e);t&&(this.disposeModel(t.model),this.scene.remove(t.model),this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e))})}clearVehicles(){for(const i of this.vehicleObjectMap.keys()){const e=this.vehicleObjectMap.get(i);e&&(this.disposeModel(e.model),this.scene.remove(e.model))}this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}updatePanelContent(i){if(i!==this.currentSpriteContent){this.currentSpriteContent=i;for(const e of this.vehicleObjectMap.keys()){const t=this.vehicleObjectMap.get(e);if(t){const s=t.model.getObjectByName("VehiclePlate");s&&(t.model.remove(s),this.disposeModel(s)),i!==p.EVehiclePlateState.None&&this.createPlateSprite(t.data,r=>{t.model.add(r),r.position.set(0,5,-4)})}}}}toggleGroundVehicle(i){}toggleElevatedVehicle(i){}disposeModel(i){i.traverse(e=>{e instanceof o.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!t||!e)return[0,0,0,0];if(e.length===0)return[0,0,0,0];if(e.length<=2)return[...e[0].pos,e[0].heading];const s=Date.now();t.model.visible=!0,t.segmentStartTime||(t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time);const r=s-t.segmentStartTime,l=Math.min(r/t.segmentTotalTime,1);if(l===1)if(e.shift(),e.length===1){t.segmentStartTime=void 0;return}else return t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time,Math.abs(e[1].heading-e[0].heading)>=180&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),[...e[0].pos,e[0].heading];else{const a=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*l,c=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*l,h=e[0].heading+(e[1].heading-e[0].heading)*l;return[a,c,0,h]}}getVehicleModel(i){let e;if(i.ptcType===2)e=this.bicycleModel.clone();else{switch(i.vehicleType){case 10:e=this.carModel.clone();break;case 20:e=this.vanModel.clone();break;case 25:e=this.truckModel.clone();break;case 50:e=this.busModel.clone();break;default:e=this.carModel.clone();break}const t=this.materialMap.get(i.vehicleColor)||this.defaultMaterial;let s=!1;e.traverse(r=>{!s&&r instanceof o.Mesh&&(r.material=t,s=!0)})}return e}createCanvas(i,e,t){const s=document.createElement("canvas"),r=i.width,l=i.height;s.width=r,s.height=l;const a=s.getContext("2d");if(!a){console.log("canvas创建失败");return}return a.fillStyle="rgba(0,0,0,0.0)",a.fillRect(0,0,r,l),a.drawImage(i,0,0,r,l),a.beginPath(),a.translate(r/2,l/2),a.fillStyle=t,a.font="bold 32px 宋体",a.textBaseline="middle",a.textAlign="center",a.fillText(e,0,0),s}createPlateSprite(i,e){var c,h;const t=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===p.EVehiclePlateState.None||this.currentSpriteContent===p.EVehiclePlateState.PlateNumber&&t)return;const s=new Image;let r="",l="",a="";if(this.currentSpriteContent===p.EVehiclePlateState.PlateNumber||this.currentSpriteContent===p.EVehiclePlateState.Mix)if(t)r="grey",l=i.ptcId,a="#ffffff";else switch(l=((c=i.showName)==null?void 0:c.substring(0,2))+"•"+((h=i.showName)==null?void 0:h.substring(2)),i.plateColor){case 1:r="blue",a="#ffffff";break;case 2:r="yellow",a="#000000";break;case 3:r="white",a="#000000";break;case 4:r="black";break;case 5:r="neo_yellow",a="#000000";break;case 6:r="neo_green",a="#000000";break;default:r="grey",l=i.plateNo,a="#ffffff";break}else this.currentSpriteContent===p.EVehiclePlateState.Id&&(r="grey",l=i.ptcId,a="#ffffff");s.src=`${this.assetsRoot}/Images/PlateBG/${r}.png`,s.onload=()=>{const n=this.createCanvas(s,l,a);if(!n)return;const d=new o.CanvasTexture(n),M=new o.SpriteMaterial({map:d}),m=new o.Sprite(M),f=.05,g=n.width*f,v=n.height*f;m.scale.set(g,v,1),m.name="VehiclePlate",e(m)}}}exports.default=C;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("@arcgis/core/Graphic"),p=require("@arcgis/core/layers/GraphicsLayer"),m=require("../../stores/index.js");class y{constructor(i){this.showVehiclePlate=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.view=i;const e=m.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(e.mapConfig)),this.vehicleLayer=new p({id:"vehicleLayer"}),this.view.map.add(this.vehicleLayer),requestAnimationFrame(()=>this.render())}addVehicles(i){const e=i.map(t=>{const{crossId:l,ptcId:n}=t,s=Number(t.x),o=Number(t.y),r=Number(t.heading),a=`${l}-${n}`;this.historyPositionMap.set(a,[{pos:[s,o,0],heading:r,time:Date.now()}]);const c=new h({geometry:{type:"point",x:s,y:o},attributes:{...t},symbol:this.createCIMSymbol(t)});return c.visible=!1,this.vehicleObjectMap.set(a,{graphic:c,data:t,waitForDelete:!1}),c});this.vehicleLayer.addMany(e)}updateVehicles(i){const e=[];i.forEach(t=>{const{crossId:l,ptcId:n}=t,s=Number(t.x),o=Number(t.y),r=`${l}-${n}`,a=this.vehicleObjectMap.get(r);a?(a.data=t,this.historyPositionMap.get(r).push({pos:[s,o,0],heading:t.heading,time:Date.now()})):e.push(t)}),this.addVehicles(e)}deleteVehicles(i){i.forEach(e=>{const t=this.vehicleObjectMap.get(e);t&&(t.waitForDelete=!0)})}clearVehicles(){this.vehicleLayer.removeAll(),this.vehicleObjectMap.clear(),this.historyPositionMap.clear()}updatePanelContent(i){console.log(i)}toggleGroundVehicle(i){this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}render(){this.vehicleObjectMap.forEach((i,e)=>{this.updatePosition(e)}),requestAnimationFrame(()=>this.render())}updatePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!e||!t||e.length<=1)return;(t.graphic.getAttribute("roadLayer")||"1")==="1"?t.graphic.visible=this.showGroundVehicle:t.graphic.visible=this.showElevatedVehicle,t.segmentStartTime||(t.segmentStartTime=Date.now(),t.segmentTotalTime=e[1].time-e[0].time);const n=Date.now()-t.segmentStartTime,s=Math.min(1,n/t.segmentTotalTime);if(s===1)if(e.shift(),e.length===1){t.waitForDelete?(this.vehicleLayer.remove(t.graphic),this.vehicleObjectMap.delete(i),this.historyPositionMap.delete(i)):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0);return}else t.segmentStartTime=Date.now(),t.segmentTotalTime=e[1].time-e[0].time,(e[1].heading>=270&&e[0].heading<=90||e[1].heading<=90&&e[0].heading>=270)&&(e[1].heading>e[0].heading?e[0].heading+=360:e[1].heading+=360),t.graphic.geometry={type:"point",x:e[0].pos[0],y:e[0].pos[1]};else{const o=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*s,r=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*s,a=e[0].heading+(e[1].heading-e[0].heading)*s;t.graphic.geometry={type:"point",x:o,y:r},t.data.heading=a,t.graphic.symbol=this.createCIMSymbol(t.data)}}createCIMSymbol(i){const e=this.getPlateFontColor(i.plateColor);return{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.showName",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:this.showVehiclePlate,size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-8,ymin:-8,xmax:8,ymax:8},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:4,horizontalAlignment:"Center",offsetX:0,offsetY:8,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e.backgroundColor}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:e.fillColor}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:30,rotation:i.heading,rotateClockwise:!0,textureFilter:"Picture",url:`${this.mapConfig.assetsRoot}Images/car/${this.getCarPic(i.vehicleColor)}`}]}}}}getCarPic(i){if(this.view.zoom<=15)return"point.png";let e="grey";switch(typeof i=="string"&&(i=i.toLowerCase()),i){case"a":case 1:e="white";break;case"b":case 2:e="grey";break;case"c":case 3:e="yellow";break;case"d":case 4:e="pink";break;case"e":case 5:e="red";break;case"f":case 10:e="purple";break;case"g":case 6:e="green";break;case"h":case 7:e="blue";break;case"i":case 8:e="brown";break;case"j":case 9:e="black";break}return e+".png"}getPlateFontColor(i){let e=[255,255,255,255],t=[169,169,169,255];switch(i){case 0:e=[0,0,0,255],t=[255,255,255,255];break;case 1:e=[0,0,0,255],t=[244,164,96,255];break;case 2:e=[255,255,255,255],t=[65,105,225,255];break;case 3:e=[255,255,255,255],t=[0,0,0,255];break;case 15:e=[244,164,96,255],t=[0,250,154,255];break;case 16:e=[0,0,0,255],t=[0,250,154,255];break}return{fillColor:e,backgroundColor:t}}}exports.default=y;
|