# 井田边界
# 创建井田边界
使用引擎(Engine)的createMinefield接口创建井田边界。井田边界一般在巷道加载完成后使用巷道外包范围创建。
// 加载巷道
engine.loadLaneways( 'assets/jsons/laneway.json', {
// 巷道样式配置参数
arrowMap: 'assets/textures/laneway/arrow.png', // 外壁箭头纹理
leftMap: 'assets/textures/laneway/left.jpg', // 内壁左邦纹理
rightMap: 'assets/texture/laneway/right.jpg', // 内壁右邦纹理
topMap: 'assets/texture/laneway/top.jpg', // 内壁顶板纹理
bottomMap: 'assets/texture/laneway/bottom.jpg' // 内壁底板纹理
} ).then( ( result ) => {
// 巷道外包范围
const bounds = result.bounds;
// 创建井田边界实体
const entity = engine.createMinefield( {
positions: [
[ bound.min.x, bound.min.y, bound.max.z ],
[ bound.max.x, bound.min.y, bound.max.z ],
[ bound.max.x, bound.min.y, bound.min.z ],
[ bound.min.x, bound.min.y, bound.min.z ]
],
height: bound.max.y - bound.min.y
} );
} );
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
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
提示
井田边界创建参数,详见MinefieldParameters。
# 井田边界属性
提示
井田边界使用Minefield组件渲染,更新属性或调用接口时需要先获取井田边界渲染组件。
import { Minefield } from '@tx3d/core';
// 获取井田边界渲染组件
const minefield = entity.getComponent( Minefield );
1
2
3
4
2
3
4
// 获取井田边界颜色
const color = minefield.color;
// 设置井田边界颜色
minefield.color = '#ff00dd';
1
2
3
4
5
2
3
4
5
🌏 opacity opacity 井田边界透明度
// 获取井田边界透明度
const opacity = minefield.opacity;
// 设置井田边界透明度
minefield.opacity = 0.8;
1
2
3
4
5
2
3
4
5