Giter Site home page Giter Site logo

Comments (9)

PerryRylance avatar PerryRylance commented on May 12, 2024 2

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

from camera-controls.

PerryRylance avatar PerryRylance commented on May 12, 2024 1

@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.

from camera-controls.

yomotsu avatar yomotsu commented on May 12, 2024 1

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

from camera-controls.

PerryRylance avatar PerryRylance commented on May 12, 2024 1

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 :)

from camera-controls.

yomotsu avatar yomotsu commented on May 12, 2024 1

I'll take a look

from camera-controls.

yomotsu avatar yomotsu commented on May 12, 2024 1

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

from camera-controls.

yomotsu avatar yomotsu commented on May 12, 2024

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

from camera-controls.

yomotsu avatar yomotsu commented on May 12, 2024

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

dollyToCursor feature is already available tho

from camera-controls.

Jesusbill avatar Jesusbill commented on May 12, 2024

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

from camera-controls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.