I have come into a problem recently when trying to rotate 3D objects. I am building a GUI and I have a separate figure where an object is plotted. In the figure, I allow the user to use MATLAB's built-in rotate button to move the object around. However, I am unable to have the light also follow the rotation as it seems to be fixed on one part of the object. To create the light, I am using
c=camlight('right');
set(c,'style','infinite');
One solution I have thought of is to add light whenever the user releases the rotate button, but this is not very nice. I also do not know how to use the rotate callbacks when the button is in a separate figure.
Does anyone know how to make the light "track" the 3D rotation, so that the current view is illuminated?
Thanks!
Implement own rotation functionality
You can implement an own functionality to adjust the axes and the lights at the same time. This way the light gets adjusted continuously while rotating the axes.
Using
rotate3d
This example uses the built-in
rotate3d
and assigned callback functions. This is the 'not very nice'-solution but takes only some lines of code.