Import LoadingScreen or set DefaultLoadingScreenFactory

I am getting this error when running a TypeScript / Webpack .js file that attempts to load a GLTF file.

Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen

It looks like the engine should have a default loading screen by default. Why is it asking me to import?

These are my imports in TS.

import { Engine } from '@babylonjs/core/Engines/engine';
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math";
import { FreeCamera } from "@babylonjs/core/Cameras/freeCamera";
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight";
import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
import { DefaultLoadingScreen } from '@babylonjs/core/Loading/loadingScreen';
import "@babylonjs/loaders/glTF";
import "@babylonjs/core/Meshes/meshBuilder";
1 Like

Pinging @sebavan

For tree shaking purpose so people not using loading screen do not have it in there output package.

You could simply import loading screen for side effects:
import “@babylonjs/core/Loading/loadingScreen”;

This will fill up engine with the required methods.

Perfect! Your advice worked for me! Thanks!