我决定不从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 = `
- uniform float iTime;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- floatsnoise(vec3 uv, float res)
- {
- const vec3 s = vec3(1e0, 1e2, 1e3);
- uv *= res;
- vec3 uv0 = floor(mod(uv, res))*s;
- vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
- vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
- vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
- uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
- vec4 r = fract(sin(v*1e-1)*1e3);
- float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
- r = fract(sin((v + uv1.z - uv0.z)*1e-1)*1e3);
- float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
- return mix(r0, r1, f.z)*2.-1.;
- }
- voidmain(void) {
- vec2 p = (vUv - 0.5) * 2.0;
- p.x *= iResolution.x/iResolution.y;
Cesium 与 Babylon.js 可视化 glsl 特效篇(十二) - 小专栏
标签:glsl,uv0,uv1,uv,js,mix,vec3,Cesium,cesium From: https://www.cnblogs.com/haibalai/p/17217422.html