# 批量创建工具

批量创建工具(BatchCreateTool)由 @tx3d/extension 包提供。

import { BatchCreateTool } from '@tx3d/extension';

//工具参数
let params = {

    spacing: 4,         // 间距
    isInstanced: true,  // 是否实例化渲染
    adsorbDistance: 1, // 吸附距离
    axesAngle: 0         //辅助轴角度

};

// 创建工具
let tool = engine.toolManager.addTool(BatchCreateTool, params);

// 监听创建完毕事件
tool.addEventListener(BatchCreateTool.EVENT_BATCH_CREATE, (event) => {

    let models = event.models; //如果isInstanced是true  返回InstancedModel实体  否则返回Model实体数组

});

// 激活工具
engine.toolManager.activateTool(BatchCreateTool);

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

提示《使用说明》

创建:鼠标左键选则要复制的物体,双击鼠标左键结束。
取消:鼠标右键可取消当前创建。
支持撤销和重做

提示

批量创建工具参数,详见BatchCreateToolParameters

# 属性

🌏 isInstanced 是否采用实例化渲染

tool.isInstanced = true;
1

🌏 spacing 物体之间的间距

tool.spacing = 4;
1

🌏 adsorbDistance 坐标轴吸附的距离阈值

tool.adsorbDistance = 1;
1

🌏 axesAngle 坐标轴旋转角度

tool.axesAngle = 90;
1
Last Updated: 9/7/2023, 4:51:53 PM