我决定不从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;
- #define POINT_COUNT 8
- vec2 points[POINT_COUNT];
- constfloat speed = -0.5;
- constfloat len = 0.25;
- constfloat scale = 0.012;
- float intensity = 1.3;
- float radius = 0.015;
- //https://www.shadertoy.com/view/MlKcDD
- //Signed distance to a quadratic bezier
- floatsdBezier(vec2 pos, vec2 A, vec2 B, vec2 C){
- vec2 a = B - A;
- vec2 b = A - 2.0*B + C;
- vec2 c = a * 2.0;
- vec2 d = A - pos;
- float kk = 1.0 / dot(b,b);
- float kx = kk * dot(a,b);
- float ky = kk * (2.0*dot(a,a)+dot(d,b)) / 3.0;
- float kz = kk * dot(d,a);
- float res = 0.0;
- float p = ky - kx*kx;
- float p3 = p*p*p;
- float q = kx*(2.0*kx*kx - 3.0*ky) + kz;
- float h = q*q + 4.0*p3;
- if(h >= 0.0){
- h = sqrt(h);
- vec2 x = (vec2(h, -h) - q) / 2.0;
- vec2 uv = sign(x)*pow(abs(x), vec2(1.0/3.0));
- float t = uv.x + uv.y - kx;
- t = clamp( t, 0.0, 1.0 );
- // 1 root
- vec2 qos = d + (c + b*t)*t;
- res = length(qos);
- }else{
- float z = sqrt(-p);
- float v = acos( q/(p*z*2.0) ) / 3.0;
- float m = cos(v);
- float n = sin(v)*1.732050808;
- vec3 t = vec3(m + m, -n - m, n - m) * z - kx;
- t = clamp( t, 0.0, 1.0 );
- // 3 roots
- vec2 qos = d + (c + b*t.x)*t.x;
Arcgis 与 Claygl 可视化 glsl 特效篇(二十九) - 小专栏
标签:glsl,claygl,2.0,1.0,float,Claygl,Arcgis,vec2,kx From: https://www.cnblogs.com/haibalai/p/17349650.html