# Selection Issue with GLB Model Organized by Tileset.json

**URL:** <https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847>\
**Category:** CesiumJS\
**Created:** [May 2, 2024, 8:59am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847 "2024-05-02T08:59:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HerculesJL](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/herculesjl/32/23304_2.png) [@HerculesJL](https://community.cesium.com/u/HerculesJL)\
**Post date:** [May 2, 2024, 8:59am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/1 "2024-05-02T08:59:44Z")

</div>

Hello！I can use the following code to highlight a glb model that contains multiple individual buildings. This will highlight the entire glb model, as shown in the picture. However, I want to highlight only a part of this glb model. The glb model is a combination of multiple OBJ files imported into Blender and exported. How can I achieve this? By the way, how can I implement clicking on a model and displaying a property box? Should I add extra information during the model construction?

```auto
Cesium.Ion.defaultAccessToken = ***
       
      
        var viewer = new Cesium.Viewer('cesiumContainer',{
            infoBox: true, 
        });
       
    
        var tileset;
        async function loadTileset() {
           
            tileset = await Cesium.Cesium3DTileset.fromUrl('./root_0330_2_glb_notileset/root/tileset.json',{allowPicking: true});
            tileset.preferFlatPrimitives = true;
            viewer.scene.primitives.add(tileset);
            
       
        }

        loadTileset().then(() => {
            console.log('Tileset success');
            viewer.zoomTo(tileset);
        }).catch((error) => {
            console.error('Tileset failed', error);
        });

        var highlighted = {
            feature: undefined,
            originalColor: new Cesium.Color()
        };

        viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(
            movement
            ) {
          if (Cesium.defined(highlighted.feature)) {
            const content = highlighted.feature.content;
            if (Cesium.defined(content) && content instanceof Cesium.Model3DTileContent) {
        
                console.log('get origin color');
                const style = new Cesium.Cesium3DTileStyle({
                    color: "color('rgba(255,255,255,1)')"
          });
          content.applyStyle(style);
            
            }
            highlighted.feature = undefined;
        }
        const pickedObject = viewer.scene.pick(movement.position);
        console.log('pickedObject:');
        console.log(pickedObject);
  
        if (Cesium.defined(pickedObject)) {
          highlighted.feature = pickedObject;
          const content = pickedObject.content;
          if (!Cesium.defined(content)) {
            return;
          }
          if (!(content instanceof Cesium.Model3DTileContent)) {
            return;
          }
        
          const style = new Cesium.Cesium3DTileStyle({
            color: "color('yellow')"
          });
          content.applyStyle(style);
          //return;
        }

      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

```

 ![image](https://global.discourse-cdn.com/cesium/original/3X/9/3/93ce30f90f87705adec6eaddf830818d786c2b70.jpeg)

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [May 2, 2024, 4:05pm UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/2 "2024-05-02T16:05:30Z")

</div>

(Just a short backlink to this issue: [Selection Issue with GLB Model Organized by Tileset.json · Issue #760 · CesiumGS/3d-tiles · GitHub](https://github.com/CesiumGS/3d-tiles/issues/760) )

There are different ways of how this could be accomplished. The goal is, roughly speaking, to know that a certain set of vertices/triangles “belong together” or “belong to the same object”. And this information has to be encoded in one form or another. And on a very low technical level, this is the goal of the [`EXT_mesh_features`](https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features) extension. Someone wrote a short summary about [how such IDs can be assigned in Blender](https://community.cesium.com/t/gltf2-0-in-ue5-2-metadata-ext-structural-metadata-ext-mesh-features/26873/8) a while ago, but I have to admit that I did not yet follow that thoroughly. And in any case, it will involve a few manual steps, and you’ll have to process these feature IDs accordingly, on the rendering side (i.e. in CesiumJS).

Referring to your case: Combining multiple OBJs into a single GLB will raise this question about how to distinguish the formerly individual buildings. And even though this is _possible_, it will involve some low-level technical efforts.

So one should probably ask: Why do you combine multiple OBJs into a single GLB?

There _can_ be good reasons for that. It might be that you want to share textures, or use instancing, or perform some form of compression, or reduce the number of network requests.

But unless there is a _strong_ reason to _combine_ these OBJs, you could consider to just export _each_ OBJ as its own GLB. This way, distinguishing the buildings would be relatively easy - that’s what’s already done in the sandcastle that you posted.

---

<div class="post-metadata">

**Author:** ![m.kwiatkowski](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/m.kwiatkowski/32/14000_2.png) [@m.kwiatkowski](https://community.cesium.com/u/m.kwiatkowski)\
**Post date:** [May 6, 2024, 6:52am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/3 "2024-05-06T06:52:28Z")

</div>

1. You can only highlight a specific triangle (model) if you have attributes table assigned to it.
2. attribute numbers should start from 0.
3. You can add the attribute table in blender. Step by step:

- create plane shift+A choose plane:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/c/c/ccc210b6f4ef8559fdd7fea5ed1984b898a326a4.png)
- add attribute table with name \_FEATURE\_ID\_0:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/9/f/9f770b8679bbc33113778887c631cf731ed16ee0.png)
- add name \_FEATURE\_ID\_0  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/7/7/77fac0ef13c9a572fc7c4c25892af74fb786e948.png)
- automatic you add 0 to all vertex:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/8/d/8d925f5509a718f39e155bd75639b89ddc1a85e6.png)
- In edit mode, add next plane, and use G to move in other place:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/d/0/d0556ab1cbead34c98c8e06797d3781febd9be53.jpeg)
- Select all new vertex in edit mode:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/3/e/3ec352bce26d4c7000dd28e4d6c74f30af976a3d.png)
- and click set Attribute in mesh panel:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/9/5/95f774d57d7857837bcc2544de320559d28cf602.png)
- add number 1 to tabel  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/e/1/e1a8f5d0183f784358390bf7a3bf4ee6defa2ae5.png)  
Now have 1 model with attribute table!

1. Export model:

- click export:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/2/4/24b6c08cb59504541ea17e1d803a2cc4c6791b43.png)
- select attribute box:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/d/c/dc133ca223bafa94a9c5ea13efb94ae596e97b54.png)  
Now have model with attribute table.

1. You can attach any random metadata to the attribute table and get random textur in UE. My buildings use this method.  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/4/5/4579b10bcded6d299305455648ef943c79d51470.jpeg)

---

<div class="post-metadata">

**Author:** ![HerculesJL](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/herculesjl/32/23304_2.png) [@HerculesJL](https://community.cesium.com/u/HerculesJL)\
**Post date:** [May 6, 2024, 8:03am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/4 "2024-05-06T08:03:25Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [May 6, 2024, 11:40am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/5 "2024-05-06T11:40:49Z")

</div>

@m.kwiatkowski Thanks again for the description! I already mentioned in the previous thread (that I linked to, and where you described this process) that we could consider to write this up in form of a small tutorial. It may have to include _some_ additional information. (For example: I think that it will be necessary to edit or post-process the glTF, to actually include the _extension_, and not only the additional attribute). I’ll try to keep this on the radar. If this question comes up more frequently, then it would probably be helpful to summarize that in one place.

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [May 6, 2024, 12:05pm UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/6 "2024-05-06T12:05:13Z")

</div>

An aside: I just opened [Consider a function to automatically assign IDs to mesh primitives · Issue #125 · CesiumGS/3d-tiles-tools · GitHub](https://github.com/CesiumGS/3d-tiles-tools/issues/125) , because I _think_ that this could already go a long way here: I assume that Blender will export all these meshes as actual, individual `mesh` objects within glTF, so automatically assigning distinct IDs could be enough for many use-cases.

---

<div class="post-metadata">

**Author:** ![m.kwiatkowski](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/m.kwiatkowski/32/14000_2.png) [@m.kwiatkowski](https://community.cesium.com/u/m.kwiatkowski)\
**Post date:** [May 7, 2024, 5:56am UTC](https://community.cesium.com/t/selection-issue-with-glb-model-organized-by-tileset-json/31847/7 "2024-05-07T05:56:25Z")

</div>

1. Unfortunately, Blender does not have tools for adding metadata. In blender you can only add an attribute table, but the metadata must be added in notepad++ or injected with another tool.
2. I wrote my own script for testing and I have currently generated the entire Poland with random metadata. My buldings have a faw metadata heght, material and type bulding.  
My Warsaw Poland in UE5:  
 ![image](https://global.discourse-cdn.com/cesium/original/3X/d/d/dd9dd0b55e5769b390bc19e12d001e41d47d40e1.jpeg)

You can use geojson or OSM to generate them. Geojson has no metadata, but is already properly set to WGS84. OSM has metadata but no height above the ellipsoid. Heights can be retrieved and assigned from TIFF files, but need GIS tool, There is no quick method 😛 . .
