To ensure that the new skin is fully rendered before extracting the image, you can use a combination of requestAnimationFrame
to wait for the next frame where the rendering is complete. Here is an example of how you can achieve this:
sack.skeleton.setSkin(item);
sack.skeleton.setSlotsToSetupPose();
// Wait for the next frame to ensure rendering is complete
requestAnimationFrame(async () => {
const base = await app.renderer.extract.base64();
console.log(base); // This will log the base64 image data of the new skin
});
This approach ensures that the rendering process has completed before you attempt to extract the image from the canvas.