Hide specific object from loaded model

I want to load a human muscle model with gltf loader and if user clicks on specific muscle like upper muscles for example the whole model except for upper muscles disappears.
can i do something like that or do i need a model for each muscle?

Get a reference to the clicked muscle or object, traverse the GLTF model, and hide all other objects except the clicked one.

To reset, traverse the GLTF model and restore the visibility of all objects.

// Load the model
const GLTFModel = await ...;

// Set the raycaster logic to get the clicked object
const clickedObject = ...;

// Hide all but the clicked object
GLTFModel.traverse((object) => {
	if(object !== clickedObject) object.visible = false;
})

// ... Reset
GLTFModel.traverse((object) => object.visible = true);
2 Likes

Thx I’ll try it

1 Like