Cesium 自定义Material 系列 (二十一)

  • 对于 折射纹理效果 我们先定义一下他的interface, 方便使用的人知道他的调用参数
  • export interface PMaterialRefraction{
  • cubeMap: {
  • positiveX: string,
  • negativeX: string,
  • positiveY: string,
  • negativeY: string,
  • positiveZ: string,
  • negativeZ: string
  • },
  • channels?:string,
  • indexOfRefractionRatio?:number
  • }
  • 对于折射纹理我们叫 MaterialRefraction

```javascript

import { MaterialProperty } from "../MaterialProperty";
const defaultOption: PMaterialRefraction = {
cubeMap: Cesium.Material.DefaultCubeMapId,
channels: 'rgb',
indexOfRefractionRatio: 0.9//折射率比
}
// 折射效果
export class MaterialRefraction extends MaterialProperty {
protected _getType(option: any): string {
return "MaterialRefraction"
}
constructor(option = defaultOption) {
super(MaterialRefraction.prototype, defaultOption, option);
}
protected _getTranslucent(material: any) {
return false;
}
protected getSource(option: any): string {
return `
uniform samplerCube cubeMap;
uniform float indexOfRefractionRatio;

  • czm_material czm_getMaterial(czm_materialInput materialInput){
  • czm_material material = czm_getDefaultMaterial(materialInput);
posted @ 2022-01-20 17:14  haibalai  阅读(55)  评论(0编辑  收藏  举报