HTMLMESH. Replacing mesh with htmlMesh

Hi! I would like to ask how you can make an htmlMesh by replacing some kind of mesh. What I mean is, for example, we have a parent-monitor mesh. The monitor mesh has a child (a separate mesh “monitor screen”, I would like to create an htmlMesh to replace this mesh “monitor screen” with my htmlMesh. When replacing it, I want it to become instead of a mesh of the “monitor screen” and in width, height, position and 1 in 1 as well as a mesh of the screen As best

Hi. Here is the example how you can do this: Babylon.js Playground

3 Likes
Here, setContent sets the grid size. Is it possible to get this size from the mesh? So that it's 1:1?

Yes, after importing your model select your screen mesh and use its bounding box info to calculate its size.

You can use minimum and maximum like I showed in the example or just double the extend size like so:

const {x: yourMeshWidth, y: yourMeshHeight} = yourScreenMesh.getBoundingInfo().boundingBox.extendSize.scale(2)

then use those calculated width and height values to set the size of html mesh: htmlScreen.setContent(iframeSite, yourMeshWidth, yourMeshHeight)

If it still does not work for you feel free to share your mesh in the playground it will be easier to show on your mesh.