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();
});
};