Hi,
I am trying to recreate a similar example using vtk.js to that shown in pyvista (see target example below) where the color scale can be set to discrete values for scalars within a particular range. I am having trouble finding a reference example to help me with this problem. See below where I have got to so far… struggling to understand if lookupTable.addRGBSegment
will be able to help me achieve this. Any help much appreciated!
Link to Pyvista example I’m trying to replicate
// Assume scalar values are between 0 and 1 for now.
lookupTable = vtk.Rendering.Core.vtkColorTransferFunction.newInstance();
// Attempt to set all scalar values between 0to0.5 = black and all values 0.5to1.0 = white
lookupTable.addRGBSegment(0, 1, 1, 1, 0.5, 1, 1, 1)
lookupTable.addRGBSegment(0.5, 0, 0, 0, 1.0, 0, 0, 0)
lookupTable.setVectorModeToMagnitude();
lookupTable.setMappingRange(0,1);
lookupTable.updateRange();
lookupTable.setDiscretize(true)
mapper.setLookupTable(lookupTable);
mapper.setColorModeToMapScalars();
mapper.setInterpolateScalarsBeforeMapping();
mapper.setScalarModeToUsePointData();
mapper.setScalarVisibility(true);
// Assume scalar range is between 0 and 1 for now. This will be set dynamically with more complex example.
mapper.setScalarRange(0,1);
const actor = vtk.Rendering.Core.vtkActor.newInstance();
actor.setMapper(mapper);