three.js RectAreaLight

2023-02-16 17:42 更新

平面光光源從一個(gè)矩形平面上均勻地發(fā)射光線。這種光源可以用來模擬像明亮的窗戶或者條狀燈光光源。

注意事項(xiàng):

  • 不支持陰影。
  • 只支持 MeshStandardMaterial 和 MeshPhysicalMaterial 兩種材質(zhì)。
  • 你必須在你的場景中加入 RectAreaLightUniformsLib ,并調(diào)用init()。

代碼示例

const width = 10;
const height = 10;
const intensity = 1;
const rectLight = new THREE.RectAreaLight( 0xffffff, intensity,  width, height );
rectLight.position.set( 5, 5, 0 );
rectLight.lookAt( 0, 0, 0 );
scene.add( rectLight )

rectLightHelper = new RectAreaLightHelper( rectLight );
scene.add( rectLightHelper );

例子

WebGL / rectarealight

構(gòu)造器(Constructor)

RectAreaLight( color : Integer, intensity : Float, width : Float, height : Float )

color - (可選參數(shù)) 十六進(jìn)制數(shù)字表示的光照顏色。缺省值為 0xffffff (白色)
intensity - (可選參數(shù)) 光源強(qiáng)度/亮度 。缺省值為 1。
width - (可選參數(shù)) 光源寬度。缺省值為 10。
height - (可選參數(shù)) 光源高度。缺省值為 10。

創(chuàng)建一個(gè)新的平面光。

屬性(Properties)

公共屬性請(qǐng)查看基類Light。

.isRectAreaLight : Boolean

用于檢查給定對(duì)象是否為 RectAreaLight 類型的只讀標(biāo)志。

方法(Methods)

公共方法請(qǐng)查看基類 Light。

.copy ( source : RectAreaLight ) : this

將所有屬性的值從源 source 復(fù)制到此平面光光源對(duì)象。

源碼

src/lights/RectAreaLight.js


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)