Currently, we have implemented a system where the client retrieves object states when the page loads, changing the colors of 'pending' objects in the model. We continue to poll for changes to update the coloring - initially coloring pending objects upon viewer load and then checking and updating state periodically to render them in different colors while storing their original color/material. If a change is detected that an object should no longer be colored, we instruct Forge to revert to the old color/material.
The Issue: We have identified the problem but are struggling to find a solution. The issue lies in the fact that changing materials in Forge only works within the first few seconds after startup (materials were used to display colors).
However, setting overlays continues to work even after the initial ~3 seconds, showing overlays instead of materials to represent colors. This is suboptimal as overlays may appear over everything.
Materials appear to be 'locked' after the initial ~3 seconds, prohibiting further changes or updates. It seems like they are not being refreshed properly.
In some examples, using viewer.impl.invalidate(true)
was suggested to refresh the Forge viewer, but this approach ceases to be effective after the initial ~3 seconds.
We have attempted various combinations of
viewer.impl.invalidate(true, true, true)
, setting material.needsUpdate
to true
, and trying to re-render the entire scene without success.
We also came across this GitHub issue, although implementing similar fixes in Forge proves challenging. Even using viewer.requestSilentRender()
did not yield results.
To better understand the situation, here is all the necessary code: DROPBOX LINK
Furthermore, here is a snippet from the index.html
file defining color settings:
try
{
viewer.restoreAllColorOverlays(); //to use materials instead of overlays: viewer.restoreAllColorMaterials();
$.each(colors, function(color, selectionIds)
{
viewer.setColorOverlay(selectionIds, color); //to use materials instead of overlays: viewer.setColorMaterial(selectionIds, color);
});
}
catch(error)
{
console.error(error);
}