@vesium/plot 1.0.1-beta.51 → 1.0.1-beta.54
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/README.md +1 -1
- package/dist/index.cjs +723 -200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -69
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +73 -69
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1887 -1370
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +695 -194
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -10
package/dist/index.iife.js
CHANGED
|
@@ -1,1510 +1,2031 @@
|
|
|
1
|
-
(function(exports, cesium, vesium, __vueuse_core, vue) {
|
|
1
|
+
(function(exports, cesium, vesium, __vueuse_core, vue, __vesium_geometry, __turf_turf) {
|
|
2
2
|
|
|
3
3
|
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}) : target, mod));
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
cesium = __toESM(cesium);
|
|
27
27
|
vesium = __toESM(vesium);
|
|
28
28
|
__vueuse_core = __toESM(__vueuse_core);
|
|
29
29
|
vue = __toESM(vue);
|
|
30
|
+
__vesium_geometry = __toESM(__vesium_geometry);
|
|
31
|
+
__turf_turf = __toESM(__turf_turf);
|
|
30
32
|
|
|
31
33
|
//#region usePlot/PlotScheme.ts
|
|
32
|
-
var PlotScheme = class PlotScheme {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
34
|
+
var PlotScheme = class PlotScheme {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
this.type = options.type;
|
|
37
|
+
this.complete = options.complete;
|
|
38
|
+
this.allowManualComplete = options.allowManualComplete;
|
|
39
|
+
this.definingCursor = options.definingCursor ?? "crosshair";
|
|
40
|
+
this.skeletons = options.skeletons?.map((item) => item()) ?? [];
|
|
41
|
+
this.initRender = options.initRender;
|
|
42
|
+
this.render = options.render;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 标绘类型。应当是全局唯一的字符串,会作为键名缓存
|
|
46
|
+
*/
|
|
47
|
+
type;
|
|
48
|
+
/**
|
|
49
|
+
* 判断是否立即完成标绘.
|
|
50
|
+
* 每次控制点发生变变化时,执行该回调函数,返回`true`则完成标绘
|
|
51
|
+
*/
|
|
52
|
+
complete;
|
|
53
|
+
/**
|
|
54
|
+
* 判断是否允许手动完成标绘。
|
|
55
|
+
* 每次控制点发生变变化时,执行该回调函数,返回`true`则后续左键双击即完成标绘
|
|
56
|
+
*/
|
|
57
|
+
allowManualComplete;
|
|
58
|
+
/**
|
|
59
|
+
* 处于定义态时鼠标的样式
|
|
60
|
+
* @default 'crosshair'
|
|
61
|
+
*/
|
|
62
|
+
definingCursor;
|
|
63
|
+
/**
|
|
64
|
+
* 当前标绘的框架点数据
|
|
65
|
+
*/
|
|
66
|
+
skeletons;
|
|
67
|
+
/**
|
|
68
|
+
* 初始化时创建贴地`Primitive`的函数,创建后的`Primitive`会作为配置项传入`render`中
|
|
69
|
+
*/
|
|
70
|
+
initRender;
|
|
71
|
+
/**
|
|
72
|
+
* 当标绘数据变化时,会触发`render`回调,返回的数据会被添加到cesium中
|
|
73
|
+
*/
|
|
74
|
+
render;
|
|
75
|
+
static _record = /* @__PURE__ */ new Map();
|
|
76
|
+
/**
|
|
77
|
+
* 标绘方案缓存。
|
|
78
|
+
* 每次标绘时都会将`PlotScheme.type`作为键名缓存,
|
|
79
|
+
* 后续可用过`PlotScheme.getCache(type)`获取完整的`PlotScheme`配置。
|
|
80
|
+
*/
|
|
81
|
+
static getCacheTypes() {
|
|
82
|
+
return [...this._record.keys()];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 通过`PlotScheme.type`获取缓存中的`PlotScheme`配置。
|
|
86
|
+
*/
|
|
87
|
+
static getCache(type) {
|
|
88
|
+
return PlotScheme._record.get(type);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 缓存标绘方案。
|
|
92
|
+
*/
|
|
93
|
+
static setCache(scheme) {
|
|
94
|
+
(0, vesium.assertError)(!scheme.type, "`scheme.type` is required");
|
|
95
|
+
PlotScheme._record.set(scheme.type, scheme);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 解析传入的maybeScheme,maybeScheme可能是一个完整的PlotScheme,也可能是缓存中的`PlotScheme.type`,并返回 PlotScheme 实例。
|
|
99
|
+
* 若传入的是`PlotScheme.type`字符串,并且缓存中不存在该标绘方案,则抛出错误。
|
|
100
|
+
*/
|
|
101
|
+
static resolve(maybeScheme) {
|
|
102
|
+
if (typeof maybeScheme === "string") {
|
|
103
|
+
const _scheme = PlotScheme.getCache(maybeScheme);
|
|
104
|
+
(0, __vueuse_core.assert)(!!_scheme, `scheme ${maybeScheme} not found`);
|
|
105
|
+
return _scheme;
|
|
106
|
+
} else if (!(maybeScheme instanceof PlotScheme)) return new PlotScheme(maybeScheme);
|
|
107
|
+
else return maybeScheme;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region usePlot/SampledPlotProperty.ts
|
|
113
|
+
let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
|
|
114
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["NEAR"] = 0] = "NEAR";
|
|
115
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["CYCLE"] = 1] = "CYCLE";
|
|
116
|
+
SampledPlotStrategy$1[SampledPlotStrategy$1["STRICT"] = 2] = "STRICT";
|
|
117
|
+
return SampledPlotStrategy$1;
|
|
118
|
+
}({});
|
|
98
119
|
/**
|
|
99
|
-
*
|
|
120
|
+
* 默认插值算法
|
|
121
|
+
*
|
|
122
|
+
* @param time 时间
|
|
123
|
+
* @param previous 前一个数据点
|
|
124
|
+
* @param next 后一个数据点
|
|
125
|
+
* @param proportion 比例
|
|
126
|
+
* @returns 插值结果
|
|
100
127
|
*/
|
|
101
|
-
|
|
102
|
-
(0
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
const defaultInterpolationAlgorithm = (time, previous, next, proportion) => {
|
|
129
|
+
if (proportion === 0) return {
|
|
130
|
+
time,
|
|
131
|
+
positions: previous.positions?.map((item) => item.clone()),
|
|
132
|
+
derivative: previous.derivative
|
|
133
|
+
};
|
|
134
|
+
else if (proportion === 1) return {
|
|
135
|
+
time,
|
|
136
|
+
positions: next.positions?.map((item) => item.clone()),
|
|
137
|
+
derivative: previous.derivative
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
time,
|
|
141
|
+
positions: next.positions?.map((right, index) => {
|
|
142
|
+
const left = previous.positions?.[index];
|
|
143
|
+
return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
|
|
144
|
+
}),
|
|
145
|
+
derivative: previous.derivative
|
|
146
|
+
};
|
|
147
|
+
};
|
|
105
148
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
149
|
+
* 标绘采样点数据。
|
|
150
|
+
* 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
|
|
151
|
+
* 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
|
|
108
152
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
153
|
+
var SampledPlotProperty = class SampledPlotProperty {
|
|
154
|
+
constructor(options) {
|
|
155
|
+
this.interpolationAlgorithm = options?.interpolationAlgorithm;
|
|
156
|
+
this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
|
|
157
|
+
options?.packables?.forEach((packable) => this.setSample(packable));
|
|
158
|
+
if (!this._times.length) this.setSample({
|
|
159
|
+
time: new cesium.JulianDate(0, 0),
|
|
160
|
+
positions: [],
|
|
161
|
+
derivative: void 0
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
|
|
165
|
+
strategy;
|
|
166
|
+
interpolationAlgorithm;
|
|
167
|
+
/**
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
_times = [];
|
|
171
|
+
/**
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
_sampleds = [];
|
|
175
|
+
/**
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
_derivatives = [];
|
|
179
|
+
get isConstant() {
|
|
180
|
+
return this._times.length === 0;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @internal
|
|
184
|
+
*/
|
|
185
|
+
_definitionChanged = new cesium.Event();
|
|
186
|
+
get definitionChanged() {
|
|
187
|
+
return this._definitionChanged;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* 获取时间数组
|
|
191
|
+
*
|
|
192
|
+
* @returns 返回包含所有时间的 JulianDate 数组
|
|
193
|
+
*/
|
|
194
|
+
getTimes() {
|
|
195
|
+
return this._times.map((t) => t.clone());
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 根据给定的儒略日期获取时间索引范围及比例
|
|
199
|
+
*
|
|
200
|
+
* @param time 给定的儒略日期
|
|
201
|
+
* @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
getIndexScope(time) {
|
|
205
|
+
if (!this._times.length) return;
|
|
206
|
+
const start = this._times[0];
|
|
207
|
+
const end = this._times[this._times.length - 1];
|
|
208
|
+
if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
|
|
209
|
+
case SampledPlotStrategy.STRICT: return;
|
|
210
|
+
case SampledPlotStrategy.NEAR:
|
|
211
|
+
time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
|
|
212
|
+
break;
|
|
213
|
+
case SampledPlotStrategy.CYCLE: {
|
|
214
|
+
const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
|
|
215
|
+
const duration = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime() - startMS;
|
|
216
|
+
const diff = (cesium.JulianDate.toDate(time).getTime() - startMS) % duration;
|
|
217
|
+
const dete = new Date(startMS + diff);
|
|
218
|
+
time = cesium.JulianDate.fromDate(dete);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
|
|
223
|
+
const nextIndex = Math.min(prevIndex, this._times.length - 1);
|
|
224
|
+
const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
|
|
225
|
+
const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
|
|
226
|
+
return {
|
|
227
|
+
prevIndex,
|
|
228
|
+
nextIndex,
|
|
229
|
+
proportion: (cesium.JulianDate.toDate(time).getTime() - prevMs) / (nextMs - prevMs) || 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
|
|
234
|
+
*
|
|
235
|
+
* @param time 指定的儒略日期(JulianDate)。
|
|
236
|
+
* @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
|
|
237
|
+
* @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
|
|
238
|
+
* @template D 数据类型。
|
|
239
|
+
*/
|
|
240
|
+
getValue(time, result) {
|
|
241
|
+
result ??= {
|
|
242
|
+
time,
|
|
243
|
+
positions: []
|
|
244
|
+
};
|
|
245
|
+
Object.assign(result, {
|
|
246
|
+
time: time?.clone(),
|
|
247
|
+
positions: [],
|
|
248
|
+
derivative: void 0
|
|
249
|
+
});
|
|
250
|
+
if (!time) {
|
|
251
|
+
result.time = this._times[0].clone();
|
|
252
|
+
result.positions = this._sampleds[0]?.map((c) => c.clone(c));
|
|
253
|
+
result.derivative = this._derivatives[0];
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
const scope = this.getIndexScope(time);
|
|
257
|
+
if (!scope) return result;
|
|
258
|
+
result.time = time;
|
|
259
|
+
const { prevIndex, nextIndex, proportion } = scope;
|
|
260
|
+
const previous = {
|
|
261
|
+
time: this._times[prevIndex],
|
|
262
|
+
positions: this._sampleds[prevIndex],
|
|
263
|
+
derivative: this._derivatives[prevIndex]
|
|
264
|
+
};
|
|
265
|
+
const next = {
|
|
266
|
+
time: this._times[nextIndex],
|
|
267
|
+
positions: this._sampleds[nextIndex],
|
|
268
|
+
derivative: this._derivatives[nextIndex]
|
|
269
|
+
};
|
|
270
|
+
const packable = (this.interpolationAlgorithm || SampledPlotProperty.defaultInterpolationAlgorithm)(time, previous, next, proportion);
|
|
271
|
+
Object.assign(result, packable);
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
|
|
276
|
+
* @param value 样本数据对象,包含时间、位置和导数信息
|
|
277
|
+
*/
|
|
278
|
+
setSample(value) {
|
|
279
|
+
const time = value.time?.clone() ?? this._times[0].clone();
|
|
280
|
+
const positions = value.positions?.map((item) => item.clone()) ?? [];
|
|
281
|
+
const derivative = value.derivative;
|
|
282
|
+
const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
|
|
283
|
+
if (index !== -1) {
|
|
284
|
+
this._times[index] = time;
|
|
285
|
+
this._sampleds[index] = positions;
|
|
286
|
+
this._derivatives[index] = value.derivative;
|
|
287
|
+
} else if (this._times.length === 0) {
|
|
288
|
+
this._times[0] = time;
|
|
289
|
+
this._sampleds[0] = positions;
|
|
290
|
+
this._derivatives[0] = value.derivative;
|
|
291
|
+
} else if (cesium.JulianDate.lessThan(time, this._times[0])) {
|
|
292
|
+
this._times.splice(0, 0, time);
|
|
293
|
+
this._sampleds.splice(0, 0, positions);
|
|
294
|
+
this._derivatives.splice(0, 0, derivative);
|
|
295
|
+
} else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
|
|
296
|
+
this._times.push(time);
|
|
297
|
+
this._sampleds.push(positions);
|
|
298
|
+
this._derivatives.push(derivative);
|
|
299
|
+
}
|
|
300
|
+
this.definitionChanged.raiseEvent(this);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 设置样本数据
|
|
304
|
+
*
|
|
305
|
+
* @param values 样本数据数组,每个元素都是类型为SampledPlotPackable<D>的对象
|
|
306
|
+
*/
|
|
307
|
+
setSamples(values) {
|
|
308
|
+
values.forEach((value) => this.setSample(value));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 从样本中移除指定时间点的数据
|
|
312
|
+
*
|
|
313
|
+
* @param time 需要移除的时间点,使用儒略日期表示
|
|
314
|
+
* @returns 如果成功移除,则返回 true;否则返回 false
|
|
315
|
+
*/
|
|
316
|
+
removeSample(time) {
|
|
317
|
+
const index = this._times.findIndex((t) => t.equals(time));
|
|
318
|
+
if (index !== -1) {
|
|
319
|
+
this._sampleds.splice(index, 1);
|
|
320
|
+
this._derivatives.splice(index, 1);
|
|
321
|
+
if (this._times.splice(index, 1).length) {
|
|
322
|
+
this._definitionChanged.raiseEvent(this);
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* 从样本中移除指定时间间隔内的样本。
|
|
330
|
+
*
|
|
331
|
+
* @param interval 要移除样本的时间间隔
|
|
332
|
+
*/
|
|
333
|
+
removeSamples(interval$1) {
|
|
334
|
+
for (let i = 0; i < this._times.length; i++) {
|
|
335
|
+
const time = this._times[i];
|
|
336
|
+
cesium.TimeInterval.contains(interval$1, time) && this.removeSample(time);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* 判断两个property是否相等
|
|
341
|
+
*/
|
|
342
|
+
equals(other) {
|
|
343
|
+
return other === this;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
118
346
|
|
|
119
347
|
//#endregion
|
|
120
|
-
//#region usePlot/
|
|
121
|
-
let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
|
|
122
|
-
SampledPlotStrategy$1[SampledPlotStrategy$1["NEAR"] = 0] = "NEAR";
|
|
123
|
-
SampledPlotStrategy$1[SampledPlotStrategy$1["CYCLE"] = 1] = "CYCLE";
|
|
124
|
-
SampledPlotStrategy$1[SampledPlotStrategy$1["STRICT"] = 2] = "STRICT";
|
|
125
|
-
return SampledPlotStrategy$1;
|
|
126
|
-
}({});
|
|
348
|
+
//#region usePlot/PlotFeature.ts
|
|
127
349
|
/**
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
|
|
350
|
+
* 标绘实例
|
|
351
|
+
*/
|
|
352
|
+
var PlotFeature = class {
|
|
353
|
+
constructor(options) {
|
|
354
|
+
const { id, disabled = false, sampled } = options;
|
|
355
|
+
this._id = id || (0, cesium.createGuid)();
|
|
356
|
+
this._scheme = PlotScheme.resolve(options.scheme);
|
|
357
|
+
this._definitionChanged = new cesium.Event();
|
|
358
|
+
this._defining = true;
|
|
359
|
+
this._disabled = disabled;
|
|
360
|
+
this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
|
|
361
|
+
this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
|
|
362
|
+
const init = this._scheme.initRender?.() ?? {};
|
|
363
|
+
this._entities = [...init.entities ?? []];
|
|
364
|
+
this._primitives = [...init.primitives ?? []];
|
|
365
|
+
this._groundPrimitives = [...init.groundPrimitives ?? []];
|
|
366
|
+
this._skeletons = [];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* @internal
|
|
370
|
+
*/
|
|
371
|
+
_id;
|
|
372
|
+
get id() {
|
|
373
|
+
return this._id;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* @internal
|
|
377
|
+
*/
|
|
378
|
+
_scheme;
|
|
379
|
+
get scheme() {
|
|
380
|
+
return this._scheme;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* @internal
|
|
384
|
+
*/
|
|
385
|
+
_definitionChanged;
|
|
386
|
+
get definitionChanged() {
|
|
387
|
+
return this._definitionChanged;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
_defining;
|
|
393
|
+
get defining() {
|
|
394
|
+
return this._defining;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
static setDefining(plot, value) {
|
|
400
|
+
if (plot._defining !== value) {
|
|
401
|
+
plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
|
|
402
|
+
plot._defining = value;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* @internal
|
|
407
|
+
*/
|
|
408
|
+
_disabled;
|
|
409
|
+
/**
|
|
410
|
+
* 获取禁用状态
|
|
411
|
+
*
|
|
412
|
+
* 当为 `true` 时,标绘实例将停止响应交互和更新;
|
|
413
|
+
* 为 `false` 时恢复正常功能。
|
|
414
|
+
*/
|
|
415
|
+
get disabled() {
|
|
416
|
+
return this._disabled;
|
|
417
|
+
}
|
|
418
|
+
set disabled(value) {
|
|
419
|
+
this.disabled = value;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* @internal
|
|
423
|
+
*/
|
|
424
|
+
_sampled;
|
|
425
|
+
get sampled() {
|
|
426
|
+
return this._sampled;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @internal
|
|
430
|
+
*/
|
|
431
|
+
_entities;
|
|
432
|
+
get entities() {
|
|
433
|
+
return this._entities;
|
|
434
|
+
}
|
|
435
|
+
set entities(value) {
|
|
436
|
+
this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
|
|
437
|
+
this._entities = value;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @internal
|
|
441
|
+
*/
|
|
442
|
+
_primitives;
|
|
443
|
+
get primitives() {
|
|
444
|
+
return this._primitives;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
set primitives(value) {
|
|
450
|
+
this._definitionChanged.raiseEvent(this, "primitives", value, this._primitives);
|
|
451
|
+
this._primitives = value;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
_groundPrimitives;
|
|
457
|
+
get groundPrimitives() {
|
|
458
|
+
return this._groundPrimitives;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* @internal
|
|
462
|
+
*/
|
|
463
|
+
set groundPrimitives(value) {
|
|
464
|
+
this._definitionChanged.raiseEvent(this, "groundPrimitives", value, this._groundPrimitives);
|
|
465
|
+
this._groundPrimitives = value;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
_skeletons;
|
|
471
|
+
get skeletons() {
|
|
472
|
+
return this._skeletons;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
set skeletons(value) {
|
|
478
|
+
this._definitionChanged.raiseEvent(this, "skeletons", value, this._skeletons);
|
|
479
|
+
this._skeletons = value;
|
|
480
|
+
}
|
|
154
481
|
};
|
|
155
|
-
|
|
482
|
+
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region usePlot/PlotSkeleton.ts
|
|
156
485
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
var SampledPlotProperty = class SampledPlotProperty {
|
|
162
|
-
constructor(options) {
|
|
163
|
-
this.interpolationAlgorithm = options?.interpolationAlgorithm;
|
|
164
|
-
this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
|
|
165
|
-
options?.packables?.forEach((packable) => this.setSample(packable));
|
|
166
|
-
if (!this._times.length) this.setSample({
|
|
167
|
-
time: new cesium.JulianDate(0, 0),
|
|
168
|
-
positions: [],
|
|
169
|
-
derivative: void 0
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
|
|
173
|
-
strategy;
|
|
174
|
-
interpolationAlgorithm;
|
|
175
|
-
/**
|
|
176
|
-
* @internal
|
|
486
|
+
* 框架点执行状态枚举
|
|
487
|
+
* - IDLE 空闲状态
|
|
488
|
+
* - HOVER 悬停状态
|
|
489
|
+
* - ACTIVE 激活状态
|
|
177
490
|
*/
|
|
178
|
-
|
|
491
|
+
let PlotAction = /* @__PURE__ */ function(PlotAction$1) {
|
|
492
|
+
PlotAction$1[PlotAction$1["IDLE"] = 0] = "IDLE";
|
|
493
|
+
PlotAction$1[PlotAction$1["HOVER"] = 1] = "HOVER";
|
|
494
|
+
PlotAction$1[PlotAction$1["ACTIVE"] = 2] = "ACTIVE";
|
|
495
|
+
return PlotAction$1;
|
|
496
|
+
}({});
|
|
179
497
|
/**
|
|
180
|
-
*
|
|
498
|
+
* 标绘框架点 Entity
|
|
181
499
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
_derivatives = [];
|
|
187
|
-
get isConstant() {
|
|
188
|
-
return this._times.length === 0;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* @internal
|
|
192
|
-
*/
|
|
193
|
-
_definitionChanged = new cesium.Event();
|
|
194
|
-
get definitionChanged() {
|
|
195
|
-
return this._definitionChanged;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* 获取时间数组
|
|
199
|
-
*
|
|
200
|
-
* @returns 返回包含所有时间的 JulianDate 数组
|
|
201
|
-
*/
|
|
202
|
-
getTimes() {
|
|
203
|
-
return this._times.map((t) => t.clone());
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* 根据给定的儒略日期获取时间索引范围及比例
|
|
207
|
-
*
|
|
208
|
-
* @param time 给定的儒略日期
|
|
209
|
-
* @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
|
|
210
|
-
* @internal
|
|
211
|
-
*/
|
|
212
|
-
getIndexScope(time) {
|
|
213
|
-
if (!this._times.length) return;
|
|
214
|
-
const start = this._times[0];
|
|
215
|
-
const end = this._times[this._times.length - 1];
|
|
216
|
-
if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
|
|
217
|
-
case SampledPlotStrategy.STRICT: return;
|
|
218
|
-
case SampledPlotStrategy.NEAR: {
|
|
219
|
-
time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
case SampledPlotStrategy.CYCLE: {
|
|
223
|
-
const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
|
|
224
|
-
const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
|
|
225
|
-
const duration = endMS - startMS;
|
|
226
|
-
const timeMS = cesium.JulianDate.toDate(time).getTime();
|
|
227
|
-
const diff = (timeMS - startMS) % duration;
|
|
228
|
-
const dete = new Date(startMS + diff);
|
|
229
|
-
time = cesium.JulianDate.fromDate(dete);
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
500
|
+
var PlotSkeletonEntity = class extends cesium.Entity {
|
|
501
|
+
constructor(options) {
|
|
502
|
+
super(options);
|
|
232
503
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region usePlot/useRender.ts
|
|
508
|
+
function useRender(plots, current, getCurrentTime) {
|
|
509
|
+
const viewer = (0, vesium.useViewer)();
|
|
510
|
+
const primitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection());
|
|
511
|
+
const groundPrimitiveCollection = (0, vesium.usePrimitive)(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
512
|
+
const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
|
|
513
|
+
const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
|
|
514
|
+
const primitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => primitiveCollection.value });
|
|
515
|
+
const groundPrimitiveScope = (0, vesium.usePrimitiveScope)({ collection: () => groundPrimitiveCollection.value });
|
|
516
|
+
const mouseCartesian = (0, vue.shallowRef)();
|
|
517
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.MOUSE_MOVE, (event) => {
|
|
518
|
+
mouseCartesian.value = (0, vesium.canvasCoordToCartesian)(event?.endPosition, viewer.value.scene);
|
|
519
|
+
});
|
|
520
|
+
(0, __vueuse_core.watchArray)(plots, (_value, _oldValue, added, removed = []) => {
|
|
521
|
+
removed.forEach((plot) => {
|
|
522
|
+
entityScope.removeWhere((item) => plot.entities.includes(item));
|
|
523
|
+
primitiveScope.removeWhere((item) => plot.primitives.includes(item));
|
|
524
|
+
groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
|
|
525
|
+
});
|
|
526
|
+
added.forEach((plot) => {
|
|
527
|
+
plot.entities.forEach((item) => entityScope.add(item));
|
|
528
|
+
plot.primitives.forEach((item) => primitiveScope.add(item));
|
|
529
|
+
plot.groundPrimitives.forEach((item) => groundPrimitiveScope.add(item));
|
|
530
|
+
});
|
|
531
|
+
}, {
|
|
532
|
+
immediate: true,
|
|
533
|
+
flush: "post"
|
|
534
|
+
});
|
|
535
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (_scope, key, newValue, oldValue) => {
|
|
536
|
+
if (key === "entities") {
|
|
537
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
538
|
+
added.forEach((item) => entityScope.add(item));
|
|
539
|
+
removed.forEach((item) => entityScope.remove(item));
|
|
540
|
+
} else if (key === "primitives") {
|
|
541
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
542
|
+
added.forEach((item) => primitiveScope.add(item));
|
|
543
|
+
removed.forEach((item) => primitiveScope.remove(item));
|
|
544
|
+
} else if (key === "groundPrimitives") {
|
|
545
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
546
|
+
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
547
|
+
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
const update = async (plot) => {
|
|
551
|
+
await (0, vue.nextTick)();
|
|
552
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
553
|
+
const mouse = plot.defining ? mouseCartesian.value : void 0;
|
|
554
|
+
const result = await plot.scheme.render?.({
|
|
555
|
+
packable,
|
|
556
|
+
mouse,
|
|
557
|
+
defining: plot.defining,
|
|
558
|
+
previous: {
|
|
559
|
+
entities: plot.entities,
|
|
560
|
+
primitives: plot.primitives,
|
|
561
|
+
groundPrimitives: plot.groundPrimitives
|
|
562
|
+
},
|
|
563
|
+
getPositions() {
|
|
564
|
+
const points = packable.positions;
|
|
565
|
+
mouse && points.push(mouse);
|
|
566
|
+
return points;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
plot.entities = result?.entities ?? [];
|
|
570
|
+
plot.primitives = result?.primitives ?? [];
|
|
571
|
+
plot.groundPrimitives = result?.groundPrimitives ?? [];
|
|
572
|
+
};
|
|
573
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
574
|
+
previous && update(previous);
|
|
575
|
+
});
|
|
576
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((item) => item.definitionChanged), (plot, key) => {
|
|
577
|
+
if ([
|
|
578
|
+
"disabled",
|
|
579
|
+
"defining",
|
|
580
|
+
"scheme",
|
|
581
|
+
"sampled",
|
|
582
|
+
"time"
|
|
583
|
+
].includes(key)) update(plot);
|
|
584
|
+
});
|
|
585
|
+
(0, vue.watch)(mouseCartesian, () => {
|
|
586
|
+
plots.value.forEach((plot) => plot.defining && update(plot));
|
|
587
|
+
});
|
|
238
588
|
return {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
589
|
+
primitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
590
|
+
groundPrimitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
591
|
+
entities: (0, vue.computed)(() => Array.from(entityScope.scope))
|
|
242
592
|
};
|
|
243
593
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
getValue(time, result) {
|
|
253
|
-
result ??= { time };
|
|
254
|
-
Object.assign(result, {
|
|
255
|
-
time: time?.clone(),
|
|
256
|
-
positions: void 0,
|
|
257
|
-
derivative: void 0
|
|
594
|
+
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region usePlot/useSampled.ts
|
|
597
|
+
function useSampled(current, getCurrentTime) {
|
|
598
|
+
const viewer = (0, vesium.useViewer)();
|
|
599
|
+
const doubleClicking = (0, vue.ref)(false);
|
|
600
|
+
const packable = (0, vue.computed)(() => {
|
|
601
|
+
return current.value?.sampled.getValue(getCurrentTime());
|
|
258
602
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
603
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, async (ctx) => {
|
|
604
|
+
await (0, __vueuse_core.promiseTimeout)(1);
|
|
605
|
+
if (!current.value || !packable.value) return;
|
|
606
|
+
if (doubleClicking.value) return;
|
|
607
|
+
const { scheme, defining, sampled } = current.value;
|
|
608
|
+
if (!defining) return;
|
|
609
|
+
const position = (0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene);
|
|
610
|
+
if (!position) return;
|
|
611
|
+
packable.value.positions ??= [];
|
|
612
|
+
packable.value.positions.push(position);
|
|
613
|
+
sampled.setSample(packable.value);
|
|
614
|
+
scheme.complete?.(packable.value) && 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
|
+
if (!(0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene)) return;
|
|
624
|
+
scheme.allowManualComplete?.(packable.value) && PlotFeature.setDefining(current.value, false);
|
|
625
|
+
});
|
|
626
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.RIGHT_CLICK, async () => {
|
|
627
|
+
if (!current.value || !packable.value) return;
|
|
628
|
+
const { defining, sampled } = current.value;
|
|
629
|
+
if (!defining) return;
|
|
630
|
+
packable.value.positions ??= [];
|
|
631
|
+
if (packable.value.positions.length === 0) return;
|
|
632
|
+
packable.value.positions.splice(packable.value.positions.length - 1, 1);
|
|
633
|
+
sampled.setSample(packable.value);
|
|
634
|
+
});
|
|
635
|
+
const definingCursorCss = (0, vue.ref)();
|
|
636
|
+
const setDefiningCursorCss = () => {
|
|
637
|
+
if (!current.value?.defining) {
|
|
638
|
+
if (definingCursorCss.value) {
|
|
639
|
+
definingCursorCss.value = void 0;
|
|
640
|
+
viewer.value.container.parentElement.style.removeProperty("cursor");
|
|
641
|
+
}
|
|
642
|
+
} else {
|
|
643
|
+
const definingCursor = current.value.scheme.definingCursor;
|
|
644
|
+
definingCursorCss.value = (0, vesium.isFunction)(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
645
|
+
if (definingCursorCss.value) viewer.value?.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
646
|
+
}
|
|
278
647
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* 设置样本数据,如果传入的数据不含时间,则会存入时间最早的集合中
|
|
285
|
-
* @param value 样本数据对象,包含时间、位置和导数信息
|
|
286
|
-
*/
|
|
287
|
-
setSample(value) {
|
|
288
|
-
const time = value.time?.clone() ?? this._times[0].clone();
|
|
289
|
-
const positions = value.positions?.map((item) => item.clone()) ?? [];
|
|
290
|
-
const derivative = value.derivative;
|
|
291
|
-
const index = this._times.findIndex((t) => cesium.JulianDate.equals(time, t));
|
|
292
|
-
if (index !== -1) {
|
|
293
|
-
this._times[index] = time;
|
|
294
|
-
this._sampleds[index] = positions;
|
|
295
|
-
this._derivatives[index] = value.derivative;
|
|
296
|
-
} else if (this._times.length === 0) {
|
|
297
|
-
this._times[0] = time;
|
|
298
|
-
this._sampleds[0] = positions;
|
|
299
|
-
this._derivatives[0] = value.derivative;
|
|
300
|
-
} else if (cesium.JulianDate.lessThan(time, this._times[0])) {
|
|
301
|
-
this._times.splice(0, 0, time);
|
|
302
|
-
this._sampleds.splice(0, 0, positions);
|
|
303
|
-
this._derivatives.splice(0, 0, derivative);
|
|
304
|
-
} else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
|
|
305
|
-
this._times.push(time);
|
|
306
|
-
this._sampleds.push(positions);
|
|
307
|
-
this._derivatives.push(derivative);
|
|
308
|
-
}
|
|
309
|
-
this.definitionChanged.raiseEvent(this);
|
|
648
|
+
(0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
|
|
649
|
+
if (key === "defining" || key === "sampled") setDefiningCursorCss();
|
|
650
|
+
});
|
|
651
|
+
(0, vue.watch)(current, () => setDefiningCursorCss());
|
|
310
652
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
653
|
+
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region usePlot/useSkeleton.ts
|
|
656
|
+
function useSkeleton(plots, current, getCurrentTime) {
|
|
657
|
+
const viewer = (0, vesium.useViewer)();
|
|
658
|
+
const dataSource = (0, vesium.useDataSource)(new cesium.CustomDataSource());
|
|
659
|
+
const entityScope = (0, vesium.useEntityScope)({ collection: () => dataSource.value.entities });
|
|
660
|
+
const hoverEntity = (0, vue.shallowRef)();
|
|
661
|
+
const activeEntity = (0, vue.shallowRef)();
|
|
662
|
+
const getPointAction = (entity) => {
|
|
663
|
+
if (!entity) return PlotAction.IDLE;
|
|
664
|
+
return activeEntity.value?.id === entity.id ? PlotAction.ACTIVE : hoverEntity.value?.id === entity.id ? PlotAction.HOVER : PlotAction.IDLE;
|
|
665
|
+
};
|
|
666
|
+
const update = (plot, destroyed) => {
|
|
667
|
+
const oldEntities = plot.skeletons;
|
|
668
|
+
const entities = [];
|
|
669
|
+
if (destroyed || plot.disabled) plot.skeletons = [];
|
|
670
|
+
else {
|
|
671
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
672
|
+
const defining = plot.defining;
|
|
673
|
+
const active = current.value === plot;
|
|
674
|
+
plot.scheme.skeletons.forEach((skeleton) => {
|
|
675
|
+
if ((0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
|
|
676
|
+
active,
|
|
677
|
+
defining
|
|
678
|
+
}) : skeleton.disabled) return;
|
|
679
|
+
const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
|
|
680
|
+
positions.forEach((position, index) => {
|
|
681
|
+
let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
|
|
682
|
+
const options = skeleton.render?.({
|
|
683
|
+
defining,
|
|
684
|
+
active,
|
|
685
|
+
index,
|
|
686
|
+
packable,
|
|
687
|
+
positions,
|
|
688
|
+
position,
|
|
689
|
+
action: getPointAction(entity)
|
|
690
|
+
});
|
|
691
|
+
const merge = new PlotSkeletonEntity(options ?? {});
|
|
692
|
+
if (entity) merge.propertyNames.forEach((key) => {
|
|
693
|
+
if (key !== "id") entity[key] = merge[key];
|
|
694
|
+
});
|
|
695
|
+
else entity = merge;
|
|
696
|
+
entity.plot = plot;
|
|
697
|
+
entity.skeleton = skeleton;
|
|
698
|
+
entity.index = index;
|
|
699
|
+
entities.push(entity);
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
plot.skeletons = entities;
|
|
704
|
+
};
|
|
705
|
+
const graphicEvent = (0, vesium.useGraphicEvent)();
|
|
706
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
707
|
+
onCleanup(graphicEvent.add("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
708
|
+
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
709
|
+
const entity = pick.id;
|
|
710
|
+
const plot = entity.plot;
|
|
711
|
+
if (plot.defining) return;
|
|
712
|
+
activeEntity.value = entity;
|
|
713
|
+
const skeleton = entity.skeleton;
|
|
714
|
+
const index = entity.index;
|
|
715
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
716
|
+
skeleton.onDrag?.({
|
|
717
|
+
viewer: viewer.value,
|
|
718
|
+
sampled: plot.sampled,
|
|
719
|
+
packable,
|
|
720
|
+
active: current.value === plot,
|
|
721
|
+
index,
|
|
722
|
+
event,
|
|
723
|
+
dragging,
|
|
724
|
+
lockCamera
|
|
725
|
+
});
|
|
726
|
+
} else activeEntity.value = void 0;
|
|
727
|
+
}, {
|
|
728
|
+
cursor: ({ pick }) => {
|
|
729
|
+
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
730
|
+
const skeleton = pick.id.skeleton;
|
|
731
|
+
return (0, vesium.isFunction)(skeleton?.cursor) ? skeleton.cursor(pick) : (0, vue.toValue)(skeleton?.cursor);
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
dragCursor: ({ pick }) => {
|
|
735
|
+
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
736
|
+
const skeleton = pick.id.skeleton;
|
|
737
|
+
return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}));
|
|
741
|
+
});
|
|
742
|
+
(0, __vueuse_core.onKeyStroke)((keyEvent) => {
|
|
743
|
+
if (activeEntity.value) {
|
|
744
|
+
const entity = activeEntity.value;
|
|
745
|
+
const plot = entity.plot;
|
|
746
|
+
const skeleton = entity.skeleton;
|
|
747
|
+
const index = entity.index;
|
|
748
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
749
|
+
skeleton.onKeyPressed?.({
|
|
750
|
+
viewer: viewer.value,
|
|
751
|
+
sampled: plot.sampled,
|
|
752
|
+
packable,
|
|
753
|
+
index,
|
|
754
|
+
keyEvent
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
759
|
+
onCleanup(graphicEvent.add("global", "HOVER", ({ hovering, pick }) => {
|
|
760
|
+
if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) hoverEntity.value = pick.id;
|
|
761
|
+
else hoverEntity.value = void 0;
|
|
762
|
+
}));
|
|
763
|
+
});
|
|
764
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
765
|
+
onCleanup(graphicEvent.add("global", "LEFT_CLICK", ({ event, pick }) => {
|
|
766
|
+
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
767
|
+
const entity = pick.id;
|
|
768
|
+
activeEntity.value = entity;
|
|
769
|
+
const plot = entity.plot;
|
|
770
|
+
const skeleton = entity.skeleton;
|
|
771
|
+
const index = entity.index;
|
|
772
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
773
|
+
skeleton.onLeftClick?.({
|
|
774
|
+
viewer: viewer.value,
|
|
775
|
+
sampled: plot.sampled,
|
|
776
|
+
packable,
|
|
777
|
+
active: current.value === plot,
|
|
778
|
+
defining: plot.defining,
|
|
779
|
+
index,
|
|
780
|
+
event
|
|
781
|
+
});
|
|
782
|
+
} else activeEntity.value = void 0;
|
|
783
|
+
}));
|
|
784
|
+
});
|
|
785
|
+
(0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
|
|
786
|
+
added.forEach((plot) => update(plot));
|
|
787
|
+
removed.forEach((plot) => update(plot, true));
|
|
788
|
+
});
|
|
789
|
+
(0, vesium.useCesiumEventListener)(() => plots.value.map((plot) => plot.definitionChanged), (plot, key, newValue, oldValue) => {
|
|
790
|
+
if ([
|
|
791
|
+
"disabled",
|
|
792
|
+
"defining",
|
|
793
|
+
"scheme",
|
|
794
|
+
"sampled",
|
|
795
|
+
"time"
|
|
796
|
+
].includes(key)) (0, vue.nextTick)(() => update(plot));
|
|
797
|
+
else if (key === "skeletons") {
|
|
798
|
+
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
799
|
+
added.forEach((item) => entityScope.add(item));
|
|
800
|
+
removed.forEach((item) => entityScope.remove(item));
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
804
|
+
plot && update(plot);
|
|
805
|
+
previous && update(previous);
|
|
806
|
+
});
|
|
807
|
+
return { dataSource };
|
|
318
808
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
809
|
+
|
|
810
|
+
//#endregion
|
|
811
|
+
//#region usePlot/usePlot.ts
|
|
812
|
+
function usePlot(options) {
|
|
813
|
+
const time = options?.time || (0, vue.shallowRef)();
|
|
814
|
+
const viewer = (0, vesium.useViewer)();
|
|
815
|
+
const getCurrentTime = () => {
|
|
816
|
+
return time.value?.clone() || new cesium.JulianDate(0, 0);
|
|
817
|
+
};
|
|
818
|
+
const collection = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
819
|
+
const plots = (0, vue.computed)(() => Array.from(collection));
|
|
820
|
+
const current = (0, vue.shallowRef)();
|
|
821
|
+
const packable = (0, vue.shallowRef)();
|
|
822
|
+
(0, vesium.useCesiumEventListener)([() => current.value?.sampled.definitionChanged], () => {
|
|
823
|
+
packable.value = current.value?.sampled.getValue(getCurrentTime());
|
|
824
|
+
});
|
|
825
|
+
useSampled(current, getCurrentTime);
|
|
826
|
+
useRender(plots, current, getCurrentTime);
|
|
827
|
+
useSkeleton(plots, current, getCurrentTime);
|
|
828
|
+
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
829
|
+
if (current.value?.defining) return;
|
|
830
|
+
const pick = viewer.value?.scene.pick(data.position.clone());
|
|
831
|
+
if (pick?.id?.plot instanceof PlotFeature) return;
|
|
832
|
+
if (!pick) {
|
|
833
|
+
current.value = void 0;
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
|
|
837
|
+
...plot.entities,
|
|
838
|
+
...plot.primitives,
|
|
839
|
+
...plot.groundPrimitives
|
|
840
|
+
]));
|
|
841
|
+
});
|
|
842
|
+
let operateResolve;
|
|
843
|
+
let operateReject;
|
|
844
|
+
(0, vue.watch)(current, (plot, previous) => {
|
|
845
|
+
if (previous) {
|
|
846
|
+
if (previous.defining) {
|
|
847
|
+
const packable$1 = previous.sampled.getValue(getCurrentTime());
|
|
848
|
+
if (previous.scheme.allowManualComplete?.(packable$1)) {
|
|
849
|
+
PlotFeature.setDefining(previous, false);
|
|
850
|
+
operateResolve?.(previous);
|
|
851
|
+
} else collection.delete(previous);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
const operate = async (plot) => {
|
|
856
|
+
return new Promise((resolve, reject) => {
|
|
857
|
+
operateResolve = resolve;
|
|
858
|
+
operateReject = reject;
|
|
859
|
+
const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
|
|
860
|
+
if (!collection.has(_plot)) collection.add(_plot);
|
|
861
|
+
current.value = _plot;
|
|
862
|
+
return resolve(_plot);
|
|
863
|
+
});
|
|
864
|
+
};
|
|
865
|
+
const remove = (plot) => {
|
|
866
|
+
if (plot === current.value) current.value = void 0;
|
|
867
|
+
if (collection.has(plot)) {
|
|
868
|
+
collection.delete(plot);
|
|
333
869
|
return true;
|
|
334
870
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
for (let i = 0; i < this._times.length; i++) {
|
|
345
|
-
const time = this._times[i];
|
|
346
|
-
cesium.TimeInterval.contains(interval$1, time) && this.removeSample(time);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* 判断两个property是否相等
|
|
351
|
-
*/
|
|
352
|
-
equals(other) {
|
|
353
|
-
return other === this;
|
|
871
|
+
return false;
|
|
872
|
+
};
|
|
873
|
+
return {
|
|
874
|
+
plots,
|
|
875
|
+
time,
|
|
876
|
+
operate,
|
|
877
|
+
remove,
|
|
878
|
+
cancel: operateReject
|
|
879
|
+
};
|
|
354
880
|
}
|
|
355
|
-
};
|
|
356
881
|
|
|
357
882
|
//#endregion
|
|
358
|
-
//#region
|
|
883
|
+
//#region skeleton/control.ts
|
|
359
884
|
/**
|
|
360
|
-
*
|
|
361
|
-
*/
|
|
362
|
-
var PlotFeature = class {
|
|
363
|
-
constructor(options) {
|
|
364
|
-
const { id, disabled = false, sampled } = options;
|
|
365
|
-
this._id = id || (0, cesium.createGuid)();
|
|
366
|
-
this._scheme = PlotScheme.resolve(options.scheme);
|
|
367
|
-
this._definitionChanged = new cesium.Event();
|
|
368
|
-
this._defining = true;
|
|
369
|
-
this._disabled = disabled;
|
|
370
|
-
this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
|
|
371
|
-
this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
|
|
372
|
-
this._entities = [...this._scheme.initEntites?.() ?? []];
|
|
373
|
-
this._primitives = [...this._scheme.initPrimitives?.() ?? []];
|
|
374
|
-
this._groundPrimitives = [...this._scheme.initGroundPrimitives?.() ?? []];
|
|
375
|
-
this._skeletons = [];
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* @internal
|
|
885
|
+
* 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
|
|
379
886
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
887
|
+
function control() {
|
|
888
|
+
return {
|
|
889
|
+
disabled: ({ active }) => !active,
|
|
890
|
+
cursor: "pointer",
|
|
891
|
+
dragCursor: "crosshair",
|
|
892
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
893
|
+
lockCamera();
|
|
894
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
895
|
+
if (position) {
|
|
896
|
+
const positions = [...packable.positions ?? []];
|
|
897
|
+
positions[index] = position;
|
|
898
|
+
sampled.setSample({
|
|
899
|
+
time: packable.time,
|
|
900
|
+
derivative: packable.derivative,
|
|
901
|
+
positions
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
|
|
906
|
+
const height = (0, vesium.toCartographic)(viewer.camera.position)?.height;
|
|
907
|
+
if (!height || ![
|
|
908
|
+
"ArrowUp",
|
|
909
|
+
"ArrowRight",
|
|
910
|
+
"ArrowDown",
|
|
911
|
+
"ArrowLeft"
|
|
912
|
+
].includes(keyEvent.key)) return;
|
|
913
|
+
keyEvent.preventDefault();
|
|
914
|
+
let headingAdjust = 0;
|
|
915
|
+
switch (keyEvent.key) {
|
|
916
|
+
case "ArrowRight":
|
|
917
|
+
headingAdjust = Math.PI / 2;
|
|
918
|
+
break;
|
|
919
|
+
case "ArrowDown":
|
|
920
|
+
headingAdjust = Math.PI;
|
|
921
|
+
break;
|
|
922
|
+
case "ArrowLeft":
|
|
923
|
+
headingAdjust = -Math.PI / 2;
|
|
924
|
+
break;
|
|
925
|
+
case "ArrowUp":
|
|
926
|
+
headingAdjust = 0;
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
930
|
+
const positions = [...packable.positions ?? []];
|
|
931
|
+
const cartographic = (0, vesium.toCartographic)(positions[index]);
|
|
932
|
+
const distance$1 = height / 1e5 * Math.PI / 180 / 1e3;
|
|
933
|
+
cartographic.latitude += distance$1 * Math.cos(newHeading);
|
|
934
|
+
cartographic.longitude += distance$1 * Math.sin(newHeading);
|
|
935
|
+
positions[index] = (0, vesium.toCartesian3)(cartographic);
|
|
936
|
+
sampled.setSample({
|
|
937
|
+
time: packable.time,
|
|
938
|
+
derivative: packable.derivative,
|
|
939
|
+
positions
|
|
940
|
+
});
|
|
941
|
+
},
|
|
942
|
+
render: ({ position, action }) => {
|
|
943
|
+
return {
|
|
944
|
+
position,
|
|
945
|
+
point: {
|
|
946
|
+
pixelSize: 8,
|
|
947
|
+
color: {
|
|
948
|
+
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
949
|
+
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
950
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
951
|
+
}[action],
|
|
952
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
953
|
+
outlineWidth: 1,
|
|
954
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
};
|
|
383
959
|
}
|
|
384
|
-
|
|
385
|
-
|
|
960
|
+
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region skeleton/interval.ts
|
|
963
|
+
/**
|
|
964
|
+
* 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
386
965
|
*/
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return
|
|
966
|
+
function interval() {
|
|
967
|
+
let dragIndex = -1;
|
|
968
|
+
return {
|
|
969
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
970
|
+
cursor: "pointer",
|
|
971
|
+
dragCursor: "crosshair",
|
|
972
|
+
format(packable) {
|
|
973
|
+
const _positions = packable.positions ?? [];
|
|
974
|
+
if (_positions.length < 2) return [];
|
|
975
|
+
return _positions.map((position, i) => {
|
|
976
|
+
const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
|
|
977
|
+
return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
|
|
978
|
+
});
|
|
979
|
+
},
|
|
980
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
981
|
+
lockCamera();
|
|
982
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
983
|
+
if (!position) return;
|
|
984
|
+
const positions = [...packable.positions ?? []];
|
|
985
|
+
if (dragIndex === -1) {
|
|
986
|
+
dragIndex = index;
|
|
987
|
+
positions.splice(index + 1, 0, position);
|
|
988
|
+
} else positions[dragIndex + 1] = position;
|
|
989
|
+
if (!dragging) dragIndex = -1;
|
|
990
|
+
sampled.setSample({
|
|
991
|
+
time: packable.time,
|
|
992
|
+
derivative: packable.derivative,
|
|
993
|
+
positions
|
|
994
|
+
});
|
|
995
|
+
},
|
|
996
|
+
render: ({ position, action, active }) => {
|
|
997
|
+
if (!active) return;
|
|
998
|
+
return {
|
|
999
|
+
position,
|
|
1000
|
+
point: {
|
|
1001
|
+
pixelSize: 6,
|
|
1002
|
+
color: {
|
|
1003
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1004
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1005
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1006
|
+
}[action],
|
|
1007
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1008
|
+
outlineWidth: 1,
|
|
1009
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
390
1014
|
}
|
|
391
|
-
|
|
392
|
-
|
|
1015
|
+
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region skeleton/intervalNonclosed.ts
|
|
1018
|
+
/**
|
|
1019
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
393
1020
|
*/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return
|
|
1021
|
+
function intervalNonclosed() {
|
|
1022
|
+
let dragIndex = -1;
|
|
1023
|
+
return {
|
|
1024
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
1025
|
+
cursor: "pointer",
|
|
1026
|
+
dragCursor: "crosshair",
|
|
1027
|
+
format(packable) {
|
|
1028
|
+
const _positions = packable.positions ?? [];
|
|
1029
|
+
if (_positions.length < 2) return [];
|
|
1030
|
+
const midpoints = [];
|
|
1031
|
+
for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
|
|
1032
|
+
return midpoints;
|
|
1033
|
+
},
|
|
1034
|
+
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1035
|
+
lockCamera();
|
|
1036
|
+
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1037
|
+
if (!position) return;
|
|
1038
|
+
const positions = [...packable.positions ?? []];
|
|
1039
|
+
if (dragIndex === -1) {
|
|
1040
|
+
dragIndex = index;
|
|
1041
|
+
positions.splice(index + 1, 0, position);
|
|
1042
|
+
} else positions[dragIndex + 1] = position;
|
|
1043
|
+
if (!dragging) dragIndex = -1;
|
|
1044
|
+
sampled.setSample({
|
|
1045
|
+
time: packable.time,
|
|
1046
|
+
derivative: packable.derivative,
|
|
1047
|
+
positions
|
|
1048
|
+
});
|
|
1049
|
+
},
|
|
1050
|
+
render: ({ position, action }) => {
|
|
1051
|
+
return {
|
|
1052
|
+
position,
|
|
1053
|
+
point: {
|
|
1054
|
+
pixelSize: 6,
|
|
1055
|
+
color: {
|
|
1056
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1057
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1058
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1059
|
+
}[action],
|
|
1060
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1061
|
+
outlineWidth: 1,
|
|
1062
|
+
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
397
1067
|
}
|
|
1068
|
+
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region skeleton/moved.ts
|
|
1071
|
+
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>")}`;
|
|
398
1072
|
/**
|
|
399
|
-
*
|
|
1073
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
400
1074
|
*/
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
1075
|
+
function moved() {
|
|
1076
|
+
return {
|
|
1077
|
+
disabled: ({ active, defining }) => !active || defining,
|
|
1078
|
+
cursor: "pointer",
|
|
1079
|
+
dragCursor: "crosshair",
|
|
1080
|
+
format(packable) {
|
|
1081
|
+
const positions = packable.positions ?? [];
|
|
1082
|
+
if (positions.length === 0) return [];
|
|
1083
|
+
else if (positions.length === 1) return [positions[0]];
|
|
1084
|
+
else return [(0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions)))];
|
|
1085
|
+
},
|
|
1086
|
+
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1087
|
+
dragging && lockCamera();
|
|
1088
|
+
const startPosition = (0, vesium.canvasCoordToCartesian)(event.startPosition, viewer.scene);
|
|
1089
|
+
const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1090
|
+
if (!startPosition || !endPosition) return;
|
|
1091
|
+
const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
|
|
1092
|
+
const positions = [...packable.positions ?? []];
|
|
1093
|
+
sampled.setSample({
|
|
1094
|
+
time: packable.time,
|
|
1095
|
+
derivative: packable.derivative,
|
|
1096
|
+
positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
|
|
1097
|
+
});
|
|
1098
|
+
},
|
|
1099
|
+
render: ({ position, action }) => {
|
|
1100
|
+
return {
|
|
1101
|
+
position,
|
|
1102
|
+
billboard: {
|
|
1103
|
+
image: svg,
|
|
1104
|
+
width: 20,
|
|
1105
|
+
height: 20,
|
|
1106
|
+
color: {
|
|
1107
|
+
[PlotAction.IDLE]: cesium.Color.WHITE,
|
|
1108
|
+
[PlotAction.HOVER]: cesium.Color.WHITE,
|
|
1109
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
1110
|
+
}[action],
|
|
1111
|
+
pixelOffset: new cesium.Cartesian3(0, -20),
|
|
1112
|
+
horizontalOrigin: cesium.HorizontalOrigin.CENTER,
|
|
1113
|
+
verticalOrigin: cesium.VerticalOrigin.BOTTOM,
|
|
1114
|
+
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
404
1119
|
}
|
|
405
|
-
|
|
406
|
-
|
|
1120
|
+
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region measure/utils/tesselate.ts
|
|
1123
|
+
/**
|
|
1124
|
+
* 将多个边界点组成的面切割成多个三角形
|
|
1125
|
+
* @param positions
|
|
407
1126
|
*/
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
|
|
411
|
-
|
|
1127
|
+
function tesselate(positions) {
|
|
1128
|
+
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1129
|
+
if (positions.length === 3) return [[
|
|
1130
|
+
positions[0].clone(),
|
|
1131
|
+
positions[1].clone(),
|
|
1132
|
+
positions[2].clone()
|
|
1133
|
+
]];
|
|
1134
|
+
const geometry = cesium.CoplanarPolygonGeometry.createGeometry(cesium.CoplanarPolygonGeometry.fromPositions({
|
|
1135
|
+
positions,
|
|
1136
|
+
vertexFormat: cesium.VertexFormat.POSITION_ONLY
|
|
1137
|
+
}));
|
|
1138
|
+
if (!geometry) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1139
|
+
const values = geometry.attributes.position.values;
|
|
1140
|
+
const indices = geometry.indices;
|
|
1141
|
+
const result = [];
|
|
1142
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
1143
|
+
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1144
|
+
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1145
|
+
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1146
|
+
result.push([
|
|
1147
|
+
a,
|
|
1148
|
+
b,
|
|
1149
|
+
c
|
|
1150
|
+
]);
|
|
412
1151
|
}
|
|
1152
|
+
return result;
|
|
413
1153
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* 当为 `true` 时,标绘实例将停止响应交互和更新;
|
|
422
|
-
* 为 `false` 时恢复正常功能。
|
|
423
|
-
*/
|
|
424
|
-
get disabled() {
|
|
425
|
-
return this._disabled;
|
|
426
|
-
}
|
|
427
|
-
set disabled(value) {
|
|
428
|
-
this.disabled = value;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @internal
|
|
432
|
-
*/
|
|
433
|
-
_sampled;
|
|
434
|
-
get sampled() {
|
|
435
|
-
return this._sampled;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* @internal
|
|
439
|
-
*/
|
|
440
|
-
_entities;
|
|
441
|
-
get entities() {
|
|
442
|
-
return this._entities;
|
|
443
|
-
}
|
|
444
|
-
set entities(value) {
|
|
445
|
-
this._definitionChanged.raiseEvent(this, "entities", value, this._entities);
|
|
446
|
-
this._entities = value;
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* @internal
|
|
1154
|
+
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region measure/utils/clampToGround.ts
|
|
1157
|
+
/**
|
|
1158
|
+
* 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
|
|
1159
|
+
* @param options - 配置项
|
|
450
1160
|
*/
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
1161
|
+
async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
|
|
1162
|
+
const { positions, scene, classificationType = cesium.ClassificationType.BOTH, terrainProvider = scene.terrainProvider } = options;
|
|
1163
|
+
const tileset = [cesium.ClassificationType.BOTH, cesium.ClassificationType.CESIUM_3D_TILE].includes(classificationType);
|
|
1164
|
+
const terrain = [cesium.ClassificationType.BOTH, cesium.ClassificationType.TERRAIN].includes(classificationType);
|
|
1165
|
+
const tilesetPromise = new Promise((resolve) => {
|
|
1166
|
+
if (tileset) scene.clampToHeightMostDetailed(positions.map((e) => e.clone())).then(resolve).catch((error) => {
|
|
1167
|
+
console.warn(error);
|
|
1168
|
+
resolve([]);
|
|
1169
|
+
});
|
|
1170
|
+
else resolve([]);
|
|
1171
|
+
});
|
|
1172
|
+
const terrainPromise = new Promise((resolve) => {
|
|
1173
|
+
if (terrain && terrainProvider) (0, cesium.sampleTerrainMostDetailed)(terrainProvider, positions.map((e) => cesium.Cartographic.fromCartesian(e))).then((e) => resolve(e)).catch((error) => {
|
|
1174
|
+
console.warn(error);
|
|
1175
|
+
resolve([]);
|
|
1176
|
+
});
|
|
1177
|
+
else resolve([]);
|
|
1178
|
+
});
|
|
1179
|
+
const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
|
|
1180
|
+
const results = [];
|
|
1181
|
+
positions.forEach((item, index) => {
|
|
1182
|
+
const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
|
|
1183
|
+
results.push(position);
|
|
1184
|
+
});
|
|
1185
|
+
return results;
|
|
454
1186
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
1187
|
+
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region measure/utils/triangleGrid.ts
|
|
1190
|
+
function defaultOptions$2(original) {
|
|
1191
|
+
const clampToGround = original?.clampToGround ?? false;
|
|
1192
|
+
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1193
|
+
const density = Math.floor(original?.density ?? 10);
|
|
1194
|
+
return {
|
|
1195
|
+
scene: original?.scene,
|
|
1196
|
+
clampToGround,
|
|
1197
|
+
classificationType,
|
|
1198
|
+
terrainProvider: original?.terrainProvider,
|
|
1199
|
+
density
|
|
1200
|
+
};
|
|
461
1201
|
}
|
|
462
1202
|
/**
|
|
463
|
-
*
|
|
1203
|
+
* 生成三角网数组
|
|
1204
|
+
* @param positions - 边界点数组
|
|
1205
|
+
* @param options - 配置项
|
|
464
1206
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
1207
|
+
async function triangleGrid(positions, options) {
|
|
1208
|
+
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1209
|
+
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$2(options);
|
|
1210
|
+
if (density <= 0) throw new Error("options.density must > 0");
|
|
1211
|
+
const bbox = cesium.Rectangle.fromCartesianArray(positions);
|
|
1212
|
+
const vertical = bbox.north - bbox.south;
|
|
1213
|
+
const horizontal = bbox.east - bbox.west;
|
|
1214
|
+
const granularity = Math.max(horizontal, vertical) / density;
|
|
1215
|
+
const polygonGeometry = cesium.PolygonGeometry.fromPositions({
|
|
1216
|
+
positions,
|
|
1217
|
+
vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
1218
|
+
granularity
|
|
1219
|
+
});
|
|
1220
|
+
const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
|
|
1221
|
+
const values = geometry.attributes.position.values;
|
|
1222
|
+
if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1223
|
+
const indices = geometry.indices;
|
|
1224
|
+
let cartesian3List = [];
|
|
1225
|
+
for (let i = 0; i < indices.length; i += 3) {
|
|
1226
|
+
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1227
|
+
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1228
|
+
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1229
|
+
cartesian3List.push(a, b, c);
|
|
1230
|
+
}
|
|
1231
|
+
if (clampToGround) {
|
|
1232
|
+
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1233
|
+
cartesian3List = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1234
|
+
scene,
|
|
1235
|
+
terrainProvider,
|
|
1236
|
+
positions: cartesian3List,
|
|
1237
|
+
classificationType
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
const grid = [];
|
|
1241
|
+
while (cartesian3List?.length) {
|
|
1242
|
+
const [a, b, c] = cartesian3List.splice(0, 3);
|
|
1243
|
+
grid.push([
|
|
1244
|
+
a,
|
|
1245
|
+
b,
|
|
1246
|
+
c
|
|
1247
|
+
]);
|
|
1248
|
+
}
|
|
1249
|
+
return grid;
|
|
468
1250
|
}
|
|
469
|
-
|
|
470
|
-
|
|
1251
|
+
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region measure/utils/area.ts
|
|
1254
|
+
/**
|
|
1255
|
+
* 计算三维坐标系下三角形面积
|
|
1256
|
+
* @param p0 - 三角形第一个点
|
|
1257
|
+
* @param p1 - 三角形第二个点
|
|
1258
|
+
* @param p2 - 三角形第三个点
|
|
471
1259
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
1260
|
+
function triangleArea(p0, p1, p2) {
|
|
1261
|
+
const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
|
|
1262
|
+
const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
|
|
1263
|
+
const cross = cesium.Cartesian3.cross(v0, v1, v0);
|
|
1264
|
+
return cesium.Cartesian3.magnitude(cross) * .5;
|
|
475
1265
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
1266
|
+
function defaultOptions$1(original) {
|
|
1267
|
+
const clampToGround = original?.clampToGround ?? false;
|
|
1268
|
+
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1269
|
+
const density = Math.floor(original?.density ?? 10);
|
|
1270
|
+
return {
|
|
1271
|
+
scene: original?.scene,
|
|
1272
|
+
clampToGround,
|
|
1273
|
+
classificationType,
|
|
1274
|
+
terrainProvider: original?.terrainProvider,
|
|
1275
|
+
density
|
|
1276
|
+
};
|
|
482
1277
|
}
|
|
483
1278
|
/**
|
|
484
|
-
*
|
|
1279
|
+
* 计算三维坐标系下图形面积
|
|
1280
|
+
* @param positions - 图形各点的笛卡尔数组
|
|
485
1281
|
*/
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
1282
|
+
async function area(positions, options) {
|
|
1283
|
+
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1284
|
+
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
|
|
1285
|
+
if (density <= 0) throw new Error("options.density must > 0");
|
|
1286
|
+
if (!clampToGround) return tesselate(positions).reduce((count, current) => count += triangleArea(...current), 0);
|
|
1287
|
+
return (await triangleGrid(positions, {
|
|
1288
|
+
density,
|
|
1289
|
+
scene,
|
|
1290
|
+
clampToGround,
|
|
1291
|
+
classificationType,
|
|
1292
|
+
terrainProvider
|
|
1293
|
+
})).reduce((count, current) => count += triangleArea(...current), 0);
|
|
489
1294
|
}
|
|
490
|
-
};
|
|
491
1295
|
|
|
492
1296
|
//#endregion
|
|
493
|
-
//#region
|
|
1297
|
+
//#region measure/utils/lerpArray.ts
|
|
494
1298
|
/**
|
|
495
|
-
*
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
let
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
1299
|
+
* 在起点和终点间进行插值, 返回的数组包括起点和终点,数组长度为 count+1
|
|
1300
|
+
*/
|
|
1301
|
+
async function lerpArray(options) {
|
|
1302
|
+
const { start, end, count, scene, clampToGround, classificationType, terrainProvider } = options;
|
|
1303
|
+
const result = [];
|
|
1304
|
+
for (let i = 0; i < count; i++) {
|
|
1305
|
+
const position = cesium.Cartesian3.lerp(start, end, 1 / count, new cesium.Cartesian3());
|
|
1306
|
+
result.push(position);
|
|
1307
|
+
}
|
|
1308
|
+
result.push(end.clone());
|
|
1309
|
+
if (!clampToGround) return result;
|
|
1310
|
+
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1311
|
+
return await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1312
|
+
scene,
|
|
1313
|
+
terrainProvider,
|
|
1314
|
+
positions: result,
|
|
1315
|
+
classificationType
|
|
1316
|
+
});
|
|
512
1317
|
}
|
|
513
|
-
};
|
|
514
1318
|
|
|
515
1319
|
//#endregion
|
|
516
|
-
//#region
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
1320
|
+
//#region measure/utils/distance.ts
|
|
1321
|
+
function defaultOptions(original) {
|
|
1322
|
+
const clampToGround = original?.clampToGround ?? false;
|
|
1323
|
+
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1324
|
+
const density = Math.floor(original?.density ?? 50);
|
|
1325
|
+
return {
|
|
1326
|
+
scene: original?.scene,
|
|
1327
|
+
clampToGround,
|
|
1328
|
+
classificationType,
|
|
1329
|
+
terrainProvider: original?.terrainProvider,
|
|
1330
|
+
density
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* 计算多点位之间的距离
|
|
1335
|
+
* @param positions
|
|
1336
|
+
*/
|
|
1337
|
+
async function distance(positions, options) {
|
|
1338
|
+
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1339
|
+
const _options = defaultOptions(options);
|
|
1340
|
+
const stages = [];
|
|
1341
|
+
let count = 0;
|
|
1342
|
+
positions.forEach((position, index) => {
|
|
1343
|
+
if (index !== positions.length - 1) {
|
|
1344
|
+
const next = positions[index + 1];
|
|
1345
|
+
const distance$1 = cesium.Cartesian3.distance(position, next);
|
|
1346
|
+
stages.push(distance$1);
|
|
1347
|
+
count += distance$1;
|
|
1348
|
+
}
|
|
534
1349
|
});
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
1350
|
+
if (!_options.clampToGround) return {
|
|
1351
|
+
stages,
|
|
1352
|
+
count
|
|
1353
|
+
};
|
|
1354
|
+
const density = _options.density;
|
|
1355
|
+
if (density <= 0) throw new Error("options.density must > 0");
|
|
1356
|
+
const densities = stages.map((stage) => {
|
|
1357
|
+
return Math.floor(stage / count * density);
|
|
539
1358
|
});
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
removed.forEach((item) => primitiveScope.remove(item));
|
|
553
|
-
} else if (key === "groundPrimitives") {
|
|
554
|
-
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
555
|
-
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
556
|
-
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
const update = async (plot) => {
|
|
560
|
-
const reslut = await plot.scheme.render?.({
|
|
561
|
-
packable: plot.sampled.getValue(getCurrentTime()),
|
|
562
|
-
mouse: plot.defining ? mouseCartesian.value : void 0,
|
|
563
|
-
defining: plot.defining,
|
|
564
|
-
previous: {
|
|
565
|
-
entities: plot.entities,
|
|
566
|
-
primitives: plot.primitives,
|
|
567
|
-
groundPrimitives: plot.groundPrimitives
|
|
568
|
-
}
|
|
1359
|
+
const diff = density - densities.reduce((count$1, current) => count$1 += current, 0);
|
|
1360
|
+
if (diff) densities[densities.length - 1] += diff;
|
|
1361
|
+
const positionListPromises = densities.map((density$1, i) => {
|
|
1362
|
+
return lerpArray({
|
|
1363
|
+
scene: _options.scene,
|
|
1364
|
+
start: positions[i],
|
|
1365
|
+
end: positions[i + 1],
|
|
1366
|
+
count: density$1,
|
|
1367
|
+
clampToGround: true,
|
|
1368
|
+
classificationType: _options.classificationType,
|
|
1369
|
+
terrainProvider: _options.terrainProvider
|
|
1370
|
+
});
|
|
569
1371
|
});
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
"defining",
|
|
581
|
-
"scheme",
|
|
582
|
-
"sampled",
|
|
583
|
-
"time"
|
|
584
|
-
].includes(key)) update(plot);
|
|
585
|
-
});
|
|
586
|
-
(0, vue.watch)(mouseCartesian, () => {
|
|
587
|
-
plots.value.forEach((plot) => plot.defining && update(plot));
|
|
588
|
-
});
|
|
589
|
-
return {
|
|
590
|
-
primitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
591
|
-
groundPrimitives: (0, vue.computed)(() => Array.from(primitiveScope.scope)),
|
|
592
|
-
entities: (0, vue.computed)(() => Array.from(entityScope.scope))
|
|
593
|
-
};
|
|
594
|
-
}
|
|
1372
|
+
const stagePromises = (await Promise.all(positionListPromises)).map(async (positions$1) => {
|
|
1373
|
+
const { count: count$1 } = await distance(positions$1);
|
|
1374
|
+
return count$1;
|
|
1375
|
+
});
|
|
1376
|
+
const groundStages = await Promise.all(stagePromises);
|
|
1377
|
+
return {
|
|
1378
|
+
stages: groundStages,
|
|
1379
|
+
count: groundStages.reduce((count$1, current) => count$1 += current, 0)
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
595
1382
|
|
|
596
1383
|
//#endregion
|
|
597
|
-
//#region
|
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
sampled.setSample(packable.value);
|
|
638
|
-
});
|
|
639
|
-
const definingCursorCss = (0, vue.ref)();
|
|
640
|
-
const setDefiningCursorCss = () => {
|
|
641
|
-
if (!current.value?.defining) {
|
|
642
|
-
if (definingCursorCss.value) {
|
|
643
|
-
definingCursorCss.value = void 0;
|
|
644
|
-
viewer.value.container.parentElement.style.removeProperty("cursor");
|
|
1384
|
+
//#region measure/measureArea.ts
|
|
1385
|
+
const schemeMeasureArea = new PlotScheme({
|
|
1386
|
+
type: "MeasureArea",
|
|
1387
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1388
|
+
skeletons: [control, interval],
|
|
1389
|
+
initRender() {
|
|
1390
|
+
return { entities: [new cesium.Entity({
|
|
1391
|
+
label: { font: "14pt" },
|
|
1392
|
+
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1393
|
+
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1394
|
+
})] };
|
|
1395
|
+
},
|
|
1396
|
+
render(context) {
|
|
1397
|
+
const entity = context.previous.entities[0];
|
|
1398
|
+
const { mouse, packable } = context;
|
|
1399
|
+
const positions = [...packable.positions ?? []];
|
|
1400
|
+
mouse && positions.push(mouse);
|
|
1401
|
+
if (positions.length === 2) {
|
|
1402
|
+
entity.position = void 0;
|
|
1403
|
+
entity.label.text = void 0;
|
|
1404
|
+
entity.polygon.hierarchy = void 0;
|
|
1405
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1406
|
+
} else if (positions.length >= 3) {
|
|
1407
|
+
positions.push(positions[0]);
|
|
1408
|
+
entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
|
|
1409
|
+
entity.label.text = new cesium.ConstantProperty("");
|
|
1410
|
+
area(positions).then((e) => {
|
|
1411
|
+
let text = "";
|
|
1412
|
+
if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
|
|
1413
|
+
else text = `${(+e).toFixed(2)}m²`;
|
|
1414
|
+
entity.label.text = new cesium.ConstantProperty(text);
|
|
1415
|
+
});
|
|
1416
|
+
entity.polyline.positions = void 0;
|
|
1417
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1418
|
+
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1419
|
+
}, false);
|
|
1420
|
+
} else {
|
|
1421
|
+
entity.position = void 0;
|
|
1422
|
+
entity.polygon.hierarchy = void 0;
|
|
1423
|
+
entity.polyline.positions = void 0;
|
|
645
1424
|
}
|
|
646
|
-
|
|
647
|
-
const definingCursor = current.value.scheme.definingCursor;
|
|
648
|
-
definingCursorCss.value = (0, vesium.isFunction)(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
649
|
-
if (definingCursorCss.value) viewer.value?.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
1425
|
+
return { entities: [entity] };
|
|
650
1426
|
}
|
|
651
|
-
};
|
|
652
|
-
(0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
|
|
653
|
-
if (key === "defining" || key === "sampled") setDefiningCursorCss();
|
|
654
1427
|
});
|
|
655
|
-
(0, vue.watch)(current, () => setDefiningCursorCss());
|
|
656
|
-
}
|
|
657
1428
|
|
|
658
1429
|
//#endregion
|
|
659
|
-
//#region
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
|
|
688
|
-
const options = skeleton.render?.({
|
|
689
|
-
defining,
|
|
690
|
-
active,
|
|
691
|
-
index,
|
|
692
|
-
packable,
|
|
693
|
-
positions,
|
|
694
|
-
position,
|
|
695
|
-
action: getPointAction(entity)
|
|
696
|
-
});
|
|
697
|
-
const merge = new PlotSkeletonEntity(options ?? {});
|
|
698
|
-
if (entity) merge.propertyNames.forEach((key) => {
|
|
699
|
-
if (key !== "id") entity[key] = merge[key];
|
|
700
|
-
});
|
|
701
|
-
else entity = merge;
|
|
702
|
-
entity.plot = plot;
|
|
703
|
-
entity.skeleton = skeleton;
|
|
704
|
-
entity.index = index;
|
|
705
|
-
entities.push(entity);
|
|
1430
|
+
//#region measure/measureDistance.ts
|
|
1431
|
+
const schemeMeasureDistance = new PlotScheme({
|
|
1432
|
+
type: "MeasureDistance",
|
|
1433
|
+
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1434
|
+
skeletons: [control],
|
|
1435
|
+
initRender() {
|
|
1436
|
+
return { entities: [new cesium.Entity({ polyline: {
|
|
1437
|
+
width: 2,
|
|
1438
|
+
material: cesium.Color.YELLOW.withAlpha(.5)
|
|
1439
|
+
} })] };
|
|
1440
|
+
},
|
|
1441
|
+
render(context) {
|
|
1442
|
+
context.previous.entities[0];
|
|
1443
|
+
const { mouse, packable, previous } = context;
|
|
1444
|
+
const entities = previous.entities;
|
|
1445
|
+
const positions = [...packable.positions ?? []];
|
|
1446
|
+
mouse && positions.push(mouse);
|
|
1447
|
+
if (positions.length < 2) return { entities };
|
|
1448
|
+
const pl = entities[0];
|
|
1449
|
+
pl.polyline ??= new cesium.PolylineGraphics();
|
|
1450
|
+
pl.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1451
|
+
positions.forEach((item, index) => {
|
|
1452
|
+
if (!entities[index + 1]) entities[index + 1] = new cesium.Entity({
|
|
1453
|
+
position: item,
|
|
1454
|
+
label: new cesium.LabelGraphics({
|
|
1455
|
+
backgroundColor: cesium.Color.fromCssColorString("#fff"),
|
|
1456
|
+
font: "12pt sans-serif"
|
|
1457
|
+
})
|
|
706
1458
|
});
|
|
707
1459
|
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
714
|
-
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
715
|
-
const entity = pick.id;
|
|
716
|
-
const plot = entity.plot;
|
|
717
|
-
if (plot.defining) return;
|
|
718
|
-
activeEntity.value = entity;
|
|
719
|
-
const skeleton = entity.skeleton;
|
|
720
|
-
const index = entity.index;
|
|
721
|
-
const packable = plot.sampled.getValue(getCurrentTime());
|
|
722
|
-
skeleton.onDrag?.({
|
|
723
|
-
viewer: viewer.value,
|
|
724
|
-
sampled: plot.sampled,
|
|
725
|
-
packable,
|
|
726
|
-
active: current.value === plot,
|
|
727
|
-
index,
|
|
728
|
-
event,
|
|
729
|
-
dragging,
|
|
730
|
-
lockCamera
|
|
1460
|
+
entities.splice(positions.length, entities.length - positions.length - 1);
|
|
1461
|
+
distance(positions).then(({ count, stages }) => {
|
|
1462
|
+
stages.forEach((stage, index) => {
|
|
1463
|
+
entities[index + 1].position = new cesium.CallbackPositionProperty(() => cesium.Cartesian3.midpoint(positions[index], positions[index + 1], new cesium.Cartesian3()), false);
|
|
1464
|
+
entities[index + 1].label.text = new cesium.CallbackProperty(() => `${stage.toFixed(2)} m`, false);
|
|
731
1465
|
});
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}
|
|
739
|
-
},
|
|
740
|
-
dragCursor: ({ pick }) => {
|
|
741
|
-
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
742
|
-
const skeleton = pick.id.skeleton;
|
|
743
|
-
return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
|
|
1466
|
+
if (stages.length > 1) {
|
|
1467
|
+
entities[entities.length - 1].position = new cesium.CallbackPositionProperty(() => positions[positions.length - 1], false);
|
|
1468
|
+
entities[entities.length - 1].label.text = new cesium.CallbackProperty(() => `${count.toFixed(2)} m`, false);
|
|
1469
|
+
} else {
|
|
1470
|
+
entities[entities.length - 1].position = void 0;
|
|
1471
|
+
entities[entities.length - 1].label.text = void 0;
|
|
744
1472
|
}
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
onCleanup(remove);
|
|
748
|
-
});
|
|
749
|
-
(0, __vueuse_core.onKeyStroke)((keyEvent) => {
|
|
750
|
-
if (activeEntity.value) {
|
|
751
|
-
const entity = activeEntity.value;
|
|
752
|
-
const plot = entity.plot;
|
|
753
|
-
const skeleton = entity.skeleton;
|
|
754
|
-
const index = entity.index;
|
|
755
|
-
const packable = plot.sampled.getValue(getCurrentTime());
|
|
756
|
-
skeleton.onKeyPressed?.({
|
|
757
|
-
viewer: viewer.value,
|
|
758
|
-
sampled: plot.sampled,
|
|
759
|
-
packable,
|
|
760
|
-
index,
|
|
761
|
-
keyEvent
|
|
762
1473
|
});
|
|
1474
|
+
return { entities };
|
|
763
1475
|
}
|
|
764
1476
|
});
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
sampled: plot.sampled,
|
|
786
|
-
packable,
|
|
787
|
-
active: current.value === plot,
|
|
788
|
-
defining: plot.defining,
|
|
789
|
-
index,
|
|
790
|
-
event
|
|
791
|
-
});
|
|
792
|
-
} else activeEntity.value = void 0;
|
|
793
|
-
});
|
|
794
|
-
onCleanup(remove);
|
|
795
|
-
});
|
|
796
|
-
(0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
|
|
797
|
-
added.forEach((plot) => update(plot));
|
|
798
|
-
removed.forEach((plot) => update(plot, true));
|
|
799
|
-
});
|
|
800
|
-
(0, vesium.useCesiumEventListener)(() => plots.value.map((plot) => plot.definitionChanged), (plot, key, newValue, oldValue) => {
|
|
801
|
-
if ([
|
|
802
|
-
"disabled",
|
|
803
|
-
"defining",
|
|
804
|
-
"scheme",
|
|
805
|
-
"sampled",
|
|
806
|
-
"time"
|
|
807
|
-
].includes(key)) (0, vue.nextTick)(() => update(plot));
|
|
808
|
-
else if (key === "skeletons") {
|
|
809
|
-
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
810
|
-
added.forEach((item) => entityScope.add(item));
|
|
811
|
-
removed.forEach((item) => entityScope.remove(item));
|
|
1477
|
+
|
|
1478
|
+
//#endregion
|
|
1479
|
+
//#region scheme/Billboard.ts
|
|
1480
|
+
const PlotSchemeBillboard = new PlotScheme({
|
|
1481
|
+
type: "Billboard",
|
|
1482
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1483
|
+
skeletons: [moved],
|
|
1484
|
+
initRender: () => {
|
|
1485
|
+
return { entities: [new cesium.Entity({ billboard: {
|
|
1486
|
+
image: "/favicon.svg",
|
|
1487
|
+
width: 32,
|
|
1488
|
+
height: 32
|
|
1489
|
+
} })] };
|
|
1490
|
+
},
|
|
1491
|
+
render(options) {
|
|
1492
|
+
const { mouse, packable } = options;
|
|
1493
|
+
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ billboard: {} });
|
|
1494
|
+
const position = packable.positions?.[0] ?? mouse;
|
|
1495
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1496
|
+
return { entities: [entity] };
|
|
812
1497
|
}
|
|
813
1498
|
});
|
|
814
|
-
(0, vue.watch)(current, (plot, previous) => {
|
|
815
|
-
plot && update(plot);
|
|
816
|
-
previous && update(previous);
|
|
817
|
-
});
|
|
818
|
-
return { dataSource };
|
|
819
|
-
}
|
|
820
1499
|
|
|
821
1500
|
//#endregion
|
|
822
|
-
//#region
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
});
|
|
836
|
-
useSampled(current, getCurrentTime);
|
|
837
|
-
useRender(plots, current, getCurrentTime);
|
|
838
|
-
useSkeleton(plots, current, getCurrentTime);
|
|
839
|
-
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
840
|
-
if (current.value?.defining) return;
|
|
841
|
-
const pick = viewer.value?.scene.pick(data.position.clone());
|
|
842
|
-
if (pick?.id?.plot instanceof PlotFeature) return;
|
|
843
|
-
if (!pick) {
|
|
844
|
-
current.value = void 0;
|
|
845
|
-
return;
|
|
1501
|
+
//#region scheme/BillboardPinBuilder.ts
|
|
1502
|
+
const PlotSchemeBillboardPinBuilder = new PlotScheme({
|
|
1503
|
+
type: "BillboardPinBuilder",
|
|
1504
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1505
|
+
skeletons: [moved],
|
|
1506
|
+
initRender() {
|
|
1507
|
+
return { entities: [new cesium.Entity({ billboard: {} })] };
|
|
1508
|
+
},
|
|
1509
|
+
render(context) {
|
|
1510
|
+
const entity = context.previous.entities[0];
|
|
1511
|
+
const position = context.packable.positions[0] ?? context.mouse;
|
|
1512
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1513
|
+
return { entities: [entity] };
|
|
846
1514
|
}
|
|
847
|
-
current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
|
|
848
|
-
...plot.entities,
|
|
849
|
-
...plot.primitives,
|
|
850
|
-
...plot.groundPrimitives
|
|
851
|
-
]));
|
|
852
1515
|
});
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
1516
|
+
|
|
1517
|
+
//#endregion
|
|
1518
|
+
//#region scheme/Cylinder.ts
|
|
1519
|
+
const PlotSchemeCylinder = new PlotScheme({
|
|
1520
|
+
type: "Cylinder",
|
|
1521
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1522
|
+
skeletons: [moved, control],
|
|
1523
|
+
initRender() {
|
|
1524
|
+
return { entities: [new cesium.Entity({ cylinder: {} })] };
|
|
1525
|
+
},
|
|
1526
|
+
render(context) {
|
|
1527
|
+
const entity = context.previous.entities[0];
|
|
1528
|
+
const positions = [...context.packable.positions];
|
|
1529
|
+
if (positions.length === 0) return context.previous;
|
|
1530
|
+
if (positions.length === 1) {
|
|
1531
|
+
const position = context.mouse;
|
|
1532
|
+
position && positions.push(position);
|
|
864
1533
|
}
|
|
1534
|
+
if (positions.length < 2) return context.previous;
|
|
1535
|
+
entity.position = new cesium.ConstantPositionProperty(positions[0]);
|
|
1536
|
+
const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
|
|
1537
|
+
entity.cylinder.bottomRadius = new cesium.CallbackProperty(() => radius, false);
|
|
1538
|
+
if (context.defining || !(0, vesium.toPropertyValue)(entity.cylinder.length)) entity.cylinder.length = (0, vesium.toProperty)(radius * 2);
|
|
1539
|
+
return { entities: [entity] };
|
|
865
1540
|
}
|
|
866
1541
|
});
|
|
867
|
-
const operate = async (plot) => {
|
|
868
|
-
return new Promise((resolve, reject) => {
|
|
869
|
-
operateResolve = resolve;
|
|
870
|
-
operateReject = reject;
|
|
871
|
-
const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
|
|
872
|
-
if (!collection.has(_plot)) collection.add(_plot);
|
|
873
|
-
current.value = _plot;
|
|
874
|
-
return resolve(_plot);
|
|
875
|
-
});
|
|
876
|
-
};
|
|
877
|
-
const remove = (plot) => {
|
|
878
|
-
if (plot === current.value) current.value = void 0;
|
|
879
|
-
if (collection.has(plot)) {
|
|
880
|
-
collection.delete(plot);
|
|
881
|
-
return true;
|
|
882
|
-
}
|
|
883
|
-
return false;
|
|
884
|
-
};
|
|
885
|
-
return {
|
|
886
|
-
plots,
|
|
887
|
-
time,
|
|
888
|
-
operate,
|
|
889
|
-
remove,
|
|
890
|
-
cancel: operateReject
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
1542
|
|
|
894
1543
|
//#endregion
|
|
895
|
-
//#region
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
cursor: "pointer",
|
|
903
|
-
dragCursor: "crosshair",
|
|
904
|
-
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
905
|
-
lockCamera();
|
|
906
|
-
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
907
|
-
if (position) {
|
|
908
|
-
const positions = [...packable.positions ?? []];
|
|
909
|
-
positions[index] = position;
|
|
910
|
-
sampled.setSample({
|
|
911
|
-
time: packable.time,
|
|
912
|
-
derivative: packable.derivative,
|
|
913
|
-
positions
|
|
914
|
-
});
|
|
915
|
-
}
|
|
1544
|
+
//#region scheme/Ellipse.ts
|
|
1545
|
+
const PlotSchemeEllipse = new PlotScheme({
|
|
1546
|
+
type: "Ellipse",
|
|
1547
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1548
|
+
skeletons: [moved, control],
|
|
1549
|
+
initRender() {
|
|
1550
|
+
return { entities: [new cesium.Entity({ ellipse: {} })] };
|
|
916
1551
|
},
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
].includes(keyEvent.key)) return;
|
|
925
|
-
keyEvent.preventDefault();
|
|
926
|
-
let headingAdjust = 0;
|
|
927
|
-
switch (keyEvent.key) {
|
|
928
|
-
case "ArrowRight":
|
|
929
|
-
headingAdjust = Math.PI / 2;
|
|
930
|
-
break;
|
|
931
|
-
case "ArrowDown":
|
|
932
|
-
headingAdjust = Math.PI;
|
|
933
|
-
break;
|
|
934
|
-
case "ArrowLeft":
|
|
935
|
-
headingAdjust = -Math.PI / 2;
|
|
936
|
-
break;
|
|
937
|
-
case "ArrowUp":
|
|
938
|
-
headingAdjust = 0;
|
|
939
|
-
break;
|
|
1552
|
+
render(context) {
|
|
1553
|
+
const entity = context.previous.entities[0];
|
|
1554
|
+
const positions = [...context.packable.positions];
|
|
1555
|
+
if (positions.length === 0) return context.previous;
|
|
1556
|
+
if (positions.length === 1) {
|
|
1557
|
+
const position = context.mouse;
|
|
1558
|
+
position && positions.push(position);
|
|
940
1559
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
cartographic.longitude += distance * Math.sin(newHeading);
|
|
948
|
-
positions[index] = (0, vesium.toCartesian3)(cartographic);
|
|
949
|
-
sampled.setSample({
|
|
950
|
-
time: packable.time,
|
|
951
|
-
derivative: packable.derivative,
|
|
952
|
-
positions
|
|
953
|
-
});
|
|
954
|
-
},
|
|
955
|
-
render: ({ position, action }) => {
|
|
956
|
-
const colors = {
|
|
957
|
-
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
958
|
-
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
959
|
-
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
960
|
-
};
|
|
961
|
-
return {
|
|
962
|
-
position,
|
|
963
|
-
point: {
|
|
964
|
-
pixelSize: 8,
|
|
965
|
-
color: colors[action],
|
|
966
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
967
|
-
outlineWidth: 1,
|
|
968
|
-
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
969
|
-
}
|
|
970
|
-
};
|
|
1560
|
+
if (positions.length < 2) return context.previous;
|
|
1561
|
+
entity.position = new cesium.ConstantPositionProperty(positions[0]);
|
|
1562
|
+
const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
|
|
1563
|
+
entity.ellipse.semiMinorAxis = new cesium.CallbackProperty(() => radius || 1, false);
|
|
1564
|
+
entity.ellipse.semiMajorAxis = entity.ellipse.semiMinorAxis;
|
|
1565
|
+
return { entities: [entity] };
|
|
971
1566
|
}
|
|
972
|
-
};
|
|
973
|
-
}
|
|
1567
|
+
});
|
|
974
1568
|
|
|
975
1569
|
//#endregion
|
|
976
|
-
//#region
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
disabled: ({ active, defining }) => !active || defining,
|
|
984
|
-
cursor: "pointer",
|
|
985
|
-
dragCursor: "crosshair",
|
|
986
|
-
format(packable) {
|
|
987
|
-
const _positions = packable.positions ?? [];
|
|
988
|
-
if (_positions.length < 2) return [];
|
|
989
|
-
return _positions.map((position, i) => {
|
|
990
|
-
const next = i === _positions.length - 1 ? _positions[0] : _positions[i + 1];
|
|
991
|
-
return cesium.Cartesian3.midpoint(position, next, new cesium.Cartesian3());
|
|
992
|
-
});
|
|
993
|
-
},
|
|
994
|
-
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
995
|
-
lockCamera();
|
|
996
|
-
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
997
|
-
if (!position) return;
|
|
998
|
-
const positions = [...packable.positions ?? []];
|
|
999
|
-
if (dragIndex === -1) {
|
|
1000
|
-
dragIndex = index;
|
|
1001
|
-
positions.splice(index + 1, 0, position);
|
|
1002
|
-
} else positions[dragIndex + 1] = position;
|
|
1003
|
-
if (!dragging) dragIndex = -1;
|
|
1004
|
-
sampled.setSample({
|
|
1005
|
-
time: packable.time,
|
|
1006
|
-
derivative: packable.derivative,
|
|
1007
|
-
positions
|
|
1008
|
-
});
|
|
1570
|
+
//#region scheme/Label.ts
|
|
1571
|
+
const PlotSchemeLabel = new PlotScheme({
|
|
1572
|
+
type: "Label",
|
|
1573
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1574
|
+
skeletons: [moved],
|
|
1575
|
+
initRender() {
|
|
1576
|
+
return { entities: [new cesium.Entity({ label: { text: "Label" } })] };
|
|
1009
1577
|
},
|
|
1010
|
-
render
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1016
|
-
};
|
|
1017
|
-
return {
|
|
1018
|
-
position,
|
|
1019
|
-
point: {
|
|
1020
|
-
pixelSize: 6,
|
|
1021
|
-
color: colors[action],
|
|
1022
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1023
|
-
outlineWidth: 1,
|
|
1024
|
-
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1578
|
+
render(context) {
|
|
1579
|
+
const entity = context.previous.entities[0];
|
|
1580
|
+
const position = context.packable.positions[0] ?? context.mouse;
|
|
1581
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1582
|
+
return { entities: [entity] };
|
|
1027
1583
|
}
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1584
|
+
});
|
|
1030
1585
|
|
|
1031
1586
|
//#endregion
|
|
1032
|
-
//#region
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
format(packable) {
|
|
1043
|
-
const _positions = packable.positions ?? [];
|
|
1044
|
-
if (_positions.length < 2) return [];
|
|
1045
|
-
const midpoints = [];
|
|
1046
|
-
for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
|
|
1047
|
-
return midpoints;
|
|
1048
|
-
},
|
|
1049
|
-
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1050
|
-
lockCamera();
|
|
1051
|
-
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1052
|
-
if (!position) return;
|
|
1053
|
-
const positions = [...packable.positions ?? []];
|
|
1054
|
-
if (dragIndex === -1) {
|
|
1055
|
-
dragIndex = index;
|
|
1056
|
-
positions.splice(index + 1, 0, position);
|
|
1057
|
-
} else positions[dragIndex + 1] = position;
|
|
1058
|
-
if (!dragging) dragIndex = -1;
|
|
1059
|
-
sampled.setSample({
|
|
1060
|
-
time: packable.time,
|
|
1061
|
-
derivative: packable.derivative,
|
|
1062
|
-
positions
|
|
1063
|
-
});
|
|
1587
|
+
//#region scheme/Point.ts
|
|
1588
|
+
const PlotSchemePoint = new PlotScheme({
|
|
1589
|
+
type: "Point",
|
|
1590
|
+
complete: (packable) => packable.positions.length >= 1,
|
|
1591
|
+
skeletons: [moved],
|
|
1592
|
+
initRender() {
|
|
1593
|
+
return { entities: [new cesium.Entity({ point: {
|
|
1594
|
+
pixelSize: 10,
|
|
1595
|
+
color: cesium.Color.RED
|
|
1596
|
+
} })] };
|
|
1064
1597
|
},
|
|
1065
|
-
render
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
};
|
|
1071
|
-
return {
|
|
1072
|
-
position,
|
|
1073
|
-
point: {
|
|
1074
|
-
pixelSize: 6,
|
|
1075
|
-
color: colors[action],
|
|
1076
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1077
|
-
outlineWidth: 1,
|
|
1078
|
-
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1079
|
-
}
|
|
1080
|
-
};
|
|
1598
|
+
render(context) {
|
|
1599
|
+
const entity = context.previous.entities[0];
|
|
1600
|
+
const position = context.packable.positions[0] ?? context.mouse;
|
|
1601
|
+
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1602
|
+
return { entities: [entity] };
|
|
1081
1603
|
}
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1604
|
+
});
|
|
1084
1605
|
|
|
1085
1606
|
//#endregion
|
|
1086
|
-
//#region
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
else {
|
|
1101
|
-
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1102
|
-
return [(0, vesium.toCartesian3)(center)];
|
|
1103
|
-
}
|
|
1607
|
+
//#region scheme/Polygon.ts
|
|
1608
|
+
const PlotSchemePolygon = new PlotScheme({
|
|
1609
|
+
type: "Polygon",
|
|
1610
|
+
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1611
|
+
skeletons: [
|
|
1612
|
+
moved,
|
|
1613
|
+
control,
|
|
1614
|
+
interval
|
|
1615
|
+
],
|
|
1616
|
+
initRender: () => {
|
|
1617
|
+
return { entities: [new cesium.Entity({
|
|
1618
|
+
polyline: {},
|
|
1619
|
+
polygon: {}
|
|
1620
|
+
})] };
|
|
1104
1621
|
},
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
const
|
|
1108
|
-
const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1109
|
-
if (!startPosition || !endPosition) return;
|
|
1110
|
-
const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
|
|
1622
|
+
render(options) {
|
|
1623
|
+
const { mouse, packable } = options;
|
|
1624
|
+
const entity = options.previous.entities[0];
|
|
1111
1625
|
const positions = [...packable.positions ?? []];
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
positions
|
|
1116
|
-
})
|
|
1626
|
+
mouse && positions.push(mouse);
|
|
1627
|
+
if (positions.length === 2) {
|
|
1628
|
+
entity.polygon.hierarchy = void 0;
|
|
1629
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1630
|
+
} else if (positions.length >= 3) {
|
|
1631
|
+
entity.polyline.positions = void 0;
|
|
1632
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1633
|
+
positions.push(positions[0]);
|
|
1634
|
+
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1635
|
+
}, false);
|
|
1636
|
+
} else {
|
|
1637
|
+
entity.polygon.hierarchy = void 0;
|
|
1638
|
+
entity.polyline.positions = void 0;
|
|
1639
|
+
}
|
|
1640
|
+
return { entities: [entity] };
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
//#endregion
|
|
1645
|
+
//#region scheme/PolygonArc.ts
|
|
1646
|
+
const PlotSchemePolygonArc = new PlotScheme({
|
|
1647
|
+
type: "PolygonArc",
|
|
1648
|
+
complete: (packable) => packable.positions.length >= 3,
|
|
1649
|
+
skeletons: [moved, control],
|
|
1650
|
+
initRender() {
|
|
1651
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1117
1652
|
},
|
|
1118
|
-
render
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
color: colors[action],
|
|
1131
|
-
pixelOffset: new cesium.Cartesian3(0, -20),
|
|
1132
|
-
horizontalOrigin: cesium.HorizontalOrigin.CENTER,
|
|
1133
|
-
verticalOrigin: cesium.VerticalOrigin.BOTTOM,
|
|
1134
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1653
|
+
render(context) {
|
|
1654
|
+
const entity = context.previous.entities[0];
|
|
1655
|
+
const points = context.packable.positions;
|
|
1656
|
+
if (points.length < 3) context.mouse && points.push(context.mouse.clone());
|
|
1657
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1658
|
+
if (coords.length < 3) {
|
|
1659
|
+
entity.polygon.hierarchy = void 0;
|
|
1660
|
+
return context.previous;
|
|
1661
|
+
}
|
|
1662
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arc)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1663
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1664
|
+
return { entities: [entity] };
|
|
1137
1665
|
}
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1666
|
+
});
|
|
1140
1667
|
|
|
1141
1668
|
//#endregion
|
|
1142
|
-
//#region
|
|
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
|
-
b,
|
|
1169
|
-
c
|
|
1170
|
-
]);
|
|
1171
|
-
}
|
|
1172
|
-
return result;
|
|
1173
|
-
}
|
|
1669
|
+
//#region scheme/PolygonArrowAttackDirection.ts
|
|
1670
|
+
const PlotSchemePolygonArrowAttackDirection = new PlotScheme({
|
|
1671
|
+
type: "PolygonArrowAttackDirection",
|
|
1672
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1673
|
+
skeletons: [
|
|
1674
|
+
moved,
|
|
1675
|
+
control,
|
|
1676
|
+
intervalNonclosed
|
|
1677
|
+
],
|
|
1678
|
+
initRender() {
|
|
1679
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1680
|
+
},
|
|
1681
|
+
render(context) {
|
|
1682
|
+
const entity = context.previous.entities[0];
|
|
1683
|
+
const points = context.packable.positions;
|
|
1684
|
+
context.mouse && points.push(context.mouse.clone());
|
|
1685
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1686
|
+
if (coords.length < 3) {
|
|
1687
|
+
entity.polygon.hierarchy = void 0;
|
|
1688
|
+
return context.previous;
|
|
1689
|
+
}
|
|
1690
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowAttackDirection)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1691
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1692
|
+
return { entities: [entity] };
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1174
1695
|
|
|
1175
1696
|
//#endregion
|
|
1176
|
-
//#region
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1697
|
+
//#region scheme/PolygonArrowAttackDirectionTailed.ts
|
|
1698
|
+
const PlotSchemePolygonArrowAttackDirectionTailed = new PlotScheme({
|
|
1699
|
+
type: "PolygonArrowAttackDirectionTailed",
|
|
1700
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1701
|
+
skeletons: [
|
|
1702
|
+
moved,
|
|
1703
|
+
control,
|
|
1704
|
+
intervalNonclosed
|
|
1705
|
+
],
|
|
1706
|
+
initRender() {
|
|
1707
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1708
|
+
},
|
|
1709
|
+
render(context) {
|
|
1710
|
+
const entity = context.previous.entities[0];
|
|
1711
|
+
const points = context.packable.positions;
|
|
1712
|
+
context.mouse && points.push(context.mouse.clone());
|
|
1713
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1714
|
+
if (coords.length < 3) {
|
|
1715
|
+
entity.polygon.hierarchy = void 0;
|
|
1716
|
+
return context.previous;
|
|
1717
|
+
}
|
|
1718
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowAttackDirectionTailed)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1719
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1720
|
+
return { entities: [entity] };
|
|
1721
|
+
}
|
|
1191
1722
|
});
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1723
|
+
|
|
1724
|
+
//#endregion
|
|
1725
|
+
//#region scheme/PolygonArrowClamped.ts
|
|
1726
|
+
const PlotSchemePolygonArrowClamped = new PlotScheme({
|
|
1727
|
+
type: "PolygonArrowClamped",
|
|
1728
|
+
complete: (packable) => packable.positions.length >= 5,
|
|
1729
|
+
skeletons: [moved, control],
|
|
1730
|
+
initRender() {
|
|
1731
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1732
|
+
},
|
|
1733
|
+
render(context) {
|
|
1734
|
+
const entity = context.previous.entities[0];
|
|
1735
|
+
const points = context.packable.positions;
|
|
1736
|
+
if (points.length < 5) {
|
|
1737
|
+
const mouse = context.mouse;
|
|
1738
|
+
mouse && points.push(mouse.clone());
|
|
1739
|
+
}
|
|
1740
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1741
|
+
if (coords.length >= 3) {
|
|
1742
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowClamped)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1743
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1744
|
+
} else entity.polygon.hierarchy = void 0;
|
|
1745
|
+
return { entities: [entity] };
|
|
1746
|
+
}
|
|
1198
1747
|
});
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1748
|
+
|
|
1749
|
+
//#endregion
|
|
1750
|
+
//#region scheme/PolygonArrowStraight.ts
|
|
1751
|
+
const PlotSchemePolygonArrowStraight = new PlotScheme({
|
|
1752
|
+
type: "PolygonArrowStraight",
|
|
1753
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1754
|
+
skeletons: [moved, control],
|
|
1755
|
+
initRender() {
|
|
1756
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1757
|
+
},
|
|
1758
|
+
render(context) {
|
|
1759
|
+
const entity = context.previous.entities[0];
|
|
1760
|
+
const points = context.packable.positions;
|
|
1761
|
+
if (points.length < 2) {
|
|
1762
|
+
const mouse = context.mouse;
|
|
1763
|
+
mouse && points.push(mouse.clone());
|
|
1764
|
+
}
|
|
1765
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1766
|
+
if (coords.length >= 2) {
|
|
1767
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowStraight)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1768
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1769
|
+
} else entity.polygon.hierarchy = void 0;
|
|
1770
|
+
return { entities: [entity] };
|
|
1771
|
+
}
|
|
1204
1772
|
});
|
|
1205
|
-
return resluts;
|
|
1206
|
-
}
|
|
1207
1773
|
|
|
1208
1774
|
//#endregion
|
|
1209
|
-
//#region
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
const bbox = cesium.Rectangle.fromCartesianArray(positions);
|
|
1232
|
-
const vertical = bbox.north - bbox.south;
|
|
1233
|
-
const horizontal = bbox.east - bbox.west;
|
|
1234
|
-
const max = Math.max(horizontal, vertical);
|
|
1235
|
-
const granularity = max / density;
|
|
1236
|
-
const polygonGeometry = cesium.PolygonGeometry.fromPositions({
|
|
1237
|
-
positions,
|
|
1238
|
-
vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
1239
|
-
granularity
|
|
1775
|
+
//#region scheme/PolygonArrowStraightSharp.ts
|
|
1776
|
+
const PlotSchemePolygonArrowStraightSharp = new PlotScheme({
|
|
1777
|
+
type: "PolygonArrowStraightSharp",
|
|
1778
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1779
|
+
skeletons: [moved, control],
|
|
1780
|
+
initRender() {
|
|
1781
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1782
|
+
},
|
|
1783
|
+
render(context) {
|
|
1784
|
+
const entity = context.previous.entities[0];
|
|
1785
|
+
const points = context.packable.positions;
|
|
1786
|
+
if (points.length < 2) {
|
|
1787
|
+
const mouse = context.mouse;
|
|
1788
|
+
mouse && points.push(mouse.clone());
|
|
1789
|
+
}
|
|
1790
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1791
|
+
if (coords.length >= 2) {
|
|
1792
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowStraightSharp)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1793
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1794
|
+
} else entity.polygon.hierarchy = void 0;
|
|
1795
|
+
return { entities: [entity] };
|
|
1796
|
+
}
|
|
1240
1797
|
});
|
|
1241
|
-
const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
|
|
1242
|
-
const values = geometry.attributes.position.values;
|
|
1243
|
-
if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1244
|
-
const indices = geometry.indices;
|
|
1245
|
-
let cartesian3List = [];
|
|
1246
|
-
for (let i = 0; i < indices.length; i += 3) {
|
|
1247
|
-
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1248
|
-
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1249
|
-
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1250
|
-
cartesian3List.push(a, b, c);
|
|
1251
|
-
}
|
|
1252
|
-
if (clampToGround) {
|
|
1253
|
-
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1254
|
-
const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1255
|
-
scene,
|
|
1256
|
-
terrainProvider,
|
|
1257
|
-
positions: cartesian3List,
|
|
1258
|
-
classificationType
|
|
1259
|
-
});
|
|
1260
|
-
cartesian3List = detaileds;
|
|
1261
|
-
}
|
|
1262
|
-
const grid = [];
|
|
1263
|
-
while (cartesian3List?.length) {
|
|
1264
|
-
const [a, b, c] = cartesian3List.splice(0, 3);
|
|
1265
|
-
grid.push([
|
|
1266
|
-
a,
|
|
1267
|
-
b,
|
|
1268
|
-
c
|
|
1269
|
-
]);
|
|
1270
|
-
}
|
|
1271
|
-
return grid;
|
|
1272
|
-
}
|
|
1273
1798
|
|
|
1274
1799
|
//#endregion
|
|
1275
|
-
//#region
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
/**
|
|
1301
|
-
* 计算三维坐标系下图形面积
|
|
1302
|
-
* @param positions - 图形各点的笛卡尔数组
|
|
1303
|
-
*/
|
|
1304
|
-
async function area(positions, options) {
|
|
1305
|
-
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1306
|
-
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions(options);
|
|
1307
|
-
if (density <= 0) throw new Error("options.density must > 0");
|
|
1308
|
-
if (!clampToGround) {
|
|
1309
|
-
const triangles$1 = tesselate(positions);
|
|
1310
|
-
return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1311
|
-
}
|
|
1312
|
-
const triangles = await triangleGrid(positions, {
|
|
1313
|
-
density,
|
|
1314
|
-
scene,
|
|
1315
|
-
clampToGround,
|
|
1316
|
-
classificationType,
|
|
1317
|
-
terrainProvider
|
|
1800
|
+
//#region scheme/PolygonArrowUnitCombatOperation.ts
|
|
1801
|
+
const PlotSchemePolygonArrowUnitCombatOperation = new PlotScheme({
|
|
1802
|
+
type: "PolygonArrowUnitCombatOperation",
|
|
1803
|
+
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1804
|
+
skeletons: [
|
|
1805
|
+
moved,
|
|
1806
|
+
control,
|
|
1807
|
+
intervalNonclosed
|
|
1808
|
+
],
|
|
1809
|
+
initRender() {
|
|
1810
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1811
|
+
},
|
|
1812
|
+
render(context) {
|
|
1813
|
+
const entity = context.previous.entities[0];
|
|
1814
|
+
const points = context.packable.positions;
|
|
1815
|
+
context.mouse && points.push(context.mouse.clone());
|
|
1816
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1817
|
+
if (coords.length < 2) {
|
|
1818
|
+
entity.polygon.hierarchy = void 0;
|
|
1819
|
+
return context.previous;
|
|
1820
|
+
}
|
|
1821
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowUnitCombatOperation)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1822
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1823
|
+
return { entities: [entity] };
|
|
1824
|
+
}
|
|
1318
1825
|
});
|
|
1319
|
-
return triangles.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1320
|
-
}
|
|
1321
1826
|
|
|
1322
1827
|
//#endregion
|
|
1323
|
-
//#region
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
entity.polygon.hierarchy =
|
|
1346
|
-
|
|
1347
|
-
} else if (positions.length >= 3) {
|
|
1348
|
-
positions.push(positions[0]);
|
|
1349
|
-
entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
|
|
1350
|
-
entity.label.text = new cesium.ConstantProperty("");
|
|
1351
|
-
area(positions).then((e) => {
|
|
1352
|
-
let text = "";
|
|
1353
|
-
if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
|
|
1354
|
-
else text = `${(+e).toFixed(2)}m²`;
|
|
1355
|
-
entity.label.text = new cesium.ConstantProperty(text);
|
|
1356
|
-
});
|
|
1357
|
-
entity.polyline.positions = void 0;
|
|
1358
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1359
|
-
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1360
|
-
}, false);
|
|
1361
|
-
} else {
|
|
1362
|
-
entity.position = void 0;
|
|
1363
|
-
entity.polygon.hierarchy = void 0;
|
|
1364
|
-
entity.polyline.positions = void 0;
|
|
1828
|
+
//#region scheme/PolygonArrowUnitCombatOperationTailed.ts
|
|
1829
|
+
const PlotSchemePolygonArrowUnitCombatOperationTailed = new PlotScheme({
|
|
1830
|
+
type: "PolygonArrowUnitCombatOperationTailed",
|
|
1831
|
+
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1832
|
+
skeletons: [
|
|
1833
|
+
moved,
|
|
1834
|
+
control,
|
|
1835
|
+
interval
|
|
1836
|
+
],
|
|
1837
|
+
initRender() {
|
|
1838
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1839
|
+
},
|
|
1840
|
+
render(context) {
|
|
1841
|
+
const entity = context.previous.entities[0];
|
|
1842
|
+
const points = context.packable.positions;
|
|
1843
|
+
context.mouse && points.push(context.mouse.clone());
|
|
1844
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1845
|
+
if (coords.length < 2) {
|
|
1846
|
+
entity.polygon.hierarchy = void 0;
|
|
1847
|
+
return context.previous;
|
|
1848
|
+
}
|
|
1849
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowUnitCombatOperationTailed)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1850
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1851
|
+
return { entities: [entity] };
|
|
1365
1852
|
}
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
});
|
|
1853
|
+
});
|
|
1369
1854
|
|
|
1370
1855
|
//#endregion
|
|
1371
|
-
//#region scheme/
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
}
|
|
1856
|
+
//#region scheme/PolygonAssemblingPlace.ts
|
|
1857
|
+
const PlotSchemePolygonAssemblingPlace = new PlotScheme({
|
|
1858
|
+
type: "PolygonAssemblingPlace",
|
|
1859
|
+
complete: (packable) => packable.positions.length >= 3,
|
|
1860
|
+
skeletons: [
|
|
1861
|
+
moved,
|
|
1862
|
+
control,
|
|
1863
|
+
interval
|
|
1864
|
+
],
|
|
1865
|
+
initRender() {
|
|
1866
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1867
|
+
},
|
|
1868
|
+
render(context) {
|
|
1869
|
+
const entity = context.previous.entities[0];
|
|
1870
|
+
const points = context.packable.positions;
|
|
1871
|
+
context.mouse && points.push(context.mouse.clone());
|
|
1872
|
+
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
1873
|
+
if (coords.length < 2) {
|
|
1874
|
+
entity.polygon.hierarchy = void 0;
|
|
1875
|
+
return context.previous;
|
|
1876
|
+
}
|
|
1877
|
+
if (coords.length === 2) {
|
|
1878
|
+
const c0 = (0, vesium.toCartographic)(coords[0]);
|
|
1879
|
+
const c1 = (0, vesium.toCartographic)(coords[1]);
|
|
1880
|
+
const latitude = c0.latitude;
|
|
1881
|
+
const height = c0.height;
|
|
1882
|
+
const longitude = c1.longitude - (c0.longitude - c1.longitude);
|
|
1883
|
+
coords.push((0, vesium.toCoord)(new cesium.Cartographic(longitude, latitude, height)));
|
|
1884
|
+
}
|
|
1885
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.assemblingPlace)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
1886
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1887
|
+
return { entities: [entity] };
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1392
1890
|
|
|
1393
1891
|
//#endregion
|
|
1394
|
-
//#region scheme/
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1892
|
+
//#region scheme/PolygonSmooth.ts
|
|
1893
|
+
const PlotSchemePolygonSmooth = new PlotScheme({
|
|
1894
|
+
type: "PolygonSmooth",
|
|
1895
|
+
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1896
|
+
skeletons: [
|
|
1897
|
+
moved,
|
|
1898
|
+
control,
|
|
1899
|
+
intervalNonclosed
|
|
1900
|
+
],
|
|
1901
|
+
initRender() {
|
|
1902
|
+
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
1903
|
+
},
|
|
1904
|
+
render(context) {
|
|
1905
|
+
const entity = context.previous.entities[0];
|
|
1906
|
+
const positions = context.packable.positions;
|
|
1907
|
+
const mousePosition = context.mouse;
|
|
1908
|
+
mousePosition && positions.push(mousePosition.clone());
|
|
1909
|
+
if (positions.length <= 2) {
|
|
1910
|
+
entity.polygon.hierarchy = void 0;
|
|
1911
|
+
return context.previous;
|
|
1912
|
+
}
|
|
1913
|
+
const wgs84s = positions.map((e) => (0, vesium.toCoord)(e));
|
|
1914
|
+
wgs84s.push(wgs84s[0]);
|
|
1915
|
+
const { features } = __turf_turf.polygonSmooth(__turf_turf.polygon([wgs84s]), { iterations: 3 });
|
|
1916
|
+
const hierarchy = new cesium.PolygonHierarchy(features[0].geometry.coordinates[0].map((item) => (0, vesium.toCartesian3)(item)).filter((e) => !!e));
|
|
1917
|
+
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
1918
|
+
return { entities: [entity] };
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1411
1921
|
|
|
1412
1922
|
//#endregion
|
|
1413
|
-
//#region scheme/
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
mouse && positions.push(mouse);
|
|
1437
|
-
if (positions.length === 2) {
|
|
1438
|
-
entity.polygon.hierarchy = void 0;
|
|
1439
|
-
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1440
|
-
} else if (positions.length >= 3) {
|
|
1441
|
-
entity.polyline.positions = void 0;
|
|
1442
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1443
|
-
positions.push(positions[0]);
|
|
1444
|
-
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1445
|
-
}, false);
|
|
1446
|
-
} else {
|
|
1447
|
-
entity.polygon.hierarchy = void 0;
|
|
1448
|
-
entity.polyline.positions = void 0;
|
|
1923
|
+
//#region scheme/Polyline.ts
|
|
1924
|
+
const PlotSchemePolyline = new PlotScheme({
|
|
1925
|
+
type: "Polyline",
|
|
1926
|
+
allowManualComplete: (packable) => packable.positions.length > 1,
|
|
1927
|
+
skeletons: [
|
|
1928
|
+
moved,
|
|
1929
|
+
control,
|
|
1930
|
+
intervalNonclosed
|
|
1931
|
+
],
|
|
1932
|
+
initRender() {
|
|
1933
|
+
return { entities: [new cesium.Entity({ polyline: {
|
|
1934
|
+
material: cesium.Color.RED,
|
|
1935
|
+
width: 2
|
|
1936
|
+
} })] };
|
|
1937
|
+
},
|
|
1938
|
+
render(context) {
|
|
1939
|
+
const entity = context.previous.entities[0];
|
|
1940
|
+
const positions = [...context.packable.positions];
|
|
1941
|
+
const mouse = context.mouse;
|
|
1942
|
+
mouse && positions.push(mouse.clone());
|
|
1943
|
+
const cache = positions.length >= 2 ? positions : [];
|
|
1944
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => cache, false);
|
|
1945
|
+
return { entities: [entity] };
|
|
1449
1946
|
}
|
|
1450
|
-
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1947
|
+
});
|
|
1453
1948
|
|
|
1454
1949
|
//#endregion
|
|
1455
|
-
//#region scheme/
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const positions = [...packable.positions
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1950
|
+
//#region scheme/PolylineCurve.ts
|
|
1951
|
+
const PlotSchemePolylineCurve = new PlotScheme({
|
|
1952
|
+
type: "PolylineCurve",
|
|
1953
|
+
allowManualComplete: (packable) => packable.positions.length > 1,
|
|
1954
|
+
skeletons: [
|
|
1955
|
+
moved,
|
|
1956
|
+
control,
|
|
1957
|
+
intervalNonclosed
|
|
1958
|
+
],
|
|
1959
|
+
initRender() {
|
|
1960
|
+
return { entities: [new cesium.Entity({ polyline: {
|
|
1961
|
+
material: cesium.Color.RED,
|
|
1962
|
+
width: 2
|
|
1963
|
+
} })] };
|
|
1964
|
+
},
|
|
1965
|
+
render(context) {
|
|
1966
|
+
const entity = context.previous.entities[0];
|
|
1967
|
+
const positions = [...context.packable.positions];
|
|
1968
|
+
const mouse = context.mouse;
|
|
1969
|
+
mouse && positions.push(mouse.clone());
|
|
1970
|
+
if (positions.length < 2) {
|
|
1971
|
+
entity.polyline.positions = void 0;
|
|
1972
|
+
return context.previous;
|
|
1973
|
+
}
|
|
1974
|
+
const coords = positions.map((position) => (0, vesium.toCoord)(position));
|
|
1975
|
+
const { geometry: { coordinates } } = __turf_turf.bezierSpline(__turf_turf.lineString(coords));
|
|
1976
|
+
entity.polyline.positions = new cesium.CallbackProperty(() => coordinates.map(vesium.toCartesian3), false);
|
|
1977
|
+
return { entities: [entity] };
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1478
1980
|
|
|
1479
1981
|
//#endregion
|
|
1480
|
-
//#region scheme/
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
});
|
|
1982
|
+
//#region scheme/Rectangle.ts
|
|
1983
|
+
const PlotSchemeRectangle = new PlotScheme({
|
|
1984
|
+
type: "Rectangle",
|
|
1985
|
+
complete: (packable) => packable.positions.length >= 2,
|
|
1986
|
+
skeletons: [moved, control],
|
|
1987
|
+
initRender() {
|
|
1988
|
+
return { entities: [new cesium.Entity({ rectangle: {} })] };
|
|
1989
|
+
},
|
|
1990
|
+
render(context) {
|
|
1991
|
+
const entity = context.previous.entities[0];
|
|
1992
|
+
const positions = [...context.packable.positions];
|
|
1993
|
+
const mouse = context.mouse;
|
|
1994
|
+
mouse && positions.push(mouse.clone());
|
|
1995
|
+
if (positions.length < 2) {
|
|
1996
|
+
entity.rectangle.coordinates = void 0;
|
|
1997
|
+
return context.previous;
|
|
1998
|
+
}
|
|
1999
|
+
const coordinates = cesium.Rectangle.fromCartesianArray(positions ?? []);
|
|
2000
|
+
entity.rectangle.coordinates = new cesium.CallbackProperty(() => coordinates, false);
|
|
2001
|
+
return { entities: [entity] };
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
1503
2004
|
|
|
1504
2005
|
//#endregion
|
|
1505
2006
|
exports.PlotAction = PlotAction;
|
|
1506
2007
|
exports.PlotFeature = PlotFeature;
|
|
1507
2008
|
exports.PlotScheme = PlotScheme;
|
|
2009
|
+
exports.PlotSchemeBillboard = PlotSchemeBillboard;
|
|
2010
|
+
exports.PlotSchemeBillboardPinBuilder = PlotSchemeBillboardPinBuilder;
|
|
2011
|
+
exports.PlotSchemeCylinder = PlotSchemeCylinder;
|
|
2012
|
+
exports.PlotSchemeEllipse = PlotSchemeEllipse;
|
|
2013
|
+
exports.PlotSchemeLabel = PlotSchemeLabel;
|
|
2014
|
+
exports.PlotSchemePoint = PlotSchemePoint;
|
|
2015
|
+
exports.PlotSchemePolygon = PlotSchemePolygon;
|
|
2016
|
+
exports.PlotSchemePolygonArc = PlotSchemePolygonArc;
|
|
2017
|
+
exports.PlotSchemePolygonArrowAttackDirection = PlotSchemePolygonArrowAttackDirection;
|
|
2018
|
+
exports.PlotSchemePolygonArrowAttackDirectionTailed = PlotSchemePolygonArrowAttackDirectionTailed;
|
|
2019
|
+
exports.PlotSchemePolygonArrowClamped = PlotSchemePolygonArrowClamped;
|
|
2020
|
+
exports.PlotSchemePolygonArrowStraight = PlotSchemePolygonArrowStraight;
|
|
2021
|
+
exports.PlotSchemePolygonArrowStraightSharp = PlotSchemePolygonArrowStraightSharp;
|
|
2022
|
+
exports.PlotSchemePolygonArrowUnitCombatOperation = PlotSchemePolygonArrowUnitCombatOperation;
|
|
2023
|
+
exports.PlotSchemePolygonArrowUnitCombatOperationTailed = PlotSchemePolygonArrowUnitCombatOperationTailed;
|
|
2024
|
+
exports.PlotSchemePolygonAssemblingPlace = PlotSchemePolygonAssemblingPlace;
|
|
2025
|
+
exports.PlotSchemePolygonSmooth = PlotSchemePolygonSmooth;
|
|
2026
|
+
exports.PlotSchemePolyline = PlotSchemePolyline;
|
|
2027
|
+
exports.PlotSchemePolylineCurve = PlotSchemePolylineCurve;
|
|
2028
|
+
exports.PlotSchemeRectangle = PlotSchemeRectangle;
|
|
1508
2029
|
exports.PlotSkeletonEntity = PlotSkeletonEntity;
|
|
1509
2030
|
exports.SampledPlotProperty = SampledPlotProperty;
|
|
1510
2031
|
exports.SampledPlotStrategy = SampledPlotStrategy;
|
|
@@ -1512,12 +2033,8 @@ exports.control = control;
|
|
|
1512
2033
|
exports.interval = interval;
|
|
1513
2034
|
exports.intervalNonclosed = intervalNonclosed;
|
|
1514
2035
|
exports.moved = moved;
|
|
1515
|
-
exports.schemeBillboard = schemeBillboard;
|
|
1516
|
-
exports.schemeLabel = schemeLabel;
|
|
1517
2036
|
exports.schemeMeasureArea = schemeMeasureArea;
|
|
1518
|
-
exports.
|
|
1519
|
-
exports.schemePolyline = schemePolyline;
|
|
1520
|
-
exports.schemeRectangle = schemeRectangle;
|
|
2037
|
+
exports.schemeMeasureDistance = schemeMeasureDistance;
|
|
1521
2038
|
exports.usePlot = usePlot;
|
|
1522
|
-
})(this.Vesium = this.Vesium || {}, Cesium, Vesium, VueUse, Vue);
|
|
2039
|
+
})(this.Vesium = this.Vesium || {}, Cesium, Vesium, VueUse, Vue, Vesium, turf);
|
|
1523
2040
|
//# sourceMappingURL=index.iife.js.map
|