|
| 1 | +/* |
| 2 | + * @Author: zouyaoji@https://github.com/zouyaoji |
| 3 | + * @Date: 2023-08-17 23:55:24 |
| 4 | + * @Description: Do not edit |
| 5 | + * @LastEditors: zouyaoji 370681295@qq.com |
| 6 | + * @LastEditTime: 2024-02-29 00:43:57 |
| 7 | + * @FilePath: \vue-cesium\packages\shared\extends\materials\VcLineTrailMaterialProperty.ts |
| 8 | + */ |
| 9 | +import { getCesiumColor, getCesiumValue } from '@vue-cesium/utils/util' |
| 10 | +import VcBaseMaterialProperty from './VcBaseMaterialProperty' |
| 11 | + |
| 12 | +export default class VcLineTrailMaterialProperty extends VcBaseMaterialProperty { |
| 13 | + image: string |
| 14 | + color: Cesium.Color |
| 15 | + axisY: boolean |
| 16 | + time: number |
| 17 | + duration: number |
| 18 | + repeat: Cesium.Cartesian2 |
| 19 | + loop: boolean |
| 20 | + lastTime: number |
| 21 | + _time: number |
| 22 | + |
| 23 | + constructor(options: any = {}) { |
| 24 | + super(options) |
| 25 | + const { Color, Cartesian2, defined } = Cesium |
| 26 | + this.image = options.image ?? options.url |
| 27 | + this.color = options.color ?? new Color(1, 0, 0, 1) |
| 28 | + this.axisY = options.axisY ?? false |
| 29 | + this.time = options.time ?? 0 |
| 30 | + this.repeat = options.repeat ?? new Cartesian2(1, 1) |
| 31 | + this.loop = options.loop ?? true |
| 32 | + this.duration = options.duration ?? 3 |
| 33 | + this._time = (new Date()).getTime() |
| 34 | + } |
| 35 | + |
| 36 | + getType(value) { |
| 37 | + return 'VcLineTrail' |
| 38 | + } |
| 39 | + |
| 40 | + getValue(time: Cesium.JulianDate, result?): VcLineTrailMaterialProperty { |
| 41 | + const { Color, Cartesian2, defined } = Cesium |
| 42 | + !defined(result) && (result = {}) |
| 43 | + |
| 44 | + if (this.lastTime >= 0.99 && !this.loop) { |
| 45 | + return result |
| 46 | + } |
| 47 | + |
| 48 | + result.image = this.image |
| 49 | + result.color = getCesiumColor(this.color, new Color(1, 1, 1, 0), time) |
| 50 | + result.repeat = getCesiumValue(this.repeat, Cartesian2, time) |
| 51 | + result.axisY = this.axisY |
| 52 | + result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration |
| 53 | + this.lastTime = result.time |
| 54 | + return result as VcLineTrailMaterialProperty |
| 55 | + } |
| 56 | + |
| 57 | + equals(other: VcLineTrailMaterialProperty) { |
| 58 | + const reData = |
| 59 | + this === other || |
| 60 | + (other instanceof VcLineTrailMaterialProperty && |
| 61 | + Cesium.Property['equals'](this.color, other.color) && |
| 62 | + Cesium.Property['equals'](this.repeat, other.repeat) && |
| 63 | + this.image === other.image && |
| 64 | + this.axisY === other.axisY && |
| 65 | + this.duration === other.duration) |
| 66 | + return reData |
| 67 | + } |
| 68 | +} |
0 commit comments