Jump to content

Babylon.js and Node.js


Recommended Posts



I have another question about the real estate project I am working on.


I am using Node.js as the server for this project. It is fairly straightforward and I have gotten the application to work except for one part.


When i look at the console, it appears that the app wont get the .babylon file I am importing into my scene. I am not sure how to solve this but I have uploaded this project on Github if you would like to take a look:




I have found an Babylon.js npm, but I don't see any tutorials on how to use it in the app. Is my approach to this wrong?

Link to comment
Share on other sites

Your Express server is not aware of how to handle the .babylon extension. You will experience this issue in pretty much any server environment as most servers will not recognize this extension and thus will not know the mime type. In your app.js you will need to add to the mime table.


I haven't used express in a while, but this used to be done like this:


app.mime.type['.fx'] = 'application/fx';

app.mime.type['.babylon'] = 'application/babylon';

app.mime.type['.babylonmeshdata'] = 'application/babylonmeshdata';


While the syntax may not be right it should point you in the right direction, you are looking for a way for the server to respond with the proper mime type in the header when the .babylon extension is being requested.

Link to comment
Share on other sites

  • 1 year later...

Hello Babylon community,


-->Here is good example, of NodeJS serving .babylon files<--


It uses Dynamic Mime Types to populate the response.Content-type field, from the request file sent.

But, at just the right moment in Node.createServer(...).

Basically this:

                        "Content-type" : mimeType,                      //<-- SET dynamic MIME TYPE when .babylon files come through.
                        "Content-Length" : contents.length


Instructions: With node installed, clone git, then cmd line run> node server

Result (localhost:8080): .babylon meshes loaded successfully by Node in two ways: AssetsManager && SceneLoader.ImportMesh.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...