three实现三维迷幻水母游动动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维可旋转的迷幻水母游动动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
html, body {
margin: 0;
overflow: hidden;
}
#canvas {
display: block;
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<canvas id="canvas" ></canvas>
<script type="x-shader" id="shader_vertex">
#define PI 3.1415926535897932384626433832795
float TAU = PI * 2.0;
uniform float u_time;
uniform float u_width;
uniform float u_bump_frequency;
uniform float u_bump_scale;
varying vec3 v_pos;
varying vec3 v_orig_pos;
varying vec3 v_view_pos;
varying float v_bumps;
const float bump_iterations = 7.0;
void main() {
vec4 model_position = modelMatrix * vec4(position, 1.0);
vec3 pos = position;
pos.xz *= u_width - (0.05 + smoothstep(0.0, -0.3, position.y) * -0.3) * u_width * 0.3;
pos.xz *= 1.0 - sin((pos.y + u_time * 0.2 * TAU) * 2.0) * 0.2;
pos.y *= 1.0 - sin((pos.y + (u_time + 0.3) * 0.2 * TAU) * 2.0) * .6;
float bumps = 0.0;
for (float i = 1.0; i < bump_iterations; i += 1.0) {
float bump_scalar = (pos.y * 0.5 - 1.0) * u_bump_frequency * pow(i, 1.4);
float bump_noise = snoise4(vec4(
pos.x * bump_scalar,
pos.y * bump_scalar + u_time * 0.1,
pos.z * bump_scalar,
u_time * 0.1 * pow(i, 1.0)
));
bump_n.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0