three+webgl实现鼠标点击拖动天女散花花朵动画效果代码
代码语言:html
所属分类:动画
代码描述:three+webgl实现鼠标点击拖动天女散花花朵动画效果代码,用到了GLSL Shader。
代码标签: three webgl 鼠标 点击 拖动 天女 散花 动画 花朵
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
html, body {
overflow: hidden;
padding: 0;
margin: 0;
}
.container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
display: flex;
/*justify-content: center;*/
align-items: end;
}
.title {
z-index: 1;
font-family: sans-serif;
font-size: 15px;
color: white;
text-shadow: 0 0 10px #000000;
user-select: none;
padding: 20px;
}
canvas {
position: absolute;
top: 0;
left: 0;
display: block;
}
#screenshot {
background-color: transparent;
outline: none;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<canvas id="canvas"></canvas>
<div class="title">[ space ] to enter / exit vanishing mode</div>
<div class="title">click to start / stop drawing</div>
<button class="title" id="screenshot" type="button">Save...</button>
</div>
<script type="x-shader/x-fragment" id="fragmentShader">
#define PI 3.14159265359
uniform float u_ratio;
uniform float u_moving;
uniform float u_stop_time;
uniform float u_speed;
uniform vec2 u_stop_randomizer;
uniform float u_clean;
uniform vec2 u_point;
uniform sampler2D u_texture;
varying vec2 vUv;
float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
float noise(vec2 n) {
const vec2 d = vec2(0.0, 1.0);
vec.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0