mvilledieu / shadertoy-react

6kB "Shadertoy" like react component letting you easily render your fragment shaders in your React web projects, without having to worry about implementing the WebGL part.
https://codesandbox.io/s/434qm4x4w0
MIT License
124 stars 12 forks source link

the calculation of “iMouse.y” is wrong #44

Open Swampert-zhi opened 1 year ago

Swampert-zhi commented 1 year ago

I find that the y component of property "iMouse" is wrong.

In the callback function of “mouseMove” and "mouseDown", the code is

# mouseMove
var mouseY = _this.canvasPosition.height - clientY - _this.canvasPosition.top - window.pageYOffset;
# mouseDown
var mouseY = _this.canvasPosition.height - clientY - _this.canvasPosition.top;

it should be

# mouseMove
var mouseY = _this.canvasPosition.height - clientY + _this.canvasPosition.top - window.pageYOffset;
# mouseDown
var mouseY = _this.canvasPosition.height - clientY + _this.canvasPosition.top;