@vesium/plot 1.0.1-beta.52 → 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 +97 -1117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -53
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -53
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1811 -2837
- 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 +88 -1112
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.iife.js
CHANGED
|
@@ -1,3029 +1,2006 @@
|
|
|
1
|
-
(function(exports, cesium, vesium, __vueuse_core, vue, __turf_turf) {
|
|
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);
|
|
30
31
|
__turf_turf = __toESM(__turf_turf);
|
|
31
32
|
|
|
32
33
|
//#region usePlot/PlotScheme.ts
|
|
33
|
-
var PlotScheme = class PlotScheme {
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
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
|
+
};
|
|
109
110
|
|
|
110
111
|
//#endregion
|
|
111
112
|
//#region usePlot/SampledPlotProperty.ts
|
|
112
|
-
let SampledPlotStrategy = /* @__PURE__ */ function(SampledPlotStrategy$1) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}({});
|
|
118
|
-
/**
|
|
119
|
-
* 默认插值算法
|
|
120
|
-
*
|
|
121
|
-
* @param time 时间
|
|
122
|
-
* @param previous 前一个数据点
|
|
123
|
-
* @param next 后一个数据点
|
|
124
|
-
* @param proportion 比例
|
|
125
|
-
* @returns 插值结果
|
|
126
|
-
*/
|
|
127
|
-
const defaultInterpolationAlgorithm = (time, previous, next, proportion) => {
|
|
128
|
-
if (proportion === 0) return {
|
|
129
|
-
time,
|
|
130
|
-
positions: previous.positions?.map((item) => item.clone()),
|
|
131
|
-
derivative: previous.derivative
|
|
132
|
-
};
|
|
133
|
-
else if (proportion === 1) return {
|
|
134
|
-
time,
|
|
135
|
-
positions: next.positions?.map((item) => item.clone()),
|
|
136
|
-
derivative: previous.derivative
|
|
137
|
-
};
|
|
138
|
-
return {
|
|
139
|
-
time,
|
|
140
|
-
positions: next.positions?.map((right, index) => {
|
|
141
|
-
const left = previous.positions?.[index];
|
|
142
|
-
return !left ? right : cesium.Cartesian3.lerp(left, right, proportion, new cesium.Cartesian3());
|
|
143
|
-
}),
|
|
144
|
-
derivative: previous.derivative
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* 标绘采样点数据。
|
|
149
|
-
* 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
|
|
150
|
-
* 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
|
|
151
|
-
*/
|
|
152
|
-
var SampledPlotProperty = class SampledPlotProperty {
|
|
153
|
-
constructor(options) {
|
|
154
|
-
this.interpolationAlgorithm = options?.interpolationAlgorithm;
|
|
155
|
-
this.strategy = options?.strategy ?? SampledPlotStrategy.NEAR;
|
|
156
|
-
options?.packables?.forEach((packable) => this.setSample(packable));
|
|
157
|
-
if (!this._times.length) this.setSample({
|
|
158
|
-
time: new cesium.JulianDate(0, 0),
|
|
159
|
-
positions: [],
|
|
160
|
-
derivative: void 0
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
static defaultInterpolationAlgorithm = defaultInterpolationAlgorithm;
|
|
164
|
-
strategy;
|
|
165
|
-
interpolationAlgorithm;
|
|
166
|
-
/**
|
|
167
|
-
* @internal
|
|
168
|
-
*/
|
|
169
|
-
_times = [];
|
|
170
|
-
/**
|
|
171
|
-
* @internal
|
|
172
|
-
*/
|
|
173
|
-
_sampleds = [];
|
|
174
|
-
/**
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
_derivatives = [];
|
|
178
|
-
get isConstant() {
|
|
179
|
-
return this._times.length === 0;
|
|
180
|
-
}
|
|
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
|
+
}({});
|
|
181
119
|
/**
|
|
182
|
-
*
|
|
183
|
-
*/
|
|
184
|
-
_definitionChanged = new cesium.Event();
|
|
185
|
-
get definitionChanged() {
|
|
186
|
-
return this._definitionChanged;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* 获取时间数组
|
|
120
|
+
* 默认插值算法
|
|
190
121
|
*
|
|
191
|
-
* @
|
|
122
|
+
* @param time 时间
|
|
123
|
+
* @param previous 前一个数据点
|
|
124
|
+
* @param next 后一个数据点
|
|
125
|
+
* @param proportion 比例
|
|
126
|
+
* @returns 插值结果
|
|
192
127
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* 根据给定的儒略日期获取时间索引范围及比例
|
|
198
|
-
*
|
|
199
|
-
* @param time 给定的儒略日期
|
|
200
|
-
* @returns 返回包含前一个索引、后一个索引及时间比例的对象,若不符合条件则返回undefined
|
|
201
|
-
* @internal
|
|
202
|
-
*/
|
|
203
|
-
getIndexScope(time) {
|
|
204
|
-
if (!this._times.length) return;
|
|
205
|
-
const start = this._times[0];
|
|
206
|
-
const end = this._times[this._times.length - 1];
|
|
207
|
-
if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
|
|
208
|
-
case SampledPlotStrategy.STRICT: return;
|
|
209
|
-
case SampledPlotStrategy.NEAR: {
|
|
210
|
-
time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
case SampledPlotStrategy.CYCLE: {
|
|
214
|
-
const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
|
|
215
|
-
const endMS = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime();
|
|
216
|
-
const duration = endMS - startMS;
|
|
217
|
-
const timeMS = cesium.JulianDate.toDate(time).getTime();
|
|
218
|
-
const diff = (timeMS - startMS) % duration;
|
|
219
|
-
const dete = new Date(startMS + diff);
|
|
220
|
-
time = cesium.JulianDate.fromDate(dete);
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const prevIndex = this._times.findIndex((t) => cesium.JulianDate.lessThanOrEquals(time, t));
|
|
225
|
-
const nextIndex = Math.min(prevIndex, this._times.length - 1);
|
|
226
|
-
const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
|
|
227
|
-
const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
|
|
228
|
-
const ms = cesium.JulianDate.toDate(time).getTime();
|
|
229
|
-
return {
|
|
230
|
-
prevIndex,
|
|
231
|
-
nextIndex,
|
|
232
|
-
proportion: (ms - prevMs) / (nextMs - prevMs) || 0
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* 根据给定的儒略日期(JulianDate)获取插值后的样本点数据。
|
|
237
|
-
*
|
|
238
|
-
* @param time 指定的儒略日期(JulianDate)。
|
|
239
|
-
* @param result 可选参数,用于存储结果的容器。如果未提供,则创建一个新的容器。
|
|
240
|
-
* @returns 插值后的样本点数据,存储在提供的或新创建的result容器中。
|
|
241
|
-
* @template D 数据类型。
|
|
242
|
-
*/
|
|
243
|
-
getValue(time, result) {
|
|
244
|
-
result ??= {
|
|
128
|
+
const defaultInterpolationAlgorithm = (time, previous, next, proportion) => {
|
|
129
|
+
if (proportion === 0) return {
|
|
245
130
|
time,
|
|
246
|
-
positions:
|
|
131
|
+
positions: previous.positions?.map((item) => item.clone()),
|
|
132
|
+
derivative: previous.derivative
|
|
247
133
|
};
|
|
248
|
-
|
|
249
|
-
time
|
|
250
|
-
positions:
|
|
251
|
-
derivative:
|
|
252
|
-
});
|
|
253
|
-
if (!time) {
|
|
254
|
-
result.time = this._times[0].clone();
|
|
255
|
-
result.positions = this._sampleds[0]?.map((c) => c.clone(c));
|
|
256
|
-
result.derivative = this._derivatives[0];
|
|
257
|
-
return result;
|
|
258
|
-
}
|
|
259
|
-
const scope = this.getIndexScope(time);
|
|
260
|
-
if (!scope) return result;
|
|
261
|
-
result.time = time;
|
|
262
|
-
const { prevIndex, nextIndex, proportion } = scope;
|
|
263
|
-
const previous = {
|
|
264
|
-
time: this._times[prevIndex],
|
|
265
|
-
positions: this._sampleds[prevIndex],
|
|
266
|
-
derivative: this._derivatives[prevIndex]
|
|
134
|
+
else if (proportion === 1) return {
|
|
135
|
+
time,
|
|
136
|
+
positions: next.positions?.map((item) => item.clone()),
|
|
137
|
+
derivative: previous.derivative
|
|
267
138
|
};
|
|
268
|
-
|
|
269
|
-
time
|
|
270
|
-
positions:
|
|
271
|
-
|
|
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
|
|
272
146
|
};
|
|
273
|
-
|
|
274
|
-
Object.assign(result, packable);
|
|
275
|
-
return result;
|
|
276
|
-
}
|
|
147
|
+
};
|
|
277
148
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
149
|
+
* 标绘采样点数据。
|
|
150
|
+
* 标绘采样点数据是一个时间序列数据,包含时间、位置和附带的额外数据。
|
|
151
|
+
* 具体用法可参考 [Cesium.SampledProperty](https://cesium.com/learn/cesiumjs/ref-doc/SampledProperty.html)
|
|
280
152
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this._times[0] = time;
|
|
292
|
-
this._sampleds[0] = positions;
|
|
293
|
-
this._derivatives[0] = value.derivative;
|
|
294
|
-
} else if (cesium.JulianDate.lessThan(time, this._times[0])) {
|
|
295
|
-
this._times.splice(0, 0, time);
|
|
296
|
-
this._sampleds.splice(0, 0, positions);
|
|
297
|
-
this._derivatives.splice(0, 0, derivative);
|
|
298
|
-
} else if (cesium.JulianDate.greaterThan(time, this._times[this._times.length - 1])) {
|
|
299
|
-
this._times.push(time);
|
|
300
|
-
this._sampleds.push(positions);
|
|
301
|
-
this._derivatives.push(derivative);
|
|
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
|
+
});
|
|
302
163
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
+
}
|
|
328
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
|
+
};
|
|
329
231
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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;
|
|
341
273
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
+
};
|
|
350
346
|
|
|
351
347
|
//#endregion
|
|
352
348
|
//#region usePlot/PlotFeature.ts
|
|
353
349
|
/**
|
|
354
|
-
* 标绘实例
|
|
355
|
-
*/
|
|
356
|
-
var PlotFeature = class {
|
|
357
|
-
constructor(options) {
|
|
358
|
-
const { id, disabled = false, sampled } = options;
|
|
359
|
-
this._id = id || (0, cesium.createGuid)();
|
|
360
|
-
this._scheme = PlotScheme.resolve(options.scheme);
|
|
361
|
-
this._definitionChanged = new cesium.Event();
|
|
362
|
-
this._defining = true;
|
|
363
|
-
this._disabled = disabled;
|
|
364
|
-
this._sampled = sampled instanceof SampledPlotProperty ? sampled : new SampledPlotProperty(sampled);
|
|
365
|
-
this._sampled.definitionChanged.addEventListener((property) => this._definitionChanged.raiseEvent(this, "sampled", property, property), this);
|
|
366
|
-
const init = this._scheme.initRender?.() ?? {};
|
|
367
|
-
this._entities = [...init.entities ?? []];
|
|
368
|
-
this._primitives = [...init.primitives ?? []];
|
|
369
|
-
this._groundPrimitives = [...init.groundPrimitives ?? []];
|
|
370
|
-
this._skeletons = [];
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* @internal
|
|
350
|
+
* 标绘实例
|
|
374
351
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
get definitionChanged() {
|
|
391
|
-
return this._definitionChanged;
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* @internal
|
|
395
|
-
*/
|
|
396
|
-
_defining;
|
|
397
|
-
get defining() {
|
|
398
|
-
return this._defining;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* @internal
|
|
402
|
-
*/
|
|
403
|
-
static setDefining(plot, value) {
|
|
404
|
-
if (plot._defining !== value) {
|
|
405
|
-
plot._definitionChanged.raiseEvent(plot, "defining", value, plot._defining);
|
|
406
|
-
plot._defining = value;
|
|
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 = [];
|
|
407
367
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
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
|
+
}
|
|
481
|
+
};
|
|
486
482
|
|
|
487
483
|
//#endregion
|
|
488
484
|
//#region usePlot/PlotSkeleton.ts
|
|
489
485
|
/**
|
|
490
|
-
* 框架点执行状态枚举
|
|
491
|
-
* - IDLE 空闲状态
|
|
492
|
-
* - HOVER 悬停状态
|
|
493
|
-
* - ACTIVE 激活状态
|
|
494
|
-
*/
|
|
495
|
-
let PlotAction = /* @__PURE__ */ function(PlotAction$1) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}({});
|
|
501
|
-
/**
|
|
502
|
-
* 标绘框架点 Entity
|
|
503
|
-
*/
|
|
504
|
-
var PlotSkeletonEntity = class extends cesium.Entity {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
};
|
|
486
|
+
* 框架点执行状态枚举
|
|
487
|
+
* - IDLE 空闲状态
|
|
488
|
+
* - HOVER 悬停状态
|
|
489
|
+
* - ACTIVE 激活状态
|
|
490
|
+
*/
|
|
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
|
+
}({});
|
|
497
|
+
/**
|
|
498
|
+
* 标绘框架点 Entity
|
|
499
|
+
*/
|
|
500
|
+
var PlotSkeletonEntity = class extends cesium.Entity {
|
|
501
|
+
constructor(options) {
|
|
502
|
+
super(options);
|
|
503
|
+
}
|
|
504
|
+
};
|
|
509
505
|
|
|
510
506
|
//#endregion
|
|
511
507
|
//#region usePlot/useRender.ts
|
|
512
|
-
function useRender(plots, current, getCurrentTime) {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
});
|
|
524
|
-
(0, __vueuse_core.watchArray)(plots, (_value, _oldValue, added, removed = []) => {
|
|
525
|
-
removed.forEach((plot) => {
|
|
526
|
-
entityScope.removeWhere((item) => plot.entities.includes(item));
|
|
527
|
-
primitiveScope.removeWhere((item) => plot.primitives.includes(item));
|
|
528
|
-
groundPrimitiveScope.removeWhere((item) => plot.groundPrimitives.includes(item));
|
|
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);
|
|
529
519
|
});
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
534
|
});
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
} else if (key === "groundPrimitives") {
|
|
549
|
-
const { added, removed } = (0, vesium.arrayDiff)(newValue, oldValue);
|
|
550
|
-
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
551
|
-
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
const update = async (plot) => {
|
|
555
|
-
const reslut = await plot.scheme.render?.({
|
|
556
|
-
packable: plot.sampled.getValue(getCurrentTime()),
|
|
557
|
-
mouse: plot.defining ? mouseCartesian.value : void 0,
|
|
558
|
-
defining: plot.defining,
|
|
559
|
-
previous: {
|
|
560
|
-
entities: plot.entities,
|
|
561
|
-
primitives: plot.primitives,
|
|
562
|
-
groundPrimitives: plot.groundPrimitives
|
|
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));
|
|
563
548
|
}
|
|
564
549
|
});
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
+
});
|
|
588
|
+
return {
|
|
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))
|
|
592
|
+
};
|
|
593
|
+
}
|
|
590
594
|
|
|
591
595
|
//#endregion
|
|
592
596
|
//#region usePlot/useSampled.ts
|
|
593
|
-
function useSampled(current, getCurrentTime) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
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());
|
|
602
|
+
});
|
|
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);
|
|
640
646
|
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
(0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
|
|
648
|
-
if (key === "defining" || key === "sampled") setDefiningCursorCss();
|
|
649
|
-
});
|
|
650
|
-
(0, vue.watch)(current, () => setDefiningCursorCss());
|
|
651
|
-
}
|
|
647
|
+
};
|
|
648
|
+
(0, vesium.useCesiumEventListener)(() => current.value?.definitionChanged, (plot, key) => {
|
|
649
|
+
if (key === "defining" || key === "sampled") setDefiningCursorCss();
|
|
650
|
+
});
|
|
651
|
+
(0, vue.watch)(current, () => setDefiningCursorCss());
|
|
652
|
+
}
|
|
652
653
|
|
|
653
654
|
//#endregion
|
|
654
655
|
//#region usePlot/useSkeleton.ts
|
|
655
|
-
function useSkeleton(plots, current, getCurrentTime) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const disabled = (0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
|
|
676
|
-
active,
|
|
677
|
-
defining
|
|
678
|
-
}) : skeleton.disabled;
|
|
679
|
-
if (disabled) return;
|
|
680
|
-
const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
|
|
681
|
-
positions.forEach((position, index) => {
|
|
682
|
-
let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
|
|
683
|
-
const options = skeleton.render?.({
|
|
684
|
-
defining,
|
|
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({
|
|
685
676
|
active,
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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);
|
|
691
700
|
});
|
|
692
|
-
const merge = new PlotSkeletonEntity(options ?? {});
|
|
693
|
-
if (entity) merge.propertyNames.forEach((key) => {
|
|
694
|
-
if (key !== "id") entity[key] = merge[key];
|
|
695
|
-
});
|
|
696
|
-
else entity = merge;
|
|
697
|
-
entity.plot = plot;
|
|
698
|
-
entity.skeleton = skeleton;
|
|
699
|
-
entity.index = index;
|
|
700
|
-
entities.push(entity);
|
|
701
701
|
});
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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;
|
|
711
745
|
const plot = entity.plot;
|
|
712
|
-
if (plot.defining) return;
|
|
713
|
-
activeEntity.value = entity;
|
|
714
746
|
const skeleton = entity.skeleton;
|
|
715
747
|
const index = entity.index;
|
|
716
748
|
const packable = plot.sampled.getValue(getCurrentTime());
|
|
717
|
-
skeleton.
|
|
749
|
+
skeleton.onKeyPressed?.({
|
|
718
750
|
viewer: viewer.value,
|
|
719
751
|
sampled: plot.sampled,
|
|
720
752
|
packable,
|
|
721
|
-
active: current.value === plot,
|
|
722
753
|
index,
|
|
723
|
-
|
|
724
|
-
dragging,
|
|
725
|
-
lockCamera
|
|
754
|
+
keyEvent
|
|
726
755
|
});
|
|
727
|
-
} else activeEntity.value = void 0;
|
|
728
|
-
}, {
|
|
729
|
-
cursor: ({ pick }) => {
|
|
730
|
-
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
731
|
-
const skeleton = pick.id.skeleton;
|
|
732
|
-
return (0, vesium.isFunction)(skeleton?.cursor) ? skeleton.cursor(pick) : (0, vue.toValue)(skeleton?.cursor);
|
|
733
|
-
}
|
|
734
|
-
},
|
|
735
|
-
dragCursor: ({ pick }) => {
|
|
736
|
-
if (!current.value?.defining && entityScope.scope.has(pick.id)) {
|
|
737
|
-
const skeleton = pick.id.skeleton;
|
|
738
|
-
return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
|
|
739
|
-
}
|
|
740
756
|
}
|
|
741
757
|
});
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
const plot = entity.plot;
|
|
748
|
-
const skeleton = entity.skeleton;
|
|
749
|
-
const index = entity.index;
|
|
750
|
-
const packable = plot.sampled.getValue(getCurrentTime());
|
|
751
|
-
skeleton.onKeyPressed?.({
|
|
752
|
-
viewer: viewer.value,
|
|
753
|
-
sampled: plot.sampled,
|
|
754
|
-
packable,
|
|
755
|
-
index,
|
|
756
|
-
keyEvent
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
(0, vue.watchEffect)((onCleanup) => {
|
|
761
|
-
const remove = addGraphicEvent("global", "HOVER", ({ hovering, pick }) => {
|
|
762
|
-
if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
763
|
-
const entity = pick.id;
|
|
764
|
-
hoverEntity.value = entity;
|
|
765
|
-
} else hoverEntity.value = void 0;
|
|
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
|
+
}));
|
|
766
763
|
});
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
} else activeEntity.value = void 0;
|
|
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
|
+
}));
|
|
788
784
|
});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
"
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}
|
|
813
|
-
return { dataSource };
|
|
814
|
-
}
|
|
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 };
|
|
808
|
+
}
|
|
815
809
|
|
|
816
810
|
//#endregion
|
|
817
811
|
//#region usePlot/usePlot.ts
|
|
818
|
-
function usePlot(options) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}
|
|
842
|
-
current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
|
|
843
|
-
...plot.entities,
|
|
844
|
-
...plot.primitives,
|
|
845
|
-
...plot.groundPrimitives
|
|
846
|
-
]));
|
|
847
|
-
});
|
|
848
|
-
let operateResolve;
|
|
849
|
-
let operateReject;
|
|
850
|
-
(0, vue.watch)(current, (plot, previous) => {
|
|
851
|
-
if (previous) {
|
|
852
|
-
if (previous.defining) {
|
|
853
|
-
const packable$1 = previous.sampled.getValue(getCurrentTime());
|
|
854
|
-
const completed = previous.scheme.allowManualComplete?.(packable$1);
|
|
855
|
-
if (completed) {
|
|
856
|
-
PlotFeature.setDefining(previous, false);
|
|
857
|
-
operateResolve?.(previous);
|
|
858
|
-
} else collection.delete(previous);
|
|
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;
|
|
859
835
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
operateReject = reject;
|
|
866
|
-
const _plot = plot instanceof PlotFeature ? plot : new PlotFeature(plot);
|
|
867
|
-
if (!collection.has(_plot)) collection.add(_plot);
|
|
868
|
-
current.value = _plot;
|
|
869
|
-
return resolve(_plot);
|
|
836
|
+
current.value = plots.value.find((plot) => (0, vesium.pickHitGraphic)(pick, [
|
|
837
|
+
...plot.entities,
|
|
838
|
+
...plot.primitives,
|
|
839
|
+
...plot.groundPrimitives
|
|
840
|
+
]));
|
|
870
841
|
});
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
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);
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
};
|
|
873
|
+
return {
|
|
874
|
+
plots,
|
|
875
|
+
time,
|
|
876
|
+
operate,
|
|
877
|
+
remove,
|
|
878
|
+
cancel: operateReject
|
|
879
|
+
};
|
|
880
|
+
}
|
|
888
881
|
|
|
889
882
|
//#endregion
|
|
890
883
|
//#region skeleton/control.ts
|
|
891
884
|
/**
|
|
892
|
-
* 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
|
|
893
|
-
*/
|
|
894
|
-
function control() {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
885
|
+
* 绘制控制的框架点,拖拽时,将更新该控制点的实时位置
|
|
886
|
+
*/
|
|
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);
|
|
903
930
|
const positions = [...packable.positions ?? []];
|
|
904
|
-
positions[index]
|
|
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);
|
|
905
936
|
sampled.setSample({
|
|
906
937
|
time: packable.time,
|
|
907
938
|
derivative: packable.derivative,
|
|
908
939
|
positions
|
|
909
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
|
+
};
|
|
910
957
|
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
const height = (0, vesium.toCartographic)(viewer.camera.position)?.height;
|
|
914
|
-
if (!height || ![
|
|
915
|
-
"ArrowUp",
|
|
916
|
-
"ArrowRight",
|
|
917
|
-
"ArrowDown",
|
|
918
|
-
"ArrowLeft"
|
|
919
|
-
].includes(keyEvent.key)) return;
|
|
920
|
-
keyEvent.preventDefault();
|
|
921
|
-
let headingAdjust = 0;
|
|
922
|
-
switch (keyEvent.key) {
|
|
923
|
-
case "ArrowRight":
|
|
924
|
-
headingAdjust = Math.PI / 2;
|
|
925
|
-
break;
|
|
926
|
-
case "ArrowDown":
|
|
927
|
-
headingAdjust = Math.PI;
|
|
928
|
-
break;
|
|
929
|
-
case "ArrowLeft":
|
|
930
|
-
headingAdjust = -Math.PI / 2;
|
|
931
|
-
break;
|
|
932
|
-
case "ArrowUp":
|
|
933
|
-
headingAdjust = 0;
|
|
934
|
-
break;
|
|
935
|
-
}
|
|
936
|
-
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
937
|
-
const positions = [...packable.positions ?? []];
|
|
938
|
-
const cartographic = (0, vesium.toCartographic)(positions[index]);
|
|
939
|
-
const r = height / 1e5;
|
|
940
|
-
const distance$1 = r * Math.PI / 180 / 1e3;
|
|
941
|
-
cartographic.latitude += distance$1 * Math.cos(newHeading);
|
|
942
|
-
cartographic.longitude += distance$1 * Math.sin(newHeading);
|
|
943
|
-
positions[index] = (0, vesium.toCartesian3)(cartographic);
|
|
944
|
-
sampled.setSample({
|
|
945
|
-
time: packable.time,
|
|
946
|
-
derivative: packable.derivative,
|
|
947
|
-
positions
|
|
948
|
-
});
|
|
949
|
-
},
|
|
950
|
-
render: ({ position, action }) => {
|
|
951
|
-
const colors = {
|
|
952
|
-
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
953
|
-
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
954
|
-
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
955
|
-
};
|
|
956
|
-
return {
|
|
957
|
-
position,
|
|
958
|
-
point: {
|
|
959
|
-
pixelSize: 8,
|
|
960
|
-
color: colors[action],
|
|
961
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
962
|
-
outlineWidth: 1,
|
|
963
|
-
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
964
|
-
}
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
969
960
|
|
|
970
961
|
//#endregion
|
|
971
962
|
//#region skeleton/interval.ts
|
|
972
963
|
/**
|
|
973
|
-
* 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
974
|
-
*/
|
|
975
|
-
function interval() {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
//#endregion
|
|
1027
|
-
//#region skeleton/intervalNonclosed.ts
|
|
1028
|
-
/**
|
|
1029
|
-
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1030
|
-
*/
|
|
1031
|
-
function intervalNonclosed() {
|
|
1032
|
-
let dragIndex = -1;
|
|
1033
|
-
return {
|
|
1034
|
-
disabled: ({ active, defining }) => !active || defining,
|
|
1035
|
-
cursor: "pointer",
|
|
1036
|
-
dragCursor: "crosshair",
|
|
1037
|
-
format(packable) {
|
|
1038
|
-
const _positions = packable.positions ?? [];
|
|
1039
|
-
if (_positions.length < 2) return [];
|
|
1040
|
-
const midpoints = [];
|
|
1041
|
-
for (let i = 0; i < _positions.length - 1; i++) midpoints.push(cesium.Cartesian3.midpoint(_positions[i], _positions[i + 1], new cesium.Cartesian3()));
|
|
1042
|
-
return midpoints;
|
|
1043
|
-
},
|
|
1044
|
-
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1045
|
-
lockCamera();
|
|
1046
|
-
const position = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1047
|
-
if (!position) return;
|
|
1048
|
-
const positions = [...packable.positions ?? []];
|
|
1049
|
-
if (dragIndex === -1) {
|
|
1050
|
-
dragIndex = index;
|
|
1051
|
-
positions.splice(index + 1, 0, position);
|
|
1052
|
-
} else positions[dragIndex + 1] = position;
|
|
1053
|
-
if (!dragging) dragIndex = -1;
|
|
1054
|
-
sampled.setSample({
|
|
1055
|
-
time: packable.time,
|
|
1056
|
-
derivative: packable.derivative,
|
|
1057
|
-
positions
|
|
1058
|
-
});
|
|
1059
|
-
},
|
|
1060
|
-
render: ({ position, action }) => {
|
|
1061
|
-
const colors = {
|
|
1062
|
-
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1063
|
-
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1064
|
-
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1065
|
-
};
|
|
1066
|
-
return {
|
|
1067
|
-
position,
|
|
1068
|
-
point: {
|
|
1069
|
-
pixelSize: 6,
|
|
1070
|
-
color: colors[action],
|
|
1071
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1072
|
-
outlineWidth: 1,
|
|
1073
|
-
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
//#endregion
|
|
1081
|
-
//#region skeleton/moved.ts
|
|
1082
|
-
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>")}`;
|
|
1083
|
-
/**
|
|
1084
|
-
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1085
|
-
*/
|
|
1086
|
-
function moved() {
|
|
1087
|
-
return {
|
|
1088
|
-
disabled: ({ active, defining }) => !active || defining,
|
|
1089
|
-
cursor: "pointer",
|
|
1090
|
-
dragCursor: "crosshair",
|
|
1091
|
-
format(packable) {
|
|
1092
|
-
const positions = packable.positions ?? [];
|
|
1093
|
-
if (positions.length === 0) return [];
|
|
1094
|
-
else if (positions.length === 1) return [positions[0]];
|
|
1095
|
-
else {
|
|
1096
|
-
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1097
|
-
return [(0, vesium.toCartesian3)(center)];
|
|
964
|
+
* 绘制封闭的间隔框架点,如多边形。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
965
|
+
*/
|
|
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
|
+
};
|
|
1098
1012
|
}
|
|
1099
|
-
}
|
|
1100
|
-
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1101
|
-
dragging && lockCamera();
|
|
1102
|
-
const startPosition = (0, vesium.canvasCoordToCartesian)(event.startPosition, viewer.scene);
|
|
1103
|
-
const endPosition = (0, vesium.canvasCoordToCartesian)(event.endPosition, viewer.scene);
|
|
1104
|
-
if (!startPosition || !endPosition) return;
|
|
1105
|
-
const offset = cesium.Cartesian3.subtract(endPosition, startPosition, new cesium.Cartesian3());
|
|
1106
|
-
const positions = [...packable.positions ?? []];
|
|
1107
|
-
sampled.setSample({
|
|
1108
|
-
time: packable.time,
|
|
1109
|
-
derivative: packable.derivative,
|
|
1110
|
-
positions: positions.map((position) => cesium.Cartesian3.add(position, offset, new cesium.Cartesian3()))
|
|
1111
|
-
});
|
|
1112
|
-
},
|
|
1113
|
-
render: ({ position, action }) => {
|
|
1114
|
-
const colors = {
|
|
1115
|
-
[PlotAction.IDLE]: cesium.Color.WHITE,
|
|
1116
|
-
[PlotAction.HOVER]: cesium.Color.WHITE,
|
|
1117
|
-
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
1118
|
-
};
|
|
1119
|
-
return {
|
|
1120
|
-
position,
|
|
1121
|
-
billboard: {
|
|
1122
|
-
image: svg,
|
|
1123
|
-
width: 20,
|
|
1124
|
-
height: 20,
|
|
1125
|
-
color: colors[action],
|
|
1126
|
-
pixelOffset: new cesium.Cartesian3(0, -20),
|
|
1127
|
-
horizontalOrigin: cesium.HorizontalOrigin.CENTER,
|
|
1128
|
-
verticalOrigin: cesium.VerticalOrigin.BOTTOM,
|
|
1129
|
-
disableDepthTestDistance: Number.POSITIVE_INFINITY
|
|
1130
|
-
}
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
//#endregion
|
|
1137
|
-
//#region measure/utils/tesselate.ts
|
|
1138
|
-
/**
|
|
1139
|
-
* 将多个边界点组成的面切割成多个三角形
|
|
1140
|
-
* @param positions
|
|
1141
|
-
*/
|
|
1142
|
-
function tesselate(positions) {
|
|
1143
|
-
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1144
|
-
if (positions.length === 3) return [[
|
|
1145
|
-
positions[0].clone(),
|
|
1146
|
-
positions[1].clone(),
|
|
1147
|
-
positions[2].clone()
|
|
1148
|
-
]];
|
|
1149
|
-
const geometry = cesium.CoplanarPolygonGeometry.createGeometry(cesium.CoplanarPolygonGeometry.fromPositions({
|
|
1150
|
-
positions,
|
|
1151
|
-
vertexFormat: cesium.VertexFormat.POSITION_ONLY
|
|
1152
|
-
}));
|
|
1153
|
-
if (!geometry) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1154
|
-
const values = geometry.attributes.position.values;
|
|
1155
|
-
const indices = geometry.indices;
|
|
1156
|
-
const result = [];
|
|
1157
|
-
for (let i = 0; i < indices.length; i += 3) {
|
|
1158
|
-
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1159
|
-
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1160
|
-
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1161
|
-
result.push([
|
|
1162
|
-
a,
|
|
1163
|
-
b,
|
|
1164
|
-
c
|
|
1165
|
-
]);
|
|
1166
|
-
}
|
|
1167
|
-
return result;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
//#endregion
|
|
1171
|
-
//#region measure/utils/clampToGround.ts
|
|
1172
|
-
/**
|
|
1173
|
-
* 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
|
|
1174
|
-
* @param options - 配置项
|
|
1175
|
-
*/
|
|
1176
|
-
async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
|
|
1177
|
-
const { positions, scene, classificationType = cesium.ClassificationType.BOTH, terrainProvider = scene.terrainProvider } = options;
|
|
1178
|
-
const tileset = [cesium.ClassificationType.BOTH, cesium.ClassificationType.CESIUM_3D_TILE].includes(classificationType);
|
|
1179
|
-
const terrain = [cesium.ClassificationType.BOTH, cesium.ClassificationType.TERRAIN].includes(classificationType);
|
|
1180
|
-
const tilesetPromise = new Promise((resolve) => {
|
|
1181
|
-
if (tileset) scene.clampToHeightMostDetailed(positions.map((e) => e.clone())).then(resolve).catch((error) => {
|
|
1182
|
-
console.warn(error);
|
|
1183
|
-
resolve([]);
|
|
1184
|
-
});
|
|
1185
|
-
else resolve([]);
|
|
1186
|
-
});
|
|
1187
|
-
const terrainPromise = new Promise((resolve) => {
|
|
1188
|
-
if (terrain && terrainProvider) (0, cesium.sampleTerrainMostDetailed)(terrainProvider, positions.map((e) => cesium.Cartographic.fromCartesian(e))).then((e) => resolve(e)).catch((error) => {
|
|
1189
|
-
console.warn(error);
|
|
1190
|
-
resolve([]);
|
|
1191
|
-
});
|
|
1192
|
-
else resolve([]);
|
|
1193
|
-
});
|
|
1194
|
-
const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
|
|
1195
|
-
const resluts = [];
|
|
1196
|
-
positions.forEach((item, index) => {
|
|
1197
|
-
const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
|
|
1198
|
-
resluts.push(position);
|
|
1199
|
-
});
|
|
1200
|
-
return resluts;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
//#endregion
|
|
1204
|
-
//#region measure/utils/triangleGrid.ts
|
|
1205
|
-
function defaultOptions$2(original) {
|
|
1206
|
-
const clampToGround = original?.clampToGround ?? false;
|
|
1207
|
-
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1208
|
-
const density = Math.floor(original?.density ?? 10);
|
|
1209
|
-
return {
|
|
1210
|
-
scene: original?.scene,
|
|
1211
|
-
clampToGround,
|
|
1212
|
-
classificationType,
|
|
1213
|
-
terrainProvider: original?.terrainProvider,
|
|
1214
|
-
density
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* 生成三角网数组
|
|
1219
|
-
* @param positions - 边界点数组
|
|
1220
|
-
* @param options - 配置项
|
|
1221
|
-
*/
|
|
1222
|
-
async function triangleGrid(positions, options) {
|
|
1223
|
-
if (positions.length < 3) throw new Error("positions must >= 3");
|
|
1224
|
-
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$2(options);
|
|
1225
|
-
if (density <= 0) throw new Error("options.density must > 0");
|
|
1226
|
-
const bbox = cesium.Rectangle.fromCartesianArray(positions);
|
|
1227
|
-
const vertical = bbox.north - bbox.south;
|
|
1228
|
-
const horizontal = bbox.east - bbox.west;
|
|
1229
|
-
const max = Math.max(horizontal, vertical);
|
|
1230
|
-
const granularity = max / density;
|
|
1231
|
-
const polygonGeometry = cesium.PolygonGeometry.fromPositions({
|
|
1232
|
-
positions,
|
|
1233
|
-
vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
1234
|
-
granularity
|
|
1235
|
-
});
|
|
1236
|
-
const geometry = cesium.PolygonGeometry.createGeometry(polygonGeometry);
|
|
1237
|
-
const values = geometry.attributes.position.values;
|
|
1238
|
-
if (!geometry || !values) throw new Error("positions无法组成有效的geometry,检查点位是否错误");
|
|
1239
|
-
const indices = geometry.indices;
|
|
1240
|
-
let cartesian3List = [];
|
|
1241
|
-
for (let i = 0; i < indices.length; i += 3) {
|
|
1242
|
-
const a = cesium.Cartesian3.unpack(values, indices[i] * 3, new cesium.Cartesian3());
|
|
1243
|
-
const b = cesium.Cartesian3.unpack(values, indices[i + 1] * 3, new cesium.Cartesian3());
|
|
1244
|
-
const c = cesium.Cartesian3.unpack(values, indices[i + 2] * 3, new cesium.Cartesian3());
|
|
1245
|
-
cartesian3List.push(a, b, c);
|
|
1246
|
-
}
|
|
1247
|
-
if (clampToGround) {
|
|
1248
|
-
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1249
|
-
const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1250
|
-
scene,
|
|
1251
|
-
terrainProvider,
|
|
1252
|
-
positions: cartesian3List,
|
|
1253
|
-
classificationType
|
|
1254
|
-
});
|
|
1255
|
-
cartesian3List = detaileds;
|
|
1256
|
-
}
|
|
1257
|
-
const grid = [];
|
|
1258
|
-
while (cartesian3List?.length) {
|
|
1259
|
-
const [a, b, c] = cartesian3List.splice(0, 3);
|
|
1260
|
-
grid.push([
|
|
1261
|
-
a,
|
|
1262
|
-
b,
|
|
1263
|
-
c
|
|
1264
|
-
]);
|
|
1265
|
-
}
|
|
1266
|
-
return grid;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
//#endregion
|
|
1270
|
-
//#region measure/utils/area.ts
|
|
1271
|
-
/**
|
|
1272
|
-
* 计算三维坐标系下三角形面积
|
|
1273
|
-
* @param p0 - 三角形第一个点
|
|
1274
|
-
* @param p1 - 三角形第二个点
|
|
1275
|
-
* @param p2 - 三角形第三个点
|
|
1276
|
-
*/
|
|
1277
|
-
function triangleArea(p0, p1, p2) {
|
|
1278
|
-
const v0 = cesium.Cartesian3.subtract(p0, p1, new cesium.Cartesian3());
|
|
1279
|
-
const v1 = cesium.Cartesian3.subtract(p2, p1, new cesium.Cartesian3());
|
|
1280
|
-
const cross = cesium.Cartesian3.cross(v0, v1, v0);
|
|
1281
|
-
return cesium.Cartesian3.magnitude(cross) * .5;
|
|
1282
|
-
}
|
|
1283
|
-
function defaultOptions$1(original) {
|
|
1284
|
-
const clampToGround = original?.clampToGround ?? false;
|
|
1285
|
-
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1286
|
-
const density = Math.floor(original?.density ?? 10);
|
|
1287
|
-
return {
|
|
1288
|
-
scene: original?.scene,
|
|
1289
|
-
clampToGround,
|
|
1290
|
-
classificationType,
|
|
1291
|
-
terrainProvider: original?.terrainProvider,
|
|
1292
|
-
density
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
/**
|
|
1296
|
-
* 计算三维坐标系下图形面积
|
|
1297
|
-
* @param positions - 图形各点的笛卡尔数组
|
|
1298
|
-
*/
|
|
1299
|
-
async function area(positions, options) {
|
|
1300
|
-
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1301
|
-
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
|
|
1302
|
-
if (density <= 0) throw new Error("options.density must > 0");
|
|
1303
|
-
if (!clampToGround) {
|
|
1304
|
-
const triangles$1 = tesselate(positions);
|
|
1305
|
-
return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1306
|
-
}
|
|
1307
|
-
const triangles = await triangleGrid(positions, {
|
|
1308
|
-
density,
|
|
1309
|
-
scene,
|
|
1310
|
-
clampToGround,
|
|
1311
|
-
classificationType,
|
|
1312
|
-
terrainProvider
|
|
1313
|
-
});
|
|
1314
|
-
return triangles.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
//#endregion
|
|
1318
|
-
//#region measure/utils/lerpArray.ts
|
|
1319
|
-
/**
|
|
1320
|
-
* 在起点和终点间进行插值, 返回的数组包括起点和终点,数组长度为 count+1
|
|
1321
|
-
*/
|
|
1322
|
-
async function lerpArray(options) {
|
|
1323
|
-
const { start, end, count, scene, clampToGround, classificationType, terrainProvider } = options;
|
|
1324
|
-
const result = [];
|
|
1325
|
-
for (let i = 0; i < count; i++) {
|
|
1326
|
-
const position = cesium.Cartesian3.lerp(start, end, 1 / count, new cesium.Cartesian3());
|
|
1327
|
-
result.push(position);
|
|
1013
|
+
};
|
|
1328
1014
|
}
|
|
1329
|
-
result.push(end.clone());
|
|
1330
|
-
if (!clampToGround) return result;
|
|
1331
|
-
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1332
|
-
const detaileds = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1333
|
-
scene,
|
|
1334
|
-
terrainProvider,
|
|
1335
|
-
positions: result,
|
|
1336
|
-
classificationType
|
|
1337
|
-
});
|
|
1338
|
-
return detaileds;
|
|
1339
|
-
}
|
|
1340
1015
|
|
|
1341
1016
|
//#endregion
|
|
1342
|
-
//#region
|
|
1343
|
-
function defaultOptions(original) {
|
|
1344
|
-
const clampToGround = original?.clampToGround ?? false;
|
|
1345
|
-
const classificationType = original?.classificationType ?? cesium.ClassificationType.BOTH;
|
|
1346
|
-
const density = Math.floor(original?.density ?? 50);
|
|
1347
|
-
return {
|
|
1348
|
-
scene: original?.scene,
|
|
1349
|
-
clampToGround,
|
|
1350
|
-
classificationType,
|
|
1351
|
-
terrainProvider: original?.terrainProvider,
|
|
1352
|
-
density
|
|
1353
|
-
};
|
|
1354
|
-
}
|
|
1017
|
+
//#region skeleton/intervalNonclosed.ts
|
|
1355
1018
|
/**
|
|
1356
|
-
*
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
//#endregion
|
|
1407
|
-
//#region measure/measureArea.ts
|
|
1408
|
-
const schemeMeasureArea = new PlotScheme({
|
|
1409
|
-
type: "MeasureArea",
|
|
1410
|
-
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
1411
|
-
skeletons: [control, interval],
|
|
1412
|
-
initRender() {
|
|
1413
|
-
return { entities: [new cesium.Entity({
|
|
1414
|
-
label: { font: "14pt" },
|
|
1415
|
-
polyline: { material: cesium.Color.YELLOW.withAlpha(.5) },
|
|
1416
|
-
polygon: { material: cesium.Color.YELLOW.withAlpha(.5) }
|
|
1417
|
-
})] };
|
|
1418
|
-
},
|
|
1419
|
-
render(context) {
|
|
1420
|
-
const entity = context.previous.entities[0];
|
|
1421
|
-
const { mouse, packable } = context;
|
|
1422
|
-
const positions = [...packable.positions ?? []];
|
|
1423
|
-
mouse && positions.push(mouse);
|
|
1424
|
-
if (positions.length === 2) {
|
|
1425
|
-
entity.position = void 0;
|
|
1426
|
-
entity.label.text = void 0;
|
|
1427
|
-
entity.polygon.hierarchy = void 0;
|
|
1428
|
-
entity.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1429
|
-
} else if (positions.length >= 3) {
|
|
1430
|
-
positions.push(positions[0]);
|
|
1431
|
-
entity.position = new cesium.ConstantPositionProperty((0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))));
|
|
1432
|
-
entity.label.text = new cesium.ConstantProperty("");
|
|
1433
|
-
area(positions).then((e) => {
|
|
1434
|
-
let text = "";
|
|
1435
|
-
if (e / 1e3 / 1e3 > 10) text = `${(e / 1e3 / 1e3).toFixed(2)}km²`;
|
|
1436
|
-
else text = `${(+e).toFixed(2)}m²`;
|
|
1437
|
-
entity.label.text = new cesium.ConstantProperty(text);
|
|
1438
|
-
});
|
|
1439
|
-
entity.polyline.positions = void 0;
|
|
1440
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => {
|
|
1441
|
-
return positions.length >= 3 ? new cesium.PolygonHierarchy([...positions]) : void 0;
|
|
1442
|
-
}, false);
|
|
1443
|
-
} else {
|
|
1444
|
-
entity.position = void 0;
|
|
1445
|
-
entity.polygon.hierarchy = void 0;
|
|
1446
|
-
entity.polyline.positions = void 0;
|
|
1447
|
-
}
|
|
1448
|
-
return { entities: [entity] };
|
|
1449
|
-
}
|
|
1450
|
-
});
|
|
1451
|
-
|
|
1452
|
-
//#endregion
|
|
1453
|
-
//#region measure/measureDistance.ts
|
|
1454
|
-
const schemeMeasureDistance = new PlotScheme({
|
|
1455
|
-
type: "MeasureDistance",
|
|
1456
|
-
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
1457
|
-
skeletons: [control],
|
|
1458
|
-
initRender() {
|
|
1459
|
-
return { entities: [new cesium.Entity({ polyline: {
|
|
1460
|
-
width: 2,
|
|
1461
|
-
material: cesium.Color.YELLOW.withAlpha(.5)
|
|
1462
|
-
} })] };
|
|
1463
|
-
},
|
|
1464
|
-
render(context) {
|
|
1465
|
-
const entity = context.previous.entities[0];
|
|
1466
|
-
const { mouse, packable, previous } = context;
|
|
1467
|
-
const entities = previous.entities;
|
|
1468
|
-
const positions = [...packable.positions ?? []];
|
|
1469
|
-
mouse && positions.push(mouse);
|
|
1470
|
-
if (positions.length < 2) return { entities };
|
|
1471
|
-
const pl = entities[0];
|
|
1472
|
-
pl.polyline ??= new cesium.PolylineGraphics();
|
|
1473
|
-
pl.polyline.positions = new cesium.CallbackProperty(() => positions, false);
|
|
1474
|
-
positions.forEach((item, index) => {
|
|
1475
|
-
if (!entities[index + 1]) entities[index + 1] = new cesium.Entity({
|
|
1476
|
-
position: item,
|
|
1477
|
-
label: new cesium.LabelGraphics({
|
|
1478
|
-
backgroundColor: cesium.Color.fromCssColorString("#fff"),
|
|
1479
|
-
font: "12pt sans-serif"
|
|
1480
|
-
})
|
|
1481
|
-
});
|
|
1482
|
-
});
|
|
1483
|
-
entities.splice(positions.length, entities.length - positions.length - 1);
|
|
1484
|
-
distance(positions).then(({ count, stages }) => {
|
|
1485
|
-
stages.forEach((stage, index) => {
|
|
1486
|
-
entities[index + 1].position = new cesium.CallbackPositionProperty(() => cesium.Cartesian3.midpoint(positions[index], positions[index + 1], new cesium.Cartesian3()), false);
|
|
1487
|
-
entities[index + 1].label.text = new cesium.CallbackProperty(() => `${stage.toFixed(2)} m`, false);
|
|
1488
|
-
});
|
|
1489
|
-
if (stages.length > 1) {
|
|
1490
|
-
entities[entities.length - 1].position = new cesium.CallbackPositionProperty(() => positions[positions.length - 1], false);
|
|
1491
|
-
entities[entities.length - 1].label.text = new cesium.CallbackProperty(() => `${count.toFixed(2)} m`, false);
|
|
1492
|
-
} else {
|
|
1493
|
-
entities[entities.length - 1].position = void 0;
|
|
1494
|
-
entities[entities.length - 1].label.text = void 0;
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
return { entities };
|
|
1498
|
-
}
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
|
-
//#endregion
|
|
1502
|
-
//#region scheme/Billboard.ts
|
|
1503
|
-
const PlotSchemeBillboard = new PlotScheme({
|
|
1504
|
-
type: "Billboard",
|
|
1505
|
-
complete: (packable) => packable.positions.length >= 1,
|
|
1506
|
-
skeletons: [moved],
|
|
1507
|
-
initRender: () => {
|
|
1508
|
-
return { entities: [new cesium.Entity({ billboard: {
|
|
1509
|
-
image: "/favicon.svg",
|
|
1510
|
-
width: 32,
|
|
1511
|
-
height: 32
|
|
1512
|
-
} })] };
|
|
1513
|
-
},
|
|
1514
|
-
render(options) {
|
|
1515
|
-
const { mouse, packable } = options;
|
|
1516
|
-
const entity = options.previous.entities?.[0] ?? new cesium.Entity({ billboard: {} });
|
|
1517
|
-
const position = packable.positions?.[0] ?? mouse;
|
|
1518
|
-
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1519
|
-
return { entities: [entity] };
|
|
1520
|
-
}
|
|
1521
|
-
});
|
|
1522
|
-
|
|
1523
|
-
//#endregion
|
|
1524
|
-
//#region scheme/BillboardPinBuilder.ts
|
|
1525
|
-
const PlotSchemeBillboardPinBuilder = new PlotScheme({
|
|
1526
|
-
type: "BillboardPinBuilder",
|
|
1527
|
-
complete: (packable) => packable.positions.length >= 1,
|
|
1528
|
-
skeletons: [moved],
|
|
1529
|
-
initRender() {
|
|
1530
|
-
return { entities: [new cesium.Entity({ billboard: {} })] };
|
|
1531
|
-
},
|
|
1532
|
-
render(context) {
|
|
1533
|
-
const entity = context.previous.entities[0];
|
|
1534
|
-
const position = context.packable.positions[0] ?? context.mouse;
|
|
1535
|
-
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1536
|
-
return { entities: [entity] };
|
|
1537
|
-
}
|
|
1538
|
-
});
|
|
1539
|
-
|
|
1540
|
-
//#endregion
|
|
1541
|
-
//#region scheme/Cylinder.ts
|
|
1542
|
-
const PlotSchemeCylinder = new PlotScheme({
|
|
1543
|
-
type: "Cylinder",
|
|
1544
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
1545
|
-
skeletons: [moved, control],
|
|
1546
|
-
initRender() {
|
|
1547
|
-
return { entities: [new cesium.Entity({ cylinder: {} })] };
|
|
1548
|
-
},
|
|
1549
|
-
render(context) {
|
|
1550
|
-
const entity = context.previous.entities[0];
|
|
1551
|
-
const positions = [...context.packable.positions];
|
|
1552
|
-
if (positions.length === 0) return context.previous;
|
|
1553
|
-
if (positions.length === 1) {
|
|
1554
|
-
const position = context.mouse;
|
|
1555
|
-
position && positions.push(position);
|
|
1556
|
-
}
|
|
1557
|
-
if (positions.length < 2) return context.previous;
|
|
1558
|
-
entity.position = new cesium.ConstantPositionProperty(positions[0]);
|
|
1559
|
-
const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
|
|
1560
|
-
entity.cylinder.bottomRadius = new cesium.CallbackProperty(() => radius, false);
|
|
1561
|
-
if (context.defining || !(0, vesium.toPropertyValue)(entity.cylinder.length)) entity.cylinder.length = (0, vesium.toProperty)(radius * 2);
|
|
1562
|
-
return { entities: [entity] };
|
|
1563
|
-
}
|
|
1564
|
-
});
|
|
1565
|
-
|
|
1566
|
-
//#endregion
|
|
1567
|
-
//#region scheme/Ellipse.ts
|
|
1568
|
-
const PlotSchemeEllipse = new PlotScheme({
|
|
1569
|
-
type: "Ellipse",
|
|
1570
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
1571
|
-
skeletons: [moved, control],
|
|
1572
|
-
initRender() {
|
|
1573
|
-
return { entities: [new cesium.Entity({ ellipse: {} })] };
|
|
1574
|
-
},
|
|
1575
|
-
render(context) {
|
|
1576
|
-
const entity = context.previous.entities[0];
|
|
1577
|
-
const positions = [...context.packable.positions];
|
|
1578
|
-
if (positions.length === 0) return context.previous;
|
|
1579
|
-
if (positions.length === 1) {
|
|
1580
|
-
const position = context.mouse;
|
|
1581
|
-
position && positions.push(position);
|
|
1582
|
-
}
|
|
1583
|
-
if (positions.length < 2) return context.previous;
|
|
1584
|
-
entity.position = new cesium.ConstantPositionProperty(positions[0]);
|
|
1585
|
-
const radius = cesium.Cartesian3.distance(positions[0], positions[1]);
|
|
1586
|
-
entity.ellipse.semiMinorAxis = new cesium.CallbackProperty(() => radius || 1, false);
|
|
1587
|
-
entity.ellipse.semiMajorAxis = entity.ellipse.semiMinorAxis;
|
|
1588
|
-
return { entities: [entity] };
|
|
1589
|
-
}
|
|
1590
|
-
});
|
|
1591
|
-
|
|
1592
|
-
//#endregion
|
|
1593
|
-
//#region scheme/Label.ts
|
|
1594
|
-
const PlotSchemeLabel = new PlotScheme({
|
|
1595
|
-
type: "Label",
|
|
1596
|
-
complete: (packable) => packable.positions.length >= 1,
|
|
1597
|
-
skeletons: [moved],
|
|
1598
|
-
initRender() {
|
|
1599
|
-
return { entities: [new cesium.Entity({ label: { text: "Label" } })] };
|
|
1600
|
-
},
|
|
1601
|
-
render(context) {
|
|
1602
|
-
const entity = context.previous.entities[0];
|
|
1603
|
-
const position = context.packable.positions[0] ?? context.mouse;
|
|
1604
|
-
entity.position = new cesium.CallbackPositionProperty(() => position, true);
|
|
1605
|
-
return { entities: [entity] };
|
|
1019
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1020
|
+
*/
|
|
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
|
+
};
|
|
1606
1067
|
}
|
|
1607
|
-
});
|
|
1608
1068
|
|
|
1609
1069
|
//#endregion
|
|
1610
|
-
//#region
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
return {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
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>")}`;
|
|
1072
|
+
/**
|
|
1073
|
+
* 绘制非封闭的间隔框架点,如线段。拖拽时,会在两点之间插入一个控制点,并持续拖拽该点。
|
|
1074
|
+
*/
|
|
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
|
+
};
|
|
1626
1119
|
}
|
|
1627
|
-
});
|
|
1628
1120
|
|
|
1629
1121
|
//#endregion
|
|
1630
|
-
//#region
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
const
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
} else {
|
|
1660
|
-
entity.polygon.hierarchy = void 0;
|
|
1661
|
-
entity.polyline.positions = void 0;
|
|
1122
|
+
//#region measure/utils/tesselate.ts
|
|
1123
|
+
/**
|
|
1124
|
+
* 将多个边界点组成的面切割成多个三角形
|
|
1125
|
+
* @param positions
|
|
1126
|
+
*/
|
|
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
|
+
]);
|
|
1662
1151
|
}
|
|
1663
|
-
return
|
|
1152
|
+
return result;
|
|
1664
1153
|
}
|
|
1665
|
-
});
|
|
1666
1154
|
|
|
1667
1155
|
//#endregion
|
|
1668
|
-
//#region
|
|
1669
|
-
const FITTING_COUNT = 100;
|
|
1670
|
-
const HALF_PI = Math.PI / 2;
|
|
1671
|
-
const ZERO_TOLERANCE = 1e-4;
|
|
1672
|
-
const TWO_PI = Math.PI * 2;
|
|
1673
|
-
/**
|
|
1674
|
-
* 计算两个坐标之间的距离
|
|
1675
|
-
* @param coord1
|
|
1676
|
-
* @param coord2
|
|
1677
|
-
*/
|
|
1678
|
-
function mathDistance(coord1, coord2) {
|
|
1679
|
-
return Math.hypot(coord1[0] - coord2[0], coord1[1] - coord2[1]);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* 计算点集合的总距离
|
|
1683
|
-
* @param points
|
|
1684
|
-
*/
|
|
1685
|
-
function wholeDistance(points) {
|
|
1686
|
-
let distance$1 = 0;
|
|
1687
|
-
if (points && Array.isArray(points) && points.length > 0) points.forEach((item, index) => {
|
|
1688
|
-
if (index < points.length - 1) distance$1 += mathDistance(item, points[index + 1]);
|
|
1689
|
-
});
|
|
1690
|
-
return distance$1;
|
|
1691
|
-
}
|
|
1692
|
-
/**
|
|
1693
|
-
* 获取基础长度
|
|
1694
|
-
* @param points
|
|
1695
|
-
*/
|
|
1696
|
-
const getBaseLength = (points) => wholeDistance(points) ** .99;
|
|
1697
|
-
/**
|
|
1698
|
-
* 求取两个坐标的中间坐标
|
|
1699
|
-
* @param coord1
|
|
1700
|
-
* @param coord2
|
|
1701
|
-
*/
|
|
1702
|
-
function mid(coord1, coord2) {
|
|
1703
|
-
return [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* 通过三个点确定一个圆的中心点
|
|
1707
|
-
* @param coord1
|
|
1708
|
-
* @param coord2
|
|
1709
|
-
* @param coord3
|
|
1710
|
-
*/
|
|
1711
|
-
function getCircleCenterOfThreeCoords(coord1, coord2, coord3) {
|
|
1712
|
-
const coordA = [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
|
|
1713
|
-
const coordB = [coordA[0] - coord1[1] + coord2[1], coordA[1] + coord1[0] - coord2[0]];
|
|
1714
|
-
const coordC = [(coord1[0] + coord3[0]) / 2, (coord1[1] + coord3[1]) / 2];
|
|
1715
|
-
const coordD = [coordC[0] - coord1[1] + coord3[1], coordC[1] + coord1[0] - coord3[0]];
|
|
1716
|
-
return getIntersectCoord(coordA, coordB, coordC, coordD);
|
|
1717
|
-
}
|
|
1718
|
-
/**
|
|
1719
|
-
* 获取交集的点
|
|
1720
|
-
* @param coordA
|
|
1721
|
-
* @param coordB
|
|
1722
|
-
* @param coordC
|
|
1723
|
-
* @param coordD
|
|
1724
|
-
*/
|
|
1725
|
-
function getIntersectCoord(coordA, coordB, coordC, coordD) {
|
|
1726
|
-
if (coordA[1] === coordB[1]) {
|
|
1727
|
-
const f$1 = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
|
|
1728
|
-
const x$1 = f$1 * (coordA[1] - coordC[1]) + coordC[0];
|
|
1729
|
-
const y$1 = coordA[1];
|
|
1730
|
-
return [x$1, y$1];
|
|
1731
|
-
}
|
|
1732
|
-
if (coordC[1] === coordD[1]) {
|
|
1733
|
-
const e$1 = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
|
|
1734
|
-
const x$1 = e$1 * (coordC[1] - coordA[1]) + coordA[0];
|
|
1735
|
-
const y$1 = coordC[1];
|
|
1736
|
-
return [x$1, y$1];
|
|
1737
|
-
}
|
|
1738
|
-
const e = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
|
|
1739
|
-
const f = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
|
|
1740
|
-
const y = (e * coordA[1] - coordA[0] - f * coordC[1] + coordC[0]) / (e - f);
|
|
1741
|
-
const x = e * y - e * coordA[1] + coordA[0];
|
|
1742
|
-
return [x, y];
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* 获取方位角(地平经度)
|
|
1746
|
-
* @param startCoord
|
|
1747
|
-
* @param endCoord
|
|
1748
|
-
*/
|
|
1749
|
-
function getAzimuth(startCoord, endCoord) {
|
|
1750
|
-
let azimuth = 0;
|
|
1751
|
-
const angle = Math.asin(Math.abs(endCoord[1] - startCoord[1]) / mathDistance(startCoord, endCoord));
|
|
1752
|
-
if (endCoord[1] >= startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = angle + Math.PI;
|
|
1753
|
-
else if (endCoord[1] >= startCoord[1] && endCoord[0] < startCoord[0]) azimuth = Math.PI * 2 - angle;
|
|
1754
|
-
else if (endCoord[1] < startCoord[1] && endCoord[0] < startCoord[0]) azimuth = angle;
|
|
1755
|
-
else if (endCoord[1] < startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = Math.PI - angle;
|
|
1756
|
-
return azimuth;
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* 通过三个点获取方位角
|
|
1760
|
-
* @param coordA
|
|
1761
|
-
* @param coordB
|
|
1762
|
-
* @param coordC
|
|
1763
|
-
*/
|
|
1764
|
-
function getAngleOfThreeCoords(coordA, coordB, coordC) {
|
|
1765
|
-
const angle = getAzimuth(coordB, coordA) - getAzimuth(coordB, coordC);
|
|
1766
|
-
return angle < 0 ? angle + Math.PI * 2 : angle;
|
|
1767
|
-
}
|
|
1768
|
-
/**
|
|
1769
|
-
* 判断是否是顺时针
|
|
1770
|
-
* @param coord1
|
|
1771
|
-
* @param coord2
|
|
1772
|
-
* @param coord3
|
|
1773
|
-
*/
|
|
1774
|
-
function isClockWise(coord1, coord2, coord3) {
|
|
1775
|
-
return (coord3[1] - coord1[1]) * (coord2[0] - coord1[0]) > (coord2[1] - coord1[1]) * (coord3[0] - coord1[0]);
|
|
1776
|
-
}
|
|
1777
|
-
/**
|
|
1778
|
-
* 获取立方值
|
|
1779
|
-
*/
|
|
1780
|
-
function getCubicValue(t, startCoord, coord1, coord2, endCoord) {
|
|
1781
|
-
t = Math.max(Math.min(t, 1), 0);
|
|
1782
|
-
const [tp, t2] = [1 - t, t * t];
|
|
1783
|
-
const t3 = t2 * t;
|
|
1784
|
-
const tp2 = tp * tp;
|
|
1785
|
-
const tp3 = tp2 * tp;
|
|
1786
|
-
const x = tp3 * startCoord[0] + 3 * tp2 * t * coord1[0] + 3 * tp * t2 * coord2[0] + t3 * endCoord[0];
|
|
1787
|
-
const y = tp3 * startCoord[1] + 3 * tp2 * t * coord1[1] + 3 * tp * t2 * coord2[1] + t3 * endCoord[1];
|
|
1788
|
-
return [x, y];
|
|
1789
|
-
}
|
|
1790
|
-
/**
|
|
1791
|
-
* 根据起止点和旋转方向求取第三个点
|
|
1792
|
-
* @param startCoord
|
|
1793
|
-
* @param endCoord
|
|
1794
|
-
* @param angle
|
|
1795
|
-
* @param distance
|
|
1796
|
-
* @param clockWise
|
|
1797
|
-
*/
|
|
1798
|
-
function getThirdCoord(startCoord, endCoord, angle, distance$1, clockWise) {
|
|
1799
|
-
const azimuth = getAzimuth(startCoord, endCoord);
|
|
1800
|
-
const alpha = clockWise ? azimuth + angle : azimuth - angle;
|
|
1801
|
-
const dx = distance$1 * Math.cos(alpha);
|
|
1802
|
-
const dy = distance$1 * Math.sin(alpha);
|
|
1803
|
-
return [endCoord[0] + dx, endCoord[1] + dy];
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* 插值弓形线段点
|
|
1807
|
-
* @param center
|
|
1808
|
-
* @param radius
|
|
1809
|
-
* @param startAngle
|
|
1810
|
-
* @param endAngle
|
|
1811
|
-
*/
|
|
1812
|
-
function getArcCoords(center, radius, startAngle, endAngle) {
|
|
1813
|
-
let [x, y, coords, angleDiff] = [
|
|
1814
|
-
0,
|
|
1815
|
-
0,
|
|
1816
|
-
[],
|
|
1817
|
-
endAngle - startAngle
|
|
1818
|
-
];
|
|
1819
|
-
angleDiff = angleDiff < 0 ? angleDiff + Math.PI * 2 : angleDiff;
|
|
1820
|
-
for (let i = 0; i <= 100; i++) {
|
|
1821
|
-
const angle = startAngle + angleDiff * i / 100;
|
|
1822
|
-
x = center[0] + radius * Math.cos(angle);
|
|
1823
|
-
y = center[1] + radius * Math.sin(angle);
|
|
1824
|
-
coords.push([x, y]);
|
|
1825
|
-
}
|
|
1826
|
-
return coords;
|
|
1827
|
-
}
|
|
1156
|
+
//#region measure/utils/clampToGround.ts
|
|
1828
1157
|
/**
|
|
1829
|
-
*
|
|
1830
|
-
* @param
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
bisectorNormalLeft = [x, y];
|
|
1858
|
-
} else {
|
|
1859
|
-
dt = t * d1;
|
|
1860
|
-
x = coord2[0] + dt * uY;
|
|
1861
|
-
y = coord2[1] - dt * uX;
|
|
1862
|
-
bisectorNormalRight = [x, y];
|
|
1863
|
-
dt = t * d2;
|
|
1864
|
-
x = coord2[0] - dt * uY;
|
|
1865
|
-
y = coord2[1] + dt * uX;
|
|
1866
|
-
bisectorNormalLeft = [x, y];
|
|
1158
|
+
* 将传入的点位列表进行贴地处理,若某个点位获取高程失败则将此进行克隆返回
|
|
1159
|
+
* @param options - 配置项
|
|
1160
|
+
*/
|
|
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;
|
|
1867
1186
|
}
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
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
|
+
};
|
|
1875
1201
|
}
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
*
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
if (points.length <= 2) return points;
|
|
1905
|
-
const bezierCoords = [];
|
|
1906
|
-
const n = points.length - 1;
|
|
1907
|
-
for (let t = 0; t <= 1; t += .01) {
|
|
1908
|
-
let [x, y] = [0, 0];
|
|
1909
|
-
for (let index = 0; index <= n; index++) {
|
|
1910
|
-
const factor = getBinomialFactor(n, index);
|
|
1911
|
-
const a = t ** index;
|
|
1912
|
-
const b = (1 - t) ** (n - index);
|
|
1913
|
-
x += factor * a * b * points[index][0];
|
|
1914
|
-
y += factor * a * b * points[index][1];
|
|
1202
|
+
/**
|
|
1203
|
+
* 生成三角网数组
|
|
1204
|
+
* @param positions - 边界点数组
|
|
1205
|
+
* @param options - 配置项
|
|
1206
|
+
*/
|
|
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);
|
|
1915
1230
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
*/
|
|
1925
|
-
function getFactorial(n) {
|
|
1926
|
-
let result = 1;
|
|
1927
|
-
switch (true) {
|
|
1928
|
-
case n <= 1:
|
|
1929
|
-
result = 1;
|
|
1930
|
-
break;
|
|
1931
|
-
case n === 2:
|
|
1932
|
-
result = 2;
|
|
1933
|
-
break;
|
|
1934
|
-
case n === 3:
|
|
1935
|
-
result = 6;
|
|
1936
|
-
break;
|
|
1937
|
-
case n === 24:
|
|
1938
|
-
result = 24;
|
|
1939
|
-
break;
|
|
1940
|
-
case n === 5:
|
|
1941
|
-
result = 120;
|
|
1942
|
-
break;
|
|
1943
|
-
default:
|
|
1944
|
-
for (let i = 1; i <= n; i++) result *= i;
|
|
1945
|
-
break;
|
|
1946
|
-
}
|
|
1947
|
-
return result;
|
|
1948
|
-
}
|
|
1949
|
-
/**
|
|
1950
|
-
* 获取二项分布
|
|
1951
|
-
* @param n
|
|
1952
|
-
* @param index
|
|
1953
|
-
*/
|
|
1954
|
-
function getBinomialFactor(n, index) {
|
|
1955
|
-
return getFactorial(n) / (getFactorial(index) * getFactorial(n - index));
|
|
1956
|
-
}
|
|
1957
|
-
/**
|
|
1958
|
-
* 插值线性点
|
|
1959
|
-
* @param points
|
|
1960
|
-
*/
|
|
1961
|
-
function getQBSplineCoords(points) {
|
|
1962
|
-
if (points.length <= 2) return points;
|
|
1963
|
-
const [n, bSplineCoords] = [2, []];
|
|
1964
|
-
const m = points.length - n - 1;
|
|
1965
|
-
bSplineCoords.push(points[0]);
|
|
1966
|
-
for (let i = 0; i <= m; i++) for (let t = 0; t <= 1; t += .05) {
|
|
1967
|
-
let [x, y] = [0, 0];
|
|
1968
|
-
for (let k = 0; k <= n; k++) {
|
|
1969
|
-
const factor = getQuadricBSplineFactor(k, t);
|
|
1970
|
-
x += factor * points[i + k][0];
|
|
1971
|
-
y += factor * points[i + k][1];
|
|
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
|
+
});
|
|
1972
1239
|
}
|
|
1973
|
-
|
|
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;
|
|
1974
1250
|
}
|
|
1975
|
-
bSplineCoords.push(points.at(-1));
|
|
1976
|
-
return bSplineCoords;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* 得到二次线性因子
|
|
1980
|
-
* @param k
|
|
1981
|
-
* @param t
|
|
1982
|
-
*/
|
|
1983
|
-
function getQuadricBSplineFactor(k, t) {
|
|
1984
|
-
let res = 0;
|
|
1985
|
-
if (k === 0) res = (t - 1) ** 2 / 2;
|
|
1986
|
-
else if (k === 1) res = (-2 * t ** 2 + 2 * t + 1) / 2;
|
|
1987
|
-
else if (k === 2) res = t ** 2 / 2;
|
|
1988
|
-
return res;
|
|
1989
|
-
}
|
|
1990
1251
|
|
|
1991
1252
|
//#endregion
|
|
1992
|
-
//#region
|
|
1253
|
+
//#region measure/utils/area.ts
|
|
1993
1254
|
/**
|
|
1994
|
-
*
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
const
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
1255
|
+
* 计算三维坐标系下三角形面积
|
|
1256
|
+
* @param p0 - 三角形第一个点
|
|
1257
|
+
* @param p1 - 三角形第二个点
|
|
1258
|
+
* @param p2 - 三角形第三个点
|
|
1259
|
+
*/
|
|
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;
|
|
1265
|
+
}
|
|
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
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* 计算三维坐标系下图形面积
|
|
1280
|
+
* @param positions - 图形各点的笛卡尔数组
|
|
1281
|
+
*/
|
|
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);
|
|
2019
1294
|
}
|
|
2020
|
-
}
|
|
2021
1295
|
|
|
2022
1296
|
//#endregion
|
|
2023
|
-
//#region
|
|
1297
|
+
//#region measure/utils/lerpArray.ts
|
|
2024
1298
|
/**
|
|
2025
|
-
*
|
|
2026
|
-
*/
|
|
2027
|
-
function
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
tailLeft = coords[1];
|
|
2034
|
-
tailRight = coords[0];
|
|
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);
|
|
2035
1307
|
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
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
|
|
2042
1316
|
});
|
|
2043
|
-
if (headCoords && headCoords.length > 4) {
|
|
2044
|
-
const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
|
|
2045
|
-
const tailWidthFactor = mathDistance(tailLeft, tailRight) / getBaseLength(boneCoords);
|
|
2046
|
-
const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, tailWidthFactor);
|
|
2047
|
-
const coordlength = bodyCoords.length;
|
|
2048
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
|
|
2049
|
-
leftCoords.push(neckLeft);
|
|
2050
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
|
|
2051
|
-
rightCoords.push(neckRight);
|
|
2052
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2053
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2054
|
-
return leftCoords.concat(headCoords, rightCoords.reverse());
|
|
2055
|
-
} else return [];
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
/**
|
|
2059
|
-
* 插值头部点
|
|
2060
|
-
*/
|
|
2061
|
-
function getArrowHeadCoords(points, options) {
|
|
2062
|
-
const { tailLeft, tailRight, headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, headTailFactor = .8 } = options;
|
|
2063
|
-
let len = getBaseLength(points);
|
|
2064
|
-
let headHeight = len * headHeightFactor;
|
|
2065
|
-
const headCoord = points.at(-1);
|
|
2066
|
-
len = mathDistance(headCoord, points.at(-2));
|
|
2067
|
-
let tailWidth = 0;
|
|
2068
|
-
if (tailLeft && tailRight) tailWidth = mathDistance(tailLeft, tailRight);
|
|
2069
|
-
if (headHeight > tailWidth * headTailFactor) headHeight = tailWidth * headTailFactor;
|
|
2070
|
-
const headWidth = headHeight * headWidthFactor;
|
|
2071
|
-
const neckWidth = headHeight * neckWidthFactor;
|
|
2072
|
-
headHeight = Math.min(headHeight, len);
|
|
2073
|
-
const neckHeight = headHeight * neckHeightFactor;
|
|
2074
|
-
const headEndCoord = getThirdCoord(points.at(-2), headCoord, 0, headHeight, true);
|
|
2075
|
-
const neckEndCoord = getThirdCoord(points.at(-2), headCoord, 0, neckHeight, true);
|
|
2076
|
-
const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
|
|
2077
|
-
const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
|
|
2078
|
-
const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
|
|
2079
|
-
const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
|
|
2080
|
-
return [
|
|
2081
|
-
neckLeft,
|
|
2082
|
-
headLeft,
|
|
2083
|
-
headCoord,
|
|
2084
|
-
headRight,
|
|
2085
|
-
neckRight
|
|
2086
|
-
];
|
|
2087
|
-
}
|
|
2088
|
-
/**
|
|
2089
|
-
* 插值面部分数据
|
|
2090
|
-
* @param points
|
|
2091
|
-
* @param neckLeft
|
|
2092
|
-
* @param neckRight
|
|
2093
|
-
* @param tailWidthFactor
|
|
2094
|
-
*/
|
|
2095
|
-
function getArrowBodyCoords(points, neckLeft, neckRight, tailWidthFactor) {
|
|
2096
|
-
const allLen = wholeDistance(points);
|
|
2097
|
-
const len = getBaseLength(points);
|
|
2098
|
-
const tailWidth = len * tailWidthFactor;
|
|
2099
|
-
const neckWidth = mathDistance(neckLeft, neckRight);
|
|
2100
|
-
const widthDif = (tailWidth - neckWidth) / 2;
|
|
2101
|
-
let tempLen = 0;
|
|
2102
|
-
const leftBodyCoords = [];
|
|
2103
|
-
const rightBodyCoords = [];
|
|
2104
|
-
for (let i = 1; i < points.length - 1; i++) {
|
|
2105
|
-
const angle = getAngleOfThreeCoords(points[i - 1], points[i], points[i + 1]) / 2;
|
|
2106
|
-
tempLen += mathDistance(points[i - 1], points[i]);
|
|
2107
|
-
const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
|
|
2108
|
-
const left = getThirdCoord(points[i - 1], points[i], Math.PI - angle, w, true);
|
|
2109
|
-
const right = getThirdCoord(points[i - 1], points[i], angle, w, false);
|
|
2110
|
-
leftBodyCoords.push(left);
|
|
2111
|
-
rightBodyCoords.push(right);
|
|
2112
1317
|
}
|
|
2113
|
-
return leftBodyCoords.concat(rightBodyCoords);
|
|
2114
|
-
}
|
|
2115
1318
|
|
|
2116
1319
|
//#endregion
|
|
2117
|
-
//#region
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
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
|
+
}
|
|
1349
|
+
});
|
|
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);
|
|
1358
|
+
});
|
|
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
|
+
});
|
|
1371
|
+
});
|
|
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
|
+
};
|
|
2129
1381
|
}
|
|
2130
|
-
const midTail = mid(tailLeft, tailRight);
|
|
2131
|
-
const boneCoords = [midTail].concat(coords.slice(2));
|
|
2132
|
-
const headCoords = getArrowHeadCoords(boneCoords, {
|
|
2133
|
-
tailLeft,
|
|
2134
|
-
tailRight,
|
|
2135
|
-
headHeightFactor,
|
|
2136
|
-
headWidthFactor,
|
|
2137
|
-
neckWidthFactor,
|
|
2138
|
-
neckHeightFactor
|
|
2139
|
-
});
|
|
2140
|
-
if (headCoords && headCoords.length > 4) {
|
|
2141
|
-
const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
|
|
2142
|
-
const tailWidth = mathDistance(tailLeft, tailRight);
|
|
2143
|
-
const allLen = getBaseLength(boneCoords);
|
|
2144
|
-
const len = allLen * tailWidthFactor * swallowTailFactor;
|
|
2145
|
-
const swallowTailCoord = getThirdCoord(boneCoords[1], boneCoords[0], 0, len, true);
|
|
2146
|
-
const factor = tailWidth / allLen;
|
|
2147
|
-
const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, factor);
|
|
2148
|
-
const coordlength = bodyCoords.length;
|
|
2149
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
|
|
2150
|
-
leftCoords.push(neckLeft);
|
|
2151
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
|
|
2152
|
-
rightCoords.push(neckRight);
|
|
2153
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2154
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2155
|
-
return leftCoords.concat(headCoords, rightCoords.reverse(), [swallowTailCoord, leftCoords[0]]);
|
|
2156
|
-
} else return [];
|
|
2157
|
-
}
|
|
2158
1382
|
|
|
2159
1383
|
//#endregion
|
|
2160
|
-
//#region
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
return rlBodyCoords.concat(rArrowCoords, bodyCoords, lArrowCoords, lrBodyCoords);
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* 插值箭形上的点
|
|
2208
|
-
* @param coord1 - Wgs84坐标
|
|
2209
|
-
* @param coord2 - Wgs84坐标
|
|
2210
|
-
* @param coord3 - Wgs84坐标
|
|
2211
|
-
* @param clockWise - 是否顺时针
|
|
2212
|
-
*/
|
|
2213
|
-
function getArrowCoords(coord1, coord2, coord3, clockWise, options) {
|
|
2214
|
-
const midCoord = mid(coord1, coord2);
|
|
2215
|
-
const len = mathDistance(midCoord, coord3);
|
|
2216
|
-
let midCoord1 = getThirdCoord(coord3, midCoord, 0, len * .3, true);
|
|
2217
|
-
let midCoord2 = getThirdCoord(coord3, midCoord, 0, len * .5, true);
|
|
2218
|
-
midCoord1 = getThirdCoord(midCoord, midCoord1, HALF_PI, len / 5, clockWise);
|
|
2219
|
-
midCoord2 = getThirdCoord(midCoord, midCoord2, HALF_PI, len / 4, clockWise);
|
|
2220
|
-
const coords = [
|
|
2221
|
-
midCoord,
|
|
2222
|
-
midCoord1,
|
|
2223
|
-
midCoord2,
|
|
2224
|
-
coord3
|
|
2225
|
-
];
|
|
2226
|
-
const arrowCoords = getArrowHeadCoords$1(coords, options);
|
|
2227
|
-
if (arrowCoords && Array.isArray(arrowCoords) && arrowCoords.length > 0) {
|
|
2228
|
-
const [neckLeftCoord, neckRightCoord] = [arrowCoords[0], arrowCoords[4]];
|
|
2229
|
-
const tailWidthFactor = mathDistance(coord1, coord2) / getBaseLength(coords) / 2;
|
|
2230
|
-
const bodyCoords = getArrowBodyCoords$1(coords, neckLeftCoord, neckRightCoord, tailWidthFactor);
|
|
2231
|
-
const n = bodyCoords.length;
|
|
2232
|
-
let lCoords = bodyCoords.slice(0, n / 2);
|
|
2233
|
-
let rCoords = bodyCoords.slice(n / 2, n);
|
|
2234
|
-
lCoords.push(neckLeftCoord);
|
|
2235
|
-
rCoords.push(neckRightCoord);
|
|
2236
|
-
lCoords = lCoords.reverse();
|
|
2237
|
-
lCoords.push(coord2);
|
|
2238
|
-
rCoords = rCoords.reverse();
|
|
2239
|
-
rCoords.push(coord1);
|
|
2240
|
-
return lCoords.reverse().concat(arrowCoords, rCoords);
|
|
2241
|
-
} else throw new Error("插值出错");
|
|
2242
|
-
}
|
|
2243
|
-
/**
|
|
2244
|
-
* 插值头部点
|
|
2245
|
-
* @param coords
|
|
2246
|
-
*/
|
|
2247
|
-
function getArrowHeadCoords$1(coords, options) {
|
|
2248
|
-
const { headHeightFactor, headWidthFactor, neckWidthFactor, neckHeightFactor } = options;
|
|
2249
|
-
const len = getBaseLength(coords);
|
|
2250
|
-
const headHeight = len * headHeightFactor;
|
|
2251
|
-
const headCoord = coords.at(-1);
|
|
2252
|
-
const headWidth = headHeight * headWidthFactor;
|
|
2253
|
-
const neckWidth = headHeight * neckWidthFactor;
|
|
2254
|
-
const neckHeight = headHeight * neckHeightFactor;
|
|
2255
|
-
const headEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, headHeight, true);
|
|
2256
|
-
const neckEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, neckHeight, true);
|
|
2257
|
-
const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
|
|
2258
|
-
const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
|
|
2259
|
-
const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
|
|
2260
|
-
const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
|
|
2261
|
-
return [
|
|
2262
|
-
neckLeft,
|
|
2263
|
-
headLeft,
|
|
2264
|
-
headCoord,
|
|
2265
|
-
headRight,
|
|
2266
|
-
neckRight
|
|
2267
|
-
];
|
|
2268
|
-
}
|
|
2269
|
-
/**
|
|
2270
|
-
* 插值面部分数据
|
|
2271
|
-
* @param coords
|
|
2272
|
-
* @param neckLeft
|
|
2273
|
-
* @param neckRight
|
|
2274
|
-
* @param tailWidthFactor
|
|
2275
|
-
*/
|
|
2276
|
-
function getArrowBodyCoords$1(coords, neckLeft, neckRight, tailWidthFactor) {
|
|
2277
|
-
const allLen = wholeDistance(coords);
|
|
2278
|
-
const len = getBaseLength(coords);
|
|
2279
|
-
const tailWidth = len * tailWidthFactor;
|
|
2280
|
-
const neckWidth = mathDistance(neckLeft, neckRight);
|
|
2281
|
-
const widthDif = (tailWidth - neckWidth) / 2;
|
|
2282
|
-
let tempLen = 0;
|
|
2283
|
-
const leftBodyCoords = [];
|
|
2284
|
-
const rightBodyCoords = [];
|
|
2285
|
-
for (let i = 1; i < coords.length - 1; i++) {
|
|
2286
|
-
const angle = getAngleOfThreeCoords(coords[i - 1], coords[i], coords[i + 1]) / 2;
|
|
2287
|
-
tempLen += mathDistance(coords[i - 1], coords[i]);
|
|
2288
|
-
const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
|
|
2289
|
-
const left = getThirdCoord(coords[i - 1], coords[i], Math.PI - angle, w, true);
|
|
2290
|
-
const right = getThirdCoord(coords[i - 1], coords[i], angle, w, false);
|
|
2291
|
-
leftBodyCoords.push(left);
|
|
2292
|
-
rightBodyCoords.push(right);
|
|
2293
|
-
}
|
|
2294
|
-
return leftBodyCoords.concat(rightBodyCoords);
|
|
2295
|
-
}
|
|
2296
|
-
/**
|
|
2297
|
-
* 获取对称点
|
|
2298
|
-
* @param lineCoord1
|
|
2299
|
-
* @param lineCoord2
|
|
2300
|
-
* @param coord
|
|
2301
|
-
*/
|
|
2302
|
-
function getTempCoord4(lineCoord1, lineCoord2, coord) {
|
|
2303
|
-
const midCoord = mid(lineCoord1, lineCoord2);
|
|
2304
|
-
const len = mathDistance(midCoord, coord);
|
|
2305
|
-
const angle = getAngleOfThreeCoords(lineCoord1, midCoord, coord);
|
|
2306
|
-
if (angle < HALF_PI) {
|
|
2307
|
-
const distance1 = len * Math.sin(angle);
|
|
2308
|
-
const distance2 = len * Math.cos(angle);
|
|
2309
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
|
|
2310
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
|
|
2311
|
-
} else if (angle >= HALF_PI && angle < Math.PI) {
|
|
2312
|
-
const distance1 = len * Math.sin(Math.PI - angle);
|
|
2313
|
-
const distance2 = len * Math.cos(Math.PI - angle);
|
|
2314
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
|
|
2315
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
|
|
2316
|
-
} else if (angle >= Math.PI && angle < Math.PI * 1.5) {
|
|
2317
|
-
const distance1 = len * Math.sin(angle - Math.PI);
|
|
2318
|
-
const distance2 = len * Math.cos(angle - Math.PI);
|
|
2319
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
|
|
2320
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
|
|
2321
|
-
} else {
|
|
2322
|
-
const distance1 = len * Math.sin(Math.PI * 2 - angle);
|
|
2323
|
-
const distance2 = len * Math.cos(Math.PI * 2 - angle);
|
|
2324
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
|
|
2325
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
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;
|
|
1424
|
+
}
|
|
1425
|
+
return { entities: [entity] };
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
2328
1428
|
|
|
2329
1429
|
//#endregion
|
|
2330
|
-
//#region
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
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
|
+
})
|
|
1458
|
+
});
|
|
1459
|
+
});
|
|
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);
|
|
1465
|
+
});
|
|
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;
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
return { entities };
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
2361
1477
|
|
|
2362
1478
|
//#endregion
|
|
2363
|
-
//#region
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
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] };
|
|
1497
|
+
}
|
|
2379
1498
|
});
|
|
2380
|
-
}
|
|
2381
1499
|
|
|
2382
1500
|
//#endregion
|
|
2383
|
-
//#region
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
tailRight,
|
|
2399
|
-
headHeightFactor,
|
|
2400
|
-
headWidthFactor,
|
|
2401
|
-
neckWidthFactor,
|
|
2402
|
-
neckHeightFactor
|
|
2403
|
-
});
|
|
2404
|
-
if (headCoords && headCoords.length > 4) {
|
|
2405
|
-
const neckLeft = headCoords[0];
|
|
2406
|
-
const neckRight = headCoords[4];
|
|
2407
|
-
const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
|
|
2408
|
-
const coordlength$1 = bodyCoords.length;
|
|
2409
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength$1 / 2));
|
|
2410
|
-
leftCoords.push(neckLeft);
|
|
2411
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
|
|
2412
|
-
rightCoords.push(neckRight);
|
|
2413
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2414
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2415
|
-
return leftCoords.concat(headCoords, rightCoords.reverse());
|
|
2416
|
-
} else return [];
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
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] };
|
|
1514
|
+
}
|
|
1515
|
+
});
|
|
2419
1516
|
|
|
2420
1517
|
//#endregion
|
|
2421
|
-
//#region
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
headWidthFactor,
|
|
2445
|
-
neckWidthFactor,
|
|
2446
|
-
neckHeightFactor
|
|
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);
|
|
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] };
|
|
1540
|
+
}
|
|
2447
1541
|
});
|
|
2448
|
-
if (headCoords && headCoords.length > 4) {
|
|
2449
|
-
const neckLeft = headCoords[0];
|
|
2450
|
-
const neckRight = headCoords[4];
|
|
2451
|
-
const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
|
|
2452
|
-
const coordlength$1 = bodyCoords.length;
|
|
2453
|
-
let leftCoords = [tailCoords[0]].concat(bodyCoords.slice(0, coordlength$1 / 2));
|
|
2454
|
-
leftCoords.push(neckLeft);
|
|
2455
|
-
let rightCoords = [tailCoords[2]].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
|
|
2456
|
-
rightCoords.push(neckRight);
|
|
2457
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2458
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2459
|
-
return leftCoords.concat(headCoords, rightCoords.reverse(), [tailCoords[1], leftCoords[0]]);
|
|
2460
|
-
}
|
|
2461
|
-
return [];
|
|
2462
|
-
}
|
|
2463
1542
|
|
|
2464
1543
|
//#endregion
|
|
2465
|
-
//#region
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
const coord1 = coords[i];
|
|
2488
|
-
const coord2 = coords[i + 1];
|
|
2489
|
-
pList.push(coord1);
|
|
2490
|
-
for (let t$1 = 0; t$1 <= FITTING_COUNT; t$1++) {
|
|
2491
|
-
const coord = getCubicValue(t$1 / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
|
|
2492
|
-
pList.push(coord);
|
|
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: {} })] };
|
|
1551
|
+
},
|
|
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);
|
|
1559
|
+
}
|
|
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] };
|
|
2493
1566
|
}
|
|
2494
|
-
|
|
2495
|
-
}
|
|
2496
|
-
return pList;
|
|
2497
|
-
}
|
|
1567
|
+
});
|
|
2498
1568
|
|
|
2499
1569
|
//#endregion
|
|
2500
|
-
//#region
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
if (coords.length > 1) {
|
|
2516
|
-
const startCoord = coords[0];
|
|
2517
|
-
const endCoord = coords.at(-1);
|
|
2518
|
-
const coord1 = startCoord;
|
|
2519
|
-
const coord2 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
|
|
2520
|
-
const coord3 = [(startCoord[0] + endCoord[0]) / 2, startCoord[1]];
|
|
2521
|
-
const coord4 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], -(endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
|
|
2522
|
-
const coord5 = [endCoord[0], startCoord[1]];
|
|
2523
|
-
const coord6 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2524
|
-
const coord7 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 3 / 8 + startCoord[1]];
|
|
2525
|
-
const coord8 = [(startCoord[0] + endCoord[0]) / 2, (startCoord[1] + endCoord[1]) / 2];
|
|
2526
|
-
const coord9 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 5 / 8 + startCoord[1]];
|
|
2527
|
-
const coord10 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2528
|
-
const coord11 = [startCoord[0], endCoord[1]];
|
|
2529
|
-
const curve1 = getBezierCoords([
|
|
2530
|
-
coord1,
|
|
2531
|
-
coord2,
|
|
2532
|
-
coord3,
|
|
2533
|
-
coord4,
|
|
2534
|
-
coord5
|
|
2535
|
-
]);
|
|
2536
|
-
const curve2 = getBezierCoords([
|
|
2537
|
-
coord6,
|
|
2538
|
-
coord7,
|
|
2539
|
-
coord8,
|
|
2540
|
-
coord9,
|
|
2541
|
-
coord10
|
|
2542
|
-
]);
|
|
2543
|
-
components = curve1.concat(curve2);
|
|
2544
|
-
components.push(coord11);
|
|
2545
|
-
}
|
|
2546
|
-
return components;
|
|
2547
|
-
}
|
|
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" } })] };
|
|
1577
|
+
},
|
|
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] };
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
2548
1585
|
|
|
2549
1586
|
//#endregion
|
|
2550
|
-
//#region
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
}
|
|
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
|
+
} })] };
|
|
1597
|
+
},
|
|
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] };
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
2569
1605
|
|
|
2570
1606
|
//#endregion
|
|
2571
|
-
//#region
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
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
|
+
})] };
|
|
1621
|
+
},
|
|
1622
|
+
render(options) {
|
|
1623
|
+
const { mouse, packable } = options;
|
|
1624
|
+
const entity = options.previous.entities[0];
|
|
1625
|
+
const positions = [...packable.positions ?? []];
|
|
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
|
+
});
|
|
2589
1643
|
|
|
2590
1644
|
//#endregion
|
|
2591
1645
|
//#region scheme/PolygonArc.ts
|
|
2592
|
-
const PlotSchemePolygonArc = new PlotScheme({
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
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: {} })] };
|
|
1652
|
+
},
|
|
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] };
|
|
2607
1665
|
}
|
|
2608
|
-
|
|
2609
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2610
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2611
|
-
return { entities: [entity] };
|
|
2612
|
-
}
|
|
2613
|
-
});
|
|
1666
|
+
});
|
|
2614
1667
|
|
|
2615
1668
|
//#endregion
|
|
2616
1669
|
//#region scheme/PolygonArrowAttackDirection.ts
|
|
2617
|
-
const PlotSchemePolygonArrowAttackDirection = new PlotScheme({
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
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] };
|
|
2636
1693
|
}
|
|
2637
|
-
|
|
2638
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2639
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2640
|
-
return { entities: [entity] };
|
|
2641
|
-
}
|
|
2642
|
-
});
|
|
1694
|
+
});
|
|
2643
1695
|
|
|
2644
1696
|
//#endregion
|
|
2645
1697
|
//#region scheme/PolygonArrowAttackDirectionTailed.ts
|
|
2646
|
-
const PlotSchemePolygonArrowAttackDirectionTailed = new PlotScheme({
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
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] };
|
|
2665
1721
|
}
|
|
2666
|
-
|
|
2667
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2668
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2669
|
-
return { entities: [entity] };
|
|
2670
|
-
}
|
|
2671
|
-
});
|
|
1722
|
+
});
|
|
2672
1723
|
|
|
2673
1724
|
//#endregion
|
|
2674
1725
|
//#region scheme/PolygonArrowClamped.ts
|
|
2675
|
-
const PlotSchemePolygonArrowClamped = new PlotScheme({
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
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] };
|
|
2688
1746
|
}
|
|
2689
|
-
|
|
2690
|
-
if (coords.length >= 3) {
|
|
2691
|
-
const positions = arrowClamped(coords);
|
|
2692
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
2693
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2694
|
-
} else entity.polygon.hierarchy = void 0;
|
|
2695
|
-
return { entities: [entity] };
|
|
2696
|
-
}
|
|
2697
|
-
});
|
|
1747
|
+
});
|
|
2698
1748
|
|
|
2699
1749
|
//#endregion
|
|
2700
1750
|
//#region scheme/PolygonArrowStraight.ts
|
|
2701
|
-
const PlotSchemePolygonArrowStraight = new PlotScheme({
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
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] };
|
|
2714
1771
|
}
|
|
2715
|
-
|
|
2716
|
-
if (coords.length >= 2) {
|
|
2717
|
-
const positions = arrowStraight(coords);
|
|
2718
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
2719
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2720
|
-
} else entity.polygon.hierarchy = void 0;
|
|
2721
|
-
return { entities: [entity] };
|
|
2722
|
-
}
|
|
2723
|
-
});
|
|
1772
|
+
});
|
|
2724
1773
|
|
|
2725
1774
|
//#endregion
|
|
2726
1775
|
//#region scheme/PolygonArrowStraightSharp.ts
|
|
2727
|
-
const PlotSchemePolygonArrowStraightSharp = new PlotScheme({
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
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] };
|
|
2740
1796
|
}
|
|
2741
|
-
|
|
2742
|
-
if (coords.length >= 2) {
|
|
2743
|
-
const positions = arrowStraightSharp(coords);
|
|
2744
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
2745
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2746
|
-
} else entity.polygon.hierarchy = void 0;
|
|
2747
|
-
return { entities: [entity] };
|
|
2748
|
-
}
|
|
2749
|
-
});
|
|
1797
|
+
});
|
|
2750
1798
|
|
|
2751
1799
|
//#endregion
|
|
2752
1800
|
//#region scheme/PolygonArrowUnitCombatOperation.ts
|
|
2753
|
-
const PlotSchemePolygonArrowUnitCombatOperation = new PlotScheme({
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
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] };
|
|
2772
1824
|
}
|
|
2773
|
-
|
|
2774
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2775
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2776
|
-
return { entities: [entity] };
|
|
2777
|
-
}
|
|
2778
|
-
});
|
|
1825
|
+
});
|
|
2779
1826
|
|
|
2780
1827
|
//#endregion
|
|
2781
1828
|
//#region scheme/PolygonArrowUnitCombatOperationTailed.ts
|
|
2782
|
-
const PlotSchemePolygonArrowUnitCombatOperationTailed = new PlotScheme({
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
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] };
|
|
2801
1852
|
}
|
|
2802
|
-
|
|
2803
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2804
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2805
|
-
return { entities: [entity] };
|
|
2806
|
-
}
|
|
2807
|
-
});
|
|
1853
|
+
});
|
|
2808
1854
|
|
|
2809
1855
|
//#endregion
|
|
2810
1856
|
//#region scheme/PolygonAssemblingPlace.ts
|
|
2811
|
-
const PlotSchemePolygonAssemblingPlace = new PlotScheme({
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2843
|
-
skeletons: [moved, control],
|
|
2844
|
-
initRender() {
|
|
2845
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2846
|
-
},
|
|
2847
|
-
render(context) {
|
|
2848
|
-
const entity = context.previous.entities[0];
|
|
2849
|
-
const points = context.packable.positions;
|
|
2850
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2851
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2852
|
-
if (coords.length < 2) {
|
|
2853
|
-
entity.polygon.hierarchy = void 0;
|
|
2854
|
-
return context.previous;
|
|
2855
|
-
}
|
|
2856
|
-
const positions = flagCurve(coords).map((item) => (0, vesium.toCartesian3)(item));
|
|
2857
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2858
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2859
|
-
return { entities: [entity] };
|
|
2860
|
-
}
|
|
2861
|
-
});
|
|
2862
|
-
|
|
2863
|
-
//#endregion
|
|
2864
|
-
//#region scheme/PolygonFlagRect.ts
|
|
2865
|
-
const PlotSchemePolygonFlagRect = new PlotScheme({
|
|
2866
|
-
type: "PolygonFlagRect",
|
|
2867
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2868
|
-
skeletons: [moved, control],
|
|
2869
|
-
initRender() {
|
|
2870
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2871
|
-
},
|
|
2872
|
-
render(context) {
|
|
2873
|
-
const entity = context.previous.entities[0];
|
|
2874
|
-
const points = context.packable.positions;
|
|
2875
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2876
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2877
|
-
if (coords.length < 2) {
|
|
2878
|
-
entity.polygon.hierarchy = void 0;
|
|
2879
|
-
return context.previous;
|
|
2880
|
-
}
|
|
2881
|
-
const positions = flagRect(coords).map((item) => (0, vesium.toCartesian3)(item));
|
|
2882
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2883
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2884
|
-
return { entities: [entity] };
|
|
2885
|
-
}
|
|
2886
|
-
});
|
|
2887
|
-
|
|
2888
|
-
//#endregion
|
|
2889
|
-
//#region scheme/PolygonFlagTriangle.ts
|
|
2890
|
-
const PlotSchemePolygonFlagTriangle = new PlotScheme({
|
|
2891
|
-
type: "PolygonFlagTriangle",
|
|
2892
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2893
|
-
skeletons: [moved, control],
|
|
2894
|
-
initRender() {
|
|
2895
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2896
|
-
},
|
|
2897
|
-
render(context) {
|
|
2898
|
-
const entity = context.previous.entities[0];
|
|
2899
|
-
const points = context.packable.positions;
|
|
2900
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2901
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2902
|
-
if (coords.length < 2) {
|
|
2903
|
-
entity.polygon.hierarchy = void 0;
|
|
2904
|
-
return context.previous;
|
|
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] };
|
|
2905
1888
|
}
|
|
2906
|
-
|
|
2907
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2908
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2909
|
-
return { entities: [entity] };
|
|
2910
|
-
}
|
|
2911
|
-
});
|
|
1889
|
+
});
|
|
2912
1890
|
|
|
2913
1891
|
//#endregion
|
|
2914
1892
|
//#region scheme/PolygonSmooth.ts
|
|
2915
|
-
const PlotSchemePolygonSmooth = new PlotScheme({
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
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] };
|
|
2934
1919
|
}
|
|
2935
|
-
|
|
2936
|
-
wgs84s.push(wgs84s[0]);
|
|
2937
|
-
const { features } = __turf_turf.polygonSmooth(__turf_turf.polygon([wgs84s]), { iterations: 3 });
|
|
2938
|
-
const cartesians = features[0].geometry.coordinates[0].map((item) => (0, vesium.toCartesian3)(item)).filter((e) => !!e);
|
|
2939
|
-
const hierarchy = new cesium.PolygonHierarchy(cartesians);
|
|
2940
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2941
|
-
return { entities: [entity] };
|
|
2942
|
-
}
|
|
2943
|
-
});
|
|
1920
|
+
});
|
|
2944
1921
|
|
|
2945
1922
|
//#endregion
|
|
2946
1923
|
//#region scheme/Polyline.ts
|
|
2947
|
-
const PlotSchemePolyline = new PlotScheme({
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
});
|
|
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] };
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
2971
1948
|
|
|
2972
1949
|
//#endregion
|
|
2973
1950
|
//#region scheme/PolylineCurve.ts
|
|
2974
|
-
const PlotSchemePolylineCurve = new PlotScheme({
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
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] };
|
|
2996
1978
|
}
|
|
2997
|
-
|
|
2998
|
-
const { geometry: { coordinates } } = __turf_turf.bezierSpline(__turf_turf.lineString(coords));
|
|
2999
|
-
entity.polyline.positions = new cesium.CallbackProperty(() => coordinates.map(vesium.toCartesian3), false);
|
|
3000
|
-
return { entities: [entity] };
|
|
3001
|
-
}
|
|
3002
|
-
});
|
|
1979
|
+
});
|
|
3003
1980
|
|
|
3004
1981
|
//#endregion
|
|
3005
1982
|
//#region scheme/Rectangle.ts
|
|
3006
|
-
const PlotSchemeRectangle = new PlotScheme({
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
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] };
|
|
3021
2002
|
}
|
|
3022
|
-
|
|
3023
|
-
entity.rectangle.coordinates = new cesium.CallbackProperty(() => coordinates, false);
|
|
3024
|
-
return { entities: [entity] };
|
|
3025
|
-
}
|
|
3026
|
-
});
|
|
2003
|
+
});
|
|
3027
2004
|
|
|
3028
2005
|
//#endregion
|
|
3029
2006
|
exports.PlotAction = PlotAction;
|
|
@@ -3045,9 +2022,6 @@ exports.PlotSchemePolygonArrowStraightSharp = PlotSchemePolygonArrowStraightShar
|
|
|
3045
2022
|
exports.PlotSchemePolygonArrowUnitCombatOperation = PlotSchemePolygonArrowUnitCombatOperation;
|
|
3046
2023
|
exports.PlotSchemePolygonArrowUnitCombatOperationTailed = PlotSchemePolygonArrowUnitCombatOperationTailed;
|
|
3047
2024
|
exports.PlotSchemePolygonAssemblingPlace = PlotSchemePolygonAssemblingPlace;
|
|
3048
|
-
exports.PlotSchemePolygonFlagCurve = PlotSchemePolygonFlagCurve;
|
|
3049
|
-
exports.PlotSchemePolygonFlagRect = PlotSchemePolygonFlagRect;
|
|
3050
|
-
exports.PlotSchemePolygonFlagTriangle = PlotSchemePolygonFlagTriangle;
|
|
3051
2025
|
exports.PlotSchemePolygonSmooth = PlotSchemePolygonSmooth;
|
|
3052
2026
|
exports.PlotSchemePolyline = PlotSchemePolyline;
|
|
3053
2027
|
exports.PlotSchemePolylineCurve = PlotSchemePolylineCurve;
|
|
@@ -3062,5 +2036,5 @@ exports.moved = moved;
|
|
|
3062
2036
|
exports.schemeMeasureArea = schemeMeasureArea;
|
|
3063
2037
|
exports.schemeMeasureDistance = schemeMeasureDistance;
|
|
3064
2038
|
exports.usePlot = usePlot;
|
|
3065
|
-
})(this.Vesium = this.Vesium || {}, Cesium, Vesium, VueUse, Vue, turf);
|
|
2039
|
+
})(this.Vesium = this.Vesium || {}, Cesium, Vesium, VueUse, Vue, Vesium, turf);
|
|
3066
2040
|
//# sourceMappingURL=index.iife.js.map
|