Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I expect have a controls can support zoomed and rotated with the current mouse position in screen #100

Closed
liuyehua opened this issue Jun 9, 2020 · 9 comments

Comments

@liuyehua
Copy link

liuyehua commented Jun 9, 2020

such as navisworks viewer behavior。。。

@liuyehua liuyehua changed the title I expect have a controls can support zoomed and rotated with the camera position I expect have a controls can support zoomed and rotated with the current camera position in screen Jun 9, 2020
@liuyehua liuyehua changed the title I expect have a controls can support zoomed and rotated with the current camera position in screen I expect have a controls can support zoomed and rotated with the current mouse position in screen Jun 9, 2020
@yomotsu
Copy link
Owner

yomotsu commented Jun 10, 2020

Hi liuyehua,
Sorry, I don't get your point. Could you explain that in more detail, please?

@PerryRylance
Copy link

@yomotsu I think he might be asking about zooming in on the mouse pointer, which is what I'm also here to ask about.

Is there any way to get the camera to zoom (and translate) about the mouse pointer on mousewheel, rather than about the center of the screen?

A bit like how Google Maps' zoom works.

Great camera, by the way.

@yomotsu
Copy link
Owner

yomotsu commented Jul 1, 2020

I see, thanks!
I started working on it at #103

dollyToCursor feature is already available tho

@Jesusbill
Copy link
Contributor

@yomotsu what is the difference between dolly and zoom? I already use dollyToCursor to zoom to mouse cursor.

@yomotsu
Copy link
Owner

yomotsu commented Jul 2, 2020

See here. I personally prefer using dolly too!
https://github.com/yomotsu/camera-controls#dolly-vs-zoom

@PerryRylance
Copy link

@Jesusbill dolly to cursor isn't as useful for orthographic cameras

@PerryRylance
Copy link

So, I've got the following code, which I've run the numbers on and it will work, however for some reason the camera moves in a very unpredictable way when I add this to zoomInternal

var zoomTowards = {
	x: _this._camera.left + (x / window.innerWidth)  * (_this._camera.right - _this._camera.left),
	y: _this._camera.top  + (y / window.innerHeight) * (_this._camera.bottom - _this._camera.top)
};

var center = {
	x: _this._camera.left + (_this._camera.right - _this._camera.left) / 2,
	y: _this._camera.top  + (_this._camera.bottom - _this._camera.top) / 2
};

var position = new THREE.Vector3(
	center.x + ((zoomTowards.x - center.x) * zoomScale), 
	center.y + ((zoomTowards.y - center.y) * zoomScale), 
	0
);

this.moveTo(position.x, position.y, this._camera.position.z);

Am I doing something wrong here in terms of interacting with your code @yomotsu ?

Thank you again for your time in this :)

@yomotsu
Copy link
Owner

yomotsu commented Aug 9, 2020

I'll take a look

@yomotsu
Copy link
Owner

yomotsu commented Jul 13, 2022

Closing this issue.
Zoom-to-cursor for orthographic has been implemented:
https://yomotsu.github.io/camera-controls/examples/orthographic.html

@yomotsu yomotsu closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants