boston160 Posted September 23, 2017 Share Posted September 23, 2017 Hi, I've got a problem with loading scene with .babylon extension. I making project in .NET Core with BabylonJS addon and I got a problem with this script: // Get the canvas element from our HTML below var canvas = document.querySelector("#renderCanvas"); // Load the BABYLON 3D engine var engine = new BABYLON.Engine(canvas, true); // ------------------------------------------------------------- engine.enableOfflineSupport = false; var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("./js/", "babilon_blender.babylon", engine, function(newScene){ var scene = newScene; scene.executeWhenReady(function(){ scene.activeCamera.attachControl(canvas); engine.runRenderLoop(function(){ scene.render(); }); }); }); Page is build and start loading scene, but this is over. Neverending loading with Babylon mark. Could someone help me and advice what should I do to make a load scene properly? Thanks for help Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 23, 2017 Share Posted September 23, 2017 Hi @boston160, Welcome to the forum! Is there any error in the console? anything we can work with? Can we see the uploaded project live somewhere? Your code seems ok at first look, but there might be a different problem we cannot debug with code only. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted September 23, 2017 Share Posted September 23, 2017 Try this : // Get the canvas element from our HTML below var canvas = document.getElementById("renderCanvas"); // Load the BABYLON 3D engine var engine = new BABYLON.Engine(canvas, true); // ------------------------------------------------------------- engine.enableOfflineSupport = false; var scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Append("js/", "babilon_blender.babylon", scene, function(newScene){ scene = newScene; scene.executeWhenReady(function(){ scene.activeCamera.attachControl(canvas); engine.runRenderLoop(function(){ scene.render(); }); }); }); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 23, 2017 Share Posted September 23, 2017 Did you make sure to enable .babylon mime type? Quote Link to comment Share on other sites More sharing options...
brianzinn Posted September 23, 2017 Share Posted September 23, 2017 Check the network logs for 404s. For your .NET project make sure your wwwroot has the files - you may need a postbuild event to copy. Like DK said - you can enable specific mime types in your config, but try this to start and then lock it down more after (in startup.cs): app.UseStaticFiles( new StaticFileOptions { /* unknown mime types (ie: .fx) files will not be served, otherwise! */ ServeUnknownFileTypes = true } ); edit: Serving unknown file types is not recommended security-wise, so once you get it working switch over to FileExtensionContentTypeProviderhttps://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files Quote Link to comment Share on other sites More sharing options...
boston160 Posted September 23, 2017 Author Share Posted September 23, 2017 Thanks guys. Now it's work well. @RaananW I work with Visual Code and terminal show nothing. On Visual Studio got 404 error. When I added change in Startup.cs, thats it's load well. Thanks RaananW 1 Quote Link to comment Share on other sites More sharing options...
boston160 Posted October 4, 2017 Author Share Posted October 4, 2017 Hi guys. I have new problem with SceneLoader. I have in Startup.cs: app.UseStaticFiles(new StaticFileOptions { ServeUnknownFileTypes = true }); And scene is loading correctly in Index.cshtml. But how do i throw a new scene in a new view (not Index.cshtml), this new scene does not load and I get an error from the console. While I adding a new scene in Index.cshtml, it is loaded correctly. Could someone help me and advice what should I do to make a load scene properly? Thanks for help Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 4, 2017 Share Posted October 4, 2017 It looks like you are using traditional NetCore MVC full page-load. I did a BabylonJS SPA example that works with multiple canvas/scene using "dotnet new" MVC (.NET core 2.0): https://github.com/brianzinn/dotnet-new-babylonjs-starter The screenshot you have provided doesn't really show what the problem could be. Show the web browser dev tools (network/console) where the issue is instead. If there is an issue with the .babylon file then you can create a PG (playground) and lots of people available to help with reproducible errors. Quote Link to comment Share on other sites More sharing options...
boston160 Posted October 4, 2017 Author Share Posted October 4, 2017 Error processing XML: no master element found Area: http: // localhost: 3262 / Home / scenes / quiz / escape.babylon Row number: 1, column 1: escape.babylon: 1: 1 Error: Error status: 404 - Unable to load scenes / quiz / escape.babylon babylon.js: 3: 5023 t.LoadFile / l / e.onreadystatechange I get this error with the web browser dev tools. I work on VisualCode on Debian 9. I have .NET Core 2.0 installed and the project was created in the console: dotnet new mvc. Quote Link to comment Share on other sites More sharing options...
boston160 Posted October 5, 2017 Author Share Posted October 5, 2017 This is my project: https://1drv.ms/u/s!ApEWaFgXVeBEg-1R_mD2yJUGcNTPhA I've just thrown a new project with 3D views, because the project is large and weighs a lot. Can someone peek at what I'm doing wrong in the files: Index.cshtml, QuizReception.cshtml, recepton.js and quiz_reception.js? I just started with babylon.js and I don't know how I can add scenes in other views. The point is that as I type in the browser bar: http://localhost:5000/ - works correctly but: http://localhost:5000/Home/QuizReception - does not load scenes. In addition, I have a problem with collision and gravity. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 5, 2017 Share Posted October 5, 2017 It looks like the file does not exists (404). I think that error message is Firefox specific if you return content-type "text/xml". The network tab in dev tools is more helpful than the console in this case. I think you need to set the .babylon file to be included as output (it's a project file property BuildAction->Content and CopyToOutputDirectory-> Copy If Newer). Make sure that there is no "MVC" route matching /Home/scenes/quiz/escape.babylon, otherwise I believe that will activate before the static file handler. In other words, if you try this .babylon file in the same directory as the other working scene then it will likely work. MVC routes are handled in the order they are added. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 5, 2017 Share Posted October 5, 2017 Just looked at your .zip file. If you want to post your project then I would suggest just static html or setup a public facing website. 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.