我决定不从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;
- mat2 m(float a){float c=cos(a), s=sin(a);return mat2(c,-s,s,c);}
- floatmap(vec3 p){
- p.xz*= m(iTime*0.4);p.xy*= m(iTime*0.3);
- vec3 q = p*2.+iTime;
- return length(p+vec3(sin(iTime*0.7)))*log(length(p)+1.) + sin(q.x+sin(q.z+sin(q.y)))*0.5 - 1.;
- }
- voidmain(void) {
- vec2 p = (vUv - 0.5) * 2.0 ;
- vec3 cl = vec3(0.);
- float d = 2.5;
Mapbox 与 Babylon.js 可视化 glsl 特效篇(二十四) - 小专栏
标签:glsl,iTime,float,Mapbox,js,vec3,mapbox,babylonjs,sin From: https://www.cnblogs.com/haibalai/p/16969854.html