Jump to content

Physics in Babylon.js


ebcj
 Share

Recommended Posts

Hi everybody,

 

I am new in Babylon. I needsomehelp as follows: I copied, from Babylon.js site, source for Physics demo (the one with a lot of red-white spheres). I copied also babylon.js, cannon.js and hand.js. I wite a main.js function :

 

    window.onload = function(){
    var canvas = document.getElementById("canvas");
    // Check support
    if (!BABYLON.Engine.isSupported()) {
        window.alert('Browser not supported');
    } else {
        // Babylon
        var engine = new BABYLON.Engine(canvas, true);
        //Creating scene
        scene = CreatePhysicsScene(engine);
        scene.activeCamera.attachControl(canvas);
        // Once the scene is loaded, just register a render loop to render it
        engine.runRenderLoop(function () {
            scene.render();
        });
        // Resize
        window.addEventListener("resize", function () {
            engine.resize();
        });
    }

};

The html is like that :

 

     <html>
    <head>
        <title>First Babylon experience</title>
        <script src="js/hand.js"></script>        
        <script src="js/cannon.js"></script>
        <script src="js/babylon.js"></script>
        <script type="text/javascript" src="js/main.js"></script>
        <script type="text/javascript" src="js/physicsscene.js"></script>
        <style type="text/css">
            html,body,#canvas {
                width:100%;
                height:100%;
                padding:0;
                margin:0;
                overflow: hidden;
            }
        </style>
    </head>
    <body>
        <canvas id="canvas"></canvas>
    </body>
</html>

 

Everything works, except for the fact that all spheres pass through the floor, they don't bump like in the demo. I checked the files and they are OK. May be I missed something but I don't know what.
 

Thanx,

 

Ebcj

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