Sandbox drag and drop: getting list of meshes based on total vertices

Good Afternoon all!

I was looking at this playground I found, showing a small version of the drag and drop files capability of the babylonjs sandbox.

So my question is this: How can I get an array of meshes from the file that was dragged and dropped and loaded into the playground based on a mesh’s total vertices? When loading files with the AssetsManager, I would rely on taskmanager, like so:

var assetsManager = new BABYLON.AssetsManager(scene);
meshTask = assetsManager.addMeshTask("mtask", "", modelpath, modelname + ".obj");

meshTask.onSuccess = function (task) {
    let ms = task.loadedMeshes.filter(function (mesh) {
        return mesh.geometry._totalVertices > 0;    // this line fails
    meshes = ms;

How do I get the meshes? I tried using
but I error out.

Thanks for the assistance!

currentScene.meshes should contain all the meshes in the scene, it is possible that currentScene.meshes[0].geometry is undefined if the mesh is an empty node (eg. containing child meshes), try printing out the geometry to the console of each mesh to see which ones exist.

1 Like

They’re there. I’m grabbing the wrong node. The model I’m using now is different from others I used from the same person. My mistake, I made an assumption. Thank you for helping me see the way!