# Loading GLTF files in a Babylon file

**URL:** <https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005>\
**Category:** Questions\
**Created:** [September 30, 2019, 4:12pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005 "2019-09-30T16:12:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 4:12pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/1 "2019-09-30T16:12:06Z")

</div>

Is it possible to load a GLTF file via the JSON in a Babylon file?

---

<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:** [September 30, 2019, 4:39pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/2 "2019-09-30T16:39:37Z")

</div>

Hi @rrangel.  
yes, of course  
[https://www.babylonjs-playground.com/#ZAKY8Z#2](https://www.babylonjs-playground.com/#ZAKY8Z#2)  
[https://playground.babylonjs.com/#U5SSCN#7](https://playground.babylonjs.com/#U5SSCN#7)

---

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 4:41pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/3 "2019-09-30T16:41:53Z")

</div>

Thank you for the response, but I should clarify that I meant the JSON in the .babylon file format: [FileFormat Map (.babylon) - Babylon.js Documentation](https://doc.babylonjs.com/resources/file_format_map_(.babylon))

---

<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:** [September 30, 2019, 4:44pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/4 "2019-09-30T16:44:17Z")

</div>

It should be exactly like in the above examples. That ‘GLTF’ from title confused me 😄

---

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 5:02pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/5 "2019-09-30T17:02:50Z")

</div>

Sorry about that! I don’t think I fully understand what you mean. I know how to load GLTF files similar to the examples you linked, but I’m wondering if it is possible to have a .babylon file that contains the location of some GLTF file so that I can create the full scene from the JSON in one .babylon file in one function call.

---

<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:** [September 30, 2019, 5:25pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/6 "2019-09-30T17:25:34Z")

</div>

I don’t know actually if you can or not, but I see no reason actually.  
You can import as babylon file an entire scene with cameras, lights and meshes.  
Or you can import meshes from a gltf file. Can you please elaborate a little bit about your scenario?

---

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 5:33pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/7 "2019-09-30T17:33:04Z")

</div>

My team is interested in created a visualization tool in Babylon and I’ve been researching various topics as they come up. The babylon file format seems really useful for creating an entire scene but I didn’t find anything on loading a GLTF file in as a mesh directly from the babylon file rather than manually adding it to the scene after. I’m just curious if it is possible, although I think in most cases it would be much easier to add it to the scene separately.

---

<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:** [September 30, 2019, 5:42pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/8 "2019-09-30T17:42:52Z")

</div>

Let see if somebody will have an idea.  
Maybe you can import the gltf file in the scene and after this export the entire scene as babylon.

---

<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:** [September 30, 2019, 5:43pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/9 "2019-09-30T17:43:48Z")

</div>

Or you can create your custom json file, but you’ll have to create a custom loader as well

---

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 5:51pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/10 "2019-09-30T17:51:27Z")

</div>

Those both sound like ideas worth looking into. Thank you for the help!

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [September 30, 2019, 8:35pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/11 "2019-09-30T20:35:53Z")

</div>

Technically, yes you can.

Hi… My name is Mackey. I am the developer for the BabylonToolkit.

My first version of the toolkit used the native .babylon file to serialize custom user metadata and then i parse that metadata on load.

My new version uses native GLTF loaders/parsers… So i get what you are trying to do.

FYI… I just use GLTF to make the Whole or Main scene as well… (Not loading .babylon files at all)

Anyways… We added support for custom user **metadata** a long time ago so…

You could serialize metadata on your babylon scene json:

```auto
scene.metadata.myloader.gltffile = "http://myserver.com/myscene.gltf"

```

Then in babylon you will have **metadata** on your scene node as an **any**

Parse your **scene.metadata.myloader.gfltffile** property to get the url of your

sub gltf scene files…

Kind of alot of work… When you can just use GLTF for every thing…

FYI… GLTF has **extras** section support for its json… That is what i use to serialize all the Unity Metadata into native GLTF files and i use native GLTF for everything… I love the binary file support of gltf for things like animations, blend shapes and of course mesh data 🙂

Here is an example Babylon Toolkit prepared racing/driving mechanics playground.

Note: Everything is really coming from: **SampleScene.gltf**

[https://www.babylonjs-playground.com/#GGCXPU#14](https://www.babylonjs-playground.com/#GGCXPU#14)

Hope that help you out

---

<div class="post-metadata">

**Author:** ![rrangel](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rrangel](https://forum.babylonjs.com/u/rrangel)\
**Post date:** [September 30, 2019, 8:56pm UTC](https://forum.babylonjs.com/t/loading-gltf-files-in-a-babylon-file/6005/12 "2019-09-30T20:56:04Z")

</div>

Thank you so much! This is really good information.
