importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

Sorry for posting this as I have already seen a few others that are very similar. But I just can’t figure it out. I am unable to load models whatsoever after several days of trying.

For example, I found this playground link here in the forum:

But when I try to run it locally, I get the importMesh error.

The only thing that I am doing differently is using the module imports (and webpack to build).

I am able to get the demo app with the cylinder working using module imports and webpack, but I cannot load any models.

import { Engine, SceneLoader, Scene } from '@babylonjs/core';

function main() {
    const canvas = document.getElementById('renderCanvas');
    const opts = { preserveDrawingBuffer: true, stencil: true };
    const engine = new Engine(canvas, true, opts);
    let scene = new Scene(engine);

    SceneLoader.ImportMesh(
        '',
        'https://playground.babylonjs.com/scenes/',
        'BoomBox.glb',
        scene,
        (meshes) => {
            scene.createDefaultCameraOrLight(true, true, true);
            scene.createDefaultEnvironment();
            console.log(meshes);
        },
    );
}

main();

Any suggestions? Thanks!

Hey there, welcome to the community. :slight_smile: It looks like maybe you’re missing the GLTF loader. After you install the package “@babylonjs/loaders” then you can import GLTF loading support like below.

import "@babylonjs/loaders/glTF";

And here’s a great example that shows how to import a glb model. :point_down:

6 Likes

Yep that seems to have done the trick. And thanks for the welcome Blake.