How can I load streamline (.vtk or .trk),and show it?

I search so many case in examples,but no answer.
I want load a streamline fie(.vtk or .trk),and show it by vtkjs,like in 3dslicer

Help me,thanks a lot
trk file
vtk file

1 Like

Did you check the Legacy reader, see this example: vtk.js

I try this,but show blank back,
and console no thing to show

Your vtk file is in binary format. The legacy PolyDataReader in vtk.js only supports the ASCII version. If you export to the ASCII vtk format, then it will work.

1 Like

vtk file load success,but streamline have no color,can I fix that?
this is a dti tract file
ASCII vtk file

slicer have color

I’d check to see if the output polydata has any pointData that can be used for coloring. If so, then you can use a lookup table to map the colors (or display rgb directly).

DTI color is come from Orientation,
I saw ScalarsToColors,but I don’t know how to use
in 3dslicer is this way

Did you set mapper.setColorByArrayName('colors')?

I try it,no effect

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
      // background: [0, 0, 0],
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const reader = vtkPolyDataReader.newInstance();
reader.setUrl(`dti/0000_str.right.vtk`).then(() => {
        const polydata = reader.getOutputData(0);
        const mapper = vtkMapper.newInstance();
        const actor = vtkActor.newInstance();

I don’t think the vtk legacy reader load fields… It was initially written to ingest geometry at the beginning of vtk.js. The readers we truly fully implemented in pure JS are .vtp and .vti along with other common formats like ply, obj


our tract model only export trk file,I use dipy convert trk to vtk format.
dipy just support trk,tck,fib,vtk,dpy convert ,so I don’t have obj or ply file.
have any way convert trk or vtk to obj file?and keep it color。