我决定不从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 = `
constfloat PI = 3.14159265359;
uniform float iTime;
uniform vec2 iResolution;
varying vec2 vUv;
floatdistanceTo(vec2 src, vec2 dst) {
float dx = src.x - dst.x;
float dy = src.y - dst.y;
float dv = dx * dx + dy * dy;
return sqrt(dv);
}
vec3 hsb2rgb( in vec3 c ){
vec3 rgb = clamp(abs(mod(c.x6.0+vec3(0.0,4.0,2.0),
6.0)-3.0)-1.0,
0.0,
1.0 );
rgb = rgbrgb*(3.0-2.0*rgb);
return c.z * mix( vec3(1.0), rgb, c.y);
}
vec2 rotate2D (vec2 _st, float _angle) {
_st = mat2(cos(_angle),-sin(_angle),
sin(_angle),cos(_angle)) * _st;
return _st;
}
voidmain() {
float len = distanceTo(vec2(0.5, 0.5), vec2(vUv.x, vU
Cesium 与 Babylon.js 可视化 glsl 特效篇(二) - 小专栏