In the add BABYLON.GUI. AdvancedDynamicTexture after a blank page

In the add BABYLON.GUI. AdvancedDynamicTexture after a blank page.
export var createScene = async function () {
const canvas: HTMLCanvasElement = document.querySelector(‘canvas.webgl’);
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
var engine = new BABYLON.Engine(canvas);
var scene = new BABYLON.Scene(engine);

var light2 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, -100), scene);

var camera = new BABYLON.ArcRotateCamera("Camera", -21, 0.8, 50, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas, false);

BABYLON.SceneLoader.ImportMesh("", "./model/", "skull.babylon", scene, function (newMeshes) {
    camera.target = newMeshes[0].position;
});

var plane = BABYLON.Mesh.CreatePlane("plane", 2,scene);
plane.position.y = 20;
plane.position.z = 48.5;
plane.position.x = -5;

var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI", true, scene);

var slider = new BABYLON.GUI.Slider();
slider.minimum = 0.1;
slider.maximum = 20;
slider.value = 5;
slider.height = "20px";
slider.width = "150px";
slider.color = "#003399";
slider.background = "grey";
slider.left = "120px";
slider.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
slider.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER;
slider.onValueChangedObservable.add(function (value) {
    //sphere.scaling = unitVec.scale(value);
});

advancedTexture.addControl(slider);
//engine.runRenderLoop((): void => scene.render());
engine.runRenderLoop(function () {
    scene.render();
});
window.addEventListener("resize", function () {
    engine.resize();
});

};

It could be the createScene being async . I think there is another function named something like createSceneDeferred if you want it to be async. Not sure on the name, but i know @carolhmj linked a demo using it, which is where i first became aware of it. Maybe try removing async first though.

thank yuo for your reply

Hello, function names are unique
Does createSceneDeferred have a function name? I didn’t find this function.

Hmm. Does this work for you? Its also using async createScene but it works, so thats actually not the issue. Babylon.js Playground

Maybe the “./model/“ path where you’re importing the skull.babylon changed with the reorganization of the repo?

1 Like

cc @RaananW for the path ?

Hello @zheju35 a Babylon.js Playground (babylonjs.com) reproduction would also help :slight_smile:

Skull was always in the ./scenes/ directory, which works - glTF Loader Demo | Babylon.js Playground (babylonjs.com) . I am not sure we ever had a “model” directory?

1 Like