-
Hi, I wondered if it was possible to combine both scrolling 3d elements with fixed elements? As an example, say I want a 3D logo that is fixed on top of the viewport, how would I go about doing this?
I've looked at the sticky example, but my requirement would be that I can set "position: fixed" on the element. That does not seem to work. Another use case would be an animated gradient background, but with scrolling content on top. That would probably require 2 canvas elements, I'm afraid. Curious to learn what your approach would be, but maybe this is outside of the scope of this library? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @kaspervdm, I think what you want to do is just place children inside the GlobalCanvas - the same way you would do with a vanilla R3F Canvas. You can use the <GlobalCanvas>
<MyPersistentObject />
</GlobalCanvas> And function MyPersistentObject() {
const viewport = useThree(s => s.viewport)
return (
<mesh>
<planeGeometry args={[viewport.width, viewport.height]} />
<meshBasicMaterial color="red" />
</mesh>
)
} You could also use |
Beta Was this translation helpful? Give feedback.
-
Hi @ffdead Is it possible to do this with a different camera? My global canvas camera is a perspective camera, but I also need to render a fixed HUD over the viewport with an orthographic camera. I've tried using the Hud element from Drei, but nothing gets rendered.
The same works fine without r3f-scroll-rig |
Beta Was this translation helpful? Give feedback.
-
@ffdead what is a good way to send |
Beta Was this translation helpful? Give feedback.
Hi @kaspervdm,
I think what you want to do is just place children inside the GlobalCanvas - the same way you would do with a vanilla R3F Canvas. You can use the
size
orviewport
fromuseThree
to size them responsively:And
MyPersistentObject
could fill the entire viewport by doing something like this:You could also use
useScrollbar()
in yourMyPersistentObject
and react to scroll manually…