Skip to content

Commit

Permalink
feat: 添加右键取消选中的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyang committed Sep 14, 2024
1 parent 88d6b6b commit dd1aea1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/lb-annotation/src/core/pointCloud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ export class PointCloud extends EventListener {
if (intersects.length > 0) {
const intersectedObject = intersects[0].object;
this.pipe?.setNeedUpdateCenter(false);
this.pipe?.setSelectedIDs([intersectedObject.userData.selectedID]);
this.pipe?.setSelectedIDs(intersectedObject.userData.selectedID);
} else {
this.pipe?.setSelectedIDs(undefined);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export default class ViewOperation extends BasicToolOperation {

public onRightClick(e: MouseEvent): void {
const targetId = this.getClickTargetId(e);
if (!targetId) return;
this.needUpdatePosition = false;
if (this.posTimer) {
clearTimeout(this.posTimer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,6 @@ class BasicToolOperation extends EventListener {
this.container.addEventListener('mouseleave', this.onMouseLeave);
this.container.addEventListener('click', this.onClick);
this.container.addEventListener('wheel', this.onWheel);
this.container.addEventListener('contextmenu', this.onRightClick);
document.addEventListener('keydown', this.onKeyDown);
document.addEventListener('keyup', this.onKeyUp);
window.parent.document.addEventListener('contextmenu', this.onContextmenu, false);
Expand All @@ -843,7 +842,6 @@ class BasicToolOperation extends EventListener {
this.container.removeEventListener('mouseleave', this.onMouseLeave);
this.container.removeEventListener('wheel', this.onWheel);
this.container.removeEventListener('click', this.onClick);
this.container.removeEventListener('contextmenu', this.onRightClick);
document.removeEventListener('keydown', this.onKeyDown);
document.removeEventListener('keyup', this.onKeyUp);
window.parent.document.removeEventListener('contextmenu', this.onContextmenu, false);
Expand Down Expand Up @@ -957,6 +955,10 @@ class BasicToolOperation extends EventListener {
}

this.startTime = 0;

if (e.button === 2) {
this.onRightClick(e);
}
this.render();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ class PointCloud2DRectOperation extends RectOperation {

public rightMouseUp(e: MouseEvent) {
const hoverRect: (IRect & { boxID?: string }) | undefined = super.rightMouseUp(e);
if (hoverRect) {
this.emit('onRightClick', { event: e, targetId: hoverRect.boxID });
}
this.emit('onRightClick', { event: e, targetId: hoverRect?.boxID });
return hoverRect;
}
}
Expand Down

0 comments on commit dd1aea1

Please sign in to comment.