-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shared): ✨ added custom material
VcLineTrail
- Loading branch information
Showing
13 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/shared/extends/materials/VcLineTrailMaterialProperty.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* @Author: zouyaoji@https://github.com/zouyaoji | ||
* @Date: 2023-08-17 23:55:24 | ||
* @Description: Do not edit | ||
* @LastEditors: zouyaoji 370681295@qq.com | ||
* @LastEditTime: 2024-02-29 00:43:57 | ||
* @FilePath: \vue-cesium\packages\shared\extends\materials\VcLineTrailMaterialProperty.ts | ||
*/ | ||
import { getCesiumColor, getCesiumValue } from '@vue-cesium/utils/util' | ||
import VcBaseMaterialProperty from './VcBaseMaterialProperty' | ||
|
||
export default class VcLineTrailMaterialProperty extends VcBaseMaterialProperty { | ||
image: string | ||
color: Cesium.Color | ||
axisY: boolean | ||
time: number | ||
duration: number | ||
repeat: Cesium.Cartesian2 | ||
loop: boolean | ||
lastTime: number | ||
_time: number | ||
|
||
constructor(options: any = {}) { | ||
super(options) | ||
const { Color, Cartesian2, defined } = Cesium | ||
this.image = options.image ?? options.url | ||
this.color = options.color ?? new Color(1, 0, 0, 1) | ||
this.axisY = options.axisY ?? false | ||
this.time = options.time ?? 0 | ||
this.repeat = options.repeat ?? new Cartesian2(1, 1) | ||
this.loop = options.loop ?? true | ||
this.duration = options.duration ?? 3 | ||
this._time = (new Date()).getTime() | ||
} | ||
|
||
getType(value) { | ||
return 'VcLineTrail' | ||
} | ||
|
||
getValue(time: Cesium.JulianDate, result?): VcLineTrailMaterialProperty { | ||
const { Color, Cartesian2, defined } = Cesium | ||
!defined(result) && (result = {}) | ||
|
||
if (this.lastTime >= 0.99 && !this.loop) { | ||
return result | ||
} | ||
|
||
result.image = this.image | ||
result.color = getCesiumColor(this.color, new Color(1, 1, 1, 0), time) | ||
result.repeat = getCesiumValue(this.repeat, Cartesian2, time) | ||
result.axisY = this.axisY | ||
result.time = (((new Date()).getTime() - this._time) % this.duration) / this.duration | ||
this.lastTime = result.time | ||
return result as VcLineTrailMaterialProperty | ||
} | ||
|
||
equals(other: VcLineTrailMaterialProperty) { | ||
const reData = | ||
this === other || | ||
(other instanceof VcLineTrailMaterialProperty && | ||
Cesium.Property['equals'](this.color, other.color) && | ||
Cesium.Property['equals'](this.repeat, other.repeat) && | ||
this.image === other.image && | ||
this.axisY === other.axisY && | ||
this.duration === other.duration) | ||
return reData | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* @Author: zouyaoji@https://github.com/zouyaoji | ||
* @Date: 2023-08-17 00:10:56 | ||
* @Description: Do not edit | ||
* @LastEditors: zouyaoji 370681295@qq.com | ||
* @LastEditTime: 2024-02-29 00:35:07 | ||
* @FilePath: \vue-cesium\packages\shared\shaders\materials\VcLineTrailMaterial.ts | ||
*/ | ||
export default ` | ||
czm_material czm_getMaterial(czm_materialInput materialInput) | ||
{ | ||
czm_material material = czm_getDefaultMaterial(materialInput); | ||
vec2 st = materialInput.st; | ||
vec4 colorImage = texture(image, vec2(fract(st.s - time), st.t)); | ||
material.alpha = colorImage.a * color.a; | ||
material.diffuse = (colorImage.rgb+color.rgb)/2.0; | ||
return material; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import VcCircleWaveMaterial from './VcCircleWaveMaterial' | ||
import VcLineFlowMaterial from './VcLineFlowMaterial' | ||
import VcLineTrailMaterial from './VcLineTrailMaterial' | ||
|
||
export { VcCircleWaveMaterial, VcLineFlowMaterial } | ||
export { VcCircleWaveMaterial, VcLineFlowMaterial, VcLineTrailMaterial } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.