this.transformControl.addEventListener("mouseUp", (e) => {
const currentPosition = this.transformControl.object.position.clone();
pushPositionToHistory(currentPosition);
if (this.transformControl.getMode() === 'scale' && this.transformControl.object.name === 'obstacle') {
this.transformControl.object.position.y =
(this.transformControl.object.scale.y / 2) + 0.01;
}
});
在控制物体改变的的时候,检测鼠标抬起,然后检测当前控制模式是否为scale,如果是,检测当前捕捉物体是否是期望的物体。
如果是则执行,
this.transformControl.object.position.y =
(this.transformControl.object.scale.y / 2) + 0.01;
0.01是为了预防深度冲突的问题