Blender Exporter 6.1.2 getting Nan values in the positions array

Hi guys,

I’ve been getting some nan values on the meshes’ “positions” array. I’ve got a character with different meshes for the hair, eyes, mouth, etc. When I select the mouth mesh in blender and export, it works fine (I don’t get any nan values, but the character will be messed up in the browser). If I select the hair mesh and export, I’ll get nan values. Is the export behavior supposed to be different according to what mesh you have selected in blender?

Selection is not used during export. Post a log file, please. 2.80 is quite production yet (hopefully this week), but close. How many bones in your armature? If you delete it, does it come out ok?

1 Like

The armature has 71 bones. If I delete the armature, everything works 100% fine. The character even shows up on the browser without any issues, which wasn’t happening before.

I’ve attached the log file. My initial log file had a mesh where some vertices had 6 influencers. I managed to get it down to 4, but still got nan values.

Thanks, deleting the armature was a great tip. I’ll try to fiddle with it some more to see if I can pinpoint the culprit.

gal.zip (1.8 KB)

Think something might be wrong with matrix weights. Cannot look at this week, Bookmarked for later.

After pdb’ing around, here’s my solution:

  • In the mesh.py file, replace the position = vertex.co with position = Vector(vertex.co)
  • Do the same for the line normal = vertex.normal. Change it to normal = Vector(vertex.normal)

I found that in json_exporter.py, when inside the loop for object in scene.objects:, the positions array values would change in between iterations. This change in values would only occur in my main body mesh (my biggest mesh, mh1:head in the log file I uploaded above). My guess is the positions array values, which are Vector objects, were linked somehow to the loop’s object. In between iterations, the loop’s object would change, and the Vector values were also changing in memory. I used Vector() to create a copy of the Vector objects, unreferenced by the main loop’s objects. The normal values were also messed up (all 0s), so I also had create a copy of vertex.normal with Vector(vertex.normal).

I’m not 100% sure this explanation is accurate. Doesn’t really explain why selecting different objects inside blender changes the final positions array. Also doesn’t explain why deleting the armature has anything to do with this issue. But it’s working :smile:

Thanks, it took a while but I am now looking through the Blender exporter stuff I put on ice. I did almost the same thing with a vertex.co.copy(). Positions & normals are stored as objects in the first pass. After all the meshes are run through, then in another pass, they are written out.

These meshes are actually temp meshes, where the modifiers are applied. An Armature is a modifier, that is the tie in, I guess. When there is no modifiers, it must just use the permanent mesh data. I now have to actively “clear” the temporary mesh in 2.80, which I do. That probably should have been a clue that I cannot rely on the objects still being there later.

This minor change will be on the next file.

1 Like