我决定不从Babylonjs 基础来讲了 直接整合cesium与babylonjs可视化来讲
我整合一个类库 后续不断更新中
- npm i @haibalai/cesium-babylonjs
初始化cesium -babylonjs 类库, map 是cesium 的viewer对象
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- BabylonMapManager.init(map);
添加特效
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- const fragmentShader = `
- #ifdef GL_ES
- precision mediump float;
- #endif
- vec2 resolution = vec2(1.0,1.0);
- varying vec2 vUv;
- uniform float time;
- varying vec2 surfacePosition;
- vec4 textureRND2D(vec2 uv){
- uv = floor(fract(uv)*1e3);
- float v = uv.x+uv.y*1e3;
- return fract(1e5*sin(vec4(v*1e-2, (v+1.)*1e-2, (v+1e3)*1e-2, (v+1e3+1.)*1e-2)));
- }
- floatnoise(vec2 p) {
- vec2 f = fract(p*1e3);
- vec4 r = textureRND2D(p);
- f = f*f*(3.0-2.0*f);
- return (mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y));
- }
- floatcloud(vec2 p) {
- float v = 0.0;
- v += noise(p*1.)*.5000;
- v += noise(p*2.)*.2500;
- v += noise(p*4.)*.1250;
- v += noise(p*8.)*.0625;
- v += noise(p*16.)*.03125;
Cesium 与 Babylon.js 可视化 glsl 特效篇(三十八) - 小专栏
标签:glsl,noise,uv,js,cesium,1e3,vec2,Cesium,babylonjs From: https://www.cnblogs.com/haibalai/p/17219811.html