Skip to content

Commit

Permalink
feat(pointcloud): Sync zoom when dragging +add zoom event in scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed May 8, 2023
1 parent 636aa06 commit acc6b64
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
29 changes: 27 additions & 2 deletions packages/lb-annotation/src/core/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ export class ToolScheduler implements IToolSchedulerOperation {
private imgNode?: HTMLImageElement;

constructor(props: IToolSchedulerProps) {
this.init();

this.container = props.container;
this.size = props.size;
this.imgNode = props.imgNode;
this.config = props.config ?? JSON.stringify(getConfig(HybridToolUtils.getTopToolName(props.toolName))); // 设置默认操作
this.style = props.style ?? styleDefaultConfig; // 设置默认操作
this.onWheel = this.onWheel.bind(this);
this.init();
}

public setImgNode(
Expand Down Expand Up @@ -346,5 +346,30 @@ export class ToolScheduler implements IToolSchedulerOperation {
public init() {
this.toolOperationList = [];
this.toolOperationDom = [];
this.eventBinding();
}

public destroy() {
this.destroyAllLayer();
this.eventUnBinding();
}

public eventBinding() {
// this event will be touched when the remark layer blocks the onWheel events in specific operations, otherwise it will be blocked by the onWheel events inside
this.container.addEventListener('wheel', this.onWheel);
}

public eventUnBinding() {
this.container.removeEventListener('wheel', this.onWheel);
}

public onWheel(e: MouseEvent) {
e.preventDefault();
e.stopPropagation();
if (this.toolOperationList.length !== 0) {
const lastOneIndex = this.toolOperationDom.length - 1;
// the last one operation is the active one
this.toolOperationList[lastOneIndex].onWheel(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const PointCloudTopView: React.FC<IProps> = ({
const { x, y, z } = pointCloud.initCameraPosition;
pointCloud.camera.position.set(x + offsetY, y - offsetX, z);
pointCloud.render();
syncTopviewToolZoom(currentPos, zoom, size);
setAnnotationPos({ zoom, currentPos });
});
}, [size, ptCtx.topViewInstance, ptCtx.topViewInstance?.toolInstance]);
Expand Down
4 changes: 2 additions & 2 deletions packages/lb-utils/src/constant/pointCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export enum EPerspectiveView {
}

export const DEFAULT_SPHERE_PARAMS = {
radius: 3,
radius: 0.3,
widthSegments: 32,
heightSegments: 16,
defaultZ: 5,
defaultZ: 1,
}

0 comments on commit acc6b64

Please sign in to comment.