Jump to content

simple .babylon viewer didn't work with me


Recommended Posts

Hi all, Im so beginner with babylon.js and im trying to do a simple example to view .babylone file with a code that i found in some sites,

but it didnt work with me.

i tryed to view the Windows cafe example (wcafe.babylon) founded in sence folder with this code that i placed in the same folder with babylon.1.9.0.js file

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <title>Using babylon.js - How to load a scene</title>    <script src="babylon.1.9.0.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("", "WCafe.babylon", engine, function (newScene) {            // Wait for textures and shaders to be ready            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>

So, is there anything to do with the "wcafe.babylon" file or the problem is from code?
PS: i use apache server to test it

and sorry for my Englesh :)

Link to comment
Share on other sites

Hello, welcome on this forum !


Which browser are you using ? Do you have anything written in the javascript console ? Did you copied all textures of the wcafe scene  in the same folder that your wcafe.babylon ?


Anyway, your code seems correct to me... Maybe an explicit javascript error in the console will help us :)

Link to comment
Share on other sites

Did you place WCafe.babylon and the rest of the assets for this demo to the same folder as babylon.1.9.0.js like you did for your index.html?


You can set the first parameter of BABYLON.SceneLoader.Load to the rootUrl of the folder containing WCafe.babylon.


If you are on Windows and have Visual Studio 2010, you can use Tools\BuildOurOwnBabylonJS\BuildOurOwnBabylonJS.sln which will set everything for you. More about it here: https://github.com/BabylonJS/Babylon.js/tree/master/Tools/BuildOurOwnBabylonJS

Link to comment
Share on other sites

Funnily enough, I tried the same thing today and it did not work either.


I got the "LoadScene" code from here including the .babylon.js file:


How to load a .babylon file produced with Blender


The file size of babylon.js is 187kb - it seems to be an old version.


I found a newer version with a file size of 310kb - and it seems to work fine.


You probably need to get the latest version of that file.


cheers, gryff :)

Link to comment
Share on other sites

I use firefox 27.0.1 and putted all files (index.html, babylon.1.9.0.js) in the same folder with the .babylon file and the texture.


PS: babylon.1.9.0.js is the latest version i found (395 KB)


useing apache the example "How to load a .babylon file produced with Blender" works (but without the ball) with the 187kb version, but didnt work with 395kb version (babylon.1.9.0.js) and it give me this error:


("[email protected]http://localhost/babylonjs-how-load-babylon/babylon.js:[email protected]://localhost/babylonjs-how-load-babylon/babylon.js:[email protected]://localhost/babylonjs-how-load-babylon/babylon.js:22BABYLON.Tools.LoadFile/noIndexedDB/[email protected]://localhost/babylonjs-how-load-babylon/babylon.js:1")


it's look like I must use another way to view the .babylon file, but i dont know how :/

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.

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.


  • Recently Browsing   0 members

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