diff --git a/docs/make.jl b/docs/make.jl index d52e8f74..5c0db530 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,6 +2,7 @@ using Multibody using Documenter using CairoMakie ENV["JULIA_DEBUG"]=Documenter # Enable this for debugging +ENV["DOCS_BUILD"] = true # used to lower the default frame rate in animations for the docs DocMeta.setdocmeta!(Multibody, :DocTestSetup, :(using Multibody); recursive = true) diff --git a/docs/src/examples/kinematic_loops.md b/docs/src/examples/kinematic_loops.md index 3870b929..6c9ae168 100644 --- a/docs/src/examples/kinematic_loops.md +++ b/docs/src/examples/kinematic_loops.md @@ -81,7 +81,7 @@ Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature ```@example kinloop import CairoMakie -Multibody.render(fourbar, sol, 0:0.033:10; x=4, y=-1, z=4, lookat=[0, -1, 0], filename = "fourbar.gif") # Use "fourbar.mp4" for a video file +Multibody.render(fourbar, sol, 0:0.05:10; x=4, y=-1, z=4, lookat=[0, -1, 0], filename = "fourbar.gif") # Use "fourbar.mp4" for a video file nothing # hide ``` diff --git a/ext/Render.jl b/ext/Render.jl index ea23c802..4b977c10 100644 --- a/ext/Render.jl +++ b/ext/Render.jl @@ -108,10 +108,20 @@ function default_scene(x,y,z; lookat=Vec3f(0,0,0),up=Vec3f(0,1,0),show_axis=fals scene, fig end +function default_framerate(filename) + if parse(Bool, get(ENV, "DOCS_BUILD", "false")) + return 20 + elseif lowercase(last(splitext(filename))) == ".gif" + return 25 + else + return 30 + end +end function render(model, sol, timevec::Union{AbstractVector, Nothing} = nothing; - framerate = 30, + filename = "multibody_$(model.name).mp4", + framerate = default_framerate(filename), x = 2, y = 0.5, z = 2, @@ -119,7 +129,6 @@ function render(model, sol, up = Vec3f(0,1,0), show_axis = false, timescale = 1.0, - filename = "multibody_$(model.name).mp4", kwargs... ) scene, fig = default_scene(x,y,z; lookat,up,show_axis)