BabylonJS/Babylon.js · error · Error
No scene available to append to
Error message
No scene available to append to
What it means
AppendScene-style APIs merge an external scene file into an existing Scene. This guard throws when the scene parameter is null/undefined, since there is no target scene to append nodes into.
Source
Thrown at packages/dev/core/src/Loading/sceneLoader.ts:1077
* @param options an object that configures aspects of how the scene is loaded
* @returns The loaded scene
*/
export async function loadSceneAsync(source: SceneSource, engine: AbstractEngine, options?: LoadOptions): Promise<Scene> {
return await LoadSceneAsync(source, engine, options);
}
// This is the core implementation of append scene
async function appendSceneCoreAsync(
rootUrl: string,
sceneFilename: SceneSource = "",
scene: Nullable<Scene> = EngineStore.LastCreatedScene,
onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,
pluginExtension?: Nullable<string>,
name = "",
pluginOptions: PluginOptions = {}
): Promise<Scene> {
if (!scene) {
throw new Error("No scene available to append to");
}
const fileInfo = GetFileInfo(rootUrl, sceneFilename);
if (!fileInfo) {
throw new Error("Cannot load file: a valid scene filename or root url was not provided.");
}
const loadingToken = {};
scene.addPendingData(loadingToken);
if (SceneLoaderFlags.ShowLoadingScreen && !showingLoadingScreen) {
showingLoadingScreen = true;
scene.getEngine().displayLoadingUI();
scene.executeWhenReady(() => {
scene.getEngine().hideLoadingUI();
showingLoadingScreen = false;
});
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Create or reuse a Scene and pass it: AppendAsync(rootUrl, filename, scene).
- Use SceneLoader.LoadAsync if the intent is to create a brand new scene from the file.
- Guard that scene && !scene.isDisposed before invoking the append call.
Example fix
// before
await SceneLoader.AppendAsync("assets/", "extra.glb", null); // throws
// after
const scene = new BABYLON.Scene(engine);
await SceneLoader.AppendAsync("assets/", "extra.glb", scene); Defensive patterns
Strategy: type-guard
Validate before calling
if (!scene || scene.isDisposed) {
throw new Error("AppendAsync requires a live Scene to append into");
} Type guard
function isUsableScene(s: unknown): s is BABYLON.Scene {
return s instanceof BABYLON.Scene && !s.isDisposed;
} Try / catch
try {
await BABYLON.SceneLoader.AppendAsync(root, file, scene);
} catch (e) {
if ((e as Error).message === "No scene available to append to") {
console.error("Target scene missing — create a Scene first or use LoadAsync");
}
} Prevention
- Remember AppendAsync merges into an existing scene; use LoadAsync to create a new one.
- Guard scene && !scene.isDisposed before append calls.
- Create the scene immediately after the engine in app bootstrap so it is always available.
When it happens
Trigger: Calling SceneLoader.AppendAsync (appendScene core path) with scene explicitly null/undefined instead of an existing Scene instance.
Common situations: Calling AppendAsync expecting it to create a scene (it does not — use LoadAsync for that); scene disposed earlier and the variable nulled; a refactor renamed variables and scene became undefined at the call site.
Related errors
- No scene available to import mesh to
- When using ArrayBufferView to load data the file extension m
- Loading from ArrayBufferView can not be used with plugins th
- Cannot load file: a valid scene filename or root url was not
- No engine available
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/79f7f584d96e8183.
Report an issue: GitHub.