我决定不从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 = `
- 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.x*6.0+vec3(0.0,4.0,2.0),
- 6.0)-3.0)-1.0,
- 0.0,
- 1.0 );
- rgb = rgb*rgb*(3.0-2.0*rgb);
- return c.z * mix( vec3(1.0), rgb, c.y);
- }
Mapbox 与 Babylon.js 可视化 glsl 特效篇(二) - 小专栏
标签:glsl,babylonjs,float,Mapbox,js,rgb,vec2,vec3,mapbox From: https://www.cnblogs.com/haibalai/p/16919475.html