Lighting

Point Light

A point light is a light source located at a point in space that emits light rays in all directions, similar to a light bulb in real life.

image-20240319174317201

Point lights have 3 main characteristics: color (color), intensity (intensity), and range (distance). Areas beyond the range will not receive light from the point light, and the intensity of the light decreases as the distance from the light source increases.

PropertyDescription
IntensityControls the intensity of the point light, higher values mean brighter light
ColorControls the color of the point light, default is white
DistanceRange within which the light affects, light intensity decreases with distance
Culling MaskControls which objects the light should illuminate, default is Everything. Needs to be used with the Layer of the Entity

Script Usage

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);

Was this page helpful?

On this page