[Solved] Uncaught TypeError: Cannot read property 'asset' of undefined (babylonjs.loaders.min.js:1)

I placed the problem on Playground

I tried to load a model from the “.glb” file. This is the file: https://dl.dropboxusercontent.com/s/735ww173uc2t6bh/gate.glb

const assetPath = "https://dl.dropboxusercontent.com/s/735ww173uc2t6bh/";
BABYLON.SceneLoader.Append(assetPath, "gate.glb", this._scene, (scene) =>
{
    console.log("Ok");
});

But I see the error message in the browser console output:

babylonjs.loaders.min.js:1 Uncaught TypeError: Cannot read property ‘asset’ of undefined
at e._getLoader (babylonjs.loaders.min.js:1)
at e.loadAsync (babylonjs.loaders.min.js:1)
at babylon.js:16
at f (babylon.js:16)
at XMLHttpRequest.p (babylon.js:16)

Property “.asset” is undefined here:

private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {
const asset = (loaderData.json).asset || {};

I had the same problem yesterday. Preview release at 08 october can not load gltf · Issue #6941 · BabylonJS/Babylon.js · GitHub

Make sure you have all imports tto preview. and not to cdn.

1 Like

@kmitov thank you very much!

Playground

Solution:

RequireConfig.ts

> requirejs.config({
>     baseUrl: ".",
>     paths: {
>         "babylonjs": "https://cdnjs.cloudflare.com/ajax/libs/babylonjs/4.0.3/babylon",
>         //Error: "babylonjs-loaders": "https://preview.babylonjs.com/loaders/babylonjs.loaders.min",
>         // Solution:
>         "babylonjs-loaders": "https://cdn.jsdelivr.net/npm/babylonjs-loaders@4.0.3/babylonjs.loaders.min"
>     }
> });
> 
> requirejs(["Program"], (Program) => { });