Skip to content

Commit c801b5a

Browse files
authored
fix: 🐛 Fix crosshairs issue whilst using a slab/MIP (#64)
Closes: #63
1 parent ea4685d commit c801b5a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/VTKViewport/vtkInteractorStyleMPRCrosshairs.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,28 @@ function vtkInteractorStyleMPRCrosshairs(publicAPI, model) {
6363
}
6464

6565
function moveCrosshairs(callData) {
66+
const { apis, apiIndex } = model;
6667
const pos = [callData.position.x, callData.position.y];
6768
const renderer = callData.pokedRenderer;
69+
6870
const dPos = vtkCoordinate.newInstance();
6971
dPos.setCoordinateSystemToDisplay();
72+
7073
dPos.setValue(pos[0], pos[1], 0);
71-
const worldPos = dPos.getComputedWorldValue(renderer);
74+
let worldPos = dPos.getComputedWorldValue(renderer);
7275

73-
const { apis, apiIndex } = model;
76+
const camera = renderer.getActiveCamera();
77+
const directionOfProjection = camera.getDirectionOfProjection();
78+
79+
const api = apis[apiIndex];
80+
const halfSlabThickness = api.getSlabThickness() / 2;
81+
82+
for (let i = 0; i < worldPos.length; i++) {
83+
worldPos[i] += halfSlabThickness * directionOfProjection[i];
84+
}
85+
86+
// Add half of the slab thickness to the world position, such that we select
87+
// The center of the slice.
7488

7589
if (apis === undefined || apiIndex === undefined) {
7690
console.error(

0 commit comments

Comments
 (0)