標籤:webgl web3d 源碼 opengl es 圖形
商域無疆 (http://blog.csdn.net/omni360/)
本文遵循“署名-非商業用途-保持一致”創作公用協議
轉載請保留此句:商域無疆 - 本部落格專註於 敏捷開發及移動和物聯裝置研究:資料視覺效果、GOLANG、Html5、WEBGL、THREE.JS,否則,出自本部落格的文章拒絕轉載或再轉載,謝謝合作。
俺也是剛開始學,好多地兒肯定不對還請見諒.
以下代碼是THREE.JS 源碼檔案中Light/AreaLight.js檔案的注釋.
更多更新在 : https://github.com/omni360/three.js.sourcecode
/** * @author MPanknin / http://www.redplant.de/ * @author alteredq / http://alteredqualia.com/ */ /*///AreaLight方法根據設定燈光的顏屬性color, 強度屬性intensity 建立平面光(面光,地區光).AreaLight對象的功能函數採用/// 定義構造的函數原型對象來實現,地區光和其他光源不同,是一種二維面積光源,他的亮度不僅和強度有關,而且還和他的面積大小有關./// 通過變換燈光的width,height,normal屬性,地區光可以類比窗戶射入光線./// TODO: AreaLight類型燈光在這個版本內還沒有實現陰影.???/// Example:/// var light = new THREE.AreaLight(0xff0000,1);//建立平面燈光對象/// light.position.set(50,50,30);//設定位置///light.rotation.set(-0.3,0.3,0.002);//設定角度///light.width = 10;//設定寬度///light.height = 1;//設定高度///scene.add(lignt);//加入情境*////<summary>AreaLight</summary>///<param name ="color" type="THREE.Color">燈光的顏色屬性</param>///<param name ="intensity" type="Number">燈光的強度,預設是1</param>///<returns type="AreaLight">返回AreaLight,地區光.</returns>THREE.AreaLight = function ( color, intensity ) {THREE.Light.call( this, color );//調用Light對象的call方法,將原本屬於Light的方法交給當前對象AreaLight來使用.this.normal = new THREE.Vector3( 0, - 1, 0 );//面光的法線.可以設定或者獲得面光的單位向量,確認燈光照射面正確.這是在局部空間計算.this.right = new THREE.Vector3( 1, 0, 0 );//this.intensity = ( intensity !== undefined ) ? intensity : 1;//燈光的顏色屬性,如果不指定,初始化為1.this.width = 1.0;//地區光的寬度,初始化為1.0this.height = 1.0;//地區光的高度,初始化為1.0//WebGL是通過光強乘以衰減係數來計算衰減光照的,//attenuation (衰減係數) = 1`/ (this.constantAttenuation + this.distance * this.linearAttenuation + this.quadraticAttenuation * this.distance * this.distance )this.constantAttenuation = 1.5;//常量衰減係數,係數值越大,衰變越快。this.linearAttenuation = 0.5;//線性衰減係數,係數值越大,衰變越快。this.quadraticAttenuation = 0.1;//衰減平方係數,係數值越大,衰變越快。};/******************************************************************************************下面是AreaLight對象提供的功能函數定義,一部分通過prototype繼承自Light方法***************************************************************************************/THREE.AreaLight.prototype = Object.create( THREE.Light.prototype );//AreaLight對象從THREE.Light的原型繼承所有屬性方法
商域無疆 (http://blog.csdn.net/omni360/)
本文遵循“署名-非商業用途-保持一致”創作公用協議
轉載請保留此句:商域無疆 - 本部落格專註於 敏捷開發及移動和物聯裝置研究:資料視覺效果、GOLANG、Html5、WEBGL、THREE.JS,否則,出自本部落格的文章拒絕轉載或再轉載,謝謝合作。
以下代碼是THREE.JS 源碼檔案中Light/AreaLight.js檔案的注釋.
更多更新在 : https://github.com/omni360/three.js.sourcecode
three.js 源碼注釋(四十二)Light/AreaLight.js