Skip to content

Mixing scrolling content with fixed content #30

Answered by ffdead
kaspervdm asked this question in Q&A
Discussion options

You must be logged in to vote

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 or viewport from useThree to size them responsively:

<GlobalCanvas>
   <MyPersistentObject />
</GlobalCanvas>

And MyPersistentObject could fill the entire viewport by doing something like this:

function MyPersistentObject() {
    const viewport = useThree(s => s.viewport)
    return (
        <mesh>
            <planeGeometry args={[viewport.width, viewport.height]} />
            <meshBasicMaterial color="red" />
        </mesh>
    )
}

You could also use useScrollbar() in your MyPersistentObject and react to scroll manually…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ffdead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #18 on October 11, 2023 07:53.