/*
* @Author: Wang jianLei
* @Date: 2022-10-14 14:49:49
* @Last Modified by: Wang JianLei
* @Last Modified time: 2022-10-14 14:50:46
*/
const Cesium = window.Cesium;
import MaterialProperty from "../../MaterialProperty";
/**
* 创建Cesium材质对象
*/
Cesium.Material.CircleDiffuseType = "CircleDiffuse";
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleDiffuseType, {
fabric: {
type: Cesium.Material.CircleDiffuseType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0,
},
source: `uniform vec4 color;
uniform float speed;
vec3 circlePing(float r, float innerTail, float frontierBorder, float timeResetSeconds, float radarPingSpeed, float fadeDistance){
float t = fract(czm_frameNumber * speed / 1000.0);
float time = mod(t, timeResetSeconds) * radarPingSpeed;
float circle;
circle += smoothstep(time - innerTail, time, r) * smoothstep(time + frontierBorder,time, r);
circle *= smoothstep(fadeDistance, 0.0, r);
return vec3(circle);
}
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0 ;
vec2 center = vec2(0.);
float time = fract(czm_frameNumber * speed / 1000.0);
vec3 flagColor;
float r = length(st - center) / 4.;
flagColor += circlePing(r, 0.25, 0.025, 4.0, 0.3, 1.0) * color.rgb;
material.alpha = length(flagColor);
material.diffuse = flagColor.rgb;
return material;
}
`,
},
translucent: function (material) {
return true;
},
});
class CircleDiffuseMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options);
}
getType(time) {
return Cesium.Material.CircleDiffuseType;
}
getValue(time, result) {
result = Cesium.defaultValue(result, {});
result.color = Cesium.Property.getValueOrUndefined(this._color, time);
result.speed = this._speed;
return result;
}
equals(other) {
return (
this === other ||
(other instanceof CircleDiffuseMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
);
}
}
Object.defineProperties(CircleDiffuseMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor("color"),
speed: Cesium.createPropertyDescriptor("speed"),
});
export default CircleDiffuseMaterialProperty;
没有合适的资源?快使用搜索试试~ 我知道了~
基于Cesium手写实现动态扩散圆材质的实现和对象展示效果组件,包括完整demo和源代码,代码未加密/未压缩,可直接调用运行
共3个文件
js:1个
vue:1个
glsl:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 44 浏览量
2023-03-13
10:56:51
上传
评论
收藏 4KB ZIP 举报
温馨提示
基于Cesium手写实现动态扩散圆材质的实现和对象展示效果组件,包括完整demo和源代码,代码未加密/未压缩,可直接调用运行 文章描述:https://blog.csdn.net/qq_34205305/article/details/127320397 代码不易,略收小费,使用过程中如果有任何问题欢迎在文章下进行评论或者私信,百分百回复哦
资源推荐
资源详情
资源评论
收起资源包目录
CircleDiffuseMaterialProperty.zip (3个子文件)
CircleDiffuseMaterialProperty.vue 6KB
lib
CircleDiffuseMaterialProperty.js 2KB
CircleDiffuseMaterial.glsl 945B
共 3 条
- 1
资源评论
- 喂!小姐留步2023-09-26感谢大佬分享的资源,对我启发很大,给了我新的灵感。
总要学点什么
- 粉丝: 842
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功