Hello, I’m trying to import a 3D model to use with Babylon locally, but I haven’t been able to do it yet. I have checked that it works correctly in the sandbox, and it indicates that it’s appropriate. The model is exported in Blender as glTF2 (although the file extension is .glb, I’m not sure if that’s important because I also converted it to a .babylon file in the sandbox and the issue persists).
The code I’m using is from the documentation for ES6/NPM Support. I have only added the part that I believe should work for importing locally. Here it is:
(at first)
import { SceneLoader} from “@babylonjs/core/Loading/sceneLoader”;
(in the body)
SceneLoader.ImportMeshAsync([null], “./”, “model3d.glb”, scene).then((result) => {
var dude = result.meshes[0];
if (dude) {
// the model is ok
console.log(“Malla ok:”, dude);
//dude.scaling = new Vector3(0.5, 0.5, 0.5);
dude.position = Vector3(5,5,5)
} else {
// model not ok
console.log(“Error not ok.”);
}
console.log(“the dude is:”, dude);
});
I believe I have tried everything, changing the directory (the only one that at least passes within the if block doubt is this one. I believe it refers to the public folder (which I had to create myself after many trials and forum assistance because the documentation does not mention anything about it for local installation) where the model and HTML are located. I also tried manually changing the file extension to .glft and .glft2, converting the file to .babylon in the sandbox (and changing it in the code as well, of course, model3d.glft or model3d.glft2 or model3d.babylon).
The best results are not ok, and the dude is is =undefined.
The download I used is exactly the one from the documentation for ES6/NPM Support. I’ve been looking at the loaders for glTF, although I suspect they should come included by default. I’m not entirely sure how to use them either, but from what I understand, it would involve the function parameter at the end. I’m not sure. Nevertheless, I haven’t been able to make it work even in .babylon format. I’ve tried changing the numbers in the result.meshes array and within the function itself [null], [“1”,“2”], but nothing seems to work.
I have tried two dozen other things, and I don’t know where else to try. If anyone can help me, I would be very grateful. Greetings.