# 矢量块
# 创建矢量块
使用引擎(Engine)的createExtrudePolygon接口创建矢量块。
// 创建矢量块
const entity = engine.createExtrudePolygon({
opacity: 1.0,
color: '#EEDC82',
outlineWidth: 4.0,
outlineOpacity: 1.0,
outlineColor: '#969696',
height: 50.0,
coordinates: [
[20, 0, 0],
[10, 0, 0],
[10, 0, 10],
[-10, 0, 10],
[-10, 0, 0],
[-20, 0, 0],
[-20, 0, -20],
[20, 0, -20]
],
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
提示
矢量块创建参数,详见ExtrudePolygonParameters。
# 矢量块属性
提示
矢量块使用ExtrudePolygon组件渲染,更新属性或调用接口时需要先获取矢量块渲染组件。
import { ExtrudePolygon } from '@tx3d/core';
// 获取矢量块渲染组件
const extrudePolygon = entity.getComponent( ExtrudePolygon );
1
2
3
4
2
3
4
🌏 color 颜色
// 获取矢量块颜色
const color = extrudePolygon.color;
// 设置矢量块颜色
extrudePolygon.color = '#ff00de';
1
2
3
4
5
2
3
4
5
🌏 opacity 透明度
// 获取矢量块透明度
const opacity = extrudePolygon.opacity;
// 设置矢量块透明度
extrudePolygon.opacity = 0.75;
1
2
3
4
5
2
3
4
5
🌏 outline 描边可见性
// 获取矢量块描边可见性
const outline = extrudePolygon.outline;
// 设置矢量块描边可见性
extrudePolygon.outline = true;
1
2
3
4
5
2
3
4
5
🌏 outlineWidth 描边宽度
// 获取矢量块描边宽度
const outlineWidth = extrudePolygon.outlineWidth;
// 设置矢量块描边宽度
extrudePolygon.outlineWidth = 2.0;
1
2
3
4
5
2
3
4
5
🌏 outlineColor 描边颜色
// 获取矢量块描边颜色
const outlineColor = extrudePolygon.outlineColor;
// 设置矢量块描边颜色
extrudePolygon.outlineColor = '#00ff00';
1
2
3
4
5
2
3
4
5
🌏 outlineOpacity 描边透明度
// 获取矢量块描边透明度
const outlineColor = extrudePolygon.outlineOpacity;
// 设置矢量块描边透明度
extrudePolygon.outlineOpacity = 0.75;
1
2
3
4
5
2
3
4
5
# 矢量块接口
🌏 updateCoordinates 更新矢量块坐标
// 更新矢量块坐标
extrudePolygon.updateCoordinates( [
[20, 0, 0],
[10, 0, 0],
[10, 0, 10],
[20, 0, 10],
] );
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9