OBJ loader splits up mesh and does not preserve vertex order anymore

I load an obj file here Babylon.js Playground but after loading it says it has 554 vertices. However when I open that obj https://punkoffice.com/hype/assets/hype.obj in some other program it reports back as 5,398 vertices which is what I expect.

How do I get the OBJ loaded into BabylonJS to have the correct number of vertices? I checked the OBJ file import to see if there were some options that compressed or did something to the vertex list but didn’t see any option. Basically I need the vertex data for that mesh in BabylonJS to match exactly the vertex data in the OBJ file (I am doing some vertex morphing that relies on this consistency)

Calculating the sum of the vertices for each of the model’s meshes gets that result of 5,398 total vertices. :slight_smile:

1 Like

I don’t understand why it has been split up into 22 meshes. Before it would just load it as 1 mesh.
Also I just looked at the vertices of that the first mesh (with the 554 vertices) and the vertex order is very different to the .OBJ file.

Before the OBJ loader would create 1 mesh with the same vertices in the exact same order as listed in the OBJ file. This preservation of vertex order was one of the advantages of using OBJ instead of .babylon files. I’m trying to figure out how to get back to that 'cos this has broken most of my existing projects.

I tried it in version 4.2.1 and it was split up into 22 meshes then as well… IDK maybe you’re exporting it differently now if it used to be imported as 1 mesh?

Ok, I know what’s happening. Thanks for pointing this out @Blake The mesh has 22 materials so it was split into 22 meshes, which makes sense. I don’t know how this worked before cos the OBJ file hasn’t changed since 2018, but I checked another demo of mine which does the same thing (reads in OBJ, changes vertices) and that uses the latest libs from the CDN, works perfectly fine.
So to conclude, I’ve stuffed something up. Completely my fault here!

I got it working again Hype dance
I just went into Blender and combined all the materials into one.
I gotta stop being so dramatic! I sound like a douche-bag lol