gisviewer-vue3-arcgis 1.0.107 → 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 (27) 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 +168 -127
  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/gis-map/utils/map-initializer.mjs +4 -4
  13. package/es/src/types/index.d.ts +1 -0
  14. package/lib/src/gis-map/gis-map.vue.js +1 -1
  15. package/lib/src/gis-map/utils/holo-flow/index.d.ts +1 -0
  16. package/lib/src/gis-map/utils/holo-flow/index.js +1 -1
  17. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +2 -0
  18. package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -1
  19. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +3 -0
  20. package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -1
  21. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +9 -5
  22. package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
  23. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.d.ts +1 -0
  24. package/lib/src/gis-map/utils/holo-flow/trace-renderer-layer.js +1 -1
  25. package/lib/src/gis-map/utils/map-initializer.js +1 -1
  26. package/lib/src/types/index.d.ts +1 -0
  27. 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
- // emissive: 0xc3c3c3,
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,
@@ -72,76 +126,64 @@ class k {
72
126
  const e = this.renderer.setRenderTarget.bind(
73
127
  this.renderer
74
128
  );
75
- this.renderer.setRenderTarget = (n) => {
76
- e(n), n == null && i.bindRenderTarget();
77
- }, this.scene = new h.Scene();
129
+ this.renderer.setRenderTarget = (s) => {
130
+ e(s), s == null && i.bindRenderTarget();
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, 2e4), this.scene.add(this.ambient), this.sun = new h.DirectionalLight(16777215, 2e4);
85
- const s = [121.51925377934634, 31.893973071723785, 1e4], a = this.toRenderCoordinates(s);
86
- this.sun.position.set(
87
- a[0],
88
- a[1],
89
- a[2]
90
- );
91
- const r = [121.46790813287619, 31.239514870157972, 1e3], o = this.toRenderCoordinates(r);
92
- this.sun.target.position.set(
93
- o[0],
94
- o[1],
95
- o[2]
96
- ), 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();
97
139
  }
98
140
  async render(i) {
99
141
  var s;
100
142
  const e = i.camera;
101
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(
102
- 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])
103
145
  ), this.camera.projectionMatrix.fromArray(e.projectionMatrix), !this.isPaused && this.needInterpolate)
104
146
  for (const a of this.vehicleObjectMap.keys()) {
105
- const r = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
106
- if (!r)
147
+ const l = (s = this.vehicleObjectMap.get(a)) == null ? void 0 : s.model;
148
+ if (!l)
107
149
  continue;
108
150
  const o = this.computeVehiclePosition(a);
109
151
  if (o) {
110
- const n = this.toRenderCoordinates(o);
111
- r.position.set(n[0], n[1], n[2]), r.rotation.y = h.MathUtils.degToRad(-o[3]);
152
+ const h = this.toRenderCoordinates(o);
153
+ l.position.set(h[0], h[1], h[2]), l.rotation.y = n.MathUtils.degToRad(-o[3]);
112
154
  }
113
155
  }
114
156
  const t = i.sunLight;
115
- 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(
116
158
  t.diffuse.color[0],
117
159
  t.diffuse.color[1],
118
160
  t.diffuse.color[2]
119
- ), 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(
120
162
  t.ambient.color[0],
121
163
  t.ambient.color[1],
122
164
  t.ambient.color[2]
123
- ), 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();
124
166
  }
125
167
  /**
126
168
  * 新增车辆
127
169
  * */
128
170
  async addVehicles(i) {
129
- if (!(this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
171
+ if (!(this.isPaused || !this.isInitialized))
130
172
  for (const e of i) {
131
- const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x), r = Number(e.y), o = Number(e.heading);
173
+ const { vehicleId: t, localTimestamp: s } = e, a = Number(e.x), l = Number(e.y), o = Number(e.heading);
132
174
  this.historyPositionMap.set(t, [
133
- { pos: [a, r, 0], heading: o, time: s }
175
+ { pos: [a, l, 0], heading: o, time: s }
134
176
  ]);
135
- const n = this.getVehicleModel(e);
136
- n.name = t, n.visible = !this.needInterpolate;
177
+ const h = this.getVehicleModel(e);
178
+ h.name = t, h.visible = !this.needInterpolate;
137
179
  try {
138
- const l = await this.createPlateSprite(e);
139
- l && (n.add(l), l.position.set(0, 5, -4));
140
- } catch (l) {
141
- console.log("createPlateSprite error:", l);
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);
142
184
  }
143
- this.scene.add(n), this.vehicleObjectMap.set(t, {
144
- model: n,
185
+ this.scene.add(h), this.vehicleObjectMap.set(t, {
186
+ model: h,
145
187
  data: e,
146
188
  waitForDelete: !1,
147
189
  isMoving: !1
@@ -152,42 +194,42 @@ class k {
152
194
  * 更新车辆
153
195
  * */
154
196
  async updateVehicles(i) {
155
- if (this.isPaused || !this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady)
197
+ if (this.isPaused || !this.isInitialized)
156
198
  return;
157
199
  const e = [];
158
200
  for (const t of i) {
159
- const { vehicleId: s, localTimestamp: a } = t, r = Number(t.x), o = Number(t.y);
160
- let n = Number(t.heading);
161
- const l = 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(
162
204
  s
163
205
  );
164
- if (!l || !m)
206
+ if (!r || !m)
165
207
  e.push(t);
166
208
  else {
167
- if (this.updateModel || l.data.vehicleColor !== t.vehicleColor || l.data.vehicleType !== t.vehicleType) {
168
- this.scene.remove(l.model), this.disposeModel(l.model), l.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);
169
211
  const c = await this.createPlateSprite(t);
170
- c && (l.model.add(c), c.position.set(0, 5, -4)), this.scene.add(l.model);
212
+ c && (r.model.add(c), c.position.set(0, 5, -4)), this.scene.add(r.model);
171
213
  }
172
- if (l.data.showName !== t.showName || l.data.plateColor !== t.plateColor) {
173
- const c = l.model.getObjectByName("VehiclePlate");
174
- c && (l.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));
175
217
  const p = await this.createPlateSprite(t);
176
- p && (l.model.add(p), p.position.set(0, 5, -4));
218
+ p && (r.model.add(p), p.position.set(0, 5, -4));
177
219
  }
178
- if (l.data = t, this.needInterpolate) {
220
+ if (r.data = t, this.needInterpolate) {
179
221
  const c = m[m.length - 1];
180
- Math.abs(n - c.heading) >= 180 && (n > c.heading ? c.heading += 360 : n += 360), m.push({
181
- pos: [r, o, 0],
182
- heading: n,
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,
183
225
  time: a
184
226
  });
185
227
  } else {
186
228
  this.historyPositionMap.set(s, [
187
- { pos: [r, o, 0], heading: n, time: a }
229
+ { pos: [l, o, 0], heading: h, time: a }
188
230
  ]);
189
- const c = this.toRenderCoordinates([r, o, 0]);
190
- l.model.position.set(c[0], c[1], c[2]), l.model.rotation.y = h.MathUtils.degToRad(-n);
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);
191
233
  }
192
234
  }
193
235
  }
@@ -195,12 +237,12 @@ class k {
195
237
  }
196
238
  toRenderCoordinates(i) {
197
239
  const e = [0, 0, 0];
198
- return g.toRenderCoordinates(
240
+ return u.toRenderCoordinates(
199
241
  // @ts-ignore
200
242
  this.view,
201
243
  i,
202
244
  0,
203
- w.WGS84,
245
+ v.WGS84,
204
246
  e,
205
247
  0,
206
248
  1
@@ -269,7 +311,7 @@ class k {
269
311
  * */
270
312
  disposeModel(i) {
271
313
  i.traverse((e) => {
272
- e instanceof h.Mesh && (e.geometry.dispose(), e.material.dispose());
314
+ e instanceof n.Mesh && (e.geometry.dispose(), e.material.dispose());
273
315
  });
274
316
  }
275
317
  /**
@@ -281,33 +323,34 @@ class k {
281
323
  return;
282
324
  const s = Date.now();
283
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);
284
- const a = s - t.segmentStartTime, r = Math.min(
326
+ const a = s - t.segmentStartTime, l = Math.min(
285
327
  a / t.segmentTotalTime,
286
328
  1
287
329
  );
288
- if (r === 1)
330
+ if (l === 1)
289
331
  if (e.shift(), e.length === 1) {
290
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));
291
333
  return;
292
334
  } else
293
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);
294
- else {
295
- const o = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * r, n = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * r, l = e[0].heading + (e[1].heading - e[0].heading) * r;
296
- return [o, n, 0, l];
297
- }
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;
298
341
  }
299
342
  /**
300
343
  * 根据车辆类型、车身颜色获取模型
301
344
  * */
302
345
  getVehicleModel(i) {
303
346
  if (this.view.camera.position.z >= this.cameraHeightThreshold) {
304
- 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({
305
348
  color: 325253,
306
349
  emissive: 0,
307
350
  roughness: this.roughness,
308
351
  metalness: this.metalness
309
352
  });
310
- return new h.Mesh(e, t);
353
+ return new n.Mesh(e, t);
311
354
  } else {
312
355
  let e;
313
356
  if (i.ptcType === 2)
@@ -333,7 +376,7 @@ class k {
333
376
  const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
334
377
  let s = !1;
335
378
  e.traverse((a) => {
336
- !s && a instanceof h.Mesh && (a.material = t, s = !0);
379
+ !s && a instanceof n.Mesh && (a.material = t, s = !0);
337
380
  });
338
381
  }
339
382
  return e;
@@ -343,72 +386,70 @@ class k {
343
386
  * 创建号牌canvas
344
387
  * */
345
388
  createCanvas(i, e, t) {
346
- const s = document.createElement("canvas"), a = i.width, r = i.height;
347
- s.width = a, s.height = r;
389
+ const s = document.createElement("canvas"), a = i.width, l = i.height;
390
+ s.width = a, s.height = l;
348
391
  const o = s.getContext("2d");
349
392
  if (!o) {
350
393
  console.log("canvas创建失败");
351
394
  return;
352
395
  }
353
- return o.fillStyle = "rgba(0,0,0,0.0)", o.fillRect(0, 0, a, r), o.drawImage(i, 0, 0, a, r), o.beginPath(), o.translate(a / 2, r / 2), o.fillStyle = t, o.font = "bold 32px 宋体", o.textBaseline = "middle", o.textAlign = "center", o.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;
354
397
  }
355
398
  createPlateSprite(i) {
356
399
  return new Promise((e, t) => {
357
- var l, m;
400
+ var r, m;
358
401
  const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
359
402
  if (this.currentSpriteContent === d.None || this.currentSpriteContent === d.PlateNumber && s) {
360
403
  e(void 0);
361
404
  return;
362
405
  }
363
- const a = new Image();
364
- let r = "", o = "", n = "";
406
+ let a = new Image(), l = "", o = "";
365
407
  if (this.currentSpriteContent === d.PlateNumber || this.currentSpriteContent === d.Mix)
366
408
  if (s)
367
- r = "grey", o = i.ptcId, n = "#ffffff";
409
+ a = this.greyPlateBG, l = i.ptcId, o = "#ffffff";
368
410
  else
369
- switch (o = ((l = i.showName) == null ? void 0 : l.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) {
370
412
  case 1:
371
- r = "blue", n = "#ffffff";
413
+ a = this.bluePlateBG, o = "#ffffff";
372
414
  break;
373
415
  case 2:
374
- r = "yellow", n = "#000000";
416
+ a = this.yellowPlateBG, o = "#000000";
375
417
  break;
376
418
  case 3:
377
- r = "white", n = "#000000";
419
+ a = this.whitePlateBG, o = "#000000";
378
420
  break;
379
421
  case 4:
380
- r = "black";
422
+ a = this.blackPlateBG, o = "#ffffff";
381
423
  break;
382
424
  case 5:
383
- r = "neo_yellow", n = "#000000";
425
+ a = this.neoYellowPlateBG, o = "#000000";
384
426
  break;
385
427
  case 6:
386
- r = "neo_green", n = "#000000";
428
+ a = this.neoGreenPlateBG, o = "#000000";
387
429
  break;
388
430
  default:
389
- r = "grey", o = i.plateNo, n = "#ffffff";
431
+ a = this.greyPlateBG, l = i.plateNo, o = "#ffffff";
390
432
  break;
391
433
  }
392
434
  else
393
- this.currentSpriteContent === d.Id && (r = "grey", o = i.ptcId, n = "#ffffff");
394
- a.src = `${this.assetsRoot}/Images/PlateBG/${r}.png`, a.onload = () => {
395
- const c = this.createCanvas(a, o, n);
396
- if (!c)
397
- t("canvas创建失败");
398
- else {
399
- const p = new h.CanvasTexture(c), M = new h.SpriteMaterial({
400
- map: p,
401
- transparent: !1
402
- }), f = new h.Sprite(M), u = 0.05, b = c.width * u, v = c.height * u;
403
- f.scale.set(b, v, 1), f.name = "VehiclePlate", e(f);
404
- }
405
- a.onerror = (p) => {
406
- console.log(`号牌背景加载失败: ${a.src}`, p), t(p);
407
- };
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);
408
449
  };
409
450
  });
410
451
  }
411
452
  }
412
453
  export {
413
- k as default
454
+ I as default
414
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) {