@@ -147,8 +147,14 @@ function render(model, sol,
147147 if traces != = nothing
148148 tvec = range (sol. t[1 ], stop= sol. t[end ], length= 500 )
149149 for frame in traces
150- (frame. metadata != = nothing && get (frame. metadata, :frame , false )) || error (" Only frames can be traced in animations." )
151- points = get_trans (sol, frame, tvec) |> Matrix
150+ (frame. metadata != = nothing ) || error (" Only frames can be traced in animations." )
151+ if get (frame. metadata, :frame , false )
152+ points = get_trans (sol, frame, tvec) |> Matrix
153+ elseif get (frame. metadata, :frame_2d , false )
154+ points = get_trans_2d (sol, frame, tvec) |> Matrix
155+ else
156+ error (" Got fishy frame metadata" )
157+ end
152158 Makie. lines! (scene, points)
153159 end
154160 end
@@ -199,8 +205,14 @@ function render(model, sol, time::Real;
199205 if traces != = nothing
200206 tvec = range (sol. t[1 ], stop= sol. t[end ], length= 500 )
201207 for frame in traces
202- (frame. metadata != = nothing && get (frame. metadata, :frame , false )) || error (" Only frames can be traced in animations." )
203- points = get_trans (sol, frame, tvec) |> Matrix
208+ (frame. metadata != = nothing ) || error (" Only frames can be traced in animations." )
209+ if get (frame. metadata, :frame , false )
210+ points = get_trans (sol, frame, tvec) |> Matrix
211+ elseif get (frame. metadata, :frame_2d , false )
212+ points = get_trans_2d (sol, frame, tvec) |> Matrix
213+ else
214+ error (" Got fishy frame metadata" )
215+ end
204216 Makie. lines! (scene, points)
205217 end
206218 end
@@ -700,6 +712,9 @@ function get_frame_fun_2d(sol, frame)
700712 end
701713end
702714
715+ get_trans_2d (sol, frame, t) = SVector {2} (sol (t, idxs = [frame. x, frame. y]))
716+ get_trans_2d (sol, frame, t:: AbstractArray ) = sol (t, idxs = [frame. x, frame. y])
717+
703718function render! (scene, :: typeof (P. Body), sys, sol, t)
704719 sol (sol. t[1 ], idxs= sys. render)== true || return true # yes, == true
705720 color = get_color (sys, sol, :purple )
0 commit comments