# Unable to animate translating a mesh in Makie

**URL:** https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731
**Category:** New to Julia
**Tags:** makie
**Created:** [April 21, 2021, 12:45pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731 "2021-04-21T12:45:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mlainz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainz/32/21183_2.png) [@mlainz](https://discourse.julialang.org/u/mlainz)
#### Post date: [April 21, 2021, 12:45pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731/1 "2021-04-21T12:45:45Z")

</div>

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)
translate!(plt,x,y,z)

```

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?

---

<div class="post-metadata">

### Author: ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)
#### Post date: [April 21, 2021, 1:01pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731/2 "2021-04-21T13:01:47Z")

</div>

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

```julia
on(x, y, z)) do x, y, z
    translate!(plt, x, y, z)
end

```

to adjust the model matrix of the plot though.

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [April 21, 2021, 1:05pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731/3 "2021-04-21T13:05:21Z")

</div>

You need to translate the plot so:

```julia
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:

```julia
onany(x, y, z) do x, y, z
    translate!(plt, x, y, z)
end

```

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

```julia
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…

---

<div class="post-metadata">

### Author: ![mlainz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainz/32/21183_2.png) [@mlainz](https://discourse.julialang.org/u/mlainz)
#### Post date: [April 21, 2021, 1:09pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731/4 "2021-04-21T13:09:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mlainz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlainz/32/21183_2.png) [@mlainz](https://discourse.julialang.org/u/mlainz)
#### Post date: [April 21, 2021, 1:31pm UTC](https://discourse.julialang.org/t/unable-to-animate-translating-a-mesh-in-makie/59731/5 "2021-04-21T13:31:06Z")

</div>

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