yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.
https://yomotsu.github.io/camera-controls/
MIT License
2.04k stars 256 forks source link

Screen Space Panning #406

Closed dntpannik closed 1 year ago

dntpannik commented 1 year ago

Is your feature request related to a problem? Please describe.

Hello,

I'm working on a drafting product and in this space the pan functionality doesn't actually move the camera in 3d space in a manner which would cause the perspective of the scene to change. It is more like the scene is a piece of paper on a desk and the pan operation is sliding the piece of paper relative to the camera.

I've attached a video showing the effect I'm going for.

https://user-images.githubusercontent.com/49544387/233508408-30a5f8b6-59f8-4616-8071-1bb4d93181a7.mp4

I am unsure what this effect is called or even how to implement it. If you don't have the time or the interest to add this functionality if someone could maybe give me some ideas how to do it I can try to implement it myself.

Thank you.

Describe the solution you'd like

An additional parameter that allows me to enable/disable this feature. If enabled the pan operation would behave as I've described. If disabled it would behave as it currently does. Alternatively, a separate operation could be added such that both types of panning could be done, similar to zoom/dolly.

Describe alternatives you've considered

I'm unsure of any alternatives.

Additional context

No response

yomotsu commented 1 year ago

I think what you are looking for is offsetX and offsetY of PerspectiveCamera.prototype.setViewOffset() see:

https://threejs.org/examples/?q=css#css3d_sandbox

yomotsu commented 1 year ago

I made a quick example: try dragging with the right mouse button or 2-finger in macOS trackpad https://yomotsu.github.io/camera-controls/examples/view-offset.html

yomotsu commented 1 year ago

Closing due to lack of feedback.