2

I am trying to create a situation where the camera is fixed and you can rotate the view around the y or axis by dragging your mouse.

Something similar to threejs.org/examples/?q=panorama#webgl_panorama_cube . But I should be able to manouvre within an object.

I tried using drei but could only succeed with PointLockControls and OrbitControls which are both not helpful since you cannot enable the cursor with PointLockControls and you cannot fix the camera position with orbit controls.

A small example in codesandbox would be super helpful. Thanks a lot!

2
  • You could always take a look at : codesandbox.io/… Commented Sep 28, 2021 at 19:43
  • Please provide enough code so others can better understand or reproduce the problem. Commented Oct 6, 2021 at 8:05

1 Answer 1

2

That example uses OrbitControls and keeps the camera in place by disabling zoom and panning. You can also restrict rotation to the Y axis by setting its min and max polar angles.

Drei's OrbitControls accepts properties, where you can directly set these options.

<OrbitControls
  enableZoom={false}
  enablePan={false}
  minPolarAngle={Math.PI / 2}
  maxPolarAngle={Math.PI / 2}
/>

This is a vanilla implementation, but the API is the same.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this is helpful! But this codepen.io/mjurczyk/pen/gOwbMVr was more what I was after! Leaving this here for reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.