Force actor to fit the renderer size exactly

Hi guys.

I have a vtkImageSlice as var actor = vtkImageSlice.newInstance();, and I would like to make it exactly the size of my renderer. Is there a simple way to do this?

Or any way to resize the ImageSlice, I can’t seem to find a way to do it.

Here is the full code:

 const renderWindow = vtkRenderWindow.newInstance(); //Now uses RenderWindow instead of Fullscreen render window
        var scalars = vtkDataArray.newInstance({
            values: rgbArray,
            numberOfComponents: 3, // number of channels
            dataType: VtkDataTypes.UNSIGNED_CHAR, // values encoding
            name: 'scalars'
        });

        var imageData = vtkImageData.newInstance();
        imageData.setOrigin(0, 0, 0);
        imageData.setSpacing(1.0, 1.0, 1.0);
        imageData.setExtent(0, width - 1, 0, height - 1, 0, depth - 1);
        imageData.getPointData().setScalars(scalars);

        var mapper = vtkImageMapper.newInstance();
        mapper.setInputData(imageData);

        var actor = vtkImageSlice.newInstance();
        actor.setMapper(mapper);

        var view3d = document.getElementById("view3d");

        const openglRenderWindow = vtkOpenGLRenderWindow.newInstance();
        openglRenderWindow.setContainer(view3d)

        const dims = view3d.getBoundingClientRect();
        openglRenderWindow.setSize(dims.width, dims.height)

        renderWindow.addView(openglRenderWindow);

        const sliceRenderer = vtkRenderer.newInstance({
            background: [255, 255, 255]
        });

        sliceRenderer.addVolume(actor);
        renderWindow.addRenderer(sliceRenderer) 
        renderWindow.render();

You will need to modify the camera parameters to make your image the size of the renderer. If you are using orthographic/parallel projection, check out this code: https://github.com/KitwareMedical/paraview-medical/blob/master/src/vtk/proxyUtils.js#L26.