cesium-pocket 0.7.1-alpha → 0.7.2-alpha
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/czml.d.ts +2 -0
- package/gauger.d.ts +2 -2
- package/gauger.js +1 -1
- package/index.js +1 -1
- package/package.json +5 -1
- package/polygonSolid-DpagI6AO.js +794 -0
- package/src/czml/path/pathHeightEditor.d.ts +204 -0
- package/src/czml/path/pathHeightMath.d.ts +89 -0
- package/src/gauger/heightPole.d.ts +14 -1
- package/polygonSolid-COmnj9NG.js +0 -754
package/polygonSolid-COmnj9NG.js
DELETED
|
@@ -1,754 +0,0 @@
|
|
|
1
|
-
import { Cartographic as D, EllipsoidGeodesic as j, Cartesian3 as u, BoundingSphere as Z, Transforms as z, Matrix4 as R, CustomDataSource as x, ConstantPositionProperty as w, ConstantProperty as c, Color as h, Cartesian2 as L, VerticalOrigin as C, HorizontalOrigin as P, LabelStyle as v, Math as Y, ScreenSpaceEventHandler as H, ScreenSpaceEventType as y, ArcType as X, PolygonHierarchy as U } from "cesium";
|
|
2
|
-
import { a as K, R as J, P as Q, D as O, C as V, b as _ } from "./CircleDrawer-D2dAuEcD.js";
|
|
3
|
-
const m = (n, e) => {
|
|
4
|
-
const r = D.fromCartesian(n), t = D.fromCartesian(e);
|
|
5
|
-
return new j(r, t).surfaceDistance;
|
|
6
|
-
}, B = (n, e) => {
|
|
7
|
-
const r = new u();
|
|
8
|
-
return u.add(n, e, r), u.divideByScalar(r, 2, r), r;
|
|
9
|
-
}, f = (n) => {
|
|
10
|
-
let e = "";
|
|
11
|
-
return n > 1e3 * 100 ? e = (n / 1e3).toFixed(0) + " 公里" : n > 1e3 ? e = (n / 1e3).toFixed(2) + " 公里" : e = n.toFixed(2) + " 米", e;
|
|
12
|
-
}, A = (n) => {
|
|
13
|
-
if (!n || n.length === 0) return null;
|
|
14
|
-
let e = 0, r = 0, t = 0;
|
|
15
|
-
const i = n.length;
|
|
16
|
-
return n.forEach((a) => {
|
|
17
|
-
e += a.x, r += a.y, t += a.z;
|
|
18
|
-
}), new u(
|
|
19
|
-
e / i,
|
|
20
|
-
r / i,
|
|
21
|
-
t / i
|
|
22
|
-
);
|
|
23
|
-
}, q = (n) => n.reduce((r, t) => r + D.fromCartesian(t).height, 0) / n.length, k = (n) => {
|
|
24
|
-
if (n.length < 3) return 0;
|
|
25
|
-
const r = Z.fromPoints(n).center, t = z.eastNorthUpToFixedFrame(r), i = R.inverse(t, new R()), s = n.map(
|
|
26
|
-
(l) => R.multiplyByPoint(i, l, new u())
|
|
27
|
-
);
|
|
28
|
-
let a = 0;
|
|
29
|
-
for (let l = 0; l < s.length; l++) {
|
|
30
|
-
const o = (l + 1) % s.length;
|
|
31
|
-
a += s[l].x * s[o].y, a -= s[o].x * s[l].y;
|
|
32
|
-
}
|
|
33
|
-
return Math.abs(a / 2);
|
|
34
|
-
}, G = (n) => {
|
|
35
|
-
let e = "";
|
|
36
|
-
return n > 1e3 * 1e3 * 1e3 ? e = (n / 1e3 / 1e3 / 1e4).toFixed(2) + "万平方公里" : n > 1e3 * 100 ? e = (n / 1e3 / 1e3).toFixed(2) + "平方公里" : e = n.toFixed(0) + "平方米", e;
|
|
37
|
-
}, T = (n) => G(k(n));
|
|
38
|
-
class rt {
|
|
39
|
-
constructor(e, r) {
|
|
40
|
-
this.tmpDistanceLabel = null, this.tmpAreaLabel = null, this.distanceLabel = null, this.areaLabel = null, this.dataSource = new x("gagugerDataSource"), this.assistDataSource = new x("assistDataSource"), this.circleEditFun = (t, i) => {
|
|
41
|
-
let s = 0;
|
|
42
|
-
if (this.distanceLabel) {
|
|
43
|
-
s = m(t, i);
|
|
44
|
-
const a = "半径:" + f(s);
|
|
45
|
-
this.distanceLabel.position = new w(i), this.distanceLabel.label && (this.distanceLabel.label.text = new c(a));
|
|
46
|
-
}
|
|
47
|
-
if (this.areaLabel) {
|
|
48
|
-
const a = window.Math.PI * s * s, l = "面积:" + G(a);
|
|
49
|
-
this.areaLabel.position = new w(t), this.areaLabel.label && (this.areaLabel.label.text = new c(l));
|
|
50
|
-
}
|
|
51
|
-
}, this.circleMovingFun = (t, i) => {
|
|
52
|
-
let s = 0;
|
|
53
|
-
if (this.tmpDistanceLabel) {
|
|
54
|
-
s = m(t, i);
|
|
55
|
-
const a = "半径:" + f(s);
|
|
56
|
-
this.tmpDistanceLabel.show = !0, this.tmpDistanceLabel.position = new w(i), this.tmpDistanceLabel.label && (this.tmpDistanceLabel.label.text = new c(a));
|
|
57
|
-
}
|
|
58
|
-
if (this.tmpAreaLabel) {
|
|
59
|
-
const a = window.Math.PI * s * s, l = "面积:" + G(a);
|
|
60
|
-
this.tmpAreaLabel.position = new w(t), this.tmpAreaLabel.label && (this.tmpAreaLabel.label.text = new c(l));
|
|
61
|
-
}
|
|
62
|
-
}, this.circleOverFun = (t, i) => {
|
|
63
|
-
this.tmpDistanceLabel.show = !1, this.tmpAreaLabel.show = !1;
|
|
64
|
-
const s = this.createTextLabel(new u(), "", h.DARKRED), a = this.createTextLabel(new u(), "", h.BLACK);
|
|
65
|
-
this.distanceLabel = this.assistDataSource.entities.add(s), this.areaLabel = this.assistDataSource.entities.add(a), this.circleEditFun(t, i);
|
|
66
|
-
}, this.createTextLabel = (t, i, s = h.DARKRED, a = -20) => {
|
|
67
|
-
const l = {
|
|
68
|
-
text: i,
|
|
69
|
-
font: "12px sans-serif bold",
|
|
70
|
-
fillColor: h.WHITE,
|
|
71
|
-
showBackground: !0,
|
|
72
|
-
backgroundColor: s,
|
|
73
|
-
style: v.FILL_AND_OUTLINE,
|
|
74
|
-
horizontalOrigin: P.CENTER,
|
|
75
|
-
verticalOrigin: C.CENTER,
|
|
76
|
-
pixelOffset: new L(0, a),
|
|
77
|
-
//偏移量
|
|
78
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
position: t,
|
|
82
|
-
label: l
|
|
83
|
-
};
|
|
84
|
-
}, this.viewer = e, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(r);
|
|
85
|
-
}
|
|
86
|
-
start() {
|
|
87
|
-
var t;
|
|
88
|
-
(t = this.circleDrawer) == null || t.start();
|
|
89
|
-
const e = this.createTextLabel(new u(), "", h.DARKRED.withAlpha(0.6)), r = this.createTextLabel(new u(), "", h.BLACK.withAlpha(0.6));
|
|
90
|
-
this.tmpDistanceLabel = this.assistDataSource.entities.add(e), this.tmpAreaLabel = this.assistDataSource.entities.add(r);
|
|
91
|
-
}
|
|
92
|
-
getStatus() {
|
|
93
|
-
var e;
|
|
94
|
-
(e = this.circleDrawer) == null || e.getStatus();
|
|
95
|
-
}
|
|
96
|
-
setEditStatus() {
|
|
97
|
-
var e;
|
|
98
|
-
(e = this.circleDrawer) == null || e.setEditStatus();
|
|
99
|
-
}
|
|
100
|
-
clearAll() {
|
|
101
|
-
var e;
|
|
102
|
-
(e = this.circleDrawer) == null || e.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
|
|
103
|
-
}
|
|
104
|
-
init(e) {
|
|
105
|
-
let t = { ...{
|
|
106
|
-
circleEditFun: this.circleEditFun,
|
|
107
|
-
circleMovingFun: this.circleMovingFun,
|
|
108
|
-
circleOverFun: this.circleOverFun
|
|
109
|
-
}, ...e };
|
|
110
|
-
this.circleDrawer = new K(this.viewer, t);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
class nt {
|
|
114
|
-
constructor(e, r) {
|
|
115
|
-
this.tmpLabel = null, this.totalLabel = null, this.dataSource = new x("gagugerDataSource"), this.assistDataSource = new x("assistDataSource"), this.rectEditFun = (t) => {
|
|
116
|
-
if (this.totalLabel) {
|
|
117
|
-
const i = A(t), s = "面积:" + T(t);
|
|
118
|
-
i && (this.totalLabel.show = !0, this.totalLabel.position = new w(i), this.totalLabel.label && (this.totalLabel.label.text = new c(s)));
|
|
119
|
-
}
|
|
120
|
-
}, this.rectMovingFun = (t) => {
|
|
121
|
-
if (this.tmpLabel) {
|
|
122
|
-
const i = A(t), s = "面积:" + T(t);
|
|
123
|
-
i && (this.tmpLabel.show = !0, this.tmpLabel.position = new w(i), this.tmpLabel.label && (this.tmpLabel.label.text = new c(s)));
|
|
124
|
-
}
|
|
125
|
-
}, this.rectOverFun = (t) => {
|
|
126
|
-
if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
|
|
127
|
-
const i = A(t), s = "面积:" + T(t);
|
|
128
|
-
if (i) {
|
|
129
|
-
const a = this.createTextlabel(i, s, h.BLACK);
|
|
130
|
-
this.totalLabel = this.assistDataSource.entities.add(a);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}, this.createTextlabel = (t, i, s = h.DARKRED, a = 0) => {
|
|
134
|
-
const l = {
|
|
135
|
-
text: i,
|
|
136
|
-
font: "12px sans-serif bold",
|
|
137
|
-
fillColor: h.WHITE,
|
|
138
|
-
showBackground: !0,
|
|
139
|
-
backgroundColor: s,
|
|
140
|
-
style: v.FILL_AND_OUTLINE,
|
|
141
|
-
horizontalOrigin: P.CENTER,
|
|
142
|
-
verticalOrigin: C.CENTER,
|
|
143
|
-
pixelOffset: new L(0, a),
|
|
144
|
-
//偏移量
|
|
145
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
146
|
-
};
|
|
147
|
-
return {
|
|
148
|
-
position: t,
|
|
149
|
-
label: l
|
|
150
|
-
};
|
|
151
|
-
}, this.createTmplabel = () => {
|
|
152
|
-
let i = {
|
|
153
|
-
position: new u(),
|
|
154
|
-
label: {
|
|
155
|
-
text: "",
|
|
156
|
-
font: "12px sans-serif bold",
|
|
157
|
-
fillColor: h.WHITE,
|
|
158
|
-
showBackground: !0,
|
|
159
|
-
backgroundColor: h.BLACK.withAlpha(0.6),
|
|
160
|
-
style: v.FILL_AND_OUTLINE,
|
|
161
|
-
horizontalOrigin: P.LEFT,
|
|
162
|
-
verticalOrigin: C.BOTTOM,
|
|
163
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
164
|
-
},
|
|
165
|
-
show: !1
|
|
166
|
-
};
|
|
167
|
-
return this.assistDataSource.entities.add(i);
|
|
168
|
-
}, this.viewer = e, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(r);
|
|
169
|
-
}
|
|
170
|
-
start() {
|
|
171
|
-
var e;
|
|
172
|
-
(e = this.rectDrawer) == null || e.start(), this.tmpLabel = this.createTmplabel();
|
|
173
|
-
}
|
|
174
|
-
getStatus() {
|
|
175
|
-
var e;
|
|
176
|
-
(e = this.rectDrawer) == null || e.getStatus();
|
|
177
|
-
}
|
|
178
|
-
setEditStatus() {
|
|
179
|
-
var e;
|
|
180
|
-
(e = this.rectDrawer) == null || e.setEditStatus();
|
|
181
|
-
}
|
|
182
|
-
clearAll() {
|
|
183
|
-
var e;
|
|
184
|
-
(e = this.rectDrawer) == null || e.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
|
|
185
|
-
}
|
|
186
|
-
init(e) {
|
|
187
|
-
let t = { ...{
|
|
188
|
-
rectEditFun: this.rectEditFun,
|
|
189
|
-
rectMovingFun: this.rectMovingFun,
|
|
190
|
-
rectOverFun: this.rectOverFun
|
|
191
|
-
}, ...e };
|
|
192
|
-
this.rectDrawer = new J(this.viewer, t);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
const $ = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAMgCAYAAABYroDnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc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xFMdT1B/XHV05BRtXtU9nOO7GL77RAhzr5wchvupoRbsc4sMZEy5eN8rUaNxsUYvjCHycuqo3QrySSt1ur1sJ+kWIay1uH433Yx2uc/nCnKtdfHTOpSblubTKnU1lskypsJYqwZ200sX4Pq101+dYvmNF+TreV5mVqitz9hMbaWSuFd1e68k2bj4vUf8Utw9Qt3Y7mdZ36ofHqbScTj3DiSVB76X+4n+V6R8BBgDKRo2v+bLvIgAAAABJRU5ErkJggg==";
|
|
196
|
-
class lt {
|
|
197
|
-
constructor(e, r) {
|
|
198
|
-
this.editCallback = (t, i) => {
|
|
199
|
-
const s = this.getLonLatStr(t);
|
|
200
|
-
i.label && i.label.text && (i.label.text = new c(s));
|
|
201
|
-
}, this.billboardCallback = (t) => {
|
|
202
|
-
const i = this.getLonLatStr(t);
|
|
203
|
-
return this.viewer.entities.add({
|
|
204
|
-
position: t,
|
|
205
|
-
label: {
|
|
206
|
-
text: i,
|
|
207
|
-
font: "500 14px Helvetica",
|
|
208
|
-
style: v.FILL,
|
|
209
|
-
fillColor: h.WHITE,
|
|
210
|
-
outlineColor: h.BLACK,
|
|
211
|
-
pixelOffset: new L(0, -90),
|
|
212
|
-
//偏移量
|
|
213
|
-
showBackground: !0,
|
|
214
|
-
backgroundColor: h.ORANGERED,
|
|
215
|
-
horizontalOrigin: P.LEFT
|
|
216
|
-
},
|
|
217
|
-
billboard: {
|
|
218
|
-
image: $,
|
|
219
|
-
width: 30,
|
|
220
|
-
height: 100,
|
|
221
|
-
scale: 1,
|
|
222
|
-
verticalOrigin: C.BOTTOM
|
|
223
|
-
},
|
|
224
|
-
show: !0
|
|
225
|
-
});
|
|
226
|
-
}, this.viewer = e, r ? (this.addPointFun = r.addBillboardFun ? r.addBillboardFun : this.billboardCallback, this.editPointFun = r.editPointFun ? r.editPointFun : this.editCallback, this.delConfirmFun = r.delConfirmFun) : (this.addPointFun = this.billboardCallback, this.editPointFun = this.editCallback), this.init();
|
|
227
|
-
}
|
|
228
|
-
start() {
|
|
229
|
-
var e;
|
|
230
|
-
(e = this.pointDrawer) == null || e.start();
|
|
231
|
-
}
|
|
232
|
-
getStatus() {
|
|
233
|
-
var e;
|
|
234
|
-
(e = this.pointDrawer) == null || e.getStatus();
|
|
235
|
-
}
|
|
236
|
-
setEditStatus() {
|
|
237
|
-
var e;
|
|
238
|
-
(e = this.pointDrawer) == null || e.setEditStatus();
|
|
239
|
-
}
|
|
240
|
-
setDelStatus() {
|
|
241
|
-
var e;
|
|
242
|
-
(e = this.pointDrawer) == null || e.setDelStatus();
|
|
243
|
-
}
|
|
244
|
-
clearAll() {
|
|
245
|
-
var e;
|
|
246
|
-
(e = this.pointDrawer) == null || e.clearAll();
|
|
247
|
-
}
|
|
248
|
-
getEntities() {
|
|
249
|
-
var e;
|
|
250
|
-
return (e = this.pointDrawer) == null ? void 0 : e.getEntities();
|
|
251
|
-
}
|
|
252
|
-
init() {
|
|
253
|
-
let e = {
|
|
254
|
-
addPointFun: this.addPointFun,
|
|
255
|
-
editPointFun: this.editPointFun
|
|
256
|
-
};
|
|
257
|
-
this.delConfirmFun && (e.delConfirmFun = this.delConfirmFun), this.pointDrawer = new Q(this.viewer, e);
|
|
258
|
-
}
|
|
259
|
-
getLonLatStr(e) {
|
|
260
|
-
const r = D.fromCartesian(e), t = Y.toDegrees(r.longitude), i = Y.toDegrees(r.latitude);
|
|
261
|
-
return `${t.toFixed(2)}, ${i.toFixed(2)}`;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
class ot {
|
|
265
|
-
constructor(e, r) {
|
|
266
|
-
this.tmpLabel = null, this.totalLabel = null, this.itemDisSource = new x("itemDisDataSource"), this.totalDisSource = new x("totalDisSource"), this.afterAddPointFun = (t) => {
|
|
267
|
-
var i, s, a;
|
|
268
|
-
if (((i = this.lineDrawer) == null ? void 0 : i.getStatus()) == O.DRAWABLE) {
|
|
269
|
-
const l = (s = t.position) == null ? void 0 : s.getValue(), o = this.lineDrawer.getPositions();
|
|
270
|
-
let b = o.length;
|
|
271
|
-
if (b > 1) {
|
|
272
|
-
const p = B(o[b - 2], l), S = m(o[b - 2], l), d = f(S);
|
|
273
|
-
let g = this.createTextlabel(p, d);
|
|
274
|
-
this.itemDisSource.entities.add(g);
|
|
275
|
-
}
|
|
276
|
-
} else ((a = this.lineDrawer) == null ? void 0 : a.getStatus()) == O.EDITABLE && this.reCreateAll();
|
|
277
|
-
}, this.movingCallbackFun = (t) => {
|
|
278
|
-
if (this.tmpLabel) {
|
|
279
|
-
const i = this.lineDrawer.getPositions(), s = i[i.length - 1];
|
|
280
|
-
let a = m(s, t), l = f(a);
|
|
281
|
-
this.tmpLabel.show = !0, this.tmpLabel.position = new w(t), this.tmpLabel.label && (this.tmpLabel.label.text = new c(l));
|
|
282
|
-
}
|
|
283
|
-
}, this.editCallbackFun = (t, i) => {
|
|
284
|
-
const s = this.lineDrawer.getPositions();
|
|
285
|
-
let a = -1, l = -1, o = 0, b = 0;
|
|
286
|
-
if (i > 0) {
|
|
287
|
-
a = i;
|
|
288
|
-
const d = this.itemDisSource.entities.values[i - 1], g = s[i - 1], E = B(g, t);
|
|
289
|
-
o = m(g, t);
|
|
290
|
-
const F = f(o);
|
|
291
|
-
d.position = new w(E), d.label.text = new c(F);
|
|
292
|
-
}
|
|
293
|
-
if (i < s.length - 1) {
|
|
294
|
-
l = i + 1;
|
|
295
|
-
const d = this.itemDisSource.entities.values[i], g = s[i + 1], E = B(t, g);
|
|
296
|
-
b = m(t, g);
|
|
297
|
-
const F = f(b);
|
|
298
|
-
d.position = new w(E), d.label.text = new c(F);
|
|
299
|
-
}
|
|
300
|
-
i == s.length - 1 && this.totalLabel && (this.totalLabel.position = new w(t));
|
|
301
|
-
let p = 0;
|
|
302
|
-
for (let d = 1, g = s.length; d < g; d++) {
|
|
303
|
-
if (a == d || l == d)
|
|
304
|
-
continue;
|
|
305
|
-
const E = s[d - 1], F = s[d], W = m(E, F);
|
|
306
|
-
p += W;
|
|
307
|
-
}
|
|
308
|
-
p += o, p += b;
|
|
309
|
-
let S = "共:" + f(p);
|
|
310
|
-
this.totalLabel && (this.totalLabel.label.text = new c(S));
|
|
311
|
-
}, this.stopDrawCallbackFun = () => {
|
|
312
|
-
if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
|
|
313
|
-
const t = this.lineDrawer.getPositions();
|
|
314
|
-
let i = 0, s = t.length;
|
|
315
|
-
for (let o = 1; o < s; o++) {
|
|
316
|
-
const b = t[o - 1], p = t[o], S = m(b, p);
|
|
317
|
-
i += S;
|
|
318
|
-
}
|
|
319
|
-
let a = "共:" + f(i), l = this.createTextlabel(t[s - 1], a, h.BLACK, -20);
|
|
320
|
-
this.totalLabel = this.totalDisSource.entities.add(l);
|
|
321
|
-
}
|
|
322
|
-
}, this.createTextlabel = (t, i, s = h.DARKRED, a = 0) => {
|
|
323
|
-
const l = {
|
|
324
|
-
text: i,
|
|
325
|
-
font: "12px sans-serif bold",
|
|
326
|
-
fillColor: h.WHITE,
|
|
327
|
-
showBackground: !0,
|
|
328
|
-
backgroundColor: s,
|
|
329
|
-
style: v.FILL_AND_OUTLINE,
|
|
330
|
-
horizontalOrigin: P.CENTER,
|
|
331
|
-
verticalOrigin: C.CENTER,
|
|
332
|
-
pixelOffset: new L(0, a),
|
|
333
|
-
//偏移量
|
|
334
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
335
|
-
};
|
|
336
|
-
return {
|
|
337
|
-
position: t,
|
|
338
|
-
label: l
|
|
339
|
-
};
|
|
340
|
-
}, this.reCreateAll = () => {
|
|
341
|
-
this.itemDisSource.entities.removeAll(), this.totalDisSource.entities.removeAll();
|
|
342
|
-
const t = this.lineDrawer.getPositions();
|
|
343
|
-
let i = 0, s = t.length;
|
|
344
|
-
for (let o = 1; o < s; o++) {
|
|
345
|
-
const b = t[o - 1], p = t[o], S = B(b, p), d = m(b, p);
|
|
346
|
-
i += d;
|
|
347
|
-
let g = f(d), E = this.createTextlabel(S, g);
|
|
348
|
-
this.itemDisSource.entities.add(E);
|
|
349
|
-
}
|
|
350
|
-
let a = "共:" + f(i), l = this.createTextlabel(t[s - 1], a, h.BLACK, -20);
|
|
351
|
-
this.totalLabel = this.totalDisSource.entities.add(l);
|
|
352
|
-
}, this.viewer = e, this.viewer.dataSources.add(this.itemDisSource), this.viewer.dataSources.add(this.totalDisSource), this.init(r);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* 开始绘制
|
|
356
|
-
*/
|
|
357
|
-
start() {
|
|
358
|
-
var e;
|
|
359
|
-
(e = this.lineDrawer) == null || e.start();
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* 获取状态
|
|
363
|
-
*/
|
|
364
|
-
getStatus() {
|
|
365
|
-
var e;
|
|
366
|
-
(e = this.lineDrawer) == null || e.getStatus();
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* 进入编辑状态
|
|
370
|
-
*/
|
|
371
|
-
setEditStatus() {
|
|
372
|
-
var e;
|
|
373
|
-
(e = this.lineDrawer) == null || e.setEditStatus(), this.stopDrawCallbackFun();
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* 进入删除状态
|
|
377
|
-
*/
|
|
378
|
-
setDelStatus() {
|
|
379
|
-
var e;
|
|
380
|
-
(e = this.lineDrawer) == null || e.setDelStatus(), this.stopDrawCallbackFun();
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* 全部清理
|
|
384
|
-
*/
|
|
385
|
-
clearAll() {
|
|
386
|
-
var e;
|
|
387
|
-
(e = this.lineDrawer) == null || e.clearAll(), this.itemDisSource.entities.removeAll(), this.totalDisSource.entities.removeAll();
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* 初始化
|
|
391
|
-
* @param options
|
|
392
|
-
*/
|
|
393
|
-
init(e) {
|
|
394
|
-
let t = { ...{
|
|
395
|
-
afterAddPointFun: this.afterAddPointFun,
|
|
396
|
-
movingCallbackFun: this.movingCallbackFun,
|
|
397
|
-
editCallbackFun: this.editCallbackFun,
|
|
398
|
-
stopDrawCallbackFun: this.stopDrawCallbackFun,
|
|
399
|
-
delCallbackFun: this.reCreateAll
|
|
400
|
-
}, ...e };
|
|
401
|
-
this.lineDrawer = new V(this.viewer, t);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
class ht {
|
|
405
|
-
constructor(e, r) {
|
|
406
|
-
this.tmpLabel = null, this.totalLabel = null, this.openTmpLabel = !1, this.dataSource = new x("gagugerDataSource"), this.assistDataSource = new x("totalAreaDataSource"), this.afterAddPointFun = () => {
|
|
407
|
-
var t, i;
|
|
408
|
-
((t = this.polygonDrawer) == null ? void 0 : t.getStatus()) == O.DRAWABLE ? this.polygonDrawer.getPositions().length > 1 && (this.openTmpLabel = !0) : ((i = this.polygonDrawer) == null ? void 0 : i.getStatus()) == O.EDITABLE && this.reCreateAll();
|
|
409
|
-
}, this.movingCallbackFun = (t) => {
|
|
410
|
-
if (this.openTmpLabel && this.tmpLabel) {
|
|
411
|
-
const s = [...this.polygonDrawer.getPositions(), t], a = A(s), l = "面积:" + T(s);
|
|
412
|
-
a && (this.tmpLabel.show = !0, this.tmpLabel.position = new w(a), this.tmpLabel.label && (this.tmpLabel.label.text = new c(l)));
|
|
413
|
-
}
|
|
414
|
-
}, this.editCallbackFun = (t) => {
|
|
415
|
-
if (this.openTmpLabel && this.totalLabel) {
|
|
416
|
-
const s = [...this.polygonDrawer.getPositions(), t], a = A(s), l = "面积:" + T(s);
|
|
417
|
-
a && (this.totalLabel.show = !0, this.totalLabel.position = new w(a), this.totalLabel.label && (this.totalLabel.label.text = new c(l)));
|
|
418
|
-
}
|
|
419
|
-
}, this.stopDrawCallbackFun = () => {
|
|
420
|
-
if (this.tmpLabel && (this.tmpLabel.show = !1), !this.totalLabel) {
|
|
421
|
-
const t = this.polygonDrawer.getPositions(), i = A(t), s = "面积:" + T(t);
|
|
422
|
-
if (i) {
|
|
423
|
-
const a = this.createTextlabel(i, s, h.BLACK);
|
|
424
|
-
this.totalLabel = this.assistDataSource.entities.add(a);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}, this.createTextlabel = (t, i, s = h.DARKRED, a = 0) => {
|
|
428
|
-
const l = {
|
|
429
|
-
text: i,
|
|
430
|
-
font: "12px sans-serif bold",
|
|
431
|
-
fillColor: h.WHITE,
|
|
432
|
-
showBackground: !0,
|
|
433
|
-
backgroundColor: s,
|
|
434
|
-
style: v.FILL_AND_OUTLINE,
|
|
435
|
-
horizontalOrigin: P.CENTER,
|
|
436
|
-
verticalOrigin: C.CENTER,
|
|
437
|
-
pixelOffset: new L(0, a),
|
|
438
|
-
//偏移量
|
|
439
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
440
|
-
};
|
|
441
|
-
return {
|
|
442
|
-
position: t,
|
|
443
|
-
label: l
|
|
444
|
-
};
|
|
445
|
-
}, this.createTmplabel = () => {
|
|
446
|
-
let i = {
|
|
447
|
-
position: new u(),
|
|
448
|
-
label: {
|
|
449
|
-
text: "",
|
|
450
|
-
font: "12px sans-serif bold",
|
|
451
|
-
fillColor: h.WHITE,
|
|
452
|
-
showBackground: !0,
|
|
453
|
-
backgroundColor: h.BLACK.withAlpha(0.6),
|
|
454
|
-
style: v.FILL_AND_OUTLINE,
|
|
455
|
-
horizontalOrigin: P.CENTER,
|
|
456
|
-
verticalOrigin: C.CENTER,
|
|
457
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
458
|
-
},
|
|
459
|
-
show: !1
|
|
460
|
-
};
|
|
461
|
-
return this.assistDataSource.entities.add(i);
|
|
462
|
-
}, this.reCreateAll = () => {
|
|
463
|
-
this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
|
|
464
|
-
const t = this.polygonDrawer.getPositions(), i = A(t), s = T(t);
|
|
465
|
-
if (i) {
|
|
466
|
-
const a = this.createTextlabel(i, s, h.BLACK);
|
|
467
|
-
this.totalLabel = this.assistDataSource.entities.add(a);
|
|
468
|
-
}
|
|
469
|
-
}, this.viewer = e, this.viewer.dataSources.add(this.dataSource), this.viewer.dataSources.add(this.assistDataSource), this.init(r);
|
|
470
|
-
}
|
|
471
|
-
start() {
|
|
472
|
-
var e;
|
|
473
|
-
(e = this.polygonDrawer) == null || e.start(), this.tmpLabel = this.createTmplabel();
|
|
474
|
-
}
|
|
475
|
-
getStatus() {
|
|
476
|
-
var e;
|
|
477
|
-
(e = this.polygonDrawer) == null || e.getStatus();
|
|
478
|
-
}
|
|
479
|
-
setEditStatus() {
|
|
480
|
-
var e;
|
|
481
|
-
(e = this.polygonDrawer) == null || e.setEditStatus(), this.stopDrawCallbackFun();
|
|
482
|
-
}
|
|
483
|
-
setDelStatus() {
|
|
484
|
-
var e;
|
|
485
|
-
(e = this.polygonDrawer) == null || e.setDelStatus(), this.stopDrawCallbackFun();
|
|
486
|
-
}
|
|
487
|
-
clearAll() {
|
|
488
|
-
var e;
|
|
489
|
-
(e = this.polygonDrawer) == null || e.clearAll(), this.dataSource.entities.removeAll(), this.assistDataSource.entities.removeAll();
|
|
490
|
-
}
|
|
491
|
-
init(e) {
|
|
492
|
-
let t = { ...{
|
|
493
|
-
drawerMode: _.POLYGON,
|
|
494
|
-
afterAddPointFun: this.afterAddPointFun,
|
|
495
|
-
movingCallbackFun: this.movingCallbackFun,
|
|
496
|
-
editCallbackFun: this.editCallbackFun,
|
|
497
|
-
stopDrawCallbackFun: this.stopDrawCallbackFun,
|
|
498
|
-
delCallbackFun: this.reCreateAll
|
|
499
|
-
}, ...e };
|
|
500
|
-
this.polygonDrawer = new V(this.viewer, t);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
let I = null;
|
|
504
|
-
const tt = (n) => n >= 1e3 ? `${(n / 1e3).toFixed(2)} km` : `${n.toFixed(2)} m`, et = (n, e, r) => {
|
|
505
|
-
const t = D.fromCartesian(n);
|
|
506
|
-
return u.fromRadians(t.longitude, t.latitude, e + r);
|
|
507
|
-
};
|
|
508
|
-
class ct {
|
|
509
|
-
constructor(e) {
|
|
510
|
-
this.records = /* @__PURE__ */ new Map(), this.drag = null, this.cameraHeld = !1, this.destroyed = !1, this.lastPosition = { x: 0, y: 0 }, this.applyExtrude = (t, i) => {
|
|
511
|
-
const s = Math.max(0, i);
|
|
512
|
-
t.extrude = s;
|
|
513
|
-
const a = t.baseHeight + s;
|
|
514
|
-
t.disk.ellipse.height = new c(a + (s < 0.05 ? 0.8 : 0));
|
|
515
|
-
const l = et(t.base, t.baseHeight, s);
|
|
516
|
-
t.line.polyline.positions = new c([t.base, l]), t.line.show = s > 0.05, t.label.position = new w(l), t.label.label.text = new c(`高度:${tt(s)}`), t.label.show = s > 0.05, this.viewer.isDestroyed() || this.viewer.scene.requestRender();
|
|
517
|
-
}, this.metersPerPixel = (t) => {
|
|
518
|
-
const i = Math.max(u.distance(this.viewer.camera.positionWC, t), 1), a = this.viewer.camera.frustum.fovy ?? Math.PI / 3;
|
|
519
|
-
return 2 * i * Math.tan(a / 2) / Math.max(this.viewer.scene.canvas.clientHeight, 1);
|
|
520
|
-
}, this.find = (t) => {
|
|
521
|
-
if (this.destroyed || this.viewer.isDestroyed()) return null;
|
|
522
|
-
const i = this.viewer.scene.drillPick(new L(t.x, t.y));
|
|
523
|
-
for (const s of i) {
|
|
524
|
-
const a = s == null ? void 0 : s.id;
|
|
525
|
-
if (!(!a || typeof a.id != "string") && this.records.has(a.id))
|
|
526
|
-
return this.records.get(a.id) ?? null;
|
|
527
|
-
}
|
|
528
|
-
return null;
|
|
529
|
-
}, this.hover = (t) => {
|
|
530
|
-
if (this.drag || this.destroyed || this.viewer.isDestroyed()) return;
|
|
531
|
-
const i = this.viewer.scene.canvas;
|
|
532
|
-
if (this.find(t)) {
|
|
533
|
-
I = this, i.style.cursor = "ns-resize";
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
I === this && (I = null, i.style.cursor = "default");
|
|
537
|
-
}, this.onDown = (t) => {
|
|
538
|
-
const i = this.find(t.position);
|
|
539
|
-
!i || this.viewer.isDestroyed() || (this.drag = {
|
|
540
|
-
record: i,
|
|
541
|
-
startY: t.position.y,
|
|
542
|
-
startExtrude: i.extrude,
|
|
543
|
-
metersPerPixel: this.metersPerPixel(i.base)
|
|
544
|
-
}, this.viewer.scene.screenSpaceCameraController.enableRotate = !1, this.viewer.scene.canvas.style.cursor = "ns-resize");
|
|
545
|
-
}, this.onMove = (t) => {
|
|
546
|
-
if (this.lastPosition = t.endPosition, !this.drag) {
|
|
547
|
-
this.hover(t.endPosition);
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
const i = this.drag.startY - t.endPosition.y;
|
|
551
|
-
this.applyExtrude(this.drag.record, this.drag.startExtrude + i * this.drag.metersPerPixel);
|
|
552
|
-
}, this.onUp = () => {
|
|
553
|
-
!this.drag || this.viewer.isDestroyed() || (this.drag = null, this.viewer.scene.screenSpaceCameraController.enableRotate = !0, this.hover(this.lastPosition), this.viewer.scene.requestRender());
|
|
554
|
-
}, this.canvasPosition = (t) => {
|
|
555
|
-
const i = this.viewer.scene.canvas.getBoundingClientRect();
|
|
556
|
-
return { x: t.clientX - i.left, y: t.clientY - i.top };
|
|
557
|
-
}, this.stopCamera = (t) => {
|
|
558
|
-
t.button !== 0 || this.destroyed || !this.find(this.canvasPosition(t)) || (this.viewer.scene.screenSpaceCameraController.enableRotate = !1, this.cameraHeld = !0);
|
|
559
|
-
}, this.restoreCamera = () => {
|
|
560
|
-
!this.cameraHeld || this.viewer.isDestroyed() || (this.cameraHeld = !1, this.viewer.scene.screenSpaceCameraController.enableRotate = !0);
|
|
561
|
-
}, this.viewer = e, this.handler = new H(e.scene.canvas), this.handler.setInputAction(this.onDown, y.LEFT_DOWN), this.handler.setInputAction(this.onMove, y.MOUSE_MOVE), this.handler.setInputAction(this.onUp, y.LEFT_UP);
|
|
562
|
-
const r = e.scene.canvas;
|
|
563
|
-
r.addEventListener("pointerdown", this.stopCamera, !0), r.addEventListener("pointerup", this.restoreCamera, !0), r.addEventListener("pointercancel", this.restoreCamera, !0);
|
|
564
|
-
}
|
|
565
|
-
add(e) {
|
|
566
|
-
if (this.destroyed || this.viewer.isDestroyed()) return;
|
|
567
|
-
const r = u.clone(e), t = D.fromCartesian(r).height, i = Math.max(this.metersPerPixel(r) * 12, 8), s = this.viewer.entities.add({
|
|
568
|
-
position: r,
|
|
569
|
-
ellipse: {
|
|
570
|
-
semiMajorAxis: i,
|
|
571
|
-
semiMinorAxis: i,
|
|
572
|
-
height: t + 0.8,
|
|
573
|
-
material: h.CYAN.withAlpha(0.55)
|
|
574
|
-
}
|
|
575
|
-
}), a = this.viewer.entities.add({
|
|
576
|
-
polyline: {
|
|
577
|
-
positions: [r, r],
|
|
578
|
-
width: 4,
|
|
579
|
-
material: h.CYAN,
|
|
580
|
-
arcType: X.NONE
|
|
581
|
-
},
|
|
582
|
-
show: !1
|
|
583
|
-
}), l = this.viewer.entities.add({
|
|
584
|
-
position: r,
|
|
585
|
-
show: !1,
|
|
586
|
-
label: {
|
|
587
|
-
text: "高度:0 m",
|
|
588
|
-
font: "16px sans-serif",
|
|
589
|
-
fillColor: h.WHITE,
|
|
590
|
-
outlineColor: h.BLACK,
|
|
591
|
-
outlineWidth: 2,
|
|
592
|
-
style: v.FILL_AND_OUTLINE,
|
|
593
|
-
showBackground: !0,
|
|
594
|
-
backgroundColor: h.BLACK.withAlpha(0.7),
|
|
595
|
-
pixelOffset: new L(0, -12),
|
|
596
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
597
|
-
verticalOrigin: C.BOTTOM
|
|
598
|
-
}
|
|
599
|
-
}), o = { disk: s, line: a, label: l, base: r, baseHeight: t, extrude: 0 };
|
|
600
|
-
this.records.set(s.id, o), this.records.set(a.id, o), this.records.set(l.id, o), this.viewer.scene.requestRender();
|
|
601
|
-
}
|
|
602
|
-
hits(e) {
|
|
603
|
-
return this.find(e) !== null;
|
|
604
|
-
}
|
|
605
|
-
destroy() {
|
|
606
|
-
if (this.destroyed) return;
|
|
607
|
-
this.destroyed = !0, I === this && (I = null, this.viewer.isDestroyed() || (this.viewer.scene.canvas.style.cursor = "default"));
|
|
608
|
-
const e = this.viewer.isDestroyed() ? null : this.viewer.scene.canvas;
|
|
609
|
-
if (e == null || e.removeEventListener("pointerdown", this.stopCamera, !0), e == null || e.removeEventListener("pointerup", this.restoreCamera, !0), e == null || e.removeEventListener("pointercancel", this.restoreCamera, !0), this.handler.isDestroyed() || this.handler.destroy(), e && this.cameraHeld && (this.viewer.scene.screenSpaceCameraController.enableRotate = !0), !this.viewer.isDestroyed()) {
|
|
610
|
-
const r = /* @__PURE__ */ new Set();
|
|
611
|
-
this.records.forEach((t) => {
|
|
612
|
-
[t.disk, t.line, t.label].forEach((i) => {
|
|
613
|
-
r.has(i) || (r.add(i), this.viewer.entities.remove(i));
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
this.drag = null, this.records.clear();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
let M = null;
|
|
621
|
-
const it = (n) => n >= 1e8 ? `${(n / 1e8).toFixed(2)} 亿 m³` : n >= 1e4 ? `${(n / 1e4).toFixed(2)} 万 m³` : `${n.toFixed(2)} m³`;
|
|
622
|
-
class N {
|
|
623
|
-
constructor(e) {
|
|
624
|
-
this.records = /* @__PURE__ */ new Map(), this.drag = null, this.cameraHeld = !1, this.paused = !1, this.destroyed = !1, this.lastPosition = { x: 0, y: 0 }, this.currentExtrude = (t, i) => {
|
|
625
|
-
var a;
|
|
626
|
-
const s = (a = t.extrudedHeight) == null ? void 0 : a.getValue(this.viewer.clock.currentTime);
|
|
627
|
-
return typeof s != "number" ? 0 : Math.max(0, s - i);
|
|
628
|
-
}, this.applyExtrude = (t, i) => {
|
|
629
|
-
const s = Math.max(0, i);
|
|
630
|
-
t.extrude = s, t.graphic.height = new c(t.baseHeight), t.graphic.extrudedHeight = s > 0.05 ? new c(t.baseHeight + s) : void 0;
|
|
631
|
-
const a = D.fromCartesian(t.center), l = u.fromRadians(a.longitude, a.latitude, t.baseHeight + s);
|
|
632
|
-
t.label.position = new w(l), t.label.label.text = new c(`体积:${it(t.area * s)}`), t.label.show = s > 0.05, this.viewer.isDestroyed() || this.viewer.scene.requestRender();
|
|
633
|
-
}, this.metersPerPixel = (t) => {
|
|
634
|
-
const i = Math.max(u.distance(this.viewer.camera.positionWC, t), 1), a = this.viewer.camera.frustum.fovy ?? Math.PI / 3;
|
|
635
|
-
return 2 * i * Math.tan(a / 2) / Math.max(this.viewer.scene.canvas.clientHeight, 1);
|
|
636
|
-
}, this.createLabel = (t, i) => {
|
|
637
|
-
const s = D.fromCartesian(t);
|
|
638
|
-
return this.viewer.entities.add({
|
|
639
|
-
position: u.fromRadians(s.longitude, s.latitude, i),
|
|
640
|
-
show: !1,
|
|
641
|
-
label: {
|
|
642
|
-
text: "体积:0 m³",
|
|
643
|
-
font: "16px sans-serif",
|
|
644
|
-
fillColor: h.WHITE,
|
|
645
|
-
outlineColor: h.BLACK,
|
|
646
|
-
outlineWidth: 2,
|
|
647
|
-
style: v.FILL_AND_OUTLINE,
|
|
648
|
-
showBackground: !0,
|
|
649
|
-
backgroundColor: h.BLACK.withAlpha(0.7),
|
|
650
|
-
pixelOffset: new L(0, -12),
|
|
651
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
652
|
-
verticalOrigin: C.BOTTOM
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
}, this.canvasPosition = (t) => {
|
|
656
|
-
const i = this.viewer.scene.canvas.getBoundingClientRect();
|
|
657
|
-
return { x: t.clientX - i.left, y: t.clientY - i.top };
|
|
658
|
-
}, this.findVolume = (t) => {
|
|
659
|
-
if (this.paused || this.destroyed || this.viewer.isDestroyed()) return null;
|
|
660
|
-
const i = this.viewer.scene.drillPick(new L(t.x, t.y));
|
|
661
|
-
for (const s of i) {
|
|
662
|
-
const a = s == null ? void 0 : s.id;
|
|
663
|
-
if (!(!a || typeof a.id != "string")) {
|
|
664
|
-
if (this.records.has(a.id)) return this.records.get(a.id) ?? null;
|
|
665
|
-
if (a.ellipse || a.polygon || a.label) return null;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
return null;
|
|
669
|
-
}, this.hover = (t) => {
|
|
670
|
-
if (this.drag || this.paused || this.destroyed || this.viewer.isDestroyed()) return;
|
|
671
|
-
const i = this.viewer.scene.canvas;
|
|
672
|
-
if (this.findVolume(t)) {
|
|
673
|
-
M = this, i.style.cursor = "ns-resize";
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
M === this && (M = null, i.style.cursor = "default");
|
|
677
|
-
}, this.onExtrudeDown = (t) => {
|
|
678
|
-
const i = this.findVolume(t.position);
|
|
679
|
-
!i || this.viewer.isDestroyed() || (this.drag = {
|
|
680
|
-
record: i,
|
|
681
|
-
startY: t.position.y,
|
|
682
|
-
startExtrude: i.extrude,
|
|
683
|
-
metersPerPixel: this.metersPerPixel(i.center)
|
|
684
|
-
}, this.viewer.scene.screenSpaceCameraController.enableRotate = !1, this.viewer.scene.canvas.style.cursor = "ns-resize");
|
|
685
|
-
}, this.onExtrudeMove = (t) => {
|
|
686
|
-
if (this.lastPosition = t.endPosition, !this.drag) {
|
|
687
|
-
this.hover(t.endPosition);
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
const i = this.drag.startY - t.endPosition.y;
|
|
691
|
-
this.applyExtrude(this.drag.record, this.drag.startExtrude + i * this.drag.metersPerPixel);
|
|
692
|
-
}, this.onExtrudeUp = () => {
|
|
693
|
-
!this.drag || this.viewer.isDestroyed() || (this.drag = null, this.viewer.scene.screenSpaceCameraController.enableRotate = !0, this.hover(this.lastPosition), this.viewer.scene.requestRender());
|
|
694
|
-
}, this.stopCameraOnVolume = (t) => {
|
|
695
|
-
t.button !== 0 || this.paused || this.destroyed || !this.findVolume(this.canvasPosition(t)) || (this.viewer.scene.screenSpaceCameraController.enableRotate = !1, this.cameraHeld = !0);
|
|
696
|
-
}, this.restoreCamera = () => {
|
|
697
|
-
!this.cameraHeld || this.viewer.isDestroyed() || (this.cameraHeld = !1, this.viewer.scene.screenSpaceCameraController.enableRotate = !0);
|
|
698
|
-
}, this.viewer = e, this.handler = new H(e.scene.canvas), this.handler.setInputAction(this.onExtrudeDown, y.LEFT_DOWN), this.handler.setInputAction(this.onExtrudeMove, y.MOUSE_MOVE), this.handler.setInputAction(this.onExtrudeUp, y.LEFT_UP);
|
|
699
|
-
const r = e.scene.canvas;
|
|
700
|
-
r.addEventListener("pointerdown", this.stopCameraOnVolume, !0), r.addEventListener("pointerup", this.restoreCamera, !0), r.addEventListener("pointercancel", this.restoreCamera, !0);
|
|
701
|
-
}
|
|
702
|
-
/** 贴地绘制过程中暂停上拉,避免和绘制抢鼠标。 */
|
|
703
|
-
setPause(e) {
|
|
704
|
-
this.paused = e;
|
|
705
|
-
}
|
|
706
|
-
destroy() {
|
|
707
|
-
if (this.destroyed) return;
|
|
708
|
-
this.destroyed = !0, M === this && (M = null, this.viewer.isDestroyed() || (this.viewer.scene.canvas.style.cursor = "default"));
|
|
709
|
-
const e = this.viewer.isDestroyed() ? null : this.viewer.scene.canvas;
|
|
710
|
-
e == null || e.removeEventListener("pointerdown", this.stopCameraOnVolume, !0), e == null || e.removeEventListener("pointerup", this.restoreCamera, !0), e == null || e.removeEventListener("pointercancel", this.restoreCamera, !0), this.handler.isDestroyed() || this.handler.destroy(), e && this.cameraHeld && (this.viewer.scene.screenSpaceCameraController.enableRotate = !0), this.drag = null, this.records.clear();
|
|
711
|
-
}
|
|
712
|
-
mount(e, r, t, i, s) {
|
|
713
|
-
if (this.destroyed || s <= 0 || this.records.has(e.id)) return;
|
|
714
|
-
const a = this.currentExtrude(r, i), l = this.createLabel(t, i + a), o = { entity: e, graphic: r, label: l, area: s, baseHeight: i, extrude: a, center: t };
|
|
715
|
-
this.records.set(e.id, o), this.records.set(l.id, o), this.applyExtrude(o, a);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
class ut extends N {
|
|
719
|
-
add(e, r, t) {
|
|
720
|
-
!e.ellipse || t <= 0 || (e.ellipse.semiMajorAxis = new c(t), e.ellipse.semiMinorAxis = new c(t), this.mount(
|
|
721
|
-
e,
|
|
722
|
-
e.ellipse,
|
|
723
|
-
u.clone(r),
|
|
724
|
-
D.fromCartesian(r).height,
|
|
725
|
-
Math.PI * t * t
|
|
726
|
-
));
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
class dt extends N {
|
|
730
|
-
add(e, r) {
|
|
731
|
-
const t = r.map((l) => u.clone(l)), i = k(t), s = A(t);
|
|
732
|
-
if (!e.polygon || t.length < 4 || i <= 0 || !s) return;
|
|
733
|
-
e.polygon.hierarchy = new c(new U(t)), e.polygon.perPositionHeight = new c(!1);
|
|
734
|
-
const a = (D.fromCartesian(t[0]).height + D.fromCartesian(t[2]).height) / 2;
|
|
735
|
-
this.mount(e, e.polygon, s, a, i);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
class wt extends N {
|
|
739
|
-
add(e, r) {
|
|
740
|
-
const t = r.map((a) => u.clone(a)), i = k(t), s = A(t);
|
|
741
|
-
!e.polygon || t.length < 3 || i <= 0 || !s || (e.polygon.hierarchy = new c(new U(t)), e.polygon.perPositionHeight = new c(!1), this.mount(e, e.polygon, s, q(t), i));
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
export {
|
|
745
|
-
rt as C,
|
|
746
|
-
ct as H,
|
|
747
|
-
ot as L,
|
|
748
|
-
lt as P,
|
|
749
|
-
nt as R,
|
|
750
|
-
ht as a,
|
|
751
|
-
ut as b,
|
|
752
|
-
dt as c,
|
|
753
|
-
wt as d
|
|
754
|
-
};
|