@vesium/plot 1.0.1-beta.50 → 1.0.1-beta.51
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/dist/index.cjs +1464 -1421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +555 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +555 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.iife.js +1522 -1475
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +2 -2
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +2 -2
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +1443 -1439
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -9
- package/dist/index.d.ts +0 -551
package/dist/index.cjs
CHANGED
|
@@ -1,1462 +1,1505 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 判断是否立即完成标绘.
|
|
18
|
-
* 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
|
|
19
|
-
*/
|
|
20
|
-
__publicField(this, "complete");
|
|
21
|
-
/**
|
|
22
|
-
* 判断是否允许手动完成标绘。
|
|
23
|
-
* 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
|
|
24
|
-
*/
|
|
25
|
-
__publicField(this, "allowManualComplete");
|
|
26
|
-
/**
|
|
27
|
-
* 处于定义态时鼠标的样式
|
|
28
|
-
* @default 'crosshair'
|
|
29
|
-
*/
|
|
30
|
-
__publicField(this, "definingCursor");
|
|
31
|
-
/**
|
|
32
|
-
* 当前标绘的框架点数据
|
|
33
|
-
*/
|
|
34
|
-
__publicField(this, "skeletons");
|
|
35
|
-
/**
|
|
36
|
-
* 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
|
|
37
|
-
*/
|
|
38
|
-
__publicField(this, "initEntites");
|
|
39
|
-
/**
|
|
40
|
-
* 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
|
|
41
|
-
*/
|
|
42
|
-
__publicField(this, "initPrimitives");
|
|
43
|
-
/**
|
|
44
|
-
* 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
|
|
45
|
-
*/
|
|
46
|
-
__publicField(this, "initGroundPrimitives");
|
|
47
|
-
/**
|
|
48
|
-
* 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
|
|
49
|
-
*/
|
|
50
|
-
__publicField(this, "render");
|
|
51
|
-
var _a;
|
|
52
|
-
this.type = options.type;
|
|
53
|
-
this.complete = options.complete;
|
|
54
|
-
this.allowManualComplete = options.allowManualComplete;
|
|
55
|
-
this.definingCursor = options.definingCursor ?? "crosshair";
|
|
56
|
-
this.skeletons = ((_a = options.skeletons) == null ? void 0 : _a.map((item) => item())) ?? [];
|
|
57
|
-
this.initEntites = options.initEntites;
|
|
58
|
-
this.initPrimitives = options.initPrimitives;
|
|
59
|
-
this.initGroundPrimitives = options.initGroundPrimitives;
|
|
60
|
-
this.render = options.render;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 标绘方案缓存。
|
|
64
|
-
* 每次标绘时都会将`PlotScheme.type`作为键名缓存,
|
|
65
|
-
* 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
|
|
66
|
-
*/
|
|
67
|
-
static getCacheTypes() {
|
|
68
|
-
return [...this._record.keys()];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
|
|
72
|
-
*/
|
|
73
|
-
static getCache(type) {
|
|
74
|
-
return _PlotScheme._record.get(type);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* 缓存标绘方案。
|
|
78
|
-
*/
|
|
79
|
-
static setCache(scheme) {
|
|
80
|
-
vesium.assertError(!scheme.type, "`scheme.type` is required");
|
|
81
|
-
_PlotScheme._record.set(scheme.type, scheme);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
|
|
85
|
-
* 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
|
|
86
|
-
*/
|
|
87
|
-
static resolve(maybeScheme) {
|
|
88
|
-
if (typeof maybeScheme === "string") {
|
|
89
|
-
const _scheme = _PlotScheme.getCache(maybeScheme);
|
|
90
|
-
core.assert(!!_scheme, `scheme ${maybeScheme} not found`);
|
|
91
|
-
return _scheme;
|
|
92
|
-
} else if (!(maybeScheme instanceof _PlotScheme)) {
|
|
93
|
-
return new _PlotScheme(maybeScheme);
|
|
94
|
-
} else {
|
|
95
|
-
return maybeScheme;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
98
17
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const cesium = __toESM(require("cesium"));
|
|
25
|
+
const vesium = __toESM(require("vesium"));
|
|
26
|
+
const __vueuse_core = __toESM(require("@vueuse/core"));
|
|
27
|
+
const vue = __toESM(require("vue"));
|
|
28
|
+
|
|
29
|
+
//#region usePlot/PlotScheme.ts
|
|
30
|
+
var PlotScheme = class PlotScheme {
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.type = options.type;
|
|
33
|
+
this.complete = options.complete;
|
|
34
|
+
this.allowManualComplete = options.allowManualComplete;
|
|
35
|
+
this.definingCursor = options.definingCursor ?? "crosshair";
|
|
36
|
+
this.skeletons = options.skeletons?.map((item) => item()) ?? [];
|
|
37
|
+
this.initEntites = options.initEntites;
|
|
38
|
+
this.initPrimitives = options.initPrimitives;
|
|
39
|
+
this.initGroundPrimitives = options.initGroundPrimitives;
|
|
40
|
+
this.render = options.render;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 标绘类型。应当是全局唯一的字符串,会作为键名缓存
|
|
44
|
+
*/
|
|
45
|
+
type;
|
|
46
|
+
/**
|
|
47
|
+
* 判断是否立即完成标绘.
|
|
48
|
+
* 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
|
|
49
|
+
*/
|
|
50
|
+
complete;
|
|
51
|
+
/**
|
|
52
|
+
* 判断是否允许手动完成标绘。
|
|
53
|
+
* 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
|
|
54
|
+
*/
|
|
55
|
+
allowManualComplete;
|
|
56
|
+
/**
|
|
57
|
+
* 处于定义态时鼠标的样式
|
|
58
|
+
* @default 'crosshair'
|
|
59
|
+
*/
|
|
60
|
+
definingCursor;
|
|
61
|
+
/**
|
|
62
|
+
* 当前标绘的框架点数据
|
|
63
|
+
*/
|
|
64
|
+
skeletons;
|
|
65
|
+
/**
|
|
66
|
+
* 初始化时创建`Entity`的函数,创建后的`Entity`会作为配置项传入`render`中
|
|
67
|
+
*/
|
|
68
|
+
initEntites;
|
|
69
|
+
/**
|
|
70
|
+
* 初始化时创建`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
|
|
71
|
+
*/
|
|
72
|
+
initPrimitives;
|
|
73
|
+
/**
|
|
74
|
+
* 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
|
|
75
|
+
*/
|
|
76
|
+
initGroundPrimitives;
|
|
77
|
+
/**
|
|
78
|
+
* 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
|
|
79
|
+
*/
|
|
80
|
+
render;
|
|
81
|
+
static _record = /* @__PURE__ */ new Map();
|
|
82
|
+
/**
|
|
83
|
+
* 标绘方案缓存。
|
|
84
|
+
* 每次标绘时都会将`PlotScheme.type`作为键名缓存,
|
|
85
|
+
* 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
|
|
86
|
+
*/
|
|
87
|
+
static getCacheTypes() {
|
|
88
|
+
return [...this._record.keys()];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
|
|
92
|
+
*/
|
|
93
|
+
static getCache(type) {
|
|
94
|
+
return PlotScheme._record.get(type);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 缓存标绘方案。
|
|
98
|
+
*/
|
|
99
|
+
static setCache(scheme) {
|
|
100
|
+
(0, vesium.assertError)(!scheme.type, "`scheme.type` is required");
|
|
101
|
+
PlotScheme._record.set(scheme.type, scheme);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
|
|
105
|
+
* 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
|
|
106
|
+
*/
|
|
107
|
+
static resolve(maybeScheme) {
|
|
108
|
+
if (typeof maybeScheme === "string") {
|
|
109
|
+
const _scheme = PlotScheme.getCache(maybeScheme);
|
|
110
|
+
(0, __vueuse_core.assert)(!!_scheme, `scheme ${maybeScheme} not found`);
|
|
111
|
+
return _scheme;
|
|
112
|
+
} else if (!(maybeScheme instanceof PlotScheme)) return new PlotScheme(maybeScheme);
|
|
113
|
+
else return maybeScheme;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region usePlot/SampledPlotProperty.ts
|
|
119
|
+
let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
|
|
120
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["NEAR"] = 0] = "NEAR";
|
|
121
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["CYCLE"] = 1] = "CYCLE";
|
|
122
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["STRICT"] = 2] = "STRICT";
|
|
123
|
+
return SampledPlotStrategy$1;
|
|
124
|
+
}({});
|
|
125
|
+
/**
|
|
126
|
+
* 默认插值算法
|
|
127
|
+
*
|
|
128
|
+
* @param time 时间
|
|
129
|
+
* @param previous 前一个数据点
|
|
130
|
+
* @param next 后一个数据点
|
|
131
|
+
* @param proportion 比例
|
|
132
|
+
* @returns 插值结果
|
|
133
|
+
*/
|
|
107
134
|
const defaultInterpolationAlgorithm = (time, previous, next, proportion) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const left = (_a2 = previous.positions) == null ? void 0 : _a2[index];
|
|
127
|
-
return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
|
|
128
|
-
}),
|
|
129
|
-
derivative: previous.derivative
|
|
130
|
-
};
|
|
135
|
+
if (proportion === 0) return {
|
|
136
|
+
time,
|
|
137
|
+
positions: previous.positions?.map((item) => item.clone()),
|
|
138
|
+
derivative: previous.derivative
|
|
139
|
+
};
|
|
140
|
+
else if (proportion === 1) return {
|
|
141
|
+
time,
|
|
142
|
+
positions: next.positions?.map((item) => item.clone()),
|
|
143
|
+
derivative: previous.derivative
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
time,
|
|
147
|
+
positions: next.positions?.map((right, index) => {
|
|
148
|
+
const left = previous.positions?.[index];
|
|
149
|
+
return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
|
|
150
|
+
}),
|
|
151
|
+
derivative: previous.derivative
|
|
152
|
+
};
|
|
131
153
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* 判断两个property是否相等
|
|
334
|
-
*/
|
|
335
|
-
equals(other) {
|
|
336
|
-
return other === this;
|
|
337
|
-
}
|
|
154
|
+
/**
|
|
155
|
+
* 标绘采样点数据。
|
|
156
|
+
* 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
|
|
157
|
+
* 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
|
|
158
|
+
*/
|
|
159
|
+
var SampledPlotProperty = class SampledPlotProperty {
|
|
160
|
+
constructor(options) {
|
|
161
|
+
this.interpolationAlgorithm = options?.interpolationAlgorithm;
|
|
162
|
+
this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
|
|
163
|
+
options?.packables?.forEach((packable) => this.setSample(packable));
|
|
164
|
+
if (!this._times.length) this.setSample({
|
|
165
|
+
time: new cesium.JulianDate(0, 0),
|
|
166
|
+
positions: [],
|
|
167
|
+
derivative: void 0
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
|
|
171
|
+
strategy;
|
|
172
|
+
interpolationAlgorithm;
|
|
173
|
+
/**
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
_times = [];
|
|
177
|
+
/**
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
_sampleds = [];
|
|
181
|
+
/**
|
|
182
|
+
* @internal
|
|
183
|
+
*/
|
|
184
|
+
_derivatives = [];
|
|
185
|
+
get isConstant() {
|
|
186
|
+
return this._times.length === 0;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
_definitionChanged = new cesium.Event();
|
|
192
|
+
get definitionChanged() {
|
|
193
|
+
return this._definitionChanged;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 获取时间数组
|
|
197
|
+
*
|
|
198
|
+
* @returns 返回包含所有时间的 JulianDate 数组
|
|
199
|
+
*/
|
|
200
|
+
getTimes() {
|
|
201
|
+
return this._times.map((t) => t.clone());
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 根据给定的儒略日期获取时间索引范围及比例
|
|
205
|
+
*
|
|
206
|
+
* @param time 给定的儒略日期
|
|
207
|
+
* @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
getIndexScope(time) {
|
|
211
|
+
if (!this._times.length) return;
|
|
212
|
+
const start = this._times[0];
|
|
213
|
+
const end = this._times[this._times.length - 1];
|
|
214
|
+
if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
|
|
215
|
+
case SampledPlotStrategy.STRICT: return;
|
|
216
|
+
case SampledPlotStrategy.NEAR: {
|
|
217
|
+
time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
case SampledPlotStrategy.CYCLE: {
|
|
221
|
+
const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
|
|
222
|
+
const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
|
|
223
|
+
const duration = endMS - startMS;
|
|
224
|
+
const timeMS = cesium.JulianDate.toDate(time).getTime();
|
|
225
|
+
const diff = (timeMS - startMS) % duration;
|
|
226
|
+
const dete = new Date(startMS + diff);
|
|
227
|
+
time = cesium.JulianDate.fromDate(dete);
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
|
|
232
|
+
const nextIndex = Math.min(prevIndex, this._times.length - 1);
|
|
233
|
+
const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
|
|
234
|
+
const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
|
|
235
|
+
const ms = cesium.JulianDate.toDate(time).getTime();
|
|
236
|
+
return {
|
|
237
|
+
prevIndex,
|
|
238
|
+
nextIndex,
|
|
239
|
+
proportion: (ms - prevMs) / (nextMs - prevMs) || 0
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
|
|
244
|
+
*
|
|
245
|
+
* @param time 指定的儒略日期(JulianDate)。
|
|
246
|
+
* @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
|
|
247
|
+
* @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
|
|
248
|
+
* @template D 数据类型。
|
|
249
|
+
*/
|
|
250
|
+
getValue(time, result) {
|
|
251
|
+
result ??= { time };
|
|
252
|
+
Object.assign(result, {
|
|
253
|
+
time: time?.clone(),
|
|
254
|
+
positions: void 0,
|
|
255
|
+
derivative: void 0
|
|
256
|
+
});
|
|
257
|
+
if (!time) {
|
|
258
|
+
result.time = this._times[0].clone();
|
|
259
|
+
result.positions = this._sampleds[0]?.map((c) => c.clone(c));
|
|
260
|
+
result.derivative = this._derivatives[0];
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
const scope = this.getIndexScope(time);
|
|
264
|
+
if (!scope) return result;
|
|
265
|
+
result.time = time;
|
|
266
|
+
const { prevIndex, nextIndex, proportion } = scope;
|
|
267
|
+
const previous = {
|
|
268
|
+
time: this._times[prevIndex],
|
|
269
|
+
positions: this._sampleds[prevIndex],
|
|
270
|
+
derivative: this._derivatives[prevIndex]
|
|
271
|
+
};
|
|
272
|
+
const next = {
|
|
273
|
+
time: this._times[nextIndex],
|
|
274
|
+
positions: this._sampleds[nextIndex],
|
|
275
|
+
derivative: this._derivatives[nextIndex]
|
|
276
|
+
};
|
|
277
|
+
const packable = (this.interpolationAlgorithm || SampledPlotProperty.defaultInterpolationAlgorithm)(time, previous, next, proportion);
|
|
278
|
+
Object.assign(result, packable);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
|
|
283
|
+
* @param value 样本数据对象,包含时间、位置和导数信息
|
|
284
|
+
*/
|
|
285
|
+
setSample(value) {
|
|
286
|
+
const time = value.time?.clone() ?? this._times[0].clone();
|
|
287
|
+
const positions = value.positions?.map((item) => item.clone()) ?? [];
|
|
288
|
+
const derivative = value.derivative;
|
|
289
|
+
const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
|
|
290
|
+
if (index !== -1) {
|
|
291
|
+
this._times[index] = time;
|
|
292
|
+
this._sampleds[index] = positions;
|
|
293
|
+
this._derivatives[index] = value.derivative;
|
|
294
|
+
} else if (this._times.length === 0) {
|
|
295
|
+
this._times[0] = time;
|
|
296
|
+
this._sampleds[0] = positions;
|
|
297
|
+
this._derivatives[0] = value.derivative;
|
|
298
|
+
} else if (cesium.JulianDate.lessThan(time, this._times[0])) {
|
|
299
|
+
this._times.splice(0, 0, time);
|
|
300
|
+
this._sampleds.splice(0, 0, positions);
|
|
301
|
+
this._derivatives.splice(0, 0, derivative);
|
|
302
|
+
} else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
|
|
303
|
+
this._times.push(time);
|
|
304
|
+
this._sampleds.push(positions);
|
|
305
|
+
this._derivatives.push(derivative);
|
|
306
|
+
}
|
|
307
|
+
this.definitionChanged.raiseEvent(this);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 设置样本数据
|
|
311
|
+
*
|
|
312
|
+
* @param values 样本数据数组,每个元素都是类型为SampledPlotPackable<D>的对象
|
|
313
|
+
*/
|
|
314
|
+
setSamples(values) {
|
|
315
|
+
values.forEach((value) => this.setSample(value));
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 从样本中移除指定时间点的数据
|
|
319
|
+
*
|
|
320
|
+
* @param time 需要移除的时间点,使用儒略日期表示
|
|
321
|
+
* @returns 如果成功移除,则返回 true;否则返回 false
|
|
322
|
+
*/
|
|
323
|
+
removeSample(time) {
|
|
324
|
+
const index = this._times.findIndex((t) => t.equals(time));
|
|
325
|
+
if (index !== -1) {
|
|
326
|
+
this._sampleds.splice(index, 1);
|
|
327
|
+
this._derivatives.splice(index, 1);
|
|
328
|
+
const removed = this._times.splice(index, 1);
|
|
329
|
+
if (removed.length) {
|
|
330
|
+
this._definitionChanged.raiseEvent(this);
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* 从样本中移除指定时间间隔内的样本。
|
|
338
|
+
*
|
|
339
|
+
* @param interval 要移除样本的时间间隔
|
|
340
|
+
*/
|
|
341
|
+
removeSamples(interval$1) {
|
|
342
|
+
for (let i = 0; i < this._times.length; i++) {
|
|
343
|
+
const time = this._times[i];
|
|
344
|
+
cesium.TimeInterval.contains(interval$1, time) && this.removeSample(time);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 判断两个property是否相等
|
|
349
|
+
*/
|
|
350
|
+
equals(other) {
|
|
351
|
+
return other === this;
|
|
352
|
+
}
|
|
338
353
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
354
|
+
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region usePlot/PlotFeature.ts
|
|
357
|
+
/**
|
|
358
|
+
* 标绘实例
|
|
359
|
+
*/
|
|
360
|
+
var PlotFeature = class {
|
|
361
|
+
constructor(options) {
|
|
362
|
+
const { id, disabled = false, sampled } = options;
|
|
363
|
+
this._id = id || (0, cesium.createGuid)();
|
|
364
|
+
this._scheme = PlotScheme.resolve(options.scheme);
|
|
365
|
+
this._definitionChanged = new cesium.Event();
|
|
366
|
+
this._defining = true;
|
|
367
|
+
this._disabled = disabled;
|
|
368
|
+
this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
|
|
369
|
+
this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
|
|
370
|
+
this._entities = [...this._scheme.initEntites?.() ?? []];
|
|
371
|
+
this._primitives = [...this._scheme.initPrimitives?.() ?? []];
|
|
372
|
+
this._groundPrimitives = [...this._scheme.initGroundPrimitives?.() ?? []];
|
|
373
|
+
this._skeletons = [];
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
_id;
|
|
379
|
+
get id() {
|
|
380
|
+
return this._id;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
_scheme;
|
|
386
|
+
get scheme() {
|
|
387
|
+
return this._scheme;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
_definitionChanged;
|
|
393
|
+
get definitionChanged() {
|
|
394
|
+
return this._definitionChanged;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
_defining;
|
|
400
|
+
get defining() {
|
|
401
|
+
return this._defining;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* @internal
|
|
405
|
+
*/
|
|
406
|
+
static setDefining(plot, value) {
|
|
407
|
+
if (plot._defining !== value) {
|
|
408
|
+
plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
|
|
409
|
+
plot._defining = value;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @internal
|
|
414
|
+
*/
|
|
415
|
+
_disabled;
|
|
416
|
+
/**
|
|
417
|
+
* 获取禁用状态
|
|
418
|
+
*
|
|
419
|
+
* 当为 `true` 时,标绘实例将停止响应交互和更新;
|
|
420
|
+
* 为 `false` 时恢复正常功能。
|
|
421
|
+
*/
|
|
422
|
+
get disabled() {
|
|
423
|
+
return this._disabled;
|
|
424
|
+
}
|
|
425
|
+
set disabled(value) {
|
|
426
|
+
this.disabled = value;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @internal
|
|
430
|
+
*/
|
|
431
|
+
_sampled;
|
|
432
|
+
get sampled() {
|
|
433
|
+
return this._sampled;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* @internal
|
|
437
|
+
*/
|
|
438
|
+
_entities;
|
|
439
|
+
get entities() {
|
|
440
|
+
return this._entities;
|
|
441
|
+
}
|
|
442
|
+
set entities(value) {
|
|
443
|
+
this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
|
|
444
|
+
this._entities = value;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
_primitives;
|
|
450
|
+
get primitives() {
|
|
451
|
+
return this._primitives;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
set primitives(value) {
|
|
457
|
+
this._definitionChanged.raiseEvent(this, "primitives", value, this._primitives);
|
|
458
|
+
this._primitives = value;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* @internal
|
|
462
|
+
*/
|
|
463
|
+
_groundPrimitives;
|
|
464
|
+
get groundPrimitives() {
|
|
465
|
+
return this._groundPrimitives;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
set groundPrimitives(value) {
|
|
471
|
+
this._definitionChanged.raiseEvent(this, "groundPrimitives", value, this._groundPrimitives);
|
|
472
|
+
this._groundPrimitives = value;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
_skeletons;
|
|
478
|
+
get skeletons() {
|
|
479
|
+
return this._skeletons;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* @internal
|
|
483
|
+
*/
|
|
484
|
+
set skeletons(value) {
|
|
485
|
+
this._definitionChanged.raiseEvent(this, "skeletons", value, this._skeletons);
|
|
486
|
+
this._skeletons = value;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region usePlot/PlotSkeleton.ts
|
|
492
|
+
/**
|
|
493
|
+
* 框架点执行状态枚举
|
|
494
|
+
* - IDLE 空闲状态
|
|
495
|
+
* - HOVER 悬停状态
|
|
496
|
+
* - ACTIVE 激活状态
|
|
497
|
+
*/
|
|
498
|
+
let PlotAction = /* @__PURE__ */ function(PlotAction$1) {
|
|
499
|
+
PlotAction$1[PlotAction$1["IDLE"] = 0] = "IDLE";
|
|
500
|
+
PlotAction$1[PlotAction$1["HOVER"] = 1] = "HOVER";
|
|
501
|
+
PlotAction$1[PlotAction$1["ACTIVE"] = 2] = "ACTIVE";
|
|
502
|
+
return PlotAction$1;
|
|
503
|
+
}({});
|
|
504
|
+
/**
|
|
505
|
+
* 标绘框架点 Entity
|
|
506
|
+
*/
|
|
507
|
+
var PlotSkeletonEntity = class extends cesium.Entity {
|
|
508
|
+
constructor(options) {
|
|
509
|
+
super(options);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region usePlot/useRender.ts
|
|
482
515
|
function useRender(plots, current, getCurrentTime) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
return {
|
|
561
|
-
primitives: vue.computed(() => Array.from(primitiveScope.scope)),
|
|
562
|
-
groundPrimitives: vue.computed(() => Array.from(primitiveScope.scope)),
|
|
563
|
-
entities: vue.computed(() => Array.from(entityScope.scope))
|
|
564
|
-
};
|
|
516
|
+
const viewer = (0, vesium.useViewer)();
|
|
517
|
+
const primitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection());
|
|
518
|
+
const groundPrimitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
519
|
+
const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
|
|
520
|
+
const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
|
|
521
|
+
const primitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => primitiveCollection.value });
|
|
522
|
+
const groundPrimitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => groundPrimitiveCollection.value });
|
|
523
|
+
const mouseCartesian = (0, vue.shallowRef)();
|
|
524
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.MOUSE_MOVE, (event) => {
|
|
525
|
+
mouseCartesian.value = (0, vesium.canvasCoordToCartesian)(event?.endPosition, viewer.value.scene);
|
|
526
|
+
});
|
|
527
|
+
(0, __vueuse_core.watchArray)(plots, (_value, _oldValue, added, removed = []) => {
|
|
528
|
+
removed.forEach((plot) => {
|
|
529
|
+
entityScope.removeWhere((item) => plot.entities.includes(item));
|
|
530
|
+
primitiveScope.removeWhere((item) => plot.primitives.includes(item));
|
|
531
|
+
groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
|
|
532
|
+
});
|
|
533
|
+
added.forEach((plot) => {
|
|
534
|
+
plot.entities.forEach((item) => entityScope.add(item));
|
|
535
|
+
plot.primitives.forEach((item) => primitiveScope.add(item));
|
|
536
|
+
plot.groundPrimitives.forEach((item) => groundPrimitiveScope.add(item));
|
|
537
|
+
});
|
|
538
|
+
}, {
|
|
539
|
+
immediate: true,
|
|
540
|
+
flush: "post"
|
|
541
|
+
});
|
|
542
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (_scope, key, newValue, oldValue) => {
|
|
543
|
+
if (key === "entities") {
|
|
544
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
545
|
+
added.forEach((item) => entityScope.add(item));
|
|
546
|
+
removed.forEach((item) => entityScope.remove(item));
|
|
547
|
+
} else if (key === "primitives") {
|
|
548
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
549
|
+
added.forEach((item) => primitiveScope.add(item));
|
|
550
|
+
removed.forEach((item) => primitiveScope.remove(item));
|
|
551
|
+
} else if (key === "groundPrimitives") {
|
|
552
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
553
|
+
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
554
|
+
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
const update = async (plot) => {
|
|
558
|
+
const reslut = await plot.scheme.render?.({
|
|
559
|
+
packable: plot.sampled.getValue(getCurrentTime()),
|
|
560
|
+
mouse: plot.defining ? mouseCartesian.value : void 0,
|
|
561
|
+
defining: plot.defining,
|
|
562
|
+
previous: {
|
|
563
|
+
entities: plot.entities,
|
|
564
|
+
primitives: plot.primitives,
|
|
565
|
+
groundPrimitives: plot.groundPrimitives
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
plot.entities = reslut?.entities ?? [];
|
|
569
|
+
plot.primitives = reslut?.primitives ?? [];
|
|
570
|
+
plot.groundPrimitives = reslut?.groundPrimitives ?? [];
|
|
571
|
+
};
|
|
572
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
573
|
+
previous && update(previous);
|
|
574
|
+
});
|
|
575
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (plot, key) => {
|
|
576
|
+
if ([
|
|
577
|
+
"disabled",
|
|
578
|
+
"defining",
|
|
579
|
+
"scheme",
|
|
580
|
+
"sampled",
|
|
581
|
+
"time"
|
|
582
|
+
].includes(key)) update(plot);
|
|
583
|
+
});
|
|
584
|
+
(0, vue.watch)(mouseCartesian, () => {
|
|
585
|
+
plots.value.forEach((plot) => plot.defining && update(plot));
|
|
586
|
+
});
|
|
587
|
+
return {
|
|
588
|
+
primitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
589
|
+
groundPrimitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
590
|
+
entities: (0, vue.computed)(() => Array.from(entityScope.scope))
|
|
591
|
+
};
|
|
565
592
|
}
|
|
593
|
+
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region usePlot/useSampled.ts
|
|
566
596
|
function useSampled(current, getCurrentTime) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
var _a;
|
|
625
|
-
if (!current.value || !packable.value) {
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
const { defining, sampled } = current.value;
|
|
629
|
-
if (!defining) {
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
(_a = packable.value).positions ?? (_a.positions = []);
|
|
633
|
-
if (packable.value.positions.length === 0) {
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
packable.value.positions.splice(packable.value.positions.length - 1, 1);
|
|
637
|
-
sampled.setSample(packable.value);
|
|
638
|
-
}
|
|
639
|
-
);
|
|
640
|
-
const definingCursorCss = vue.ref();
|
|
641
|
-
const setDefiningCursorCss = () => {
|
|
642
|
-
var _a, _b;
|
|
643
|
-
if (!((_a = current.value) == null ? void 0 : _a.defining)) {
|
|
644
|
-
if (definingCursorCss.value) {
|
|
645
|
-
definingCursorCss.value = void 0;
|
|
646
|
-
viewer.value.container.parentElement.style.removeProperty("cursor");
|
|
647
|
-
}
|
|
648
|
-
} else {
|
|
649
|
-
const definingCursor = current.value.scheme.definingCursor;
|
|
650
|
-
definingCursorCss.value = vesium.isFunction(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
651
|
-
if (definingCursorCss.value) {
|
|
652
|
-
(_b = viewer.value) == null ? void 0 : _b.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
|
-
vesium.useCesiumEventListener(() => {
|
|
657
|
-
var _a;
|
|
658
|
-
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
659
|
-
}, (plot, key) => {
|
|
660
|
-
if (key === "defining" || key === "sampled") {
|
|
661
|
-
setDefiningCursorCss();
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
vue.watch(current, () => setDefiningCursorCss());
|
|
597
|
+
const viewer = (0, vesium.useViewer)();
|
|
598
|
+
const doubleClicking = (0, vue.ref)(false);
|
|
599
|
+
const packable = (0, vue.computed)(() => {
|
|
600
|
+
return current.value?.sampled.getValue(getCurrentTime());
|
|
601
|
+
});
|
|
602
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, async (ctx) => {
|
|
603
|
+
await (0, __vueuse_core.promiseTimeout)(1);
|
|
604
|
+
if (!current.value || !packable.value) return;
|
|
605
|
+
if (doubleClicking.value) return;
|
|
606
|
+
const { scheme, defining, sampled } = current.value;
|
|
607
|
+
if (!defining) return;
|
|
608
|
+
const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
|
|
609
|
+
if (!position) return;
|
|
610
|
+
packable.value.positions ??= [];
|
|
611
|
+
packable.value.positions.push(position);
|
|
612
|
+
sampled.setSample(packable.value);
|
|
613
|
+
const completed = scheme.complete?.(packable.value);
|
|
614
|
+
completed && PlotFeature.setDefining(current.value, false);
|
|
615
|
+
});
|
|
616
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, async (ctx) => {
|
|
617
|
+
if (!current.value || !packable.value) return;
|
|
618
|
+
doubleClicking.value = true;
|
|
619
|
+
await (0, __vueuse_core.promiseTimeout)(2);
|
|
620
|
+
doubleClicking.value = false;
|
|
621
|
+
const { scheme, defining } = current.value;
|
|
622
|
+
if (!defining) return;
|
|
623
|
+
const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
|
|
624
|
+
if (!position) return;
|
|
625
|
+
const completed = scheme.allowManualComplete?.(packable.value);
|
|
626
|
+
completed && PlotFeature.setDefining(current.value, false);
|
|
627
|
+
});
|
|
628
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.RIGHT_CLICK, async () => {
|
|
629
|
+
if (!current.value || !packable.value) return;
|
|
630
|
+
const { defining, sampled } = current.value;
|
|
631
|
+
if (!defining) return;
|
|
632
|
+
packable.value.positions ??= [];
|
|
633
|
+
if (packable.value.positions.length === 0) return;
|
|
634
|
+
packable.value.positions.splice(packable.value.positions.length - 1, 1);
|
|
635
|
+
sampled.setSample(packable.value);
|
|
636
|
+
});
|
|
637
|
+
const definingCursorCss = (0, vue.ref)();
|
|
638
|
+
const setDefiningCursorCss = () => {
|
|
639
|
+
if (!current.value?.defining) {
|
|
640
|
+
if (definingCursorCss.value) {
|
|
641
|
+
definingCursorCss.value = void 0;
|
|
642
|
+
viewer.value.container.parentElement.style.removeProperty("cursor");
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
const definingCursor = current.value.scheme.definingCursor;
|
|
646
|
+
definingCursorCss.value = (0, vesium.isFunction)(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
647
|
+
if (definingCursorCss.value) viewer.value?.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
(0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
|
|
651
|
+
if (key === "defining" || key === "sampled") setDefiningCursorCss();
|
|
652
|
+
});
|
|
653
|
+
(0, vue.watch)(current, () => setDefiningCursorCss());
|
|
665
654
|
}
|
|
655
|
+
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region usePlot/useSkeleton.ts
|
|
666
658
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
core.watchArray(plots, (value, oldValue, added, removed = []) => {
|
|
826
|
-
added.forEach((plot) => update(plot));
|
|
827
|
-
removed.forEach((plot) => update(plot, true));
|
|
828
|
-
});
|
|
829
|
-
vesium.useCesiumEventListener(
|
|
830
|
-
() => plots.value.map((plot) => plot.definitionChanged),
|
|
831
|
-
(plot, key, newValue, oldValue) => {
|
|
832
|
-
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
833
|
-
vue.nextTick(() => update(plot));
|
|
834
|
-
} else if (key === "skeletons") {
|
|
835
|
-
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
836
|
-
added.forEach((item) => entityScope.add(item));
|
|
837
|
-
removed.forEach((item) => entityScope.remove(item));
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
);
|
|
841
|
-
vue.watch(current, (plot, previous) => {
|
|
842
|
-
plot && update(plot);
|
|
843
|
-
previous && update(previous);
|
|
844
|
-
});
|
|
845
|
-
return {
|
|
846
|
-
dataSource
|
|
847
|
-
};
|
|
659
|
+
const viewer = (0, vesium.useViewer)();
|
|
660
|
+
const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
|
|
661
|
+
const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
|
|
662
|
+
const hoverEntity = (0, vue.shallowRef)();
|
|
663
|
+
const activeEntity = (0, vue.shallowRef)();
|
|
664
|
+
const getPointAction = (entity) => {
|
|
665
|
+
if (!entity) return PlotAction.IDLE;
|
|
666
|
+
return activeEntity.value?.id === entity.id ? PlotAction.ACTIVE : hoverEntity.value?.id === entity.id ? PlotAction.HOVER : PlotAction.IDLE;
|
|
667
|
+
};
|
|
668
|
+
const update = (plot, destroyed) => {
|
|
669
|
+
const oldEntities = plot.skeletons;
|
|
670
|
+
const entities = [];
|
|
671
|
+
if (destroyed || plot.disabled) plot.skeletons = [];
|
|
672
|
+
else {
|
|
673
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
674
|
+
const defining = plot.defining;
|
|
675
|
+
const active = current.value === plot;
|
|
676
|
+
const skeletons = plot.scheme.skeletons;
|
|
677
|
+
skeletons.forEach((skeleton) => {
|
|
678
|
+
const disabled = (0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
|
|
679
|
+
active,
|
|
680
|
+
defining
|
|
681
|
+
}) : skeleton.disabled;
|
|
682
|
+
if (disabled) return;
|
|
683
|
+
const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
|
|
684
|
+
positions.forEach((position, index) => {
|
|
685
|
+
let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
|
|
686
|
+
const options = skeleton.render?.({
|
|
687
|
+
defining,
|
|
688
|
+
active,
|
|
689
|
+
index,
|
|
690
|
+
packable,
|
|
691
|
+
positions,
|
|
692
|
+
position,
|
|
693
|
+
action: getPointAction(entity)
|
|
694
|
+
});
|
|
695
|
+
const merge = new PlotSkeletonEntity(options ?? {});
|
|
696
|
+
if (entity) merge.propertyNames.forEach((key) => {
|
|
697
|
+
if (key !== "id") entity[key] = merge[key];
|
|
698
|
+
});
|
|
699
|
+
else entity = merge;
|
|
700
|
+
entity.plot = plot;
|
|
701
|
+
entity.skeleton = skeleton;
|
|
702
|
+
entity.index = index;
|
|
703
|
+
entities.push(entity);
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
plot.skeletons = entities;
|
|
708
|
+
};
|
|
709
|
+
const { addGraphicEvent } = (0, vesium.useGraphicEvent)();
|
|
710
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
711
|
+
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
712
|
+
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
713
|
+
const entity = pick.id;
|
|
714
|
+
const plot = entity.plot;
|
|
715
|
+
if (plot.defining) return;
|
|
716
|
+
activeEntity.value = entity;
|
|
717
|
+
const skeleton = entity.skeleton;
|
|
718
|
+
const index = entity.index;
|
|
719
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
720
|
+
skeleton.onDrag?.({
|
|
721
|
+
viewer: viewer.value,
|
|
722
|
+
sampled: plot.sampled,
|
|
723
|
+
packable,
|
|
724
|
+
active: current.value === plot,
|
|
725
|
+
index,
|
|
726
|
+
event,
|
|
727
|
+
dragging,
|
|
728
|
+
lockCamera
|
|
729
|
+
});
|
|
730
|
+
} else activeEntity.value = void 0;
|
|
731
|
+
}, {
|
|
732
|
+
cursor: ({ pick }) => {
|
|
733
|
+
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
734
|
+
const skeleton = pick.id.skeleton;
|
|
735
|
+
return (0, vesium.isFunction)(skeleton?.cursor) ? skeleton.cursor(pick) : (0, vue.toValue)(skeleton?.cursor);
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
dragCursor: ({ pick }) => {
|
|
739
|
+
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
740
|
+
const skeleton = pick.id.skeleton;
|
|
741
|
+
return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
onCleanup(remove);
|
|
746
|
+
});
|
|
747
|
+
(0, __vueuse_core.onKeyStroke)((keyEvent) => {
|
|
748
|
+
if (activeEntity.value) {
|
|
749
|
+
const entity = activeEntity.value;
|
|
750
|
+
const plot = entity.plot;
|
|
751
|
+
const skeleton = entity.skeleton;
|
|
752
|
+
const index = entity.index;
|
|
753
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
754
|
+
skeleton.onKeyPressed?.({
|
|
755
|
+
viewer: viewer.value,
|
|
756
|
+
sampled: plot.sampled,
|
|
757
|
+
packable,
|
|
758
|
+
index,
|
|
759
|
+
keyEvent
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
764
|
+
const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
|
|
765
|
+
if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
766
|
+
const entity = pick.id;
|
|
767
|
+
hoverEntity.value = entity;
|
|
768
|
+
} else hoverEntity.value = void 0;
|
|
769
|
+
});
|
|
770
|
+
onCleanup(remove);
|
|
771
|
+
});
|
|
772
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
773
|
+
const remove = addGraphicEvent("global", "LEFT_CLICK", ({ event, pick }) => {
|
|
774
|
+
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
775
|
+
const entity = pick.id;
|
|
776
|
+
activeEntity.value = entity;
|
|
777
|
+
const plot = entity.plot;
|
|
778
|
+
const skeleton = entity.skeleton;
|
|
779
|
+
const index = entity.index;
|
|
780
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
781
|
+
skeleton.onLeftClick?.({
|
|
782
|
+
viewer: viewer.value,
|
|
783
|
+
sampled: plot.sampled,
|
|
784
|
+
packable,
|
|
785
|
+
active: current.value === plot,
|
|
786
|
+
defining: plot.defining,
|
|
787
|
+
index,
|
|
788
|
+
event
|
|
789
|
+
});
|
|
790
|
+
} else activeEntity.value = void 0;
|
|
791
|
+
});
|
|
792
|
+
onCleanup(remove);
|
|
793
|
+
});
|
|
794
|
+
(0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
|
|
795
|
+
added.forEach((plot) => update(plot));
|
|
796
|
+
removed.forEach((plot) => update(plot, true));
|
|
797
|
+
});
|
|
798
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((plot) => plot.definitionChanged), (plot, key, newValue, oldValue) => {
|
|
799
|
+
if ([
|
|
800
|
+
"disabled",
|
|
801
|
+
"defining",
|
|
802
|
+
"scheme",
|
|
803
|
+
"sampled",
|
|
804
|
+
"time"
|
|
805
|
+
].includes(key)) (0, vue.nextTick)(() => update(plot));
|
|
806
|
+
else if (key === "skeletons") {
|
|
807
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
808
|
+
added.forEach((item) => entityScope.add(item));
|
|
809
|
+
removed.forEach((item) => entityScope.remove(item));
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
813
|
+
plot && update(plot);
|
|
814
|
+
previous && update(previous);
|
|
815
|
+
});
|
|
816
|
+
return { dataSource };
|
|
848
817
|
}
|
|
818
|
+
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region usePlot/usePlot.ts
|
|
849
821
|
function usePlot(options) {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
current.value = void 0;
|
|
919
|
-
}
|
|
920
|
-
if (collection.has(plot)) {
|
|
921
|
-
collection.delete(plot);
|
|
922
|
-
return true;
|
|
923
|
-
}
|
|
924
|
-
return false;
|
|
925
|
-
};
|
|
926
|
-
return {
|
|
927
|
-
plots,
|
|
928
|
-
time,
|
|
929
|
-
operate,
|
|
930
|
-
remove,
|
|
931
|
-
cancel: operateReject
|
|
932
|
-
};
|
|
822
|
+
const time = options?.time || (0, vue.shallowRef)();
|
|
823
|
+
const viewer = (0, vesium.useViewer)();
|
|
824
|
+
const getCurrentTime = () => {
|
|
825
|
+
return time.value?.clone() || new cesium.JulianDate(0, 0);
|
|
826
|
+
};
|
|
827
|
+
const collection = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
828
|
+
const plots = (0, vue.computed)(() => Array.from(collection));
|
|
829
|
+
const current = (0, vue.shallowRef)();
|
|
830
|
+
const packable = (0, vue.shallowRef)();
|
|
831
|
+
(0, vesium.useCesiumEventListener)([() => current.value?.sampled.definitionChanged], () => {
|
|
832
|
+
packable.value = current.value?.sampled.getValue(getCurrentTime());
|
|
833
|
+
});
|
|
834
|
+
useSampled(current, getCurrentTime);
|
|
835
|
+
useRender(plots, current, getCurrentTime);
|
|
836
|
+
useSkeleton(plots, current, getCurrentTime);
|
|
837
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
838
|
+
if (current.value?.defining) return;
|
|
839
|
+
const pick = viewer.value?.scene.pick(data.position.clone());
|
|
840
|
+
if (pick?.id?.plot instanceof PlotFeature) return;
|
|
841
|
+
if (!pick) {
|
|
842
|
+
current.value = void 0;
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
|
|
846
|
+
...plot.entities,
|
|
847
|
+
...plot.primitives,
|
|
848
|
+
...plot.groundPrimitives
|
|
849
|
+
]));
|
|
850
|
+
});
|
|
851
|
+
let operateResolve;
|
|
852
|
+
let operateReject;
|
|
853
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
854
|
+
if (previous) {
|
|
855
|
+
if (previous.defining) {
|
|
856
|
+
const packable$1 = previous.sampled.getValue(getCurrentTime());
|
|
857
|
+
const completed = previous.scheme.allowManualComplete?.(packable$1);
|
|
858
|
+
if (completed) {
|
|
859
|
+
PlotFeature.setDefining(previous, false);
|
|
860
|
+
operateResolve?.(previous);
|
|
861
|
+
} else collection.delete(previous);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
const operate = async (plot) => {
|
|
866
|
+
return new Promise((resolve, reject) => {
|
|
867
|
+
operateResolve = resolve;
|
|
868
|
+
operateReject = reject;
|
|
869
|
+
const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
|
|
870
|
+
if (!collection.has(_plot)) collection.add(_plot);
|
|
871
|
+
current.value = _plot;
|
|
872
|
+
return resolve(_plot);
|
|
873
|
+
});
|
|
874
|
+
};
|
|
875
|
+
const remove = (plot) => {
|
|
876
|
+
if (plot === current.value) current.value = void 0;
|
|
877
|
+
if (collection.has(plot)) {
|
|
878
|
+
collection.delete(plot);
|
|
879
|
+
return true;
|
|
880
|
+
}
|
|
881
|
+
return false;
|
|
882
|
+
};
|
|
883
|
+
return {
|
|
884
|
+
plots,
|
|
885
|
+
time,
|
|
886
|
+
operate,
|
|
887
|
+
remove,
|
|
888
|
+
cancel: operateReject
|
|
889
|
+
};
|
|
933
890
|
}
|
|
891
|
+
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region skeleton/control.ts
|
|
894
|
+
/**
|
|
895
|
+
* 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
|
|
896
|
+
*/
|
|
934
897
|
function control() {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
898
|
+
return {
|
|
899
|
+
disabled: ({ active }) => !active,
|
|
900
|
+
cursor: "pointer",
|
|
901
|
+
dragCursor: "crosshair",
|
|
902
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
903
|
+
lockCamera();
|
|
904
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
905
|
+
if (position) {
|
|
906
|
+
const positions = [...packable.positions ?? []];
|
|
907
|
+
positions[index] = position;
|
|
908
|
+
sampled.setSample({
|
|
909
|
+
time: packable.time,
|
|
910
|
+
derivative: packable.derivative,
|
|
911
|
+
positions
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
|
|
916
|
+
const height = (0, vesium.toCartographic)(viewer.camera.position)?.height;
|
|
917
|
+
if (!height || ![
|
|
918
|
+
"ArrowUp",
|
|
919
|
+
"ArrowRight",
|
|
920
|
+
"ArrowDown",
|
|
921
|
+
"ArrowLeft"
|
|
922
|
+
].includes(keyEvent.key)) return;
|
|
923
|
+
keyEvent.preventDefault();
|
|
924
|
+
let headingAdjust = 0;
|
|
925
|
+
switch (keyEvent.key) {
|
|
926
|
+
case "ArrowRight":
|
|
927
|
+
headingAdjust = Math.PI / 2;
|
|
928
|
+
break;
|
|
929
|
+
case "ArrowDown":
|
|
930
|
+
headingAdjust = Math.PI;
|
|
931
|
+
break;
|
|
932
|
+
case "ArrowLeft":
|
|
933
|
+
headingAdjust = -Math.PI / 2;
|
|
934
|
+
break;
|
|
935
|
+
case "ArrowUp":
|
|
936
|
+
headingAdjust = 0;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
940
|
+
const positions = [...packable.positions ?? []];
|
|
941
|
+
const cartographic = (0, vesium.toCartographic)(positions[index]);
|
|
942
|
+
const r = height / 1e5;
|
|
943
|
+
const distance = r * Math.PI / 180 / 1e3;
|
|
944
|
+
cartographic.latitude += distance * Math.cos(newHeading);
|
|
945
|
+
cartographic.longitude += distance * Math.sin(newHeading);
|
|
946
|
+
positions[index] = (0, vesium.toCartesian3)(cartographic);
|
|
947
|
+
sampled.setSample({
|
|
948
|
+
time: packable.time,
|
|
949
|
+
derivative: packable.derivative,
|
|
950
|
+
positions
|
|
951
|
+
});
|
|
952
|
+
},
|
|
953
|
+
render: ({ position, action }) => {
|
|
954
|
+
const colors = {
|
|
955
|
+
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
956
|
+
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
957
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
958
|
+
};
|
|
959
|
+
return {
|
|
960
|
+
position,
|
|
961
|
+
point: {
|
|
962
|
+
pixelSize: 8,
|
|
963
|
+
color: colors[action],
|
|
964
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
965
|
+
outlineWidth: 1,
|
|
966
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
};
|
|
1005
971
|
}
|
|
972
|
+
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region skeleton/interval.ts
|
|
975
|
+
/**
|
|
976
|
+
* 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
977
|
+
*/
|
|
1006
978
|
function interval() {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
point: {
|
|
1056
|
-
pixelSize: 6,
|
|
1057
|
-
color: colors[action],
|
|
1058
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1059
|
-
outlineWidth: 1,
|
|
1060
|
-
outlineColor: cesium.Color.WHITE.withAlpha(0.4)
|
|
1061
|
-
}
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
979
|
+
let dragIndex = -1;
|
|
980
|
+
return {
|
|
981
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
982
|
+
cursor: "pointer",
|
|
983
|
+
dragCursor: "crosshair",
|
|
984
|
+
format(packable) {
|
|
985
|
+
const _positions = packable.positions ?? [];
|
|
986
|
+
if (_positions.length < 2) return [];
|
|
987
|
+
return _positions.map((position, i) => {
|
|
988
|
+
const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
|
|
989
|
+
return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
993
|
+
lockCamera();
|
|
994
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
995
|
+
if (!position) return;
|
|
996
|
+
const positions = [...packable.positions ?? []];
|
|
997
|
+
if (dragIndex === -1) {
|
|
998
|
+
dragIndex = index;
|
|
999
|
+
positions.splice(index + 1, 0, position);
|
|
1000
|
+
} else positions[dragIndex + 1] = position;
|
|
1001
|
+
if (!dragging) dragIndex = -1;
|
|
1002
|
+
sampled.setSample({
|
|
1003
|
+
time: packable.time,
|
|
1004
|
+
derivative: packable.derivative,
|
|
1005
|
+
positions
|
|
1006
|
+
});
|
|
1007
|
+
},
|
|
1008
|
+
render: ({ position, action, active }) => {
|
|
1009
|
+
if (!active) return;
|
|
1010
|
+
const colors = {
|
|
1011
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1012
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1013
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1014
|
+
};
|
|
1015
|
+
return {
|
|
1016
|
+
position,
|
|
1017
|
+
point: {
|
|
1018
|
+
pixelSize: 6,
|
|
1019
|
+
color: colors[action],
|
|
1020
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1021
|
+
outlineWidth: 1,
|
|
1022
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1065
1027
|
}
|
|
1028
|
+
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region skeleton/intervalNonclosed.ts
|
|
1031
|
+
/**
|
|
1032
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1033
|
+
*/
|
|
1066
1034
|
function intervalNonclosed() {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
point: {
|
|
1114
|
-
pixelSize: 6,
|
|
1115
|
-
color: colors[action],
|
|
1116
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1117
|
-
outlineWidth: 1,
|
|
1118
|
-
outlineColor: cesium.Color.WHITE.withAlpha(0.4)
|
|
1119
|
-
}
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
};
|
|
1035
|
+
let dragIndex = -1;
|
|
1036
|
+
return {
|
|
1037
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
1038
|
+
cursor: "pointer",
|
|
1039
|
+
dragCursor: "crosshair",
|
|
1040
|
+
format(packable) {
|
|
1041
|
+
const _positions = packable.positions ?? [];
|
|
1042
|
+
if (_positions.length < 2) return [];
|
|
1043
|
+
const midpoints = [];
|
|
1044
|
+
for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
|
|
1045
|
+
return midpoints;
|
|
1046
|
+
},
|
|
1047
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1048
|
+
lockCamera();
|
|
1049
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1050
|
+
if (!position) return;
|
|
1051
|
+
const positions = [...packable.positions ?? []];
|
|
1052
|
+
if (dragIndex === -1) {
|
|
1053
|
+
dragIndex = index;
|
|
1054
|
+
positions.splice(index + 1, 0, position);
|
|
1055
|
+
} else positions[dragIndex + 1] = position;
|
|
1056
|
+
if (!dragging) dragIndex = -1;
|
|
1057
|
+
sampled.setSample({
|
|
1058
|
+
time: packable.time,
|
|
1059
|
+
derivative: packable.derivative,
|
|
1060
|
+
positions
|
|
1061
|
+
});
|
|
1062
|
+
},
|
|
1063
|
+
render: ({ position, action }) => {
|
|
1064
|
+
const colors = {
|
|
1065
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1066
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1067
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1068
|
+
};
|
|
1069
|
+
return {
|
|
1070
|
+
position,
|
|
1071
|
+
point: {
|
|
1072
|
+
pixelSize: 6,
|
|
1073
|
+
color: colors[action],
|
|
1074
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1075
|
+
outlineWidth: 1,
|
|
1076
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1123
1081
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1082
|
+
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region skeleton/moved.ts
|
|
1085
|
+
const svg = `data:image/svg+xml;utf8,${encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 24 24\"><path stroke=\"#ffffff\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6\"/></svg>")}`;
|
|
1086
|
+
/**
|
|
1087
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1088
|
+
*/
|
|
1127
1089
|
function moved() {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1090
|
+
return {
|
|
1091
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
1092
|
+
cursor: "pointer",
|
|
1093
|
+
dragCursor: "crosshair",
|
|
1094
|
+
format(packable) {
|
|
1095
|
+
const positions = packable.positions ?? [];
|
|
1096
|
+
if (positions.length === 0) return [];
|
|
1097
|
+
else if (positions.length === 1) return [positions[0]];
|
|
1098
|
+
else {
|
|
1099
|
+
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1100
|
+
return [(0, vesium.toCartesian3)(center)];
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1104
|
+
dragging && lockCamera();
|
|
1105
|
+
const startPosition = (0, vesium.canvasCoordToCartesian)(event.startPosition, viewer.scene);
|
|
1106
|
+
const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1107
|
+
if (!startPosition || !endPosition) return;
|
|
1108
|
+
const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
|
|
1109
|
+
const positions = [...packable.positions ?? []];
|
|
1110
|
+
sampled.setSample({
|
|
1111
|
+
time: packable.time,
|
|
1112
|
+
derivative: packable.derivative,
|
|
1113
|
+
positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
|
|
1114
|
+
});
|
|
1115
|
+
},
|
|
1116
|
+
render: ({ position, action }) => {
|
|
1117
|
+
const colors = {
|
|
1118
|
+
[PlotAction.IDLE]: cesium.Color.WHITE,
|
|
1119
|
+
[PlotAction.HOVER]: cesium.Color.WHITE,
|
|
1120
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
1121
|
+
};
|
|
1122
|
+
return {
|
|
1123
|
+
position,
|
|
1124
|
+
billboard: {
|
|
1125
|
+
image: svg,
|
|
1126
|
+
width: 20,
|
|
1127
|
+
height: 20,
|
|
1128
|
+
color: colors[action],
|
|
1129
|
+
pixelOffset: new cesium.Cartesian3(0, -20),
|
|
1130
|
+
horizontalOrigin: cesium.HorizontalOrigin.CENTER,
|
|
1131
|
+
verticalOrigin: cesium.VerticalOrigin.BOTTOM,
|
|
1132
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1179
1137
|
}
|
|
1138
|
+
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region measure/utils/tesselate.ts
|
|
1141
|
+
/**
|
|
1142
|
+
* 将多个边界点组成的面切割成多个三角形
|
|
1143
|
+
* @param positions
|
|
1144
|
+
*/
|
|
1180
1145
|
function tesselate(positions) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1146
|
+
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1147
|
+
if (positions.length === 3) return [[
|
|
1148
|
+
positions[0].clone(),
|
|
1149
|
+
positions[1].clone(),
|
|
1150
|
+
positions[2].clone()
|
|
1151
|
+
]];
|
|
1152
|
+
const geometry = cesium.CoplanarPolygonGeometry.createGeometry(cesium.CoplanarPolygonGeometry.fromPositions({
|
|
1153
|
+
positions,
|
|
1154
|
+
vertexFormat: cesium.VertexFormat.POSITION_ONLY
|
|
1155
|
+
}));
|
|
1156
|
+
if (!geometry) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1157
|
+
const values = geometry.attributes.position.values;
|
|
1158
|
+
const indices = geometry.indices;
|
|
1159
|
+
const result = [];
|
|
1160
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
1161
|
+
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1162
|
+
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1163
|
+
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1164
|
+
result.push([
|
|
1165
|
+
a,
|
|
1166
|
+
b,
|
|
1167
|
+
c
|
|
1168
|
+
]);
|
|
1169
|
+
}
|
|
1170
|
+
return result;
|
|
1206
1171
|
}
|
|
1172
|
+
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region measure/utils/clampToGround.ts
|
|
1175
|
+
/**
|
|
1176
|
+
* 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
|
|
1177
|
+
* @param options - 配置项
|
|
1178
|
+
*/
|
|
1179
|
+
async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
|
|
1180
|
+
const { positions, scene, classificationType = cesium.ClassificationType.BOTH, terrainProvider = scene.terrainProvider } = options;
|
|
1181
|
+
const tileset = [cesium.ClassificationType.BOTH, cesium.ClassificationType.CESIUM_3D_TILE].includes(classificationType);
|
|
1182
|
+
const terrain = [cesium.ClassificationType.BOTH, cesium.ClassificationType.TERRAIN].includes(classificationType);
|
|
1183
|
+
const tilesetPromise = new Promise((resolve) => {
|
|
1184
|
+
if (tileset) scene.clampToHeightMostDetailed(positions.map((e) => e.clone())).then(resolve).catch((error) => {
|
|
1185
|
+
console.warn(error);
|
|
1186
|
+
resolve([]);
|
|
1187
|
+
});
|
|
1188
|
+
else resolve([]);
|
|
1189
|
+
});
|
|
1190
|
+
const terrainPromise = new Promise((resolve) => {
|
|
1191
|
+
if (terrain && terrainProvider) (0, cesium.sampleTerrainMostDetailed)(terrainProvider, positions.map((e) => cesium.Cartographic.fromCartesian(e))).then((e) => resolve(e)).catch((error) => {
|
|
1192
|
+
console.warn(error);
|
|
1193
|
+
resolve([]);
|
|
1194
|
+
});
|
|
1195
|
+
else resolve([]);
|
|
1196
|
+
});
|
|
1197
|
+
const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
|
|
1198
|
+
const resluts = [];
|
|
1199
|
+
positions.forEach((item, index) => {
|
|
1200
|
+
const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
|
|
1201
|
+
resluts.push(position);
|
|
1202
|
+
});
|
|
1203
|
+
return resluts;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
//#endregion
|
|
1207
|
+
//#region measure/utils/triangleGrid.ts
|
|
1208
|
+
function defaultOptions$1(original) {
|
|
1209
|
+
const clampToGround = original?.clampToGround ?? false;
|
|
1210
|
+
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1211
|
+
const density = Math.floor(original?.density ?? 10);
|
|
1212
|
+
return {
|
|
1213
|
+
scene: original?.scene,
|
|
1214
|
+
clampToGround,
|
|
1215
|
+
classificationType,
|
|
1216
|
+
terrainProvider: original?.terrainProvider,
|
|
1217
|
+
density
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* 生成三角网数组
|
|
1222
|
+
* @param positions - 边界点数组
|
|
1223
|
+
* @param options - 配置项
|
|
1224
|
+
*/
|
|
1225
|
+
async function triangleGrid(positions, options) {
|
|
1226
|
+
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1227
|
+
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
|
|
1228
|
+
if (density <= 0) throw new Error("options.density must > 0");
|
|
1229
|
+
const bbox = cesium.Rectangle.fromCartesianArray(positions);
|
|
1230
|
+
const vertical = bbox.north - bbox.south;
|
|
1231
|
+
const horizontal = bbox.east - bbox.west;
|
|
1232
|
+
const max = Math.max(horizontal, vertical);
|
|
1233
|
+
const granularity = max / density;
|
|
1234
|
+
const polygonGeometry = cesium.PolygonGeometry.fromPositions({
|
|
1235
|
+
positions,
|
|
1236
|
+
vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
1237
|
+
granularity
|
|
1238
|
+
});
|
|
1239
|
+
const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
|
|
1240
|
+
const values = geometry.attributes.position.values;
|
|
1241
|
+
if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1242
|
+
const indices = geometry.indices;
|
|
1243
|
+
let cartesian3List = [];
|
|
1244
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
1245
|
+
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1246
|
+
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1247
|
+
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1248
|
+
cartesian3List.push(a, b, c);
|
|
1249
|
+
}
|
|
1250
|
+
if (clampToGround) {
|
|
1251
|
+
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1252
|
+
const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1253
|
+
scene,
|
|
1254
|
+
terrainProvider,
|
|
1255
|
+
positions: cartesian3List,
|
|
1256
|
+
classificationType
|
|
1257
|
+
});
|
|
1258
|
+
cartesian3List = detaileds;
|
|
1259
|
+
}
|
|
1260
|
+
const grid = [];
|
|
1261
|
+
while (cartesian3List?.length) {
|
|
1262
|
+
const [a, b, c] = cartesian3List.splice(0, 3);
|
|
1263
|
+
grid.push([
|
|
1264
|
+
a,
|
|
1265
|
+
b,
|
|
1266
|
+
c
|
|
1267
|
+
]);
|
|
1268
|
+
}
|
|
1269
|
+
return grid;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
//#endregion
|
|
1273
|
+
//#region measure/utils/area.ts
|
|
1274
|
+
/**
|
|
1275
|
+
* 计算三维坐标系下三角形面积
|
|
1276
|
+
* @param p0 - 三角形第一个点
|
|
1277
|
+
* @param p1 - 三角形第二个点
|
|
1278
|
+
* @param p2 - 三角形第三个点
|
|
1279
|
+
*/
|
|
1207
1280
|
function triangleArea(p0, p1, p2) {
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1281
|
+
const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
|
|
1282
|
+
const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
|
|
1283
|
+
const cross = cesium.Cartesian3.cross(v0, v1, v0);
|
|
1284
|
+
return cesium.Cartesian3.magnitude(cross) * .5;
|
|
1212
1285
|
}
|
|
1213
1286
|
function defaultOptions(original) {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1287
|
+
const clampToGround = original?.clampToGround ?? false;
|
|
1288
|
+
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1289
|
+
const density = Math.floor(original?.density ?? 10);
|
|
1290
|
+
return {
|
|
1291
|
+
scene: original?.scene,
|
|
1292
|
+
clampToGround,
|
|
1293
|
+
classificationType,
|
|
1294
|
+
terrainProvider: original?.terrainProvider,
|
|
1295
|
+
density
|
|
1296
|
+
};
|
|
1224
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* 计算三维坐标系下图形面积
|
|
1300
|
+
* @param positions - 图形各点的笛卡尔数组
|
|
1301
|
+
*/
|
|
1225
1302
|
async function area(positions, options) {
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1303
|
+
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1304
|
+
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions(options);
|
|
1305
|
+
if (density <= 0) throw new Error("options.density must > 0");
|
|
1306
|
+
if (!clampToGround) {
|
|
1307
|
+
const triangles$1 = tesselate(positions);
|
|
1308
|
+
return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1309
|
+
}
|
|
1310
|
+
const triangles = await triangleGrid(positions, {
|
|
1311
|
+
density,
|
|
1312
|
+
scene,
|
|
1313
|
+
clampToGround,
|
|
1314
|
+
classificationType,
|
|
1315
|
+
terrainProvider
|
|
1316
|
+
});
|
|
1317
|
+
return triangles.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1237
1318
|
}
|
|
1319
|
+
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region measure/measureArea.ts
|
|
1238
1322
|
const schemeMeasureArea = new PlotScheme({
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
vesium.toCartesian3(
|
|
1283
|
-
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1284
|
-
)
|
|
1285
|
-
);
|
|
1286
|
-
entity.label.text = new cesium.ConstantProperty("");
|
|
1287
|
-
area(positions).then((e) => {
|
|
1288
|
-
let text = "";
|
|
1289
|
-
if (e / 1e3 / 1e3 > 10) {
|
|
1290
|
-
text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
|
|
1291
|
-
} else {
|
|
1292
|
-
text = `${(+e).toFixed(2)}m²`;
|
|
1293
|
-
}
|
|
1294
|
-
entity.label.text = new cesium.ConstantProperty(text);
|
|
1295
|
-
});
|
|
1296
|
-
entity.polyline.positions = void 0;
|
|
1297
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1298
|
-
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1299
|
-
}, false);
|
|
1300
|
-
} else {
|
|
1301
|
-
entity.position = void 0;
|
|
1302
|
-
entity.polygon.hierarchy = void 0;
|
|
1303
|
-
entity.polyline.positions = void 0;
|
|
1304
|
-
}
|
|
1305
|
-
return {
|
|
1306
|
-
entities: [entity]
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1323
|
+
type: "measureArea",
|
|
1324
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1325
|
+
skeletons: [control, interval],
|
|
1326
|
+
initEntites: () => [new cesium.Entity({
|
|
1327
|
+
label: { font: "14pt" },
|
|
1328
|
+
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1329
|
+
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1330
|
+
})],
|
|
1331
|
+
render(options) {
|
|
1332
|
+
const { mouse, packable } = options;
|
|
1333
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({
|
|
1334
|
+
label: { font: "14pt" },
|
|
1335
|
+
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1336
|
+
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1337
|
+
});
|
|
1338
|
+
const positions = [...packable.positions ?? []];
|
|
1339
|
+
mouse && positions.push(mouse);
|
|
1340
|
+
if (positions.length === 2) {
|
|
1341
|
+
entity.position = void 0;
|
|
1342
|
+
entity.label.text = void 0;
|
|
1343
|
+
entity.polygon.hierarchy = void 0;
|
|
1344
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1345
|
+
} else if (positions.length >= 3) {
|
|
1346
|
+
positions.push(positions[0]);
|
|
1347
|
+
entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
|
|
1348
|
+
entity.label.text = new cesium.ConstantProperty("");
|
|
1349
|
+
area(positions).then((e) => {
|
|
1350
|
+
let text = "";
|
|
1351
|
+
if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
|
|
1352
|
+
else text = `${(+e).toFixed(2)}m²`;
|
|
1353
|
+
entity.label.text = new cesium.ConstantProperty(text);
|
|
1354
|
+
});
|
|
1355
|
+
entity.polyline.positions = void 0;
|
|
1356
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1357
|
+
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1358
|
+
}, false);
|
|
1359
|
+
} else {
|
|
1360
|
+
entity.position = void 0;
|
|
1361
|
+
entity.polygon.hierarchy = void 0;
|
|
1362
|
+
entity.polyline.positions = void 0;
|
|
1363
|
+
}
|
|
1364
|
+
return { entities: [entity] };
|
|
1365
|
+
}
|
|
1309
1366
|
});
|
|
1367
|
+
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region scheme/billboard.ts
|
|
1370
|
+
/**
|
|
1371
|
+
* 广告牌标绘方案
|
|
1372
|
+
*/
|
|
1310
1373
|
const schemeBillboard = new PlotScheme({
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
entities: [entity]
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1374
|
+
type: "billboard",
|
|
1375
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1376
|
+
skeletons: [moved],
|
|
1377
|
+
initEntites: () => [new cesium.Entity({ billboard: {
|
|
1378
|
+
image: "/favicon.svg",
|
|
1379
|
+
width: 32,
|
|
1380
|
+
height: 32
|
|
1381
|
+
} })],
|
|
1382
|
+
render(options) {
|
|
1383
|
+
const { mouse, packable } = options;
|
|
1384
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ billboard: {} });
|
|
1385
|
+
const position = packable.positions?.[0] ?? mouse;
|
|
1386
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1387
|
+
return { entities: [entity] };
|
|
1388
|
+
}
|
|
1329
1389
|
});
|
|
1390
|
+
|
|
1391
|
+
//#endregion
|
|
1392
|
+
//#region scheme/label.ts
|
|
1393
|
+
/**
|
|
1394
|
+
* 标签文字标绘方案
|
|
1395
|
+
*/
|
|
1330
1396
|
const schemeLabel = new PlotScheme({
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({ label: {} });
|
|
1343
|
-
const position = ((_b = packable.positions) == null ? void 0 : _b[0]) ?? mouse;
|
|
1344
|
-
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1345
|
-
return {
|
|
1346
|
-
entities: [entity]
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
1397
|
+
type: "label",
|
|
1398
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1399
|
+
skeletons: [moved],
|
|
1400
|
+
initEntites: () => [new cesium.Entity({ label: { text: "Label" } })],
|
|
1401
|
+
render(options) {
|
|
1402
|
+
const { mouse, packable } = options;
|
|
1403
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ label: {} });
|
|
1404
|
+
const position = packable.positions?.[0] ?? mouse;
|
|
1405
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1406
|
+
return { entities: [entity] };
|
|
1407
|
+
}
|
|
1349
1408
|
});
|
|
1409
|
+
|
|
1410
|
+
//#endregion
|
|
1411
|
+
//#region scheme/polygon.ts
|
|
1412
|
+
/**
|
|
1413
|
+
* 内置的多边形标绘方案
|
|
1414
|
+
*/
|
|
1350
1415
|
const schemePolygon = new PlotScheme({
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1416
|
+
type: "polygon",
|
|
1417
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1418
|
+
skeletons: [
|
|
1419
|
+
control,
|
|
1420
|
+
interval,
|
|
1421
|
+
moved
|
|
1422
|
+
],
|
|
1423
|
+
initEntites: () => [new cesium.Entity({
|
|
1424
|
+
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1425
|
+
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1426
|
+
})],
|
|
1427
|
+
render(options) {
|
|
1428
|
+
const { mouse, packable } = options;
|
|
1429
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({
|
|
1430
|
+
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1431
|
+
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1432
|
+
});
|
|
1433
|
+
const positions = [...packable.positions ?? []];
|
|
1434
|
+
mouse && positions.push(mouse);
|
|
1435
|
+
if (positions.length === 2) {
|
|
1436
|
+
entity.polygon.hierarchy = void 0;
|
|
1437
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1438
|
+
} else if (positions.length >= 3) {
|
|
1439
|
+
entity.polyline.positions = void 0;
|
|
1440
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1441
|
+
positions.push(positions[0]);
|
|
1442
|
+
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1443
|
+
}, false);
|
|
1444
|
+
} else {
|
|
1445
|
+
entity.polygon.hierarchy = void 0;
|
|
1446
|
+
entity.polyline.positions = void 0;
|
|
1447
|
+
}
|
|
1448
|
+
return { entities: [entity] };
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#region scheme/polyline.ts
|
|
1454
|
+
/**
|
|
1455
|
+
* 内置的线段标绘方案
|
|
1456
|
+
*/
|
|
1457
|
+
const schemePolyline = new PlotScheme({
|
|
1458
|
+
type: "polyline",
|
|
1459
|
+
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1460
|
+
skeletons: [
|
|
1461
|
+
control,
|
|
1462
|
+
intervalNonclosed,
|
|
1463
|
+
moved
|
|
1464
|
+
],
|
|
1465
|
+
initEntites: () => [new cesium.Entity({ polyline: { width: 1 } })],
|
|
1466
|
+
render(options) {
|
|
1467
|
+
const { mouse, packable } = options;
|
|
1468
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ polyline: {} });
|
|
1469
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => {
|
|
1470
|
+
const positions = [...packable.positions ?? []].concat(mouse ? [mouse] : []);
|
|
1471
|
+
return positions.length >= 2 ? positions : [];
|
|
1472
|
+
}, false);
|
|
1473
|
+
return { entities: [entity] };
|
|
1474
|
+
}
|
|
1398
1475
|
});
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
intervalNonclosed,
|
|
1406
|
-
moved
|
|
1407
|
-
],
|
|
1408
|
-
initEntites: () => [
|
|
1409
|
-
new cesium.Entity({ polyline: { width: 1 } })
|
|
1410
|
-
],
|
|
1411
|
-
render(options) {
|
|
1412
|
-
var _a;
|
|
1413
|
-
const { mouse, packable } = options;
|
|
1414
|
-
const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({ polyline: {} });
|
|
1415
|
-
entity.polyline.positions = new cesium.CallbackProperty(() => {
|
|
1416
|
-
const positions = [...packable.positions ?? []].concat(mouse ? [mouse] : []);
|
|
1417
|
-
return positions.length >= 2 ? positions : [];
|
|
1418
|
-
}, false);
|
|
1419
|
-
return {
|
|
1420
|
-
entities: [entity]
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
);
|
|
1476
|
+
|
|
1477
|
+
//#endregion
|
|
1478
|
+
//#region scheme/rectangle.ts
|
|
1479
|
+
/**
|
|
1480
|
+
* 内置的多边形标绘方案
|
|
1481
|
+
*/
|
|
1425
1482
|
const schemeRectangle = new PlotScheme({
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
const entity = ((_a = options.previous.entities) == null ? void 0 : _a[0]) ?? new cesium.Entity({
|
|
1444
|
-
rectangle: {
|
|
1445
|
-
material: cesium.Color.YELLOW.withAlpha(0.5)
|
|
1446
|
-
}
|
|
1447
|
-
});
|
|
1448
|
-
const positions = [...packable.positions ?? []];
|
|
1449
|
-
mouse && positions.push(mouse);
|
|
1450
|
-
if (positions.length >= 2) {
|
|
1451
|
-
entity.rectangle.coordinates = new cesium.CallbackProperty(() => cesium.Rectangle.fromCartesianArray(positions), false);
|
|
1452
|
-
} else {
|
|
1453
|
-
entity.rectangle.coordinates = void 0;
|
|
1454
|
-
}
|
|
1455
|
-
return {
|
|
1456
|
-
entities: [entity]
|
|
1457
|
-
};
|
|
1458
|
-
}
|
|
1483
|
+
type: "rectangle",
|
|
1484
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1485
|
+
skeletons: [
|
|
1486
|
+
control,
|
|
1487
|
+
interval,
|
|
1488
|
+
moved
|
|
1489
|
+
],
|
|
1490
|
+
initEntites: () => [new cesium.Entity({ rectangle: { material: cesium.Color.YELLOW.withAlpha(.5) } })],
|
|
1491
|
+
render(options) {
|
|
1492
|
+
const { mouse, packable } = options;
|
|
1493
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ rectangle: { material: cesium.Color.YELLOW.withAlpha(.5) } });
|
|
1494
|
+
const positions = [...packable.positions ?? []];
|
|
1495
|
+
mouse && positions.push(mouse);
|
|
1496
|
+
if (positions.length >= 2) entity.rectangle.coordinates = new cesium.CallbackProperty(() => cesium.Rectangle.fromCartesianArray(positions), false);
|
|
1497
|
+
else entity.rectangle.coordinates = void 0;
|
|
1498
|
+
return { entities: [entity] };
|
|
1499
|
+
}
|
|
1459
1500
|
});
|
|
1501
|
+
|
|
1502
|
+
//#endregion
|
|
1460
1503
|
exports.PlotAction = PlotAction;
|
|
1461
1504
|
exports.PlotFeature = PlotFeature;
|
|
1462
1505
|
exports.PlotScheme = PlotScheme;
|
|
@@ -1474,4 +1517,4 @@ exports.schemePolygon = schemePolygon;
|
|
|
1474
1517
|
exports.schemePolyline = schemePolyline;
|
|
1475
1518
|
exports.schemeRectangle = schemeRectangle;
|
|
1476
1519
|
exports.usePlot = usePlot;
|
|
1477
|
-
//# sourceMappingURL=index.cjs.map
|
|
1520
|
+
//# sourceMappingURL=index.cjs.map
|