I am attempting to allow user interactions such as pan and rotate with a figure, where the contents of the figure are rapidly updating. This is a question of whether the below method is, in fact, the best way of doing this. I find that this method leaves the resulting animation a little choppy, and the interactions sometimes don't work; the rotate tool, for example, takes multiple clicks to "connect". I think this is due to the click occuring in the wrong part of the loop.
I will use an updating, Brownian motion demo just as a test. It parallels other codes where I am using hold to plot several layers of data.
targAxes = gca;
axis([-15 15 -15 15 -15 15]);
randz = @(sz1,sz2) 2*(rand(sz1,sz2) - .5);
pos1 = randz(1000,3);
pos2 = 2*randz(1000,3);
pos3 = 10*randz(1000,3);
for ii = 1:600
cv = targAxes.View;
ca = [targAxes.XLim, targAxes.YLim,targAxes.ZLim];
mv1 = randz(1000,3)/100;
mv2 = randz(1000,3)/50;
mv3 = randz(1000,3)/10;
pos1 = pos1 + mv1;
pos2 = pos2 + mv2;
pos3 = pos3 + mv3;
Nominally, I would want to set the current view during the plot3 command: I think the issues are that
- There is some latency for each of the plot3 commands (not just drawnow), and so there is a dead period where changes in the view/pan will not be recorded
- If a mouse click occurs during this dead period, it doesn't seem to always connect.
- The dead period also leads to some appearance of jitter, where the view resets slightly at the end of the dead period. This will get worse the longer the dead period is.
- Rapid pans and rotates get reset due to this dead period.
Since each plot3 command resets the view to [1 1 1] (or something like that) I cannot recapture the view after each plotting command.
So, is there a better way of doing this to improve smoothness/interactability?