MATLAB: Surface Lighting in App Designer not Showing Properly

3d plotsapp designerimage processinglightingMATLAB

I've recently begun to move a MATLAB GUI that I've been working on into App Designer. However, I have gotten to a point where a 3D surface plot (using trisurf) is not coming out as it did in my Guide GUI. I believe it has to do with the lighting property as the image comes up as a 2D blob rather than a 3D object with edges. Here is what it looks like:
knee.JPG
This image is what it looks like in my old Guide GUI:
knee.JPG
Here are the few lines of code that actually plot the image in App Designer:
trisurf(tri, outXYZ(:,1), outXYZ(:,2), outXYZ(:,3),'FaceColor','yellow','EdgeColor','none','FaceAlpha',1, 'FaceLighting', 'gouraud','Parent', app.KneeMask);
view(3)
axis tight;
camlight;
I used to specify the lighting outside of the trisurf call by putting
lighting gouraud
I tried moving it inside of the trisurf call in case it had anything to do with not specifying the axes (which wasn't an issue in Guide GUI), but this didn't help either. I also re-ran the code once and saved the trisurf as a variable in order to observe the lighting property and it was indeed gouraud, so I'm not sure why it's coming out as a blob. Any help with this would be much appreciated. Thank you!

Best Answer

Alright, I finally ended up figuring this out on my own. The issue was you have to create a light object, and for some reason when I called camlight it didn't work on the axes I was interested in, so the gouraud lighting didn't take effect. I had to experiment to find out how to do all of the proper syntax when specifying the axes, but here's my solution for anyone who may run into this issue when using App Designer:
trisurf(tri, outXYZ(:,1), outXYZ(:,2), outXYZ(:,3),'FaceColor','yellow','EdgeColor',...
'none','FaceAlpha',1, 'Parent', app.KneeMask);
daspect(app.KneeMask, aspect_view);
camlight(app.KneeMask);
lighting gouraud;
view(app.KneeMask,3)
axis(app.KneeMask, 'tight');
Related Question