# 工具
Tx3d Engine默认提供测量和编辑工具。此外,二次开发人员也可以根据具体需求扩展新的工具,详见教程“如何开发一个工具”。工具需要先添加到工具管理器(ToolMananger)中,然后才能够被激活和冻结。
# 添加工具
使用引擎(Engine)toolManager属性的addTool接口添加工具。
import { TransformEditorTool } from '@tx3d/extension';
// 添加方位编辑工具
const tool = engine.toolManager.addTool( TransformEditorTool );
1
2
3
4
2
3
4
# 获取工具
使用引擎(Engine)toolManager属性的getTool接口获取工具。
import { TransformEditorTool } from '@tx3d/extension';
// 获取方位编辑工具
const tool = engine.toolManager.getTool( TransformEditorTool );
1
2
3
4
2
3
4
# 移除工具
使用引擎(Engine)toolManager属性的removeTool接口移除工具。
import { TransformEditorTool } from '@tx3d/extension';
// 移除方位编辑工具
engine.toolManager.removeTool( TransformEditorTool );
1
2
3
4
2
3
4
# 激活工具
使用引擎(Engine)toolManager属性的activateTool接口激活工具。
import { QueryMask } from '@tx3d/core';
import { TransformEditorTool } from '@tx3d/extension';
// 激活方位编辑工具
engine.toolManager.activateTool( TransformEditorTool, {
mode : 'translate' ,
space: 'local',
queryMask : QueryMask.All
} );
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 获取激活工具
使用引擎(Engine)toolManager属性的activatedTool属性获取当前激活工具。
// 获取当前激活工具
const tool = engine.toolManager.activatedTool;
1
2
2
# 冻结工具
使用引擎(Engine)toolManager属性的deactivateTool接口冻结当前激活工具。
// 冻结当前激活工具
engine.toolManager.deactivateTool();
1
2
2