Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTMLMesh rendering issues #15788

Closed
PSI497 opened this issue Oct 25, 2024 · 2 comments
Closed

HTMLMesh rendering issues #15788

PSI497 opened this issue Oct 25, 2024 · 2 comments
Assignees

Comments

@PSI497
Copy link

PSI497 commented Oct 25, 2024

Hey,

First off, the HTMLMesh extension is amazing and really simple to use. I've been battling two small, but annoying rendering issues with the library:

  1. as other people, for example HtmlMesh Renders Incorrectly When Browser Window is Resized Extensions#304 have pointed out, when resizing the window, the html meshes do not resize correctly. I ended up using a different workaround to what's mentioned in the linked issue, I basically disabled the resize logic in the extension ( line: (window as Window).addEventListener("resize", boundOnResize);), and I apply my own resizing logic from outside, by calling this.htmlMeshRenderer.setSize(window.innerWidth, window.innerHeight) when the window is resized. The benefit over the solution in 304 is that there's no lag when resizing the window, the html mesh is sized correctly immediately on the next render.

Wouldn't it be helpful if we could provide an option to the HtmlMeshRenderer and allow updating the size from the outside, optionally?

  1. there's a rounding error causing a white border around the meshes.

image

My scene is very dark with a black background, so this becomes very pronounced. I think this might be a rounding issue somewhere during the scaling. I found two hacky ways to solve this if anyone wants to resolve the issue, one option is modifying this line in the html-mesh.ts createMask function:

from

protected createMask() {
const vertexData = CreatePlaneVertexData({ width: 1, height: 1 }); // BJS 5
to

protected createMask() {
const vertexData = CreatePlaneVertexData({ width: 0.99, height: 0.99}); // BJS 5

or, alternatively, to change the sizing in fit-strategy.ts:|

from
sizingElement.style.width = ${width}px;
sizingElement.style.height = ${height}px;

to
sizingElement.style.width = ${width*1.01}px;
sizingElement.style.height = ${height*1.01}px;

This hack basically crops the iframe a tiny bit so the white lines won't show from the mask. Obviously, this hack is only useful if you're fine with cropping a couple pixels of your website in the iframe. I'm wondering where the rounding issue is coming from, if anyone finds a better solution please let me know!

@RaananW
Copy link
Member

RaananW commented Oct 28, 2024

cc @ericwood73

@deltakosh deltakosh transferred this issue from BabylonJS/Extensions Nov 7, 2024
@deltakosh
Copy link
Contributor

@PSI497 Hey as you can see we are giving the VIP treatment to HtmlMesh
Wanna do a PR to fix your 2 concerns?

@deltakosh deltakosh self-assigned this Nov 7, 2024
deltakosh added a commit that referenced this issue Nov 8, 2024
deltakosh added a commit that referenced this issue Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants