ライト
説明
このコンポーネントは、実体を発光させる。
プロパティ
プロパティ | タイプ | デフォルト | 説明 |
---|---|---|---|
タイプ (必須) | ストリング | 方向性 | サポートされているタイプは以下の通り:ディレクショナル」、「ポイント」、「アンビエント |
キャストシャドウ | ブーリアン | 真の | 光源が影を落とす場合。 |
強度 | 番号 | 0.5 | 放出強度。 |
r | 番号(0~255) | 255 | 光が発する赤の量。 |
g | 番号(0~255) | 255 | 光が発する緑の量。 |
b | 番号(0~255) | 255 | 光が発する青の量。 |
シャドウバイアス | 番号 | -0.005 | サーフェスが影になっているかどうかを判断するときに、正規化された深度からどれだけ足したり引いたりするか。 |
シャドウ・ノーマルバイアス | 番号 | 0 | シャドウマップのクエリに使用される位置が、オブジェクトの法線に沿ってどれだけオフセットされるか。 |
シャドウ半径 | 番号 | 1 | 影の半径 |
シャドウ自動更新 | ブーリアン | 真の | シャドーは自動的に計算され、更新されるべきか |
シャドウブラーサンプル | 番号 | 8 | 仮想シャドウマップを計算する際に使用するサンプル量。 |
shadowMapSizeHeight | 番号 | 1024 | シャドウマップの高さ。 (値は**2の累乗でなければならない) |
シャドウマップサイズ幅 | 番号 | 1024 | シャドウマップの幅。 (値は**2の累乗でなければならない) |
シャドウカメラニア | 番号 | 0.5 | 影を計算するためのカメラニアペイン |
シャドウカメラファー | 番号 | 200 | 影を計算するためのカメラ・フラストゥム・ファーペイン |
シャドウカメラ左 | 番号 | -50 | 影を計算するためのカメラ錐台左ペイン |
シャドウカメラ右 | 番号 | 50 | 影を計算するためのカメラの挫折の右ペイン |
シャドーカメラ下部 | 番号 | -50 | 影を計算するためのカメラ錐台下ペイン |
シャドウカメラトップ | 番号 | 50 | 影を計算するためのカメラ・フラストゥルム・トップペイン |
ターゲットエックス | 番号 | 0 | ライトのターゲットX座標(指向性のみ) |
ターゲットY | 番号 | 0 | ライトのターゲットY座標(指向性のみ) |
ターゲットZ | 番号 | 0 | 光のターゲットZ座標(指向性のみ) |
機能
Get
Returns a read-only reference.
Example
ecs.Light.get(world, component.eid)
Set
Ensures the component exists on the entity, then assigns the (optional) data to the component.
Example
ecs.Light.set(world, component.eid, {
type: 'directional',
castShadow: true,
intensity: 0.5,
r: 255,
g: 255,
b: 255,
shadowBias: -0.005,
shadowNormalBias: 0,
shadowRadius: 1,
shadowAutoUpdate: true,
shadowBlurSamples: 8,
shadowMapSizeHeight: 1024,
shadowMapSizeWidth: 1024,
shadowCameraNear: 0.5,
shadowCameraFar: 200,
shadowCameraLeft: -50,
shadowCameraRight: 50,
shadowCameraBottom: -50,
shadowCameraTop: 50,
targetX: 0,
targetY: 0,
targetZ: 0
})
Mutate
Perform an update to the component within a callback function. Return true
to indicate no changes made.
Example
ecs.Light.mutate(world, component.eid, (cursor) => {
cursor.intensity = 1.0;
cursor.castShadow = false;
return false;
})
Remove
Removes the component from the entity.
Example
ecs.Light.remove(world, component.eid)
Has
Returns true
if the component is present on the entity.
Example
ecs.Light.has(world, component.eid)
Reset
Adds, or resets the component to its default state.
Example
ecs.Light.reset(world, component.eid)
Advanced Functions
Cursor
Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.
Example
ecs.Light.cursor(world, component.eid)