0

We're working with Forge Viewer v7 and trying to color objects based on their ID. The idea is simple: when we provide an ID, the viewer should color the corresponding objects and sub-objects.

We’ve used viewer.setThemingColor(dbId, colorCode, null, true) hoping it would apply the color recursively:

dbIds.forEach(dbId => {
  let color = new THREE.Color(colour);
  let colorCode = new THREE.Vector4(color.r, color.g, color.b, 1);
  vm.viewer.setThemingColor(dbId, colorCode, null, true);
});

It works fine when the ID matches a geometry node directly (like a mesh), but when the node corresponds to a group, the sub-object inside that group are not colored. It seems the recursive flag doesn’t traverse into the group structure as expected.

Has anyone run into this issue before or found a reliable way to color all sub-objects belonging to an ID node? Any advice or ideas would be greatly appreciated.

2
  • When tagging try to get as close to the product and framework you can. "color", "viewer" is not related to "Autodesk Forge Viewer" and "Three.js" Commented Sep 18 at 10:49
  • So there is a flag, but try the “Revisiting Viewer’s Theming Coloring” blog Commented Sep 18 at 10:57

1 Answer 1

0

It seems to work for me. I select a group with SHIFT+Right-Click then check the dbId for it, use it to set the colour, then deselect it so that I can see its colour (otherwise the blue highlight colour hides it).

I'm testing on https://viewer.autodesk.com/ based on https://aps.autodesk.com/blog/do-simple-viewer-api-tests-quickly

NOP_VIEWER.getSelection()
// [2219]
NOP_VIEWER.setThemingColor(2219, new THREE.Vector4(1, 0, 0, 1), null, true)
// undefined
NOP_VIEWER.select() // clearing selection

Here is the model: https://autode.sk/46Q3kGA

Set theming colour for group

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.