(Just a short backlink to this issue: Selection Issue with GLB Model Organized by Tileset.json · Issue #760 · CesiumGS/3d-tiles · GitHub )
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
extension. Someone wrote a short summary about how such IDs can be assigned in Blender 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.