我决定不从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;
- floatplasma(vec2 p, float iso, float fade)
- {
- float c = 0.0;
- for (float i=1.0; i<10.0; ++i) {
- float f1 = i / 0.6;
- float f2 = i / 0.3;
- float f3 = i / 0.7;
- float f4 = i / 0.5;
- float s1 = i / 2.0;
- float s2 = i / 4.0;
- float s3 = i / 3.0;
- c += sin(p.x * f1 + iTime) * s1 + sin(p.y * f2 + 0.5 * iTime) * s2 + sin(p.x * f3 + p.y * f4 - 1.5 * iTime) * s3;
- }
- //c = mod(clamp(c, -1.0, 1.0), 0.5) * 2.0;
- c = mod(c, 16.0) * 0.5 - 7.0;
- if (c < iso) {
- return 0.0;
- }
- else {
- if (c > 0.5) c = 1.0 - c;
- c *= 2.0;
- return c * fade;
- }
- }
Mapbox 与 Babylon.js 可视化 glsl 特效篇(十四) - 小专栏
标签:glsl,babylonjs,Mapbox,float,0.5,js,iTime,mapbox,1.0 From: https://www.cnblogs.com/haibalai/p/16919505.html