Facet Data and .glB files

I am loading a series of .glb files which represent the blood cast in the left ventricle of a heart.

This mesh should not be see though but it has some weird artifacts.

Here is an example of what I’d like the mesh to look like:

You can see the blood cast is ‘solid’.

When I render this in Babylon (you can see in the red circles) There are internal artifacts of the cast which are visible:

Here is the wiremesh view:

You can see the dimensions here.

I think I need to turn on the facet data.

I can access the mesh like so:

var mesh = assetContainers[currentSceneIndex].meshes[i];

but when I do:
console.log("Total number of facets:" + assetContainers[currentSceneIndex].meshes[i].facetNb);
It says there are no facets.
When I do:
I get an error that says the Facet Data is null.

So how do I get the facet data from the .glb file or better yet how do I make this object look solid and not have these weird transparent artifacts in my mesh.


If the objects need to be solid then you need to make sure your glb is not flagging the material as transparent.

Maybe you an share an example of it in the playground?

That is a good idea. I’ll set a repo up to import the meshes.

That being said…I do believe they are not transparent. I loaded them into the sandbox and toggled all the settings to see if I could find a way to turn this off.

My best result was Alpha Blended…but that didn’t remove the artifacts.

This playground shows a similiar problem:


The material in your example is transparent (alpha = 0.9):

And you can see on the torus on the left (with mesh.updateFacetData():wink: that the sorting works :wink:

Here is what it looks like in the sandbox. There’s no change when I set the Alpha value.

what if you set the material alpha mode to Opaque?

No change…
Is there a way to add facet data to the .glb mesh?

yep the same way you add it to any mesh (see your PG)

can you share the mesh in a pg?
Using External Assets In the Playground | Babylon.js Documentation (babylonjs.com)

Yes, would be great because all we have for this mesh is a screenshot and it looks to me like some of your facets are actually overlapping others (which would explain the glitches where the light hits)


Here you go…I made this very simple. It just imports the mesh at the moment. Let me know what I need to fix :smiley:
thank you!!

OK, thanks. Great to have a PG. I cannot have a closer look just now because it’s time for dinner;) (sry, a more urgent matter;)
But to me, this mesh, the way it’s built, has all characteristic to create the glitches.
I’m about 98% sure that the source of your problem is the mesh.

I corrected your initial PG otherwise the mesh wouldn’t have desired material - https://playground.babylonjs.com/#BAHE7U#5

I add my 2% here :slight_smile:

(it also could be that there is some part of needed rendering info is missed after exporting to GLTF). What is the original format of this file and how it is done?

1 Like

Hahaha. Glad to have your 2%:wink: And your 2% are often much worth considering than my 98% when it comes to BJS :mage: However, it would still be related to the mesh/export, correct? And not to a specific BJS setting for rendering. The mesh and/or export would still remain the part to investigate, yes?

Thanks for the edit to the PG.
When I do this:
I get the desired result… I think I just am not getting the mesh correctly. I’ll look at my code and see if I can do something similiar.

1 Like

So I’m still having issues viewing this mesh correctly. If you rotate the mesh around with your mouse you can see as you rotate the mesh suddenly the wall turns transparent and you can see the other side of the mesh.

I made a better PG here: https://playground.babylonjs.com/#BAHE7U#20

for some reason I can’t get the facets to load. I started another thread asking about the type of .glb file I should be rendering as well.

Thanks for all the help so far!

Looks better - https://playground.babylonjs.com/#BAHE7U#21
myMaterial.needDepthPrePass = true;

1 Like

Your mesh has alpha blended enabled because it has some vertex colors with alpha component:

You can set hasVertexAlpha = false to disable alpha blending and have your mesh correctly displayed:


1 Like

These solutions worked! Thank you!!!