Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Zoom only when mouse is over the globe #67

Open
Zaniyar opened this issue Apr 5, 2017 · 1 comment
Open

Zoom only when mouse is over the globe #67

Zaniyar opened this issue Apr 5, 2017 · 1 comment

Comments

@Zaniyar
Copy link

Zaniyar commented Apr 5, 2017

How can we achieve that the globe only zooms in/out when the mouse is over the globe itself, instead of that the mouse is just over the canvas?

@Zaniyar
Copy link
Author

Zaniyar commented Apr 6, 2017

I solved it in a cheap way, I know otherwise you have to use raycasting (send a ray which goes through the camera and the mouse and then hitTest if the ray collides with the globe):


function onMouseWheel(event) {
        console.log("Mouse X Y :: ", event.x, event.y);

        if (event.x > 720 && event.x < 1180 && event.y > 120 && event.y < 330) {
            event.preventDefault();
            if (overRenderer) {
                zoom(event.wheelDeltaY * 0.3);
            }
        }
        return false;
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant