11function updateAnimatedLine(obj ,plotIndex )
22
3+ axisData = obj .State .Plot(plotIndex ).AssociatedAxis;
4+
35% -AXIS INDEX-%
4- axIndex = obj .getAxisIndex(obj . State .Plot( plotIndex ).AssociatedAxis );
6+ axIndex = obj .getAxisIndex(axisData );
57
68% -PLOT DATA STRUCTURE- %
79plotData = get(obj .State .Plot(plotIndex ).Handle);
@@ -150,6 +152,115 @@ function updateAnimatedLine(obj,plotIndex)
150152
151153% -------------------------------------------------------------------------%
152154
155+ % -SCENE CONFIGUTATION-% for 3D animations, like comet3
156+
157+ % -------------------------------------------------------------------------%
158+ if obj .PlotOptions .is3d
159+
160+ % -aspect ratio-%
161+ asr = obj .PlotOptions .AspectRatio ;
162+
163+ if ~isempty(asr )
164+ if ischar(asr )
165+ scene.aspectmode = asr ;
166+ elseif isvector(ar ) && length(asr ) == 3
167+ xar = asr(1 );
168+ yar = asr(2 );
169+ zar = asr(3 );
170+ end
171+ else
172+
173+ % -define as default-%
174+ xar = max(x(: ));
175+ yar = max(y(: ));
176+ xyar = max([xar , yar ]);
177+ zar = 0.75 * xyar ;
178+ end
179+
180+ scene.aspectratio.x = 1.1 * xyar ;
181+ scene.aspectratio.y = 1.0 * xyar ;
182+ scene.aspectratio.z = zar ;
183+
184+ % ---------------------------------------------------------------------%
185+
186+ % -camera eye-%
187+ ey = obj .PlotOptions .CameraEye ;
188+
189+ if ~isempty(ey )
190+ if isvector(ey ) && length(ey ) == 3
191+ scene.camera.eye.x = ey(1 );
192+ scene.camera.eye.y = ey(2 );
193+ scene.camera.eye.z = ey(3 );
194+ end
195+ else
196+
197+ % -define as default-%
198+ xey = - xyar ; if xey > 0, xfac = - 0.0 ; else , xfac = 0.0 ; end
199+ yey = - xyar ; if yey > 0, yfac = - 0.3 ; else , yfac = 0.3 ; end
200+ if zar > 0, zfac = - 0.1 ; else , zfac = 0.1 ; end
201+
202+ scene.camera.eye.x = xey + xfac * xey ;
203+ scene.camera.eye.y = yey + yfac * yey ;
204+ scene.camera.eye.z = zar + zfac * zar ;
205+ end
206+
207+ % -------------------------------------------------------------------------%
208+
209+ % -scene axis configuration-%
210+
211+ scene.xaxis.range = axisData .XLim ;
212+ scene.yaxis.range = axisData .YLim ;
213+ scene.zaxis.range = axisData .ZLim ;
214+
215+ scene.xaxis.tickvals = axisData .XTick ;
216+ scene.xaxis.ticktext = axisData .XTickLabel ;
217+
218+ scene.yaxis.tickvals = axisData .YTick ;
219+ scene.yaxis.ticktext = axisData .YTickLabel ;
220+
221+ scene.zaxis.tickvals = axisData .ZTick ;
222+ scene.zaxis.ticktext = axisData .ZTickLabel ;
223+
224+ scene.xaxis.zeroline = false ;
225+ scene.yaxis.zeroline = false ;
226+ scene.zaxis.zeroline = false ;
227+
228+ scene.xaxis.showgrid = strcmpi(axisData .XGrid ,' on' );
229+ scene.yaxis.showgrid = strcmpi(axisData .YGrid ,' on' );
230+ scene.zaxis.showgrid = strcmpi(axisData .ZGrid ,' on' );
231+
232+ scene.xaxis.showline = true ;
233+ scene.yaxis.showline = true ;
234+ scene.zaxis.showline = true ;
235+
236+ scene.xaxis.tickcolor = ' rgba(0,0,0,1)' ;
237+ scene.yaxis.tickcolor = ' rgba(0,0,0,1)' ;
238+ scene.zaxis.tickcolor = ' rgba(0,0,0,1)' ;
239+
240+ scene.xaxis.ticklabelposition = ' outside' ;
241+ scene.yaxis.ticklabelposition = ' outside' ;
242+ scene.zaxis.ticklabelposition = ' outside' ;
243+
244+ scene.xaxis.title = axisData .XLabel .String ;
245+ scene.yaxis.title = axisData .YLabel .String ;
246+ scene.zaxis.title = axisData .ZLabel .String ;
247+
248+ scene.xaxis.tickfont.size = axisData .FontSize ;
249+ scene.yaxis.tickfont.size = axisData .FontSize ;
250+ scene.zaxis.tickfont.size = axisData .FontSize ;
251+
252+ scene.xaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
253+ scene.yaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
254+ scene.zaxis.tickfont.family = matlab2plotlyfont(axisData .FontName );
255+
256+ % -------------------------------------------------------------------------%
257+
258+ % -SET SCENE TO LAYOUT-%
259+ obj.layout = setfield(obj .layout , sprintf(' scene%d ' , xsource ), scene );
260+ end
261+
262+ % -------------------------------------------------------------------------%
263+
153264% -Add a temporary tag-%
154265obj.layout.isAnimation = true ;
155266
@@ -165,6 +276,9 @@ function updateAnimatedLine(obj,plotIndex)
165276 end
166277 frameData.x= x(sIdx + 1 : i );
167278 frameData.y= y(sIdx + 1 : i );
279+ if obj .PlotOptions .is3d
280+ frameData.z= z(sIdx + 1 : i );
281+ end
168282 obj.frames{i }.name = [' f' ,num2str(i )];
169283 obj.frames{i }.data{plotIndex } = frameData ;
170284end
0 commit comments