Jump to content

Express.js with Babylon files


Recommended Posts

The newest Express doesn't really seem to be handling the Babylon files correctly, even after setting the mime types.

I'm using express.static with a folder, and every time BabylonJS downloads the file but doesn't create a mesh afterwards. Going to the link directly in your browser downloads the mesh instead of showing the data (not sure if this is intended)

The appropriate mime types are set, looking them up by file extension also returns these types.


Basically the code to have the mime types is this:

express.static.mime.define({    'application/babylon': ['babylon'],    'application/fx': ['fx'],    'application/babylonmeshdata': ['babylonmeshdata']});app.use(express.static('YOUR FOLDER'));


BABYLON.SceneLoader.ImportMesh("test", "objs/", "skull.babylon", scene, function (newMeshes) {	console.log("mesh loaded");	console.log(arguments); // This logs: [Array[0], Array[0], Array[0]]});

skull.babylon is the skull which you see often on the Babylon playground.


The Chrome Networking tool returns this for skull.babylon:



    1. Remote Address:
    2. Request URL:
    3. Request Method:
    4. Status Code:
      200 OK
  1. Response Headersview source
    1. Accept-Ranges:
    2. Cache-Control:
      public, max-age=0
    3. Connection:
    4. Content-Length:
    5. Content-Type:
    6. Date:
      Tue, 17 Nov 2015 16:27:23 GMT
    7. ETag:
    8. Last-Modified:
      Sat, 24 Oct 2015 15:38:58 GMT
    9. X-Powered-By:
  2. Request Headersview source
    1. Accept:
    2. Accept-Encoding:
      gzip, deflate, sdch
    3. Accept-Language:
    4. Cache-Control:
    5. Connection:
    6. Host:
    7. Pragma:
    8. Referer:
    9. User-Agent:
      Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
It seems that the networking tool actually does get the correct information:
But that "newMeshes" in the client code returns an array of size 0
Link to comment
Share on other sites


Would you be able to show us the setup? Or maybe publish a demo page temporarily?

A Babylon file is a simple static file, I would assume there wouldn't be any problem serving it.

What mime type have you tried?

I've edited the main post a few minutes before you posted this :)


There's not really something else.. There's no other setting that I'm changing or something.

Link to comment
Share on other sites

The weird thing is that this works:

var assetsManager = new BABYLON.AssetsManager(scene);var meshTask = assetsManager.addMeshTask("skull task", "", "./objs/", "skull.babylon");// You can handle success and error on a per-task basis (onSuccess, onError)meshTask.onSuccess = function (task) {	task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0);}// But you can also do it on the assets manager itself (onTaskSuccess, onTaskError)assetsManager.onTaskError = function (task) {	console.log("error while loading " + task.name);}assetsManager.load();

But BABYLON.SceneLoader.ImportMesh doesn't

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...