Spotlight is like the light emitted from a flashlight in real life, emitting conically from a point in a specific direction.

| Attribute | Function |
|---|---|
| Angle (Scatter Angle) | Indicates the angle within which there is light relative to the direction of the light source |
| Color | Controls the color of the spotlight |
| Distance | Effective distance, light intensity attenuates with distance |
| Penumbra (Attenuation Angle) | Indicates that within the effective angle range, the light intensity gradually attenuates to 0 as the angle increases |
| 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 |
const lightEntity = rootEntity.createChild("light");
const spotLight = lightEntity.addComponent(SpotLight);
// 散射角度
spotLight.angle = Math.PI / 6;
// 半影衰减角度,为 0 时没有衰减
spotLight.penumbra = Math.PI / 12;
// 颜色
spotLight.color.set(0.3, 0.3, 1, 1);
// 位置
lightEntity.transform.setPosition(-10, 10, 10);
// 朝向
lightEntity.transform.setRotation(-45, -45, 0);