# Export scene into .obj

**URL:** <https://forum.babylonjs.com/t/export-scene-into-obj/1126>\
**Category:** Questions\
**Tags:** blender\
**Created:** [February 1, 2019, 5:07pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126 "2019-02-01T17:07:11Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hejny](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hejny/32/609_2.png) [@hejny](https://forum.babylonjs.com/u/hejny)\
**Post date:** [February 1, 2019, 5:07pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/1 "2019-02-01T17:07:11Z")

</div>

Hi,  
I am working with [Babylon exporters](https://doc.babylonjs.com/extensions/gltfexporter). They can perfectly export scene into gltf or glb, this is working almost everywhere, but I can not import this created gltf/glb via Blender.

My problem is that I want to have a scene in .obj . Is there any option how to convert exported gltf/glb or how to directly export Babylon scene into .obj?

Thanks.

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [February 1, 2019, 5:26pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/2 "2019-02-01T17:26:47Z")

</div>

You can import into Blender 2.80 with gltf. Never tried it though.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [February 2, 2019, 6:53pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/3 "2019-02-02T18:53:40Z")

</div>

Hi.  
I don’t know if I understood your issue, but I exported meshes from babylonjs as obj and work well in 3dsMax, so I think they should work too in Blender, maybe you are doing something wrong on export. You can test your exported meshes on [https://sandbox.babylonjs.com](https://sandbox.babylonjs.com) first.  
[here](https://doc.babylonjs.com/playground/?code=OBJExport) you find few examples about OBJexporter

Here is how I’m using it.

const obj = OBJExport.OBJ(array\_Meshes, true, ‘material’, true)  
const mtl = OBJExport.MTL(array\_Meshes)

const names = [‘object.obj’, ‘material.mtl’]  
const blobs = [new Blob([obj], { type: ‘octet/stream’ }), new Blob([mtl], { type: ‘octet/stream’ })]

If you are using gltf files into babylonjs scene then in array\_Meshes you can put directly children of ‘root’ node.

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fselcukcan/32/2370_2.png) [@fselcukcan](https://forum.babylonjs.com/u/fselcukcan)\
**Post date:** [June 12, 2019, 7:43am UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/4 "2019-06-12T07:43:47Z")

</div>

It is a bit ambiguous there where to get the meshes, for example all the meshes. gltf and glb export works with scene, maybe it even uses the meshes part of the scene.

Should we get the meshes to pass to obj exporter as `scene.meshes` (or `this.scene.meshes`), for exporting the whole scene?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 12, 2019, 11:30am UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/5 "2019-06-12T11:30:50Z")

</div>

Yes exactly scene.meshes would do 🙂

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fselcukcan/32/2370_2.png) [@fselcukcan](https://forum.babylonjs.com/u/fselcukcan)\
**Post date:** [June 12, 2019, 11:36am UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/6 "2019-06-12T11:36:31Z")

</div>

Then how to download the files. Is there a `downloadFiles()` method on the returned object (as in gltf and glb exporters), or do we have to construct a file through Blob API or something like it?

Is `OBJ` and `MTL` methods asynchronous or sync? They look like sync from usage above and from source code.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 12, 2019, 11:42am UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/7 "2019-06-12T11:42:04Z")

</div>

they are sync and yes:

const names = [‘object.obj’, ‘material.mtl’]  
const blobs = [new Blob([obj], { type: ‘octet/stream’ }), new Blob([mtl], { type: ‘octet/stream’ })]

Then you could rely on Tools.Download to dl blobs

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fselcukcan/32/2370_2.png) [@fselcukcan](https://forum.babylonjs.com/u/fselcukcan)\
**Post date:** [June 12, 2019, 11:46am UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/8 "2019-06-12T11:46:57Z")

</div>

In that method where does the textures come from if any?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 12, 2019, 12:00pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/9 "2019-06-12T12:00:36Z")

</div>

looking at the code the url used to create the material will be the one ending up in the exporter.

The obj exporter is an external contrib and could probably be enhanced if you wish to contribute.

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fselcukcan/32/2370_2.png) [@fselcukcan](https://forum.babylonjs.com/u/fselcukcan)\
**Post date:** [June 12, 2019, 1:32pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/10 "2019-06-12T13:32:39Z")

</div>

I would like to contribute once I get more fluency in webgl based programming. Yes the obj exporter code looks different in style than the others. Also kind of old but probably most compatible in terms of js and web features.

An async version would be cool.

How do I get the texture files. Obj as a blob, mtl as another blob. whatabout picture files?

---

<div class="post-metadata">

**Author:** ![fselcukcan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fselcukcan/32/2370_2.png) [@fselcukcan](https://forum.babylonjs.com/u/fselcukcan)\
**Post date:** [June 12, 2019, 2:12pm UTC](https://forum.babylonjs.com/t/export-scene-into-obj/1126/11 "2019-06-12T14:12:20Z")

</div>

Additionally it looks like MTL method does take a single mesh as an argument oppesd to OBJ method taking an array of meshes.  
So, I kind of need to map or forEach through my scene.meshes array and call MTL method in each ietration. And then hand this utput array to the Blob constructor.

Am I correct?

Maybe later I can turn this MTL method to an array passed method since babylonjs gives us that as an array.
