function my_rotate3d(varargin);
persistent currentdrag;

if strcmp(varargin{1},'down'),
	mouse_pt=get(gcf,'currentpoint');
	win_size=get(gcf,'position');
	mouse_pt=mouse_pt./win_size(3:4);
	s=get(gcf,'userdata');
	axes_size=get(s.axes,'position');
	get(gcf,'CurrentAxes');
	if (mouse_pt(1)>axes_size(1))&(mouse_pt(2)>axes_size(2))&...
		(mouse_pt(1)<axes_size(1)+axes_size(3))&(mouse_pt(2)<axes_size(2)+axes_size(4)),
		currentdrag=1;
		rotate3d(varargin{:});
	end
else
	if ~isempty(currentdrag)&currentdrag,
		currentdrag=0;
		rotate3d(varargin{:});
	end
end
