three实现鼠标滚动三维粒子流变形动画炫酷效果代码
代码语言:html
所属分类:粒子
代码描述:three实现鼠标滚动三维粒子流变形动画炫酷效果代码
代码标签: three 鼠标 滚动 三维 粒子流 变形 动画 炫酷
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Three.js Particle Morphing</title> <style> body { margin: 0; background-color: #001009; color: white; } #app { /* This div makes the page scrollable */ height: 500vh; position: relative; z-index: 1; } #three-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; z-index: -1; /* Place canvas behind content */ } </style> </head> <body> <!-- Canvas for Three.js --> <canvas id="three-canvas"></canvas> <!-- Scrollable content area --> <div id="app"></div> <!-- Import Three.js from a CDN --> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.127.js"></script> <script type="module"> // --- Shaders (GLSL Code) --- const vertexShader = ` uniform float uTime; uniform float uSphereStrength; uniform float uTorusStrength; uniform float uKnotStrength; uniform float uScale; varying float vDistToCamera; // Simplex Noise function (from the original code) vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);} vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;} vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);} float cnoise(vec3 P){ vec3 Pi0 = floor(P); vec3 Pi1 = Pi0 + vec3(1.0); Pi0 = mod(Pi0, 289.0); Pi1 = mod(Pi1, 289.0); vec3 Pf0 = fract(P); vec3 Pf1 = Pf0 - vec3(1.0); vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); vec4 iy = vec4(Pi0.yy, Pi1.yy); vec4 iz0 = Pi0.zzzz; vec4 iz1 = Pi1.zzzz; vec4 ixy = permute(permute(ix) + iy); .........完整代码请登录后点击上方下载按钮下载查看
网友评论0