# 描边
描边可以绘制某个物体的轮廓线。
# 初始化
使用Outline类添加描边效果。
import {
Postprocessing,
Outline,
KernelSize
} from '@tx3d/postprocessing';
// 创建后处理类
const postprocessing = new Postprocessing( engine );
// 添加后处理效果
const effect = postprocessing.addEffect( Outline,
{
resolutionY: 480, // 分辨率
edgeStrength: 24, // 强度
pulseSpeed: 0.4, // 动画间隔
visibleEdgeColor: 0x0091ff, // 描边的颜色
blur: true, // 是否模糊
kernelSize: KernelSize.SMALL, // 模糊强度 VERY_SMALL SMALL MEDIUM LARGE VERY_LARGE HUGE
xRay: true, // 是否显示被遮挡描边
}
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
提示
描边初始化参数,详见OutlineParams。
# 属性
🌏 edgeStrength 描边强度
// 设置描边强度
effect.edgeStrength = 1.0;
1
2
2
🌏 visibleEdgeColor 描边颜色
// 设置描边颜色
effect.visibleEdgeColor = 0x0091ff;
1
2
2
🌏 pulseSpeed 闪烁动画速度
// 设置闪烁动画速度
effect.pulseSpeed = 0.5;
1
2
2
🌏 blurSize 模糊的大小
// 设置模糊的大小
effect.blurSize = KernelSize.VERY_SMALL;
1
2
2
# 接口
🌏 setOutline 设置要描边的对象
// 设置描边
effect.setOutline(component, true);
1
2
2