Skip to content

Meaning and usage of viewport, size, aspect, and mouse #857

Answered by drcmda
mattrossman asked this question in Q&A
Discussion options

You must be logged in to vote

viewport is screen width/height in three units. the following would fill the entire screen:

const { viewport } the  = useThree()
return (
  <mesh scale={[viewport.width, viewport.height, 1]}>
    <planeBufferGeometry />

size is the size in pixels of the dom container-

aspect is just some thing that's necessary for the internal cameras, if you had your own camera you would need to calculate it yourself. i don't know what it is for but i take it some people do - after all they did use it in all of their projects before r3f.

mouse are centered, normalized coordinates. -1 is left/top side, 0 middle, 1 is right/bottom side

distance how far the camera is away from center point.

you can edit the…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
1 reply
@mattrossman
Comment options

Answer selected by mattrossman
Comment options

You must be logged in to vote
7 replies
@drcmda
Comment options

@mattrossman
Comment options

@drcmda
Comment options

@mattrossman
Comment options

@pedroalmeida415
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants