autodesk-forgeautodesk-viewer

Autodesk Forge Viewer v7 - setThemingColor


I hope somebody can help me with a question about the setThemingColor function for the Autodesk Forge Viewer.

Basically my issue is that when I run the

viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), null, true )

from within my code nothing happens, and the element does not get a new color.

What I have tried:

1) If I try to run exactly the same line of code in the browser on the NOP_VIEWER it works, but only if it is a new dbId and not the one which had just been run from within my code.

2) I have tried to make sure to find the leaf dbId and use this. Did not have any effect.

3) I have tried to add the model to the function call:

viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), model, true )

4) I have tried to run the function on the level of the model:

model.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ));

viewer.impl.invalidate(true);

5) I have from within my code tested viewer.isolate(dbId) to make sure I have access to the viewer instance. And this works.

Is anybody else experiencing the same issue or can replicate the bug? I hope somebody can help us out.

EDIT: More infor after Petr Broz answer:

"What version of the viewer are you using?": We are using v. 7.*

"Do you see any error logs in the console after setting the theming color?": I see no error logs.

"At what point in time are you trying to set the color (for example, after the GEOMETRY_LOADED_EVENT)?": I use a onClick event on button, so it is after GEOMETRY_LOADED_EVENT

ANSWER:

I found the solution. I had to import THREE as a global.

/* global THREE */

instead of

import {Vector4d} from "three"


Solution

  • Here's a quick codepen setting the theming color on a pre-configured dbID (roof of the house), using viewer version 7.* (currently 7.10): https://codepen.io/petrbroz/pen/WNbYXWz.

    It'd be helpful if we had some additional info, for example:

    Alternatively, if you don't mind sharing a live link to your app or your Forge app config, please send us an email to forge (dot) help (at) autodesk (dot) com, and we'll investigate the issue from our end.