KarelAnker Posted November 17, 2015 Share Posted November 17, 2015 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: http://localhost:3000/objs/skull.babylon 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: http://localhost:3000/ 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:http://puu.sh/loUkK/f5a4213053.png But that "newMeshes" in the client code returns an array of size 0 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 17, 2015 Share Posted November 17, 2015 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? Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted November 17, 2015 Author Share Posted November 17, 2015 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. Quote Link to comment Share on other sites More sharing options...
KarelAnker Posted November 17, 2015 Author Share Posted November 17, 2015 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 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 17, 2015 Share Posted November 17, 2015 Have you tried without the "test" as the first variable? Is the skull's mesh really called test? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.