|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /**
- * @Author: Caven
- * @Date: 2021-01-09 21:40:36
- */
-
- import { Cesium } from '@dc-modules/namespace'
- 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 ElecEllipsoidPrimitive extends Overlay {
- constructor(position, radius) {
- super()
- this._position = Parse.parsePosition(position)
- this._radius = radius || { x: 10, y: 10, z: 10 }
- this._delegate = new Cesium.Primitive({
- geometryInstances: new Cesium.GeometryInstance({
- geometry: {}
- })
- })
- this._state = State.INITIALIZED
- }
-
- get type() {
- return Overlay.getOverlayType('elec_ellipsoid_primitive')
- }
-
- set position(position) {
- this._position = Parse.parsePosition(position)
- this._delegate.geometryInstances.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
- Transform.transformWGS84ToCartesian(this._position)
- )
- return this
- }
-
- get position() {
- return this._position
- }
-
- set radius(radius) {
- this._radius = radius
- this._delegate.geometryInstances.geometry = new Cesium.EllipsoidGeometry({
- radii: this._radius,
- maximumCone: Cesium.Math.PI_OVER_TWO
- })
- return this
- }
-
- get radius() {
- return this._radius
- }
-
- /**
- *
- * @private
- */
- _setAppearance() {
- if (!this._style) {
- return
- }
- this._delegate.appearance = new Cesium.MaterialAppearance({
- material: Cesium.Material.fromType('EllipsoidElectric', {
- color: this._style?.color || Cesium.Color.GREEN,
- speed: this._style?.speed || 5
- })
- })
- }
-
- _mountedHook() {
- /**
- * set the radius
- */
- this.radius = this._radius
-
- /**
- * set the position
- */
- this.position = this._position
-
- /**
- * set the appearance
- */
- !this._delegate.appearance && this._setAppearance()
- }
-
- /**
- *
- * @param text
- * @param textStyle
- * @returns {ElecEllipsoidPrimitive}
- */
- setLabel(text, textStyle) {
- return this
- }
-
- /**
- * Sets Style
- * @param style
- * @returns {ElecEllipsoidPrimitive}
- */
- setStyle(style = {}) {
- if (Object.keys(style).length === 0) {
- return this
- }
- Util.merge(this._style, style)
- this._setAppearance()
- return this
- }
- }
-
- Overlay.registerType('elec_ellipsoid_primitive')
-
- export default ElecEllipsoidPrimitive
|