Cesium 自定义Material 系列 (九)

  • 对于扫描线效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
  • export interface PMaterialScan{
  • color?: any,
  • speed?: number,
  • }
  • 对于扫描线我们叫 MaterialScan

```javascript

import {MaterialProperty} from "./MaterialProperty";
const defaultOption: PMaterialScan = {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 10,
}
//扫描
export class MaterialScan extends MaterialProperty{
protected _getType(option: any): string {
return "MaterialScan"
}
constructor(option=defaultOption) {
super(MaterialScan.prototype, defaultOption, option);
}
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);
  • vec2 st = materialInput.st;
  • float time = fract(czm_frameNumber * speed / 1000.0);
  • material.diffuse = color.rgb;
  • material.alpha = color.a * fract(st.s-time);
posted @ 2022-01-20 17:03  haibalai  阅读(182)  评论(0编辑  收藏  举报