AddMeshTask output

Hello, I’m trying to use AddMeshTask for my project like this:

addMesh = (name, rootUrl, file) => {
let task = this.addMeshTask(name + ‘__MeshTask’, “”, rootUrl, file);
task.onSuccess = (task) => {
console.log(task.loadedMeshes[0]);
this.mesh.set(name, task.loadedMeshes[0]);
}
return task;
}

but why the output of the console are like this:


Isn’t it supposed to be a mesh output ? and how can I get the task.loadedMeshes[0] to be a mesh instead of ‘t’ ?
Thank you in advanced

Hmm. Well I don’t know what’s the issue but that result seems okay.

task.loadedMeshes[0] will grab “root” node (to be honest I don’t know exactly why root node, which is usually found in gltf format, is represented as Mesh. If you check it with

task.loadedMeshes[0].getClassName();

It will return Mesh. Now, with that said, that mesh contains list of child meshes (which are actual meshes you are looking for).

So you can do something like

task.loadedMeshes[0].getChildMeshes() (which will return array of child meshes).

I suggest you to use babylon inspector tool where you can see the complete hierarchy of meshes with the root mesh being the first node in the hierarchy (ergo, task.loadedMeshes[0] returns exactly that node)…

Hope this helps.

1 Like

Hi @Nicolette_Gray and welcome to the forum

See Getting Started - Chapter 1 - Working with Models | Babylon.js Documentation

_root_ is added to deal with changing from left to right handed axes if needed.

The playground uses the minified version of Babylon.js t will be the property name of the task storing the mesh.

1 Like