DataArray example

Thanks so much Sebastien, I really appreciate it! I have followed the steps from the Geometry Viewer code that you referenced but still couldn’t get it to work.
https://jsfiddle.net/k_udilovich/r3joqg74/113/
I know that data array has scalar information but I must be missing something obvious in the mapper.
Obviously, it works in your repo. I think that I should probably run the same data side by side using Geometry Viewer and my code to see where the differences are. What would be the best way to do it? I’ve tried

npm run example -- GeometryViewer

from vtk-js folder, but then the project tells me “Project is running at http://0.0.0.0:9999/” which I cannot open in Firefox.

Just open http://localhost:9999

Perfect. This was very helpful. I got it to work.
image

These were the settings that I should have used:

      mapper.set({
        colorByArrayName: "acceleration",
        colorMode: ColorMode.MAP_SCALARS,
        interpolateScalarsBeforeMapping: true,
        scalarMode: ScalarMode.USE_POINT_FIELD_DATA,
        scalarVisibility: true,
        lookupTable: lookupTable,
      });

the lookup table looks like this:

      //configure lookup table
      const lookupTable = vtkColorTransferFunction.newInstance();
      //apply preset
      var preset = vtkColorMaps.getPresetByName("erdc_rainbow_bright");
      lookupTable.setVectorModeToComponent();
      lookupTable.setVectorComponent(0);
      lookupTable.setMappingRange(0, 1);
      lookupTable.applyColorMap(preset);
      lookupTable.updateRange();

Obviously for this test the data range is between 0 and 1.
Sebastien, thank you som much for guiding me through this! :joy:

1 Like

Is there an tutorial or documentation to explain the internal data structure of vtk.js?

Why do you need the internal? Don’t you want to use the API?