Error occurs when using vtkImageResliceMapper

Dear VTK team

here is my code:

const slicePlane = vtkPlane.newInstance();
slicePlane.setNormal([1, 0, 0]);
slicePlane.setOrigin([-177, -172, -22]);
const imageResliceMapper = vtkImageResliceMapper.newInstance();
imageResliceMapper.setInputData(this._imageData);
imageResliceMapper.setSlicePlane(slicePlane);
imageResliceMapper.setSlabType(0);
const actor = vtkImageSlice.newInstance();
actor.setMapper(imageResliceMapper);

but the actor need a mapper type of vtkImageMapper,the error occurs at the last line:

Argument of type ‘vtkImageResliceMapper’ is not assignable to parameter of type ‘vtkImageMapper’.
Type ‘vtkImageResliceMapper’ is missing the following properties from type ‘vtkImageMapper’: getSliceAtPosition, getClosestIJKAxis, getBoundsForSlice, getRenderToRectangle, and 15 more.ts(2345)

I followed the api and the example,and the example works: vtk.js.

Could you please answer why is so?
Thank you so much for the help.

Best regards

Thanks for reporting the issue. It looks like we need to update vtkImageReslice and vtkImageResliceMapper ts definitions for typescript related errors. I will log this as an issue on GitHub. Hopefully, we can get this fixed soon.

Got it
Thanks for reply

hi
Is there any other way to achieve the same function

thanks

@jadh4v

hi
Is there any other way to achieve the same function

thanks

Sorry for the delay and thanks for waiting patiently. I have posted a pull-request to address this issue:
Fix vtkImageSlice typescript definitions by jadh4v · Pull Request #2896 · Kitware/vtk-js (github.com)

This should get merged and released quickly once accepted.

@jadh4v

hi
there is another problem, can you give me more help?

  1. I download the source from github and test the ImageResliceMapper by:
    npm run example – ImageResliceMapper
    it works

  2. I tried the [Script usage] by:
    script type=“text/javascript” src=“https://unpkg.com/vtk.js”></script
    it works

  3. I import the module by:
    npm install @kitware/vtk.js
    the ImageSliceMapper dosenot work

Thanks
Best regards

I have install the latest version at 28.8.2