'no active camera..' warning message

I am seeing warning messages in DevTools console window when babylon scene is loaded

I am using this
scene.createDefaultCameraOrLight(true, true, true);

not sure what is triggering those messages. I see 20 messages as soon as the page is loaded

This is because you start rendering the scene before calling the createDefaultCameraOrLight.

1 Like

okay so how do I change that?

well create your scene and then call createDefaultCameraOrLight before returning the scene or starting the renderloop

I am using SceneComponent as follows

import SceneComponent from ‘babylonjs-hook’;
< SceneComponent antialias onSceneReady={onSceneReady} id=“my-canvas” />

const onSceneReady = (scene: any) => {
SceneLoader.ImportMesh(“”, ${process.env.PUBLIC_URL}/models/, “ThreeDModel.glb”, scene, function (theMeshes) {
if (theMeshes === undefined || typeof (theMeshes) === ‘undefined’)

  scene.createDefaultCameraOrLight(true, true, true);


please let me know how I can make sure scene is created and rendered before createDefaultCameraOrLight is called

adding @brianzinn to the rescue

Yes - that is current design. It logs in the render loop to advise that the camera isn’t ready.
babylonjs-hook/babylonjs-hook.tsx at master · brianzinn/babylonjs-hook (github.com)

onSceneReady callback is called before the engine render loop is setup. what is happening is that the ImportMesh is async, so it’s rendering without a camera. I can add an opt-out mechanism, but what about adding default camera/lights before the model is loading and show a loading animation? if it takes a while to load the model there is just a blank screen. i’m happy to add an opt-out mechanism - the logging is there more for people who have forgotten to add a camera, but I hadn’t considered somebody wanting to show an empty canvas.

1 Like

Hello @nuguru just checking if you still have questions

Hi @brianzinn . I took your suggestion and am now creating the camera before I call ImportMesh

this got rid of the ‘no active camera…’ warning message but my scene changed from


when I add ‘camera.setPosition(new Vector3(0, 1, 2.8));’ I get this

I tried playing around with different numbers for setPosition but this it the best I got without going out of bounds.

Any suggestions on how I can get my scene to look more like figure 1


are you interested in trying a framing behavior?
react-babylon-viewer-1/Render.tsx at master · brianzinn/react-babylon-viewer-1 (github.com)

it’s not really a React specific thing and not sure exactly what you are trying to accomplish.