Jump to content

Can't get .babylon files to load!


danielvh96
 Share

Recommended Posts

I have a problem, the file location is correct. I use everything in the same folder now and the babylon file is namen scene.babylon, all I see is a white screen and nothing happens :/ It isn't an empty file because the sandbox displays everything correctly.. Please Help!

Link to comment
Share on other sites

I do use a local host on visual studio. This is the code that I use:

<!DOCTYPE html>
<head>
    <title>Using babylon.js - How to load a scene</title>
    <script src="hand.js"></script>
    <script src="babylon.js"></script>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }
 
        #renderCanvas {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <canvas id="renderCanvas"></canvas>
    <script>
        if (BABYLON.Engine.isSupported()) {
            var canvas = document.getElementById("renderCanvas");
            var engine = new BABYLON.Engine(canvas, true);
 
            BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene) {
                newScene.executeWhenReady(function () {
                    // Attach camera to canvas inputs
                    newScene.activeCamera.attachControl(canvas);
 
                    // Once the scene is loaded, just register a render loop to render it
                    engine.runRenderLoop(function() {
                        newScene.render();
                    });
                });
            }, function (progress) {
                // To do: give progress feedback to user
            });
        }
    </script>
</body>
</html>
Link to comment
Share on other sites

Just read something about adding some script to your web.config file. Here is the code I currently use but what do I have to add?

<?xml version="1.0"?>
 
<!--
  For more information on how to configure your ASP.NET application, please visit
  -->
 
<configuration>
 
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>
</configuration>
Link to comment
Share on other sites

Try to add that to your web.config file:

<system.webServer>	<staticContent>		<mimeMap fileExtension=".fx" mimeType="application/fx" />		<mimeMap fileExtension=".babylon" mimeType="application/babylon" />		<mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata" />	</staticContent></system.webServer>
Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 11 months later...

I could see it ll be a bit tricky to debug without seeing any code!! ;)  just didn't wanna flood with any code but couldn't import my mesh on playground either! sophei's choice! so here it is ... 

function startBabylonJS() {

    if (BABYLON.Engine.isSupported()) {
        scene = createScene();


        BABYLON.SceneLoader.ImportMesh("", "scenes/", "Rabbit.babylon", scene, function (newMeshes) {
            // Set the target of the camera to the first imported mesh
            camera.target = newMeshes[0];
        });
        
        engine.runRenderLoop(function () {
            scene.render();
        });

        window.addEventListener("resize", function () {
            engine.resize();
        });
    }
}

function createScene() {
    canvas = document.getElementById('renderCanvas');
    engine = new BABYLON.Engine(canvas, true);
    scene = new BABYLON.Scene(engine);
    camera = new BABYLON.ArcRotateCamera("camera", Math.PI, Math.PI / 2, 10, BABYLON.Vector3.Zero(), scene);
    sun = new BABYLON.HemisphericLight("sunLight", new BABYLON.Vector3(0, 1, 0), scene);

    camera.checkCollisions = true;
    camera.attachControl(canvas);

    return scene;
}

and i have a basic wen.config like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>-->
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".fx" mimeType="application/fx" />
      <mimeMap fileExtension=".babylon" mimeType="application/babylon" />
      <mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata" />
    </staticContent>
  
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
  </system.webServer>
</configuration>

 

thanks in advance :)

Link to comment
Share on other sites

A 404 error can be displayed in the console if the file Rabbit.babylon.manifest is not found. Is it the case for you ?
In this case, it can be ignored, and I suggest you to read this article about this: http://doc.babylonjs.com/tutorials/07._Caching_Resources_in_IndexedDB

Anyway, your code should be working. If you add this:

BABYLON.SceneLoader.ImportMesh("", "scenes/", "Rabbit.babylon", scene, function (newMeshes) {
  // Set the target of the camera to the first imported mesh
  camera.target = newMeshes[0];
  console.log(newMeshes);
});

Do you have anything shown in the console? Can you see the rabbit ?

Link to comment
Share on other sites

yeah, I was not counting the manifest file 404

I still can't see the rabbit, nothing gets printed out to the console other than 

GET http://localhost:59991/scenes/Rabbit.babylon 404 (Not Found)h @ babylon.2.2.js:4r.LoadFile @ babylon.2.2.js:4c @ babylon.2.2.js:20t @ babylon.2.2.js:3(anonymous function) @ babylon.2.2.js:3
babylon.2.2.js:4 Uncaught Error: Error status: 404 - Unable to load ../scenes/Rabbit.babylone.onreadystatechange @ babylon.2.2.js:4

 

it makes me wonder if there is any other visual studio environment setting that is not allowing for this babylon file to be visible ... 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks Dad72, i figured it out!!

it was an ASP.Net 5.2 setup issue ... in the startup.cs file I had to include the following so it would recognize babylon files


            app.UseStaticFiles(new StaticFileOptions
            {
                ServeUnknownFileTypes = true,
                DefaultContentType = "application/javascript"
            });
            //app.UseDirectoryBrowser();

            // Set up custom content types - associating file extension to MIME type
            var provider = new FileExtensionContentTypeProvider();
            provider.Mappings.Add(".babylon", "application/javascript");
 

Link to comment
Share on other sites

  • 1 year later...
On 27/05/2014 at 5:52 PM, davrous said:

Try to add that to your web.config file:


<system.webServer>	<staticContent>		<mimeMap fileExtension=".fx" mimeType="application/fx" />		<mimeMap fileExtension=".babylon" mimeType="application/babylon" />		<mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata" />	</staticContent></system.webServer>

Thanks, God

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...