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