# How to highlight a single model based on 3dtiles attribute fields?

**URL:** <https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432>\
**Category:** Cesium for Unreal\
**Created:** [May 24, 2024, 10:18am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432 "2024-05-24T10:18:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![842661047](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/842661047/32/14000_2.png) [@842661047](https://community.cesium.com/u/842661047)\
**Post date:** [May 24, 2024, 10:18am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/1 "2024-05-24T10:18:28Z")

</div>

My 3dtiles data contains two properties, id and name, both of which are string types.How to use the CesiumFeaturesMetadata Component to highlight the model by the name filed.How to correspond string types to material layers.

 ![1](https://global.discourse-cdn.com/cesium/original/3X/e/3/e3e649e0a701621c796ba6ff276f0fed53ccbea5.png)  
 ![2](https://global.discourse-cdn.com/cesium/original/3X/4/6/466ecc486c70f00bdc763e55799b18bff643bf0f.png)  
 ![3](https://global.discourse-cdn.com/cesium/original/3X/9/b/9b9e284b4fdab802f7884a41177e0473b0258d3b.png)

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [May 26, 2024, 11:52pm UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/2 "2024-05-26T23:52:43Z")

</div>

If your strings correspond to numbers, you can use the “Coerce” conversion. If the strings are CSS style color codes, you can use the “Parse Color from String” option. But if they are something else, there is currently no way to do it (short of modifying the Cesium for Unreal source code). You’d need something like this issue to be implemented:

> <https://github.com/CesiumGS/cesium-unreal/issues/829>
>
> After #698, Cesium for Unreal has the ability to pass feature metadata into Mate…rials as textures 🎉. While the "Auto Fill" button on the \`CesiumEncodedMetadataComponent\` only discovers numeric properties, even string properties can be coerced to numbers (i.e.: parsed) and then used for shading.
> 
> However, it's not currently possible to do more complicated transformations of properties to prepare them for use in Materials. For example, Cesium OSM Buildings has a \`cesium#color\` property with string values like \`"rgb(100, 65, 170)"\`. There's no way to parse this string and write an actual color into the generated texture. I hacked up a way to do this in https://github.com/CesiumGS/cesium-unreal/tree/metadata-colors, but I don't think we should ship it in this form.
> 
> In CesiumJS, \[3D Tiles Styling\](https://github.com/CesiumGS/3d-tiles/tree/main/specification/Styling) allows the use of JavaScript-like expressions to style. Implementing this in Unreal at runtime is unlikely, but we could offer an in-editor option to turn a style description into a Material.
> 
> Perhaps the more Unreal-y way to do it, though, is to let the user write a Blueprint that takes feature metadata as input and returns values to be stored in a texture, which can then be accessed from a Material. Conceptually this is really straightforward, and a proof of concept of this would probably be quick to implement. But it raises some questions:
> 
> \* Where do the Blueprints live? On the encoded metadata component?
> \* Will executing a Blueprint function per feature be too slow?
> \* Can we run a Blueprint function in a worker thread, so we don't have to block the main thread while we're processing metadata for shading?

---

<div class="post-metadata">

**Author:** ![842661047](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/842661047/32/14000_2.png) [@842661047](https://community.cesium.com/u/842661047)\
**Post date:** [May 27, 2024, 1:57am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/3 "2024-05-27T01:57:18Z")

</div>

Ok,Thank you for your reply!

---

<div class="post-metadata">

**Author:** ![cqliao](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/cqliao/32/3294_2.png) [@cqliao](https://community.cesium.com/u/cqliao)\
**Post date:** [May 28, 2024, 11:40am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/4 "2024-05-28T11:40:22Z")

</div>

I have been striving to find ways to individually modify the materials of each component in a 3DTiles model but have encountered challenges along the way. Specifically, after converting a BIM model to 3DTiles format, I aim to dynamically adjust the color of certain building elements through a RESTful API interface. For instance, I would like to color some building columns red, others green, or set them to be transparent. Considering the potential need to transmit substantial data via the API, such as altering the color of up to 1,000 columns at once, I am uncertain whether the Cesium for Unreal plugin supports this functionality or if it is technologically unfeasible altogether. Please help confirm the viability of this requirement and suggest feasible approaches. Thank you.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [May 30, 2024, 8:26am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/5 "2024-05-30T08:26:21Z")

</div>

@cqliao please start a new thread, as your question appears unrelated to the previous discussion in this one.

To answer briefly: dynamically changing styling based on metadata properties as you describe should be doable, though the specifics may vary. You’ll need to provide a custom material, and then it’s a matter of getting the information needed to drive the styling into that material. One way to do that is with a Material Parameter Collection:

> **[Using Material Parameter Collections In Unreal Engine | Unreal Engine 5.4...](https://dev.epicgames.com/documentation/en-us/unreal-engine/using-material-parameter-collections-in-unreal-engine)**
>
> Assets that store an arbitrary set of scalar and vector parameters which can be referenced in any Unreal Engine Material.

Another possibility is to bake the style into a texture that your material samples, and then you update that texture as needed.

---

<div class="post-metadata">

**Author:** ![842661047](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/842661047/32/14000_2.png) [@842661047](https://community.cesium.com/u/842661047)\
**Post date:** [June 4, 2024, 6:32am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/6 "2024-06-04T06:32:39Z")

</div>

Hello, it seems that storing the string field previously did not achieve a highlighting effect. Now, I have saved the float field in 3dtiles.  
I can set the model to highlight by using the CesiumEncodedmetadata component in CesiumForUnreal version 1.31.2.

 ![1](https://global.discourse-cdn.com/cesium/original/3X/7/d/7d7727d8eafeb92cfa70002f4c640439634fee29.jpeg)

However, using the CesiumFeaturesmetadata component in CesiumForUnreal version 2.5.0 does not seem to work properly.

 ![2](https://global.discourse-cdn.com/cesium/original/3X/2/6/264de599fe3756b2c40742541dc8191364d64331.png)

The problem may be that the PTABLE\_propertyTableName\_propertyName has not been updated.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [June 4, 2024, 6:58am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/7 "2024-06-04T06:58:01Z")

</div>

Hi @842661047, I’m not sure what might cause that problem. Can you give us step-by-step instructions for reproducing the problem you’re seeing, preferably starting with the Cesium for Unreal Samples project, so that we can investigate?

---

<div class="post-metadata">

**Author:** ![Join\_Hans](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/join_hans/32/26190_2.png) [@Join\_Hans](https://community.cesium.com/u/Join_Hans)\
**Post date:** [October 30, 2024, 1:03pm UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/8 "2024-10-30T13:03:51Z")

</div>

Hi @Kevin_Ring I see that I can convert string property to shader by “Parse color from string” and support format is rgb and hexcode e.g ff0000 like this image:

 ![image](https://global.discourse-cdn.com/cesium/original/3X/0/3/03e9bf03d051ead6116516ab07cd3a5889fbab2a.png)  
I want to ask if it supports rgba too? for example my string color property is “#f2f2f2b2”

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [November 4, 2024, 6:47am UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/9 "2024-11-04T06:47:59Z")

</div>

Hi @Join_Hans,  
Unfortunately, no, “Parse Color from String” currently does not support alpha. For reference, the code that does the parsing is here:

> <https://github.com/CesiumGS/cesium-unreal/blob/v2.10.0/Source/CesiumRuntime/Private/CesiumEncodedMetadataConversions.cpp#L453>

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [November 4, 2024, 3:02pm UTC](https://community.cesium.com/t/how-to-highlight-a-single-model-based-on-3dtiles-attribute-fields/32432/10 "2024-11-04T15:02:17Z")

</div>

@Join_Hans Kevin is right, but I just wanted to add that you’re welcome to open a Github issue for this feature if you’d like it to be supported in the plugin.

You’re also welcome to modify the plugin for your needs – and if you do, we’d love to see a PR opened for the contribution! 😄
