我决定不从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 ratio;
- uniform vec2 windowSize: WINDOW_SIZE;
- float M_PI = 3.1415926;
- float M_TWO_PI = 6.28318530718;
- vec3 iMouse = vec3(0.0, 0.0 ,0.0 );
- uniform float iTime;
- const vec2 iResolution = vec2(1.0,1.0);
- varying vec2 vUv;
- floatrand(vec2 n) {
- return fract(sin(dot(n, vec2(12.9898,12.1414))) * 83758.5453);
- }
- floatnoise(vec2 n) {
- const vec2 d = vec2(0.0, 1.0);
- vec2 b = floor(n);
- vec2 f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
- return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
- }
- vec3 ramp(float t) {
- return t <= .5 ? vec3( 1. - t * 1.4, .2, 1.05 ) / t : vec3( .3 * (1. - t) * 2., .2, 1.05 ) / t;
- }
- vec2 polarMap(vec2 uv, float shift, float inner) {
- uv = vec2(0.5) - uv;
- float px = 1.0 - fract(atan(uv.y, uv.x) / 6.28 + 0.25) + shift;
- float py = (sqrt(uv.x * uv.x + uv.y * uv.y) * (1.0 + inner * 2.0) - inner) * 2.0;
- return vec2(px, py);
- }
- floatfire(vec2 n) {
- return noise(n) + noise(n * 2.1) * .6 + noise(n * 5.4) * .42;
- }
- floatshade(vec2 uv, float t) {
- uv.x += uv.y < .5 ? 23.0 + t * .035 : -11.0 + t * .03;
- uv.y = abs(uv.y - .5);
- uv.x *= 35.0;
- float q = fire(uv - t * .013) / 2.0;
- vec2 r = vec2(fire(uv + q / 2.0 + t - uv.x - uv.y), fire(uv + q - t));
Arcgis 与 Claygl 可视化 glsl 特效篇(五) - 小专栏
标签:glsl,claygl,float,1.0,uv,Claygl,Arcgis,vec2,return From: https://www.cnblogs.com/haibalai/p/17328405.html