Skip to content

Commit

Permalink
docs(Html): add details about the scaling of Html in transform mode (#…
Browse files Browse the repository at this point in the history
…1702)

* docs: give more info about the size of the Html component in transform mode

Updates the part of the readme about the Html helper in transform mode:
- explains how the size works
- explains the possibility of a blurry rendering on some browsers and gives a possible workaround

* docs: minor changes on the part about the scaling of Html
  • Loading branch information
giusepperaso authored Nov 15, 2023
1 parent 990eae1 commit b2fadaa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,16 @@ Enable shadows using the `castShadow` and `recieveShadow` prop.

> Note: Html 'blending' mode only correctly occludes rectangular HTML elements by default. Use the `geometry` prop to swap the backing geometry to a custom one if your Html has a different shape.

If transform mode is enabled, the dimensions of the rendered html will depend on the position relative to the camera, the camera fov and the distanceFactor. For example, an Html component placed at (0,0,0) and with a distanceFactor of 10, rendered inside a scene with a perspective camera positioned at (0,0,2.45) and a FOV of 75, will have the same dimensions as a "plain" html element like in [this example](https://codesandbox.io/s/drei-html-magic-number-6mzt6m).

A caveat of transform mode is that on some devices and browsers, the rendered html may appear blurry, as discussed in [#859](https://github.com/pmndrs/drei/issues/859). The issue can be at least mitigated by scaling down the Html parent and scaling up the html children:

```jsx
<Html transform scale={0.5}>
<div style={{ transform: "scale(2)" }}>Some text</div>
</Html>
```

#### CycleRaycast

![](https://img.shields.io/badge/-Dom only-red)
Expand Down

1 comment on commit b2fadaa

@vercel
Copy link

@vercel vercel bot commented on b2fadaa Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.