Unable to animate translating a mesh in Makie

I want to animate a moving object in Makie
For this, I do the following
using GLMakie, FileIO

x = Node{Float32}(0.0)
y = Node{Float32}(0.0)
z = Node{Float32}(0.0)

data = load("mesh.stl")
fig, ax, plt = mesh(data)

Then I obtain the following error MethodError: no method matching Float32(::Observable{Float32}). Note that it works if x, y, z are Floats instead of Nodes.

I also tried translating by vec = @lift Vec3f0($x,$y,$z) and it doesn’t work either.

It also does not work for 3d scatter plots (say fig, ax, plt = scatter([0.,0.,0.])

A workaround would be to operate on the mesh directly. Anyone knows how to do this efficiently?

I don’t think translate! is applicable to a mesh (the data). You can use

on(x, y, z)) do x, y, z
    translate!(plt, x, y, z)

to adjust the model matrix of the plot though.

You need to translate the plot so:

data = load(assetpath("brain.stl"))
fig, ax, plt = mesh(data)
translate!(plt, 0.0, 0.0, 10.0)

If you want to translate via an observable you can do:

onany(x, y, z) do x, y, z
    translate!(plt, x, y, z)

There is also an option to give a plot a transformation like so:

fig, ax, plt = mesh(data, transformation=Transformation())

But this all bitrotted a bit and isn’t that user friendly right now… You can have a look at the constructors for Transformation to see how to pass it the translate Observable…

sorry, I meant translate!(plt,x,y,z). I will correct the code now

Thank you! I couldn’t use transformation, but onany worked.