@ino-cesium/primitive 0.0.1-5.beta.1

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