# 通风工具

通风工具包括巷道设计工具风筒绘制工具通风设施创建工具风路反转工具,同样由 @tx3d/ventilation 包提供。

提示

AirwayManager初始化时会默认将所有的通风工具注册到工具管理器(ToolManager)中,使用时只需要激活相应的工具即可。

import { LanewayDesignTool } from '@tx3d/ventilation';

// 激活巷道设计工具
engine.toolManager.activateTool( LanewayDesignTool );
1
2
3
4

注意

  • 为了确保通风工具的事件响应不与相机控制器等的事件响应冲突,需要将工具管理器的事件优先级设置为最高,如下所示:
import { Engine, Priority } from '@tx3d/core';

// 创建引擎
const engine = new Engine( {

    // 工具管理器初始化参数
    toolManager: {

        eventPriority: Priority.HIGH // 将工具管理器事件优先级设置为最高

    }

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
  • 撤销&重做通风工具操作时,需要手动刷新一下通风拓扑网络,用于同步通风数据,如下所示:

// 撤销命令
const undo = () => {

    // 撤销命令
    engine.commandManager.undo();

    // 刷新通风拓扑网络
    airwayManager.refreshTopologyNetwork();

}

// 重做命令
const redo = () => {

    // 重做命令
    engine.commandManager.redo();

    // 刷新通风拓扑网络
    airwayManager.refreshTopologyNetwork();

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# 巷道设计工具

巷道设计工具(LanewayDesignTool)包含绘制巷道编辑巷道删除巷道打断巷道合并巷道节点5种设计模式。可以在激活巷道设计工具时指定设计模式,激活后可以使用巷道设计工具的switchMode接口切换设计模式。

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

const { toolManager } = engine;

// 激活巷道设计工具,不指定设计模式
toolManager.activateTool( LanewayDesignTool );

// 激活巷道设计工具,并设置为编辑巷道模式
toolManager.activateTool( LanewayDesignTool, {

    mode: DesignMode.DESIGN_EDIT

} );

const { activatedTool } = toolManager;

// 切换到绘制巷道模式
activatedTool.switchMode( DesignMode.DESIGN_DRAW );

// 切换到未知设计模式(即,禁用所有设计操作)
activatedTool.switchMode( DesignMode.DESIGN_UNKNOWN );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

提示

LanewayDesignTool的激活参数,详见LanewayDesignToolParameters

# 绘制巷道

在绘制模式下,可以通过点击和移动鼠标在场景中绘制巷道,具体的绘制规则如下所示:

  • 单击鼠标左键添加一个巷道导线点;

  • 移动鼠标更新巷道最后一个导线点位置;

  • 按住Ctrl键 + 单击鼠标右键删除巷道最后一个导线点;

  • 按住Shift键进入竖井绘制模式,此时只能在垂直方向操作导线点;

  • 双击鼠标左键或鼠标左键单击其它巷道或巷道节点完成巷道绘制。

  • 按住Alt键(自定义键位,默认‘Alt’)进入坐标输入模式,此时通过坐标输入添加一个导线点;

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

// 方法1:激活巷道设计工具时设置为绘制模式
toolManager.activateTool( LanewayDesignTool, {

    mode: DesignMode.DESIGN_DRAW,
    designer: {

        adsorbHelper: true,     // 轴辅助对象是否开启
        adsorbAngle: 5,         // 轴辅助对象吸附角度
        color: '#0d1ee5',       // 轴辅助对象颜色
        constant: 0.0,          // 拾取面y方向位置
        inputSwitchKey: 'alt',  // 输入切换键位
        // 绘制完成回调
        onCompleted: (message) => {

            console.log(message);

        },
        // 巷道延伸回调
        onExtend: () => {

            return new Promise(( resolve, reject ) => {

                if ( confirm( '是否延申当前巷道?' ) ) {

                    resolve( true );

                } else {

                    reject();

                }

            });

        },
        // 巷道合并回调
        onMerge: () => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '是否将两条巷道合并成一条巷道?' ) ) {

                    resolve( true );

                } else {

                    reject();

                }

            } );

        }

    }

} );

// 方法2:通过当前激活的巷道设计工具切换到绘制模式
const { activatedTool } = toolManager;

activatedTool.switchMode( DesignMode.DESIGN_DRAW, {

    // 绘制完成回调
    onCompleted: ( guid ) => {

        // TODO:待实现

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

提示

除了通过回调方式监听巷道绘制完成,可以通过事件监听方式监听巷道绘制完成,如下所示:

import { LanewayDesignTool, VentEventType } from '@tx3d/ventilation';

// 获取巷道设计工具
const tool = toolManager.getTool( LanewayDesignTool );

// 监听巷道绘制完成事件
tool.addEventListener( VentEventType.LANEWAY_DRAW_COMPLETED, ( guid ) => {

    // TODO:待实现

} );
1
2
3
4
5
6
7
8
9
10
11

提示

绘制巷道模式初始化参数,详见LanewayDrawerParameters

# 编辑巷道

在编辑模式下,可以通过拖拽巷道节点对象修改巷道导线点坐标,可以通过拖拽巷道节点与其它的巷道节点连接形成新的连接交叉口。巷道节点与巷道节点连接时遵循以下规则:

1️⃣ 同一条巷道的巷道节点无法相互连接;

2️⃣ 交叉口节点交叉口节点连接时,会将两个交叉口合并成一个新的交叉口;

3️⃣ 交叉口节点巷道首尾节点连接时,会将巷道作为新的分支插入到交叉口中,反之亦然;

4️⃣ 交叉口节点巷道非首尾节点连接时,会先将巷道打断成两条新巷道,然后将这两条新巷道作为分支插入到交叉口中,反之亦然;

5️⃣ 巷道首尾节点另一条巷道首尾节点连接时,如果设置了合并响应且选择合并则会将两条巷道合并成一条新巷道,否则会以这两条巷道为分支构建一个新的交叉口;

6️⃣ 巷道首尾节点另一条巷道非首尾节点连接时,会先将非首尾节点所属巷道打断成两条新巷道,然后以这三条巷道为分支构建新的交叉口,反之亦然。

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

// 方法1:激活巷道设计工具时设置为编辑模式
toolManager.activateTool( LanewayDesignTool,{

    mode: DesignMode.DESIGN_EDIT,
    designer: {

        // 合并响应
        onMerge: () => {

            if ( confirm( '是否将两条巷道合并成一条巷道?' ) ) {

                resolve( true );

            } else {

                reject();

            }

        }

    }

} );

// 方法2:通过当前激活的巷道设计工具切换到编辑模式
const { activatedTool } = toolManager;

activatedTool.switchMode( DesignMode.DESIGN_EDIT, {

    // 合并响应
    onMerge: () => {

        if ( confirm( '是否将两条巷道合并成一条巷道?' ) ) {

            resolve( true );

        } else {

            reject();

        }

    }

} );
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
39
40
41
42
43
44
45
46
47
48

提示

编辑巷道模式初始化参数,详见LanewayEditorParameters

# 删除巷道

在删除模式下,通过鼠标左键单击巷道或巷道节点,实现巷道、巷道交叉口、巷道导线点的删除。删除时遵循以下原则:

  • 单击巷道,会删除整条巷道;

  • 单击非交叉口巷道节点时,如果删除后剩余导线点个数小于等于1则会删除整条巷道,否则只会删除一个巷道导线点;

  • 单击交叉口节点时,如果交叉口连接分支数等于2且设置了合并响应则会根据响应决定是断开巷道还是将分支巷道合并成一条巷道,如果交叉口连接分支数大于2会断开所有连接巷道。

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

// 方法1:激活巷道设计工具时设置为删除模式
toolManager.activateTool( LanewayDesignTool, {

    mode: DesignMode.DESIGN_DELETE,
    designer: {

        // 是否删除响应
        onConfirm: ( message ) => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( `确定删除? type: ${message.type} guid: ${message.guid}` ) ) {

                    resolve( status: true );

                } else {

                    reject();

                }

            } );

        },

        // 合并响应
        onMerge: () => {

            if ( confirm( '是否将交叉口连接的两条巷道合并成一条巷道?' ) ) {

                resolve( true );

            } else {

                reject();

            }

        },

        // 删除完成回调
        onCompleted: ( message ) => {

            console.log( `删除完成 type: ${message.type} guid: ${message.guid}` );

        }

    }

} );

// 方法2:通过当前激活的巷道设计工具切换到删除模式
activatedTool.switchMode( DesignMode.DESIGN_DELETE, {

    // 是否删除响应
    onConfirm: ( message ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( `确定删除? type: ${message.type} guid: ${message.guid}` ) ) {

                resolve( status: true );

            } else {

                reject();

            }

        } );

    },

    // 合并响应
    onMerge: () => {

        if ( confirm( '是否将交叉口连接的两条巷道合并成一条巷道?' ) ) {

            resolve( true );

        } else {

            reject();

        }

    },    

    // 删除完成回调
    onCompleted: ( message ) => {

        console.log( `删除完成 type: ${message.type} guid: ${message.guid}` );

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

提示

除了通过回调方式监听巷道删除完成,可以通过事件监听方式监听巷道删除完成,如下所示:

import { LanewayDesignTool, VentEventType } from '@tx3d/ventilation';

// 获取巷道设计工具
const tool = toolManager.getTool( LanewayDesignTool );

// 监听巷道删除完成事件
tool.addEventListener( VentEventType.LANEWAY_DELETE_COMPLETED, ( message ) => {

    console.log( `删除完成 type: ${message.type} guid: ${message.guid}` );

} );
1
2
3
4
5
6
7
8
9
10
11

提示

删除巷道模式初始化参数,详见LanewayDeleterParameters

# 打断巷道

在打断模式下,可以将一条巷道打断成两条连接或不连接的巷道。

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

// 方法1:激活巷道设计工具时设置为打断模式
toolManager.activateTool( LanewayDesignTool, {

    mode: DesignMode.DESIGN_BREAK,
    designer: {

        // 打断确认响应
        onConfirm: () => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定打断?' ) ) {

                    resolve( true );

                } else {

                    reject();

                }

            } );

        },

        // 是否连接打断后的巷道响应
        onConnect: () => {
          
            return new Promise( ( resolve, reject ) => {

                if ( confirm( '是否连接打断后的两条巷道?' ) ) {

                    resolve( true );

                } else {

                    reject();

                }

            } );

        },

        // 打断完成回调
        onCompleted: ( message ) => {

            const {

                srcLanewayCode      // 打断前源巷道编码
                newPrevLanewayCode  // 打断后新建的前一段巷道编码
                newNextLanewayCode  // 打断后新建的后一段巷道编码
                newCrossingCode     // 打断后新建的交叉口拓扑编码(注:可能不存在)

            } = message;

        }

    }

} );

// 方法2:通过当前激活的巷道设计工具切换到打断模式
activatedTool.switchMode( DesignMode.DESIGN_BREAK, {
    
    // 打断确认响应
    onConfirm: () => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定打断?' ) ) {

                resolve( true );

            } else {

                reject();

            }

        } );

    },

    // 是否连接打断后的巷道响应
    onConnect: () => {
        
        return new Promise( ( resolve, reject ) => {

            if ( confirm( '是否连接打断后的两条巷道?' ) ) {

                resolve( true );

            } else {

                reject();

            }

        } );

    },

    // 打断完成回调
    onCompleted: ( message ) => {

        const {

            srcLanewayCode      // 打断前源巷道编码
            newPrevLanewayCode  // 打断后新建的前一段巷道编码
            newNextLanewayCode  // 打断后新建的后一段巷道编码
            newCrossingCode     // 打断后新建的交叉口拓扑编码(注:可能不存在)

        } = message;

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

提示

除了通过回调方式监听巷道打断完成,也可以通过事件监听方式监听巷道打断完成,如下所示:

import { LanewayDesignTool, VentEventType } from '@tx3d/ventilation';

// 获取巷道设计工具
const tool = toolManager.getTool( LanewayDesignTool );

// 监听巷道打断完成事件
tool.addEventListener( VentEventType.LANEWAY_DRAW_COMPLETED, ( message ) => {

    const {

        srcLanewayCode      // 打断前源巷道编码
        newPrevLanewayCode  // 打断后新建的前一段巷道编码
        newNextLanewayCode  // 打断后新建的后一段巷道编码
        newCrossingCode     // 打断后新建的交叉口拓扑编码(注:可能不存在)

    } = message;

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

提示

打断巷道模式初始化参数,详见LanewayBreakerParameters

# 合并巷道节点

在节点合并模式下,单击鼠标左键选择节点,单击鼠标右键取消当前选择。巷道节点合并时遵循以下规则:

1️⃣ 同一条巷道的巷道节点无法合并;

2️⃣ 节点合并时,会先将起始节点平移至目标节点,再做合并操作;

3️⃣ 交叉口节点交叉口节点合并时,会将两个交叉口合并成一个新的交叉口;

4️⃣ 交叉口节点巷道首尾节点合并时,会将巷道作为新的分支插入到交叉口中,反之亦然;

5️⃣ 交叉口节点巷道非首尾节点合并时,会先将巷道打断成两条新巷道,然后将这两条新巷道作为分支插入到交叉口中,反之亦然;

6️⃣ 巷道首尾节点与另一条巷道首尾节点合并时,会弹出是否合并提示,如果选则合并则会将两条巷道合并成一条新巷道,如选择不合并则会以这两条巷道为分支构建一个新的交叉口;

7️⃣ 巷道首尾节点与另一条巷道非首尾节点合并时,会先将非首尾节点所属巷道打断成两条新巷道构建新的交叉口,然后将巷道作为新的分支插入到交叉口中,反之亦然。

import { DesignMode, LanewayDesignTool } from '@tx3d/ventilation';

// 方法1:激活巷道设计工具时设置为合并模式
toolManager.activateTool( LanewayDesignTool, {

    mode: DesignMode.DESIGN_MERGE,
    designer: {

        // 合并确认响应
        onConfirm: () => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定合并节点?' ) ) {

                    resolve( true );

                } else {

                    reject();

                }

            } );

        },

        // 是否合并巷道提示响应
        onMerge: () => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '是否将两条巷道合并成一条巷道?' ) ) {

                    resolve( true );

                } else {

                    reject()

                }

            } )

        },

        // 合并完成回调
        onCompleted: ( message ) => {

            // TODO:待实现

        },

        // 合并报错回调
        onError: ( message ) => {

            // 输出错误信息
            console.log( message );

        }

    }

} );

// 方法2:通过当前激活的巷道设计工具切换到节点合并模式
activatedTool.switchMode( DesignMode.DESIGN_MERGE, {

    // 合并确认响应
    onConfirm: () => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定合并节点?' ) ) {

                resolve( true );

            } else {

                reject();

            }

        } );

    },

    // 是否合并巷道提示响应
    onMerge: () => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '是否将两条巷道合并成一条巷道?' ) ) {

                resolve( true );

            } else {

                reject()

            }

        } )

    },

    // 合并完成回调
    onCompleted: ( message ) => {

        // TODO:待实现

    },

    // 合并报错回调
    onError: ( message ) => {

        // 输出错误信息
        console.log( message );

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

提示

除了通过回调方式监听节点合并完成&报错,也可以通过事件监听方式监听完成&报错,如下所示:

import { LanewayDesignTool, VentEventType } from '@tx3d/ventilation';

// 获取巷道设计工具
const tool = toolManager.getTool( LanewayDesignTool );

// 监听巷道节点合并完成事件
tool.addEventListener( VentEventType.LANEWAY_MERGE_COMPLETED, ( message ) => {

    // TODO:待实现

} );

// 监听巷道节点合并报错事件
tool.addEventListener( VentEventType.LANEWAY_MERGE_ERROR, ( message ) => {

    // 输出错误信息
    console.log( message );

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

提示

巷道节点合并模式初始化参数,详见LanewayMergerParameters

# 风筒绘制工具

风筒绘制工具(AirDuctCreateTool)启用后,单击鼠标左键选取巷道,双击鼠标左键结束绘制。

import { AirDuctCreateTool } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 激活风筒创建工具
toolManager.activateTool( AirDuctCreateTool, {

    // 创建确认响应
    onConfirm: () => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定创建风筒?' ) ) {

                // radius 半径, offset是指在巷道上方偏移量
                resolve( { status: true, radius: 2, offset: 4 } );

            } else {

                reject();

            }

        } );

    },

    // 创建完成回调
    onCompleted: ( guid ) => {

        // TODO:待实现

    },

    // 创建报错回调
    onError: ( message ) => {

        // 输出错误信息
        console.log( message );

    }

} );

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
39
40
41
42
43
44

提示

除了通过回调方式监听风筒创建完成和风筒创建出错,也可以通过事件监听方式监听风筒创建完成和风筒创建出错,如下所示:

import { AirDuctCreateTool, VentEventType } from '@tx3d/ventilation';

// 获取风筒绘制工具
const tool = toolManager.getTool( AirDuctCreateTool );

// 监听风筒创建完成事件
tool.addEventListener( VentEventType.DUCT_DRAW_COMPLETED, ( guid ) => {

    // TODO:待实现

} );

// 监听风筒创建报错事件
tool.addEventListener( VentEventType.DUCT_DRAW_ERROR, ( message ) => {

    // 输出错误信息
    console.log( message );

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

提示

AirDuctCreateToolParameters参数,详见:AirDuctCreateToolParameters

# 通风设施创建工具

通风设施创建工具(VentilationDeviceCreateTool)包含风门风机风桥密闭 4种通风设施创建模式。可以在激活通风设施创建工具时指定创建模式,激活后可以使用通风设施创建工具的switchMode接口切换通风设施创建模式。

# 创建风门

import { VentilationDeviceCreateTool, VentDeviceType } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 方法1:激活通风设施创建工具,并设置为风门创建模式
toolManager.activateTool( VentilationDeviceCreateTool, {

    mode: VentDeviceType.AirDoor,
    options: {

        // 创建确定响应
        onConfirm: ( airwayGUID ) => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定创建风门?' ) ) {

                    resolve( { status: true, airflow: 50 } ); 

                } else {

                    reject();

                }

            } );

        },

        // 创建完成回调
        onCompleted: ( message ) => {

            const { type, guid } = message;

            // TODO:待实现

        },

        // 创建报错回调
        onError: ( message ) => {

            // 输出错误信息
            console.log( message );

        }

    }

} );

// 方法2:通过当前激活的通风设备创建工具切换到风门创建模式
ativatedTool.switchMode( VentDeviceType.AirDoor, {

    // 创建确定响应
    onConfirm: ( airwayGUID ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定创建风门?' ) ) {

                resolve( { status: true, airflow: 50 } ); 

            } else {

                reject();

            }

        } );

    },

    // 创建完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现

    },

    // 创建报错回调
    onError: ( message ) => {

        // 输出错误信息
        console.log( message );

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

提示

风门创建模式初始化参数,详见AirDoorCreaterParameters

# 创建风机

import { VentilationDeviceCreateTool, VentDeviceType } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 方法1:激活通风设施创建工具,并设置为风机创建模式
toolManager.activateTool( VentilationDeviceCreateTool, {

    mode: VentDeviceType.AirFan,
    options: {

        // 创建确定响应
        onConfirm: ( airwayGUID ) => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定创建风机?' ) ) {

                    resolve( { status: true, fanData: {} } ); 

                } else {

                    reject();

                }

            } );

        },

        // 创建完成回调
        onCompleted: ( message ) => {

            const { type, guid } = message;

            // TODO:待实现

        },

        // 创建报错回调
        onError: ( message ) => {

            // 输出错误信息
            console.log( message );

        }

    }

} );

// 方法2:通过当前激活的通风设备创建工具切换到风机创建模式
ativatedTool.switchMode( VentDeviceType.AirFan, {

    // 创建确定响应
    onConfirm: ( airwayGUID ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定创建风机?' ) ) {

                resolve( { status: true, fanData: {} } ); 

            } else {

                reject();

            }

        } );

    },

    // 创建完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现

    },

    // 创建报错回调
    onError: ( message ) => {

        // 输出错误信息
        console.log( message );

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

提示

风机创建模式初始化参数,详见AirFanCreaterParameters

# 创建风桥

import { VentilationDeviceCreateTool, VentDeviceType } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 方法1:激活通风设施创建工具,并设置为风桥创建模式
toolManager.activateTool( VentilationDeviceCreateTool, {

    mode: VentDeviceType.AirBridge,
    options: {

        // 创建确定响应
        onConfirm: ( airwayGUID ) => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定创建风桥?' ) ) {

                    resolve( true ); 

                } else {

                    reject();

                }

            } );

        },

        // 创建完成回调
        onCompleted: ( message ) => {

            const { type, guid } = message;

            // TODO:待实现

        }

    }

} );

// 方法2:通过当前激活的通风设备创建工具切换到风桥创建模式
ativatedTool.switchMode( VentDeviceType.AirBridge, {

    // 创建确定响应
    onConfirm: ( airwayGUID ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定创建风桥?' ) ) {

                resolve( true ); 

            } else {

                reject();

            }

        } );

    },

    // 创建完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

提示

风桥创建模式初始化参数,详见DeviceCreaterParameters

# 创建密闭

import { VentilationDeviceCreateTool, VentDeviceType } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 方法1:激活通风设施创建工具,并设置为密闭创建模式
toolManager.activateTool( VentilationDeviceCreateTool, {

    mode: VentDeviceType.SealingWall,
    options: {

        // 创建确定响应
        onConfirm: ( airwayGUID ) => {

            return new Promise( ( resolve, reject ) => {

                if ( confirm( '确定创建密闭?' ) ) {

                    resolve( true ); 

                } else {

                    reject();

                }

            } );

        },

        // 创建完成回调
        onCompleted: ( message ) => {

            const { type, guid } = message;

            // TODO:待实现

        },

        // 创建报错回调
        onError: ( message ) => {

            // 输出错误信息
            console.log( message );

        }

    }

} );

// 方法2:通过当前激活的通风设备创建工具切换到密闭创建模式
ativatedTool.switchMode( VentDeviceType.SealingWall, {

    // 创建确定响应
    onConfirm: ( airwayGUID ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定创建密闭?' ) ) {

                resolve( true ); 

            } else {

                reject();

            }

        } );

    },

    // 创建完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现

    },

    // 创建报错回调
    onError: ( message ) => {

        // 输出错误信息
        console.log( message );

    }

} );
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

提示

密闭创建模式初始化参数,详见DeviceCreaterParameters

提示

除了通过回调方式监听通风设备创建完成和创建报错,也可以通过事件监听方式监听创建完成和报错,如下所示:

import { VentilationDeviceCreateTool, VentEventType } from '@tx3d/ventilation';

// 获取通风设备创建工具
const tool = toolManager.getTool( VentilationDeviceCreateTool );

// 监听通风设备创建完成事件
tool.addEventListener( VentEventType.VENTDEVICE_CREATE_COMPLETED, ( message ) => {

    const { type, guid } = message;

} );

// 监听通风设备创建报错事件
tool.addEventListener( VentEventType.VENTDEVICE_CREATE_ERROR, ( message ) => {

    // 输出错误信息
    console.log( message );

} );
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

注意

为了满足通风模拟解算当前风门风机密闭三种通风设施的创建是互斥的,即以上三种类型通风设施在同一条巷道上面只允许创建一个,如果要创建一个新的通风设施,需要先删除已存在的。

# 通风设施删除工具

通风设施删除工具(VentilationDeleteTool),通风设备删除工具激活后,可以通过单击鼠标左键选中删除处场景中的巷道巷道节点风门风机风桥密闭风筒

提示

在删除巷道交叉口节点时,如果交叉口连接分支数等于2且设置了合并响应则会根据响应决定是断开巷道还是将分支巷道合并成一条巷道,如果交叉口连接分支数大于2会断开所有连接巷道。

import { VentilationDeleteTool } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 激活通风设备删除工具
engine.toolManager.activateTool( VentilationDeleteTool, {

    // 删除确定响应
    onConfirm: ( message ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( `确定删除? type: ${ message.type } guid: ${ message.guid }` ) ) {

                resolve( true );

            } else {

                reject();

            }

        } );

    },

    // 合并响应
    onMerge: () => {

        if ( confirm( '是否将交叉口连接的两条巷道合并成一条巷道?' ) ) {

            resolve( true );

        } else {

            reject();

        }

    },    

    // 删除完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现

    }

} );

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52

提示

除了通过回调方式监听通风设施删除完成,也可以通过事件监听方式监听通风设施删除完成,如下所示:

import { VentilationDeleteTool, VentEventType } from '@tx3d/ventilation';

// 获取通风设施删除工具
const tool = toolManager.getTool( VentilationDeleteTool );

// 监听通风设施删除完成事件
tool.addEventListener( VentEventType.VENTDEVICE_DELETE_COMPLETED, ( message ) => {

    const { type, guid } = message;

    // TODO:待实现

} );
1
2
3
4
5
6
7
8
9
10
11
12
13

# 通风设施修改工具

通风设施修改工具(VentilationDeviceChangeTool)主要对风门风机 两种通风设施修改。

import { VentilationDeviceChangeTool } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 激活修改工具
engine.toolManager.activateTool( VentilationDeviceChangeTool, {

    // 确认响应
    onConfirm: ( value, airwayGUID, deviceGUID, isResistance ) => {

        // value: 风阻或风量值 取决于isResistance,true为风阻,否则风量
        // airwayGUID: 风路GUID
        // deviceGUID: 设备GUID

        return new Promise( ( resolve, reject ) => {

            if ( confirm( '确定修改风门风阻?' ) ) {

                resolve( { status: true, data: { resistance: 50, isResistance: true } } );

            } else {

                reject();

            }
        } )
    }

    device: null, // 可选参数

} );

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

提示

通风设施修改工具激活参数,详见VentilationDeviceChangeToolParameters, 注意如果参数中指定了设备对象device,那激活工具后不再被允许拾取设备,如果未指定device,则工具默认拾取通风设备修改。

# 风路反转工具

风路反转工具(AirwayReverseTool),风路反转工具激活后,通过鼠标左键单击巷道或风筒反转其对应的风路方向。

import { AirwayReverseTool } from '@tx3d/ventilation';

const { toolManager } = engine; 

// 激活通风反转工具
engine.toolManager.activateTool(AirwayReverseTool, {

    // 反转确认响应
    onConfirm: ( message ) => {

        return new Promise( ( resolve, reject ) => {

            if ( confirm( `确定反转? type: ${ message.type } guid: ${ message.guid }` ) ) {

                resolve( true );

            } else {

                reject();

            }

        } );

    },

    // 反转完成回调
    onCompleted: ( message ) => {

        const { type, guid } = message;

        // TODO:待实现
        
    }

} );

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

提示

除了通过回调方式监听风路反转完成,也可以通过事件监听方式监听风路反转完成,如下所示:

import { AirwayReverseTool, VentEventType } from '@tx3d/ventilation';

// 获取风路反转工具
const tool = toolManager.getTool( AirwayReverseTool );

// 监听风路反转完成事件
tool.addEventListener( VentEventType.VENTDEVICE_REVERSE_COMPLETED, ( message ) => {

    const { type, guid } = message;

    // TODO:待实现

} );
1
2
3
4
5
6
7
8
9
10
11
12
13

提示

风路反转工具激活参数,详见AirwayReverseToolParameters

Last Updated: 3/13/2024, 11:03:57 AM