You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
/*
|
|
* @Author: cbwu 504-wuchengbo@htsdfp.com
|
|
* @Date: 2024-03-28 16:35:33
|
|
* @LastEditors: cbwu
|
|
* @LastEditTime: 2024-03-30 22:06:23
|
|
* @Description: 封装的点几何类
|
|
*/
|
|
import {
|
|
Entity,
|
|
Cartesian3,
|
|
Color,
|
|
PointGraphics,
|
|
PositionProperty,
|
|
LabelGraphics,
|
|
Cartesian2,
|
|
CallbackProperty,
|
|
Property,
|
|
} from 'cesium'
|
|
type EntityOptions = {
|
|
id?: string
|
|
name?: string
|
|
show?: boolean
|
|
pixelSize?: number
|
|
outlineColor?: Color
|
|
color?: Color
|
|
fillColor?: Color
|
|
fill?: boolean
|
|
width?: number
|
|
outlineWidth?: number
|
|
text?: string
|
|
font?: string
|
|
pixelOffset?: Cartesian2
|
|
}
|
|
// 点
|
|
class PointEntity extends Entity {
|
|
static ID: number = 0
|
|
public subId: number = 0 //用于作为其他几何体的控制点时标记节点号
|
|
options: EntityOptions = {
|
|
id: 'Point' + String(PointEntity.ID),
|
|
name: 'Point' + String(PointEntity.ID + 1),
|
|
show: true,
|
|
pixelSize: 10,
|
|
color: Color.GREEN,
|
|
outlineWidth: 0,
|
|
}
|
|
constructor(position: Cartesian3, options?: EntityOptions) {
|
|
super({
|
|
position: position,
|
|
})
|
|
this.options = { ...this.options, ...options }
|
|
//点对象
|
|
this.point = new PointGraphics({
|
|
pixelSize: this.options.pixelSize,
|
|
color: this.options.color,
|
|
outlineColor: this.options.outlineColor,
|
|
outlineWidth: this.options.outlineWidth,
|
|
})
|
|
// 标注对象
|
|
this.label = new LabelGraphics({
|
|
text: this.options.text,
|
|
font: this.options.font,
|
|
pixelOffset: this.options.pixelOffset,
|
|
})
|
|
|
|
PointEntity.ID++
|
|
}
|
|
}
|
|
|
|
export { PointEntity, type EntityOptions }
|