How can I "clone" a texture created from renderTexture?

Evening!
Not sure if I’m even asking the right question in the title.
I’m trying to create some kind of “quicksave/rollback” for a simple doodle feature using renderTexture.
Basically restoring the texture to a prior state.

I’ve made a simple example/scaffold:

  • You can draw with the mouse
  • On right arrow the texture gets created with the key ‘doodle’ and the current texture gets wiped.
  • On arrow left I’m trying to load the old texture back in but to no avail (I’m doing it wrong).

Codepen:
https://codepen.io/abk/pen/LYYraYa?editors=1000

It seems that userCanvas.saveTexture('doodle'); actually changes the texture.key. But what im looking for is creating a distinct texture. Effectively cloning it and loading it back in at a later time. How would you go about implementing this? It feels like it should be done fairly quickly but I’m simply stuck here…

Thanks!

Might be best to create another RenderTexture and then draw one to the other.

1 Like

Ah thanks so much, sometimes its really the simplest solution you can’t think of at the time.

For future ref, working example with one quicksave:
https://codepen.io/abk/pen/oNNyVOb