# WaterCylinder组件
使用WaterCylinder组件可以创建水柱,由 @tx3d/extension 包提供。
import { WaterCylinder } from '@tx3d/extension';
// 构建参数
const parameters = {
radius: 3,
resolutionScale: 10, // 网格精细度
height: 2, // 高度 Y轴方向
usePoint: true, //是否启用水面点 默认值是ture
pointShapeUrl: "./assets/textures/water/point.png",
pointDensity: 4,
pointColor: 0x51BBE4,
topColorContrast: 0.85,
topColor: 0x0d5c97,
sideTopColor: 0x0d5c97,
sideBottomColor: 0x3C7693,
topOpacity: 0.6,
sideOpacity: 0.5,
timeSpeed: 0.5,
amplitude: 0.45,
direction: -177,
wavelength: 5,
wavepeak: 0,
wavecount: 8,
isRenderBottom: false
};
// 创建实体
const entity = engine.createEntity({ transform: { position: [0.0, 0, 15.0] } });
// 添加水柱渲染组件
const water = entity.addComponent(WaterCylinder, parameters);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
提示
WaterCylinder组件初始化参数,详见WaterCylinderParameters。
# 属性
🌏 height 水面高度
代表从0点坐标向上的距离 负值代表向下
water.height = 1;
1
🌏 pointDensity 水面点密度
water.pointDensity = 4;
1
🌏 pointColor 水面点颜色
water.pointColor = 0xfe9090;
1
🌏 topColorContrast 水面颜色对比度
water.topColorContrast = 0.85;
1
🌏 topColor 水面颜色
water.topColor = 0xbe4341;
1
🌏 sideTopColor 侧面顶部颜色
water.sideTopColor = 0xbe4341;
1
🌏 sideBottomColor 侧面底部颜色
water.sideBottomColor = 0x1487b8;
1
🌏 topOpacity 水面透明度
water.topOpacity = 0.6;
1
🌏 sideOpacity 侧面透明度
water.sideOpacity = 0.5;
1
🌏 timeSpeed 水波波动速度
water.timeSpeed = 0.5;
1
🌏 amplitude 水波高度
water.amplitude = 0.45;
1
🌏 direction 水波方向
water.direction = -177;
1
🌏 wavelength 水波波长
water.wavelength = 5;
1
🌏 wavepeak 水波尖锐度
water.wavepeak = 1.5;
1
2
2
🌏 wavecount 水波叠加数量
water.wavecount = 8;
1