mirror of
https://github.com/galacean/engine.git
synced 2026-06-02 08:40:12 +08:00
34 lines
1.6 KiB
Plaintext
34 lines
1.6 KiB
Plaintext
---
|
|
order: 2
|
|
title: Point Light
|
|
type: Graphics
|
|
group: Lighting
|
|
label: Graphics/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 src="https://gw.alipayobjects.com/zos/OasisHub/3eb4bc88-fc7e-4957-83a4-dfb7dd678af5/image-20240319174317201.png" alt="image-20240319174317201" style={{ zoom: "50%" }} />
|
|
|
|
Point lights have 3 main characteristics: _color_ ([color](/apis/core/#PointLight-color)), _intensity_ ([intensity](/apis/core/#PointLight-intensity)), and _range_ ([distance](/apis/core/#PointLight-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.
|
|
|
|
| Property | Description |
|
|
| :------------ | :----------------------------------------------------------------------- |
|
|
| Color | Controls the color of the point light, default is white |
|
|
| Distance | Range within which the light affects, light intensity decreases with distance, area beyond the range will not receive light from the point light |
|
|
| Culling Mask | Controls which objects the light should illuminate, default is Everything. Needs to be used with the Layer of the Entity |
|
|
|
|
### Script Usage
|
|
|
|
```typescript
|
|
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);
|
|
```
|