Skip to content

Commit

Permalink
Offset fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Dec 29, 2023
1 parent 2c23a69 commit ee0f1fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions example/src/GlobeControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const DRAG = 1;
const ROTATE = 2;
const ZOOM = 3;

const ACTION_THRESHOLD = 2 * window.devicePixelRatio;

const _matrix = new Matrix4();
const _rotMatrix = new Matrix4();
const _delta = new Vector3();
Expand All @@ -36,6 +34,7 @@ const _newPointer = new Vector2();
// - Consider using sphere intersect for positioning
// - Toggles for zoom to cursor, zoom forward, orbit around center, etc?
// - provide fallback plane for cases when you're off the map
// - consider enabling drag with zoom

// helper function for constructing a matrix for rotating around a point
function makeRotateAroundPoint( point, quat, target ) {
Expand All @@ -55,8 +54,10 @@ function makeRotateAroundPoint( point, quat, target ) {
// get the three.js pointer coords from an event
function mouseToCoords( clientX, clientY, element, target ) {

target.x = ( clientX / element.clientWidth ) * 2 - 1;
target.y = - ( clientY / element.clientHeight ) * 2 + 1;
console.log( element.offsetLeft );

target.x = ( ( clientX - element.offsetLeft ) / element.clientWidth ) * 2 - 1;
target.y = - ( ( clientY - element.offsetTop ) / element.clientHeight ) * 2 + 1;

}

Expand Down

0 comments on commit ee0f1fb

Please sign in to comment.