MeshView Issue - Smooth .obj file but messy preview


Building scanning into personal app and have run into issue with the MeshView preview. During scanning, the surface fills out as expected and the final .obj file is smooth as well, but the preview in the MeshViewController is very corrupt. It almost looks like every scanned point has been connected by a line to some arbitrary vertex. Has anyone run into this/know a fix?

Scanning View (smooth):

Mesh Preview (messy):

*the preview is exactly what is shown by stopping the scan shown above


Appears to be other people having (had?) simialr issues.

You might want to message them, compare notes, and see if they have a solution.

-Andy W



Triangle array was previously int[] (apparently long) now it is short[] if you alloc it as int half of your triangle values will be zero which you can see in the image.


Structure SDK (for iOS) Release 0.10.3: iOS 13 Compatibility and Tracking Improvements

Hi @Petja
Do you have more information on what you mean by the Triangle array has changed type? I’ve tried looking around the demo project included in the most recent SDK compared to my projects code and I can’t seem to figure out exactly what you mean here. Do you have a code reference from the demo project you could share?

Thanks in advance


Hi Christopher,

This was based on Unity project that we have and for us changing former int[] array to short[] fixed this issue.




Thanks to your original comment, I was able to figure out what was different between the scanner sample projects so thank you so much! Below are more details for other that run into this issue cause it’s definitely subtle.

Between SDK’s, the project changed how it renders the meshes. So, if you start from the new SDK it will all work, but if you worked with an old one and are converting, the following lines need to change in the following functions inside the meshRenderer.

void MeshRenderer::uploadMesh (STMesh* mesh)

for (int meshIndex = 0; meshIndex < numUploads; ++meshIndex)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, d->facesVbo[meshIndex]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, [mesh numberOfMeshFaces:meshIndex] * sizeof(unsigned int) * 3,
[mesh meshFaces:meshIndex], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, d->linesVbo[meshIndex]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, [mesh numberOfMeshLines:meshIndex] * sizeof(unsigned int) * 2,
[mesh meshLines:meshIndex], GL_STATIC_DRAW);

void MeshRenderer::renderPartialMesh(int meshIndex) {

glDrawElements(GL_TRIANGLES, d->numTriangleIndices[meshIndex], GL_UNSIGNED_INT, 0);


The issue is the type used which is supposed to be GL_UNSIGNED_INT for the new SDK. In my project that was from the old SDK, it was set to GL_UNSIGNED_SHORT which produced invalid data as @Petja pointed out. So, check that code in your project to make sure it is GL_UNSIGNED_INT or Unsigned int in both locations shown above and it should correct the rendering of meshes in the preview window.

@alin @sludlow Hopefully this fixes your issues if you haven’t solved them already.


I’m glad that you @christopher.wood sorted out your problems. Thanks for explaining how you did it - hopefully this helps others as well :smiley: