|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /**
- * @Author: Caven
- * @Date: 2021-01-05 20:18:34
- */
-
- import { Cesium } from '@dc-modules/namespace'
- import State from '@dc-modules/state/State'
- import Parse from '@dc-modules/parse/Parse'
- import { Transform } from '@dc-modules/transform'
- import Overlay from '../Overlay'
-
- class FlowLinePrimitive extends Overlay {
- constructor(positions, width = 1) {
- super()
- this._positions = Parse.parsePositions(positions)
- this._width = width
- this._delegate = new Cesium.Primitive({
- geometryInstances: new Cesium.GeometryInstance({
- geometry: {}
- })
- })
- this._state = State.INITIALIZED
- }
-
- get type() {
- return Overlay.getOverlayType('flow_line_primitive')
- }
-
- set positions(positions) {
- this._positions = Parse.parsePositions(positions)
- this._delegate.geometryInstances.geometry = new Cesium.PolylineGeometry({
- positions: Transform.transformWGS84ArrayToCartesianArray(this._positions),
- width: this._width
- })
- return this
- }
-
- get positions() {
- return this._positions
- }
-
- /**
- *
- * @private
- */
- _setAppearance() {
- this._delegate.appearance = new Cesium.PolylineMaterialAppearance({
- material: Cesium.Material.fromType('PolylineFlow', {
- color: this._style?.color || new Cesium.Color(1.0, 0.0, 0.0, 0.7),
- speed: this._style?.speed || 1,
- percent: this._style?.percent || 0.03,
- gradient: this._style?.gradient || 0.1
- })
- })
- }
-
- _mountedHook() {
- /**
- * set the positions
- */
- this.positions = this._positions
- /**
- * set the appearance
- */
- !this._delegate.appearance && this._setAppearance()
- }
-
- /**
- *
- * @param text
- * @param textStyle
- * @returns {FlowLinePrimitive}
- */
- setLabel(text, textStyle) {
- return this
- }
-
- /**
- * Sets Style
- * @param style
- * @returns {FlowLinePrimitive}
- */
- setStyle(style = {}) {
- if (Object.keys(style).length === 0) {
- return this
- }
- this._style = style
- style.classificationType &&
- (this._delegate.classificationType = this._style.classificationType)
- this._setAppearance()
- return this
- }
- }
-
- Overlay.registerType('flow_line_primitive')
-
- export default FlowLinePrimitive
|