pmndrs / drei

🥉 useful helpers for react-three-fiber

Home Page:https://drei.pmnd.rs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Html component render blurry when using transform attribute on firefox

hyamero opened this issue · comments

  • three version: 0.139.2
  • @react-three/fiber version: 8.0.10
  • @react-three/drei version: 9.4.2
  • node version: 16.13.2
  • yarn version: 1.22.17
  • Firefox Developer Edition version: 100.0b4 (64-bit)

Problem description:

Elements placed into the <Html> component render blurry when using the transform attribute.

Firefox:

image

Edge:

image

Relevant code:

<Html transform>

Also observable in the laptop example
image
image

@wmurphyrd same here on latest chrome, any updates?

I opened my project in Firefox today and it the html components were rendering correctly. Don't know if it's because of the new version 100 or if this issue is intermittent

Still having issues on the drei docs + on my current project
Firefox looks completely broken and chrome blurry

Firefox (broken)

CleanShot 2022-05-07 at 09 27 28

Chrome (blurry)

CleanShot 2022-05-07 at 09 28 02

commented

I just updated from Firefox 99 to Firefox 101 and that fixed the issue for me.

Hi,
same here on input field, HTML component got blur and I don't know why
image
image

commented

This is pretty hacky, but you can scale down the mesh, and then use a CSS transform to scale up the HTML like so :

<mesh
  geometry={nodes['node1'].geometry}
  material={materials['material1']}
  position={[0, 0, 0]}
  scale={0.5}
>
  <Html transform>
    <div className="wrapper" onPointerDown={(e) => e.stopPropagation()}>
      <div
        style={{
          transform: 'scale(2)',
          transformOrigin: 'top left',
        }}
      >
        <h1>This text used to be blurry.</h1>
      </div>
    </div>
  </Html>
</mesh>

Doesn't solve the underlying issue, but you get sharper text (and a slower scene.)

Does anyone have a solution?

Same here. Chrome shows not so clear markup

Hi, same here on input field, HTML component got blur and I don't know why

This isn't necessarily a fix, but I had this same issue and found that it fixes the issue to set these styles on the input:

input {
    caret-color: transparent;
    outline: 0;
}

One or the other on its own doesn't work, not sure why yet.

commented

thanks @leonsbuddydave this finally worked. does this work for non input as well? can we add this to the outer drei/html div?

commented

(It doesn't here, unfortunately --> Chrome)

@drcmda @cptSwing I did some more testing and got a couple recordings. For some reason setting the styles above (caret-color, outline) on just the input keeps the whole HTML object including parents and siblings looking crisp. There are no style changes between these two recordings other than the two style changes on the input.

For me it's only happening when the input is focused with no text selected. Selecting the text in the box or clicking out of the input box makes it sharp again.

No styles applied:
textblur recording-no-styles

Styles applied:
textblur-recording-styles-applied

EDIT: Forgot to mention, this is on Chrome latest (112.0.5615.137) on an M1 Mac

commented

I've fixed the very blurry rendering by applying this to the HTML's wrapperClass:

.html-component-blurriness-hack {
    zoom: 2;
    scale: 0.5;
    transform-origin: top left;
}

EDIT: zoom is only safely supported on Chrome and IE and will always fail on Firefox, to my understanding. Too bad.

Another fix:

<Html scale={0.5}>
    <div style={ { transform: 'scale(2)' } } />
</Html>

As far as I can tell, this will impact performance since the content of HTML is rendered as a texture in browsers and this will upsize-then-downscale the resulting texture?
(see also discussion at three's github: mrdoob/three.js#17641 (comment))

It also appears that as soon as one transforms again, the blockiness reappears, so YMMV

@drcmda https://keithclark.co.uk/articles/gpu-text-rendering-in-webkit/ seems to suggest it's non-integer px values in the transforms?