Terminator Posted July 18, 2016 Share Posted July 18, 2016 Hello, I am following this tutorial: https://doc.babylonjs.com/tutorials/05._Game_Pipeline_Integration_with_Babylon.js so when I try to work with the physics, then I export and open the files using the sandbox: http://www.babylonjs.com/sandbox/ I get this error: [03:39:46]: Physics not enabled. Please use scene.enablePhysics(...) before creating impostors. check attached for a screenshot so, what can I do to fix this? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 18, 2016 Share Posted July 18, 2016 Summoning @davrous.... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 18, 2016 Share Posted July 18, 2016 Just in case can you share the babylon file you created? Quote Link to comment Share on other sites More sharing options...
davrous Posted July 18, 2016 Share Posted July 18, 2016 I'll have a look tomorrow Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 19, 2016 Share Posted July 19, 2016 This should be enabled if the .babylon file has physics enabled. Might be my mistake here, I will check as well. Would be great to see the .babylon file! especially if it has the beautiful Suzanne! Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 19, 2016 Share Posted July 19, 2016 Just checked - physics will be enabled if the .babylon file has "physicsEnabled" set to true. should be working, even if the engine's name wasn't stated, and even if no gravity was provided. Quote Link to comment Share on other sites More sharing options...
Terminator Posted July 19, 2016 Author Share Posted July 19, 2016 I have attached the babylon file, was there something I should've done differently before exporting? blender.babylon Quote Link to comment Share on other sites More sharing options...
drodsou Posted April 15, 2017 Share Posted April 15, 2017 Same problem here, could you clarify what is the solution?, do I need to tick something else in Blender before exporting? Thanks Quote Link to comment Share on other sites More sharing options...
drodsou Posted April 16, 2017 Share Posted April 16, 2017 Ok, I think I found the problem. For the interest of others to come, I got it working locally creating the scene by itself before, and then using SceneLoader.Append, instead of directly creating the scene with SceneLoader.Load, which it seems is what the Sandbox does, and why it throws the error the OP mentions. It looks like Load is becoming deprecated since v 2.4.0 in favor of Append. See:http://doc.babylonjs.com/whats-new This is the code that does work using the same .babylon file that was throwing the error of the OP: var scene if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); // Define scene first var scene = new BABYLON.Scene(engine); var gravityVector = new BABYLON.Vector3(0,-9.81, 0); var physicsPlugin = new BABYLON.CannonJSPlugin(); scene.enablePhysics(gravityVector, physicsPlugin); // And then append to it, instead of creating it with BABYLON.SceneLoader.Load BABYLON.SceneLoader.Append("", "scene.babylon", scene, function () { scene.activeCamera.attachControl(canvas) engine.runRenderLoop(function() { // animations update scene.render(); }) }, function (progress) { // To do: give progress feedback to user }); } So this solved my problem locally to be able to go on learning BabylonJS but maybe the Sandbox should be fixed... Regards! Quote Link to comment Share on other sites More sharing options...
davrous Posted April 17, 2017 Share Posted April 17, 2017 Hello, The problem must come from somewhere else as .Load is immediately using .Append: https://github.com/BabylonJS/Babylon.js/blob/master/src/Loading/babylon.sceneLoader.ts#L243 I think it's more because the enablePhysics is not called during the loading process for some reasons. We need to check that. David Quote Link to comment Share on other sites More sharing options...
davrous Posted April 17, 2017 Share Posted April 17, 2017 Ping @JCPalmer. The property enablePhysics is not exported from Blender when some physics properties are affected to a mesh. We're checking for this property in our loader: https://github.com/BabylonJS/Babylon.js/blob/master/src/Loading/Plugins/babylon.babylonFileLoader.ts#L245 as well as the physics engine to enable (cannon or oimo). Do you think you could enable this exportation at the scene level from your great exporter? BTW, one small note on the type of camera exported, we now tend to prefer using by default the Universal camera rather than the free one as it embeds more available input options by default (it's basically a combinaison of Free + Touch + Gamepad). Thanks!!! Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 17, 2017 Share Posted April 17, 2017 This happened about a month ago as well. User was able to fix himself. I put a patch out. Left off any camera changes for now. Quote Link to comment Share on other sites More sharing options...
jank Posted April 18, 2017 Share Posted April 18, 2017 did you mean this issue? https://github.com/BabylonJS/Babylon.js/issues/1964 Quote i monkey-patched the 5.2 loader.file_handler.write('"physicsEnabled":true,\n') in to_scene_file(self) does the job for me for now.. it is probably easiest to conditionally add this flag if there are any physics-enabled objects in the export i guess.. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 18, 2017 Share Posted April 18, 2017 Yes, however 5.2.1 out yesterday now does this. GameMonetize and drodsou 2 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted April 20, 2017 Share Posted April 20, 2017 On 4/17/2017 at 1:31 PM, davrous said: Hello, The problem must come from somewhere else as .Load is immediately using .Append: https://github.com/BabylonJS/Babylon.js/blob/master/src/Loading/babylon.sceneLoader.ts#L243 I think it's more because the enablePhysics is not called during the loading process for some reasons. We need to check that. David Ok, I am looking at Cameras. Swapping out Free for Universal is not a problem (It is being converted to Universal on load anyway). I am writing lockedTargetID, but looks like FileLoader is checking for Target. I do not see how FollowCam is going to work or why 2 different kinds of targets are needed. I never actually use a .babylon exporter. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 20, 2017 Share Posted April 20, 2017 FollowCamera has his own serializer: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.followCamera.ts#L20 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.