我决定不从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 ratio = 1.0;
float PI = 3.1415926;
uniform float iTime;
const vec2 iResolution = vec2(1.0,1.0);
varying vec2 vUv;
constfloat cloudscale = 1.1;
constfloat speed = 0.03;
constfloat clouddark = 0.5;
constfloat cloudlight = 0.3;
constfloat cloudcover = 0.2;
constfloat cloudalpha = 8.0;
constfloat skytint = 0.5;
const vec3 skycolour1 = vec3(0.2, 0.4, 0.6);
const vec3 skycolour2 = vec3(0.4, 0.7, 1.0);
const mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 );
vec2 hash( vec2 p ) {
p = vec2(dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)));
return -1.0 + 2.0*fract(sin§*43758.5453123);
}
floatnoise( in vec2 p ) {
constfloat K1 = 0.366025404; // (sqrt(3)-1)/2;
constfloat K2 = 0.211324865; // (3-sqrt(3))/6;
vec2 i = floor(p + (p.x+p.y)*K1);
Mapbox 与 Babylon.js 可视化 glsl 特效篇(九) - 小专栏