VTK JS Image Slicing basics

Hi,

I was experimenting with the image slicing example

which are really nice btw. But if I change

mapper.setSlicingMode(SlicingMode.Z)

to

mapper.setSlicingMode(SlicingMode.Y)

The rendered image disappears (no errors). I was expecting it to take the slices using a Y- orthogonal plane instead. What else do I need to change?

Hi Kit,

Have you updated your camera as well? The rendered slice respects world orientation, so showing a Y-slice when the camera is looking down the Z axis will “disappear” from the camera’s POV.

That was it. Thanks.

Hi, i’ve tried updating the camera by calling renderer.updateCamera(), but browser throws an error (activeCamera.render() is not a function)

Do I have to manually update the parameters (viewUp, directionOfProjection, etc) instead?

Indeed, renderer.updateCamera() seems to not apply for “regular” cameras (but remote cameras)…

I’m not sure to understand what you are trying to do…

I’m switching between different slicing modes (X, Y, Z) within the image-slicing.js to view the volume from different planes (axial, sagittal or coronal).

If I change mapper.setSlicingMode(SlicingMode.Z) to mapper.setSlicingMode(SlicingMode.Y) or mapper.setSlicingMode(SlicingMode.X), the renderWindow just turns black. I know that I have to update the camera properties, just not sure which values to set for each slicing mode.

Gotcha,

When you change slicing mode, your camera focal point does not change.
You only need to change the camera position.
It should be newCameraPosition = focalPoint + distance * newSlicingNormal. where distance could be the one before changing the slicing mode: distance = cameraPosition - focalPoint.