Jump to content

Express.js with Babylon files


KarelAnker
 Share

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'));

Client:

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:
      [::1]:3000
    2. Request URL:
    3. Request Method:
      GET
    4. Status Code:
       
      200 OK
  1. Response Headersview source
    1. Accept-Ranges:
      bytes
    2. Cache-Control:
      public, max-age=0
    3. Connection:
      keep-alive
    4. Content-Length:
      4130385
    5. Content-Type:
      application/babylon
    6. Date:
      Tue, 17 Nov 2015 16:27:23 GMT
    7. ETag:
      W/"3f0651-1509a80b833"
    8. Last-Modified:
      Sat, 24 Oct 2015 15:38:58 GMT
    9. X-Powered-By:
      Express
  2. Request Headersview source
    1. Accept:
      */*
    2. Accept-Encoding:
      gzip, deflate, sdch
    3. Accept-Language:
      nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
    4. Cache-Control:
      no-cache
    5. Connection:
      keep-alive
    6. Host:
      localhost:3000
    7. Pragma:
      no-cache
    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

Hi,

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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