| @@ -18,6 +18,9 @@ class PrimitiveLayer extends Layer { | |||
| this._labels = this._delegate.add(new Cesium.LabelCollection()) | |||
| this._billboards = this._delegate.add(new Cesium.BillboardCollection()) | |||
| this._polylines = this._delegate.add(new Cesium.PolylineCollection()) | |||
| if (Cesium.CloudCollection) { | |||
| this._clouds = this._delegate.add(new Cesium.CloudCollection()) | |||
| } | |||
| this._state = State.INITIALIZED | |||
| } | |||
| @@ -41,6 +44,10 @@ class PrimitiveLayer extends Layer { | |||
| return this._polylines | |||
| } | |||
| get clouds() { | |||
| return this._clouds | |||
| } | |||
| /** | |||
| * Clears all primitives | |||
| * @returns {PrimitiveLayer} | |||
| @@ -51,6 +58,9 @@ class PrimitiveLayer extends Layer { | |||
| this._labels = this._delegate.add(new Cesium.LabelCollection()) | |||
| this._billboards = this._delegate.add(new Cesium.BillboardCollection()) | |||
| this._polylines = this._delegate.add(new Cesium.PolylineCollection()) | |||
| if (Cesium.CloudCollection) { | |||
| this._clouds = this._delegate.add(new Cesium.CloudCollection()) | |||
| } | |||
| this._cache = {} | |||
| this._state = State.CLEARED | |||
| return this | |||
| @@ -30,6 +30,10 @@ class Overlay { | |||
| return this._id | |||
| } | |||
| get type() { | |||
| return '' | |||
| } | |||
| set id(id) { | |||
| this._bid = id | |||
| return this | |||
| @@ -126,25 +130,23 @@ class Overlay { | |||
| } | |||
| this._layer = layer | |||
| this._mountedHook && this._mountedHook() | |||
| let collection = { | |||
| point_primitive: this._layer.points, | |||
| billboard_primitive: this._layer.billboards, | |||
| bounce_billboard_primitive: this._layer.billboards, | |||
| label_primitive: this._layer.labels, | |||
| bounce_label_primitive: this._layer.labels, | |||
| polyline_primitive: this._layer.polylines, | |||
| cloud_primitive: this._layer.clouds | |||
| } | |||
| // for Entity | |||
| if (this._layer?.delegate?.entities && this._delegate) { | |||
| this._layer.delegate.entities.add(this._delegate) | |||
| } else if (this._layer?.delegate?.add && this._delegate) { | |||
| // for Primitive | |||
| if (this.type && this.type === 'point_primitive' && this._layer.points) { | |||
| this._delegate = this._layer.points.add(this._delegate) | |||
| } else if ( | |||
| this.type.indexOf('billboard_primitive') >= 0 && | |||
| this._layer.billboards | |||
| ) { | |||
| this._delegate = this._layer.billboards.add(this._delegate) | |||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | |||
| this._delegate = this._layer.polylines.add(this._delegate) | |||
| } else if ( | |||
| this.type.indexOf('label_primitive') >= 0 && | |||
| this._layer.labels | |||
| ) { | |||
| this._delegate = this._layer.labels.add(this._delegate) | |||
| } | |||
| // for Primitive | |||
| else if (this._layer?.delegate?.add && this._delegate) { | |||
| if (this.type && collection[this.type]) { | |||
| this._delegate = collection[this.type].add(this._delegate) | |||
| } else { | |||
| this._layer.delegate.add(this._delegate) | |||
| } | |||
| @@ -161,25 +163,23 @@ class Overlay { | |||
| if (!this._layer || !this._delegate) { | |||
| return | |||
| } | |||
| let collection = { | |||
| point_primitive: this._layer.points, | |||
| billboard_primitive: this._layer.billboards, | |||
| bounce_billboard_primitive: this._layer.billboards, | |||
| label_primitive: this._layer.labels, | |||
| bounce_label_primitive: this._layer.labels, | |||
| polyline_primitive: this._layer.polylines, | |||
| cloud_primitive: this._layer.clouds | |||
| } | |||
| // for Entity | |||
| if (this._layer?.delegate?.entities) { | |||
| this._layer.delegate.entities.remove(this._delegate) | |||
| } else if (this._layer?.delegate?.remove) { | |||
| // for Primitive | |||
| if (this.type === 'point_primitive' && this._layer.points) { | |||
| this._layer.points.remove(this._delegate) | |||
| } else if ( | |||
| this.type.indexOf('billboard_primitive') >= 0 && | |||
| this._layer.billboards | |||
| ) { | |||
| this._layer.billboards.remove(this._delegate) | |||
| } else if (this.type === 'polyline_primitive' && this._layer.polylines) { | |||
| this._layer.polylines.remove(this._delegate) | |||
| } else if ( | |||
| this.type.indexOf('label_primitive') >= 0 && | |||
| this._layer.labels | |||
| ) { | |||
| this._layer.labels.remove(this._delegate) | |||
| } | |||
| // for Primitive | |||
| else if (this._layer?.delegate?.remove) { | |||
| if (this.type && collection[this.type]) { | |||
| collection[this.type].remove(this._delegate) | |||
| } else { | |||
| this._layer.delegate.remove(this._delegate) | |||
| } | |||
| @@ -44,6 +44,7 @@ export { default as TailedAttackArrow } from './plot/TailedAttackArrow' | |||
| export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js' | |||
| export { default as BounceBillboardPrimitive } from './primitive/BounceBillboardPrimitive' | |||
| export { default as BounceLabelPrimitive } from './primitive/BounceLabelPrimitive' | |||
| export { default as CloudPrimitive } from './primitive/CloudPrimitive' | |||
| export { default as DiffuseWallPrimitive } from './primitive/DiffuseWallPrimitive.js' | |||
| export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' | |||
| export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' | |||
| @@ -0,0 +1,64 @@ | |||
| /** | |||
| * @Author: Caven | |||
| * @Date: 2021-11-08 20:35:42 | |||
| */ | |||
| import State from '@dc-modules/state/State' | |||
| import Parse from '@dc-modules/parse/Parse' | |||
| import { Util } from '@dc-modules/utils' | |||
| import { Transform } from '@dc-modules/transform' | |||
| import Overlay from '../Overlay' | |||
| class CloudPrimitive extends Overlay { | |||
| constructor(position) { | |||
| super() | |||
| this._position = Parse.parsePosition(position) | |||
| this._delegate = { | |||
| position: undefined, | |||
| scale: { x: 12, y: 8 } | |||
| } | |||
| this._state = State.INITIALIZED | |||
| } | |||
| get type() { | |||
| return Overlay.getOverlayType('cloud_primitive') | |||
| } | |||
| set position(position) { | |||
| this._position = Parse.parsePosition(position) | |||
| this._delegate.position = Transform.transformWGS84ToCartesian( | |||
| this._position | |||
| ) | |||
| return this | |||
| } | |||
| get position() { | |||
| return this._position | |||
| } | |||
| _mountedHook() { | |||
| /** | |||
| * set the location | |||
| */ | |||
| this.position = this._position | |||
| } | |||
| /** | |||
| * | |||
| * @param style | |||
| * @returns {CloudPrimitive} | |||
| */ | |||
| setStyle(style) { | |||
| if (!style || Object.keys(style).length === 0) { | |||
| return this | |||
| } | |||
| delete style['position'] | |||
| this._style = style | |||
| Util.merge(this._delegate, this._style) | |||
| return this | |||
| } | |||
| } | |||
| Overlay.registerType('cloud_primitive') | |||
| export default CloudPrimitive | |||
| @@ -79,6 +79,7 @@ import { | |||
| BillboardPrimitive, | |||
| BounceBillboardPrimitive, | |||
| BounceLabelPrimitive, | |||
| CloudPrimitive, | |||
| DiffuseWallPrimitive, | |||
| ElecEllipsoidPrimitive, | |||
| FlowLinePrimitive, | |||
| @@ -288,6 +289,7 @@ const components = { | |||
| BillboardPrimitive, | |||
| BounceBillboardPrimitive, | |||
| BounceLabelPrimitive, | |||
| CloudPrimitive, | |||
| DiffuseWallPrimitive, | |||
| ElecEllipsoidPrimitive, | |||
| FlowLinePrimitive, | |||