Skip to content

Commit

Permalink
switch rendering backend to WGLMakie
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Jun 21, 2024
1 parent f425e87 commit 9ec0580
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 83 deletions.
154 changes: 89 additions & 65 deletions docs/Manifest.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
JuliaSimCompiler = "8391cb6b-4921-5777-4e45-fd9aab8cb88d"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Expand All @@ -8,3 +7,4 @@ ModelingToolkitStandardLibrary = "16a59e39-deab-5bd0-87e4-056b12336739"
Multibody = "e1cad5d1-98ef-44f9-a79a-9ca4547f95b9"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Multibody
using Documenter
using CairoMakie
using WGLMakie
ENV["JULIA_DEBUG"]=Documenter # Enable this for debugging
ENV["DOCS_BUILD"] = true # used to lower the default frame rate in animations for the docs

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/free_motion.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ plot(sol, idxs = [body.r_0...])
```

```@example FREE_MOTION
import CairoMakie
import WGLMakie
Multibody.render(model, sol, filename = "free_body.gif")
nothing # hide
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/kinematic_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ using Test
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example kinloop
import CairoMakie
import WGLMakie
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
```
Expand Down Expand Up @@ -137,7 +137,7 @@ plot(sol, idxs=[j2.s]) # Plot the joint coordinate of the prismatic joint (green
```

```@example kinloop
import CairoMakie
import WGLMakie
Multibody.render(fourbar2, sol; x=-2, y = 2, z = 3, filename = "fourbar2.gif") # Use "fourbar2.mp4" for a video file
nothing # hide
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/pendulum.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The solution `sol` can be plotted directly if the Plots package is loaded. The f
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example pendulum
import CairoMakie # GLMakie is another alternative, suitable for interactive plots
import WGLMakie # GLMakie is another alternative, suitable for interactive plots
Multibody.render(model, sol; filename = "pendulum.gif") # Use "pendulum.mp4" for a video file
nothing # hide
```
Expand Down Expand Up @@ -226,7 +226,7 @@ plot(sol, layout=4)
```

```@example pendulum
import CairoMakie
import WGLMakie
Multibody.render(model, sol, filename = "furuta.gif")
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/robot.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ plot(sol, idxs = [
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example robot
import CairoMakie
import WGLMakie
Multibody.render(robot, sol; y=2, lookat=[0,1,0], filename = "robot.gif")
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/ropes_and_cables.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ prob = ODEProblem(ssys, [], (0, 5))
sol = solve(prob, Rodas4(autodiff=false))
@test SciMLBase.successful_retcode(sol)
import CairoMakie
import WGLMakie
Multibody.render(stiff_rope, sol, filename = "stiff_rope.gif") # May take long time for n>=10
```
![stiff_rope animation](stiff_rope.gif)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/space.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ plot(sol)


```@example SPACE
import CairoMakie
import WGLMakie
Multibody.render(model, sol, filename = "space.gif")
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/spherical_pendulum.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ plot(sol, idxs = [body.r_0...])
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example spring_mass_system
import CairoMakie
import WGLMakie
Multibody.render(model, sol; filename = "spherical.gif") # Use "spherical.mp4" for a video file
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/spring_damper_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ In this example we used separate springs and dampers, see also the component [`S
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example spring_damper_system
import CairoMakie
import WGLMakie
Multibody.render(model, sol; filename = "springdamper.gif")
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/spring_mass_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The plot indicates that the two systems behave identically.
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example spring_mass_system
import CairoMakie
import WGLMakie
Multibody.render(model, sol; x=5, z = 5, filename = "springmass.gif")
nothing # hide
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/swing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sol = solve(prob, ImplicitEuler(autodiff=false), reltol=5e-3)
```

```@example SWING
import CairoMakie
import WGLMakie
Multibody.render(model, sol; z = -5, filename = "simple_swing.gif") # Use "simple_swing.mp4" for a video file
nothing # hide
```
Expand Down Expand Up @@ -155,7 +155,7 @@ Plots.plot(sol, idxs = [collect(model.body.r_0);])
```

```@example SWING
import CairoMakie
import WGLMakie
Multibody.render(model, sol; y = -1, z = -3, lookat = [0, -1, 0], filename = "swing.gif") # Use "swing.mp4" for a video file
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/three_springs.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Plots.plot(sol, idxs = [body1.r_0...])
Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature to illustrate the result of the simulation below:

```@example spring_mass_system
import CairoMakie
import WGLMakie
Multibody.render(model, sol; filename = "three_springs.gif") # Use "three_springs.mp4" for a video file
nothing # hide
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ prob = ODEProblem(ssys, [], (0.0, 3.51))
sol = solve(prob, Rodas5P())
Plots.plot(sol)
import CairoMakie
import WGLMakie
framerate = 30
timevec = [zeros(30); range(sol.t[1], sol.t[end], step=1/framerate)] |> reverse
render(logo, sol, timevec; z=-2.5, x=0, y=-0.5, lookat=[0.2,-0.5, 0], filename="JuliaSim_logo.gif", framerate)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ or
using CairoMakie
```
!!! note "Backend choice"
GLMakie produces much nicer-looking animations and is also significantly faster. CairoMakie is used to produce the graphics in the documentation due to the constraints imposed by the web environment. CairoMakie also struggles with the Z-order of drawn objects, sometimes making bodies that should have been visible hidden behind bodies that are further back in the scene.
GLMakie and WGLMakie produce much nicer-looking animations and is also significantly faster. CairoMakie may be used to produce the graphics in some web environments if constraints imposed by the web environment do not allow any of the GL alternatives. CairoMakie struggles with the Z-order of drawn objects, sometimes making bodies that should have been visible hidden behind bodies that are further back in the scene.

After that, the [`render`](@ref) function is the main entry point to create 3D renderings. This function has the following methods:

Expand Down

0 comments on commit 9ec0580

Please sign in to comment.