Skip to main content

Visualize Mesh Features and Metadata

Building in a 3D dataset highlighted with associated metadata in a popup window, visualized in Cesium for Unreal

Metadata shown in a UMG widget from Cesium for Unreal Samples.

Features and metadata are core concepts in 3D Tiles, providing a finer granularity of detail to enable rich informational experiences. In one example, a building can differentiate sub-building features in its 3D mesh—e.g., windows, walls, and roofs—and render them with photorealistic materials. The same building can also be part of a larger city block with per-building metadata, such as number of floors or date of construction. With Cesium for Unreal, this information can be queried at runtime and displayed or visualized in meaningful ways.

Features and metadata are specified by the EXT_mesh_features and EXT_structural_metadata glTF extensions, respectively. These extend a model’s geometry and texture information, storing supplemental data for efficient retrieval at runtime. Both extensions are supported in Cesium for Unreal v2.0+. For backward compatibility, legacy 3D Tiles with batch tables or batch table hierarchies will be converted to the new extensions as they load. Although EXT_mesh_features is often used in tandem with EXT_structural_metadata, these extensions can exist and be used independently of each other.

This tutorial outlines how to utilize mesh features and metadata in two ways:

  1. Styling: modifying the tileset’s appearance based on its features and metadata values.
  2. Picking: selecting a feature in the tileset and displaying its associated metadata.

The steps below will use the New York City 3D Buildings dataset, available to all Cesium ion users via the Asset Depot. Feel free to use your own 3D Tiles tileset if it contains features or metadata—just note that the available features and metadata properties will depend on the data.

You’ll learn how to:

  • Use the CesiumFeaturesMetadata component to style a 3D Tileset.
  • Access features and metadata in the tileset with Blueprints.
  • Select features at runtime to view their associated metadata properties.
Information

Want to see this feature in action without implementing it yourself? Check out the premade sample scene in Cesium for Unreal Samples. The level contains a UMG widget that displays the tileset’s metadata. Feel free to experiment with and build on the existing level for your own projects.

Prerequisites

  • Unreal Engine 5.6 or later.
  • Cesium for Unreal v2.31.0 or later. 
  • Know how to set up a basic Cesium for Unreal application. Check out our Cesium for Unreal Quickstart guide for instructions on getting started with the Cesium for Unreal plugin.
  • A Cesium ion account. If you don’t have one, you can log in with your Epic Games account.
Information

The minimum versions required for this tutorial are Unreal Engine 5.1 and Cesium for Unreal v2.0.0. However, it is highly recommended to use Cesium for Unreal v.2.30.0 or later. Earlier versions do not support Blueprint Styling and will display a different user interface.

If you’re still using Cesium for Unreal v1, find the older version of this tutorial here.

It is recommended that you familiarize yourself with the EXT_mesh_features and EXT_structural_metadata specifications, because Cesium for Unreal will interface directly with those extensions.

1Add the New York City tileset

This tutorial uses the New York City 3D Buildings tileset. Each building is a feature associated with various metadata properties, such as height, building type, and ownership.

1Start with a scene that includes Cesium World Terrain, CesiumSunSky, and a DynamicPawn. If you need with creating these elements, check out the Quickstart for detailed instructions.

2Connect to Cesium ion using the Cesium panel, if you have not already connected.

3Open the Cesium ion Assets window. If you don’t see the window in the Editor, open it using Window > Cesium ion Assets, or press the Add button in the Cesium panel.

The Add button in the Cesium panel, next to the Cesium ion Assets item in the Window drop-down.

4Find New York City 3D Buildings in the asset list and select it. Click Add to Level.

New York City 3D Buildings listed in the Cesium ion Assets window, with an Add to Level button.
Information

Is New York City 3D Buildings missing from the asset list? Visit the New York City 3D Buildings Asset Depot page and click Add to my assets. Then return to Unreal Engine. Click the blue Refresh button in the top left corner of the Cesium ion Assets panel to refresh the asset list.

5Double-click on the CesiumGeoreference in the World Outliner. In the Details panel, set the Georeference Origin to the following coordinates:

Origin Latitude: 40.700001
Origin Longitude: -74.002998
Origin Height: 418.0

After setting these coordinates, you should see the New York buildings that you just added at this new location.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. New York City 3D Buildings.

Depending on what tileset you use, you may have to adjust the Time Zone or Solar Time on your CesiumSunSky to properly light the level.

6Right-click on the DynamicPawn in the World Outliner and select Move Object to Camera. This ensures that the game will start at the new location.

Move Object to Camera, under View Options

2Style with features and metadata in material

Next, you'll prepare a material to style the tileset, i.e., modify its appearance based on its features and metadata. There are two methods of metadata styling in Cesium for Unreal:

  • Material: Metadata values are passed directly to the material through textures.
  • Blueprint: Visual styles for each feature are evaluated in Blueprints before being passed to the material.

This step explains how to style the tileset in the Material itself. Each method has its own advantages and tradeoffs that will be discussed in the upcoming sections; feel free to pick the one that makes the most sense for your use case.

Here, the New York City buildings will be styled based on their height and year of construction.

1Select the tileset you just added. In the Details panel, click Add and attach a CesiumFeaturesMetadata component to the tileset.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. The Details panel with both the Add button and the CesiumFeaturesMetadata component highlighted.

With the component selected, the Details panel will display three buttons at the top. For now, focus on the first two buttons, Add Properties and Generate Material.

Cesium for Unreal: The Details panel with the Add Properties and Generate Material buttons highlighted.

2In the Editor Viewport, move the camera so that a substantial portion of your tileset is visible. Then, click the Add Properties under the CesiumFeaturesMetadata component’s Details.

This will open a new window to view the available features and metadata information on all currently visible tiles. If you are using New York City 3D Buildings, the window will appear as shown below:

Cesium for Unreal: Metadata properties listed for the New York City 3D Buildings dataset.
Information

If one or more properties are missing, you can adjust the Editor camera to view a different portion of the tileset and click Refresh for Current View.

The glTF Features section lists any feature ID sets available through the EXT_mesh_features extensions in the tileset. Each feature ID set describes a defined set of features in the primitive’s mesh.

Information

A feature can be thought of as a distinguishable part of a larger model. Features are indicated by numerical values called feature IDs, and components with the same feature ID belong to the same feature. In EXT_mesh_features, feature IDs can be assigned to vertices in a mesh or texels in a texture via different methods. A feature ID set refers to a set of feature ID values that are all assigned through the same method.

The glTF Metadata section displays any metadata that exists on the EXT_structural_metadata across models in the tileset. Properties are grouped by Property Tables and Property Textures, which are just different ways of storing sets of metadata values in the model.


The New York City 3D Buildings dataset contains one feature ID set, which itself is associated with the one property table. Each feature ID set and metadata property must be explicitly “registered” with the CesiumFeaturesMetadata component so it can be used for styling. This selective system prevents performance from degrading for tilesets with numerous metadata properties.

3First, register the feature ID set with the component by clicking the add icon to the right of Material.

Cesium for Unreal: register feature ID set

This will add it under the component’s Primitive Features dropdown in the Details panel.

Cesium for Unreal primitive features

Once registered, the add icon will change to a pencil, indicating that any changes made will overwrite the existing entry for the feature ID set. This allows modifications to the registered features and metadata without having to manually edit them in the Details panel. Likewise, the remove icon will remove the feature ID set from the component.

Cesium for Unreal overwrite and remove features

4Now that the feature ID set has been registered, it’s time to add properties from its associated property table.

If you’re using New York City 3D Buildings, properties will appear under the table labeled “default”. Each property is a dropdown that can be expanded to inspect the instances of it across the tileset. For example, the Longitude property is described as a 64-bit floating precision scalar (aka a double):

Cesium for Unreal property details

For this tutorial, let’s add the Height property to the material. Click on Height to expand the dropdown, then locate the three options to the right of the property entry.

Cesium for Unreal height encoding details

This determines how the property is encoded, i.e., how its values are converted so they can be passed to the Unreal Engine material through texture parameters. The leftmost dropdown shows the method used to encode the property, which defaults to Coerce for numeric properties.

Cesium for Unreal height conversion options

With Coerce, the property will attempt to cast its values to the GPU-compatible type specified by the two other dropdowns. In this case, the 64-bit floating precision values will be downcast to the closest 32-bit precision floats, since there is no universal support for double-precision textures.

Cesium for Unreal: height coerce options

These three fields are referred to as the Encoding Details of the property. The default configuration works best for this property, so leave it as-is. Click the add icon on the right to register it with the component. Once registered, it will appear under the Model Metadata dropdown under the component’s Details panel.

Cesium for Unreal property table property view

If desired, you can verify that the Property Details and Encoding Details of the Height property match those below.

Cesium for Unreal hieght property details

The property and encoding details of “Height” shown side by side.

Information

Property Details and Encoding Details are explained more in depth in the Features and Metadata Technical Reference.

5Now let’s register the Year property with the component. You may have noticed multiple entries with different types under the Year property:

Cesium for Unreal Year Property Details

When tiles across the tileset define the same property with different types, the window will show all discovered instances under the same property dropdown. This occurs most often for older 3D Tiles datasets, since tiles are upgraded on-the-fly and assigned best-fitting types for their given set of property values. In New York City 3D Buildings, some tiles do not contain construction year data, so their Year property will have been converted to a String type with null values.

This view allows you to make informed decisions about how the data is interpreted. Here, it makes the most sense to treat the property as an Int16 Scalar and coerce the values to Float. Register this instance of the property by clicking its add icon.

Cesium for Unreal register year
Information

Cesium for Unreal will log warnings when it encounters the other property types, but otherwise still attempts to coerce their values. Note that Coerce can be used with any property type—even strings—to parse numerical values from the data where possible.

Back in the Details panel, click Generate Material to create a material layer containing the listed features and metadata properties. Then, double-click the Target Material Layer’s icon. This will open an editor window for the layer so you can begin to build it out.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Click Generate Material to create a material layer corresponding to the listed features and metadata properties.

You should see nodes in the material layer that will have been generated by the CesiumFeaturesMetadata component.

Cesium for Unreal generated material nodes

Starting from the leftmost nodes, this node graph can be interpreted as follows:

  • This material layer uses an attribute feature ID set called _FEATURE_ID_0. 
  • Feature IDs are retrieved from the aforementioned set via CesiumGetFeatureIdsFromAttribute.
  • The resulting feature ID is passed into Get Property Values from default, a custom function that will sample the textures containing encoded metadata values. This corresponds to the property table named default on the CesiumFeaturesMetadata component.
  • The metadata values associated with that feature ID will be output to the Height and Year pins. These are the properties that you kept under the property table on the component.
  • Feature ID sets may have an optional “null feature ID” value, which indicates that some part of the model is not associated with a feature. The _FEATURE_ID_0_NULL_ID node was generated to anticipate this case.
  • The If node allows you to implement fallback behavior whenever a null feature ID is encountered. The New York City 3D Buildings dataset does not have one, but in general, you can assign logic to the A==B node to anticipate this case, such as a default color.

In general, feature IDs are retrieved from the model before their corresponding metadata can be found. Any property table properties that you add to the CesiumFeaturesMetadata component will be made available as output pins on the auto-generated Get Property Values node.

Information

Be careful not to edit the auto-generated nodes or their connections to each other. Any modifications may prevent the feature IDs and metadata from being properly resolved in the material.

6Now you can connect the property outputs to the material logic you want to apply. For example, if you’re using the New York City 3D Buildings dataset, you can color the buildings with respect to their Height in meters and their Year of construction. (Feel free to copy the nodes below and paste them into your material graph.)

Cesium for Unreal height year style logic

Each property is normalized within a range specified in the RemapValueRangeNormalized nodes, between the given minimum and maximum values. The output will be a three-dimensional color vector assembled by MakeFloat3. The Height of each building is used in the red color channel (X), and the Year of construction is used for green (Y). The blue color channel (Z) is set to a constant value of 1.

This material layer styles the buildings based on where their values fall in the entire range, resulting in a gradient appearance. Try setting your own values in the Input Low / High pins on the RemapValueRangeNormalized nodes to see how these changes affect the material.

7To see the metadata material layer in action, it must be added to a material instance. Check out the Editing Tileset Materials tutorial if you need help with creating custom materials. You can also download a copy of the Unreal materials here for reference.

Create a custom tileset material by duplicating the MI_CesiumThreeOverlaysAndClipping material included with the plugin. Then, in the material editor, in the Layer Parameters tab, add a material layer to your custom material by clicking the plus icon. Label it FeaturesMetadata.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Add a material layer to your custom material by clicking the plus icon. Label it FeaturesMetadata.
Information

You must label this material layer with the FeaturesMetadata label. This step is not optional. Without it, the plugin cannot set the required parameters on your material layer.

8Expand the new FeaturesMetadata layer. Select your material layer under Layer Asset. Finally, select an appropriate Blend Asset for your styling logic. This tutorial uses the MLB_CesiumAlphaBlendBaseColor blend asset included in the Cesium for Unreal plugin.

Your material setup should resemble the image below:

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Then, select your material layer under Layer Asset. Finally, select a Blend Asset that is appropriate for your styling logic.

9Go to your tileset’s Details panel. Under the Cesium > Rendering category, set the Material property to your own custom material.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Go to your tileset’s Details panel. Under the Cesium > Rendering category, set the Material property to your own custom material.

Once you add the material to your tileset, click Refresh Tileset in the Details panel to make the tileset pick up changes from its CesiumFeaturesMetadata component. After the tileset reloads, you can observe how the material layer transforms your dataset!

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Once you add the material to your tileset, the tileset should automatically refresh, but you can also click Refresh Tileset to force the tileset to reload.

Shorter buildings appear more blue, while taller buildings are more red. The saturation of each color also varies depending on the building’s year of construction. Tall buildings that were constructed recently appear almost white. Conversely, deeper colors are indicative of shorter buildings constructed in a much earlier year.

Styling may expose areas with missing metadata, too. For New York City 3D Buildings, few buildings in Manhattan were built prior to 1700, the low range input used by the material. Thus, bright pink or deep blue buildings are more likely to have missing values or a nonsensical value of 0 as their Year.

10If you’d like to add other metadata properties to the CesiumFeaturesMetadata component, use the Add Properties window to make modifications. To update the material layer with your changes, make sure the Target Material Layer is set to the same layer asset, then click Generate Material again.

Information

Regenerating a material layer will not remove nodes that you have manually added to the material graph. However, if you remove properties that are actively being used in the material, any nodes that are connected to those properties will be disconnected.

If you added new feature ID sets or metadata properties, you will have to also click Refresh Tileset. Feature ID sets and metadata values are only encoded as tiles load and cannot be retroactively added. Thus, refreshing the tileset is necessary for new property values to be passed to the material layer.

Try experimenting with the material on your own. Some ideas to get you started:

  • What happens if you change the range limits or swap the color channels?
  • How would you style the buildings by their latitude and longitude?
  • How would you highlight only buildings constructed after 2000?
  • Try making a material that styles buildings based only on feature ID. For example, use two different colors to distinguish buildings with odd versus even feature IDs.

3Style with features and metadata in Blueprints

Material styling, as explained in the previous step, works well for numeric properties that can be encoded to textures on the GPU. However, this is not reasonably possible for all property types.

For example, the New York City 3D Buildings dataset contains a string property called Majority_Ownership_Type. All possible values for the property are listed in the description of the asset in the Cesium ion Assets window:

Cesium for Unreal New York City buildings description

There is no way to reasonably convert these values to numbers, which makes the property incompatible with Material styling. However, Blueprint styling allows you to take advantage of these values and compute visual properties for the features in a Blueprint graph. This step will walk you through how to create a Blueprint class that does that.

1In the Details panel of the CesiumFeaturesMetadata component, find Blueprint Style Class. This property lets you specify a Blueprint class to run on the features in the tileset.

The Blueprint class must implement an interface called Cesium3DTilesStylingProvider in order to work. The quickest way to set this up is to click the plus icon next to the property. This opens a new window to create, name, and save a new Blueprint class that already inherits from the Cesium3DTilesStylingProvider interface.

Cesium for Unreal create Blueprint style class

Give your class a descriptive name. Then, select the folder in which you want to save your Blueprint and hit Save.

Cesium for Unreal save Blueprint

Once saved, a new window will open so you can edit the class.

If you want to use an existing Blueprint class, click the Class Settings button in the Blueprint editor, then find the Implemented Interfaces in the Details panel. From there, you can search and add Cesium3DTilesStylingProvider.

Cesium for Unreal existing class interface

Once the class has been created, look to the left sidebar of the Blueprint editor. You should see a function named EvaluateStyle listed under Interfaces, which confirms that the class properly implements the interface.

Cesium for Unreal Blueprints interface sidebar

2Click on EvaluateStyle to open the function graph. At first, there will only be two nodes representing when the function begins and ends.

Cesium for Unreal evaluate style nodes

EvaluateStyle is called for every single feature ID within a feature ID set. The Property Table parameter passes the property table that the feature ID set is associated with, if any. The feature ID itself can be accessed from the Feature Id parameter.

On the Return Node, the Return Value expects a Cesium3DTilesStyle structure, which will be explained in a bit. Click and drag from the Return Value pin to open the Blueprint search menu, then find and add Make Cesium 3DTiles Style.

Cesium for Unreal make style struct

This node shows the properties used to build the style. Show is a boolean toggle, indicating whether the feature should be visible at all. Color is an Unreal FColor (8-bit RGBA) that gets evaluated for the feature. These properties mirror the API used for Styling and Filtering 3D Tiles in CesiumJS.

Now you can add Blueprint logic to act on the properties within the Property Table. For this tutorial, the Blueprint will be set up to access the Majority_Ownership_Type property from New York City 3D Buildings.

First, drag the Return Node and Make Cesium 3DTiles Style nodes off to the right to make space for the Blueprint. Then, under the EvaluateStyle node, click and drag out from the Property Table pin. Search for the Find Property node and add it to the graph.

Cesium for Unreal Blueprint find property

Put Majority_Ownership_Type as the Property Name. Then, from the node’s Return Value, find and add the Get String function shown below.

Cesium for Unreal get string

Finally, connect the Feature Id pin under EvaluateStyle to the Feature ID pin under Get String.

Cesium for Unreal get string connected

3Now you can use the string values from the property to style the features. Let’s make a simple style that only shows buildings with Individual ownership and highlights them green.

From the Return Value pin of Get String, drag and add an Equal Exactly (String) node.  

Cesium for Unreal String Equal Exactly

4Set the other string to Individual, then drag the boolean output into the Show pin of Make Cesium 3DTiles Style. Finally, drag from the Color pin and add a Make Color node, setting it to an opaque green.

Cesium for Unreal show only individual as green

5Save and compile your Blueprint. Now you can set up the CesiumFeaturesMetadata component to use it for styling!

First, open the Add Properties window on the component. Find the feature ID set that you previously added and look for the dropdown that is set to Material. Click the dropdown and switch the option to Blueprint. Then, click the pencil icon to apply the change.

Cesium for Unreal Blueprint options

This changes what mode you are using to style the features in the set. When set to Blueprint, the component will create an instance of its Blueprint Style Class, then run the EvaluateStyle function on the features of tiles as they load. In other words, this executes the Blueprint on the feature IDs in the tileset to evaluate how they should be shown and colored.

With Blueprint styling, there is no need to encode metadata properties for direct use in the material. You can clear the properties you previously added by clicking the minus icons to the right of their entries. Alternatively, look for the Property Tables list under the Details panel and click the trash icon to clear all items.

Cesium for Unreal remove properties
Cesium for Unreal clear property table

6Finally, let’s create a material layer that consumes the results of EvaluateStyle and applies them to the features.

Under the Details of the CesiumFeaturesMetadata component, clear the Target Material Layer property by pressing the arrow to the right of the asset.

Cesium for Unreal clear target material layer

Then, click Generate Material. This causes the component to create a new material layer when you click Generate Material, rather than overwriting one that is already specified.

The new material layer will look familiar, but its middle nodes will be different:

Cesium for Unreal Blueprint styling nodes

Instead of a Get Property Values node, there is now a Get Blueprint Style node that retrieves the Show and Color properties for the feature. These outputs can be plugged directly into SetMaterialAttributes such that:

  • Show is connected to Opacity Mask
  • Color is connected to Base Color
  • The fourth component of Color is connected to Opacity (requires the material instance to be Translucent to work)

Feel free to copy and paste the following nodes into your material graph:

Otherwise, you can manually add these attributes by selecting the SetMaterialAttributes node, then adding them under its Details. Then, connect the pins as shown.

Cesium for Unreal set material attributes
Cesium for Unreal connecting the set material attributes

If your dataset contains a null feature ID, you can incorporate fallback behavior for it using multiple If nodes, as shown:

Cesium for Unreal set material attributes with null feature ID

The material graph modified to account for a possible null feature ID. Both the Show and Color outputs are connected to If nodes at the A > B and A < B pins. The A==B pins are connected to sensible fallback values.

Create a new material instance and add this material layer under the FeaturesMetadata label. For Blend Asset, select MLB_CesiumMultiplyBaseColorAlpha, which is set up to correctly handle the Opacity Mask and Opacity.

A copy of the material can be downloaded here for reference.

Cesium for Unreal Blueprint material layer

Then, assign this material instance to apply the style to the tileset. (If nothing happens, click Refresh Tileset to pick up the changes.)

New York City buildings in Cesium for Unreal, with and without styling

Left: New York City 3D Buildings without styling. Right: New York City 3D Buildings, filtered for buildings with majority individual ownership.

Under the hood, the CesiumFeaturesMetadata component has created an instance of the Blueprint Style Class so it can call EvaluateStyle on tiles as they load. This results in much of the Manhattan Skyline being hidden to reveal the smaller, individually-owned buildings in the area, highlighted in green.

7Try experimenting with Blueprint styling on your own! Any changes to the Blueprint can be applied by clicking Refresh Style on the CesiumFeaturesMetadata component.

Cesium for Unreal refresh style

With Blueprints, you can also modify variables or call functions on the style instance at runtime. For example, you can create a list of Majority_Ownership_Type values on the tileset and let the user toggle their visibility, either through keyboard input or a clickable user interface. In your Blueprint Style Class, you can add a set of strings called ShownValues and check whether the value is present:

Then in your Level Blueprint, you can get the style instance from the CesiumFeaturesMetadata component and update ShownValues at runtime. For example, you can use a key to toggle visibility of one of the ownership types in the dataset.

Cesium for Unreal interactive Blueprint styling

Top: Blueprint logic in EvaluateStyle that sets visibility depending on if the value is present in the ShownValues set. Bottom: Logic in the Level Blueprint that toggles the visibility of features with Individual ownership on the style.

These capabilities allow you to implement flexible styling of your 3D data with plenty of room for user interactivity.

Information

While material graphs run on the render thread (GPU), Blueprints must run synchronously on the main game thread (CPU). Be mindful of performance implications when loading or refreshing the Blueprint style on larger tilesets.

4Set up picking with the mouse

While styling is a useful tool for visualizing information across the dataset, there are many cases where querying metadata from a single feature is just as valuable. Steps 4 and 5 will walk you through how to build the Level Blueprint so you can click on a feature in your dataset, retrieve its associated metadata, and print the values to the screen.

Step 4 sets up user interactivity with the mouse, while Step 5 shows how to actually access the metadata in Blueprints. If you just want to see the final Blueprint or reference it as you follow the tutorial, skip to the end of Step 5.

1Under the Blueprints menu, select Open Level Blueprint.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Under the Blueprints menu, select Open Level Blueprint.

2Right-click in an empty space on the graph to bring up a Blueprint search menu. Type “Left Mouse Button” in the search bar, and click Left Mouse Button in the results to create a node for the corresponding input.

Cesium for Unreal left mouse button

3Click and drag the DynamicPawn actor from the World Outliner to the Level Blueprint graph. This will create a reference to your DynamicPawn in the Level Blueprint.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. The Left Mouse Button and Dynamic Pawn nodes created in the previous two steps.

The Left Mouse Button and Dynamic Pawn nodes created in the previous two steps.

4Click on the blue pin of DynamicPawn and drag it out to an empty spot on the graph. Release the mouse to bring up another menu. Search for and create a Get Camera View node.

5Connect the Pressed pin from Left Mouse Button to the execution pin on Get Camera View. Now your Blueprint can obtain the camera view from the Dynamic Pawn whenever the left mouse button is pressed.

Cesium for Unreal Blueprint get camera view

6From the right execution pin of Get Camera View, drag and release the mouse. Then, search “Line Trace By Channel” in the menu to create a Line Trace By Channel node.

7For our purposes, the line trace should start from the middle of the camera and go out into the environment. From the blue Desired View pin of Get Camera View, drag and release the mouse again, then select Break MinimalViewInfo from the context menu.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. From the blue Desired View pin of Get Camera View, drag and release the mouse again, then select Break MinimalViewInfo from the context menu.

Connect the yellow Location pin of Break MinimalViewInfo directly to the Start pin of LineTraceByChannel.

8The End location should extend out from the Start position into the world. To help us compute this, create a Get Rotation X Vector node from the Rotation pin of Break MinimalViewInfo. Then, create a Multiply operator node.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Create a Get Rotation X Vector node from the Rotation pin of Break MinimalViewInfo. Then, create a Multiply operator node.

Right-click the bottom-left pin of the Multiply node to convert it to a Float (double precision).

Cesium for Unreal convert pin

Then, set the B value on the Multiply node to 500,000. This will scale the RotationXVector such that the line trace is 500,000 units long.


Finally, create an Add operator node to add the result of the Multiply node to the original Location. The level Blueprint should now look like this:

Cesium for Unreal Blueprint  complete line trace

You can adjust the multiplier of the Rotation X Vector depending on the context of your application.

9Return to the LineTraceByChannel node. Change the Draw Debug Type to For Duration.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Return to the LineTraceByChannel node. Change the Draw Debug Type to For Duration.

Now, you’ll be able to see your line traces in the world as you click. If you wish, you can also change Trace Color and Trace Hit Color on the node. If you don’t see these options, click the arrow at the bottom of Line Trace By Channel to expand the pins.

10Save and compile the Blueprint. Now you should have a Blueprint that traces a line from the center of your screen that can collide with the world. You can test it out by playing your level in the editor, then left-clicking to cast a ray from the center of your screen.

Cesium for Unreal line trace debug

Right now, nothing happens when the line trace hits a building, but you can build upon this interaction by following the next step.

5Use Blueprints to access per-feature metadata

Once you have a working line trace mechanism, you can check if the line trace intersects a feature in your tileset. If so, you can identify that feature and retrieve any metadata that is associated with it.

In Cesium for Unreal, metadata can be conveniently retrieved from a line trace hit with a single Blueprint. However, there are many other Blueprint nodes that can accomplish the same functionality when used together. If you need more control over your metadata picking logic, check out the Features and Metadata Technical Reference for the full Blueprints API.

1In the Level Blueprint, find the Out Hit pin of Line Trace By Channel. From it, create a Get Property Table Values From Hit node.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. From the Out Hit pin of Line Trace By Channel, create a Get Property Table Values From Hit node.

Whenever a line trace successfully hits a model in the scene, it outputs additional information from the intersection via Out Hit. The Get Property Table Values from Hit Blueprint can take this hit information, determine which feature was selected, and then retrieve its metadata on the user’s behalf.

You may have noticed that this Blueprint provides a numeric parameter, Feature ID Set Index. This is the index of the target feature ID set with respect to the array of sets in the EXT_mesh_features extension. The New York City 3D Buildings dataset only contains one feature ID set, so for this tutorial, keep the Feature ID Set Index set to 0.

2From the Return Value pin on the Blueprint you just added, find and create a Get Values As Strings node.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. From the Return Value pin on the Blueprint you just added, find and create a Get Values As Strings node.

Metadata values from Get Property Table Values from Hit are provided in a Blueprint Map, where each value is mapped to the name of its corresponding metadata property. Values are stored in instances of the CesiumMetadataValue struct, which can be used to apply the same functionality to multiple metadata values, regardless of their underlying type.

The Get Values As Strings Blueprint converts each CesiumMetadataValue in the input map to its representation as a string. It is still mapped by property name, but now the map holds entirely string values.

3From the Return Value of Get Values As Strings, create a Keys node, which returns an array of every string key in the map. Then, create a For Each Loop node to loop through that array. Make sure to connect the execution pins of these new nodes.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. From the Return Value of Get Values As Strings, create a Keys node, which returns an array of every string key in the map. Then, create a For Each Loop node to loop through that array. Make sure to connect the execution pins of these new nodes.

4To view the metadata in an easily readable format, this tutorial will display the values by joining the string keys of the map—the property names—to their values, with a colon and space in between.

First, right-click and search “Append”, and locate the String > Append node in the context menu. Create an instance of this node; then drag the Array Element pin from For Each Loop to the A pin of the Append node.

In the B pin, type a colon and a space (“: “). Click Add pin on the Append node to add a third input.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. To view the metadata in an easily readable format, this tutorial will display the values by joining the string keys of the map—the property names—to their values, with a colon and space in between.

5From the output of Get Values As Strings, create a Find node. Connect the Array Element from For Each Loop to the empty pin on the Find node. Finally, connect the output of Find to the C pin of Append.

Now, all you have to do is print the result. Create a Print String node that connects to the Loop Body of For Each Loop. Finally, connect the Return Value of Append to the In String pin.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. Print the result.

You can view the final Level Blueprint in its entirety below.

This is an interactive node graph. Right-click and drag to pan around the graph. To zoom in or out, press control/command and scroll with your mouse. You can also copy and paste nodes from this graph directly into your own Blueprint.

6Be sure to compile and save your Blueprint. Then, play your level in the Editor and test it out! When you select a building with the mouse, you should see the metadata properties associated with that feature in the top left corner.

Cesium for Unreal tutorial: Visualize Mesh Features and Metadata. When you select a building with the mouse, you should see the metadata properties associated with that feature in the top left corner.
Information

Depending on your dataset, some models may be missing metadata values. You may not see a value for a printed property. If you’d like, you can modify the Blueprint to exclude the property if its value is empty.

You can edit the Print String node to change the color of the text or adjust the duration that it stays on screen.

Now that you've learned to access mesh features and metadata in 3D Tiles, use them however you wish in your application! In Cesium for Unreal Samples, Level 6 contains an example UMG widget that neatly displays these properties on the screen. You can use and modify that widget for your projects by downloading the Cesium for Unreal Samples.

Next steps

For more information on Cesium for Unreal’s features and metadata API, check out the Features and Metadata Technical Reference.

How are you using mesh features or metadata in your Cesium for Unreal projects? Share your creations with us on X and LinkedIn!

Further Reading:

Content and code examples at cesium.com/learn are available under the Apache 2.0 license. You can use the code examples in your commercial or non-commercial applications.