我决定不从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 ratio;
float M_PI = 3.1415926;
float M_TWO_PI = 6.28318530718;
vec3 iMouse = vec3(0.0, 0.0 ,0.0 );
uniform float iTime;
const vec2 iResolution = vec2(1.0,1.0);
varying vec2 vUv;
floatrand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898,12.1414))) * 83758.5453);
}
floatnoise(vec2 n) {
const vec2 d = vec2(0.0, 1.0);
vec2 b = floor(n);
vec2 f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
}
vec3 ramp(float t) {
return t <= .5 ? vec3( 1. - t * 1.4, .2, 1.05 ) / t : vec3( .3 * (1. - t) * 2., .2, 1.05 ) / t;
Cesium 与 Babylon.js 可视化 glsl 特效篇(五) - 小专栏