Correctly convert input coords into scratch coords
This commit is contained in:
parent
019a4c52ed
commit
46b8784217
@ -623,15 +623,19 @@ class RenderWebGL extends EventEmitter {
|
||||
const drawable = this._allDrawables[drawableID];
|
||||
if (!drawable) return null;
|
||||
|
||||
// Convert client coordinates into absolute scratch units
|
||||
const scratchX = this._nativeSize[0] * ((x / this._gl.canvas.clientWidth) - 0.5);
|
||||
const scratchY = this._nativeSize[1] * ((y / this._gl.canvas.clientHeight) - 0.5);
|
||||
|
||||
const gl = this._gl;
|
||||
twgl.bindFramebufferInfo(gl, this._queryBufferInfo);
|
||||
|
||||
const bounds = drawable.getFastBounds();
|
||||
bounds.snapToInt();
|
||||
|
||||
// Translate input x and y to coordinates relative to the drawable
|
||||
const pickX = x - ((this._nativeSize[0] / 2) + bounds.left);
|
||||
const pickY = y - ((this._nativeSize[1] / 2) - bounds.top);
|
||||
// Translate to scratch units relative to the drawable
|
||||
const pickX = scratchX - bounds.left;
|
||||
const pickY = scratchY + bounds.top;
|
||||
|
||||
// Limit size of viewport to the bounds around the target Drawable,
|
||||
// and create the projection matrix for the draw.
|
||||
@ -672,8 +676,8 @@ class RenderWebGL extends EventEmitter {
|
||||
width: bounds.width,
|
||||
height: bounds.height,
|
||||
scratchOffset: [
|
||||
(this._nativeSize[0] / 2) - x + drawable._position[0],
|
||||
(this._nativeSize[1] / 2) - y - drawable._position[1]
|
||||
-scratchX + drawable._position[0],
|
||||
-scratchY - drawable._position[1]
|
||||
],
|
||||
x: pickX,
|
||||
y: pickY
|
||||
|
Loading…
x
Reference in New Issue
Block a user