光照

点光源

点光源存在于空间中的一点,由该点向四面八方发射光线,比如生活中的灯泡就是点光源。

image-20240319174317201
属性作用
Color控制点光源的颜色,默认白色
Distance有效距离,光照强度随距离衰减,超过有效距离的地方将无法接受到点光源的光线
Culling Mask控制灯光需要照亮的物体,默认 Everything。 需要配合 Entity 的 Layer 来使用

脚本使用

const lightEntity = rootEntity.createChild("light");
const pointLight = lightEntity.addComponent(PointLight);
 
// 调整距离
pointLight.distance = 100;
// 调整颜色
pointLight.color.set(0.3, 0.3, 1, 1);
// 调整点光源位置
lightEntity.transform.setPosition(-10, 10, 10);

这篇文档对您有帮助吗?

On this page