Jump to content

Error in sandbox: Physics not enabled..


Terminator
 Share

Recommended Posts

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?

Screen Shot 2016-07-18 at 3.39.24 AM.png

Link to comment
Share on other sites

  • 8 months later...

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!

Link to comment
Share on other sites

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!!! :)

Link to comment
Share on other sites

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.

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