mediabounds Posted July 28, 2014 Share Posted July 28, 2014 I'm trying to gain an understanding as to how setPhysicsLinkWith works and I must be missing something. Here's my sample code:http://www.babylonjs.com/playground/#1LXLMJ Why does ball2 not "link" to the bottom of ball1? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 28, 2014 Share Posted July 28, 2014 I just put the mass a 0 http://www.babylonjs.com/playground/#1LXLMJ#1 Quote Link to comment Share on other sites More sharing options...
mediabounds Posted July 28, 2014 Author Share Posted July 28, 2014 I would have expected it to work with a mass. Bigger picture, I want to chain together a number of spheres that "lean" towards whatever direction gravity is pointing. Like a chain or beaded necklace or something. Without a mass, the objects won't respond to gravity. Quote Link to comment Share on other sites More sharing options...
mediabounds Posted July 28, 2014 Author Share Posted July 28, 2014 So I've been digging through the Physics example on babylonjs.com trying to figure out what the difference was between it's linked object and mine, but nothing was jumping out. But it turns out the difference was in the environment: Apparently one render loop has to run first before I can set the physics links. http://www.babylonjs.com/playground/#1LXLMJ#2 It doesn't actually matter if the scene has been created yet or not--as long as the render loop has run at least once. For example:This does not work:var canvas = document.getElementById("renderCanvas");var engine = new BABYLON.Engine(canvas, true);var scene = CreatePhysicsScene(engine);var renderLoop = function() { scene.render();};engine.runRenderLoop(renderLoop);But this does:var canvas = document.getElementById("renderCanvas");var engine = new BABYLON.Engine(canvas, true);var scene;var renderLoop = function() { if (scene) { scene.render(); } else { scene = CreatePhysicsScene(engine); }};engine.runRenderLoop(renderLoop);I'd be really interested in the explanation if anyone knows! Temechon and Dad72 2 Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 28, 2014 Share Posted July 28, 2014 Wow, nice catch ! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 28, 2014 Share Posted July 28, 2014 {edit} I just see your fixed, good view. But I have no explanation of why 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.