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