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.
Files changed (25) hide show
  1. package/es/src/gis-map/gis-map.vue.mjs +88 -88
  2. package/es/src/gis-map/utils/holo-flow/index.d.ts +1 -0
  3. package/es/src/gis-map/utils/holo-flow/index.mjs +23 -27
  4. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +2 -0
  5. package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +69 -57
  6. package/es/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +3 -0
  7. package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +48 -40
  8. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +9 -5
  9. package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +169 -116
  10. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +1 -0
  11. package/es/src/gis-map/utils/holo-flow/trace-renderer-layer.mjs +3 -0
  12. package/es/src/types/index.d.ts +1 -0
  13. package/lib/src/gis-map/gis-map.vue.js +1 -1
  14. package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -0
  15. package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
  16. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +2 -0
  17. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
  18. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +3 -0
  19. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
  20. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +9 -5
  21. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
  22. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +1 -0
  23. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
  24. package/lib/src/types/index.d.ts +1 -0
  25. package/package.json +1 -1
@@ -1,41 +1,49 @@
1
- import * as g from "@arcgis/core/views/3d/externalRenderers";
2
- import u from "../../stores/index.mjs";
3
- import f from "./trace-renderer-external.mjs";
4
- import T from "./trace-renderer-layer.mjs";
5
- class N {
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 o = u.useAppDataStore;
9
- this.mapConfig = JSON.parse(JSON.stringify(o.mapConfig)), e.type === "3d" ? (this.traceRenderer = new f(e), g.add(
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 T(e);
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 o = new Date().getTime(), { newVehList: s, updateVehList: a, deleteVehList: c, jgsj: i } = e, n = e.crossId || "", l = [], h = [];
19
- if (s && s.length > 0) {
20
- for (const t of s) {
21
- t.localTimestamp || (t.localTimestamp = i || o);
22
- const r = this.buildVehicleTrackData(t, n);
23
- r && l.push(r);
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 (a && a.length > 0) {
28
- for (const t of a) {
29
- const r = this.buildVehicleTrackData(t, n);
30
- r && h.push(r);
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
- await this.traceRenderer.updateVehicles(h);
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 t = c.map(
36
- (r) => n + "-" + (r.ptcId || r.vehno || r.vehNo)
43
+ const a = c.map(
44
+ (t) => i + "-" + (t.ptcId || t.vehno || t.vehNo)
37
45
  );
38
- this.traceRenderer.deleteVehicles(t);
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, o) {
73
- const s = e.longitude, a = e.latitude, c = e.ptcId, i = Number(e.ptcType), n = e.heading, l = Number(e.vehicleType), h = Number(e.vehicleColor), t = e.plateNo || e.plateno, r = Number(e.plateColor), p = e.timestamp, d = e.localTimestamp, m = e.roadLayer ? String(e.roadLayer) : "1";
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: c,
77
- crossId: o,
78
- vehicleId: o + "-" + c,
79
- x: s,
80
- y: a,
84
+ ptcId: n,
85
+ crossId: r,
86
+ vehicleId: r + "-" + n,
87
+ x: o,
88
+ y: c,
81
89
  ptcType: i,
82
- vehicleType: l,
83
- heading: i === 2 ? -n : n,
84
- vehicleColor: h,
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: r,
88
- timestamp: p,
89
- localTimestamp: d,
95
+ plateColor: p,
96
+ timestamp: h,
97
+ localTimestamp: Date.now(),
90
98
  roadLayer: m
91
99
  };
92
100
  }
93
101
  }
94
102
  export {
95
- N as default
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 bicycleModelReady;
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 y from "@arcgis/core/core/reactiveUtils.js";
2
- import w from "@arcgis/core/geometry/SpatialReference";
3
- import * as g from "@arcgis/core/views/3d/externalRenderers";
4
- import * as h from "three";
5
- import { GLTFLoader as R } from "three/examples/jsm/loaders/GLTFLoader.js";
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 P from "../../stores/index.mjs";
8
- class k {
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 h.MeshPhongMaterial({
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.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !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;
25
- const e = P.useAppDataStore;
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
- ), y.watch(
35
+ ), b.watch(
47
36
  () => this.view.camera.position.z,
48
- (s, a) => {
49
- (a <= this.cameraHeightThreshold && s > this.cameraHeightThreshold || a > this.cameraHeightThreshold && s <= this.cameraHeightThreshold) && (this.updateModel = !0);
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 h.MeshPhongMaterial({
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 h.WebGLRenderer({
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 h.Scene();
131
+ }, this.scene = new n.Scene();
78
132
  const { camera: t } = i;
79
- this.camera = new h.PerspectiveCamera(
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 h.AmbientLight(16777215, 2), this.scene.add(this.ambient), this.sun = new h.DirectionalLight(16777215, 2), this.scene.add(this.sun), i.resetWebGLState();
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 h.Vector3(e.center[0], e.center[1], e.center[2])
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 o = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
94
- if (!o)
147
+ const l = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
148
+ if (!l)
95
149
  continue;
96
- const r = this.computeVehiclePosition(a);
97
- if (r) {
98
- const l = this.toRenderCoordinates(r);
99
- o.position.set(l[0], l[1], l[2]), o.rotation.y = h.MathUtils.degToRad(-r[3]);
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 h.Color(
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 h.Color(
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), g.requestRender(this.view), i.resetWebGLState();
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.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
171
+ if (!(this.isPaused || !this.isInitialized))
118
172
  for (const e of i) {
119
- const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x), o = Number(e.y), r = Number(e.heading);
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, o, 0], heading: r, time: s }
175
+ { pos: [a, l, 0], heading: o, time: s }
122
176
  ]);
123
- const l = this.getVehicleModel(e);
124
- l.name = t, l.visible = !this.needInterpolate;
177
+ const h = this.getVehicleModel(e);
178
+ h.name = t, h.visible = !this.needInterpolate;
125
179
  try {
126
- const n = await this.createPlateSprite(e);
127
- n && (l.add(n), n.position.set(0, 5, -4));
128
- } catch (n) {
129
- console.log("createPlateSprite error:", n);
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(l), this.vehicleObjectMap.set(t, {
132
- model: l,
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.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
197
+ if (this.isPaused || !this.isInitialized)
144
198
  return;
145
199
  const e = [];
146
200
  for (const t of i) {
147
- const { vehicleId: s, localTimestamp: a } = t, o = Number(t.x), r = Number(t.y);
148
- let l = Number(t.heading);
149
- const n = this.vehicleObjectMap.get(s), m = this.historyPositionMap.get(
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 (!n || !m)
206
+ if (!r || !m)
153
207
  e.push(t);
154
208
  else {
155
- if (this.updateModel || n.data.vehicleColor !== t.vehicleColor || n.data.vehicleType !== t.vehicleType) {
156
- this.scene.remove(n.model), this.disposeModel(n.model), n.model = this.getVehicleModel(t);
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 && (n.model.add(c), c.position.set(0, 5, -4)), this.scene.add(n.model);
212
+ c && (r.model.add(c), c.position.set(0, 5, -4)), this.scene.add(r.model);
159
213
  }
160
- if (n.data.showName !== t.showName || n.data.plateColor !== t.plateColor) {
161
- const c = n.model.getObjectByName("VehiclePlate");
162
- c && (n.model.remove(c), this.disposeModel(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 && (n.model.add(p), p.position.set(0, 5, -4));
218
+ p && (r.model.add(p), p.position.set(0, 5, -4));
165
219
  }
166
- if (n.data = t, this.needInterpolate) {
220
+ if (r.data = t, this.needInterpolate) {
167
221
  const c = m[m.length - 1];
168
- Math.abs(l - c.heading) >= 180 && (l > c.heading ? c.heading += 360 : l += 360), m.push({
169
- pos: [o, r, 0],
170
- heading: l,
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: [o, r, 0], heading: l, time: a }
229
+ { pos: [l, o, 0], heading: h, time: a }
176
230
  ]);
177
- const c = this.toRenderCoordinates([o, r, 0]);
178
- n.model.position.set(c[0], c[1], c[2]), n.model.rotation.y = h.MathUtils.degToRad(-l);
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 g.toRenderCoordinates(
240
+ return u.toRenderCoordinates(
187
241
  // @ts-ignore
188
242
  this.view,
189
243
  i,
190
244
  0,
191
- w.WGS84,
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 h.Mesh && (e.geometry.dispose(), e.material.dispose());
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, o = Math.min(
326
+ const a = s - t.segmentStartTime, l = Math.min(
273
327
  a / t.segmentTotalTime,
274
328
  1
275
329
  );
276
- if (o === 1)
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 r = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * o, l = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * o, n = e[0].heading + (e[1].heading - e[0].heading) * o;
284
- return [r, l, 0, n];
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 h.SphereGeometry(5, 32, 32), t = new h.MeshPhysicalMaterial({
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 h.Mesh(e, t);
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 h.Mesh && (a.material = t, s = !0);
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, o = i.height;
335
- s.width = a, s.height = o;
336
- const r = s.getContext("2d");
337
- if (!r) {
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 r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, a, o), r.drawImage(i, 0, 0, a, o), r.beginPath(), r.translate(a / 2, o / 2), r.fillStyle = t, r.font = "bold 32px 宋体", r.textBaseline = "middle", r.textAlign = "center", r.fillText(e, 0, 0), s;
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 n, m;
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
- const a = new Image();
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
- o = "grey", r = i.ptcId, l = "#ffffff";
409
+ a = this.greyPlateBG, l = i.ptcId, o = "#ffffff";
356
410
  else
357
- switch (r = ((n = i.showName) == null ? void 0 : n.substring(0, 2)) + "•" + ((m = i.showName) == null ? void 0 : m.substring(2)), i.plateColor) {
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
- o = "blue", l = "#ffffff";
413
+ a = this.bluePlateBG, o = "#ffffff";
360
414
  break;
361
415
  case 2:
362
- o = "yellow", l = "#000000";
416
+ a = this.yellowPlateBG, o = "#000000";
363
417
  break;
364
418
  case 3:
365
- o = "white", l = "#000000";
419
+ a = this.whitePlateBG, o = "#000000";
366
420
  break;
367
421
  case 4:
368
- o = "black";
422
+ a = this.blackPlateBG, o = "#ffffff";
369
423
  break;
370
424
  case 5:
371
- o = "neo_yellow", l = "#000000";
425
+ a = this.neoYellowPlateBG, o = "#000000";
372
426
  break;
373
427
  case 6:
374
- o = "neo_green", l = "#000000";
428
+ a = this.neoGreenPlateBG, o = "#000000";
375
429
  break;
376
430
  default:
377
- o = "grey", r = i.plateNo, l = "#ffffff";
431
+ a = this.greyPlateBG, l = i.plateNo, o = "#ffffff";
378
432
  break;
379
433
  }
380
434
  else
381
- this.currentSpriteContent === d.Id && (o = "grey", r = i.ptcId, l = "#ffffff");
382
- a.src = `${this.assetsRoot}/Images/PlateBG/${o}.png`, a.onload = () => {
383
- const c = this.createCanvas(a, r, l);
384
- if (!c)
385
- t("canvas创建失败");
386
- else {
387
- const p = new h.CanvasTexture(c), M = new h.SpriteMaterial({
388
- map: p,
389
- transparent: !1
390
- }), f = new h.Sprite(M), u = 0.05, b = c.width * u, v = c.height * u;
391
- f.scale.set(b, v, 1), f.name = "VehiclePlate", e(f);
392
- }
393
- a.onerror = (p) => {
394
- console.log(`号牌背景加载失败: ${a.src}`, p), t(p);
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
- k as default
454
+ I as default
402
455
  };
@@ -5,6 +5,7 @@ export default class TraceRendererLayer implements ITraceRendererInterface {
5
5
  private mapConfig;
6
6
  private rafSignal;
7
7
  constructor(view: __esri.MapView);
8
+ init(): Promise<void>;
8
9
  private needInterpolate;
9
10
  private isPaused;
10
11
  private showVehiclePlate;
@@ -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) {
@@ -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;