我决定不从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;
- floatplasma(vec2 p, float iso, float fade)
- {
- float c = 0.0;
- for (float i=1.0; i<10.0; ++i) {
- float f1 = i / 0.6;
- float f2 = i / 0.3;
- float f3 = i / 0.7;
- float f4 = i / 0.5;
- float s1 = i / 2.0;
- float s2 = i / 4.0;
- float s3 = i / 3.0;
- c += sin(p.x * f1 + iTime) * s1 + sin(p.y * f2 + 0.5 * iTime) * s2 + sin(p.x * f3 + p.y * f4 - 1.5 * iTime) * s3;
- }
- //c = mod(clamp(c, -1.0, 1.0), 0.5) * 2.0;
- c = mod(c, 16.0) * 0.5 - 7.0;
- if (c < iso) {
- return 0.0;
- }
- else {
- if (c > 0.5) c = 1.0 - c;
- c *= 2.0;
- return c * fade;
- }
- }
- voidmain(void) {
- vec2 pos = (vUv - 0.5) * 2.0;
- float c = 0.0;
- for (float i=0.0; i<27.0; ++i)
- {
- float patazoom = mod(0.5 * iTime, 1.0);
- float zoom = 1.0 + i - patazoom;
Cesium 与 Babylon.js 可视化 glsl 特效篇(十四) - 小专栏
标签:glsl,iTime,1.0,float,0.5,js,cesium,Cesium,babylonjs From: https://www.cnblogs.com/haibalai/p/17217431.html