Get Mesh from imported FBX

I’m importing a library of FBX into divs and I would like to save the mesh loaded from the first one to be reused with the next imported files.

I’m not sure how to do that and I’m trying it using object.traverse. If the child isMesh I can store it and then apply it to the next one.

But it seems to not working:

   loaderF.load(url, function (object) {
     object.traverse(function (child) {
        if (child.isMesh) {
          child.castShadow = true;
          child.receiveShadow = true;
          if (!them.model) them.model = child;
           child = them.model;

Any suggestions? Thanks for your time!

Not sure about the intention of this line but unfortunately it has no effect. Changing the reference of the child variable has no influence on the subsequent traversal process. It’s like assigning a value to the argument of a method or function call. It does not effect code outside of the method/function scope.

1 Like

Thanks. I suspected it, so I was trying to add an index i to get the current child but I’m not able to get the object’s descendent “i” …

them.model is a global variable to store the selected mesh