Draw Texture object on DynamicTexture

I want to do this:

drawImage(dynamicTexture: DynamicTexture, texture: Texture) {
  const ctx = dynamicTexture.getContext();
  ctx.drawImage(texture.???, 0, 0);

drawImage takes a https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource

how can I do this without loading the image url again?

You cannot unfortunately :frowning:

the Canvas2D needs CPU data and not GPU data. You can download again it will be almost free thanks to the browser cache

https://www.babylonjs-playground.com/#10KKS5#5 with just a slight blip


awesome, that looks like exactly what I needed.

For anyone looking, this is how you can use drawImage as well:

const pixeldata = texture.readPixels() as any;
const arr = new Uint8ClampedArray(pixeldata);
const imageData = new ImageData(arr, texture.getSize().width, texture.getSize().height);

createImageBitmap(imageData).then(bitmap => {
  const ctx = dynamicTexture.getContext();
  ctx.drawImage(image, x, y, w, h);