A demand for a camera

I’ve just posted a little puzzle in Demos and Projects. And I get a problem that I have to create a “dummy camera” even though there is a camera to actually be used in the .babylon file that is being loaded. So my code looks like this :

var myScene = new BABYLON.Scene(engine);
var dummyCamera = new BABYLON.FreeCamera(“dummy”,new BABYLON.Vector3(0,10,
100),myScene);
BABYLON.SceneLoader.Append(“”, “square_puzzle01.babylon”, myScene);

If I leave out that second line then I will sometimes, and sometimes not, get an error message :

Uncaught Error: No camera defined

But it does not happen every time. If I refresh the scene sometimes it will work and no error message.

Try this page, and if the scene loads or if it does not load properly, hit the refresh button a few times

Puzzle - Camera error

Sometimes it loads, sometimes not

Anybody have any thoughts?

Stay Safe All, gryff :slight_smile:

you should only start rendering (calling into scene.render) once your full scene will be loaded.

2 Likes

TY @sebavan . A little bit of code out of place. Seems to work fine now the rendering takes place inside the :

myScene.executeWhenReady(function () {

})

Thank you again.

Stay Safe, gryff :slight_smile:

1 Like