// @ts-nocheck import Utils from "../../Utils" import { Enviroment } from "../../Enviroment" import { type AreaInfo, ElementOperator, LineType } from '../Common' export type OutlineDes = { show: boolean width: number, color: Cesium.Color, editColor: Cesium.Color, type: LineType } export class SimpleOutlineOperator extends ElementOperator { private outline: Cesium.Polyline = undefined; inflate() { if (this.outline != undefined) { return; } this.outline = Enviroment.lines.add({ id: this.id, positions: this.info.positionList, width: this.des.width, loop: true, material: this.getMaterial(), disableDepthTestDistance: Number.POSITIVE_INFINITY, // 禁用深度测试 show: this.stateble.isVisible() && this.des.show }); } remove(): void { if (this.outline == undefined) { return; } Enviroment.lines.remove(this.outline); this.outline = undefined; } refresh(): void { if (this.outline == undefined) { return; } this.outline.width = this.des.width; this.outline.material = this.getMaterial(); this.outline.show = this.stateble.isVisible() && this.des.show; } reposite(): void { if (this.outline == undefined) { return; } this.outline.positions = this.info.positionList; } private getMaterial(): Cesium.Material { return new Cesium.Material.fromType( this.des.type, { color: (this.stateble.isEditing() ? this.des.editColor : this.des.color) } ); } } export class GroundOutlineOperator extends ElementOperator { private outline: Cesium.Primitive | undefined = undefined; inflate() { if (this.outline != undefined) { return; } const num = this.info.positionList.length; if (num < 2) { return; } // 复制数据,避免数据污染 const positionList = Utils.Position.copyList(this.info.positionList); const primitive = new Cesium.GroundPolylinePrimitive({ geometryInstances: new Cesium.GeometryInstance({ id: this.id, geometry: new Cesium.GroundPolylineGeometry({ positions: positionList, width: this.des.width, loop: true, vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEXT_FORMAT, }) }), appearance: new Cesium.EllipsoidSurfaceAppearance({ flat: true, material: this.getMaterial() }), asynchronous: false, show: this.stateble.isVisible() && this.des.show }); this.outline = Enviroment.primitives.add(primitive); } remove(): void { if (this.outline == undefined) { return; } Enviroment.primitives.remove(this.outline); this.outline.destroy(); this.outline = undefined; } refresh(): void { if (this.outline == undefined) { return; } this.outline.show = this.stateble.isVisible() && this.des.show; this.outline.appearance.material = this.getMaterial(); } reposite(): void { this.remove(); this.inflate(); } private getMaterial(): Cesium.Material { return new Cesium.Material.fromType( this.des.type, { color: (this.stateble.isEditing() ? this.des.editColor : this.des.color) } ); } }