Using drei HTML is not showing anything
See original GitHub issueI have tried to add html when using react-xr. I am using HTML from drei but cannot get anything to show up.
import React from "react";
import { VRCanvas, DefaultXRControllers } from "@react-three/xr";
import { Html } from "drei";
function App() {
const style = {
heigh: "100px",
width: "100px",
backgroundColor: "red",
};
return (
<div className="App">
<VRCanvas>
<ambientLight intensity={0.5} />
<pointLight position={[5, 5, 5]} />
<mesh position={[1, 1, 1]}>
<Html
prepend
center
fullscreen
scaleFactor={10}
zIndexRange={[100, 0]}
>
<h1 style={style}>hello</h1>
<p>world</p>
</Html>
</mesh>
<DefaultXRControllers />
</VRCanvas>
</div>
);
}
export default App;
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React three fiber Drei HTML Transform mode not working
My parent mesh is imported from GLTF file with "z-up" orientation. So I rotated it -90 degrees. Child component's orientation is dependent to ......
Read more >Position property in drei's Html not working : r/threejs - Reddit
I'm trying to implement an onPointerOver function in my model, where when you select it, a text should be displayed, as this example...
Read more >@react-three/drei - npm
Start using @react-three/drei in your project by running `npm i ... The native route of the library does not export Html or Loader...
Read more >HTML in WebGL With React-Three-Fiber And Drei - YouTube
Our stream overlay gets some more elbow grease in the form of additional features. We work on shifting the chat overlay into our...
Read more >@react-three/drei examples - CodeSandbox
Learn how to use @react-three/drei by viewing and forking @react-three/drei example apps on CodeSandbox.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You can also render textures dynamically by rendering HTML to a canvas using a library like html2canvas, then using that canvas as a texture on a plane.
Here’s an example of how to do that:
Then you can use it like the
DreiHtmlcomponent:It should look something like this:
Hi, drei
Htmlcomponent will not work in VR/AR. It works by adding DOM node over canvas and not in a threejs scene so when you’re in a VR session you only see what is being rendered in 3D scene.If you want to render text in VR I recommend using drei’s
Textcomponent that works in VR/AR