我决定不从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;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- vec3 firePalette(float i){
- float T = 1400. + 1300.*i;
- vec3 L = vec3(7.4, 5.6, 4.4);
- L = pow(L,vec3(5)) * (exp(1.43876719683e5/(T*L)) - 1.);
- return 1. - exp(-5e8/L);
- }
- vec3 hash33(vec3 p){
- float n = sin(dot(p, vec3(7, 157, 113)));
- return fract(vec3(2097152, 262144, 32768)*n);
- }
- floatvoronoi(vec3 p){
- vec3 b, r, g = floor(p);
- p = fract(p);
- float d = 1.;
- for(int j = -1; j <= 1; j++) {
- for(int i = -1; i <= 1; i++) {
- b = vec3(i, j, -1);
- r = b - p + hash33(g+b);
- d = min(d, dot(r,r));
Mapbox 与 Babylon.js 可视化 glsl 特效篇(四) - 小专栏
标签:glsl,特效,babylonjs,Mapbox,float,js,可视化,vec3,mapbox From: https://www.cnblogs.com/haibalai/p/16919482.html