kampos
-
0.14.4
+
0.14.5
-
Exposes the u_mouse
uniform for use inside fragment shaders.
+
Exposes the u_mouse
uniform for use inside fragment shaders.
+Note that internally the y
coordinate is inverted to match the WebGL coordinate system.
diff --git a/index.umd.js b/index.umd.js
index bda721f..bb0226f 100644
--- a/index.umd.js
+++ b/index.umd.js
@@ -52,6 +52,7 @@
/**
* Exposes the `u_mouse` uniform for use inside fragment shaders.
+ * Note that internally the `y` coordinate is inverted to match the WebGL coordinate system.
*
* @function mouse
* @param {Object} [params]
@@ -78,17 +79,17 @@
},
get position() {
const [x, y] = this.uniforms[0].data;
- return { x, y };
+ return { x, y: 1 - y };
},
set position({ x, y }) {
if (typeof x !== 'undefined') this.uniforms[0].data[0] = x;
- if (typeof y !== 'undefined') this.uniforms[0].data[1] = y;
+ if (typeof y !== 'undefined') this.uniforms[0].data[1] = 1 - y;
},
uniforms: [
{
name: 'u_mouse',
type: 'f',
- data: [initial.x || 0, initial.y || 0],
+ data: [initial.x || 0, 1 - initial.y || 0],
},
],
};
diff --git a/package-lock.json b/package-lock.json
index 77aea11..9dd6f8b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "kampos",
- "version": "0.14.5",
+ "version": "0.14.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "kampos",
- "version": "0.14.5",
+ "version": "0.14.6",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.26.0",
diff --git a/package.json b/package.json
index 1bbd1a5..8789062 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "kampos",
- "version": "0.14.5",
+ "version": "0.14.6",
"description": "Tiny and fast effects compositor on WebGL",
"registry": "https://registry.npmjs.org/",
"main": "dist/index.cjs",
diff --git a/src/utilities/mouse.js b/src/utilities/mouse.js
index 9271223..e43c216 100644
--- a/src/utilities/mouse.js
+++ b/src/utilities/mouse.js
@@ -1,5 +1,6 @@
/**
* Exposes the `u_mouse` uniform for use inside fragment shaders.
+ * Note that internally the `y` coordinate is inverted to match the WebGL coordinate system.
*
* @function mouse
* @param {Object} [params]
@@ -26,17 +27,17 @@ function mouse({
},
get position() {
const [x, y] = this.uniforms[0].data;
- return { x, y };
+ return { x, y: 1 - y };
},
set position({ x, y }) {
if (typeof x !== 'undefined') this.uniforms[0].data[0] = x;
- if (typeof y !== 'undefined') this.uniforms[0].data[1] = y;
+ if (typeof y !== 'undefined') this.uniforms[0].data[1] = 1 - y;
},
uniforms: [
{
name: 'u_mouse',
type: 'f',
- data: [initial.x || 0, initial.y || 0],
+ data: [initial.x || 0, 1 - initial.y || 0],
},
],
};