• Runtimes
  • How can I get the new img of the new skin after setSlotsToSetupPose() ?

ts-runtime: pixi
I want to transform canvas into img after setSlotsToSetupPose(), but funtion setSlotsToSetupPose takes times to render the new skin. So the content of img shows nothing if rendering does not finish after setSlotsToSetupPose().
Q: How can I get the new img of the new skin after setSlotsToSetupPose() ?

sack.skeleton.setSkin(item)
sack.skeleton.setSlotsToSetupPose()
const img = await app.renderer.extract.base64()

Related Discussions
...

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.