webgl介紹
WebGL是一種3D繪圖協(xié)議,它把JavaScript和OpenGL ES 2.0結(jié)合在一起,通過增加OpenGL ES 2.0的一個JavaScript綁定,WebGL可以為HTML5 Canvas提供硬件3D加速渲染。
WebGL技術(shù)標(biāo)準(zhǔn)免去了開發(fā)網(wǎng)頁專用渲染插件的麻煩,可被用于創(chuàng)建具有復(fù)雜3D結(jié)構(gòu)的網(wǎng)站頁面,甚至可以用來設(shè)計3D網(wǎng)頁游戲。
原生的WebGl比較復(fù)雜,主要通過對頂點著色器和片元著色器的操作,來實現(xiàn)渲染,但實現(xiàn)起來比較復(fù)雜,需要一定的數(shù)學(xué)基礎(chǔ),但更多的是需要學(xué)習(xí)基礎(chǔ)的耐心。
Three.js介紹
Three.js是一個js的開源框架,它把webgl的所有東西都封裝好了,我們不再需要去了解webgl那些比較麻煩的細(xì)節(jié),直接在此框架上進(jìn)行開發(fā),既方便,又快捷,而且很容易就能學(xué)習(xí),相對于原生的webgl花100多行代碼畫幾個三角形,Three.js只需要幾行代碼就能實現(xiàn)更復(fù)雜的3D效果。
下載地址: https://github.com/mrdoob/three.js。
環(huán)境搭建
為了以后的學(xué)習(xí)方便,首先是搭建一個萬能框架,所有的three.js開發(fā)都可以在此框架上進(jìn)行。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Three.js</title> <script src="../../../Import/three.js"></script> <script src="../../../Import/stats.js"></script> <script src="../../../Import/Setting.js"></script> <style type="text/css"> div#canvas-frame { border: none; cursor: pointer; width: 100%; height: 850px; background-color: #333333; } </style> <script> let renderer; function initThree() { //TODO } let camera; function initCamera() { //TODO } let scene; function initScene() { //TODO } let light; function initLight() { //TODO } let cube; function initObject() { //TODO } //提前定義好的一個功能文件,方便以后的每一個程序調(diào)用 function initSetting() { loadAutoScreen(camera,renderer);//自適應(yīng)屏幕 loadFullScreen();//網(wǎng)頁全屏播放 loadStats();//性能檢測插件 } function threeStart() { initSetting(); initThree(); initCamera(); initScene(); initLight(); initObject(); animation(); } function animation(){ renderer.clear(); renderer.render(scene,camera); stats.update(); requestAnimationFrame(animation); } </script> </head> <body onload="threeStart()"> <div id="canvas-frame"></div> </body> </html>
網(wǎng)站欄目:WebGL學(xué)習(xí)教程之Three.js學(xué)習(xí)筆記(第一篇)-創(chuàng)新互聯(lián)
新聞來源:http://jinyejixie.com/article8/gpsop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、App開發(fā)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容