{"record":{"id":"06b27608e189fad9","repo":"BabylonJS/Babylon.js","slug":"no-engine-available","errorCode":null,"errorMessage":"No engine available","messagePattern":"No engine available","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Loading/sceneLoader.ts","lineNumber":1028,"sourceCode":"\r\n        return result;\r\n    } finally {\r\n        scene.removePendingData(loadingToken);\r\n    }\r\n}\r\n\r\n// This is the core implementation of load scene\r\nasync function loadSceneCoreAsync(\r\n    rootUrl: string,\r\n    sceneFilename: SceneSource = \"\",\r\n    engine: Nullable<AbstractEngine> = EngineStore.LastCreatedEngine,\r\n    onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>,\r\n    pluginExtension?: Nullable<string>,\r\n    name = \"\",\r\n    pluginOptions: PluginOptions = {}\r\n): Promise<Scene> {\r\n    if (!engine) {\r\n        throw new Error(\"No engine available\");\r\n    }\r\n\r\n    const scene = new Scene(engine);\r\n    try {\r\n        await appendSceneCoreAsync(rootUrl, sceneFilename, scene, onProgress, pluginExtension, name, pluginOptions);\r\n    } catch (error) {\r\n        // The scene was created here, so dispose it on failure to avoid leaking the partially loaded scene.\r\n        scene.dispose();\r\n        throw error;\r\n    }\r\n    return scene;\r\n}\r\n\r\n/**\r\n * Load a scene\r\n * @param source a string that defines the name of the scene file, or starts with \"data:\" following by the stringified version of the scene, or a File object, or an ArrayBufferView\r\n * @param engine is the instance of BABYLON.Engine to use to create the scene\r\n * @param options an object that configures aspects of how the scene is loaded\r","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Loading/sceneLoader.ts#L1010-L1046","documentation":"This API creates a new Scene internally from an AbstractEngine. If the engine parameter is null/undefined, the loader cannot construct a Scene and throws immediately. Unlike ImportMesh-style APIs, this entry point owns scene creation, so a live engine is mandatory.","triggerScenarios":"Calling SceneLoader.LoadAsync (or the core 'load' variant) with an engine that is null/undefined, e.g. before engine initialization completes.","commonSituations":"Calling the loader before await engine creation (WebGPU async init); using a disposed engine reference; passing the wrong variable (scene instead of engine) due to argument-order confusion.","solutions":["Wait for engine initialization (especially WebGPU's async creation) before calling the loader.","Pass the actual AbstractEngine instance, not a scene or a disposed engine.","If you already have a scene, use ImportMeshAsync/AppendScene variants that take a scene instead."],"exampleFix":"// before\nlet engine; // never initialized\nawait SceneLoader.LoadAsync(root, \"scene.glb\", engine); // throws\n\n// after\nconst engine = new BABYLON.Engine(canvas, true);\nawait SceneLoader.LoadAsync(\"assets/\", \"scene.glb\", engine);","handlingStrategy":"type-guard","validationCode":"if (!engine) {\n  throw new Error(\"Engine must be created before calling SceneLoader.LoadAsync\");\n}","typeGuard":"function isReadyEngine(e: unknown): e is BABYLON.AbstractEngine {\n  return !!e && typeof (e as BABYLON.AbstractEngine).getRenderWidth === \"function\";\n}","tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadAsync(root, file, engine);\n} catch (e) {\n  if ((e as Error).message === \"No engine available\") {\n    console.error(\"Engine was null/undefined — await engine creation first\");\n  }\n}","preventionTips":["Await WebGPU engine creation (CreateEngineAsync) before any loading calls.","Pass the engine (not a scene or canvas) to LoadAsync — mind argument order.","Keep engine references in a single module so they are never stale or nulled."],"tags":["loading","engine","validation","null-check"],"backgroundTag":"missing-engine-reference","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}