Reinitializing engine in Playground (TypeScript)

Hi all!

Trying to create a TypeScript Playground with an engine with deterministicLockstep as shown in the Playground: https://www.babylonjs-playground.com/#DU4FPJ#3.

In TypeScript, I added the lines:

// @ts-ignore
delete engine;
engine = new BABYLON.Engine(canvas, true, {
    deterministicLockstep: true,
    lockstepMaxSteps: 4
});

However, this gives the error createEngine function must return an engine. as shown in the Playground: https://www.babylonjs-playground.com/#3ZW889#1

Thank you for your help! :stuck_out_tongue:

to create a difference engine in the playground you will need to define a createEngine function. In typescript it should be a static CreateEngine function that returns an engine. A random example I found -

https://www.babylonjs-playground.com/#2LX5WU#13

Not mine, just here to show how it works :slight_smile:

2 Likes

Ah, thank you so much, @RaananW, your solution works great!

https://www.babylonjs-playground.com/#3ZW889#4

1 Like

Just today, the Playground above (https://www.babylonjs-playground.com/#3ZW889#4) is no longer working due to createScene function must return a scene.

The Playgrounds in Ray/RayHelper incorrectly registering hit were working earlier today, but stopped working just now.

Edit:

Can be fixed by changing

document.getElementById("renderCanvas")

to

document.getElementById("renderingCanvas")

Do you mind doing a PR to fix the doc?

1 Like

PR made!

You’re awesome! PR approved
A quick question @Deltakosh before merging - the rendering canvas’s ID was changed since the new deployment. Many playgrounds will fail now that the canvas’ id is different - don’t we want to keep the old id to support them?

2 Likes

Please change it. There is no problem

1 Like

Hey! Discussed internally, I am changing the id of the canvas element back to renderCanvas. Your PR is amazingly helpful, but it will need to be re-adjusted to renderCanvbas instead of renderingCanvas. The playground change will be merged later today, will you be update to update the docs after it is available?

Thanks a lot!!!

1 Like

Of course, @RaananW! Looking forward to the changes becoming available :slight_smile:

1 Like

@RaananW, PR created! :slight_smile:

1 Like

Merged! Thanks a lot

1 Like