我决定不从Babylonjs 基础来讲了 直接整合mapbox与babylonjs可视化来讲
我整合一个类库 后续不断更新中
- npm i @haibalai/mapbox-babylonjs
初始化mapbox-babylonjs 类库, map 是mapbox.gl 的map 对象
- import { BabylonMapManager } from "@haibalai/mapbox-babylonjs";
- BabylonMapManager.init(map);
添加特效
- import { BabylonMapManager } from "@haibalai/mapbox-babylonjs";
- const fragmentShader = `
- uniform float iTime;
- uniform vec2 iResolution;
- varying vec2 vUv;
- vec3 COLOR1 = vec3(0.0, 0.0, 0.3);
- vec3 COLOR2 = vec3(0.5, 0.0, 0.0);
- float BLOCK_WIDTH = 0.01;
- voidmain(void) {
- vec2 uv = (vUv - 0.3) * 2.0 ;
- // To create the BG pattern
- vec3 final_color = vec3(1.0);
- vec3 bg_color = vec3(0.0);
- vec3 wave_color = vec3(0.0);
- float c1 = mod(uv.x, 2.0 * BLOCK_WIDTH);
- c1 = step(BLOCK_WIDTH, c1);
- float c2 = mod(uv.y, 2.0 * BLOCK_WIDTH);
- c2 = step(BLOCK_WIDTH, c2);
- bg_color = mix(uv.x * COLOR1, uv.y * COLOR2, c1 * c2);
- // To create the waves
- float wave_width = 0.01;
- uv = -1.0 + 2.0 * uv;
Mapbox 与 Babylon.js 可视化 glsl 特效篇(二十三) - 小专栏
标签:glsl,float,WIDTH,0.0,uv,js,mapbox,vec3,Mapbox From: https://www.cnblogs.com/haibalai/p/16969853.html