Directional Light represents light that is emitted uniformly in a certain direction, with parallel light rays. Sunlight hitting the Earth's surface can be considered directional light because the distance between the Sun and the Earth is much greater than the Earth's radius. Therefore, sunlight hitting the Earth can be seen as a set of parallel light rays coming from the same direction, i.e., directional light.
Property | Function |
---|---|
Color | Controls the color of the parallel light, default is white |
Culling Mask | Controls the objects that need to be illuminated by the light, default is Everything. Needs to be used in conjunction with the Entity's Layer |
Directional light can cast shadows. For related configurations, refer to the shadow documentation.
const lightEntity = rootEntity.createChild("light");
const directLight = lightEntity.addComponent(DirectLight);
// 调整颜色
directLight.color.set(0.3, 0.3, 1, 1);
// 调整方向
lightEntity.transform.setRotation(-45, -45, 0);