Appearance
光照系统
RayChart 自动配置专业光照,大多数情况无需手动设置。
💡 推荐做法
不配置光照,让框架自动处理。只在需要特殊视觉效果时才自定义。
何时需要自定义光照
- ✅ 需要特殊氛围(如戏剧性、科技感)
- ✅ 需要突出特定数据
- ✅ 需要配合品牌色调
- ❌ 普通数据展示(用默认即可)
光源类型
环境光 (Ambient)
均匀照亮所有物体,提供基础亮度。
javascript
{
lights: [{
type: 'Ambient',
color: '#ffffff',
intensity: 0.5
}]
}方向光 (Directional)
模拟太阳光,产生明暗对比和立体感。
javascript
{
lights: [{
type: 'Directional',
color: '#ffffff',
intensity: 1.0,
position: { x: 5, y: 10, z: 5 }
}]
}点光源 (Point)
从一点向四周发光,如灯泡。
javascript
{
lights: [{
type: 'Point',
color: '#ffffff',
intensity: 1.0,
position: { x: 0, y: 10, z: 0 }
}]
}聚光灯 (Spot)
锥形光束,聚焦特定区域。
javascript
{
lights: [{
type: 'Spot',
color: '#ffffff',
intensity: 1.0,
position: { x: 0, y: 10, z: 0 },
angle: Math.PI / 6, // 光束锥角
penumbra: 0.2, // 边缘柔化(0-1)
distance: 50 // 最大照射距离
}]
}默认光照
不配置 lights 时,引擎自动启用四点光照系统(LightManager):
| 光源 | 类型 | 强度 | 位置 | 说明 |
|---|---|---|---|---|
| 环境光 | Ambient | 0.15 | - | 基础照明(正午天空色) |
| 主光 | Directional | 1.8 | (10, 15, 10) | 主要光源,带阴影 |
| 补光 | Directional | 0.6 | (-10, 8, -5) | 柔和补充(冷蓝色) |
| 轮廓光 | Directional | 0.4 | (0, 5, -15) | 增强立体感 |
配置了 lights 数组后,默认光照会被替换。
常用光照方案
javascript
// 适合数据展示
{
lights: [
{ type: 'Ambient', color: '#ffffff', intensity: 0.6 },
{
type: 'Directional',
color: '#ffffff',
intensity: 0.8,
position: { x: 5, y: 10, z: 5 }
}
]
}javascript
// 适合演示展示
{
lights: [
{ type: 'Ambient', color: '#ffffff', intensity: 0.2 },
{
type: 'Directional',
color: '#ffffff',
intensity: 1.5,
position: { x: 10, y: 15, z: 10 }
}
]
}javascript
// 适合科技产品
{
lights: [
{ type: 'Ambient', color: '#87ceeb', intensity: 0.4 },
{
type: 'Directional',
color: '#00d4ff',
intensity: 1.0,
position: { x: 5, y: 10, z: 5 }
}
]
}光照参数
| 参数 | 说明 | 常用值 |
|---|---|---|
type | 光源类型 | Ambient, Directional |
color | 光源颜色 | '#ffffff' |
intensity | 光照强度 | 0.5-1.5 |
position | 光源位置 | {x: 5, y: 10, z: 5} |
调试光照
启用光源辅助器查看光源位置:
javascript
{
series: [{ data: [120, 200, 150] }],
showLightHelpers: true // 显示光源位置
}性能建议
- 光源数量不超过 3-4 个
- 避免在移动端使用阴影
- 环境光 + 方向光组合最常用
另请参阅
基础学习
相关系统
实践指南
图表示例
API 参考
