Cesium 自定义Material 系列 (二十二)
- 对于弹性圆效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
-
export interface PMaterialElasticCircle{
-
color?: any,
-
speed?: number,
-
}
- 对于弹性圆我们叫 MaterialElasticCircle
``javascript import { MaterialProperty } from "../MaterialProperty"; const defaultOption: PMaterialElasticCircle = { color: new Cesium.Color(1.0, 0.0, 0.0, 0.7), speed: 5 } //弹性圆效果 export class MaterialElasticCircle extends MaterialProperty { protected _getType(option: any): string { return "MaterialElasticCircle" } constructor(option = defaultOption) { super(MaterialElasticCircle.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;
-
float circle(vec2 uv, float r, float blur) {
-
float d = length(uv) * 2.0;
-
float c = smoothstep(r+blur, r, d);
-
return c;
-
}
-
-
czm_material czm_getMaterial(czm_materialInput materialInput)
-
{
-
czm_material material = czm_getDefaultMaterial(materialInput);
更多参考 https://xiaozhuanlan.com/topic/3547862091