ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Cesium 自定义Material 系列 (一)

2022-01-21 11:00:52  阅读:160  来源: 互联网

标签:return option 自定义 defaultOption Material param ._ Cesium any


cesium 在materail 定义上还是比较自由的允许自己构建shader, 我整理一下常用的效果materail 设计
全程使用typescript 来编写这个系列。

首先我们要设计material 的基础类


const loadedMap = new Map<string, boolean="">();
// 着色器的基类
export abstract class MaterialProperty {
public _type_ = "";//类型,不允许修改
protected option: any = {};//用户传入的参数
public _definitionChanged: any = new Cesium.Event();
get isConstant() {
return false
}
get definitionChanged() {
return this._definitionChanged
}
/**
* 需要根据参数变化而新建新的着色器类型,可以动态修改他-----------参考MaterialTrailImage类
* @param option
/ protected abstract _getType(option: any):string; /*
* 获得着色器字符串
* @param option 参数
/ protected abstract getSource(option: any): string; /*
*
* @param childprototype 实现类的原型链
* @param defaultOption 默认的参数
* @param option 用户传入的参数
/ constructor(childprototype: any, defaultOption: any, option: any) { super(); this._type_ = this.getType(option); this.init(childprototype, defaultOption, option); this.option = JSON.parse(JSON.stringify(defaultOption)); Object.assign(this.option, option); this.setattributes(this.option); } /*
* 判断是否相等
* @param other 比较的对象
/ public equals(other: any): boolean { if (other === this) { return true; } for (const key in this.option) { if (other[key] !== this.option[key]) { return false; } } return true; } /*
* 获得类型
* @param option
*/
public getType(option?: any) {
if (this._type_) {
return this._type_;
} else {
return this._getType(option);
}
}

/**
* 是否要透明度,按照具体需求设置,默认有透明度
* @param material
*/
protected _getTranslucent(material: any){
return true;
}
/**
* 设置必须要的属性
* @param option
 更多参考https://xiaozhuanlan.com/topic/6479351028

标签:return,option,自定义,defaultOption,Material,param,._,Cesium,any
来源: https://blog.csdn.net/haibalai2009/article/details/122616825

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有