I have two loaded models and an array of dbId elements of these models. I need to change the color of the elements of the models by their dbId, which I already have in the array. I had implemented such a function, but now I have to change it so that it works only after the user clicks the color change button.
Not sure what exactly is holding you back here? Shouldn't you just change the colors by dbids and model in your click event handler of the button?:
<button onclick="viewer.setThemingColor(dbid,THREEVecrtor4Color,model,recursiveFlag)">Click me</button>