akashraihan05 Posted January 29, 2017 Share Posted January 29, 2017 As server i am using babyloninnode but i can not load any external .babylon file. For two weeks, I tried a lot to render any external babylon file on any browser but I can not . so anyone can help to solve this problem? server.js <!DOCTYPE html> <html> <head> <title>BabylonJS - Espilit demo</title> <script src="http://www.babylonjs.com/hand.minified-1.2.js"></script> <script src="http://www.babylonjs.com/Oimo.js"></script> <script src="http://www.babylonjs.com/babylon.js"></script> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } #renderCanvas { width: 100%; height: 100%; touch-action: none; -ms-touch-action: none; } #lcContainer { position: absolute; top: 30px; left: 30px; color: gold; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <div id="lcContainer"> <ul id="listColliders"> </ul> </div> <script> var engine; var canvas; var scene; document.addEventListener("DOMContentLoaded", startGame, false); function startGame() { if (BABYLON.Engine.isSupported()) { canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, false); BABYLON.SceneLoader.Load("Espilit/", "Espilit.babylon", engine, function (loadedScene) { scene = loadedScene; // Wait for textures and shaders to be ready scene.executeWhenReady(function () { // Attach camera to canvas inputs scene.activeCamera.attachControl(canvas); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function () { scene.render(); }); }); }, function (progress) { // To do: give progress feedback to user }); } } </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 29, 2017 Share Posted January 29, 2017 Hi and welcome. Here are a couple of topics that may help you. I found them by typing manifest in the forum search bar. Quote Link to comment Share on other sites More sharing options...
akashraihan05 Posted January 29, 2017 Author Share Posted January 29, 2017 when i used and Espilit.babylon.manifest file { "version" : 1, "enableSceneOffline" : true, "enableTexturesOffline" : true } ,browser showed that's error. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 29, 2017 Share Posted January 29, 2017 Yes, I also have the impression that since some week, I notice that if I load a babylon file and I do not use a manifest file, the file is still cached, because if I modify the file and I reload it, it shows me the previous version of the babylon file. I am obliged to empty the caches of the browser or use: file.babylon?' + (new Date()).getTime() Can be a bug too. Quote Link to comment Share on other sites More sharing options...
davrous Posted January 30, 2017 Share Posted January 30, 2017 It's then not a manifest error. Indeed, as specified before, you just need to set the boolean enableOfflineSupport to false and babylon.js will stop trying to do a XHR to test for the availbility of a .manifest file. Your error seems to be linked to your node.js configuration. Have you set correctly the MIME type for .babylon file? David Quote Link to comment Share on other sites More sharing options...
akashraihan05 Posted January 30, 2017 Author Share Posted January 30, 2017 this my node.js code var http = require('http'), path = require('path'), fs = require('fs'), extensions = { //<--specify MIME file types. ".html" : "text/html", ".css" : "text/css", ".js" : "application/javascript", ".png" : "image/png", ".gif" : "image/gif", ".jpg" : "image/jpeg", ".babylon" : "application/babylon" //<--- ADD .babylon MIME type. }; //helper function handles file verification function getFile(filePath,res,page404,mimeType){ //does the requested file exist? fs.exists(filePath,function(exists){ //if it does... if(exists){ //read file and send response. fs.readFile(filePath,function(err,contents){ if(!err){ res.writeHead(200,{ "Content-type" : mimeType, //<-- SET dynamic MIME TYPE. "Content-Length" : contents.length }); res.end(contents); } }); } }); }; //handler for HTTP requests function requestHandler(req, res) { var fileName = path.basename(req.url) || 'index.html', ext = path.extname(fileName), localFolder = __dirname + '/public/', page404 = localFolder + '404.html'; if(!extensions[ext]){ //<-- CHECK file MIME type. //for now just send a 404 and a short message res.writeHead(404, {'Content-Type': 'text/html'}); res.end("Not Found"); }; getFile((localFolder + fileName),res,page404,extensions[ext]); }; http.createServer(requestHandler).listen(8008); console.log('Node server is running on http://localhost:8008'); 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.