three.js 源碼注釋(三十九)Light/HemisphereLight.js
轉載請保留此句:商域無疆 - 本部落格專註於 敏捷開發及移動和物聯裝置研究:資料視覺效果、GOLANG、Html5、WEBGL、THREE.JS,否則,出自本部落格的文章拒絕轉載或再轉載,謝謝合作。
俺也是剛開始學,好多地兒肯定不對還請見諒.
以下代碼是THREE.JS 源碼檔案中Light/HemisphereLight.js檔案的注釋.
/** * @author alteredq / http://alteredqualia.com/ */ /*///HemisphereLight類是在情境中建立半球光,就是天光效果,經常用在室外,將各個位置的物體都照亮,室內的光線大多是方向性的,///無論是視窗還是燈槽,用平面光很方便,室外用平面光太麻煩了.HemisphereLight對象的功能函數採用定義構造的函數原型對象來實現./// TODO: HemisphereLight類型燈光在這個版本內還沒有實現陰影.???/// Example:///var light = new THREE.HemisphereLight(0x003388,0xcc0088,1);//建立半球光///scene.add(light)//添加到情境///light.position.set(0,300,0);*////HemisphereLight///半球光的顏色(天光的顏色)///半球光的地面顏色///燈光的強度,預設是1///返回HemisphereLight,半球光.THREE.HemisphereLight = function ( skyColor, groundColor, intensity ) {THREE.Light.call( this, skyColor );//調用Light對象的call方法,將原本屬於Light的方法交給當前對象HemisphereLight來使用.this.position.set( 0, 100, 0 );//燈光的位置屬性初始化為,0,100,0this.groundColor = new THREE.Color( groundColor );//半球光的地面顏色this.intensity = ( intensity !== undefined ) ? intensity : 1;//燈光的顏色屬性,如果不指定,初始化為1.};/******************************************************************************************下面是HemisphereLight對象提供的功能函數定義,一部分通過prototype繼承自Light方法***************************************************************************************/THREE.HemisphereLight.prototype = Object.create( THREE.Light.prototype );//HemisphereLight對象從THREE.Light的原型繼承所有屬性方法/*clone方法///clone方法複製PointLight對象*////clone///返回複製的HemiSphereLight對象THREE.HemisphereLight.prototype.clone = function () {var light = new THREE.HemisphereLight();THREE.Light.prototype.clone.call( this, light );//調用THREE.Light.clone方法,複製扥光對象light.groundColor.copy( this.groundColor );//複製燈光的地面顏色屬性light.intensity = this.intensity;//複製燈光的強度屬性.return light;//返回複製的半球光的對象}; 上一篇http://www.bkjia.com/kf/201412/359024.html