three+webgl实现炫酷着色器旋转动画效果代码

代码语言:html

所属分类:动画

代码描述:three+webgl实现炫酷着色器旋转动画效果代码

代码标签: three webgl 炫酷 着色器 旋转 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
body {
  margin: 0;
  overflow: hidden;
  background: #000;
  font-family: "Press Start 2P", cursive;
}

canvas {
  width: 100vw;
  height: 100vh;
  display: block;
}

.button-3d {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 15px 25px;
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
  color: white;
  text-decoration: none;
  border: none;
  transform: perspective(500px) rotateX(10deg);
  transform-style: preserve-3d;
  transition: all 0.3s ease;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
  box-shadow: 0 6px 0 #cc5757, 0 8px 10px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}

.button-3d:hover {
  transform: perspective(500px) rotateX(15deg) translateY(-2px);
  box-shadow: 0 8px 0 #cc5757, 0 12px 15px rgba(0, 0, 0, 0.3);
}

.button-3d:active {
  transform: perspective(500px) rotateX(10deg) translateY(2px);
  box-shadow: 0 4px 0 #cc5757, 0 5px 8px rgba(0, 0, 0, 0.3);
}

.credits {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: #ff8e8e;
  font-size: 14px;
  z-index: 1000;
  opacity: 0.8;
  animation: pulse 2s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    opacity: 0.8;
    transform: scale(1);
  }

  to {
    opacity: 1;
    transform: scale(1.05);
  }
}
</style>



  
  
</head>



<body>
  <canvas id="canvas"></canvas>


<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.133.js"></script>
  
<script type="module">

let scene, camera, renderer;
let time = 0;

// Vertex Shader
const vertexShader = `
varying vec2 vUv;
varying vec3 vPosition;
varying vec3 vNormal;
void main() {
    vUv = uv;
    vPosition = position;
    vNormal = normal;
    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`;

// Fragment Shader
const fragmentShader = `
#ifdef GL_ES
precision highp float;
#endif
uniform float time;
varying vec2 vUv;
varying vec3 vPosition;
varying vec3 vNormal;
#define PHI 1.61803398874989484820459
#define PI 3.14159265359
#define GOLDEN_ANGLE 2.39996322972865332
#define E 2.71828182845904523536

float rand(vec2 n) { 
    return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}

float noise(vec2 p) {
    vec2 ip = floor(p.........完整代码请登录后点击上方下载按钮下载查看

网友评论0