vtk/vtp to vtk.js

Is there a way to generate such polydata object in vtk.js format from either vtk or vtp?

When we load a vtk or vtp file on Paraview glance, this conversion happens through some script. @jourdain, can you please point me to that script that takes a vtk/vtp as an input and generates a vtk.js object?

Is this something that can help me?

As per this page, I seem to be in the right direction.

I am only with to write polydata in json format that vtk.js understands

vtp is supported natively with the vtkXMLPolyDataReader in vtk.js. You should not send a text based format over the wire.

By using one of those methods setUrl or parseAsArrayBuffer.