gisviewer-vue3-arcgis 1.0.103 → 1.0.105
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/utils/holo-flow/trace-holo-flow.mjs +13 -13
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.d.ts +8 -3
- package/es/src/gis-map/utils/holo-flow/trace-renderer-external.mjs +178 -152
- package/es/src/gis-map/utils/map-initializer.mjs +4 -3
- 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 +8 -3
- package/lib/src/gis-map/utils/holo-flow/trace-renderer-external.js +1 -1
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/package.json +1 -1
- package/es/src/gis-map/utils/GreenWaveline.d.ts +0 -68
- package/lib/src/gis-map/utils/GreenWaveline.d.ts +0 -68
|
@@ -2,11 +2,11 @@ import * as f from "@arcgis/core/views/3d/externalRenderers";
|
|
|
2
2
|
import g from "../../stores/index.mjs";
|
|
3
3
|
import u from "./trace-renderer-external.mjs";
|
|
4
4
|
import T from "./trace-renderer-layer.mjs";
|
|
5
|
-
class
|
|
5
|
+
class N {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
this.lastDataTime = 0, this.view = e;
|
|
8
|
-
const
|
|
9
|
-
this.mapConfig = JSON.parse(JSON.stringify(
|
|
8
|
+
const o = g.useAppDataStore;
|
|
9
|
+
this.mapConfig = JSON.parse(JSON.stringify(o.mapConfig)), e.type === "3d" ? (this.traceRenderer = new u(e), f.add(
|
|
10
10
|
e,
|
|
11
11
|
this.traceRenderer
|
|
12
12
|
)) : this.traceRenderer = new T(e);
|
|
@@ -15,10 +15,10 @@ class b {
|
|
|
15
15
|
* 处理全息流轨迹数据
|
|
16
16
|
* */
|
|
17
17
|
handleVehicleTraceData(e) {
|
|
18
|
-
const
|
|
18
|
+
const o = new Date().getTime(), { newVehList: s, updateVehList: l, deleteVehList: c, jgsj: i } = e, n = e.crossId || "", a = [], h = [];
|
|
19
19
|
if (s && s.length > 0) {
|
|
20
20
|
for (const t of s) {
|
|
21
|
-
t.localTimestamp || (t.localTimestamp = i ||
|
|
21
|
+
t.localTimestamp || (t.localTimestamp = i || o);
|
|
22
22
|
const r = this.buildVehicleTrackData(t, n);
|
|
23
23
|
r && a.push(r);
|
|
24
24
|
}
|
|
@@ -31,8 +31,8 @@ class b {
|
|
|
31
31
|
}
|
|
32
32
|
this.traceRenderer.updateVehicles(h);
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
const t =
|
|
34
|
+
if (c && c.length > 0) {
|
|
35
|
+
const t = c.map(
|
|
36
36
|
(r) => n + "-" + (r.ptcId || r.vehno || r.vehNo)
|
|
37
37
|
);
|
|
38
38
|
this.traceRenderer.deleteVehicles(t);
|
|
@@ -63,13 +63,13 @@ class b {
|
|
|
63
63
|
setInterpolate(e) {
|
|
64
64
|
this.traceRenderer.setInterpolate(e);
|
|
65
65
|
}
|
|
66
|
-
buildVehicleTrackData(e,
|
|
67
|
-
const s = e.longitude, l = e.latitude,
|
|
66
|
+
buildVehicleTrackData(e, o) {
|
|
67
|
+
const s = e.longitude, l = e.latitude, c = e.ptcId, i = Number(e.ptcType), n = e.heading, a = 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";
|
|
68
68
|
if (!(i < 0 || i > 8))
|
|
69
69
|
return {
|
|
70
|
-
ptcId:
|
|
71
|
-
crossId:
|
|
72
|
-
vehicleId:
|
|
70
|
+
ptcId: c,
|
|
71
|
+
crossId: o,
|
|
72
|
+
vehicleId: o + "-" + c,
|
|
73
73
|
x: s,
|
|
74
74
|
y: l,
|
|
75
75
|
ptcType: i,
|
|
@@ -86,5 +86,5 @@ class b {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
N as default
|
|
90
90
|
};
|
|
@@ -5,8 +5,13 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
5
5
|
private camera;
|
|
6
6
|
private ambient;
|
|
7
7
|
private sun;
|
|
8
|
+
/** 车辆模型变化的阈值 */
|
|
9
|
+
private readonly zoomThreshold;
|
|
10
|
+
private readonly roughness;
|
|
11
|
+
private readonly metalness;
|
|
8
12
|
/** 默认车身材质 */
|
|
9
13
|
private defaultMaterial;
|
|
14
|
+
private createCarMaterial;
|
|
10
15
|
/** 车身颜色材质 */
|
|
11
16
|
private materialMap;
|
|
12
17
|
private readonly view;
|
|
@@ -21,17 +26,17 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
21
26
|
private busModelReady;
|
|
22
27
|
private bicycleModel;
|
|
23
28
|
private bicycleModelReady;
|
|
29
|
+
private showGroundVehicle;
|
|
30
|
+
private showElevatedVehicle;
|
|
24
31
|
private currentSpriteContent;
|
|
25
32
|
private historyPositionMap;
|
|
26
33
|
private vehicleObjectMap;
|
|
27
34
|
private needInterpolate;
|
|
28
|
-
private
|
|
29
|
-
private sprite;
|
|
35
|
+
private updateModel;
|
|
30
36
|
constructor(view: __esri.SceneView);
|
|
31
37
|
setInterpolate(needInterpolate: boolean): void;
|
|
32
38
|
private context;
|
|
33
39
|
setup(context: any): Promise<void>;
|
|
34
|
-
private geometryTest;
|
|
35
40
|
render(context: any): Promise<void>;
|
|
36
41
|
/**
|
|
37
42
|
* 新增车辆
|
|
@@ -1,109 +1,123 @@
|
|
|
1
|
+
import * as y from "@arcgis/core/core/reactiveUtils.js";
|
|
1
2
|
import w from "@arcgis/core/geometry/SpatialReference";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { GLTFLoader as
|
|
3
|
+
import * as M from "@arcgis/core/views/3d/externalRenderers";
|
|
4
|
+
import * as h from "three";
|
|
5
|
+
import { GLTFLoader as R } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
5
6
|
import { EVehiclePlateState as p } from "../../../types/index.mjs";
|
|
6
|
-
import
|
|
7
|
+
import C from "../../stores/index.mjs";
|
|
7
8
|
class k {
|
|
8
9
|
constructor(i) {
|
|
9
|
-
this.defaultMaterial = new
|
|
10
|
-
color:
|
|
10
|
+
this.zoomThreshold = 18.5, this.roughness = 0.4, this.metalness = 0.5, this.defaultMaterial = new h.MeshPhysicalMaterial({
|
|
11
|
+
color: 16777215,
|
|
12
|
+
emissive: 0,
|
|
13
|
+
roughness: this.roughness,
|
|
14
|
+
metalness: this.metalness
|
|
11
15
|
}), this.materialMap = /* @__PURE__ */ new Map([
|
|
12
|
-
[1,
|
|
13
|
-
[2,
|
|
14
|
-
[3,
|
|
15
|
-
[4,
|
|
16
|
-
[5,
|
|
17
|
-
[6,
|
|
18
|
-
[7,
|
|
19
|
-
[8,
|
|
20
|
-
[9,
|
|
21
|
-
[10,
|
|
22
|
-
[99,
|
|
23
|
-
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.currentSpriteContent = p.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0;
|
|
24
|
-
const e =
|
|
16
|
+
[1, this.createCarMaterial(16777215)],
|
|
17
|
+
[2, this.createCarMaterial(7833753)],
|
|
18
|
+
[3, this.createCarMaterial(16766720)],
|
|
19
|
+
[4, this.createCarMaterial(16758465)],
|
|
20
|
+
[5, this.createCarMaterial(14423100)],
|
|
21
|
+
[6, this.createCarMaterial(3329330)],
|
|
22
|
+
[7, this.createCarMaterial(2003183)],
|
|
23
|
+
[8, this.createCarMaterial(16032864)],
|
|
24
|
+
[9, this.createCarMaterial(2105376)],
|
|
25
|
+
[10, this.createCarMaterial(9662683)],
|
|
26
|
+
[99, this.createCarMaterial(6908265)]
|
|
27
|
+
]), this.carModelReady = !1, this.vanModelReady = !1, this.truckModelReady = !1, this.busModelReady = !1, this.bicycleModelReady = !1, this.showGroundVehicle = !0, this.showElevatedVehicle = !0, this.currentSpriteContent = p.None, this.historyPositionMap = /* @__PURE__ */ new Map(), this.vehicleObjectMap = /* @__PURE__ */ new Map(), this.needInterpolate = !0, this.updateModel = !1;
|
|
28
|
+
const e = C.useAppDataStore;
|
|
25
29
|
this.assetsRoot = JSON.parse(
|
|
26
30
|
JSON.stringify(e.mapConfig)
|
|
27
31
|
).assetsRoot, this.view = i;
|
|
28
|
-
const t = new
|
|
32
|
+
const t = new R();
|
|
29
33
|
t.load(`${this.assetsRoot}/3DModels/car.glb`, (s) => {
|
|
30
|
-
this.carModel = s.scene, this.carModel.rotation.x =
|
|
34
|
+
this.carModel = s.scene, this.carModel.rotation.x = h.MathUtils.degToRad(90), this.carModelReady = !0;
|
|
31
35
|
}), t.load(`${this.assetsRoot}/3DModels/van.glb`, (s) => {
|
|
32
|
-
this.vanModel = s.scene, this.vanModel.rotation.x =
|
|
36
|
+
this.vanModel = s.scene, this.vanModel.rotation.x = h.MathUtils.degToRad(90), this.vanModelReady = !0;
|
|
33
37
|
}), 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 =
|
|
38
|
+
this.truckModel = s.scene, this.truckModel.scale.set(1.2, 1, 1.5), this.truckModel.rotation.x = h.MathUtils.degToRad(90), this.truckModelReady = !0;
|
|
35
39
|
}), t.load(`${this.assetsRoot}/3DModels/bus.glb`, (s) => {
|
|
36
|
-
this.busModel = s.scene, this.busModel.rotation.x =
|
|
40
|
+
this.busModel = s.scene, this.busModel.rotation.x = h.MathUtils.degToRad(90), this.busModelReady = !0;
|
|
37
41
|
}), t.load(`${this.assetsRoot}/3DModels/bicycle.glb`, (s) => {
|
|
38
|
-
this.bicycleModel = s.scene, this.bicycleModel.rotation.x =
|
|
42
|
+
this.bicycleModel = s.scene, this.bicycleModel.rotation.x = h.MathUtils.degToRad(90), this.bicycleModel.rotation.y = h.MathUtils.degToRad(180), this.bicycleModelReady = !0;
|
|
39
43
|
}), document.addEventListener(
|
|
40
44
|
"visibilitychange",
|
|
41
45
|
() => {
|
|
42
46
|
this.clearVehicles(), this.needInterpolate = !document.hidden;
|
|
43
47
|
},
|
|
44
48
|
!1
|
|
49
|
+
), y.watch(
|
|
50
|
+
() => this.view.zoom,
|
|
51
|
+
(s, o) => {
|
|
52
|
+
(o <= this.zoomThreshold && s > this.zoomThreshold || o > this.zoomThreshold && s <= this.zoomThreshold) && (this.updateModel = !0);
|
|
53
|
+
}
|
|
45
54
|
);
|
|
46
55
|
}
|
|
56
|
+
createCarMaterial(i) {
|
|
57
|
+
return new h.MeshPhysicalMaterial({
|
|
58
|
+
color: i,
|
|
59
|
+
emissive: 0,
|
|
60
|
+
roughness: this.roughness,
|
|
61
|
+
metalness: this.metalness
|
|
62
|
+
});
|
|
63
|
+
}
|
|
47
64
|
setInterpolate(i) {
|
|
48
65
|
this.clearVehicles(), this.needInterpolate = i;
|
|
49
66
|
}
|
|
50
67
|
async setup(i) {
|
|
51
|
-
this.context = i, this.renderer = new
|
|
68
|
+
this.context = i, this.renderer = new h.WebGLRenderer({
|
|
52
69
|
context: i.gl,
|
|
53
70
|
premultipliedAlpha: !0,
|
|
54
71
|
logarithmicDepthBuffer: !0,
|
|
55
72
|
antialias: !0,
|
|
56
73
|
powerPreference: "high-performance"
|
|
57
|
-
}), 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;
|
|
74
|
+
}), this.renderer.shadowMap.enabled = !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;
|
|
58
75
|
const e = this.renderer.setRenderTarget.bind(
|
|
59
76
|
this.renderer
|
|
60
77
|
);
|
|
61
|
-
this.renderer.setRenderTarget = (
|
|
62
|
-
e(
|
|
63
|
-
}, this.scene = new
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
});
|
|
78
|
+
this.renderer.setRenderTarget = (a) => {
|
|
79
|
+
e(a), a == null && i.bindRenderTarget();
|
|
80
|
+
}, this.scene = new h.Scene();
|
|
81
|
+
const { camera: t } = i;
|
|
82
|
+
this.camera = new h.PerspectiveCamera(
|
|
83
|
+
t.fovY,
|
|
84
|
+
t.aspect,
|
|
85
|
+
0.1,
|
|
86
|
+
1e5
|
|
87
|
+
), this.ambient = new h.AmbientLight(16777215, 2e4), this.scene.add(this.ambient), this.sun = new h.DirectionalLight(16777215, 2e4);
|
|
88
|
+
const s = [121.46790813287619, 31.239514870157972, 1e3], o = this.toRenderCoordinates(s);
|
|
89
|
+
this.sun.position.set(
|
|
90
|
+
o[0],
|
|
91
|
+
o[1],
|
|
92
|
+
o[2]
|
|
93
|
+
), this.scene.add(this.sun), i.resetWebGLState();
|
|
80
94
|
}
|
|
81
95
|
async render(i) {
|
|
82
96
|
var s;
|
|
83
97
|
const e = i.camera;
|
|
84
98
|
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(
|
|
85
|
-
new
|
|
99
|
+
new h.Vector3(e.center[0], e.center[1], e.center[2])
|
|
86
100
|
), this.camera.projectionMatrix.fromArray(e.projectionMatrix), this.needInterpolate)
|
|
87
|
-
for (const
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
101
|
+
for (const o of this.vehicleObjectMap.keys()) {
|
|
102
|
+
const a = (s = this.vehicleObjectMap.get(o)) == null ? void 0 : s.model;
|
|
103
|
+
if (!a)
|
|
90
104
|
continue;
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
|
|
105
|
+
const r = this.computeVehiclePosition(o);
|
|
106
|
+
if (r) {
|
|
107
|
+
const n = this.toRenderCoordinates(r);
|
|
108
|
+
a.position.set(n[0], n[1], n[2]), a.rotation.y = h.MathUtils.degToRad(-r[3]);
|
|
95
109
|
}
|
|
96
110
|
}
|
|
97
111
|
const t = i.sunLight;
|
|
98
|
-
this.sun.position.set(t.direction[0], t.direction[1], t.direction[2]), this.sun.intensity = t.diffuse.intensity, this.sun.color = new
|
|
112
|
+
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(
|
|
99
113
|
t.diffuse.color[0],
|
|
100
114
|
t.diffuse.color[1],
|
|
101
115
|
t.diffuse.color[2]
|
|
102
|
-
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new
|
|
116
|
+
), this.ambient.intensity = t.ambient.intensity, this.ambient.color = new h.Color(
|
|
103
117
|
t.ambient.color[0],
|
|
104
118
|
t.ambient.color[1],
|
|
105
119
|
t.ambient.color[2]
|
|
106
|
-
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera),
|
|
120
|
+
), this.renderer.resetState(), i.bindRenderTarget(), this.renderer.render(this.scene, this.camera), M.requestRender(this.view), i.resetWebGLState();
|
|
107
121
|
}
|
|
108
122
|
/**
|
|
109
123
|
* 新增车辆
|
|
@@ -111,22 +125,22 @@ class k {
|
|
|
111
125
|
async addVehicles(i) {
|
|
112
126
|
if (!(!this.carModelReady || !this.vanModelReady || !this.truckModelReady || !this.busModelReady || !this.bicycleModelReady))
|
|
113
127
|
for (const e of i) {
|
|
114
|
-
const { vehicleId: t, localTimestamp: s } = e,
|
|
128
|
+
const { vehicleId: t, localTimestamp: s } = e, o = Number(e.x), a = Number(e.y), r = Number(e.heading);
|
|
115
129
|
this.historyPositionMap.set(t, [
|
|
116
|
-
{ pos: [
|
|
130
|
+
{ pos: [o, a, 0], heading: r, time: s }
|
|
117
131
|
]);
|
|
118
|
-
const
|
|
119
|
-
|
|
132
|
+
const n = this.getVehicleModel(e);
|
|
133
|
+
n.name = t, n.visible = !this.needInterpolate;
|
|
120
134
|
try {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
model:
|
|
135
|
+
const l = await this.createPlateSprite(e);
|
|
136
|
+
l && (n.add(l), l.position.set(0, 5, -4)), this.scene.add(n), this.vehicleObjectMap.set(t, {
|
|
137
|
+
model: n,
|
|
124
138
|
data: e,
|
|
125
139
|
waitForDelete: !1,
|
|
126
140
|
isMoving: !1
|
|
127
141
|
});
|
|
128
|
-
} catch (
|
|
129
|
-
console.log("createPlateSprite error:",
|
|
142
|
+
} catch (l) {
|
|
143
|
+
console.log("createPlateSprite error:", l);
|
|
130
144
|
}
|
|
131
145
|
}
|
|
132
146
|
}
|
|
@@ -138,46 +152,46 @@ class k {
|
|
|
138
152
|
return;
|
|
139
153
|
const e = [];
|
|
140
154
|
for (const t of i) {
|
|
141
|
-
const { vehicleId: s, localTimestamp:
|
|
142
|
-
let
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
155
|
+
const { vehicleId: s, localTimestamp: o } = t, a = Number(t.x), r = Number(t.y);
|
|
156
|
+
let n = Number(t.heading);
|
|
157
|
+
const l = this.vehicleObjectMap.get(s);
|
|
158
|
+
if (!l)
|
|
145
159
|
e.push(t);
|
|
146
160
|
else {
|
|
147
|
-
if (
|
|
148
|
-
this.scene.remove(
|
|
149
|
-
const
|
|
150
|
-
|
|
161
|
+
if (this.updateModel || l.data.vehicleColor !== t.vehicleColor || l.data.vehicleType !== t.vehicleType) {
|
|
162
|
+
this.scene.remove(l.model), this.disposeModel(l.model), l.model = this.getVehicleModel(t);
|
|
163
|
+
const c = await this.createPlateSprite(t);
|
|
164
|
+
c && (l.model.add(c), c.position.set(0, 5, -4)), this.scene.add(l.model);
|
|
151
165
|
}
|
|
152
|
-
if (
|
|
153
|
-
const
|
|
154
|
-
|
|
166
|
+
if (l.data.showName !== t.showName || l.data.plateColor !== t.plateColor) {
|
|
167
|
+
const c = l.model.getObjectByName("VehiclePlate");
|
|
168
|
+
c && (l.model.remove(c), this.disposeModel(c));
|
|
155
169
|
const d = await this.createPlateSprite(t);
|
|
156
|
-
d && (
|
|
170
|
+
d && (l.model.add(d), d.position.set(0, 5, -4));
|
|
157
171
|
}
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
172
|
+
if (l.data = t, this.needInterpolate) {
|
|
173
|
+
const c = this.historyPositionMap.get(
|
|
160
174
|
s
|
|
161
|
-
), d =
|
|
162
|
-
Math.abs(
|
|
163
|
-
pos: [
|
|
164
|
-
heading:
|
|
165
|
-
time:
|
|
175
|
+
), d = c[c.length - 1];
|
|
176
|
+
Math.abs(n - d.heading) >= 180 && (n > d.heading ? d.heading += 360 : n += 360), c.push({
|
|
177
|
+
pos: [a, r, 0],
|
|
178
|
+
heading: n,
|
|
179
|
+
time: o
|
|
166
180
|
});
|
|
167
181
|
} else {
|
|
168
182
|
this.historyPositionMap.set(s, [
|
|
169
|
-
{ pos: [
|
|
183
|
+
{ pos: [a, r, 0], heading: n, time: o }
|
|
170
184
|
]);
|
|
171
|
-
const
|
|
172
|
-
|
|
185
|
+
const c = this.toRenderCoordinates([a, r, 0]);
|
|
186
|
+
l.model.position.set(c[0], c[1], c[2]), l.model.rotation.y = h.MathUtils.degToRad(-n);
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
}
|
|
176
|
-
this.addVehicles(e), this.needInterpolate || this.render(this.context);
|
|
190
|
+
this.addVehicles(e), this.updateModel = !1, this.needInterpolate || this.render(this.context);
|
|
177
191
|
}
|
|
178
192
|
toRenderCoordinates(i) {
|
|
179
193
|
const e = [0, 0, 0];
|
|
180
|
-
return
|
|
194
|
+
return M.toRenderCoordinates(
|
|
181
195
|
// @ts-ignore
|
|
182
196
|
this.view,
|
|
183
197
|
i,
|
|
@@ -203,7 +217,7 @@ class k {
|
|
|
203
217
|
this.vehicleObjectMap.delete(e), this.historyPositionMap.delete(e);
|
|
204
218
|
}
|
|
205
219
|
async toggleTrafficInfo(i) {
|
|
206
|
-
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === p.None ? await this.updatePanelContent(p.
|
|
220
|
+
i.name === "vehiclePlate" && (i.visible === !0 && this.currentSpriteContent === p.None ? await this.updatePanelContent(p.PlateNumber) : await this.updatePanelContent(
|
|
207
221
|
i.visible ? this.currentSpriteContent : p.None
|
|
208
222
|
));
|
|
209
223
|
}
|
|
@@ -230,23 +244,25 @@ class k {
|
|
|
230
244
|
if (t) {
|
|
231
245
|
const s = t.model.getObjectByName("VehiclePlate");
|
|
232
246
|
if (s && (t.model.remove(s), this.disposeModel(s)), i !== p.None) {
|
|
233
|
-
const
|
|
234
|
-
|
|
247
|
+
const o = await this.createPlateSprite(t.data);
|
|
248
|
+
o && (t.model.add(o), o.position.set(0, 5, -4));
|
|
235
249
|
}
|
|
236
250
|
}
|
|
237
251
|
}
|
|
238
252
|
}
|
|
239
253
|
}
|
|
240
254
|
toggleGroundVehicle(i) {
|
|
255
|
+
console.log("toggleGroundVehicle", i), this.showGroundVehicle = i;
|
|
241
256
|
}
|
|
242
257
|
toggleElevatedVehicle(i) {
|
|
258
|
+
this.showElevatedVehicle = i;
|
|
243
259
|
}
|
|
244
260
|
/**
|
|
245
261
|
* 释放模型资源
|
|
246
262
|
* */
|
|
247
263
|
disposeModel(i) {
|
|
248
264
|
i.traverse((e) => {
|
|
249
|
-
e instanceof
|
|
265
|
+
e instanceof h.Mesh && (e.geometry.dispose(), e.material.dispose());
|
|
250
266
|
});
|
|
251
267
|
}
|
|
252
268
|
/**
|
|
@@ -257,120 +273,130 @@ class k {
|
|
|
257
273
|
if (!t || !e || !t.isMoving && e.length <= 2)
|
|
258
274
|
return;
|
|
259
275
|
const s = Date.now();
|
|
260
|
-
t.
|
|
261
|
-
const
|
|
262
|
-
|
|
276
|
+
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);
|
|
277
|
+
const o = s - t.segmentStartTime, a = Math.min(
|
|
278
|
+
o / t.segmentTotalTime,
|
|
263
279
|
1
|
|
264
280
|
);
|
|
265
|
-
if (
|
|
281
|
+
if (a === 1)
|
|
266
282
|
if (e.shift(), e.length === 1) {
|
|
267
283
|
t.waitForDelete === !0 ? this.deleteVehicle(t) : (t.segmentStartTime = void 0, t.segmentTotalTime = void 0, t.model.visible = !1, t.isMoving = !1, console.log("pause vehicle", i));
|
|
268
284
|
return;
|
|
269
285
|
} else
|
|
270
286
|
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);
|
|
271
287
|
else {
|
|
272
|
-
const
|
|
273
|
-
return [
|
|
288
|
+
const r = e[0].pos[0] + (e[1].pos[0] - e[0].pos[0]) * a, n = e[0].pos[1] + (e[1].pos[1] - e[0].pos[1]) * a, l = e[0].heading + (e[1].heading - e[0].heading) * a;
|
|
289
|
+
return [r, n, 0, l];
|
|
274
290
|
}
|
|
275
291
|
}
|
|
276
292
|
/**
|
|
277
293
|
* 根据车辆类型、车身颜色获取模型
|
|
278
294
|
* */
|
|
279
295
|
getVehicleModel(i) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
e = this.carModel.clone();
|
|
287
|
-
break;
|
|
288
|
-
case 20:
|
|
289
|
-
e = this.vanModel.clone();
|
|
290
|
-
break;
|
|
291
|
-
case 25:
|
|
292
|
-
e = this.truckModel.clone();
|
|
293
|
-
break;
|
|
294
|
-
case 50:
|
|
295
|
-
e = this.busModel.clone();
|
|
296
|
-
break;
|
|
297
|
-
default:
|
|
298
|
-
e = this.carModel.clone();
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
302
|
-
let s = !1;
|
|
303
|
-
e.traverse((l) => {
|
|
304
|
-
!s && l instanceof o.Mesh && (l.material = t, s = !0);
|
|
296
|
+
if (this.view.zoom <= this.zoomThreshold) {
|
|
297
|
+
const e = new h.SphereGeometry(5, 32, 32), t = new h.MeshPhysicalMaterial({
|
|
298
|
+
color: 325253,
|
|
299
|
+
emissive: 0,
|
|
300
|
+
roughness: this.roughness,
|
|
301
|
+
metalness: this.metalness
|
|
305
302
|
});
|
|
303
|
+
return new h.Mesh(e, t);
|
|
304
|
+
} else {
|
|
305
|
+
let e;
|
|
306
|
+
if (i.ptcType === 2)
|
|
307
|
+
e = this.bicycleModel.clone();
|
|
308
|
+
else {
|
|
309
|
+
switch (i.vehicleType) {
|
|
310
|
+
case 10:
|
|
311
|
+
e = this.carModel.clone();
|
|
312
|
+
break;
|
|
313
|
+
case 20:
|
|
314
|
+
e = this.vanModel.clone();
|
|
315
|
+
break;
|
|
316
|
+
case 25:
|
|
317
|
+
e = this.truckModel.clone();
|
|
318
|
+
break;
|
|
319
|
+
case 50:
|
|
320
|
+
e = this.busModel.clone();
|
|
321
|
+
break;
|
|
322
|
+
default:
|
|
323
|
+
e = this.carModel.clone();
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
const t = this.materialMap.get(i.vehicleColor) || this.defaultMaterial;
|
|
327
|
+
let s = !1;
|
|
328
|
+
e.traverse((o) => {
|
|
329
|
+
!s && o instanceof h.Mesh && (o.material = t, s = !0);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return e;
|
|
306
333
|
}
|
|
307
|
-
return e;
|
|
308
334
|
}
|
|
309
335
|
/**
|
|
310
336
|
* 创建号牌canvas
|
|
311
337
|
* */
|
|
312
338
|
createCanvas(i, e, t) {
|
|
313
|
-
const s = document.createElement("canvas"),
|
|
314
|
-
s.width =
|
|
315
|
-
const
|
|
316
|
-
if (!
|
|
339
|
+
const s = document.createElement("canvas"), o = i.width, a = i.height;
|
|
340
|
+
s.width = o, s.height = a;
|
|
341
|
+
const r = s.getContext("2d");
|
|
342
|
+
if (!r) {
|
|
317
343
|
console.log("canvas创建失败");
|
|
318
344
|
return;
|
|
319
345
|
}
|
|
320
|
-
return
|
|
346
|
+
return r.fillStyle = "rgba(0,0,0,0.0)", r.fillRect(0, 0, o, a), r.drawImage(i, 0, 0, o, a), r.beginPath(), r.translate(o / 2, a / 2), r.fillStyle = t, r.font = "bold 32px 宋体", r.textBaseline = "middle", r.textAlign = "center", r.fillText(e, 0, 0), s;
|
|
321
347
|
}
|
|
322
348
|
createPlateSprite(i) {
|
|
323
349
|
return new Promise((e, t) => {
|
|
324
|
-
var
|
|
350
|
+
var l, c;
|
|
325
351
|
const s = !i.plateNo || i.plateNo === "0" || i.plateNo === "000000";
|
|
326
352
|
if (this.currentSpriteContent === p.None || this.currentSpriteContent === p.PlateNumber && s) {
|
|
327
353
|
e(void 0);
|
|
328
354
|
return;
|
|
329
355
|
}
|
|
330
|
-
const
|
|
331
|
-
let
|
|
356
|
+
const o = new Image();
|
|
357
|
+
let a = "", r = "", n = "";
|
|
332
358
|
if (this.currentSpriteContent === p.PlateNumber || this.currentSpriteContent === p.Mix)
|
|
333
359
|
if (s)
|
|
334
|
-
|
|
360
|
+
a = "grey", r = i.ptcId, n = "#ffffff";
|
|
335
361
|
else
|
|
336
|
-
switch (
|
|
362
|
+
switch (r = ((l = i.showName) == null ? void 0 : l.substring(0, 2)) + "•" + ((c = i.showName) == null ? void 0 : c.substring(2)), i.plateColor) {
|
|
337
363
|
case 1:
|
|
338
|
-
|
|
364
|
+
a = "blue", n = "#ffffff";
|
|
339
365
|
break;
|
|
340
366
|
case 2:
|
|
341
|
-
|
|
367
|
+
a = "yellow", n = "#000000";
|
|
342
368
|
break;
|
|
343
369
|
case 3:
|
|
344
|
-
|
|
370
|
+
a = "white", n = "#000000";
|
|
345
371
|
break;
|
|
346
372
|
case 4:
|
|
347
|
-
|
|
373
|
+
a = "black";
|
|
348
374
|
break;
|
|
349
375
|
case 5:
|
|
350
|
-
|
|
376
|
+
a = "neo_yellow", n = "#000000";
|
|
351
377
|
break;
|
|
352
378
|
case 6:
|
|
353
|
-
|
|
379
|
+
a = "neo_green", n = "#000000";
|
|
354
380
|
break;
|
|
355
381
|
default:
|
|
356
|
-
|
|
382
|
+
a = "grey", r = i.plateNo, n = "#ffffff";
|
|
357
383
|
break;
|
|
358
384
|
}
|
|
359
385
|
else
|
|
360
|
-
this.currentSpriteContent === p.Id && (
|
|
361
|
-
|
|
362
|
-
const d = this.createCanvas(
|
|
386
|
+
this.currentSpriteContent === p.Id && (a = "grey", r = i.ptcId, n = "#ffffff");
|
|
387
|
+
o.src = `${this.assetsRoot}/Images/PlateBG/${a}.png`, o.onload = () => {
|
|
388
|
+
const d = this.createCanvas(o, r, n);
|
|
363
389
|
if (!d)
|
|
364
390
|
t("canvas创建失败");
|
|
365
391
|
else {
|
|
366
|
-
const
|
|
367
|
-
map:
|
|
392
|
+
const m = new h.CanvasTexture(d), g = new h.SpriteMaterial({
|
|
393
|
+
map: m,
|
|
368
394
|
transparent: !1
|
|
369
|
-
}),
|
|
370
|
-
|
|
395
|
+
}), f = new h.Sprite(g), u = 0.05, b = d.width * u, v = d.height * u;
|
|
396
|
+
f.scale.set(b, v, 1), f.name = "VehiclePlate", e(f);
|
|
371
397
|
}
|
|
372
|
-
|
|
373
|
-
console.log(`号牌背景加载失败: ${
|
|
398
|
+
o.onerror = (m) => {
|
|
399
|
+
console.log(`号牌背景加载失败: ${o.src}`, m), t(m);
|
|
374
400
|
};
|
|
375
401
|
};
|
|
376
402
|
});
|
|
@@ -39,7 +39,7 @@ class Q {
|
|
|
39
39
|
container: a,
|
|
40
40
|
...e == null ? void 0 : e.mapOptions
|
|
41
41
|
}), this.view.on("click", async (s) => {
|
|
42
|
-
var
|
|
42
|
+
var v, b;
|
|
43
43
|
if (d) {
|
|
44
44
|
let o = s.mapPoint;
|
|
45
45
|
o.spatialReference.isWebMercator && (o = f.webMercatorToGeographic(
|
|
@@ -60,9 +60,10 @@ class Q {
|
|
|
60
60
|
tilt: o.tilt,
|
|
61
61
|
position: l.toJSON()
|
|
62
62
|
};
|
|
63
|
-
console.log(w), (
|
|
63
|
+
console.log(w), (v = navigator.clipboard) == null || v.writeText(JSON.stringify(w));
|
|
64
64
|
} else
|
|
65
65
|
console.log(o.toJSON());
|
|
66
|
+
console.log(this.view.zoom, this.view.scale);
|
|
66
67
|
} else {
|
|
67
68
|
let o = this.view.center;
|
|
68
69
|
this.view.spatialReference.isWebMercator && (o = f.webMercatorToGeographic(
|
|
@@ -72,7 +73,7 @@ class Q {
|
|
|
72
73
|
zoom: this.view.zoom
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
|
-
const h = (
|
|
76
|
+
const h = (b = (await this.view.hitTest(s)).results) == null ? void 0 : b.filter(
|
|
76
77
|
(o) => o.type === "graphic"
|
|
77
78
|
);
|
|
78
79
|
h.length > 0 && h.forEach((o) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@arcgis/core/views/3d/externalRenderers"),m=require("../../stores/index.js"),T=require("./trace-renderer-external.js"),b=require("./trace-renderer-layer.js");function R(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@arcgis/core/views/3d/externalRenderers"),m=require("../../stores/index.js"),T=require("./trace-renderer-external.js"),b=require("./trace-renderer-layer.js");function R(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const y=R(g);class V{constructor(e){this.lastDataTime=0,this.view=e;const r=m.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(r.mapConfig)),e.type==="3d"?(this.traceRenderer=new T.default(e),y.add(e,this.traceRenderer)):this.traceRenderer=new b.default(e)}handleVehicleTraceData(e){const r=new Date().getTime(),{newVehList:n,updateVehList:a,deleteVehList:i,jgsj:s}=e,l=e.crossId||"",d=[],h=[];if(n&&n.length>0){for(const t of n){t.localTimestamp||(t.localTimestamp=s||r);const c=this.buildVehicleTrackData(t,l);c&&d.push(c)}this.traceRenderer.addVehicles(d)}if(a&&a.length>0){for(const t of a){const c=this.buildVehicleTrackData(t,l);c&&h.push(c)}this.traceRenderer.updateVehicles(h)}if(i&&i.length>0){const t=i.map(c=>l+"-"+(c.ptcId||c.vehno||c.vehNo));this.traceRenderer.deleteVehicles(t)}}toggleTrafficInfo(e){this.traceRenderer.toggleTrafficInfo(e)}clearTrace(){this.traceRenderer.clearVehicles()}updatePanelContent(e){this.traceRenderer.updatePanelContent(e)}toggleGroundVehicle(e){this.traceRenderer.toggleGroundVehicle(e)}toggleElevatedVehicle(e){this.traceRenderer.toggleElevatedVehicle(e)}setInterpolate(e){this.traceRenderer.setInterpolate(e)}buildVehicleTrackData(e,r){const n=e.longitude,a=e.latitude,i=e.ptcId,s=Number(e.ptcType),l=e.heading,d=Number(e.vehicleType),h=Number(e.vehicleColor),t=e.plateNo||e.plateno,c=Number(e.plateColor),u=e.timestamp,p=e.localTimestamp,f=e.roadLayer?String(e.roadLayer):"1";if(!(s<0||s>8))return{ptcId:i,crossId:r,vehicleId:r+"-"+i,x:n,y:a,ptcType:s,vehicleType:d,heading:s===2?-l:l,vehicleColor:h,showName:t&&t!==""&&t!=="0"&&t!=="000000"?t:"",plateNo:t,plateColor:c,timestamp:u,localTimestamp:p,roadLayer:f}}}exports.default=V;
|
|
@@ -5,8 +5,13 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
5
5
|
private camera;
|
|
6
6
|
private ambient;
|
|
7
7
|
private sun;
|
|
8
|
+
/** 车辆模型变化的阈值 */
|
|
9
|
+
private readonly zoomThreshold;
|
|
10
|
+
private readonly roughness;
|
|
11
|
+
private readonly metalness;
|
|
8
12
|
/** 默认车身材质 */
|
|
9
13
|
private defaultMaterial;
|
|
14
|
+
private createCarMaterial;
|
|
10
15
|
/** 车身颜色材质 */
|
|
11
16
|
private materialMap;
|
|
12
17
|
private readonly view;
|
|
@@ -21,17 +26,17 @@ export default class TraceRendererExternal implements ITraceRendererInterface {
|
|
|
21
26
|
private busModelReady;
|
|
22
27
|
private bicycleModel;
|
|
23
28
|
private bicycleModelReady;
|
|
29
|
+
private showGroundVehicle;
|
|
30
|
+
private showElevatedVehicle;
|
|
24
31
|
private currentSpriteContent;
|
|
25
32
|
private historyPositionMap;
|
|
26
33
|
private vehicleObjectMap;
|
|
27
34
|
private needInterpolate;
|
|
28
|
-
private
|
|
29
|
-
private sprite;
|
|
35
|
+
private updateModel;
|
|
30
36
|
constructor(view: __esri.SceneView);
|
|
31
37
|
setInterpolate(needInterpolate: boolean): void;
|
|
32
38
|
private context;
|
|
33
39
|
setup(context: any): Promise<void>;
|
|
34
|
-
private geometryTest;
|
|
35
40
|
render(context: any): Promise<void>;
|
|
36
41
|
/**
|
|
37
42
|
* 新增车辆
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("@arcgis/core/geometry/SpatialReference"),P=require("@arcgis/core/views/3d/externalRenderers"),T=require("three"),g=require("three/examples/jsm/loaders/GLTFLoader.js"),p=require("../../../types/index.js"),C=require("../../stores/index.js");function y(f){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const e in f)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(f,e);Object.defineProperty(i,e,t.get?t:{enumerable:!0,get:()=>f[e]})}}return i.default=f,Object.freeze(i)}const b=y(P),o=y(T);class V{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,this.needInterpolate=!0;const e=C.default.useAppDataStore;this.assetsRoot=JSON.parse(JSON.stringify(e.mapConfig)).assetsRoot,this.view=i;const t=new g.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}),document.addEventListener("visibilitychange",()=>{this.clearVehicles(),this.needInterpolate=!document.hidden},!1)}setInterpolate(i){this.clearVehicles(),this.needInterpolate=i}async setup(i){this.context=i,this.renderer=new o.WebGLRenderer({context:i.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),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()}geometryTest(){new g.GLTFLoader().load(`${this.assetsRoot}/3DModels/car.glb`,e=>{this.mesh=e.scene,this.mesh.rotation.x=o.MathUtils.degToRad(90);const t=[121.46892831020403,31.239681632841354,0],s=this.toRenderCoordinates(t);this.mesh.position.set(s[0],s[1],s[2]),this.scene.add(this.mesh),new o.TextureLoader().load(`${this.assetsRoot}/Images/PlateBG/grey.png`,r=>{const n=new o.SpriteMaterial({map:r,transparent:!1}),a=new o.Sprite(n);a.scale.set(5,2.5,1),a.position.set(0,5,-4),this.mesh.add(a),console.log(this.mesh.visible,a.visible)})})}async render(i){var s;const e=i.camera;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(new o.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),this.needInterpolate)for(const l of this.vehicleObjectMap.keys()){const r=(s=this.vehicleObjectMap.get(l))==null?void 0:s.model;if(!r)continue;const n=this.computeVehiclePosition(l);if(n){const a=this.toRenderCoordinates(n);r.position.set(a[0],a[1],a[2]),r.rotation.y=o.MathUtils.degToRad(-n[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),b.requestRender(this.view),i.resetWebGLState()}async addVehicles(i){if(!(!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady))for(const e of i){const{vehicleId:t,localTimestamp:s}=e,l=Number(e.x),r=Number(e.y),n=Number(e.heading);this.historyPositionMap.set(t,[{pos:[l,r,0],heading:n,time:s}]);const a=this.getVehicleModel(e);a.name=t,a.visible=!this.needInterpolate;try{const c=await this.createPlateSprite(e);c&&(a.add(c),c.position.set(0,5,-4)),this.scene.add(a),this.vehicleObjectMap.set(t,{model:a,data:e,waitForDelete:!1,isMoving:!1})}catch(c){console.log("createPlateSprite error:",c)}}}async updateVehicles(i){if(!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady)return;const e=[];for(const t of i){const{vehicleId:s,localTimestamp:l}=t,r=Number(t.x),n=Number(t.y);let a=Number(t.heading);const c=this.vehicleObjectMap.get(s);if(!c)e.push(t);else{if(c.data.vehicleColor!==t.vehicleColor||c.data.vehicleType!==t.vehicleType){this.scene.remove(c.model),this.disposeModel(c.model),c.model=this.getVehicleModel(t);const h=await this.createPlateSprite(t);h&&(c.model.add(h),h.position.set(0,5,-4)),this.scene.add(c.model)}if(c.data.showName!==t.showName||c.data.plateColor!==t.plateColor){const h=c.model.getObjectByName("VehiclePlate");h&&(c.model.remove(h),this.disposeModel(h));const d=await this.createPlateSprite(t);d&&(c.model.add(d),d.position.set(0,5,-4))}if(c.data=t,this.needInterpolate){const h=this.historyPositionMap.get(s),d=h[h.length-1];Math.abs(a-d.heading)>=180&&(a>d.heading?d.heading+=360:a+=360),h.push({pos:[r,n,0],heading:a,time:l})}else{this.historyPositionMap.set(s,[{pos:[r,n,0],heading:a,time:l}]);const h=this.toRenderCoordinates([r,n,0]);c.model.position.set(h[0],h[1],h[2]),c.model.rotation.y=o.MathUtils.degToRad(-a)}}}this.addVehicles(e),this.needInterpolate||this.render(this.context)}toRenderCoordinates(i){const e=[0,0,0];return b.toRenderCoordinates(this.view,i,0,S.WGS84,e,0,1),e}deleteVehicles(i){i.forEach(e=>{const t=this.vehicleObjectMap.get(e);t&&(this.needInterpolate?t.isMoving?t.waitForDelete=!0:this.deleteVehicle(t):this.deleteVehicle(t))})}deleteVehicle(i){this.scene.remove(i.model),this.disposeModel(i.model);const e=i.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(i){i.name==="vehiclePlate"&&(i.visible===!0&&this.currentSpriteContent===p.EVehiclePlateState.None?await this.updatePanelContent(p.EVehiclePlateState.Id):await this.updatePanelContent(i.visible?this.currentSpriteContent:p.EVehiclePlateState.None))}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()}async 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");if(s&&(t.model.remove(s),this.disposeModel(s)),i!==p.EVehiclePlateState.None){const l=await this.createPlateSprite(t.data);l&&(t.model.add(l),l.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||!t.isMoving&&e.length<=2)return;const s=Date.now();t.model.visible=!0,t.isMoving=!0,t.segmentStartTime||(t.segmentStartTime=s,t.segmentTotalTime=e[1].time-e[0].time);const l=s-t.segmentStartTime,r=Math.min(l/t.segmentTotalTime,1);if(r===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("pause vehicle",i));return}else 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);else{const n=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*r,a=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*r,c=e[0].heading+(e[1].heading-e[0].heading)*r;return[n,a,0,c]}}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(l=>{!s&&l instanceof o.Mesh&&(l.material=t,s=!0)})}return e}createCanvas(i,e,t){const s=document.createElement("canvas"),l=i.width,r=i.height;s.width=l,s.height=r;const n=s.getContext("2d");if(!n){console.log("canvas创建失败");return}return n.fillStyle="rgba(0,0,0,0.0)",n.fillRect(0,0,l,r),n.drawImage(i,0,0,l,r),n.beginPath(),n.translate(l/2,r/2),n.fillStyle=t,n.font="bold 32px 宋体",n.textBaseline="middle",n.textAlign="center",n.fillText(e,0,0),s}createPlateSprite(i){return new Promise((e,t)=>{var c,h;const s=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===p.EVehiclePlateState.None||this.currentSpriteContent===p.EVehiclePlateState.PlateNumber&&s){e(void 0);return}const l=new Image;let r="",n="",a="";if(this.currentSpriteContent===p.EVehiclePlateState.PlateNumber||this.currentSpriteContent===p.EVehiclePlateState.Mix)if(s)r="grey",n=i.ptcId,a="#ffffff";else switch(n=((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",n=i.plateNo,a="#ffffff";break}else this.currentSpriteContent===p.EVehiclePlateState.Id&&(r="grey",n=i.ptcId,a="#ffffff");l.src=`${this.assetsRoot}/Images/PlateBG/${r}.png`,l.onload=()=>{const d=this.createCanvas(l,n,a);if(!d)t("canvas创建失败");else{const u=new o.CanvasTexture(d),v=new o.SpriteMaterial({map:u,transparent:!1}),M=new o.Sprite(v),m=.05,w=d.width*m,R=d.height*m;M.scale.set(w,R,1),M.name="VehiclePlate",e(M)}l.onerror=u=>{console.log(`号牌背景加载失败: ${l.src}`,u),t(u)}}})}}exports.default=V;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/core/reactiveUtils.js"),R=require("@arcgis/core/geometry/SpatialReference"),S=require("@arcgis/core/views/3d/externalRenderers"),C=require("three"),T=require("three/examples/jsm/loaders/GLTFLoader.js"),p=require("../../../types/index.js"),V=require("../../stores/index.js");function g(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 N=g(P),b=g(S),h=g(C);class k{constructor(i){this.zoomThreshold=18.5,this.roughness=.4,this.metalness=.5,this.defaultMaterial=new h.MeshPhysicalMaterial({color:16777215,emissive:0,roughness:this.roughness,metalness:this.metalness}),this.materialMap=new Map([[1,this.createCarMaterial(16777215)],[2,this.createCarMaterial(7833753)],[3,this.createCarMaterial(16766720)],[4,this.createCarMaterial(16758465)],[5,this.createCarMaterial(14423100)],[6,this.createCarMaterial(3329330)],[7,this.createCarMaterial(2003183)],[8,this.createCarMaterial(16032864)],[9,this.createCarMaterial(2105376)],[10,this.createCarMaterial(9662683)],[99,this.createCarMaterial(6908265)]]),this.carModelReady=!1,this.vanModelReady=!1,this.truckModelReady=!1,this.busModelReady=!1,this.bicycleModelReady=!1,this.showGroundVehicle=!0,this.showElevatedVehicle=!0,this.currentSpriteContent=p.EVehiclePlateState.None,this.historyPositionMap=new Map,this.vehicleObjectMap=new Map,this.needInterpolate=!0,this.updateModel=!1;const e=V.default.useAppDataStore;this.assetsRoot=JSON.parse(JSON.stringify(e.mapConfig)).assetsRoot,this.view=i;const t=new T.GLTFLoader;t.load(`${this.assetsRoot}/3DModels/car.glb`,s=>{this.carModel=s.scene,this.carModel.rotation.x=h.MathUtils.degToRad(90),this.carModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/van.glb`,s=>{this.vanModel=s.scene,this.vanModel.rotation.x=h.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=h.MathUtils.degToRad(90),this.truckModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/bus.glb`,s=>{this.busModel=s.scene,this.busModel.rotation.x=h.MathUtils.degToRad(90),this.busModelReady=!0}),t.load(`${this.assetsRoot}/3DModels/bicycle.glb`,s=>{this.bicycleModel=s.scene,this.bicycleModel.rotation.x=h.MathUtils.degToRad(90),this.bicycleModel.rotation.y=h.MathUtils.degToRad(180),this.bicycleModelReady=!0}),document.addEventListener("visibilitychange",()=>{this.clearVehicles(),this.needInterpolate=!document.hidden},!1),N.watch(()=>this.view.zoom,(s,a)=>{(a<=this.zoomThreshold&&s>this.zoomThreshold||a>this.zoomThreshold&&s<=this.zoomThreshold)&&(this.updateModel=!0)})}createCarMaterial(i){return new h.MeshPhysicalMaterial({color:i,emissive:0,roughness:this.roughness,metalness:this.metalness})}setInterpolate(i){this.clearVehicles(),this.needInterpolate=i}async setup(i){this.context=i,this.renderer=new h.WebGLRenderer({context:i.gl,premultipliedAlpha:!0,logarithmicDepthBuffer:!0,antialias:!0,powerPreference:"high-performance"}),this.renderer.shadowMap.enabled=!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=o=>{e(o),o==null&&i.bindRenderTarget()},this.scene=new h.Scene;const{camera:t}=i;this.camera=new h.PerspectiveCamera(t.fovY,t.aspect,.1,1e5),this.ambient=new h.AmbientLight(16777215,2e4),this.scene.add(this.ambient),this.sun=new h.DirectionalLight(16777215,2e4);const s=[121.46790813287619,31.239514870157972,1e3],a=this.toRenderCoordinates(s);this.sun.position.set(a[0],a[1],a[2]),this.scene.add(this.sun),i.resetWebGLState()}async render(i){var s;const e=i.camera;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(new h.Vector3(e.center[0],e.center[1],e.center[2])),this.camera.projectionMatrix.fromArray(e.projectionMatrix),this.needInterpolate)for(const a of this.vehicleObjectMap.keys()){const o=(s=this.vehicleObjectMap.get(a))==null?void 0:s.model;if(!o)continue;const r=this.computeVehiclePosition(a);if(r){const n=this.toRenderCoordinates(r);o.position.set(n[0],n[1],n[2]),o.rotation.y=h.MathUtils.degToRad(-r[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 h.Color(t.diffuse.color[0],t.diffuse.color[1],t.diffuse.color[2]),this.ambient.intensity=t.ambient.intensity,this.ambient.color=new h.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),b.requestRender(this.view),i.resetWebGLState()}async addVehicles(i){if(!(!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady))for(const e of i){const{vehicleId:t,localTimestamp:s}=e,a=Number(e.x),o=Number(e.y),r=Number(e.heading);this.historyPositionMap.set(t,[{pos:[a,o,0],heading:r,time:s}]);const n=this.getVehicleModel(e);n.name=t,n.visible=!this.needInterpolate;try{const l=await this.createPlateSprite(e);l&&(n.add(l),l.position.set(0,5,-4)),this.scene.add(n),this.vehicleObjectMap.set(t,{model:n,data:e,waitForDelete:!1,isMoving:!1})}catch(l){console.log("createPlateSprite error:",l)}}}async updateVehicles(i){if(!this.carModelReady||!this.vanModelReady||!this.truckModelReady||!this.busModelReady||!this.bicycleModelReady)return;const e=[];for(const t of i){const{vehicleId:s,localTimestamp:a}=t,o=Number(t.x),r=Number(t.y);let n=Number(t.heading);const l=this.vehicleObjectMap.get(s);if(!l)e.push(t);else{if(this.updateModel||l.data.vehicleColor!==t.vehicleColor||l.data.vehicleType!==t.vehicleType){this.scene.remove(l.model),this.disposeModel(l.model),l.model=this.getVehicleModel(t);const c=await this.createPlateSprite(t);c&&(l.model.add(c),c.position.set(0,5,-4)),this.scene.add(l.model)}if(l.data.showName!==t.showName||l.data.plateColor!==t.plateColor){const c=l.model.getObjectByName("VehiclePlate");c&&(l.model.remove(c),this.disposeModel(c));const d=await this.createPlateSprite(t);d&&(l.model.add(d),d.position.set(0,5,-4))}if(l.data=t,this.needInterpolate){const c=this.historyPositionMap.get(s),d=c[c.length-1];Math.abs(n-d.heading)>=180&&(n>d.heading?d.heading+=360:n+=360),c.push({pos:[o,r,0],heading:n,time:a})}else{this.historyPositionMap.set(s,[{pos:[o,r,0],heading:n,time:a}]);const c=this.toRenderCoordinates([o,r,0]);l.model.position.set(c[0],c[1],c[2]),l.model.rotation.y=h.MathUtils.degToRad(-n)}}}this.addVehicles(e),this.updateModel=!1,this.needInterpolate||this.render(this.context)}toRenderCoordinates(i){const e=[0,0,0];return b.toRenderCoordinates(this.view,i,0,R.WGS84,e,0,1),e}deleteVehicles(i){i.forEach(e=>{const t=this.vehicleObjectMap.get(e);t&&(this.needInterpolate?t.isMoving?t.waitForDelete=!0:this.deleteVehicle(t):this.deleteVehicle(t))})}deleteVehicle(i){this.scene.remove(i.model),this.disposeModel(i.model);const e=i.data.vehicleId;this.vehicleObjectMap.delete(e),this.historyPositionMap.delete(e)}async toggleTrafficInfo(i){i.name==="vehiclePlate"&&(i.visible===!0&&this.currentSpriteContent===p.EVehiclePlateState.None?await this.updatePanelContent(p.EVehiclePlateState.PlateNumber):await this.updatePanelContent(i.visible?this.currentSpriteContent:p.EVehiclePlateState.None))}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()}async 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");if(s&&(t.model.remove(s),this.disposeModel(s)),i!==p.EVehiclePlateState.None){const a=await this.createPlateSprite(t.data);a&&(t.model.add(a),a.position.set(0,5,-4))}}}}}toggleGroundVehicle(i){console.log("toggleGroundVehicle",i),this.showGroundVehicle=i}toggleElevatedVehicle(i){this.showElevatedVehicle=i}disposeModel(i){i.traverse(e=>{e instanceof h.Mesh&&(e.geometry.dispose(),e.material.dispose())})}computeVehiclePosition(i){const e=this.historyPositionMap.get(i),t=this.vehicleObjectMap.get(i);if(!t||!e||!t.isMoving&&e.length<=2)return;const s=Date.now();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);const a=s-t.segmentStartTime,o=Math.min(a/t.segmentTotalTime,1);if(o===1)if(e.shift(),e.length===1){t.waitForDelete===!0?this.deleteVehicle(t):(t.segmentStartTime=void 0,t.segmentTotalTime=void 0,t.model.visible=!1,t.isMoving=!1,console.log("pause vehicle",i));return}else 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);else{const r=e[0].pos[0]+(e[1].pos[0]-e[0].pos[0])*o,n=e[0].pos[1]+(e[1].pos[1]-e[0].pos[1])*o,l=e[0].heading+(e[1].heading-e[0].heading)*o;return[r,n,0,l]}}getVehicleModel(i){if(this.view.zoom<=this.zoomThreshold){const e=new h.SphereGeometry(5,32,32),t=new h.MeshPhysicalMaterial({color:325253,emissive:0,roughness:this.roughness,metalness:this.metalness});return new h.Mesh(e,t)}else{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(a=>{!s&&a instanceof h.Mesh&&(a.material=t,s=!0)})}return e}}createCanvas(i,e,t){const s=document.createElement("canvas"),a=i.width,o=i.height;s.width=a,s.height=o;const r=s.getContext("2d");if(!r){console.log("canvas创建失败");return}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}createPlateSprite(i){return new Promise((e,t)=>{var l,c;const s=!i.plateNo||i.plateNo==="0"||i.plateNo==="000000";if(this.currentSpriteContent===p.EVehiclePlateState.None||this.currentSpriteContent===p.EVehiclePlateState.PlateNumber&&s){e(void 0);return}const a=new Image;let o="",r="",n="";if(this.currentSpriteContent===p.EVehiclePlateState.PlateNumber||this.currentSpriteContent===p.EVehiclePlateState.Mix)if(s)o="grey",r=i.ptcId,n="#ffffff";else switch(r=((l=i.showName)==null?void 0:l.substring(0,2))+"•"+((c=i.showName)==null?void 0:c.substring(2)),i.plateColor){case 1:o="blue",n="#ffffff";break;case 2:o="yellow",n="#000000";break;case 3:o="white",n="#000000";break;case 4:o="black";break;case 5:o="neo_yellow",n="#000000";break;case 6:o="neo_green",n="#000000";break;default:o="grey",r=i.plateNo,n="#ffffff";break}else this.currentSpriteContent===p.EVehiclePlateState.Id&&(o="grey",r=i.ptcId,n="#ffffff");a.src=`${this.assetsRoot}/Images/PlateBG/${o}.png`,a.onload=()=>{const d=this.createCanvas(a,r,n);if(!d)t("canvas创建失败");else{const m=new h.CanvasTexture(d),v=new h.SpriteMaterial({map:m,transparent:!1}),f=new h.Sprite(v),M=.05,y=d.width*M,w=d.height*M;f.scale.set(y,w,1),f.name="VehiclePlate",e(f)}a.onerror=m=>{console.log(`号牌背景加载失败: ${a.src}`,m),t(m)}}})}}exports.default=k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),z=require("@arcgis/core/Map"),b=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),O=require("@arcgis/core/geometry/support/webMercatorUtils"),S=require("@arcgis/core/layers/GeoJSONLayer"),W=require("@arcgis/core/layers/TileLayer"),x=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function v(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const T=v(q),p=v(O),G=v(I);function y(r,e){return r.startsWith("http://")||r.startsWith("https://")?r:e+r}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:a,markerClickCallback:n,mapClickCallback:f}=e;b.assetsPath=`${t.assetsRoot}/ArcgisAssets`,b.fontsUrl=`${t.assetsRoot}/fonts`,b.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const l=new z;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:l,container:a,...t.mapOptions}):this.view=new R({map:l,container:a,...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var M,P;if(f){let o=s.mapPoint;o.spatialReference.isWebMercator&&(o=p.webMercatorToGeographic(o)),f([o.x,o.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(o.position),d={heading:o.heading,tilt:o.tilt,position:u.toJSON()};console.log(d),(M=navigator.clipboard)==null||M.writeText(JSON.stringify(d))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=p.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom})}const h=(P=(await this.view.hitTest(s)).results)==null?void 0:P.filter(o=>o.type==="graphic");h.length>0&&h.forEach(o=>{var d;const u=o.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const c=y(s.url,t.assetsRoot),h=new x({urlTemplate:c,...s.options});l.add(h);break}case"tile":{const c=y(s.url,t.assetsRoot),h=new W({url:c,...s.options});l.add(h);break}case"arcgis":{const c=new k(s.options);l.basemap=c;break}}}):l.basemap=new k({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(c=>new S({url:y(c.url,t.assetsRoot),...c.options,title:c.options.id}));l.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,a=this.view.map.findLayerById(i);return a?(a.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const a=Math.tan(i*Math.PI/180)*e.height,n=H(G.point(e.center),a,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:a}=this.mapConfig;if(!a)return{status:-1,message:"未配置camera"};const n=a[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const l=this.transformPoints(e),w=Date.now();w-t>n&&(i(l),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),a=this.view.toScreen(t);return[a.x,a.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,a=>{i&&a<=i&&(this.view.zoom=i),t&&a>=t&&(this.view.zoom=t)}))}}exports.default=N;
|
package/package.json
CHANGED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import Graphic from '@arcgis/core/Graphic';
|
|
2
|
-
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
|
-
import MapView from '@arcgis/core/views/MapView';
|
|
4
|
-
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
interface GreenWaveLineOptions {
|
|
6
|
-
viewer: MapView | SceneView;
|
|
7
|
-
graphicsLayerOptions: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface roadPath {
|
|
12
|
-
paths: [number, number][];
|
|
13
|
-
symbol: any;
|
|
14
|
-
attributes: any;
|
|
15
|
-
visible?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface animationOptions {
|
|
18
|
-
isAnimation: boolean;
|
|
19
|
-
positive?: boolean;
|
|
20
|
-
positiveColor?: number[];
|
|
21
|
-
negative?: boolean;
|
|
22
|
-
negativeColor?: number[];
|
|
23
|
-
}
|
|
24
|
-
export default class GreenWaveLine {
|
|
25
|
-
private viewer;
|
|
26
|
-
overlayLayer: GraphicsLayer;
|
|
27
|
-
customGreenWaveLineView: any;
|
|
28
|
-
material: THREE.ShaderMaterial;
|
|
29
|
-
renderer: THREE.WebGLRenderer;
|
|
30
|
-
threeScene: THREE.Scene;
|
|
31
|
-
camera: THREE.PerspectiveCamera;
|
|
32
|
-
private defaultAnimationOptions;
|
|
33
|
-
constructor(options: GreenWaveLineOptions);
|
|
34
|
-
addGreenWaveLine(paths: roadPath[], options?: animationOptions): void;
|
|
35
|
-
getAnimationPath(paths: [number, number][], options?: animationOptions): any;
|
|
36
|
-
createLine(paths: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
37
|
-
addPointText(points: any[]): void;
|
|
38
|
-
createPointText(point: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
39
|
-
/**
|
|
40
|
-
* 隐藏覆盖物
|
|
41
|
-
*
|
|
42
|
-
* @param {string[]} [ids]
|
|
43
|
-
* @memberof GreenWaveLine
|
|
44
|
-
*/
|
|
45
|
-
hideWaveLine(ids?: string[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* 显示覆盖物
|
|
48
|
-
*
|
|
49
|
-
* @param {string[]} [ids]
|
|
50
|
-
* @memberof GreenWaveLine
|
|
51
|
-
*/
|
|
52
|
-
showWaveLine(ids?: string[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* 隐藏图层
|
|
55
|
-
*
|
|
56
|
-
* @memberof GreenWaveLine
|
|
57
|
-
*/
|
|
58
|
-
hideLayer(): void;
|
|
59
|
-
/**
|
|
60
|
-
* 显示图层
|
|
61
|
-
*
|
|
62
|
-
* @memberof Overlay
|
|
63
|
-
*/
|
|
64
|
-
showLayer(): void;
|
|
65
|
-
clearGreenWaveLine(): void;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import Graphic from '@arcgis/core/Graphic';
|
|
2
|
-
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
3
|
-
import MapView from '@arcgis/core/views/MapView';
|
|
4
|
-
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
-
interface GreenWaveLineOptions {
|
|
6
|
-
viewer: MapView | SceneView;
|
|
7
|
-
graphicsLayerOptions: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface roadPath {
|
|
12
|
-
paths: [number, number][];
|
|
13
|
-
symbol: any;
|
|
14
|
-
attributes: any;
|
|
15
|
-
visible?: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface animationOptions {
|
|
18
|
-
isAnimation: boolean;
|
|
19
|
-
positive?: boolean;
|
|
20
|
-
positiveColor?: number[];
|
|
21
|
-
negative?: boolean;
|
|
22
|
-
negativeColor?: number[];
|
|
23
|
-
}
|
|
24
|
-
export default class GreenWaveLine {
|
|
25
|
-
private viewer;
|
|
26
|
-
overlayLayer: GraphicsLayer;
|
|
27
|
-
customGreenWaveLineView: any;
|
|
28
|
-
material: THREE.ShaderMaterial;
|
|
29
|
-
renderer: THREE.WebGLRenderer;
|
|
30
|
-
threeScene: THREE.Scene;
|
|
31
|
-
camera: THREE.PerspectiveCamera;
|
|
32
|
-
private defaultAnimationOptions;
|
|
33
|
-
constructor(options: GreenWaveLineOptions);
|
|
34
|
-
addGreenWaveLine(paths: roadPath[], options?: animationOptions): void;
|
|
35
|
-
getAnimationPath(paths: [number, number][], options?: animationOptions): any;
|
|
36
|
-
createLine(paths: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
37
|
-
addPointText(points: any[]): void;
|
|
38
|
-
createPointText(point: any, symbol: any, attributes: any, visible: boolean): Graphic;
|
|
39
|
-
/**
|
|
40
|
-
* 隐藏覆盖物
|
|
41
|
-
*
|
|
42
|
-
* @param {string[]} [ids]
|
|
43
|
-
* @memberof GreenWaveLine
|
|
44
|
-
*/
|
|
45
|
-
hideWaveLine(ids?: string[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* 显示覆盖物
|
|
48
|
-
*
|
|
49
|
-
* @param {string[]} [ids]
|
|
50
|
-
* @memberof GreenWaveLine
|
|
51
|
-
*/
|
|
52
|
-
showWaveLine(ids?: string[]): void;
|
|
53
|
-
/**
|
|
54
|
-
* 隐藏图层
|
|
55
|
-
*
|
|
56
|
-
* @memberof GreenWaveLine
|
|
57
|
-
*/
|
|
58
|
-
hideLayer(): void;
|
|
59
|
-
/**
|
|
60
|
-
* 显示图层
|
|
61
|
-
*
|
|
62
|
-
* @memberof Overlay
|
|
63
|
-
*/
|
|
64
|
-
showLayer(): void;
|
|
65
|
-
clearGreenWaveLine(): void;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
}
|
|
68
|
-
export {};
|