记录three中拖拽场景会触发click事件
解决方法
dragNoClick = () => {
const lock = (e) => {
this.lockStart = this.map.controls.target.clone();
};
const unlock = (e) => {
const target = this.map.controls.target;
if (!this.lockStart || this.lockStart.distanceTo(target) > 0.1) {
this.lockTiles = false;
} else {
this.lockTiles = true;
}
};
const controls = this.map.controls;
controls.addEventListener("start", lock);
controls.addEventListener("end", unlock);
绑定事件
handleEvent = (t, fn) => {
this.map.on(t, (e) => {
if (e.length <= 0) {
return;
}
if (t === "click") {
if (this.lockTiles) {
fn(e);
}
} else {
fn(e);
}
});