我决定不从Babylonjs 基础来讲了 直接整合cesium与babylonjs可视化来讲
我整合一个类库 后续不断更新中
- npm i @haibalai/cesium-babylonjs
初始化cesium-babylonjs 类库, viewer是cesium的viewer对象
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- BabylonMapManager.init(viewer);
添加特效
- import { BabylonMapManager } from "@haibalai/cesium-babylonjs";
- const fragmentShader = `
- uniform float ratio;
- float PI = 3.1415926;
- uniform float iTime;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- voidmain() {
- vec2 p = (vUv - 0.5) * 2.0;
- float tau = PI * 2.0;
- float a = atan(p.x,p.y);
- float r = length(p)*0.75;
- vec2 uv = vec2(a/tau,r);
- //get the color
- float xCol = (uv.x - (iTime / 3.0)) * 3.0;
- xCol = mod(xCol, 3.0);
- vec3 horColour = vec3(0.25, 0.25, 0.25);
- if (xCol < 1.0) {
- horColour.r += 1.0 - xCol;
- horColour.g += xCol;
- }
- elseif (xCol < 2.0) {
- xCol -= 1.0;
- horColour.g += 1.0 - xCol;
- horColour.b += xCol;
- }
- else {
Cesium 与 Babylon.js 可视化 glsl 特效篇(六) - 小专栏
标签:glsl,xCol,babylonjs,1.0,float,js,cesium,vec2,Cesium From: https://www.cnblogs.com/haibalai/p/17217412.html