国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 15:12:06
文檔

逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹

逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹:這是一款基于HTML5的3D水波動(dòng)畫特效,它的效果非常逼真,水池中的石頭在水中沉浮,泛起了一層層水波。同時(shí)我們可以拖拽鼠標(biāo)從不同的視角來瀏覽水池,3D效果非常不錯(cuò)。另外,我們可以按G鍵來讓水池中的石頭上下浮動(dòng),按L鍵添加燈光效果,設(shè)計(jì)相當(dāng)完美
推薦度:
導(dǎo)讀逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹:這是一款基于HTML5的3D水波動(dòng)畫特效,它的效果非常逼真,水池中的石頭在水中沉浮,泛起了一層層水波。同時(shí)我們可以拖拽鼠標(biāo)從不同的視角來瀏覽水池,3D效果非常不錯(cuò)。另外,我們可以按G鍵來讓水池中的石頭上下浮動(dòng),按L鍵添加燈光效果,設(shè)計(jì)相當(dāng)完美

這是一款基于HTML5的3D水波動(dòng)畫特效,它的效果非常逼真,水池中的石頭在水中沉浮,泛起了一層層水波。同時(shí)我們可以拖拽鼠標(biāo)從不同的視角來瀏覽水池,3D效果非常不錯(cuò)。另外,我們可以按“G”鍵來讓水池中的石頭上下浮動(dòng),按“L”鍵添加燈光效果,設(shè)計(jì)相當(dāng)完美。同時(shí)說明一下,這款3D水波動(dòng)畫是基于WebGL渲染技術(shù)的,大家可以了解一下WebGL。

HTML代碼

<img id="tiles" src="tiles.jpg">
<img id="xneg" src="xneg.jpg">
<img id="xpos" src="xpos.jpg">
<img id="ypos" src="ypos.jpg">
<img id="zneg" src="zneg.jpg">
<img id="zpos" src="zpos.jpg">

JavaScript代碼

function Water() {
 var vertexShader = '\
 varying vec2 coord;\
 void main() {\
 coord = gl_Vertex.xy * 0.5 + 0.5;\
 gl_Position = vec4(gl_Vertex.xyz, 1.0);\
 }\
 ';
 this.plane = GL.Mesh.plane();
 if (!GL.Texture.canUseFloatingPointTextures()) {
 throw new Error('This demo requires the OES_texture_float extension');
 }
 var filter = GL.Texture.canUseFloatingPointLinearFiltering() ? gl.LINEAR : gl.NEAREST;
 this.textureA = new GL.Texture(256, 256, { type: gl.FLOAT, filter: filter });
 this.textureB = new GL.Texture(256, 256, { type: gl.FLOAT, filter: filter });
 this.dropShader = new GL.Shader(vertexShader, '\
 const float PI = 3.141592653589793;\
 uniform sampler2D texture;\
 uniform vec2 center;\
 uniform float radius;\
 uniform float strength;\
 varying vec2 coord;\
 void main() {\
 /* get vertex info */\
 vec4 info = texture2D(texture, coord);\
 \
 /* add the drop to the height */\
 float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\
 drop = 0.5 - cos(drop * PI) * 0.5;\
 info.r += drop * strength;\
 \
 gl_FragColor = info;\
 }\
 ');
 this.updateShader = new GL.Shader(vertexShader, '\
 uniform sampler2D texture;\
 uniform vec2 delta;\
 varying vec2 coord;\
 void main() {\
 /* get vertex info */\
 vec4 info = texture2D(texture, coord);\
 \
 /* calculate average neighbor height */\
 vec2 dx = vec2(delta.x, 0.0);\
 vec2 dy = vec2(0.0, delta.y);\
 float average = (\
 texture2D(texture, coord - dx).r +\
 texture2D(texture, coord - dy).r +\
 texture2D(texture, coord + dx).r +\
 texture2D(texture, coord + dy).r\
 ) * 0.25;\
 \
 /* change the velocity to move toward the average */\
 info.g += (average - info.r) * 2.0;\
 \
 /* attenuate the velocity a little so waves do not last forever */\
 info.g *= 0.995;\
 \
 /* move the vertex along the velocity */\
 info.r += info.g;\
 \
 gl_FragColor = info;\
 }\
 ');
 this.normalShader = new GL.Shader(vertexShader, '\
 uniform sampler2D texture;\
 uniform vec2 delta;\
 varying vec2 coord;\
 void main() {\
 /* get vertex info */\
 vec4 info = texture2D(texture, coord);\
 \
 /* update the normal */\
 vec3 dx = vec3(delta.x, texture2D(texture, vec2(coord.x + delta.x, coord.y)).r - info.r, 0.0);\
 vec3 dy = vec3(0.0, texture2D(texture, vec2(coord.x, coord.y + delta.y)).r - info.r, delta.y);\
 info.ba = normalize(cross(dy, dx)).xz;\
 \
 gl_FragColor = info;\
 }\
 ');
 this.sphereShader = new GL.Shader(vertexShader, '\
 uniform sampler2D texture;\
 uniform vec3 oldCenter;\
 uniform vec3 newCenter;\
 uniform float radius;\
 varying vec2 coord;\
 \
 float volumeInSphere(vec3 center) {\
 vec3 toCenter = vec3(coord.x * 2.0 - 1.0, 0.0, coord.y * 2.0 - 1.0) - center;\
 float t = length(toCenter) / radius;\
 float dy = exp(-pow(t * 1.5, 6.0));\
 float ymin = min(0.0, center.y - dy);\
 float ymax = min(max(0.0, center.y + dy), ymin + 2.0 * dy);\
 return (ymax - ymin) * 0.1;\
 }\
 \
 void main() {\
 /* get vertex info */\
 vec4 info = texture2D(texture, coord);\
 \
 /* add the old volume */\
 info.r += volumeInSphere(oldCenter);\
 \
 /* subtract the new volume */\
 info.r -= volumeInSphere(newCenter);\
 \
 gl_FragColor = info;\
 }\
 ');
}

Water.prototype.addDrop = function(x, y, radius, strength) {
 var this_ = this;
 this.textureB.drawTo(function() {
 this_.textureA.bind();
 this_.dropShader.uniforms({
 center: [x, y],
 radius: radius,
 strength: strength
 }).draw(this_.plane);
 });
 this.textureB.swapWith(this.textureA);
};

Water.prototype.moveSphere = function(oldCenter, newCenter, radius) {
 var this_ = this;
 this.textureB.drawTo(function() {
 this_.textureA.bind();
 this_.sphereShader.uniforms({
 oldCenter: oldCenter,
 newCenter: newCenter,
 radius: radius
 }).draw(this_.plane);
 });
 this.textureB.swapWith(this.textureA);
};

Water.prototype.stepSimulation = function() {
 var this_ = this;
 this.textureB.drawTo(function() {
 this_.textureA.bind();
 this_.updateShader.uniforms({
 delta: [1 / this_.textureA.width, 1 / this_.textureA.height]
 }).draw(this_.plane);
 });
 this.textureB.swapWith(this.textureA);
};

Water.prototype.updateNormals = function() {
 var this_ = this;
 this.textureB.drawTo(function() {
 this_.textureA.bind();
 this_.normalShader.uniforms({
 delta: [1 / this_.textureA.width, 1 / this_.textureA.height]
 }).draw(this_.plane);
 });
 this.textureB.swapWith(this.textureA);
};

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹

逼真的HTML53D水波動(dòng)畫可多視角瀏覽代碼圖文介紹:這是一款基于HTML5的3D水波動(dòng)畫特效,它的效果非常逼真,水池中的石頭在水中沉浮,泛起了一層層水波。同時(shí)我們可以拖拽鼠標(biāo)從不同的視角來瀏覽水池,3D效果非常不錯(cuò)。另外,我們可以按G鍵來讓水池中的石頭上下浮動(dòng),按L鍵添加燈光效果,設(shè)計(jì)相當(dāng)完美
推薦度:
標(biāo)簽: 代碼 3d html5
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 免费一级a毛片在线播放直播 | 伊人网伊人影院 | 美日韩免费视频 | 欧美最新一区二区三区四区 | 欧美 亚洲 一区 | 欧美日韩国产在线播放 | 日本午夜在线观看 | 国产一区二区三区高清 | 亚洲国产视频网站 | 亚洲视频在线看 | 成人区精品一区二区不卡亚洲 | 影音先锋在线视频 | 国产不卡视频在线播放 | 欧美精品免费在线观看 | 九九国产精品九九 | 亚洲欧美日韩色图 | 夜夜操夜夜 | 国产99精品视频 | 国产成人久久蜜一区二区 | 亚洲国产精品视频 | 欧美极品尤物在线播放一级 | 欧美亚洲另类综合 | 日韩亚洲欧美视频 | 免费观看国产 | 99久久99久久久精品久久 | 亚洲国产福利 | 日韩亚洲视频 | 99久久综合国产精品免费 | 精品国产成人综合久久小说 | 国产成人综合精品一区 | 亚洲 欧美 手机 在线观看 | 91av欧美 | 另类专区欧美 | 伊人网伊人影院 | 欧美激情在线 | 热久久91 | 91精品91久久久久久 | 国产在线成人一区二区 | 青青青久久久 | 精品一区 二区三区免费毛片 | 亚洲欧美日韩综合在线 |