How to detect BodyInstance without mesh

On some occasions, we hit a 3D model with missing meshes. So we keep hitting crashes when trying to instance or simply when trying to get a bounding box. I was wondering if there’s was an easy check we could try on node IDs to test whether they are faulty or not.

Same model with getNodeRealBounding()

Hello @guillaume.robichaud,

So there is not a function that directly confirms if a given meshData object is valid (contains geometry).

You can try using a .catch():

hwv.model.getNodeMeshData(nodeId)
    .then(meshData => {
        console.log('Mesh Data:', meshData);
        // Process the meshData
    })
    .catch(error => {
        console.error('Error fetching node mesh data:', error);
    });

Thanks,
Tino

The documentation for getNodeMeshData says it returns a MeshDataCopy which is

A self-contained copy of the data of a single mesh

It feels really inefficient to copy all valid meshes, just to find the faulty ones, especially when the intent is to instance an already loaded part.

Indeed, it can be an expensive operation. I’ll see about creating a feature request to address this.

Thanks,
Tino