Augmented reality in my localhost

Hello ,
if i test this in the playgroud itโ€™s work fine https://www.babylonjs-playground.com/#BCU1XR#804
but if i download it and try to work with it i get this problem :confused:

Thnaks for help :slight_smile:

Yeah, this is due to the async nature of scene creation in the demo.

In the last lines of the html file you downloaded, you can find those lines:

scene = createScene();
        
        

        engine.runRenderLoop(function () {
            if (scene) {
                scene.render();
            }
        });

        // Resize
        window.addEventListener("resize", function () {
            engine.resize();
        });

change that to:

createScene().then((scene) => {
        engine.runRenderLoop(function () {
            if (scene) {
                scene.render();
            }
        });

        // Resize
        window.addEventListener("resize", function () {
            engine.resize();
        });
})

This should work.

You can read about async await and maybe implement it a bit better if you want :slight_smile:

2 Likes

thannnnkks @RaananW :smiley:

1 Like