I want to create a custom Loading Page. I have 2 classes running the operation.
CustomLoading.ts
export class CustomLoading{
scene: Scene;
engine: Engine;
loadingScreen: CustomLoadingScreen;
lightTubes!: AbstractMesh[];
models!: AbstractMesh[];
ball!: AbstractMesh;
constructor(
private canvas: HTMLCanvasElement,
private loadingBar: HTMLElement,
private precentLoaded: HTMLElement,
private Loader: HTMLElement,
){
this.engine = new Engine(this.canvas, true);
this.loadingScreen = new CustomLoadingScreen(this.loadingBar, this.precentLoaded, this.Loader);
this.engine.loadingScreen = this.loadingScreen;
this.engine.displayLoadingUI();
this.scene = this.CreateScene();
this.createEnvironment();
this.engine.runRenderLoop(()=>{
this.scene.render();
})
}
CreateScene():Scene {
const scene = new Scene(this.engine);
const camera = new FreeCamera('camera', new Vector3(0,1,-8), scene);
camera.attachControl();
camera.speed = 0.25;
const envTex = CubeTexture.CreateFromPrefilteredData("./environments/wide_street.env", scene);
scene.environmentTexture = envTex;
scene.createDefaultSkybox(envTex, true);
return scene;
}
async createEnvironment(): Promise<void> {
const {meshes} = await SceneLoader.ImportMeshAsync("", "./models/","LightingScene.glb");
this.models = meshes;
this.lightTubes = meshes.filter(
(mesh) =>
mesh.name === "lightTube_left" || mesh.name === "lightTube_right"
);
// this.engine.hideLoadingUI();
}
}
CustomLoadingScreen.ts
export class CustomLoadingScreen implements ILoadingScreen{
loadingUIBackgroundColor!: string;
loadingUIText!: string;
constructor(
private loadingBar: HTMLElement,
private precentLoaded: HTMLElement,
private Loader: HTMLElement
){}
displayLoadingUI(): void{
this.loadingBar.style.width = '0%';
this.precentLoaded.innerText = '0%';
}
hideLoadingUI = () => {
this.Loader.id = 'loaded';
}
}
I don’t call hideloadingUI in CustomLoading but it still changes the id of the HTMLElement. what do you think is the problem?