Use variable as Cesium3DTileStyle condition value


I’m probably overlooking something, but I would like to use a variable in a condition to style features with that value. I tried defining it, but no luck. If I enter the value in manually, the styling does work.
Is it possible to use a variable in the conditions?
By the way, the values I’m trying to compare are both strings.

Thanks in advance

function hideDuplicateBuilding(someVar) { = new Cesium.Cesium3DTileStyle({
        defines: {
            someNewVar: someVar,
        color: {
            conditions: [
                    "${feature['sameVarValue']} === '${someNewVar}'",
                    "color('cyan', 0.5)",

This seems to be related to the types and evaluation of the expressions.

With a definition like

    someNewVar: `'${someVar}'`,

(inserting the value (which is a string) into 'quotes'), and the condition using

"${feature['sameVarValue']} === ${someNewVar}",
//-----------------------------^  no quotes  ^

it should be possible to achieve the desired result.

Intuitively, one could expect the same result as for your approach, but there seems to be a caveat. Maybe the single quotes in ... === '${someNewVar}' cause it to not do the variable substitution? If this was the case, it would end up comparing the value to the string '${someNewVar}' (insead of the string 'whateverTheValueWas'). But that’s really only a wild guess for now - I’d have to read more about the types, expression evaluation, variable substitution, and escaping rules of the styling language if I had to profoundly explain why it did not work…

Here’s a sandcastle using such a construct, to color certain buildings in the Cesium OSM buildings, based on their material:


If I have understood correctly, I think that you can solve your problem by using the following expression:

“${feature[‘sameVarValue’]} ===”+someVar, “color(‘cyan’, 0.5)”

that is by chaining the strings.

I use this kind of expression to compare values that are numbers, hope it works also for strings!