How to identify one building in a glTF primitive?

A glTF file contains a number of buildings, how to list all the buildings contain in this glTF primitive? How to pick up one of these while moving your mouse?

I attached my gltf file.

All help is appreciated.
thanks.

MultiBuildingModel.gltf (787 KB)

MultiBuildingModel.gltf (787 KB)

Hi,

If each building is in a separate mesh, Cesium’s pick function returns the mesh that was picked. For example, see this mouse move function.

If the buildings are combined into one mesh, see the approach we use in 3D Tiles.

Patrick

Hi Patrick,

Is it also possible to change color of single building on mouse move event?

Im during a whole day trying to get it. My result - change the color of all materials with the same name…

handler.setInputAction(function (movement) {

var pick = viewer.scene.pick(movement.endPosition);

if (Cesium.defined(pick) && Cesium.defined(pick.node) && Cesium.defined(pick.mesh)) {

console.log('node: ’ + pick.node.name + '. mesh: ’ + pick.mesh.name);

var mesh = pick.mesh;

var mats = mesh.materials;

for (var i = 0; i < mats.length; i++) {

if (mats[i].id == “ID930” || mats[i]._id == “ID930”) {

console.log(mats[i]);

mats[i].setValue(‘diffuse’, Cesium.Cartesian4.fromColor(Cesium.Color.RED));

console.log(mats[i]);

}

}

}

}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

After this all houses which have material ID930 change color… But is there is a way for single one?

Daria

hi,Patrick Cozzi
thank you very much.

my glTF file only contains two kinds of meshes or materials,using your first method I can identify these two of them.

but there are many separate building in fact,as shown in this.

**I want identify these **separate building,eg bld 1,2,3,…

what should I do?

Daria - you are running into issue #2387. A workaround is to author the model so that there is a different material per mesh.

Patrick