That’s one of the quirks with the current way the FilteringExtension works. It’s sort of 'all-or-nothing", and it does reset materials when using it’s functions
Fortunately, you don’t necessarily need to go trough the filtering extension in order to color or change object materials. Similarly to how you use setMaterial to color specific materials, you can also ghost them. Depending on how you access object ids and render views, there is more than one way of achieving this, however I will exemplify an easy approach
const allRenderViews = viewer.getWorldTree().getRenderTree().getRenderableRenderViews( SpeckleType.Pointcloud,
SpeckleType.Brep,
SpeckleType.Mesh,
SpeckleType.Point,
SpeckleType.Line,
...<whichever other type>
)
const renderTree = viewer.getWorldTree().getRenderTree(nodeTree.model.id);
const node = viewer.getWorldTree().findId(nodeTree.model.id);
const rvs = renderTree.getRenderViewsForNode(node[0]);
const materialData = {
color: color,
opacity: opacity,
roughness: 1,
metalness: 0,
vertexColors: false,
};
// Whenever you need to color things, you start off by ghosting everything
viewer.getRenderer().setMaterial(allRenderViews , { filterType: FilterMaterialType.GHOST })
// Then you color what you need to color
viewer.getRenderer().setMaterial(rvs, materialData);
// Other coloring ...
It’s not the most efficient, but should get the job done. Just remember that if your scene does not change, you don’t need to search for nodes and render views each time you want to color objects. You can easily cache them, and just invalidate that cache if the scene changes