Переглянути джерело

add CloudPrimitive

tags/2.7.0
Caven Chen 4 роки тому
джерело
коміт
c6a69bc34d

+ 10
- 0
modules/layer/type/PrimitiveLayer.js Переглянути файл

this._labels = this._delegate.add(new Cesium.LabelCollection()) this._labels = this._delegate.add(new Cesium.LabelCollection())
this._billboards = this._delegate.add(new Cesium.BillboardCollection()) this._billboards = this._delegate.add(new Cesium.BillboardCollection())
this._polylines = this._delegate.add(new Cesium.PolylineCollection()) this._polylines = this._delegate.add(new Cesium.PolylineCollection())
if (Cesium.CloudCollection) {
this._clouds = this._delegate.add(new Cesium.CloudCollection())
}
this._state = State.INITIALIZED this._state = State.INITIALIZED
} }


return this._polylines return this._polylines
} }


get clouds() {
return this._clouds
}

/** /**
* Clears all primitives * Clears all primitives
* @returns {PrimitiveLayer} * @returns {PrimitiveLayer}
this._labels = this._delegate.add(new Cesium.LabelCollection()) this._labels = this._delegate.add(new Cesium.LabelCollection())
this._billboards = this._delegate.add(new Cesium.BillboardCollection()) this._billboards = this._delegate.add(new Cesium.BillboardCollection())
this._polylines = this._delegate.add(new Cesium.PolylineCollection()) this._polylines = this._delegate.add(new Cesium.PolylineCollection())
if (Cesium.CloudCollection) {
this._clouds = this._delegate.add(new Cesium.CloudCollection())
}
this._cache = {} this._cache = {}
this._state = State.CLEARED this._state = State.CLEARED
return this return this

+ 32
- 32
modules/overlay/Overlay.js Переглянути файл

return this._id return this._id
} }


get type() {
return ''
}

set id(id) { set id(id) {
this._bid = id this._bid = id
return this return this
} }
this._layer = layer this._layer = layer
this._mountedHook && this._mountedHook() 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 // for Entity
if (this._layer?.delegate?.entities && this._delegate) { if (this._layer?.delegate?.entities && this._delegate) {
this._layer.delegate.entities.add(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 { } else {
this._layer.delegate.add(this._delegate) this._layer.delegate.add(this._delegate)
} }
if (!this._layer || !this._delegate) { if (!this._layer || !this._delegate) {
return 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 // for Entity
if (this._layer?.delegate?.entities) { if (this._layer?.delegate?.entities) {
this._layer.delegate.entities.remove(this._delegate) 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 { } else {
this._layer.delegate.remove(this._delegate) this._layer.delegate.remove(this._delegate)
} }

+ 1
- 0
modules/overlay/index.js Переглянути файл

export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js' export { default as BillboardPrimitive } from './primitive/BillboardPrimitive.js'
export { default as BounceBillboardPrimitive } from './primitive/BounceBillboardPrimitive' export { default as BounceBillboardPrimitive } from './primitive/BounceBillboardPrimitive'
export { default as BounceLabelPrimitive } from './primitive/BounceLabelPrimitive' 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 DiffuseWallPrimitive } from './primitive/DiffuseWallPrimitive.js'
export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive' export { default as ElecEllipsoidPrimitive } from './primitive/ElecEllipsoidPrimitive'
export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive' export { default as FlowLinePrimitive } from './primitive/FlowLinePrimitive'

+ 64
- 0
modules/overlay/primitive/CloudPrimitive.js Переглянути файл

/**
* @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

+ 2
- 0
packages/core/src/components.js Переглянути файл

BillboardPrimitive, BillboardPrimitive,
BounceBillboardPrimitive, BounceBillboardPrimitive,
BounceLabelPrimitive, BounceLabelPrimitive,
CloudPrimitive,
DiffuseWallPrimitive, DiffuseWallPrimitive,
ElecEllipsoidPrimitive, ElecEllipsoidPrimitive,
FlowLinePrimitive, FlowLinePrimitive,
BillboardPrimitive, BillboardPrimitive,
BounceBillboardPrimitive, BounceBillboardPrimitive,
BounceLabelPrimitive, BounceLabelPrimitive,
CloudPrimitive,
DiffuseWallPrimitive, DiffuseWallPrimitive,
ElecEllipsoidPrimitive, ElecEllipsoidPrimitive,
FlowLinePrimitive, FlowLinePrimitive,

Завантаження…
Відмінити
Зберегти