GLTF Mesh picking highlight


I am currently having an issue when trying to highlight a mesh from a gltf model with shared materials.

When selecting the object, this code is executed during left click event.

var pickedFeature = viewer.scene.pick(movement.position);

pickedFeature.node._runtimeNode.commands[“0”].command = pickedFeature.node._runtimeNode.commands[“0”].pickCommand;

I am able to change the color of the selected mesh as you can see in ChanteloupHighlighted.png.

However I have no control over the color, and when I try to force the color in the fragment shaders of all pickCommands by replacing

gl_FragColor = czm_pickColor;

with gl_FragColor = vec4(0.5,0.5,0.0,0.0);

I can’t select any features anymore.

I have also tried modifying colors of pickIds but the results are the same, I can’t select any features.

Since material are shared but shaders can be used to highlight different meshes that use the same material, is there anyway to control the highlighted color ?



What you’re seeing drawn is the pick color and it is not meant to be modified. The pick color correlates to a unique id associated with the node that enables picking to work. Internally the pick pass will render all pick commands to an offscreen framebuffer, read the pixel color at the mouses’s position, and then get the associated entity. Basically it’s not intended for setting an object’s color or rendering.

So long way to say we don’t yet have support for changing the color of a model node. It’s possible in 3D Tiles but not models alone.

There’s a Github issue open for this:

What about now?