我决定不从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; #define PI 3.14159265358979323846 uniform float time; voidmain(void) { float pi = atan(-1.0) * 4.0; vec2 uv = (vUv -0.5) * 1.0 ; float c = fract(abs(cos(time*1.5))); float r = length(uv); for (int i = 0; i < 3; ++i) { float b = (float(i) + 0.5 + time) * pi / 3.0; vec2 a = vec2(cos(b), sin(b)); c = abs(c - smoothstep(0.0, 0.005, clamp(dot(uv, a), 0.0, 0.005))); } c *= smoothstep(0.145, 0.15, r) - smoothstep(0.495, 0.5, r); c *= smoothstep(0.145, 0.15, r) - smoothstep(0.495, 0.5, r); c += 1.0 - smoothstep(0.095, 0.1, r); c = 1.0 - c; //un-reverse gl_FragColor = vec4(c * .95, c * 0.8, 0.0, 0.8) ; }
const vertexShader = `
attribute vec3 position;
Cesium 与 Babylon.js 可视化 glsl 特效篇(四十三) - 小专栏