Setting 'white' color using the filtering extension is grey

Thank you for seeking help! Our friendly community is here to assist you. :folded_hands:

To assist you better, please consider providing:

  • Speckle Status: Please check that our systems are up and running: https://status.speckle.systems/

  • Objective: I am trying to export elevations from the Speckle Viewer with objects color coded.

  • Issue: I can assign colors to the objects properly but am dealing with the issue of ‘white’ not appearing as white, but grayish. I would like some help in figuring out how to change object colors to pure white.

  • Example:
    In my code, I am getting all the nodes which have properties that I can identify as Facade Modules (a custom class), and properly assign the colors to them. Everything which is not a Facade Module should be white.

    try {
      viewer.getWorldTree().walk((node: TreeNode) => {
        if (isFacadeClass(node)) {
          const globalId = node['model']['raw']['GlobalId'];
          if (globalId && globalIdToColorMap.has(globalId)) {
            const color = globalIdToColorMap.get(globalId)!;
            // If this color hasn't been seen, initialize its array.
            if (!colorUpdatesMap.has(color)) {
              colorUpdatesMap.set(color, []);
            }
            colorUpdatesMap.get(color)!.push(node['model']['id']);
          }
        } else {
          if (
            prepareForExport &&
            node['model'].hasOwnProperty('renderView') &&
            node['model']['renderView'] !== undefined &&
            node['model']['renderView'] !== null
          ) {
            nonFacadeNodes.push(node);
            colorUpdatesMap.get('FFFFFF')?.push(node['model']['id']);
          }
        }
        return true; // Continue walking the tree
      });

      const colorUpdates = Array.from(colorUpdatesMap.entries()).map(
        ([color, objectIds]) => ({
          color,
          objectIds,
        })
      );

      if (colorUpdates.length > 0) {
        this.filterExtension.setUserObjectColors(colorUpdates);

      }

Hi @Jovin_Lim_DPASG

The underlying material that setUserColors applies is a derivation of a stock three.js PBR material which implicitly is affected by both direct and indirect light. This means that even if you set it’s color to white the final color that you will get will be influenced by lighting as well as tonemapping.

However, I tried setting some objects to white and even if they are not solid white they are “reasonably white”. Can you share the stream, maybe there is something wrong with the normals

Alternatively, if you want solid colors you can make a SpeckleBasicMaterial and apply it directly to the render views like so

const material = new SpeckleBasicMaterial({
  color: 0xffffff
})
material.toneMapped = false // important
material.color.convertSRGBToLinear()

const rvs = // the render views
 
viewer.getRenderer().setMaterial(rvs, material)

The above will apply solid colors unaffected by lighting or anything else.

Cheers

I unfortunately am unable to share the stream. Your solution works pretty well, thank you!

1 Like

This topic was automatically closed after 180 days. New replies are no longer allowed.