茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    多視角3D逼真HTML5水波動(dòng)畫
    來(lái)源:易賢網(wǎng) 閱讀:1326 次 日期:2016-07-07 13:50:54
    溫馨提示:易賢網(wǎng)小編為您整理了“多視角3D逼真HTML5水波動(dòng)畫”,方便廣大網(wǎng)友查閱!

    這是一款基于HTML5的3D水波動(dòng)畫特效,它的效果非常逼真,我們可以按“G”鍵來(lái)讓水池中的石頭上下浮動(dòng),按“L”鍵添加燈光效果,設(shè)計(jì)相當(dāng)完美。同時(shí)說明一下,這款3D水波動(dòng)畫是基于WebGL渲染技術(shù)的,大家可以了解一下WebGL。

    名單

    HTML代碼

    XML/HTML Code

    <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代碼

    JavaScript Code

    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);   

    };   

    以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

    更多信息請(qǐng)查看網(wǎng)頁(yè)制作
    易賢網(wǎng)手機(jī)網(wǎng)站地址:多視角3D逼真HTML5水波動(dòng)畫
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
    相關(guān)閱讀網(wǎng)頁(yè)制作

    2026國(guó)考·省考課程試聽報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)