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);

        var mapper = vtkImageMapper.newInstance();

        var actor = vtkImageSlice.newInstance();

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

        const openglRenderWindow = vtkOpenGLRenderWindow.newInstance();

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


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


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: