Arcgis 与 Claygl 可视化 glsl 特效篇(二十八)

发布时间 2023-04-24 15:26:22作者: haibalai

我决定不从claygl基础来讲了 直接整合arcgis与claygl可视化来讲
关于整合clagyl 有兴趣看我这篇文章 arcgis 与 claygl 引擎结合做地图可视化

我整合一个类库 后续不断更新中

  • npm i @haibalai/gismap4-claygl

 

初始化gismap4-claygl 类库, view是arcgis的sceneView对象

  • import { ClayglMapManager} from "@haibalai/gismap4-claygl";
  • ClayglMapManager.init(view);

 

添加特效

  • import { ClayglMapManager} from "@haibalai/gismap4-claygl";
  • import * as clay from "claygl";
  • const fragmentShader = `
  • uniform float iTime;
  • const vec2 iResolution = vec2(1.0,1.0);
  • varying vec2 vUv;
  • float time;
  • floathash( float n )
  • {
  • return fract(sin(n)*43758.5453);
  • }
  • floatnoise( in vec2 x )
  • {
  • vec2 p = floor(x);
  • vec2 f = fract(x);
  • f = f*f*(3.0-2.0*f);
  • float n = p.x + p.y*57.0;
  • float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
  • mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);
  • return res;
  • }
  • floatSmokeParticle(vec2 loc, vec2 pos, float size, float rnd)
  • {
  • loc = loc-pos;
  • float d = dot(loc, loc)/size;
  • if (d > 1.0) return 0.0;
  • float r= time*rnd*1.85;
  • float si = sin(r);
  • float co = cos(r);
  • d = noise(hash(rnd*828.0)*83.1+mat2(co, si, -si, co)*loc.xy*2./(pos.y*.16)) * pow((1.-d), 3.)*.7;
  • return d;
  • }
  • floatRockParticle(vec2 loc, vec2 pos, float size, float rnd)
  • {
  • loc = loc-pos;
  • float d = dot(loc, loc)/size;
  • if (d > 1.0) return 0.0;
  • float r= time*1.5 * (rnd);
  • float si = sin(r);

Arcgis 与 Claygl 可视化 glsl 特效篇(二十八) - 小专栏