Cesium 自定义Material 系列 (十九)
- 对于fade 圆效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
-
export interface PMaterialFade{
-
color?: any,
-
speed?: number,
-
}
- 对于fade 圆我们叫 MaterialFade
```javascript
import { MaterialProperty } from "./MaterialProperty";
const defaultOption: any = {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
speed: 1
}
export class MaterialFade extends MaterialProperty {
protected _getType(option: any): string {
return "MaterialFade"
}
constructor(option = defaultOption) {
super(MaterialFade.prototype, defaultOption, option);
}
protected _getTranslucent(material: any) {
return material.uniforms.color.alpha < 1.0;
}
-
protected getSource(option: any): string {
-
return `
-
uniform vec4 color;
-
uniform float speed;
-
-
czm_material czm_getMaterial(czm_materialInput materialInput){
-
czm_material material = czm_getDefaultMaterial(materialInput);
-
material.diffuse = 1.5 * color.rgb;
-
vec2 st = materialInput.st;
-
float dis = distance(st, vec2(0.5, 0.5));
-
float per = fract(czm_frameNumber * speed / 1000.0);
更多参考 https://xiaozhuanlan.com/topic/1520798634