# Cant find rendering HTML/iframe in texture

**URL:** <https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159>\
**Category:** Questions\
**Created:** [March 26, 2019, 3:10pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159 "2019-03-26T15:10:46Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 3, 2019, 6:34pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/22 "2019-07-03T18:34:20Z")

</div>

This sounds interesting. I will look at this ready.  
Thank you very much for spending time for me. I appreciate your help.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [July 3, 2019, 7:02pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/23 "2019-07-03T19:02:44Z")

</div>

Any time buddy! That’s what I am here for.

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 3, 2019, 8:39pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/24 "2019-07-03T20:39:23Z")

</div>

I tested with several site. Some site does not pass. I do not really know why.  
French site, with accents returns one \< ? \> in a triangle. There is an encoding problem but I do not know where.  
Otherwise the approach is quite interesting. 😃

There is some thing that I did not quite understand, the translation does not seem correct to me.  
I do not know what means mmmPie UI also. 😗

> [@Pryme8](#):
>
> Now if you combined this with my mmmPie UI canvas engine, you could add hotspots and click callbacks on the canvas which

I did not understand also what you mean by converting the UV of the mesh into a working space. I am a lost here.

> [@Pryme8](#):
>
> If you did a conversion of the UV of the mesh to canvas space you could simulate the actual website interactions in the 3d scene (including scroll)

There too, you lost me. I did not understand to correct some warning. (can be the translation that to be messed up)

> [@Pryme8](#):
>
> Now there are going to be some caveats that you have to fix, like a regEx scrape over the HTML context prior to injecting into the data div to correct image URLS and other things that might not be appearing correctly due to linkages.

It’s really a first for me to do this kind of thing and I have a hard time understanding how it works. Your example makes me understand something, but I do not know how it works, so it’s hard to understand what I’m quoting above.

Thanks again Pryme

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [July 3, 2019, 9:02pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/25 "2019-07-03T21:02:37Z")

</div>

Basically saying you need a way to parse user mouse clicks on the mesh, and get them to “do something” on the page.

I bet you could actually come up with a system that you take a mouse click from the meshes UV coordinates (assuming is a rectangle you are showing this in) and then convert that into pxl coordinates. ID the element at those coordinates on the injected webpage (you will have to calculates offsets from scrolling independently) and then simulate the clicks. If you are in control of the context that is being presented it would be best aka a non external website.

You could use this to have html forms and other things embedded in a game I guess if fully worked out.

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [July 3, 2019, 9:15pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/26 "2019-07-03T21:15:12Z")

</div>

OK, I understand better. This seems really complex to do.

The idea was for each user of metaverse I built, he could put the link of his website to promote it in his world built in 3D. So I can not use an internal web page server and I do not know the structure of the site inject.

This makes this task complex. I do not think I’ll go further with this idea. So I will just create a link on 3D objects that will redirect to the users’ website. It will be an easier solution to achieve.

In any case, thank you Pryme, it’s very nice. Maybe I would find another use with the function that you have offered me that remains very interesting.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [July 3, 2019, 10:32pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/27 "2019-07-03T22:32:04Z")

</div>

Try to see if you can fix the images that are on the pages first.

Do a regex scan over the page and replace the srcs of stuff that are set to non-specific locations.  
Let me see if I can whip that up really quick.

---

<div class="post-metadata">

**Author:** ![Wingnut](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wingnut/32/53_2.png) [@Wingnut](https://forum.babylonjs.com/u/Wingnut)\
**Post date:** [July 3, 2019, 10:50pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/28 "2019-07-03T22:50:06Z")

</div>

regexp-munge or XSL-transform “node-gathering”… won’t collect the x and y coords of WHERE that link will be flow-located in browser canvas. You need some measurements for your “areaMap/isMap” image, right? lots of 'em. Click zones and pic zones. 🙂

How do you gather the coordinates of where a link happens on a rendered webpage… ie. origin 23.5% .left, and 61.9% .top… and how wide and tall is the link/button/image? (click zone range/extends) hmm. 🙂

I deleted my post about the html-to-gui2d converter… but I still stand firmly behind it… I think. heh.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [July 3, 2019, 10:58pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/29 "2019-07-03T22:58:32Z")

</div>

[http://html2canvas.hertzen.com/proxy/](http://html2canvas.hertzen.com/proxy/)

and update the getWebsite.php to:

```auto
<?php
$str_json = file_get_contents('php://input'); 
$data = json_decode($str_json, true);
//echo file_get_contents($data['url']);

$content = file_get_contents($data['url']);

preg_match('/<img[^>]+src="([^">]+)"/', $content, $matches, PREG_OFFSET_CAPTURE);

$offsetTill = 0;

for($i=1; $i<count($matches); $i+=2){
	$str = $matches[$i][0];
	$idx = $matches[$i][1];
	$content = substr_replace($content, $data['url'], $idx+$offsetTill, 0);
	$offsetTill+=count($data['url']);
}

echo $content;
?>

```

Does not fix it on the texture but gets them in the databox at least.

---

<div class="post-metadata">

**Author:** ![Zyad\_Mardini](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zyad_mardini/32/8529_2.png) [@Zyad\_Mardini](https://forum.babylonjs.com/u/Zyad_Mardini)\
**Post date:** [May 19, 2020, 8:44am UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/30 "2020-05-19T08:44:29Z")

</div>

Hello and apologies for the extremely noob post, but i can’t seem to figure out how to implement an iframe simply as a fullscreen overlay over the scene render. I tried to configure the PG by @Dad72 on [https://www.babylonjs-playground.com/#WADD47#50](https://www.babylonjs-playground.com/#WADD47#50) but no luck whatsoever.

Would greatly appreciate your help !

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [May 19, 2020, 11:30am UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/31 "2020-05-19T11:30:16Z")

</div>

I am not the author of this PG.  
What do you want to configure?  
You can modify the URL line 25 to display another html page  
the call ifram line 36  
There is not much to configure.

---

<div class="post-metadata">

**Author:** ![nasimiasl](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nasimiasl/32/34_2.png) [@nasimiasl](https://forum.babylonjs.com/u/nasimiasl)\
**Post date:** [August 29, 2020, 5:58pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/32 "2020-08-29T17:58:46Z")

</div>

hey i start that in old forum  
what configuration you need?

> **[html+webgl](https://www.html5gamedevs.com/topic/30513-htmlwebgl/?tab=comments#comment-175034)**
>
> hy gangs, howve you been? Is it possible to have something like this in babylonjs:

[https://www.babylonjs-playground.com/#1BUXYF#23](https://www.babylonjs-playground.com/#1BUXYF#23)

---

<div class="post-metadata">

**Author:** ![zxcvbs](https://avatars.discourse-cdn.com/v4/letter/z/ecae2f/32.png) [@zxcvbs](https://forum.babylonjs.com/u/zxcvbs)\
**Post date:** [November 1, 2020, 3:08pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/33 "2020-11-01T15:08:00Z")

</div>

Hi, i made this with threejs [Hydra + Threejs - YouTube](https://www.youtube.com/watch?v=wAF9ehMtb94&feature=youtu.be) webgl+css3d, is there any updates on this, on babylon.js? in that example the iframes are loaded as holes through webgl, there is no overlapping, they are fully integrated on the scene.

---

<div class="post-metadata">

**Author:** ![ob1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ob1/32/14632_2.png) [@ob1](https://forum.babylonjs.com/u/ob1)\
**Post date:** [March 10, 2021, 10:03am UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/34 "2021-03-10T10:03:24Z")

</div>

@Pryme8 Hello chaps!

I have stumbled upon this dusscussion after looking for the same, I have used A-Frame in the past and am now looking to move accross to Babylon as it has advantages over ThreeJS that A-Frame uses.

In my A-Frame projects I used [a-frame-htmlembed](https://github.com/supereggbert/aframe-htmlembed-component) and I have been trying to port it to TypeScript and Babylon using [`DynamicTexture`](https://doc.babylonjs.com/divingDeeper/materials/using/dynamicTexture).  
The main class that does the work seems to be [htmlCanvas.js](https://github.com/supereggbert/aframe-htmlembed-component/blob/master/src/htmlcanvas.js) so in a Babylon port we would have `HtmlTexture`.  
So I guess the constructor would be:

```auto
constructor(content: string | HTMLElement, with: number, height: number)

```

Or

```auto
constructor({
  content: string | HTMLElement,
  ...
}, scene) // Other properties?

```

One important and tricky thing will be getting mouse and perhaps even keyboard events working, you would need to use [Vector3.Project](https://doc.babylonjs.com/typedoc/classes/babylon.vector3#project) to project the world units into pixels inside the [Scene.OnPointerDown](https://doc.babylonjs.com/typedoc/classes/babylon.scene#onpointerdown) (et al) events.  
But it is doable.

Perhaps you chaps will be better than me… I only started using Babylon 4 weeks ago, so I don’t have much exp.  
What do you think?

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [March 10, 2021, 5:11pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/35 "2021-03-10T17:11:22Z")

</div>

Sounds promising, I don’t see why you could not do that honestly.

You might need to come up with a “hotspot” system to track what points are actually valid interaction areas, but other then that I don’t see much problem with your idea.

---

<div class="post-metadata">

**Author:** ![ob1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ob1/32/14632_2.png) [@ob1](https://forum.babylonjs.com/u/ob1)\
**Post date:** [March 11, 2021, 3:10pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/36 "2021-03-11T15:10:35Z")

</div>

Just want to share with you my [HtmlTextue experiment on StackBlitz](https://stackblitz.com/edit/babylonjs-htmltexture?file=HtmlTexture.ts).  
I am using `Html2Canvas` which seems to do the job and is a well maintained project so I am happy with using that.  
Need to do some tweaking scale to the mesh perhaps.  
Still more work to do.

> Note the mouse wheel (zoom) and pan are not working on StackBlitz example.

## Update

I am experimenting first with `mousedown`, I cam consruct and dispatch the [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) pretty easy but I cannot get the coordinates quite right.

I have created an absolute 5X5 px div, you can see here where I click on the pane mesh, but in the HTML element space the div is positioned wrongly.

 ![babylon-htmltexture-mousedown](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/b/b15cf44deef5e57d4b87ab3b2870bca43584801f.png)

I wonder if someone might take a look and be able to help or offer ideas.

Thanks

---

<div class="post-metadata">

**Author:** ![owen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/owen/32/9325_2.png) [@owen](https://forum.babylonjs.com/u/owen)\
**Post date:** [July 28, 2021, 4:44pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/37 "2021-07-28T16:44:51Z")

</div>

This is pretty interesting. This would be awesome if it could support HTML based menus inside VR. Does it work with other interactions like scrolling or text input?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 28, 2021, 5:17pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/38 "2021-07-28T17:17:53Z")

</div>

Adding @RaananW

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [July 28, 2021, 5:19pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/39 "2021-07-28T17:19:19Z")

</div>

AR does support it using the DOM Overlays. There is no plan (that i know of) to support this in VR, though it will be a nice feature IMO.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [June 17, 2022, 2:15pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/40 "2022-06-17T14:15:21Z")

</div>

I’ve gotten simulated mouse actions from taking the uv location of the pointer on the mesh then converting that to the pixel location on the HTML page.

We were able to get an entire react menu rendering on a plane in the scene that had all it’s HTML/css animations working.

Now the problem was that it was not efficient and did not work in a real life project but we where passing the html data to a texture each frame and that was intensive.

**Wow just realize this was a Necro post… The forums had pinged me about this thread so I thought someone brought it back up… Wow smh my bad.**

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [June 17, 2022, 3:36pm UTC](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159/41 "2022-06-17T15:36:54Z")

</div>

Well, to me, it simply shows how much dedicated you are. 😇 Replying to an over two years old topic is not something you can find in just every community forum 😁  
Have a great weekend 🕶 🌞

[Previous page](https://forum.babylonjs.com/t/cant-find-rendering-html-iframe-in-texture/2159.md?page=1)
