GLTF export and texture to PNG

I have a vtk structured grid with single scalar points data (temperature values). I am taking a planar slice out of it using vtk cutter and supplying it a constant z plane. Then, I am exporting that slice out to a gltf file. I am also trying to export out the slice texture as png. Here is my code snippet:

plane = vtk.vtkPlane()
plane.SetOrigin(grid.GetCenter())
plane.SetNormal(0.0, 0.0, 1.0)

cutter = vtk.vtkCutter()
cutter.SetInputData(grid);
cutter.SetCutFunction(plane);
cutter.Update()

slice = cutter.GetOutput()

slice.GetPointData().SetActiveScalars(attr)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(slice)
mapper.SetInterpolateScalarsBeforeMapping(True)

actor = vtk.vtkActor()
actor.SetMapper(mapper)

renderer = vtk.vtkRenderer()
renderer.AddActor(actor)

render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)

render_window.Render()

exporter = vtk.vtkGLTFExporter()
exporter.SetFileName(“slice.gltf”)
exporter.SetRenderWindow(render_window)
exporter.SetInlineData(True)
exporter.Update()

w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(render_window);
w2if.Update();

writer = vtk.vtkPNGWriter()
writer.SetFileName(outPath+“/”+attr+“-z(”+str(z)+“)-slice.png”)
writer.SetInputData(w2if.GetOutput());
writer.Write();

exporter.Write()

Firstly, the vtk render window doesn’t show temperature colors. When I open the exported GLTF in paraview, it opens in “Solid color” mode by default, and when I change that to TEXCOORD_0, it correctly shows colors corresponding to temperature values, just that the slice colors correspond to temperature range within the slice. Additionally, when I open this GLTF in a GLTF viewer, e.g. Babylon.js, it doesn’t show up with TEXCOOR_0 colors. Furthermore, what I export out as png is the render_window, while I just want to export out the slice.

My questions are:

  1. How to rename TEXCOORD_0 to a more appropriate attribute name, e.g. “temp”?
  2. How to change slice colors so that they correspond to the temperature values in the grid and not in the slice?
  3. How to setup gltf export such that by default it opens with TEXCOORD_O or temp in any gltf viewer.
  4. How to export slice texture out as a png image?

Thanks
Ashish