gisviewer-vue3-arcgis 1.0.108 → 1.0.109
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.mjs +88 -88
- package/es/src/gis-map/utils/holo-flow/index.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/index.mjs +23 -27
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +2 -0
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +69 -57
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +3 -0
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +48 -40
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +9 -5
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +169 -116
- package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +1 -0
- package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +3 -0
- package/es/src/types/index.d.ts +1 -0
- package/lib/src/gis-map/gis-map.vue.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +2 -0
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +3 -0
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +9 -5
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
- package/lib/src/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
class
|
|
1
|
+
import * as d from "@arcgis/core/views/3d/externalRenderers";
|
|
2
|
+
import T from "../../stores/index.mjs";
|
|
3
|
+
import g from "./trace-renderer-external.mjs";
|
|
4
|
+
import u from "./trace-renderer-layer.mjs";
|
|
5
|
+
class L {
|
|
6
6
|
constructor(e) {
|
|
7
|
-
this.lastDataTime = 0, this.view = e;
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
7
|
+
this.lastDataTime = 0, this.lastLocalTimestamp = 0, this.lastDataTimestamp = 0, this.view = e;
|
|
8
|
+
const r = T.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(r.mapConfig)), e.type === "3d" ? (this.traceRenderer = new g(e), d.add(
|
|
10
10
|
e,
|
|
11
11
|
this.traceRenderer
|
|
12
|
-
)) : this.traceRenderer = new
|
|
12
|
+
)) : this.traceRenderer = new u(e);
|
|
13
|
+
}
|
|
14
|
+
async init() {
|
|
15
|
+
await this.traceRenderer.init();
|
|
13
16
|
}
|
|
14
|
-
/**
|
|
15
|
-
* 处理全息流轨迹数据
|
|
16
|
-
* */
|
|
17
17
|
async handleVehicleTraceData(e) {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
for (const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
18
|
+
const { newVehList: r, updateVehList: o, deleteVehList: c, jgsj: n } = e, i = e.crossId || "", l = [], s = [];
|
|
19
|
+
if (r && r.length > 0) {
|
|
20
|
+
for (const a of r) {
|
|
21
|
+
a.localTimestamp || (a.localTimestamp = n || Date.now());
|
|
22
|
+
const t = this.buildVehicleTrackData(a, i);
|
|
23
|
+
t && l.push(t);
|
|
24
24
|
}
|
|
25
25
|
await this.traceRenderer.addVehicles(l);
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
28
|
-
for (const
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
if (o && o.length > 0) {
|
|
28
|
+
for (const p of o) {
|
|
29
|
+
const h = this.buildVehicleTrackData(p, i);
|
|
30
|
+
h && s.push(h);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
const a = s[0].localTimestamp - this.lastLocalTimestamp, t = s[0].timestamp - this.lastDataTimestamp;
|
|
33
|
+
console.log(
|
|
34
|
+
"localTimeGap",
|
|
35
|
+
a,
|
|
36
|
+
"timeGap",
|
|
37
|
+
t,
|
|
38
|
+
"delta",
|
|
39
|
+
a - t
|
|
40
|
+
), this.lastLocalTimestamp = s[0].localTimestamp, this.lastDataTimestamp = s[0].timestamp, await this.traceRenderer.updateVehicles(s);
|
|
33
41
|
}
|
|
34
42
|
if (c && c.length > 0) {
|
|
35
|
-
const
|
|
36
|
-
(
|
|
43
|
+
const a = c.map(
|
|
44
|
+
(t) => i + "-" + (t.ptcId || t.vehno || t.vehNo)
|
|
37
45
|
);
|
|
38
|
-
this.traceRenderer.deleteVehicles(
|
|
46
|
+
this.traceRenderer.deleteVehicles(a);
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
@@ -69,28 +77,28 @@ class N {
|
|
|
69
77
|
setInterpolate(e) {
|
|
70
78
|
this.traceRenderer.setInterpolate(e);
|
|
71
79
|
}
|
|
72
|
-
buildVehicleTrackData(e,
|
|
73
|
-
const
|
|
80
|
+
buildVehicleTrackData(e, r) {
|
|
81
|
+
const o = e.longitude, c = e.latitude, n = e.ptcId, i = Number(e.ptcType), l = e.heading, s = Number(e.vehicleType), a = Number(e.vehicleColor), t = e.plateNo || e.plateno, p = Number(e.plateColor), h = e.timestamp, m = e.roadLayer ? String(e.roadLayer) : "1";
|
|
74
82
|
if (!(i < 0 || i > 8))
|
|
75
83
|
return {
|
|
76
|
-
ptcId:
|
|
77
|
-
crossId:
|
|
78
|
-
vehicleId:
|
|
79
|
-
x:
|
|
80
|
-
y:
|
|
84
|
+
ptcId: n,
|
|
85
|
+
crossId: r,
|
|
86
|
+
vehicleId: r + "-" + n,
|
|
87
|
+
x: o,
|
|
88
|
+
y: c,
|
|
81
89
|
ptcType: i,
|
|
82
|
-
vehicleType:
|
|
83
|
-
heading: i === 2 ? -
|
|
84
|
-
vehicleColor:
|
|
90
|
+
vehicleType: s,
|
|
91
|
+
heading: i === 2 ? -l : l,
|
|
92
|
+
vehicleColor: a,
|
|
85
93
|
showName: t && t !== "" && t !== "0" && t !== "000000" ? t : "",
|
|
86
94
|
plateNo: t,
|
|
87
|
-
plateColor:
|
|
88
|
-
timestamp:
|
|
89
|
-
localTimestamp:
|
|
95
|
+
plateColor: p,
|
|
96
|
+
timestamp: h,
|
|
97
|
+
localTimestamp: Date.now(),
|
|
90
98
|
roadLayer: m
|
|
91
99
|
};
|
|
92
100
|
}
|
|
93
101
|
}
|
|
94
102
|
export {
|
|
95
|
-
|
|
103
|
+
L as default
|
|
96
104
|
};
|
|
@@ -18,15 +18,18 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
18
18
|
private readonly view;
|
|
19
19
|
private readonly assetsRoot;
|
|
20
20
|
private carModel;
|
|
21
|
-
private carModelReady;
|
|
22
21
|
private vanModel;
|
|
23
|
-
private vanModelReady;
|
|
24
22
|
private truckModel;
|
|
25
|
-
private truckModelReady;
|
|
26
23
|
private busModel;
|
|
27
|
-
private busModelReady;
|
|
28
24
|
private bicycleModel;
|
|
29
|
-
private
|
|
25
|
+
private bluePlateBG;
|
|
26
|
+
private yellowPlateBG;
|
|
27
|
+
private whitePlateBG;
|
|
28
|
+
private blackPlateBG;
|
|
29
|
+
private neoYellowPlateBG;
|
|
30
|
+
private neoGreenPlateBG;
|
|
31
|
+
private greyPlateBG;
|
|
32
|
+
private isInitialized;
|
|
30
33
|
private showGroundVehicle;
|
|
31
34
|
private showElevatedVehicle;
|
|
32
35
|
private isPaused;
|
|
@@ -36,6 +39,7 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
36
39
|
private needInterpolate;
|
|
37
40
|
private updateModel;
|
|
38
41
|
constructor(view: __esri.SceneView);
|
|
42
|
+
init(): Promise<void>;
|
|
39
43
|
setInterpolate(needInterpolate: boolean): void;
|
|
40
44
|
private context;
|
|
41
45
|
setup(context: any): Promise<void>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
1
|
+
import * as P from "@arcgis/core/core/promiseUtils.js";
|
|
2
|
+
import * as b from "@arcgis/core/core/reactiveUtils.js";
|
|
3
|
+
import v from "@arcgis/core/geometry/SpatialReference";
|
|
4
|
+
import * as u from "@arcgis/core/views/3d/externalRenderers";
|
|
5
|
+
import * as n from "three";
|
|
6
|
+
import { GLTFLoader as y } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
6
7
|
import { EVehiclePlateState as d } from "../../../types/index.mjs";
|
|
7
|
-
import
|
|
8
|
-
class
|
|
8
|
+
import G from "../../stores/index.mjs";
|
|
9
|
+
class I {
|
|
9
10
|
constructor(i) {
|
|
10
|
-
this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new
|
|
11
|
+
this.cameraHeightThreshold = 1e3, this.roughness = 0.2, this.metalness = 0.8, this.defaultMaterial = new n.MeshPhongMaterial({
|
|
11
12
|
color: 16777215
|
|
12
13
|
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
13
14
|
[1, this.createCarMaterial(16777215)],
|
|
@@ -21,48 +22,101 @@ class k {
|
|
|
21
22
|
[9, this.createCarMaterial(2105376)],
|
|
22
23
|
[10, this.createCarMaterial(9662683)],
|
|
23
24
|
[99, this.createCarMaterial(6908265)]
|
|
24
|
-
]), this.
|
|
25
|
-
const e =
|
|
25
|
+
]), this.isInitialized = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.isPaused = !1, this.currentSpriteContent = d.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0, this.updateModel = !1;
|
|
26
|
+
const e = G.useAppDataStore;
|
|
26
27
|
this.assetsRoot = JSON.parse(
|
|
27
28
|
JSON.stringify(e.mapConfig)
|
|
28
|
-
).assetsRoot, this.view = i
|
|
29
|
-
const t = new R();
|
|
30
|
-
t.load(`${this.assetsRoot}/3DModels/car.glb`, (s) => {
|
|
31
|
-
this.carModel = s.scene, this.carModel.rotation.x = h.MathUtils.degToRad(90), this.carModelReady = !0;
|
|
32
|
-
}), t.load(`${this.assetsRoot}/3DModels/van.glb`, (s) => {
|
|
33
|
-
this.vanModel = s.scene, this.vanModel.rotation.x = h.MathUtils.degToRad(90), this.vanModelReady = !0;
|
|
34
|
-
}), t.load(`${this.assetsRoot}/3DModels/truck.glb`, (s) => {
|
|
35
|
-
this.truckModel = s.scene, this.truckModel.scale.set(1.2, 1, 1.5), this.truckModel.rotation.x = h.MathUtils.degToRad(90), this.truckModelReady = !0;
|
|
36
|
-
}), t.load(`${this.assetsRoot}/3DModels/bus.glb`, (s) => {
|
|
37
|
-
this.busModel = s.scene, this.busModel.rotation.x = h.MathUtils.degToRad(90), this.busModelReady = !0;
|
|
38
|
-
}), t.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (s) => {
|
|
39
|
-
this.bicycleModel = s.scene, this.bicycleModel.rotation.x = h.MathUtils.degToRad(90), this.bicycleModel.rotation.y = h.MathUtils.degToRad(180), this.bicycleModelReady = !0;
|
|
40
|
-
}), document.addEventListener(
|
|
29
|
+
).assetsRoot, this.view = i, document.addEventListener(
|
|
41
30
|
"visibilitychange",
|
|
42
31
|
() => {
|
|
43
32
|
this.clearVehicles(), this.needInterpolate = !document.hidden;
|
|
44
33
|
},
|
|
45
34
|
!1
|
|
46
|
-
),
|
|
35
|
+
), b.watch(
|
|
47
36
|
() => this.view.camera.position.z,
|
|
48
|
-
(
|
|
49
|
-
(
|
|
37
|
+
(t, s) => {
|
|
38
|
+
(s <= this.cameraHeightThreshold && t > this.cameraHeightThreshold || s > this.cameraHeightThreshold && t <= this.cameraHeightThreshold) && (this.updateModel = !0);
|
|
50
39
|
}
|
|
51
40
|
);
|
|
52
41
|
}
|
|
53
42
|
createCarMaterial(i) {
|
|
54
|
-
return new
|
|
43
|
+
return new n.MeshPhongMaterial({
|
|
55
44
|
color: i
|
|
56
45
|
// // emissive: 0xc3c3c3,
|
|
57
46
|
// roughness: this.roughness,
|
|
58
47
|
// metalness: this.metalness
|
|
59
48
|
});
|
|
60
49
|
}
|
|
50
|
+
async init() {
|
|
51
|
+
const i = new y();
|
|
52
|
+
await P.eachAlways([
|
|
53
|
+
new Promise((e) => {
|
|
54
|
+
i.load(`${this.assetsRoot}/3DModels/car.glb`, (t) => {
|
|
55
|
+
this.carModel = t.scene, this.carModel.rotation.x = n.MathUtils.degToRad(90), e();
|
|
56
|
+
});
|
|
57
|
+
}),
|
|
58
|
+
new Promise((e) => {
|
|
59
|
+
i.load(`${this.assetsRoot}/3DModels/van.glb`, (t) => {
|
|
60
|
+
this.vanModel = t.scene, this.vanModel.rotation.x = n.MathUtils.degToRad(90), e();
|
|
61
|
+
});
|
|
62
|
+
}),
|
|
63
|
+
new Promise((e) => {
|
|
64
|
+
i.load(`${this.assetsRoot}/3DModels/truck.glb`, (t) => {
|
|
65
|
+
this.truckModel = t.scene, this.truckModel.scale.set(1.2, 1, 1.5), this.truckModel.rotation.x = n.MathUtils.degToRad(90), e();
|
|
66
|
+
});
|
|
67
|
+
}),
|
|
68
|
+
new Promise((e) => {
|
|
69
|
+
i.load(`${this.assetsRoot}/3DModels/bus.glb`, (t) => {
|
|
70
|
+
this.busModel = t.scene, this.busModel.rotation.x = n.MathUtils.degToRad(90), e();
|
|
71
|
+
});
|
|
72
|
+
}),
|
|
73
|
+
new Promise((e) => {
|
|
74
|
+
i.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (t) => {
|
|
75
|
+
this.bicycleModel = t.scene, this.bicycleModel.rotation.x = n.MathUtils.degToRad(90), this.bicycleModel.rotation.y = n.MathUtils.degToRad(180), e();
|
|
76
|
+
});
|
|
77
|
+
}),
|
|
78
|
+
new Promise((e) => {
|
|
79
|
+
this.bluePlateBG = new Image(), this.bluePlateBG.src = `${this.assetsRoot}/Images/PlateBG/blue.png`, this.bluePlateBG.onload = () => {
|
|
80
|
+
e();
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
new Promise((e) => {
|
|
84
|
+
this.yellowPlateBG = new Image(), this.yellowPlateBG.src = `${this.assetsRoot}/Images/PlateBG/yellow.png`, this.yellowPlateBG.onload = () => {
|
|
85
|
+
e();
|
|
86
|
+
};
|
|
87
|
+
}),
|
|
88
|
+
new Promise((e) => {
|
|
89
|
+
this.whitePlateBG = new Image(), this.whitePlateBG.src = `${this.assetsRoot}/Images/PlateBG/white.png`, this.whitePlateBG.onload = () => {
|
|
90
|
+
e();
|
|
91
|
+
};
|
|
92
|
+
}),
|
|
93
|
+
new Promise((e) => {
|
|
94
|
+
this.blackPlateBG = new Image(), this.blackPlateBG.src = `${this.assetsRoot}/Images/PlateBG/black.png`, this.blackPlateBG.onload = () => {
|
|
95
|
+
e();
|
|
96
|
+
};
|
|
97
|
+
}),
|
|
98
|
+
new Promise((e) => {
|
|
99
|
+
this.neoYellowPlateBG = new Image(), this.neoYellowPlateBG.src = `${this.assetsRoot}/Images/PlateBG/neo_yellow.png`, this.neoYellowPlateBG.onload = () => {
|
|
100
|
+
e();
|
|
101
|
+
};
|
|
102
|
+
}),
|
|
103
|
+
new Promise((e) => {
|
|
104
|
+
this.neoGreenPlateBG = new Image(), this.neoGreenPlateBG.src = `${this.assetsRoot}/Images/PlateBG/neo_green.png`, this.neoGreenPlateBG.onload = () => {
|
|
105
|
+
e();
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
new Promise((e) => {
|
|
109
|
+
this.greyPlateBG = new Image(), this.greyPlateBG.src = `${this.assetsRoot}/Images/PlateBG/grey.png`, this.greyPlateBG.onload = () => {
|
|
110
|
+
e();
|
|
111
|
+
};
|
|
112
|
+
})
|
|
113
|
+
]), this.isInitialized = !0;
|
|
114
|
+
}
|
|
61
115
|
setInterpolate(i) {
|
|
62
116
|
this.clearVehicles(), this.needInterpolate = i;
|
|
63
117
|
}
|
|
64
118
|
async setup(i) {
|
|
65
|
-
this.context = i, this.renderer = new
|
|
119
|
+
this.context = i, this.renderer = new n.WebGLRenderer({
|
|
66
120
|
context: i.gl,
|
|
67
121
|
premultipliedAlpha: !0,
|
|
68
122
|
logarithmicDepthBuffer: !0,
|
|
@@ -74,62 +128,62 @@ class k {
|
|
|
74
128
|
);
|
|
75
129
|
this.renderer.setRenderTarget = (s) => {
|
|
76
130
|
e(s), s == null && i.bindRenderTarget();
|
|
77
|
-
}, this.scene = new
|
|
131
|
+
}, this.scene = new n.Scene();
|
|
78
132
|
const { camera: t } = i;
|
|
79
|
-
this.camera = new
|
|
133
|
+
this.camera = new n.PerspectiveCamera(
|
|
80
134
|
t.fovY,
|
|
81
135
|
t.aspect,
|
|
82
136
|
0.1,
|
|
83
137
|
1e5
|
|
84
|
-
), this.ambient = new
|
|
138
|
+
), this.ambient = new n.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new n.DirectionalLight(16777215, 2), this.scene.add(this.sun), i.resetWebGLState();
|
|
85
139
|
}
|
|
86
140
|
async render(i) {
|
|
87
141
|
var s;
|
|
88
142
|
const e = i.camera;
|
|
89
143
|
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(
|
|
90
|
-
new
|
|
144
|
+
new n.Vector3(e.center[0], e.center[1], e.center[2])
|
|
91
145
|
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
|
|
92
146
|
for (const a of this.vehicleObjectMap.keys()) {
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
147
|
+
const l = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
|
|
148
|
+
if (!l)
|
|
95
149
|
continue;
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
|
|
150
|
+
const o = this.computeVehiclePosition(a);
|
|
151
|
+
if (o) {
|
|
152
|
+
const h = this.toRenderCoordinates(o);
|
|
153
|
+
l.position.set(h[0], h[1], h[2]), l.rotation.y = n.MathUtils.degToRad(-o[3]);
|
|
100
154
|
}
|
|
101
155
|
}
|
|
102
156
|
const t = i.sunLight;
|
|
103
|
-
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new
|
|
157
|
+
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new n.Color(
|
|
104
158
|
t.diffuse.color[0],
|
|
105
159
|
t.diffuse.color[1],
|
|
106
160
|
t.diffuse.color[2]
|
|
107
|
-
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new
|
|
161
|
+
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new n.Color(
|
|
108
162
|
t.ambient.color[0],
|
|
109
163
|
t.ambient.color[1],
|
|
110
164
|
t.ambient.color[2]
|
|
111
|
-
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera),
|
|
165
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), u.requestRender(this.view), i.resetWebGLState();
|
|
112
166
|
}
|
|
113
167
|
/**
|
|
114
168
|
* 新增车辆
|
|
115
169
|
* */
|
|
116
170
|
async addVehicles(i) {
|
|
117
|
-
if (!(this.isPaused || !this.
|
|
171
|
+
if (!(this.isPaused || !this.isInitialized))
|
|
118
172
|
for (const e of i) {
|
|
119
|
-
const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x),
|
|
173
|
+
const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x), l = Number(e.y), o = Number(e.heading);
|
|
120
174
|
this.historyPositionMap.set(t, [
|
|
121
|
-
{ pos: [a,
|
|
175
|
+
{ pos: [a, l, 0], heading: o, time: s }
|
|
122
176
|
]);
|
|
123
|
-
const
|
|
124
|
-
|
|
177
|
+
const h = this.getVehicleModel(e);
|
|
178
|
+
h.name = t, h.visible = !this.needInterpolate;
|
|
125
179
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
} catch (
|
|
129
|
-
console.log("createPlateSprite error:",
|
|
180
|
+
const r = await this.createPlateSprite(e);
|
|
181
|
+
r && (h.add(r), r.position.set(0, 5, -4));
|
|
182
|
+
} catch (r) {
|
|
183
|
+
console.log("createPlateSprite error:", r);
|
|
130
184
|
}
|
|
131
|
-
this.scene.add(
|
|
132
|
-
model:
|
|
185
|
+
this.scene.add(h), this.vehicleObjectMap.set(t, {
|
|
186
|
+
model: h,
|
|
133
187
|
data: e,
|
|
134
188
|
waitForDelete: !1,
|
|
135
189
|
isMoving: !1
|
|
@@ -140,42 +194,42 @@ class k {
|
|
|
140
194
|
* 更新车辆
|
|
141
195
|
* */
|
|
142
196
|
async updateVehicles(i) {
|
|
143
|
-
if (this.isPaused || !this.
|
|
197
|
+
if (this.isPaused || !this.isInitialized)
|
|
144
198
|
return;
|
|
145
199
|
const e = [];
|
|
146
200
|
for (const t of i) {
|
|
147
|
-
const { vehicleId: s,
|
|
148
|
-
let
|
|
149
|
-
const
|
|
201
|
+
const { vehicleId: s, timestamp: a } = t, l = Number(t.x), o = Number(t.y);
|
|
202
|
+
let h = Number(t.heading);
|
|
203
|
+
const r = this.vehicleObjectMap.get(s), m = this.historyPositionMap.get(
|
|
150
204
|
s
|
|
151
205
|
);
|
|
152
|
-
if (!
|
|
206
|
+
if (!r || !m)
|
|
153
207
|
e.push(t);
|
|
154
208
|
else {
|
|
155
|
-
if (this.updateModel ||
|
|
156
|
-
this.scene.remove(
|
|
209
|
+
if (m.length >= 5 && console.log(s, m.length), this.updateModel || r.data.vehicleColor !== t.vehicleColor || r.data.vehicleType !== t.vehicleType) {
|
|
210
|
+
this.scene.remove(r.model), this.disposeModel(r.model), r.model = this.getVehicleModel(t);
|
|
157
211
|
const c = await this.createPlateSprite(t);
|
|
158
|
-
c && (
|
|
212
|
+
c && (r.model.add(c), c.position.set(0, 5, -4)), this.scene.add(r.model);
|
|
159
213
|
}
|
|
160
|
-
if (
|
|
161
|
-
const c =
|
|
162
|
-
c && (
|
|
214
|
+
if (r.data.showName !== t.showName || r.data.plateColor !== t.plateColor) {
|
|
215
|
+
const c = r.model.getObjectByName("VehiclePlate");
|
|
216
|
+
c && (r.model.remove(c), this.disposeModel(c));
|
|
163
217
|
const p = await this.createPlateSprite(t);
|
|
164
|
-
p && (
|
|
218
|
+
p && (r.model.add(p), p.position.set(0, 5, -4));
|
|
165
219
|
}
|
|
166
|
-
if (
|
|
220
|
+
if (r.data = t, this.needInterpolate) {
|
|
167
221
|
const c = m[m.length - 1];
|
|
168
|
-
Math.abs(
|
|
169
|
-
pos: [
|
|
170
|
-
heading:
|
|
222
|
+
Math.abs(h - c.heading) >= 180 && (h > c.heading ? c.heading += 360 : h += 360), m.push({
|
|
223
|
+
pos: [l, o, 0],
|
|
224
|
+
heading: h,
|
|
171
225
|
time: a
|
|
172
226
|
});
|
|
173
227
|
} else {
|
|
174
228
|
this.historyPositionMap.set(s, [
|
|
175
|
-
{ pos: [
|
|
229
|
+
{ pos: [l, o, 0], heading: h, time: a }
|
|
176
230
|
]);
|
|
177
|
-
const c = this.toRenderCoordinates([
|
|
178
|
-
|
|
231
|
+
const c = this.toRenderCoordinates([l, o, 0]);
|
|
232
|
+
r.model.position.set(c[0], c[1], c[2]), r.model.rotation.y = n.MathUtils.degToRad(-h);
|
|
179
233
|
}
|
|
180
234
|
}
|
|
181
235
|
}
|
|
@@ -183,12 +237,12 @@ class k {
|
|
|
183
237
|
}
|
|
184
238
|
toRenderCoordinates(i) {
|
|
185
239
|
const e = [0, 0, 0];
|
|
186
|
-
return
|
|
240
|
+
return u.toRenderCoordinates(
|
|
187
241
|
// @ts-ignore
|
|
188
242
|
this.view,
|
|
189
243
|
i,
|
|
190
244
|
0,
|
|
191
|
-
|
|
245
|
+
v.WGS84,
|
|
192
246
|
e,
|
|
193
247
|
0,
|
|
194
248
|
1
|
|
@@ -257,7 +311,7 @@ class k {
|
|
|
257
311
|
* */
|
|
258
312
|
disposeModel(i) {
|
|
259
313
|
i.traverse((e) => {
|
|
260
|
-
e instanceof
|
|
314
|
+
e instanceof n.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
261
315
|
});
|
|
262
316
|
}
|
|
263
317
|
/**
|
|
@@ -269,33 +323,34 @@ class k {
|
|
|
269
323
|
return;
|
|
270
324
|
const s = Date.now();
|
|
271
325
|
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);
|
|
272
|
-
const a = s - t.segmentStartTime,
|
|
326
|
+
const a = s - t.segmentStartTime, l = Math.min(
|
|
273
327
|
a / t.segmentTotalTime,
|
|
274
328
|
1
|
|
275
329
|
);
|
|
276
|
-
if (
|
|
330
|
+
if (l === 1)
|
|
277
331
|
if (e.shift(), e.length === 1) {
|
|
278
332
|
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));
|
|
279
333
|
return;
|
|
280
334
|
} else
|
|
281
335
|
return 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), e[0].pos.concat(e[0].heading);
|
|
282
|
-
else {
|
|
283
|
-
const
|
|
284
|
-
return [
|
|
285
|
-
}
|
|
336
|
+
else if (e.length >= 2) {
|
|
337
|
+
const o = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * l, h = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * l, r = e[0].heading + (e[1].heading - e[0].heading) * l;
|
|
338
|
+
return [o, h, 0, r];
|
|
339
|
+
} else
|
|
340
|
+
return;
|
|
286
341
|
}
|
|
287
342
|
/**
|
|
288
343
|
* 根据车辆类型、车身颜色获取模型
|
|
289
344
|
* */
|
|
290
345
|
getVehicleModel(i) {
|
|
291
346
|
if (this.view.camera.position.z >= this.cameraHeightThreshold) {
|
|
292
|
-
const e = new
|
|
347
|
+
const e = new n.SphereGeometry(5, 32, 32), t = new n.MeshPhysicalMaterial({
|
|
293
348
|
color: 325253,
|
|
294
349
|
emissive: 0,
|
|
295
350
|
roughness: this.roughness,
|
|
296
351
|
metalness: this.metalness
|
|
297
352
|
});
|
|
298
|
-
return new
|
|
353
|
+
return new n.Mesh(e, t);
|
|
299
354
|
} else {
|
|
300
355
|
let e;
|
|
301
356
|
if (i.ptcType === 2)
|
|
@@ -321,7 +376,7 @@ class k {
|
|
|
321
376
|
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
322
377
|
let s = !1;
|
|
323
378
|
e.traverse((a) => {
|
|
324
|
-
!s && a instanceof
|
|
379
|
+
!s && a instanceof n.Mesh && (a.material = t, s = !0);
|
|
325
380
|
});
|
|
326
381
|
}
|
|
327
382
|
return e;
|
|
@@ -331,72 +386,70 @@ class k {
|
|
|
331
386
|
* 创建号牌canvas
|
|
332
387
|
* */
|
|
333
388
|
createCanvas(i, e, t) {
|
|
334
|
-
const s = document.createElement("canvas"), a = i.width,
|
|
335
|
-
s.width = a, s.height =
|
|
336
|
-
const
|
|
337
|
-
if (!
|
|
389
|
+
const s = document.createElement("canvas"), a = i.width, l = i.height;
|
|
390
|
+
s.width = a, s.height = l;
|
|
391
|
+
const o = s.getContext("2d");
|
|
392
|
+
if (!o) {
|
|
338
393
|
console.log("canvas创建失败");
|
|
339
394
|
return;
|
|
340
395
|
}
|
|
341
|
-
return
|
|
396
|
+
return o.fillStyle = "rgba(0,0,0,0.0)", o.fillRect(0, 0, a, l), o.drawImage(i, 0, 0, a, l), o.beginPath(), o.translate(a / 2, l / 2), o.fillStyle = t, o.font = "bold 32px 宋体", o.textBaseline = "middle", o.textAlign = "center", o.fillText(e, 0, 0), s;
|
|
342
397
|
}
|
|
343
398
|
createPlateSprite(i) {
|
|
344
399
|
return new Promise((e, t) => {
|
|
345
|
-
var
|
|
400
|
+
var r, m;
|
|
346
401
|
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
347
402
|
if (this.currentSpriteContent === d.None || this.currentSpriteContent === d.PlateNumber && s) {
|
|
348
403
|
e(void 0);
|
|
349
404
|
return;
|
|
350
405
|
}
|
|
351
|
-
|
|
352
|
-
let o = "", r = "", l = "";
|
|
406
|
+
let a = new Image(), l = "", o = "";
|
|
353
407
|
if (this.currentSpriteContent === d.PlateNumber || this.currentSpriteContent === d.Mix)
|
|
354
408
|
if (s)
|
|
355
|
-
|
|
409
|
+
a = this.greyPlateBG, l = i.ptcId, o = "#ffffff";
|
|
356
410
|
else
|
|
357
|
-
switch (
|
|
411
|
+
switch (l = ((r = i.showName) == null ? void 0 : r.substring(0, 2)) + "•" + ((m = i.showName) == null ? void 0 : m.substring(2)), i.plateColor) {
|
|
358
412
|
case 1:
|
|
359
|
-
|
|
413
|
+
a = this.bluePlateBG, o = "#ffffff";
|
|
360
414
|
break;
|
|
361
415
|
case 2:
|
|
362
|
-
|
|
416
|
+
a = this.yellowPlateBG, o = "#000000";
|
|
363
417
|
break;
|
|
364
418
|
case 3:
|
|
365
|
-
|
|
419
|
+
a = this.whitePlateBG, o = "#000000";
|
|
366
420
|
break;
|
|
367
421
|
case 4:
|
|
368
|
-
o = "
|
|
422
|
+
a = this.blackPlateBG, o = "#ffffff";
|
|
369
423
|
break;
|
|
370
424
|
case 5:
|
|
371
|
-
|
|
425
|
+
a = this.neoYellowPlateBG, o = "#000000";
|
|
372
426
|
break;
|
|
373
427
|
case 6:
|
|
374
|
-
|
|
428
|
+
a = this.neoGreenPlateBG, o = "#000000";
|
|
375
429
|
break;
|
|
376
430
|
default:
|
|
377
|
-
|
|
431
|
+
a = this.greyPlateBG, l = i.plateNo, o = "#ffffff";
|
|
378
432
|
break;
|
|
379
433
|
}
|
|
380
434
|
else
|
|
381
|
-
this.currentSpriteContent === d.Id && (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
};
|
|
435
|
+
this.currentSpriteContent === d.Id && (a = this.greyPlateBG, l = i.ptcId, o = "#ffffff");
|
|
436
|
+
const h = this.createCanvas(a, l, o);
|
|
437
|
+
if (h) {
|
|
438
|
+
const c = new n.CanvasTexture(h), p = new n.SpriteMaterial({
|
|
439
|
+
map: c,
|
|
440
|
+
transparent: !1
|
|
441
|
+
}), g = new n.Sprite(p), f = 0.05, M = h.width * f, w = h.height * f;
|
|
442
|
+
g.scale.set(M, w, 1), g.name = "VehiclePlate", e(g);
|
|
443
|
+
} else {
|
|
444
|
+
t("canvas创建失败");
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
a.onerror = (c) => {
|
|
448
|
+
console.log(`号牌背景加载失败: ${a.src}`, c), t(c);
|
|
396
449
|
};
|
|
397
450
|
});
|
|
398
451
|
}
|
|
399
452
|
}
|
|
400
453
|
export {
|
|
401
|
-
|
|
454
|
+
I as default
|
|
402
455
|
};
|
|
@@ -9,6 +9,9 @@ class f {
|
|
|
9
9
|
id: "vehicleLayer"
|
|
10
10
|
}), this.view.map.add(this.vehicleLayer), this.rafSignal = requestAnimationFrame(() => this.render());
|
|
11
11
|
}
|
|
12
|
+
async init() {
|
|
13
|
+
console.log("init");
|
|
14
|
+
}
|
|
12
15
|
addVehicles(i) {
|
|
13
16
|
return new Promise((e) => {
|
|
14
17
|
if (this.isPaused) {
|
package/es/src/types/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ export interface IToggleTrafficInfoParams {
|
|
|
140
140
|
visible: boolean;
|
|
141
141
|
}
|
|
142
142
|
export interface ITraceRendererInterface {
|
|
143
|
+
init(): Promise<void>;
|
|
143
144
|
addVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
144
145
|
updateVehicles(objects: IVehicleTrack[]): Promise<void>;
|
|
145
146
|
deleteVehicles(idList: string[]): void;
|