Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display <iframe>s as a texture in A-Frame?

I want to display webpages as 2D content with a VR scene. Can I use an <iframe> element as a source for a texture in WebGL/three.js in https://aframe.io?

like image 250
ngokevin Avatar asked Feb 07 '23 09:02

ngokevin


1 Answers

You can't use iframes or any other HTML element inside WebGL as it would be a security risk. People could read passwords and other private info from the textures.

you can however find creative solutions like this one which is the first hit of googling "iframe webgl".

You do it by putting a iframe behind a webgl canvas, using 3d math cut a hole (draw transparent pixels) where you need the iframe to show through by using a 2d plane that represents the iframe. Then use 3D css to position the iframe element to match the plane.

like image 142
gman Avatar answered Feb 11 '23 00:02

gman