404 Not Found - Unable to load model with SceneLoader.ImportMesh()

I’m trying to use the model “Dude”. But the console says that it’s unable to find my model. I indicated the path correctly.
There is my code

import {
    Color3,
    Mesh,
    MeshBuilder,
    Scene,
    SceneLoader,
    StandardMaterial,
    Vector3,
} from '@babylonjs/core';

export class MeshManager {
    constructor(private readonly _scene: Scene) {}

    public createPlayerMesh(id: string) {
        const mesh: any = SceneLoader.ImportMesh(
            id,
            '../assets/Dude/',
            'Dude.babylon',
            this._scene
        );
        return mesh;
    }
}

404 error means that there is no file there or it is unavailable.
Could you load any model from the absolute URL?
(You can use any model from library - The Meshes Library | Babylon.js Documentation)


Same problem

An absolute URL contains the entire address from the protocol (HTTPS) to the domain name (www.example.com) and includes the location within your website in your folder system (/foldernameA or /foldernameB) names within the URL.
Here is the example of loading the model with the absolute URL - https://playground.babylonjs.com/#QCU8DJ#169
It should work in your case too (if the id is correct or blank) - see code below.


public createPlayerMesh(id: string) {
        const mesh: any = SceneLoader.ImportMesh(
            id,
           'https://playground.babylonjs.com/scenes/Dude/',
            'Dude.babylon',
            this._scene
        );
        return mesh;
    }
3 Likes

Check what is the value of your id variable. If you don’t want to import some specific mesh from the model, it should be blank string, like "" .

2 Likes