How to add vtkImageSlice for addActor

Hello, i’m beginer vtk.js using 24.18.7

I tried to convert a 2D image to 3D as in your MultiSliceImageMapper example

const renderer = fullScreenRenderWindow.getRenderer();
const imageActorI = vtkImageSlice.newInstance();
renderer.addActor(imageActorI);

TypeScript error message:
TS2345: Argument of type 'vtkImageSlice' is not assignable to parameter of type 'vtkActor'.

imageSlice/index.d.ts

export interface vtkImageSlice extends vtkProp3D {
	/**
	 * 
	 */
	getActors(): any;
...
}

but ImageSlice/index.js

  publicAPI.getActors = () => publicAPI;

is not implemented getActors in imageSlice in 24.18.7?
Do you have any other options for implementation?

This looks like a bug in the vtk.js types. Please post this as an issue to the vtk.js issue tracker, and we can address this soon.

In the meantime, you can instead call renderer.addViewProp(imageActorI). The addActor signature should accept vtkProp, not just vtkActor.

2 Likes