Files
engine/docs/zh/graphics/light/point.mdx
2025-02-10 14:51:48 +08:00

35 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
order: 2
title: 点光源
type: 图形
group: 光照
label: Graphics/Light
---
**点光源**存在于空间中的一点,由该点向四面八方发射光线,比如生活中的灯泡就是点光源。
<Image src="https://gw.alipayobjects.com/zos/OasisHub/3eb4bc88-fc7e-4957-83a4-dfb7dd678af5/image-20240319174317201.png" alt="image-20240319174317201" style={{ zoom: "50%" }} />
点光源有 3 个主要特性_颜色_[color](/apis/core/#PointLight-color)、_强度_[intensity](/apis/core/#PointLight-intensity)、_有效距离_[distance](/apis/core/#PointLight-distance)))。超过有效距离的地方将无法接受到点光源的光线,并且离光源越远光照强度也会逐渐降低。
| 属性 | 作用 |
| :----------- | :------------------------------------------------------------------------ |
| Intensity | 控制点光源的强度,**值越高越亮** |
| Color | 控制点光源的颜色,默认白色 |
| Distance | 有效距离,光照强度随距离衰减 |
| Culling Mask | 控制灯光需要照亮的物体,默认 Everything。 需要配合 Entity 的 Layer 来使用 |
### 脚本使用
```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);
```