我决定不从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 =
- `
- // arxeon was here
- #ifdef GL_ES
- precision mediump float;
- #endif
- uniform float time;
- vec2 resolution = vec2(1.0,1.0);
- varying vec2 vUv;
- #define PI 3.14159265358979
- vec3 color = 0.3 * vec3(0.03125, 0.4523560209, 0.703703703);
- floatd2y(float d) {
- return 1. / (0.2 + d);
- }
- float radius = 0.4;
- floatfct(vec2 p, float r) {
- float a = 3. * mod(atan(p.y, p.x) + time, 2. * PI);
- float scan = 0. * 1.;
- return (d2y(a) + scan) * (1. - step(radius, r));
- }
Mapbox 与 Babylon.js 可视化 glsl 特效篇(四十七) - 小专栏
标签:glsl,特效,babylonjs,Mapbox,float,js,vec2,mapbox,可视化 From: https://www.cnblogs.com/haibalai/p/17011747.html