@ino-cesium/primitive 0.0.2
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 +3 -0
- package/dist/index.d.ts +591 -0
- package/dist/index.js +1 -0
- package/package.json +47 -0
package/README.MD
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import * as Cesium from 'cesium';
|
|
2
|
+
import { CircleGeometry, Primitive, GroundPrimitive, Appearance } from 'cesium';
|
|
3
|
+
import { FeatureCollection, Point, Polygon, MultiPolygon, GeoJsonProperties, LineString, MultiLineString, Feature } from 'geojson';
|
|
4
|
+
import { Material } from '@ino-cesium/material';
|
|
5
|
+
import { BasePrimitive } from '@ino-cesium/common';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 定义标签接口
|
|
9
|
+
* @param id 标签的唯一标识符
|
|
10
|
+
* @param field 字段名称,用于从数据中提取标签文本
|
|
11
|
+
* @param font 字体样式
|
|
12
|
+
* @param fillColor 填充颜色
|
|
13
|
+
* @param outlineColor 轮廓颜色
|
|
14
|
+
* @param outlineWidth 轮廓宽度
|
|
15
|
+
* @param style 样式
|
|
16
|
+
* @param showBackground 是否显示背景
|
|
17
|
+
* @param backgroundColor 背景颜色
|
|
18
|
+
* @param backgroundPadding 背景填充
|
|
19
|
+
* @param scale 缩放比例
|
|
20
|
+
* @param horizontalOrigin 水平原点
|
|
21
|
+
* @param verticalOrigin 垂直原点
|
|
22
|
+
* @param pixelOffset 像素偏移
|
|
23
|
+
* @param eyeOffset 视角偏移
|
|
24
|
+
* @param heightReference 高度参考
|
|
25
|
+
* @param translucencyByDistance 透明度随距离变化
|
|
26
|
+
* @param pixelOffsetScaleByDistance 像素偏移随距离变化
|
|
27
|
+
* @param scaleByDistance 缩放随距离变化
|
|
28
|
+
* @param distanceDisplayCondition 显示距离条件
|
|
29
|
+
* @param disableDepthTestDistance 禁用深度测试距离
|
|
30
|
+
*/
|
|
31
|
+
interface ILabel {
|
|
32
|
+
/**
|
|
33
|
+
* 标签的唯一标识符
|
|
34
|
+
*/
|
|
35
|
+
id?: any;
|
|
36
|
+
/**
|
|
37
|
+
* 字段名称,用于从数据中提取标签文本
|
|
38
|
+
*/
|
|
39
|
+
field: string;
|
|
40
|
+
/**
|
|
41
|
+
* 字体样式
|
|
42
|
+
*/
|
|
43
|
+
font?: string;
|
|
44
|
+
/**
|
|
45
|
+
* 填充颜色
|
|
46
|
+
*/
|
|
47
|
+
fillColor?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 轮廓颜色
|
|
50
|
+
*/
|
|
51
|
+
outlineColor?: string;
|
|
52
|
+
/**
|
|
53
|
+
* 轮廓宽度
|
|
54
|
+
*/
|
|
55
|
+
outlineWidth?: number;
|
|
56
|
+
/**
|
|
57
|
+
* 样式
|
|
58
|
+
*/
|
|
59
|
+
style?: string;
|
|
60
|
+
/**
|
|
61
|
+
* 是否显示背景
|
|
62
|
+
*/
|
|
63
|
+
showBackground?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* 背景颜色
|
|
66
|
+
*/
|
|
67
|
+
backgroundColor?: string;
|
|
68
|
+
/**
|
|
69
|
+
* 背景填充
|
|
70
|
+
*/
|
|
71
|
+
backgroundPadding?: number[];
|
|
72
|
+
/**
|
|
73
|
+
* 缩放比例
|
|
74
|
+
*/
|
|
75
|
+
scale?: number;
|
|
76
|
+
/**
|
|
77
|
+
* 水平原点
|
|
78
|
+
*/
|
|
79
|
+
horizontalOrigin?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 垂直原点
|
|
82
|
+
*/
|
|
83
|
+
verticalOrigin?: number;
|
|
84
|
+
/**
|
|
85
|
+
* 像素偏移
|
|
86
|
+
*/
|
|
87
|
+
pixelOffset?: number[];
|
|
88
|
+
/**
|
|
89
|
+
* 视角偏移
|
|
90
|
+
*/
|
|
91
|
+
eyeOffset?: number[];
|
|
92
|
+
/**
|
|
93
|
+
* 高度参考
|
|
94
|
+
*/
|
|
95
|
+
heightReference?: Cesium.HeightReference;
|
|
96
|
+
/**
|
|
97
|
+
* 透明度随距离变化
|
|
98
|
+
*/
|
|
99
|
+
translucencyByDistance?: Cesium.NearFarScalar;
|
|
100
|
+
/**
|
|
101
|
+
* 像素偏移随距离变化
|
|
102
|
+
*/
|
|
103
|
+
pixelOffsetScaleByDistance?: Cesium.NearFarScalar;
|
|
104
|
+
/**
|
|
105
|
+
* 缩放随距离变化
|
|
106
|
+
*/
|
|
107
|
+
scaleByDistance?: Cesium.NearFarScalar;
|
|
108
|
+
/**
|
|
109
|
+
* 显示距离条件
|
|
110
|
+
*/
|
|
111
|
+
distanceDisplayCondition?: Cesium.DistanceDisplayCondition;
|
|
112
|
+
/**
|
|
113
|
+
* 禁用深度测试距离
|
|
114
|
+
*/
|
|
115
|
+
disableDepthTestDistance?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 定义点接口
|
|
119
|
+
* @param id 点的唯一标识符
|
|
120
|
+
* @param color 颜色
|
|
121
|
+
* @param pixelSize 像素大小
|
|
122
|
+
* @param outlineColor 轮廓颜色
|
|
123
|
+
* @param outlineWidth 轮廓宽度
|
|
124
|
+
* @param scaleByDistance 缩放随距离变化
|
|
125
|
+
* @param translucencyByDistance 透明度随距离变化
|
|
126
|
+
* @param distanceDisplayCondition 显示距离条件
|
|
127
|
+
* @param disableDepthTestDistance 禁用深度测试距离
|
|
128
|
+
*/
|
|
129
|
+
interface IPoint {
|
|
130
|
+
/**
|
|
131
|
+
* 点的唯一标识符
|
|
132
|
+
*/
|
|
133
|
+
id?: any;
|
|
134
|
+
/**
|
|
135
|
+
* 颜色
|
|
136
|
+
*/
|
|
137
|
+
color?: string;
|
|
138
|
+
/**
|
|
139
|
+
* 像素大小
|
|
140
|
+
*/
|
|
141
|
+
pixelSize?: number;
|
|
142
|
+
/**
|
|
143
|
+
* 轮廓颜色
|
|
144
|
+
*/
|
|
145
|
+
outlineColor?: string;
|
|
146
|
+
/**
|
|
147
|
+
* 轮廓宽度
|
|
148
|
+
*/
|
|
149
|
+
outlineWidth?: number;
|
|
150
|
+
/**
|
|
151
|
+
* 缩放随距离变化
|
|
152
|
+
*/
|
|
153
|
+
scaleByDistance?: Cesium.NearFarScalar;
|
|
154
|
+
/**
|
|
155
|
+
* 透明度随距离变化
|
|
156
|
+
*/
|
|
157
|
+
translucencyByDistance?: Cesium.NearFarScalar;
|
|
158
|
+
/**
|
|
159
|
+
* 显示距离条件
|
|
160
|
+
*/
|
|
161
|
+
distanceDisplayCondition?: Cesium.DistanceDisplayCondition;
|
|
162
|
+
/**
|
|
163
|
+
* 禁用深度测试距离
|
|
164
|
+
*/
|
|
165
|
+
disableDepthTestDistance?: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* 定义广告牌接口
|
|
169
|
+
* @param id 广告牌的唯一标识符
|
|
170
|
+
* @param show 是否显示
|
|
171
|
+
* @param image 图像或画布元素
|
|
172
|
+
* @param scale 缩放比例
|
|
173
|
+
* @param pixelOffset 像素偏移
|
|
174
|
+
* @param eyeOffset 视角偏移
|
|
175
|
+
* @param horizontalOrigin 水平原点
|
|
176
|
+
* @param verticalOrigin 垂直原点
|
|
177
|
+
* @param heightReference 高度参考
|
|
178
|
+
* @param color 颜色
|
|
179
|
+
* @param rotation 旋转角度
|
|
180
|
+
* @param alignedAxis 对齐轴
|
|
181
|
+
* @param sizeInMeters 是否以米为单位
|
|
182
|
+
* @param width 宽度
|
|
183
|
+
* @param height 高度
|
|
184
|
+
* @param scaleByDistance 缩放随距离变化
|
|
185
|
+
* @param translucencyByDistance 透明度随距离变化
|
|
186
|
+
* @param pixelOffsetScaleByDistance 像素偏移随距离变化
|
|
187
|
+
* @param imageSubRegion 图像子区域
|
|
188
|
+
* @param distanceDisplayCondition 显示距离条件
|
|
189
|
+
* @param disableDepthTestDistance 禁用深度测试距离
|
|
190
|
+
*/
|
|
191
|
+
interface IBillboard {
|
|
192
|
+
/**
|
|
193
|
+
* 广告牌的唯一标识符
|
|
194
|
+
*/
|
|
195
|
+
id?: any;
|
|
196
|
+
/**
|
|
197
|
+
* 是否显示
|
|
198
|
+
*/
|
|
199
|
+
show?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* 图像或画布元素
|
|
202
|
+
*/
|
|
203
|
+
image?: string | HTMLCanvasElement;
|
|
204
|
+
/**
|
|
205
|
+
* 缩放比例
|
|
206
|
+
*/
|
|
207
|
+
scale?: number;
|
|
208
|
+
/**
|
|
209
|
+
* 像素偏移
|
|
210
|
+
*/
|
|
211
|
+
pixelOffset?: number[];
|
|
212
|
+
/**
|
|
213
|
+
* 视角偏移
|
|
214
|
+
*/
|
|
215
|
+
eyeOffset?: number[];
|
|
216
|
+
/**
|
|
217
|
+
* 水平原点
|
|
218
|
+
*/
|
|
219
|
+
horizontalOrigin?: Cesium.HorizontalOrigin;
|
|
220
|
+
/**
|
|
221
|
+
* 垂直原点
|
|
222
|
+
*/
|
|
223
|
+
verticalOrigin?: Cesium.VerticalOrigin;
|
|
224
|
+
/**
|
|
225
|
+
* 高度参考
|
|
226
|
+
*/
|
|
227
|
+
heightReference?: Cesium.HeightReference;
|
|
228
|
+
/**
|
|
229
|
+
* 颜色
|
|
230
|
+
*/
|
|
231
|
+
color?: string;
|
|
232
|
+
/**
|
|
233
|
+
* 旋转角度
|
|
234
|
+
*/
|
|
235
|
+
rotation?: number;
|
|
236
|
+
/**
|
|
237
|
+
* 对齐轴
|
|
238
|
+
*/
|
|
239
|
+
alignedAxis?: number[];
|
|
240
|
+
/**
|
|
241
|
+
* 是否以米为单位
|
|
242
|
+
*/
|
|
243
|
+
sizeInMeters?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* 宽度
|
|
246
|
+
*/
|
|
247
|
+
width?: number;
|
|
248
|
+
/**
|
|
249
|
+
* 高度
|
|
250
|
+
*/
|
|
251
|
+
height?: number;
|
|
252
|
+
/**
|
|
253
|
+
* 缩放随距离变化
|
|
254
|
+
*/
|
|
255
|
+
scaleByDistance?: Cesium.NearFarScalar;
|
|
256
|
+
/**
|
|
257
|
+
* 透明度随距离变化
|
|
258
|
+
*/
|
|
259
|
+
translucencyByDistance?: Cesium.NearFarScalar;
|
|
260
|
+
/**
|
|
261
|
+
* 像素偏移随距离变化
|
|
262
|
+
*/
|
|
263
|
+
pixelOffsetScaleByDistance?: Cesium.NearFarScalar;
|
|
264
|
+
/**
|
|
265
|
+
* 图像子区域
|
|
266
|
+
*/
|
|
267
|
+
imageSubRegion?: Cesium.BoundingRectangle;
|
|
268
|
+
/**
|
|
269
|
+
* 显示距离条件
|
|
270
|
+
*/
|
|
271
|
+
distanceDisplayCondition?: Cesium.DistanceDisplayCondition;
|
|
272
|
+
/**
|
|
273
|
+
* 禁用深度测试距离
|
|
274
|
+
*/
|
|
275
|
+
disableDepthTestDistance?: number;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 定义聚类接口
|
|
279
|
+
* @param id 聚类的唯一标识符
|
|
280
|
+
* @param radius 聚类半径
|
|
281
|
+
* @param maxZoom 最大缩放级别
|
|
282
|
+
* @param colorsByRate 聚合点的颜色组,通过聚合数量和总数的比例控制颜色
|
|
283
|
+
*/
|
|
284
|
+
interface Icluster {
|
|
285
|
+
/**
|
|
286
|
+
* 聚类的唯一标识符
|
|
287
|
+
*/
|
|
288
|
+
id?: any;
|
|
289
|
+
/**
|
|
290
|
+
* 聚类半径
|
|
291
|
+
*/
|
|
292
|
+
radius?: number;
|
|
293
|
+
/**
|
|
294
|
+
* 最大缩放级别
|
|
295
|
+
*/
|
|
296
|
+
maxZoom?: number;
|
|
297
|
+
/**
|
|
298
|
+
* 聚合点的颜色组,通过聚合数量和总数的比例控制颜色
|
|
299
|
+
* 例如:
|
|
300
|
+
* 0.1: '#ff0000',
|
|
301
|
+
* 0.01: '#ff00ff',
|
|
302
|
+
* 0.001: 'blue',
|
|
303
|
+
* 0.0001: '#00ff00',
|
|
304
|
+
*/
|
|
305
|
+
colorsByRate?: any;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* 定义点图元选项接口
|
|
309
|
+
* @param viewer Cesium viewer实例
|
|
310
|
+
* @param geoJson GeoJSON 数据
|
|
311
|
+
* @param calcHeight 是否根据地形计算点高度
|
|
312
|
+
* @param point 点样式
|
|
313
|
+
* @param billboard 广告牌样式
|
|
314
|
+
* @param label 标签样式
|
|
315
|
+
* @param cluster 聚类样式
|
|
316
|
+
*/
|
|
317
|
+
interface IPointPrimitivesOptions {
|
|
318
|
+
/**
|
|
319
|
+
* Cesium viewer实例
|
|
320
|
+
*/
|
|
321
|
+
viewer: Cesium.Viewer;
|
|
322
|
+
/**
|
|
323
|
+
* GeoJSON 数据
|
|
324
|
+
*/
|
|
325
|
+
geoJson: FeatureCollection<Point>;
|
|
326
|
+
/**
|
|
327
|
+
* 是否根据地形计算点高度
|
|
328
|
+
*/
|
|
329
|
+
calcHeight: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* 点样式
|
|
332
|
+
*/
|
|
333
|
+
point?: IPoint;
|
|
334
|
+
/**
|
|
335
|
+
* 广告牌样式
|
|
336
|
+
*/
|
|
337
|
+
billboard?: IBillboard;
|
|
338
|
+
/**
|
|
339
|
+
* 标签样式
|
|
340
|
+
*/
|
|
341
|
+
label?: ILabel;
|
|
342
|
+
/**
|
|
343
|
+
* 聚类样式
|
|
344
|
+
*/
|
|
345
|
+
cluster?: Icluster;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 定义雷达扫描图元选项接口
|
|
349
|
+
* @param viewer Cesium 查看器实例
|
|
350
|
+
* @param position 位置
|
|
351
|
+
* @param radius 半径
|
|
352
|
+
* @param appearanceOptions appearance配置
|
|
353
|
+
* @param materialOptions 材质配置
|
|
354
|
+
*/
|
|
355
|
+
interface IRaderScanPrimitiveOptions {
|
|
356
|
+
/**
|
|
357
|
+
* Cesium 查看器实例
|
|
358
|
+
*/
|
|
359
|
+
viewer: Cesium.Viewer;
|
|
360
|
+
/**
|
|
361
|
+
* 位置
|
|
362
|
+
*/
|
|
363
|
+
position: Cesium.Cartesian3;
|
|
364
|
+
/**
|
|
365
|
+
* 半径
|
|
366
|
+
*/
|
|
367
|
+
radius: number;
|
|
368
|
+
/**
|
|
369
|
+
* 是否贴地形
|
|
370
|
+
*/
|
|
371
|
+
ground?: boolean;
|
|
372
|
+
appearanceOptions?: Cesium.MaterialAppearance;
|
|
373
|
+
materialOptions?: Material.IRadarScanMaterialOptions;
|
|
374
|
+
}
|
|
375
|
+
interface ICircleAperturePrimitiveOptions {
|
|
376
|
+
/**
|
|
377
|
+
* 位置
|
|
378
|
+
*/
|
|
379
|
+
position: Cesium.Cartesian3;
|
|
380
|
+
/**
|
|
381
|
+
* 半径
|
|
382
|
+
*/
|
|
383
|
+
radius: number;
|
|
384
|
+
/**
|
|
385
|
+
* 是否贴地形
|
|
386
|
+
*/
|
|
387
|
+
ground?: boolean;
|
|
388
|
+
appearanceOptions?: Cesium.MaterialAppearance;
|
|
389
|
+
materialOptions?: Material.ICircleApertureMaterialOptions;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 定义地面多边形图元选项接口
|
|
393
|
+
* @param geoJson GeoJSON 数据
|
|
394
|
+
* @param line 线样式
|
|
395
|
+
*/
|
|
396
|
+
interface IGroundPolygonPrimitivesOptions {
|
|
397
|
+
/**
|
|
398
|
+
* GeoJSON 数据
|
|
399
|
+
*/
|
|
400
|
+
geoJson: FeatureCollection<Polygon | MultiPolygon, GeoJsonProperties>;
|
|
401
|
+
line: {
|
|
402
|
+
/**
|
|
403
|
+
* 线宽
|
|
404
|
+
*/
|
|
405
|
+
width?: number;
|
|
406
|
+
/**
|
|
407
|
+
* 线颜色
|
|
408
|
+
*/
|
|
409
|
+
color?: string;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* 定义地面折线图元选项接口
|
|
414
|
+
* @param geoJson GeoJSON 数据
|
|
415
|
+
* @param line 线样式
|
|
416
|
+
* @param material 材质颜色二选一
|
|
417
|
+
*/
|
|
418
|
+
interface IGroundPolylinePrimitivesOptions {
|
|
419
|
+
/**
|
|
420
|
+
* GeoJSON 数据
|
|
421
|
+
*/
|
|
422
|
+
geoJson: FeatureCollection<LineString | MultiLineString, GeoJsonProperties>;
|
|
423
|
+
line: {
|
|
424
|
+
/**
|
|
425
|
+
* 线宽
|
|
426
|
+
*/
|
|
427
|
+
width?: number;
|
|
428
|
+
/**
|
|
429
|
+
* 线颜色
|
|
430
|
+
*/
|
|
431
|
+
color?: string;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* 材质颜色二选一
|
|
435
|
+
*/
|
|
436
|
+
material?: Cesium.Material;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
type types_IBillboard = IBillboard;
|
|
440
|
+
type types_ICircleAperturePrimitiveOptions = ICircleAperturePrimitiveOptions;
|
|
441
|
+
type types_IGroundPolygonPrimitivesOptions = IGroundPolygonPrimitivesOptions;
|
|
442
|
+
type types_IGroundPolylinePrimitivesOptions = IGroundPolylinePrimitivesOptions;
|
|
443
|
+
type types_ILabel = ILabel;
|
|
444
|
+
type types_IPoint = IPoint;
|
|
445
|
+
type types_IPointPrimitivesOptions = IPointPrimitivesOptions;
|
|
446
|
+
type types_IRaderScanPrimitiveOptions = IRaderScanPrimitiveOptions;
|
|
447
|
+
type types_Icluster = Icluster;
|
|
448
|
+
declare namespace types {
|
|
449
|
+
export type { types_IBillboard as IBillboard, types_ICircleAperturePrimitiveOptions as ICircleAperturePrimitiveOptions, types_IGroundPolygonPrimitivesOptions as IGroundPolygonPrimitivesOptions, types_IGroundPolylinePrimitivesOptions as IGroundPolylinePrimitivesOptions, types_ILabel as ILabel, types_IPoint as IPoint, types_IPointPrimitivesOptions as IPointPrimitivesOptions, types_IRaderScanPrimitiveOptions as IRaderScanPrimitiveOptions, types_Icluster as Icluster };
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare class RadereScanPrimitive extends BasePrimitive<any> {
|
|
453
|
+
private position;
|
|
454
|
+
private options;
|
|
455
|
+
constructor(options: IRaderScanPrimitiveOptions);
|
|
456
|
+
getGeometry(): CircleGeometry;
|
|
457
|
+
getPrimitive(): Primitive | GroundPrimitive | Cesium.PointPrimitiveCollection | Cesium.GroundPolylinePrimitive | Cesium.LabelCollection | Cesium.PrimitiveCollection | undefined;
|
|
458
|
+
setAppearance(appearance?: Appearance): void;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 大量点 primitive 集合
|
|
463
|
+
*/
|
|
464
|
+
declare class PointPrimitives extends BasePrimitive<any> {
|
|
465
|
+
private options;
|
|
466
|
+
private pointPrimitives;
|
|
467
|
+
boundingSphere: Cesium.BoundingSphere;
|
|
468
|
+
private pointCollection;
|
|
469
|
+
private labelCollection;
|
|
470
|
+
private billboardCollection;
|
|
471
|
+
private clusterImageCache;
|
|
472
|
+
private supercluster;
|
|
473
|
+
constructor(options: IPointPrimitivesOptions);
|
|
474
|
+
initCollection: (geojson: FeatureCollection<Point, GeoJsonProperties>) => Promise<void>;
|
|
475
|
+
clacBoundingSphere(geoJson: FeatureCollection<Point, GeoJsonProperties>): void;
|
|
476
|
+
createPoint(feature: Feature<Point, GeoJsonProperties>): {
|
|
477
|
+
id: string;
|
|
478
|
+
position: Cesium.Cartesian3;
|
|
479
|
+
color: Cesium.Color;
|
|
480
|
+
pixelSize: any;
|
|
481
|
+
outlineColor: Cesium.Color;
|
|
482
|
+
outlineWidth: any;
|
|
483
|
+
scaleByDistance: any;
|
|
484
|
+
translucencyByDistance: any;
|
|
485
|
+
disableDepthTestDistance: any;
|
|
486
|
+
distanceDisplayCondition: any;
|
|
487
|
+
};
|
|
488
|
+
createBillboard(feature: Feature<Point, GeoJsonProperties>): {
|
|
489
|
+
id: string;
|
|
490
|
+
position: Cesium.Cartesian3;
|
|
491
|
+
image: any;
|
|
492
|
+
scale: any;
|
|
493
|
+
width: any;
|
|
494
|
+
height: any;
|
|
495
|
+
color: Cesium.Color | undefined;
|
|
496
|
+
pixelOffset: Cesium.Cartesian2;
|
|
497
|
+
horizontalOrigin: any;
|
|
498
|
+
verticalOrigin: any;
|
|
499
|
+
heightReference: any;
|
|
500
|
+
scaleByDistance: any;
|
|
501
|
+
translucencyByDistance: any;
|
|
502
|
+
disableDepthTestDistance: any;
|
|
503
|
+
distanceDisplayCondition: any;
|
|
504
|
+
};
|
|
505
|
+
createLabel(feature: Feature<Point, GeoJsonProperties>): {
|
|
506
|
+
id: string;
|
|
507
|
+
position: Cesium.Cartesian3;
|
|
508
|
+
text: any;
|
|
509
|
+
font: any;
|
|
510
|
+
fillColor: Cesium.Color;
|
|
511
|
+
outlineColor: Cesium.Color;
|
|
512
|
+
outlineWidth: any;
|
|
513
|
+
style: any;
|
|
514
|
+
scale: any;
|
|
515
|
+
showBackground: any;
|
|
516
|
+
backgroundColor: Cesium.Color;
|
|
517
|
+
backgroundPadding: Cesium.Cartesian2;
|
|
518
|
+
pixelOffset: Cesium.Cartesian2;
|
|
519
|
+
horizontalOrigin: any;
|
|
520
|
+
verticalOrigin: any;
|
|
521
|
+
heightReference: any;
|
|
522
|
+
scaleByDistance: any;
|
|
523
|
+
translucencyByDistance: any;
|
|
524
|
+
disableDepthTestDistance: any;
|
|
525
|
+
distanceDisplayCondition: any;
|
|
526
|
+
};
|
|
527
|
+
initCluster: (viewer: Cesium.Viewer, geoJson: FeatureCollection<Point>) => Promise<void>;
|
|
528
|
+
/**
|
|
529
|
+
* 缩放至聚合点子集
|
|
530
|
+
*/
|
|
531
|
+
flyToChildByClusterId(id: number): any[] | undefined;
|
|
532
|
+
loadCluster: (viewer: Cesium.Viewer) => void;
|
|
533
|
+
getClusterImageByCount(color: string, count: number, zoom: number): any;
|
|
534
|
+
calcfontSize(zoom: number): number;
|
|
535
|
+
calcPointHeight(viewer: Cesium.Viewer, geoJson: FeatureCollection<Point>): Promise<void>;
|
|
536
|
+
clearCollection(): void;
|
|
537
|
+
remove(): void;
|
|
538
|
+
removeAll(): void;
|
|
539
|
+
getPrimitive(): Cesium.PrimitiveCollection;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
declare class GroundPolylinePrimitives<T> extends BasePrimitive<T> {
|
|
543
|
+
private options;
|
|
544
|
+
private polylinePrimitives;
|
|
545
|
+
constructor(options: IGroundPolylinePrimitivesOptions);
|
|
546
|
+
initCollection(): void;
|
|
547
|
+
getPrimitive(): Cesium.GroundPolylinePrimitive | undefined;
|
|
548
|
+
setMaterialAppearance(): void;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 贴地多边形
|
|
553
|
+
*/
|
|
554
|
+
declare class GroundPolygonPrimitives<T> extends BasePrimitive<T> {
|
|
555
|
+
private options;
|
|
556
|
+
private primitives;
|
|
557
|
+
constructor(options: IGroundPolygonPrimitivesOptions);
|
|
558
|
+
initCollection(): void;
|
|
559
|
+
getPrimitive(): Cesium.GroundPolylinePrimitive | undefined;
|
|
560
|
+
getAppearance(appearance?: Cesium.Appearance): void;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Defines how screen space objects (billboards, points, labels) are clustered.
|
|
565
|
+
*
|
|
566
|
+
* @param {object} [options] An object with the following properties:
|
|
567
|
+
* @param {boolean} [options.enabled] Whether or not to enable clustering.
|
|
568
|
+
* @param {number} [options.pixelRange] The pixel range to extend the screen space bounding box.
|
|
569
|
+
* @param {number} [options.minimumClusterSize] The minimum number of screen space objects that can be clustered.
|
|
570
|
+
* @param {boolean} [options.clusterBillboards] Whether or not to cluster the billboards of an entity.
|
|
571
|
+
* @param {boolean} [options.clusterLabels] Whether or not to cluster the labels of an entity.
|
|
572
|
+
* @param {boolean} [options.clusterPoints] Whether or not to cluster the points of an entity.
|
|
573
|
+
* @param {boolean} [options.show] Determines if the entities in the cluster will be shown.
|
|
574
|
+
*
|
|
575
|
+
* @alias PrimitiveCluster
|
|
576
|
+
* @constructor
|
|
577
|
+
*
|
|
578
|
+
* @demo {@link https://sandcastle.cesium.com/index.html?src=Clustering.html|Cesium Sandcastle Clustering Demo}
|
|
579
|
+
*/
|
|
580
|
+
declare function PointClusterPrimitives(options: any): void;
|
|
581
|
+
|
|
582
|
+
declare class CircleAperturePrimitive extends BasePrimitive<any> {
|
|
583
|
+
private position;
|
|
584
|
+
private options;
|
|
585
|
+
constructor(options: ICircleAperturePrimitiveOptions);
|
|
586
|
+
getGeometry(): CircleGeometry;
|
|
587
|
+
getPrimitive(): Primitive | GroundPrimitive | Cesium.PointPrimitiveCollection | Cesium.GroundPolylinePrimitive | Cesium.LabelCollection | Cesium.PrimitiveCollection | undefined;
|
|
588
|
+
setAppearance(appearance?: Appearance): void;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export { CircleAperturePrimitive, GroundPolygonPrimitives, GroundPolylinePrimitives, PointClusterPrimitives, PointPrimitives, types as Primitives, RadereScanPrimitive };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"cesium";import{CircleGeometry as t,GeometryInstance as i,GroundPrimitive as o,Primitive as s,MaterialAppearance as l,BoundingRectangle as n,defined as r,defaultValue as c,Event as a,LabelCollection as h,BillboardCollection as d,PointPrimitiveCollection as p,Billboard as u,Matrix4 as g,Cartesian3 as m,Cartesian2 as b,SceneMode as C,Label as _,PointPrimitive as y}from"cesium";import{BasePrimitive as f,numberId as v,calcZoomFromCameraHeight as P}from"@ino-cesium/common";import{createScanRadarMaterial as B,createCircleApertureMaterial as w}from"@ino-cesium/material";import D from"supercluster";import I from"kdbush";class x extends f{position;options;constructor(e){super(),this.options=e,this.position=e.position,this.setAppearance()}getGeometry(){return new t({center:this.position,radius:this.options.radius})}getPrimitive(){if(!this.needUpdate&&this._primitive)return this._primitive;const e=this.getGeometry();if(!e)return;const t={geometryInstances:new i({geometry:e}),appearance:this.appearance,asynchronous:!1};return this.options.ground?new o(t):new s(t)}setAppearance(e){e?this.appearance=e:(this.appearance=new l({material:B(this.options.materialOptions||{}),flat:!1,faceForward:!1,translucent:!0,closed:!1,...this.options.appearanceOptions||{}}),this.options.viewer.scene.preRender.addEventListener((()=>{this.appearance.material.uniforms.radians+=3*Math.PI/300})))}}class S extends f{options;pointPrimitives=new e.PrimitiveCollection;boundingSphere=new e.BoundingSphere(e.Cartesian3.ZERO,0);pointCollection;labelCollection;billboardCollection;clusterImageCache={};supercluster;constructor(t){super(),this.options=t,this.clacBoundingSphere(this.options.geoJson),this.options.point&&(this.pointCollection=new e.PointPrimitiveCollection,this.pointPrimitives.add(this.pointCollection)),this.options.billboard&&(this.billboardCollection=new e.BillboardCollection({scene:t.viewer.scene}),this.pointPrimitives.add(this.billboardCollection)),this.options.label&&(this.labelCollection=new e.LabelCollection({scene:t.viewer.scene}),this.pointPrimitives.add(this.labelCollection)),t.cluster?(this.supercluster=new D({radius:this.options.cluster?.radius||A.radius,maxZoom:this.options.cluster?.maxZoom||A.maxZoom}),this.initCluster(this.options.viewer,this.options.geoJson)):this.initCollection(this.options.geoJson)}initCollection=async t=>{await this.calcPointHeight(this.options.viewer,t);const i=[];t.features.forEach((t=>{if(i.push(e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0)),this.options.point){this.pointCollection.add(this.createPoint(t)).properties=t.properties||{}}if(this.options.billboard){this.billboardCollection.add(this.createBillboard(t)).properties=t.properties||{}}if(this.options.label){this.labelCollection.add(this.createLabel(t)).properties=t.properties||{}}}))};clacBoundingSphere(t){const i=t.features.map((t=>e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0)));e.BoundingSphere.fromPoints(i,this.boundingSphere)}createPoint(t){const i={...L,...this.options.point,...t.properties?.style?.point};return{id:v(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]),color:e.Color.fromCssColorString(i.color),pixelSize:i.pixelSize,outlineColor:e.Color.fromCssColorString(i.outlineColor),outlineWidth:i.outlineWidth,scaleByDistance:i.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}createBillboard(t){const i={...O,...this.options.billboard,...t.properties?.style?.billboard};return{id:v(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]||0),image:i.image,scale:i.scale,width:t.properties?.cluster?void 0:i.width,height:t.properties?.cluster?void 0:i.height,color:t.properties?.cluster?void 0:e.Color.fromCssColorString(i.color),pixelOffset:e.Cartesian2.fromArray(i?.pixelOffset),horizontalOrigin:i.horizontalOrigin,verticalOrigin:i.verticalOrigin,heightReference:i.heightReference,scaleByDistance:i.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}createLabel(t){const i={...E,...this.options.label,...t.properties?.style?.label};return{id:v(),position:e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],t.geometry.coordinates[2]||0),text:t.properties?.[i?.field]||i?.field,font:i?.font,fillColor:e.Color.fromCssColorString(i?.fillColor),outlineColor:e.Color.fromCssColorString(i?.outlineColor),outlineWidth:i?.outlineWidth,style:i?.style,scale:i?.scale,showBackground:i?.showBackground,backgroundColor:e.Color.fromCssColorString(i?.backgroundColor),backgroundPadding:e.Cartesian2.fromArray(i?.backgroundPadding),pixelOffset:e.Cartesian2.fromArray(i?.pixelOffset),horizontalOrigin:i.horizontalOrigin,verticalOrigin:i.verticalOrigin,heightReference:i?.heightReference,scaleByDistance:i?.scaleByDistance,translucencyByDistance:i.translucencyByDistance,disableDepthTestDistance:i?.disableDepthTestDistance,distanceDisplayCondition:i.distanceDisplayCondition}}initCluster=async(t,i)=>{this.supercluster.load(i.features);let o=e.getTimestamp();this.loadCluster(t),t.camera.changed.addEventListener((()=>{e.getTimestamp()-o<=500||(o=e.getTimestamp(),this.loadCluster(t))}))};flyToChildByClusterId(t){const i=this.supercluster?.getChildren(t),o=i?.map((t=>e.Cartesian3.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1],0))),s=e.BoundingSphere.fromPoints(o);return this.options.viewer.camera.flyToBoundingSphere(s),i}loadCluster=t=>{const i=P(t.camera),o=t.camera.computeViewRectangle(),s=this.supercluster.getClusters([e.Math.toDegrees(o.west),e.Math.toDegrees(o.south),e.Math.toDegrees(o.east),e.Math.toDegrees(o.north)],i);this.clearCollection();const l=this.options.cluster.colorsByRate||A.colorsByRate,n={type:"FeatureCollection",features:s.map((e=>{const t=e.properties.point_count/this.options.geoJson.features.length,o=Object.keys(l).find((e=>t>Number(e)))||"#ff0000";if(e.properties.cluster){const t=this.getClusterImageByCount(l[o],e.properties.point_count,i),s=16*(String(e.properties.point_count).length+1);e.properties.style={...e.properties.style,billboard:{...e.properties.style?.billboard,image:t,pixelOffset:[0,-s/12]}}}return e}))};this.initCollection(n)};getClusterImageByCount(t,i,o){if(!this.clusterImageCache[i+t]){const s=16*(String(i).length+1);let l=-Math.PI/12;const n=Math.PI/2,r=Math.PI/6,c=document.createElement("canvas");c.width=s,c.height=s;const a=c.getContext("2d");a.save(),a.scale(s/24,s/24),a.beginPath(),a.arc(12,12,6,0,2*Math.PI),a.fillStyle=t,a.fill(),a.closePath(),a.lineWidth=2,a.fillStyle="rgba(255,255,255,1)",a.font=`${this.calcfontSize(o)}px Microsoft YaHei`,a.textAlign="center",a.textBaseline="middle",a.fillText(`${i}`,11.5,12.5);for(let i=0;i<3;i++)a.beginPath(),a.arc(12,12,8,l,l+n,!1),a.strokeStyle=e.Color.fromCssColorString(t).withAlpha(.4).toCssColorString(),a.stroke(),a.arc(12,12,11,l,l+n,!1),a.strokeStyle=e.Color.fromCssColorString(t).withAlpha(.2).toCssColorString(),a.stroke(),a.closePath(),l=l+n+r;a.restore(),this.clusterImageCache[i+t]=c.toDataURL()}return this.clusterImageCache[i+t]}calcfontSize(e){return e<4?4:e-1}async calcPointHeight(t,i){if(this.options.calcHeight)if(t.scene.terrainProvider instanceof e.EllipsoidTerrainProvider)i.features.forEach((e=>{3===e.geometry.coordinates.length?e.geometry.coordinates[2]=0:e.geometry.coordinates.push(0)}));else{const o=t.scene.terrainProvider,s=i.features.map((t=>e.Cartographic.fromDegrees(t.geometry.coordinates[0],t.geometry.coordinates[1]))),l=await e.sampleTerrainMostDetailed(o,s);i.features.forEach(((e,t)=>{3===e.geometry.coordinates.length?e.geometry.coordinates[2]=l[t].height:e.geometry.coordinates.push(l[t].height)}))}}clearCollection(){this.pointCollection?.removeAll(),this.billboardCollection?.removeAll(),this.labelCollection?.removeAll()}remove(){}removeAll(){this.clearCollection(),this.pointPrimitives.removeAll()}getPrimitive(){return this.pointPrimitives}}const L={color:"rgba(81,255,0,0.8)",pixelSize:10,outlineColor:"rgba(255,0,0,0.8)",outlineWidth:1},E={font:"20px sans-serif",fillColor:"rgba(255,255,255,0.8)",outlineColor:"rgba(0,0,0,0.8)",backgroundColor:"rgba(0,0,0,1)",outlineWidth:2,pixelOffset:[0,0],backgroundPadding:[0,0],scale:1,disableDepthTestDistance:0,horizontalOrigin:0,verticalOrigin:0,heightReference:e.HeightReference.CLAMP_TO_GROUND},O={image:"/icons/cesium-marker.png",scale:1,color:"rgba(255,0,0,1)",rotation:0,width:32,height:32,horizontalOrigin:0,verticalOrigin:0,pixelOffset:[0,-16],heightReference:e.HeightReference.CLAMP_TO_GROUND},A={radius:60,maxZoom:25,colorsByRate:{.1:"#ff0000",.01:"#ff00ff",.001:"blue",1e-4:"#00ff00"}},R={width:2,color:"rgba(0,255,0,0.8)"};class M extends f{options;polylinePrimitives;constructor(e){super(),this.options=e,this.polylinePrimitives=void 0,this.options.material&&this.setMaterialAppearance(),this.initCollection()}initCollection(){const t=[],i=[];let o;this.options.geoJson.features.forEach((e=>{"MultiLineString"===e.geometry.type?e.geometry.coordinates.forEach((t=>{i.push({coordinates:t,properties:e.properties})})):i.push({coordinates:e.geometry.coordinates,properties:e.properties})})),i.forEach((i=>{const o=i.coordinates.map((t=>e.Cartesian3.fromDegrees(t[0],t[1],t[2]))),s={...R,...this.options?.line,...i.properties?.style?.line};t.push(new e.GeometryInstance({id:v(),geometry:new e.GroundPolylineGeometry({positions:o,width:s?.width}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.fromCssColorString(s.color))}}))})),o=this.appearance?this.appearance:new e.PolylineColorAppearance,this.polylinePrimitives=new e.GroundPolylinePrimitive({geometryInstances:t,appearance:o})}getPrimitive(){return this.polylinePrimitives}setMaterialAppearance(){this.appearance=new e.MaterialAppearance({material:this.options.material})}}const T={width:2,color:"rgba(0,255,0,0.8)"};class z extends f{options;primitives;constructor(e){super(),this.options=e,this.primitives=void 0,this.initCollection()}initCollection(){const t=[];this.options.geoJson.features.forEach((i=>{let o;o="Polygon"===i.geometry.type?new e.PolygonHierarchy(e.Cartesian3.fromDegreesArray(i.geometry.coordinates[0].flat())):k(i.geometry);const s={...T,...this.options?.line,...i.properties?.style?.line},l=v();i.properties&&(i.properties.id=l);const n=new e.GeometryInstance({id:l,geometry:new e.PolygonGeometry({polygonHierarchy:o}),attributes:{color:e.ColorGeometryInstanceAttribute.fromColor(e.Color.fromCssColorString(s.color))}});t.push(n),n.properties=i.properties})),this.primitives=new e.GroundPrimitive({geometryInstances:t,appearance:new e.PerInstanceColorAppearance({})})}getPrimitive(){return this.primitives}getAppearance(t){this.appearance=t||new e.PolylineMaterialAppearance({material:e.Material.fromType("Color",{color:e.Color.fromCssColorString("rgba(81,255,0,0.8)")})})}}const k=t=>new e.PolygonHierarchy(e.Cartesian3.fromDegreesArray(t.coordinates[0][0].flat()));function G(e){e=c(e,c.EMPTY_OBJECT),this._enabled=c(e.enabled,!1),this._pixelRange=c(e.pixelRange,80),this._minimumClusterSize=c(e.minimumClusterSize,2),this._clusterBillboards=c(e.clusterBillboards,!0),this._clusterLabels=c(e.clusterLabels,!0),this._clusterPoints=c(e.clusterPoints,!0),this._labelCollection=void 0,this._billboardCollection=void 0,this._pointCollection=void 0,this._clusterBillboardCollection=void 0,this._clusterLabelCollection=void 0,this._clusterPointCollection=void 0,this._collectionIndicesByEntity={},this._unusedLabelIndices=[],this._unusedBillboardIndices=[],this._unusedPointIndices=[],this._previousClusters=[],this._previousHeight=void 0,this._enabledDirty=!1,this._clusterDirty=!1,this._cluster=void 0,this._removeEventListener=void 0,this._clusterEvent=new a,this.show=c(e.show,!0)}function H(e){return e.coord.x}function W(e){return e.coord.y}function J(e,t){e.x-=t,e.y-=t,e.width+=2*t,e.height+=2*t}const Z=new n;function U(e,t,i,o,s){if(r(e._labelCollection)&&o._clusterLabels?s=_.getScreenSpaceBoundingBox(e,t,s):r(e._billboardCollection)&&o._clusterBillboards?s=u.getScreenSpaceBoundingBox(e,t,s):r(e._pointPrimitiveCollection)&&o._clusterPoints&&(s=y.getScreenSpaceBoundingBox(e,t,s)),J(s,i),o._clusterLabels&&!r(e._labelCollection)&&r(e.id)&&F(o,e.id.id)&&r(e.id._label)){const l=o._collectionIndicesByEntity[e.id.id].labelIndex,r=o._labelCollection.get(l),c=_.getScreenSpaceBoundingBox(r,t,Z);J(c,i),s=n.union(s,c,s)}return s}function N(e,t){if(e.clusterShow=!0,!r(e._labelCollection)&&r(e.id)&&F(t,e.id.id)&&r(e.id._label)){const i=t._collectionIndicesByEntity[e.id.id].labelIndex;t._labelCollection.get(i).clusterShow=!0}}function j(e,t,i,o){const s={billboard:o._clusterBillboardCollection.add(),label:o._clusterLabelCollection.add(),point:o._clusterPointCollection.add()};s.billboard.show=!1,s.point.show=!1,s.label.show=!0,s.label.text=t.toLocaleString(),s.label.id=i,s.billboard.position=s.label.position=s.point.position=e,o._clusterEvent.raiseEvent(i,s)}function F(e,t){return r(e)&&r(e._collectionIndicesByEntity[t])&&r(e._collectionIndicesByEntity[t].labelIndex)}function V(e,t,i,o,s){if(!r(e))return;const l=e.length;for(let n=0;n<l;++n){const l=e.get(n);if(l.clusterShow=!1,!l.show||s._scene.mode===C.SCENE3D&&!o.isPointVisible(l.position))continue;const c=l.computeScreenSpacePosition(i);r(c)&&t.push({index:n,collection:e,clustered:!1,coord:c})}}const Y=new n,$=new n,q=new n;function K(e,t,i,o){return function(s){let l=this[e];r(this._collectionIndicesByEntity)||(this._collectionIndicesByEntity={});let n,c,a=this._collectionIndicesByEntity[s.id];if(r(a)||(a=this._collectionIndicesByEntity[s.id]={billboardIndex:void 0,labelIndex:void 0,pointIndex:void 0}),r(l)&&r(a[o]))return l.get(a[o]);r(l)||(l=this[e]=new t({scene:this._scene}));const h=this[i];return h.length>0?(n=h.pop(),c=l.get(n)):(c=l.add(),n=l.length-1),a[o]=n,Promise.resolve().then((()=>{this._clusterDirty=!0})),c}}function Q(e,t){const i=e._collectionIndicesByEntity[t];r(i.billboardIndex)||r(i.labelIndex)||r(i.pointIndex)||delete e._collectionIndicesByEntity[t]}function X(e){if(!r(e))return;const t=e.length;for(let i=0;i<t;++i)e.get(i).clusterShow=!0}G.prototype._initialize=function(t){this._scene=t;const i=(o=this,function(t){if(r(t)&&t<.05||!o.enabled)return;const i=o._scene,s=o._labelCollection,l=o._billboardCollection,c=o._pointCollection;if(!r(s)&&!r(l)&&!r(c)||!o._clusterBillboards&&!o._clusterLabels&&!o._clusterPoints)return;let a=o._clusterLabelCollection,C=o._clusterBillboardCollection,_=o._clusterPointCollection;r(a)?a.removeAll():a=o._clusterLabelCollection=new h({scene:i}),r(C)?C.removeAll():C=o._clusterBillboardCollection=new d({scene:i}),r(_)?_.removeAll():_=o._clusterPointCollection=new p;const y=o._pixelRange,f=o._minimumClusterSize,v=o._previousClusters,P=[],B=o._previousHeight,w=i.camera.positionCartographic.height,D=i.mapProjection.ellipsoid,x=i.camera.positionWC,S=new e.EllipsoidalOccluder(D,x),L=[];let E,O,A,R,M,T,z,k,G,J,Z,F;o._clusterLabels&&V(s,L,i,S,o),o._clusterBillboards&&V(l,L,i,S,o),o._clusterPoints&&V(c,L,i,S,o);const K=new I(L,H,W,64,Int32Array);if(w<B)for(A=v.length,E=0;E<A;++E){const e=v[E];if(!S.isPointVisible(e.position))continue;const t=u._computeScreenSpacePosition(g.IDENTITY,e.position,m.ZERO,b.ZERO,i);if(!r(t))continue;const s=1-w/B;let l=e.width=e.width*s,n=e.height=e.height*s;l=Math.max(l,e.minimumWidth),n=Math.max(n,e.minimumHeight);const c=t.x-.5*l,a=t.y-.5*n,h=t.x+l,d=t.y+n;for(M=K.range(c,a,h,d),T=M.length,J=0,G=[],O=0;O<T;++O)z=M[O],k=L[z],k.clustered||(++J,Z=k.collection,F=k.index,G.push(Z.get(F).id));if(J>=f)for(j(e.position,J,G,o),P.push(e),O=0;O<T;++O)L[M[O]].clustered=!0}for(A=L.length,E=0;E<A;++E){const e=L[E];if(e.clustered)continue;e.clustered=!0,Z=e.collection,F=e.index;const t=Z.get(F);R=U(t,e.coord,y,o,Y);const i=n.clone(R,$);M=K.range(R.x,R.y,R.x+R.width,R.y+R.height),T=M.length;const s=m.clone(t.position);for(J=1,G=[t.id],O=0;O<T;++O)if(z=M[O],k=L[z],!k.clustered){const e=k.collection.get(k.index),t=U(e,k.coord,y,o,q);m.add(e.position,s,s),n.union(i,t,i),++J,G.push(e.id)}if(J>=f){const e=m.multiplyByScalar(s,1/J,s);for(j(e,J,G,o),P.push({position:e,width:i.width,height:i.height,minimumWidth:R.width,minimumHeight:R.height}),O=0;O<T;++O)L[M[O]].clustered=!0}else N(t,o)}0===a.length&&(a.destroy(),o._clusterLabelCollection=void 0),0===C.length&&(C.destroy(),o._clusterBillboardCollection=void 0),0===_.length&&(_.destroy(),o._clusterPointCollection=void 0),o._previousClusters=P,o._previousHeight=w});var o;this._cluster=i,this._removeEventListener=t.camera.changed.addEventListener(i)},Object.defineProperties(G.prototype,{enabled:{get(){return this._enabled},set(e){this._enabledDirty=e!==this._enabled,this._enabled=e}},pixelRange:{get(){return this._pixelRange},set(e){this._clusterDirty=this._clusterDirty||e!==this._pixelRange,this._pixelRange=e}},minimumClusterSize:{get(){return this._minimumClusterSize},set(e){this._clusterDirty=this._clusterDirty||e!==this._minimumClusterSize,this._minimumClusterSize=e}},clusterEvent:{get(){return this._clusterEvent}},clusterBillboards:{get(){return this._clusterBillboards},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterBillboards,this._clusterBillboards=e}},clusterLabels:{get(){return this._clusterLabels},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterLabels,this._clusterLabels=e}},clusterPoints:{get(){return this._clusterPoints},set(e){this._clusterDirty=this._clusterDirty||e!==this._clusterPoints,this._clusterPoints=e}}}),G.prototype.getLabel=K("_labelCollection",h,"_unusedLabelIndices","labelIndex"),G.prototype.removeLabel=function(e){const t=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[e.id];if(!r(this._labelCollection)||!r(t)||!r(t.labelIndex))return;const i=t.labelIndex;t.labelIndex=void 0,Q(this,e.id);const o=this._labelCollection.get(i);o.show=!1,o.text="",o.id=void 0,this._unusedLabelIndices.push(i),this._clusterDirty=!0},G.prototype.getBillboard=K("_billboardCollection",d,"_unusedBillboardIndices","billboardIndex"),G.prototype.removeBillboard=function(e){const t=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[e.id];if(!r(this._billboardCollection)||!r(t)||!r(t.billboardIndex))return;const i=t.billboardIndex;t.billboardIndex=void 0,Q(this,e.id);const o=this._billboardCollection.get(i);o.id=void 0,o.show=!1,o.image=void 0,this._unusedBillboardIndices.push(i),this._clusterDirty=!0},G.prototype.getPoint=K("_pointCollection",p,"_unusedPointIndices","pointIndex"),G.prototype.removePoint=function(e){const t=this._collectionIndicesByEntity&&this._collectionIndicesByEntity[e.id];if(!r(this._pointCollection)||!r(t)||!r(t.pointIndex))return;const i=t.pointIndex;t.pointIndex=void 0,Q(this,e.id);const o=this._pointCollection.get(i);o.show=!1,o.id=void 0,this._unusedPointIndices.push(i),this._clusterDirty=!0},G.prototype.update=function(e){if(!this.show)return;let t;var i;r(this._labelCollection)&&this._labelCollection.length>0&&0===this._labelCollection.get(0)._glyphs.length&&(t=e.commandList,e.commandList=[],this._labelCollection.update(e),e.commandList=t),r(this._billboardCollection)&&this._billboardCollection.length>0&&!r(this._billboardCollection.get(0).width)&&(t=e.commandList,e.commandList=[],this._billboardCollection.update(e),e.commandList=t),this._enabledDirty&&(this._enabledDirty=!1,(i=this).enabled||(r(i._clusterLabelCollection)&&i._clusterLabelCollection.destroy(),r(i._clusterBillboardCollection)&&i._clusterBillboardCollection.destroy(),r(i._clusterPointCollection)&&i._clusterPointCollection.destroy(),i._clusterLabelCollection=void 0,i._clusterBillboardCollection=void 0,i._clusterPointCollection=void 0,X(i._labelCollection),X(i._billboardCollection),X(i._pointCollection)),this._clusterDirty=!0),this._clusterDirty&&(this._clusterDirty=!1,this._cluster()),r(this._clusterLabelCollection)&&this._clusterLabelCollection.update(e),r(this._clusterBillboardCollection)&&this._clusterBillboardCollection.update(e),r(this._clusterPointCollection)&&this._clusterPointCollection.update(e),r(this._labelCollection)&&this._labelCollection.update(e),r(this._billboardCollection)&&this._billboardCollection.update(e),r(this._pointCollection)&&this._pointCollection.update(e)},G.prototype.destroy=function(){this._labelCollection=this._labelCollection&&this._labelCollection.destroy(),this._billboardCollection=this._billboardCollection&&this._billboardCollection.destroy(),this._pointCollection=this._pointCollection&&this._pointCollection.destroy(),this._clusterLabelCollection=this._clusterLabelCollection&&this._clusterLabelCollection.destroy(),this._clusterBillboardCollection=this._clusterBillboardCollection&&this._clusterBillboardCollection.destroy(),this._clusterPointCollection=this._clusterPointCollection&&this._clusterPointCollection.destroy(),r(this._removeEventListener)&&(this._removeEventListener(),this._removeEventListener=void 0),this._labelCollection=void 0,this._billboardCollection=void 0,this._pointCollection=void 0,this._clusterBillboardCollection=void 0,this._clusterLabelCollection=void 0,this._clusterPointCollection=void 0,this._collectionIndicesByEntity=void 0,this._unusedLabelIndices=[],this._unusedBillboardIndices=[],this._unusedPointIndices=[],this._previousClusters=[],this._previousHeight=void 0,this._enabledDirty=!1,this._pixelRangeDirty=!1,this._minimumClusterSizeDirty=!1};class ee extends f{position;options;constructor(e){super(),this.options=e,this.position=e.position,this.setAppearance()}getGeometry(){return new t({center:this.position,radius:this.options.radius})}getPrimitive(){if(!this.needUpdate&&this._primitive)return this._primitive;this.needUpdate=!1;const e=this.getGeometry();if(!e)return;const t={geometryInstances:new i({geometry:e}),appearance:this.appearance,asynchronous:!1};return this.options.ground?new o(t):new s(t)}setAppearance(e){this.appearance=e||new l({material:w(this.options.materialOptions),flat:!1,faceForward:!1,translucent:!0,closed:!1})}}export{ee as CircleAperturePrimitive,z as GroundPolygonPrimitives,M as GroundPolylinePrimitives,G as PointClusterPrimitives,S as PointPrimitives,x as RadereScanPrimitive};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ino-cesium/primitive",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"author": "koino",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cesium",
|
|
8
|
+
"ino-cesium",
|
|
9
|
+
"ino-cesium-primitive"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.js"
|
|
13
|
+
},
|
|
14
|
+
"typesVersions": {
|
|
15
|
+
"*": {
|
|
16
|
+
"*": [
|
|
17
|
+
"./src/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/*.d.ts",
|
|
23
|
+
"dist/*.js",
|
|
24
|
+
"README.MD"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"cesium": "*"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ino-cesium/common": "0.0.2",
|
|
34
|
+
"@ino-cesium/material": "0.0.2",
|
|
35
|
+
"kdbush": "^3.0.0",
|
|
36
|
+
"supercluster": "^8.0.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/supercluster": "^7.1.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rimraf dist && rollup -c",
|
|
43
|
+
"clean": "rimraf dist",
|
|
44
|
+
"release": "pnpm publish --no-git-checks --access public ",
|
|
45
|
+
"unpublish": "pnpm unpublish @ino-cesium/primitive --force "
|
|
46
|
+
}
|
|
47
|
+
}
|