How to render app into custom canvas (div) on website

I’ve created a 3d worldmap with Playcanvas, downloaded the source, put it on a webserver and implemented it to my website using " Serve your own HTML". Works fine! It renders a canvas right before end of body tag.

What I want now is to render the canvas into a specific div that is located im my html structure with a specific size and position (like if I’m using an iframe, but I need it inline to communicate with the elements of the website). How do I control this? Thanks for helping out!

Hi @Karl47,

If you are already rendering the canvas in your webpage, you can easily move it from the end of the body tag to any other element, after it loaded, using Javascript:

By the way, you can still use the iframe solution and easily communicate with your parent window using the postMessage api:

1 Like

Hi @Leonidas,
thank you so much for your quick reply. That helped a lot! It works using:

var my-app = document.getElementById('application-canvas');
1 Like