Cesium 自定义Material 系列 (二十)
- 对于缩放 圆效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
-
export interface PMaterialZoom{
-
color?: any,
-
speed?: number,
-
zoom?: boolean,
-
}
- 对于缩放 圆我们叫 MaterialZoom
```javascript
import { MaterialProperty } from "./MaterialProperty";
const defaultOption: PMaterialZoom = {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1,
zoom:true//true:放大,false缩小
}
//缩放效果
export class MaterialZoom extends MaterialProperty {
public _getType(option: PMaterialZoom) {
// 由于参数需要动态变动,所以count有变动,认为是新着色器
const { zoom=true } = option;
return MaterialTrailImage${zoom}
}
constructor(option = defaultOption) {
super(MaterialZoom.prototype, defaultOption, option);
}
protected _getTranslucent(material: any) {
return material.uniforms.color.alpha < 1.0;
}
-
protected getSource(option: PMaterialZoom): string {
-
const { zoom=true } = option;
-
let timeStr;
-
if(zoom){
-
timeStr = "float time = fract(czm_frameNumber * speed / 1000.0);";
-
}else{
-
timeStr = " float time = 1.0-fract(czm_frameNumber * speed / 1000.0);"
-
}
-
return `
-
uniform vec4 color;
-
uniform float speed;
-
-
czm_material czm_getMaterial(czm_materialInput materialInput){
更多参考 https://xiaozhuanlan.com/topic/3481295067