# How do I load scene data directly?

**URL:** <https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337>\
**Category:** Questions\
**Created:** [December 5, 2020, 2:06am UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337 "2020-12-05T02:06:21Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 5, 2020, 2:06am UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/1 "2020-12-05T02:06:21Z")

</div>

Hi, beginner here, I’m working on a project that needs to be able to run in a local file. I need to be able to load a mesh from blender and I wanted to know if there is a function I can run, and just supply the object from the babylon file, and have it load into the scene. Ive looked through the code, and, other than realizing I’m not as good at javascript as I thoght I was, I didnt find anything. Please help, thanks in advanced!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 5, 2020, 4:34pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/2 "2020-12-05T16:34:57Z")

</div>

hello and welcome!

I guess the Viewer is what you need: [Babylon.js Viewer | Babylon.js Documentation](https://doc.babylonjs.com/extensions/babylonViewer)

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 5, 2020, 5:42pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/3 "2020-12-05T17:42:25Z")

</div>

Thanks, but i need to be able to load the model data into a scene. Is there a function to just use scene data? like where I can be able to just run BABYLON.something.function({content of babylon file})? Thanks!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 7, 2020, 7:11pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/4 "2020-12-07T19:11:00Z")

</div>

what do you mean by scene data? Not the url I guess, how your scene data is stored?

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 9, 2020, 9:56pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/5 "2020-12-09T21:56:22Z")

</div>

The content of the babylon file I exported from blender.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 10, 2020, 4:48pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/6 "2020-12-10T16:48:02Z")

</div>

but how do you store it? In a file, in a arrayBuffer?

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 11, 2020, 6:06pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/7 "2020-12-11T18:06:14Z")

</div>

in an object, I think. It’s stored like: {“producer”:“Blender”, …}

Edit: I think I know what you mean. It’s stored in an array of positions, normals, and indices.  
Like this:{…“positions”:[…], “normals”:[…], “indices”:[…]}

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 11, 2020, 6:59pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/8 "2020-12-11T18:59:20Z")

</div>

Ok so if you have a JSON object containing your file, you can recreate a file like that:

```auto
let blob = new Blob([yourDataFile]);
let file = new File([blob], 'myscene.babylon');

BABYLON.SceneLoader.LoadAsync('file:', file, scene).then((scene) => {
// Use your scene here
});

```

My question then would be: how do you get the object? Are you loading it?

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 11, 2020, 7:21pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/9 "2020-12-11T19:21:07Z")

</div>

Thanks for the help! I’ll try that! And the way I’m getting the object is I’m exporting it from blender, and I plan on just copying and pasting the JSON code into a separate JS file that defines all of the meshes and stuff in the scene.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 11, 2020, 7:43pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/10 "2020-12-11T19:43:09Z")

</div>

why not simply loading the scene files? like with SceneLoader.LoadAsync(url) …?

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 11, 2020, 7:59pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/11 "2020-12-11T19:59:33Z")

</div>

I need to have my project able to be loaded as a local file. I thought you cant load any outside files with Javascript on a local file?

edit:Yeah, I just tried it, if I try to just load a babylon file with LoadAsync, it tells me it cant load the file because its not http.

edit2:it says “Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///untitled.babylon. (Reason: CORS request not http)”

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 11, 2020, 8:29pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/12 "2020-12-11T20:29:20Z")

</div>

I tried making the file object and stuff, it keeps giving me this error:  
Uncaught (in promise) TypeError: \_this.\_engine.scenes is undefined

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 11, 2020, 10:28pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/13 "2020-12-11T22:28:49Z")

</div>

Well I guess you missed one info: you cannot run js code locally without millions of issues. You have to host your code in a web server and then from there it will be straightforward to load your scenes as I mentioned before

---

<div class="post-metadata">

**Author:** ![random](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/random/32/12701_2.png) [@random](https://forum.babylonjs.com/u/random)\
**Post date:** [December 11, 2020, 10:59pm UTC](https://forum.babylonjs.com/t/how-do-i-load-scene-data-directly/16337/14 "2020-12-11T22:59:27Z")

</div>

Ok, well thanks for the help!
