Saving the rendered mesh to local disk

Need help.
I’ve created a mesh and mapped textures to it. Now I want this to be saved to my local disk.
I tried with CreatesnapShot function, but I see there are no options to save to my disk automatically once the mesh is rendered. Can someone point to any references.

TIA.

I’m not sure I understand.
You’ve made and mapped a mesh in a DCC, then you load it with Babylonjs and then you want to save it again?

@Cedric once i generate the mesh, I did screenshot functionality. If I click the screenshot button, it’s not asking to download / save to my local disk. That’s what I’m looking for.

With the inspector, you can export the scene as glb or .babylon formats:

1 Like

@Cedric Thanks a lot and it worked.
I’m looking little more actually. I do not want to press export button every time. Instead what I want is, whenever I run the script the image should get downloaded.
I need this to be automated because, I really have large set of images and clicking export button every time is really hectic work.

You can do it programmatically. Check this documentation page : glTF Exporter | Babylon.js Documentation

1 Like

Tried that, but seeing this error.


I tried using both GLTFAsync and GLBAsync. But the same error in both the cases.

I did a quick try and I get a download:

export glb | Babylon.js Playground

Yep, it works on PG for me. But getting that error when I tried it locally on my browser.

Did you also follow this JS imports ? : glTF Exporter | Babylon.js Documentation

Yes I’ve used and the error is showing up on those imported files only.

“o.TextureTools.ApplyPostProcess() is not a function” this is the error. This function is coming from https://preview.babylonjs.com/serializers/babylonjs.serializers.min.js

Do you have an idea why it’s crashing @Evgeni_Popov ?

@Cedric Is there any possibility that it can be downloaded as .jpg or .png files ?
(My scene do not contain any animations or 3 d effects. It’s just a mesh mapped with image on it).

Thanks.

It seems your are using the 5.0 version of the serializers: you should use the 4.2 version to match the version of your Babylon lib. So, get it from:

https://cdn.babylonjs.com/serializers/babylonjs.serializers.min.js

[EDIT] To render pictures of the scene: Render Scenes To .png Files | Babylon.js Documentation

1 Like

wait! you want to save the mesh or a screen capture of your scene?
If the later, then follow these steps : Render Scenes To .png Files | Babylon.js Documentation

@Cedric I want scene.
The screenshot reference again points me to the initial stage for which I’ve posted the question.
How can I do without click the screenshot button.

@Evgeni_Popov Thanks a lot for the quick help. It worked.

2 Likes

paint3d can open .glb.


as well as Babylon sandbox Babylon.js Sandbox - View glTF, glb, obj and babylon files

and a search on the web will bring more options.

1 Like

Thanks.
I used 3D Builder.

screenshot_21-4-22_13-21

Followed this, it’s just getting the screenshot of the background. But I need the image.

https://www.babylonjs-playground.com/#JKA0QS
Can you pls check at line number 164 and line number 166.