nomadic_aviator Posted September 25, 2015 Share Posted September 25, 2015 I have successfully created a scene and imported it, which shows up on my localhost, but when I put it on a live server (http://www.cosmiqcloud.com/webgl), I get an endless loading screen and this error in the console in Chrome: Uncaught SyntaxError: Unexpected token , e.SceneLoader.RegisterPlugin.load @ babylon.js:17u @ babylon.js:17e.onreadystatechange @ babylon.js:4 And this error in Firefox: SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 454 column 23 of the JSON data babylon.js:16:26015 Here is the code for the app <!DOCTYPE html><head> <title>3D Real Estate Application | Babylon.js version</title> <script src="http://cdn.babylonjs.com/2-1/babylon.js"></script> <style> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; touch-action: none; } </style></head><body> <canvas id="renderCanvas"></canvas> <script> window.addEventListener('DOMContentLoaded', function(){ // get the canvas DOM element var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); // createScene function that creates and return the scene var createScene = function(){ // create a basic BJS Scene object var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(.25, .181, .240); // create a FreeCamera, and set its position to (x:0, y:5, z:-10) var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 0,13), scene); // target the camera to scene origin camera.setTarget(BABYLON.Vector3.Zero()); // attach the camera to the canvas camera.attachControl(canvas, false);BABYLON.SceneLoader.Load("", "realestate.babylon", engine, function(newScene){ if (!newScene.activeCamera) { newScene.activeCamera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(3, 2,0), newScene); } newScene.executeWhenReady(function() { newScene.activeCamera.attachControl(canvas); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { newScene.render(); }); }); }); // return the created scene return scene; }; // call the createScene function var scene = createScene(); // run the render loop engine.runRenderLoop(function(){ scene.render(); }); // the canvas/window resize event handler window.addEventListener('resize', function(){ engine.resize(); }); }); </script></body></html>I have also attached a screenshot of what is supposed to appear in the browser. I wanted to make sure it wasn't something in my code that is causing this. Thank you for your help. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 25, 2015 Share Posted September 25, 2015 Just a thought that comes to me. This would not be the missing textures in the scene file that search textures? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 26, 2015 Share Posted September 26, 2015 Hello did you enabled MIME type for .babylon files on your server? Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted September 28, 2015 Author Share Posted September 28, 2015 Hello, thank you for your reply. No I didn't enable the .babylon MIME type on my server. How would I do that? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 28, 2015 Share Posted September 28, 2015 It depends on the server. What are you using ? IIS? Apache? Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted September 29, 2015 Author Share Posted September 29, 2015 I am using Apache. I am also not the admin for my server. I am using a webhosting company. I have used Babylon on this server before. this is the first time I am seeing this error. I noticed that the server seems to add code to the end of the .babylon file. I think that is where the error is coming from. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 29, 2015 Share Posted September 29, 2015 Yes I agree. Can you share a link to your site? Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted October 1, 2015 Author Share Posted October 1, 2015 Here is the link to the site on the live server. http://www.cosmiqcloud.com/webgl/ Is there a way I can prevent this site from adding this code? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 2, 2015 Share Posted October 2, 2015 I got a "unknown host" error Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted October 2, 2015 Author Share Posted October 2, 2015 I think I have sort of figured this out. I have another version of this scene built with Three.js. The JSON file that loads seems to work fine. That link is here: http://www.cosmiqcloud.com/webgl/three/ With this scene, I believe that my server doesn't recognize the .babylon file as JSON. I believe this because it keeps adding JavaScript at the end of the .babylon file that causes the error. At least that is my theory anyway. Problem is, I am not sure how to fix that. I may have to just have a chat with the administrator. So I have one more question. Once, I import a scene, is there a way to add materials to each individual mesh, or do I need to place the materials on them before they are imported? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 2, 2015 Share Posted October 2, 2015 Your realestate.json file is not a babylon file. it does not suffices rename .json in .babylon for this to work. I think this is your error.The your file is not done to Babylon, but to this old ThreeJS.Anyway, this error comes is the way, not good path or not good file. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 2, 2015 Share Posted October 2, 2015 Once, I import a scene, is there a way to add materials to each individual mesh, or do I need to place the materials on them before they are imported?Yes you can: just use scene.getMeshByName(name).material = ... Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted October 5, 2015 Author Share Posted October 5, 2015 dad72. The realestate.babylon file is what I exported from Blender using the Babylon exporter. Not sure why it would be a three.js file if I used that exporter. I'll export it once more and see if I get that error still. Deltakosh. Thank you. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted October 5, 2015 Share Posted October 5, 2015 This is because I saw that same file in your demonstration with Thee.js, but with the extension .json.I supposed that you wanted to try the same file in Babylon. So bad hypothesis. Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 5, 2015 Share Posted October 5, 2015 I took a look at that file of yours and it ends like that:"cameras":[],"activeCamera":"Camera","lights":[{"name":"Torchiere Light.001","id":"Torchiere Light.001","type":0,"position":[0,1.7034,0],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]},{"name":"Sun","id":"Sun","type":1,"position":[16.663,3.4832,16.5793],"direction":[-0.7899,-0.1332,-0.5986],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]},{"name":"Torchiere Light","id":"Torchiere Light","type":0,"position":[0,1.7034,0],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]}],"shadowGenerators":[],<script type="text/javascript">(function (d, w) {var x = d.getElementsByTagName('SCRIPT')[0];var f = function () {var s = d.createElement('SCRIPT');s.type = 'text/javascript';s.async = true;s.src = "//np.lexity.com/embed/YW/454fac790ad7f7c41310bbb9e7868a48?id=a4df5e1a9777";x.parentNode.insertBefore(s, x);};w.attachEvent ? w.attachEvent('onload',f) :w.addEventListener('load',f,false);}(document, window));</script>So that's probably the problem (as you have already found out). The question is why there a script tag instead of a properly closed file. Are you using the latest blender exporter? Can you confirm that the file does not have this script thingy in it right after you create it on you PC? Was there a problem during the upload? Too little space on you websrver to upload the file and that is some weird server configuration? Just throwing ideas around Quote Link to comment Share on other sites More sharing options...
nomadic_aviator Posted October 7, 2015 Author Share Posted October 7, 2015 iiceman, that was my theory too. It doesn't get added until I upload it to my server, which is a real problem. I am going to talk to the admin of this server space and figure out why that gets added. I have been meaning to look at another option for server space anyway. Which leads me to my last question, maybe this has been asked before, but is there a thread that explains how to use Babylon with Node.js? I am sure I will find it in a search, but I figured I'd ask just in case there are resources elsewhere for that. Thank you. 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.