threejs打造三维多彩峡谷穿梭效果
代码语言:html
所属分类:三维
代码描述:threejs打造三维多彩峡谷穿梭效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
color: #ffffff;
font-family: Monospace;
font-size: 13px;
text-align: center;
font-weight: bold;
background-color: #000;
margin: 0px;
overflow: hidden;
}
#info, #controls {
position: absolute;
width: 100%;
padding: 5px;
background: rgba(0, 0, 0, 0.4);
}
#info {
top: 0;
}
#controls {
bottom: 0;
}
a {
color: #ffffff;
-webkit-transition: 150ms all;
transition: 150ms all;
}
a:hover, a:focus {
color: #ffc107;
}
.stats-element {
position: absolute;
right: 0;
top: 0;
}
.audio-embed {
position: absolute;
left: 0;
bottom: 100%;
border: 0;
}
#hide-audio:checked + .audio-embed {
opacity: 0;
}
</style>
</head>
<body translate="no">
<script id="vertexShader" type="x-shader/x-vertex">
attribute vec3 center;
uniform float uTime;
varying float vDisp;
varying vec3 vCenter;
varying vec2 vSceneYZ;
#define PULSE_TIME 1.16
void main() {
vCenter = center;
vDisp = max(
max(0., 1.-pow(3.*abs(uv.y-fract(-uTime*PULSE_TIME)+0.5), 0.5)),
1.-pow(3.*abs(uv.y-fract(-uTime*PULSE_TIME)-0.5), 0.5)
);
// FIXME - magic numbers in displacement calculation
vec4 scenePosition = modelViewMatrix*vec4(position+vec3(0., 1., 0.)*2.5*vDisp, 1.);
vSceneYZ = scenePosition.yz;
gl_Position = projectionMatrix*scenePosition;
}
</script>
<script id="f.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0