Herbert

Error when I set Engine => lockstepMaxSteps higher than 1

Recommended Posts

hi 
I try to use onBeforeStepObservable so I pass two more option to engine(http://doc.babylonjs.com/tutorials/animations#deterministic-lockstep)

var engine = new BABYLON.Engine(canvas, true, {
    deterministicLockstep: true,
    lockstepMaxSteps: 4
});

and it occurs an error like below at scene.render()

error.png.dc45a922f11c96cd47634b6bb83cdd75.png

engine.runRenderLoop(() => {
    scene.render();
});

If I set the lockstepMaxSteps to 1, then it's alright.
This issue seems not happen to the example on PG(https://www.babylonjs-playground.com/#DU4FPJ#3)

any hint what could be the problem?

Share this post


Link to post
Share on other sites
9 hours ago, Herbert said:

hi 
I try to use onBeforeStepObservable so I pass two more option to engine(http://doc.babylonjs.com/tutorials/animations#deterministic-lockstep)


var engine = new BABYLON.Engine(canvas, true, {
    deterministicLockstep: true,
    lockstepMaxSteps: 4
});

and it occurs an error like below at scene.render()

error.png.dc45a922f11c96cd47634b6bb83cdd75.png


engine.runRenderLoop(() => {
    scene.render();
});

If I set the lockstepMaxSteps to 1, then it's alright.
This issue seems not happen to the example on PG(https://www.babylonjs-playground.com/#DU4FPJ#3)

any hint what could be the problem?

Hey @Herbert ,

Can you try with max version ? It should give a better insight. I will however try it later and post here the results.

Share this post


Link to post
Share on other sites

Hi @RelativeNull
This is already tested in the latest version(3.1 alpha)
I recreate a simple project and everything goes well, so I think it only happens to a specific case.
I will test around it, if I find something I will post it here.

but i am also curios  why does the speed become so slow in this PG example(https://www.babylonjs-playground.com/#DU4FPJ#3)

Share this post


Link to post
Share on other sites

So it might happen when I try to switch the scene to be rendered.

var scene = createScene(engine);
var scene2 = createScene(engine);

var sceneOption = [
    scene,
    scene2
];

var sceneIndex = 0;

setTimeout(() => {
    sceneIndex = 1;
}, 0);

engine.runRenderLoop(function () {
    sceneOption[sceneIndex].render();
});

and it depends on the timing you switch the scene(e.g. maybe switch at 10ms is alright, but might go wrong at 11ms)

Share this post


Link to post
Share on other sites

First about the speed - it seems like the cannon step time is wrong. Issue already exists in GitHub, I am taking care of this today.

About the scene switching - Maybe make sure to switch scenes right before the runder loop starts, so you will be surer there is no leak between the two. Scene-switching should be working and shouldn't be a problem. Make sure you initialize your meshes in the right scene, and that the render loop starts and ends with the same scene (should be the case, unless you do async stuff internally).

If you can reproduce it (playground or online), it would be wonderful to see what the problem is. And as @RelativeNull said, a babylon.max would be helpful for debugging.

Share this post


Link to post
Share on other sites

I thought max version refers to latest version:wacko:

ok, I will try babylon.max.

and I will try to reproduce it on PG, just wonder how I can switch scene on PG(since runRenderLoop is called outside)?

"the render loop starts and ends with the same scene" => does that mean I have to call stopRenderLoop before I switch scene and start a new loop?
 

var scene = createScene(engine);
var scene2 = createScene(engine);

var renderLoop = engine.runRenderLoop(function () {
    scene.render();
});

setTimeout(function() {
    engine.stopRenderLoop(renderLoop);

    engine.runRenderLoop(function () {
        scene2.render();
    });
}, 2000);

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.