you can try this
import { Behaviour } from "@needle-tools/engine";
import { screenshot } from "@needle-tools/engine/engine/engine_utils_screenshot"
export class TakeAScreenshot extends Behaviour {
start(): void {
const data = screenshot(this.context, 1024, 512);
if (typeof data === "string")
{
var a = document.createElement("a"); //Create <a>
a.href = "data:image/png;base64," + data; //Image Base64 Goes here
a.download = "Image.webp"; //File name Here
a.click(); //Downloaded file
}
}
}