BABYLON.SceneLoader.ImportMesh Error

BABYLON.SceneLoader.ImportMesh(“obj”, “./testData/DLQHJ/”, “DHQLJ.obj”, this._scene,

        function (newMeshes) {

            console.log("succeed")

        },

        function (progressEvent) {          

            console.log("progressEvent")

        },

        function (scene, message, exception) {

            console.log("ImportMesh failed: " + message)

        },

        ".pointcloud"

    );

ImportMesh failed: Unable to load from ./testData/DLQHJ/DHQLJ.obj: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

Obj model is a local file

Are you using a local server?

No, the obj file is a local resource file

Even if local services are used:

ImportMesh failed: Unable to load from http://127.0.0.1:8080/testData/DLQHJ/DHQLJ.obj: importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse

Have you tried the obj file in the sandbox?

Also is your mesh actually named ‘obj’ ?

Try “” instead of “obj”.

“” instead of “obj” ,still not successful,same exception,All kinds of attempts just don’t work, and the obj file is OK

Let’s see if @RaananW can help.

@RaananW It’s very urgent. Please help

I have already pinged him, he will reply when he is able. Please remember that help on the forum is voluntary and at a time when it is convenient for community members, who are usually very good with their assistance. Re-pinging a community member is not at all helpful.

1 Like

+1 on that one!

Now, about the issue at hand - it feels like you are missing the loaders library, which is required in order to load files other than the .babylon file format. Make sure to include the loaders library, either in your html file or in your npm bundle, depending on how you work.

1 Like

BABYLON.SceneLoader.ImportMesh("", “https://www.lerengebaren.nl/3d/try1/”, “aj.glb”, this._scene,
function (newMeshes) {
console.log(“succeed”)
},

import * as BABYLON from ‘babylonjs’
import * as BABYLONloader from ‘babylonjs-loaders’

image

image

My English is not good and I am not good at expression. Please forgive me for offending. Is my use of the above correct? Even using the resources of the official website is not successful

You have weird quote characters in what you pasted, i assume this is not the case in your code.

It does seem to work - Babylon.js Playground

So I would make sure you are really including and bundling the loaders. The loaders package is most certainly missing if it is trying to load a .glb file as a JSON file.

Try running npm update , as there might be a version discrepancy between the two.

As mentioned above, ImportMesh can only be used successfully when it is quoted online. Ts&weckpack can’t succeed all the time,I don’t know why,Can this situation be solved?

Maybe you need to use BABYLONloader.ImportMesh instead of Babylon.SceneLoader.ImportMesh if that’s where you imported that functionality into? I’m just guessing thou since I don’t actually import that way (I import the classes one at a time from their path without any BABYLON or BABYLONloader namespaces)…

I don’t quite understand what doesn’t work, so it’s hard to help. Are you able to reproduce this? Share a project where it is not working?

Could you try to change this line to

import "babylonjs-loaders";

Hello @yuemiao just checking in, are you still having issues?