I miss in your code where your scene is loaded “scene = createSzene();”
let engine = new BABYLON.Engine(canvas, true, {
preserveDrawingBuffer: true,
stencil: true
});
let scene = createScene();
engine.runRenderLoop(function () {
if (scene) {
scene.render();
}
});