Jump to content

I'm new to this, what am I doing wrong?


aaronmck
 Share

Recommended Posts

Hi, 

I've created a simple 3d model in 3ds Max and everything exports fine and I am able to view it in sandbox with no problems.

When I try to load the scene in the index.html file, all I get is a blank screen when I run it.

Here is the code I'm using, if anyone could help please

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
    
    <title>PC Deconstructor</title>
    <script src="babylon.2.4.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>
        var canvas = document.getElementById("renderCanvas");
        var engine = new Babylon.Engine(canvas, true);
        
        BABYLON.SceneLoader.Load("psu/", "psu.babylon", engine, function (scene) {
            scene.activeCamera.attachControl(canvas);
            
            engine.runRenderLoop(function () {
            scene.render();
            });
        });
        
        //Resize
        window.addEventListener("resize", function () {
        engine.resize();
        }};
    </script>
</body>
</html>

Thanks!

Link to comment
Share on other sites

So many things can go wrong here! Orin any other code :)

You could have forgotten to have babylon.2.4.js in the right directory. The .babylon file could be somewhere else, or your server could reject the .babylon file because it doesn't know the mime type. There could also be an error in the Javascript itself.

But we will never really know without you showing us a live example. Or the console error log ;)

What errors are you getting? what server are you using? can you share an online version of this file, server on some public server? We'd love to help, but we are missing a lot of information.

 

Link to comment
Share on other sites

Thanks for the reply.

I definitely have babylon.2.4.js in the right directory.

I was being an idiot and not using the server. 

I have WAMP server installed and moved the folder containing my scenes and .html file etc... into the "www" folder of wamp. How do I add the mime type in Apache so it accepts it?

Sorry for being such a noob at this!

Link to comment
Share on other sites

Hi,

nice to see that you found the solution.

What I've seen in my case was that by opening the html-file without using a webserver, the firefox loads an external file well, while the chrome doesn't load it due to sandbox restrictions. The interesting thing in that case was that there was no error message within the browser debug console.

Link to comment
Share on other sites

I checked the network tab and it displayed the name of the project as the failure. 

Done a bit of researching and apparently by clicking the project name from the localhost menu it doesn't add the "localhost/" prefix at the start.

So I added that and I don't get the error message any more but I'm now getting a blank page.

I was able to open it fine in Chrome when using Visual Studio

Link to comment
Share on other sites

ERR_NAME_RESOLVED is a DNS error, the system that translates "names" (actually FQDN, ask your favorite search engine) into IP addresses.

This means either the distant server name is wrong (not complete,... or typo) either it doesn't exist (at least your DNS client can't resolve it)

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...