Create Collisions along viewport edges #373
Unanswered
MrUltimate
asked this question in
Q&A
Replies: 1 comment
-
Hey MrUltimate! I already shared this with you on the discord, but for others coming across this question, you can achieve this with the e.g. function Plane({ color, ...props }) {
usePlane(() => ({ ...props }))
return null
}
function Borders() {
const { viewport } = useThree()
return (
<>
<Plane position={[0, -viewport.height / 2, 0]} rotation={[-Math.PI / 2, 0, 0]} />
<Plane position={[-viewport.width / 2 - 1, 0, 0]} rotation={[0, Math.PI / 2, 0]} />
<Plane position={[viewport.width / 2 + 1, 0, 0]} rotation={[0, -Math.PI / 2, 0]} />
<Plane position={[0, 0, -1]} rotation={[0, 0, 0]} />
<Plane position={[0, 0, 12]} rotation={[0, -Math.PI, 0]} />
</>
)
} Check out this codesandbox for an example: https://codesandbox.io/s/ballpit-mvkqs |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Is there a programmatic way in which I can create collisions along the 4 edges of the viewport (aka browser window)?
I'm currently having to estimated values which isn't quite responsive:
Beta Was this translation helpful? Give feedback.
All reactions