我决定不从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 iMouse;
varying vec2 vUv;
#define PI 3.1415926
#define NUM 20.
#define PALETTE vec3(.0, 1.4, 2.)+1.5
#define COLORED
#define MIRROR
//#define ROTATE
#define ROT_OFST
#define TRIANGLE_NOISE
//#define SHOW_TRIANGLE_NOISE_ONLY
mat2 mm2(infloat a){float c = cos(a), s = sin(a);return mat2(c,-s,s,c);}
floattri(infloat x){return abs(fract(x)-.5);}
vec2 tri2(in vec2 p){return vec2(tri(p.x+tri(p.y2.)),tri(p.y+tri(p.x2.)));}
mat2 m2 = mat2( 0.970, 0.242, -0.242, 0.970 );
floattriangleNoise(in vec2 p)
{
float z=1.5;
float z2=1.5;
float rz = 0.;
vec2 bp = p;
for (float i=0.; i<=3.; i++ )
{
vec2 dg = tri2(bp2.).8;
dg = mm2(iTime.3);
p += dg/z2;
bp *= 1.6;
z2 *= .6;
z *= 1.8;
p *= 1.2;
Cesium 与 Babylon.js 可视化 glsl 特效篇(十九) - 小专栏