Quantcast
Viewing all articles
Browse latest Browse all 388

Express.js with Babylon files

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

Viewing all articles
Browse latest Browse all 388

Trending Articles