Skip to content

Commit 30f0a96

Browse files
committed
add render method
1 parent 8584bc3 commit 30f0a96

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

ext/Render.jl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,34 @@ end
962962
get_trans_2d(sol, frame, t) = SVector{2}(sol(t, idxs = [frame.x, frame.y]))
963963
get_trans_2d(sol, frame, t::AbstractArray) = sol(t, idxs = [frame.x, frame.y])
964964

965+
function render!(scene, ::typeof(P.Frame), sys, sol, t)
966+
# sol(sol.t[1], idxs=sys.render)==true || return true # yes, == true
967+
radius = 0.005f0# sol(sol.t[1], idxs=sys.radius) |> Float32
968+
length = 0.1f0#sol(sol.t[1], idxs=sys.length) |> Float32
969+
T = get_frame_fun_2d(sol, sys)
970+
971+
thing = @lift begin
972+
Ti = T($t)
973+
Rx = Ti[:, 1]
974+
O = Point3f([Ti[1:2, 3]; 0]) # Assume world is never moving
975+
x = O .+ Point3f([length*Rx; 0])
976+
Makie.GeometryBasics.Cylinder(O, x, radius)
977+
end
978+
mesh!(scene, thing, color=:red)
979+
980+
thing = @lift begin
981+
Ti = T($t)
982+
Ry = Ti[:, 2]
983+
O = Point3f([Ti[1:2, 3]; 0]) # Assume world is never moving
984+
y = O .+ Point3f([length*Ry; 0])
985+
Makie.GeometryBasics.Cylinder(O, y, radius)
986+
end
987+
mesh!(scene, thing, color=:green)
988+
989+
990+
true
991+
end
992+
965993
function render!(scene, ::typeof(P.Body), sys, sol, t)
966994
sol(sol.t[1], idxs=sys.render)==true || return true # yes, == true
967995
color = get_color(sys, sol, :purple)

src/PlanarMechanics/components.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ The `BodyShape` component is similar to a [`Body`](@ref), but it has two frames
133133
end
134134

135135
systems = @named begin
136-
translation = FixedTranslation(; r)
137-
translation_cm = FixedTranslation(; r=r_cm)
136+
translation = FixedTranslation(; r, render=false)
137+
translation_cm = FixedTranslation(; r=r_cm, render=false)
138138
body = Body(; I, m, gy, state_priority)
139139
frame_a = Frame()
140140
frame_b = Frame()

0 commit comments

Comments
 (0)