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

◇◆丶佛笑我妖孽 提交于 2020-06-27 16:36:05

问题


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?


回答1:


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.




回答2:


No. Currently as a limitation of the browser, <iframe>s can not be displayed within A-Frame, used as a texture, or be mixed with WebGL or WebVR.

While it is possible to overlay an iframe on top of the scene, it won’t display properly in stereoscopic mode (VR) with proper distortion, and it won’t be properly shaded.



来源:https://stackoverflow.com/questions/36290628/how-do-i-display-iframes-as-a-texture-in-a-frame

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!