Error in obtaining indices for gltf's mesh

This mesh calls the getTotalIndices function to get 0.

Is it unindexed? mesh.isUnIndexed should confirm.

2 Likes

Yes, that’s the case here.

1 Like

I want to get the number of faces of the mesh now. Since getTotalIndices() is 0, can I use getTotalVertice()/3? So the number of statistical surfaces of the inspector needs to be modified

I believe this question could be easily answered by yourself :rofl:

Maybe you could try: mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind).length / 3

EDIT:
Sorry, I missread your question w/o glasses LOL

I’ve read: Since getTotalIndices() is 0, can I use getTotalIndices()/3 and since getTotalIndices returns 0 you couldn’t use it. That’s why the :rofl: smiley…

SO yes, you can use getTotalVertices()

Yes, I think so too.

Can you help with PR repair for this :grin:

I am not sure if it is a good idea to change it here. Because we don’t have a getActiveFaces() function available only getTotalFaces() and the inspector displays the active count. getTotalFaces() returns inactive faces too.

So this is not a simple PR changing only one function and we should discuss this with the team. Let’s wait until Monday.

Yes, I think we need to traverse scene.meshs.
Okay, I’ll wait

1 Like

Yeah I’m not super keen on it honestly. Why not adding your own extension to the inspector?

Adding more code to the scene will simply bloat it whereas that data can be found with existing code.

At the very least, I would be ok to have the info displayed in the inspector BUT not added to the scene

Yes, it’s better to fix it in the inspector. Then this method can be used elsewhere for reference.

Roughly speaking, it is:

let vexterCount = 0;
let meshs = scene.getActiveMeshes();
meshs.forEach(itemMesh=>{
    if(itemMesh.isUnIndexed ){
        vexterCount += itemMesh.getTotalVertices();
    }else{
        vexterCount += itemMesh.getTotalIndices();
    }
});
let faces = vexterCount / 3;  //Obtain the number of vertices

Can replace scene.getActiveIndices()/3

I would say in addition to actually instead of replace.
Wanna do a PR?

I can try

1 Like