Cesium 与 Babylon.js 可视化 glsl 特效篇(二十四)
我决定不从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;
- uniform vec2 iResolution;
- varying vec2 vUv;
- mat2 m(float a){float c=cos(a), s=sin(a);return mat2(c,-s,s,c);}
- floatmap(vec3 p){
- p.xz*= m(iTime*0.4);p.xy*= m(iTime*0.3);
- vec3 q = p*2.+iTime;
- return length(p+vec3(sin(iTime*0.7)))*log(length(p)+1.) + sin(q.x+sin(q.z+sin(q.y)))*0.5 - 1.;
- }
- voidmain(void) {
- vec2 p = (vUv - 0.5) * 2.0 ;
- vec3 cl = vec3(0.);
- float d = 2.5;
- for(int i=0; i<=5; i++) {
- vec3 p = vec3(0,0,5.) + normalize(vec3(p, -1.))*d;