Getting wrong type of object

The think I want to do is to find the mesh and remove it from scene.

But the problem that occured is after getting the object by id I get Group instead of MeshStandardMaterial and it causes a crash because of not having geometry and meterial to delete.

I am begginer with three js so I would appreciate any type of help.

console.log(decalMaterial); //MeshStandardMaterial
let objs = state.scene.getObjectsByProperty('id',;
console.log(objs); //Group

objs[0].geometry.dispose(); //Cannot read properties of undefined (reading 'dispose')

I’m not confident about your setup (what objects you have and what materials are used), but this line looks suspicious:

let objs = state.scene.getObjectsByProperty('id',;

Method getObjectsByProperty is used to find objects with a given property, but this code provides the id of material. Maybe your matches by accident the id of a group object?

If you want to find and object with specific material, maybe it is better to use the method traverse, scan all objects and pick the ones with this material.

I solved this by adding name property to every added decal. So I would get object by property and target name with the unique milliseconds. But thanks you for your answer