question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OrbitControls - Zoom to cursor

See original GitHub issue

Related problem

Is your feature request related to a problem? Please describe. We’re working on a Sigma style editor for electrical engineering and PCB design. Navigating within a design by zooming is a big part of our application. The current zoom controls always force the user to pan and then to zoom. This is a sub-optimal experience

Solution

Describe the solution you’d like

Zoom to cursor allows you to zoom a screen to the current position of the cursor. The movement is a combination of pan and zoom. The cursor stays during the entire operation at the same position and the scene zooms in around the objects of the cursor. The behaviour is the same as it is implemented in Google Maps web interface in 3D view or Apple’s macOS Maps app in 3D view for zooming IN and OUT.

Describe alternatives you’ve considered

We have hacked the zoom to cursor in the OrthographicCamera and are looking to have a better version that also supports the PerspectiveCamera in the main repo. You can find the solution in https://github.com/buildwithflux/three-orbitcontrols/blame/master/OrbitControls.js when looking. for the commit Zoom to cursor.

API spec proposal

There are different ideas on how the API interface for this functionality could look like.

Proposal 1

zoomToCursor: Bool - Requires enableZoom to be set to true as a prerequisite. When true, changes the zoom mode from the center of the scene to zooming to the cursor.

Proposal 2 - preferred

zoomMode: Enum { .center, .cursor } - Defines the zoom mode of the enableZoom flag. .center behaves like existing zoom functionality while .cursor allows for zooming to the cursor. Default: .center.

Personal opinion: I prefer proposal 2, as it will play nice with the “Zoom to objects” proposal and other future zoom functionality as well. Maintaining multiple booleans where the behavior is not clear defined is always messy.

Tasks

References Google Maps 3D view with zoom to cursor Screen Shot 2021-09-10 at 12 36 22 PM

Implementation plan

We aim to implement this feature ourselves. We’re filing a GitHub issue to be able to communicate about the implementation details with the projects core maintainers.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

3reactions
looeeecommented, Sep 23, 2021

@philippb you can also check out yomotsu/camera-controls which has zoom to cursor.

2reactions
philippbcommented, Sep 10, 2021

@Mugen87 Thanks, I didn’t see that. How do you think we can help best getting this to a state that is where i can be merged in? The linked PR has been open for 2 years. We’re happy to help getting this over the finish line or just to make a clean version from scratch. Your guidance is appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

three js zooming in where the cursor is using orbit controls
I'm very new to three js and is currently trying to implement a feature where the user can zoom in ...
Read more >
threejs zoom to cursor
OrbitControls.ts. fitAll.ts. index.tsx. styles.css. package.json. tsconfig.json. Dependencies. @react-spring/three. 9.0.0-rc.3 (9.0.0-rc.3).
Read more >
How to zoom in where the mouse pointer is with the help ...
Hello Three js Team, I am looking for a way to zoom in to where the cursor pointer is by default it is...
Read more >
Three.JS Orbit Controls: Zoom, Pan, Rotate [Checkers 1]
Let's see how to use Three.JS orbit controls to zoom, pan and rotate a model. The Orbit Controls are an optional add-in available...
Read more >
Extend three.js With a Camera Controls Plugin
Here, we extend the three.js core with a camera controls plugin called OrbitControls. This plugin allows us to rotate/pan/zoom to the camera to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found