Help importing meshes, models

Can somebody please help me with meshes that are not importing correctly. Below is a link to a package I got from Turbo Squid. It is a set of commercial steel doors and is beautiful. It loads and renders in Blender perfectly but when I try BABYLON.SceneLoader.ImportMesh it loads without error but looks as if there are no materials applied. I have looked at it in the inspector and the materials are there, it just does not import properly and looks incomplete. Gray doors, no materials.

I am new to Babylon and have not been able to create a playground for this because I have nowhere to put the files that they will load properly. The zip file includes the .blend, .obj and .mtl files. I have also tried exporting from Blender in Stl and glTF without success. Nothing loads correctly.

Any help would be greatly appreciated.

This is the code I am using to import the meshes:


function (meshes) {
for(var i = 0; i < meshes.length; i++){

Hi MattS!

When I open the .blend file in Blender, the doors appear grey to me:

Is this how they are supposed to appear?

That is how they look when you load it in Blender yes but the rendered image looks like this:

When I import them into Babylon they look like this:

To me this typically looks like an issue with UVs(UVWs). Models from turbosquid or others are often converted in a weird/unfinished piece of biz manner. You would eventually want to try to optimize the mesh which will eventually reset the UVs or (if the model initially used a weird projection mode and UVs are f***ed), what I usually do is that I make sure my texture uses an appropriate projection mode and next I regen my UVs from there. But it could be something else, I didn’t look at your file (sry). I’m just posting quickly because I have a neighborhood apero awaiting me (lucky me:). Well, I hope this helps, but in any case when you have this sort of issue with importing/exporting meshes, it is always good to check back on this part.

Going to ping @PatrickRyan, who has much more familiarity with 3D file formats :slight_smile:

As @mawa says, models from the internet are often not optimized, normals facing the wrong direction, faces missing etc.

@MattS : In your case, I have to wonder at the textures you are using - a .tga format (see the picture in the post above). Does BJS handle .tga files? Last time I used that format was when I was building things for Second Life.

Normally I use .png or .jpg. I cant find any reference to .tga in the BJS documents.

Stay Safe All, gryff :slight_smile:

Yup we do support some TGA :slight_smile: but would also recommend another format if possible

@MattS, so what is happening is that your file does not contain any of your textures. Even though I would suggest jpg (for color data) and png (for non-color data) images for your textures, also a requirement of glTF, if you have no textures in your file, your export will be wrong. I did look at the UVs and other than some strange combining of meshes like a double door with one door and its hinge combined and the other door and its handle combined with the remaining hinge and handle being separate meshes, I didn’t see anything super odd.

But your material tells the story:

You have textures plugged into roughness, base color, and normal, but those textures are missing from the file. This means that your materials will export incorrectly as the file has no way to know what you intend for the material parameters to be without the textures. The Blender glTF exporter is even failing to write out any information (you do have a metallic factor set) because it sees the roughness texture so it is ignoring the metallic factor. So your material list in the glTF looks like this:

Every material, other than the glass which has no texture applied is just an empty object so Babylon is just setting default values for the PBRMaterial of white albedoColor, 1.0 metallic, and 1.0 roughness. To fix this you either need to relink the missing images before outputting or delete the image inputs and just use factors for each parameter (like 0.5 roughness).

The other thing to take into account with this model is that it was made for pre-render and not real time rendering. The meshes are really heavy and not at all optimized for real time rendering:


The triangle count alone is very high, but the fact that you have double-sided materials for all your meshes when none need them, and 268 meshes in your scene is driving your draw calls to a ridiculous level. Ideally for this mesh, even if you had alpha blending on the glass, which is currently disabled, you should have maybe 3 or 4 draw calls unless you need more materials for some special cases.

Hopefully this gives you some idea where to go from here, but if you have more questions, feel free to ask.

1 Like

Sorry I did not include the complete project with textures. Here is the complete file.

I do appreciate the input. Understand that I have zero experience with 3D modeling, which is why I am trying to use existing models.


Looking at the textures, I have a couple of concerns the main one being the size of the files. The textures are all 4K textures which is very large for what is actually in the textures. This is the albedo texture for one of the doors:

There is quite a bit of slight variation in the grey tones, but nothing that is very large. For tga files, this makes the texture enormous, with this texture weighing in at just over 28MB. Converting the file to a png and saved at the smallest size (using superpng without quantization) reduces it to 5.5MB, but if you quantize it, even at high quality reduces the file to 40KB. But there is no need for these textures to be 4K textures and could be reduced to 1K or even 512 x 512 and you would likely see no difference. This will help the footprint in memory as the extra resolution is not helping you at all. You will need to do this optimization because this file has 28 textures ranging from 1MB to over 28MB with most hovering in the 10-16MB range. This will be a killer for downloading, and will be super problematic for some devices.

With changing the textures to png, and relinking them the resulting glTF file is fine:

This is normally the challenge with using models from online libraries. You can get a model that is meant for pre-render which may increase your render time, but that is the only tradeoff. Trying to use one of those assets in real-time rendering, where you need to render 60 frames per second, will likely cause major issues and require significant optimization. The question then is do you spend the time to optimize, find another asset that is built for real-time rendering, or do you build it yourself?

I understand this is a big challenge for someone new to 3D content creation, but these models are simple enough that I believe you would be surprised how quickly you could get up and running with Blender to make something like this.

1 Like

Thanks. I did the same thing except without all of the optimization and got a similar result, although yours still looks better. :slight_smile:

@MattS are you still loading the file as an obj or as a glTF? If you export the mesh from Blender as a glTF, you will get all of the material settings when the file is loaded without needing to hook anything back up. This is what you are seeing in my files. I can just drag/drop the glb (a binary of the gltf with all needed mesh and texture files) into the sandbox and have it render correctly.

If you are loading the file as an obj, you will likely need to do some extra setup on the materials for the file so that you are using a PBRMaterial material type rather than a standard material so that you can get the benefit of IBL lighting.

Of all the challenges learning Bablylon, i found this one to be the toughest. Esp seeing such incredible models in turbosquid, bitgem, unity store, sketchfab, and then them not working right away. I ended up taking a Blender class, which ended up being more challenging than Babylon itself…

You know what would be amazing, all you entrepreneurs out there - is a stock 3d model store dedicated to web friendly models. Or some kind of magical conversion tool.