Skip to content

Commit 64b0dbd

Browse files
authored
revert changes in environment.js
1 parent 03270d4 commit 64b0dbd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/core/environment.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,28 +1314,26 @@ function environment(p5, fn, lifecycles){
13141314
*
13151315
*/
13161316
fn.screenToWorld = function(screenPosition) {
1317-
1318-
let origDimension = (typeof screenPosition === 'number')
1319-
? arguments.length
1320-
: screenPosition._origDimension;
1321-
13221317
if (typeof screenPosition === 'number') {
13231318
// We got passed numbers, convert to vector
13241319
screenPosition = this.createVector(...arguments);
13251320
}
13261321

13271322
const matrix = this._renderer.getWorldToScreenMatrix();
1328-
if (origDimension === 2) {
1323+
1324+
if (screenPosition.dimensions === 2) {
13291325
// Calculate a sensible Z value for the current camera projection that
13301326
// will result in 0 once converted to world coordinates
13311327
let z = matrix.mat4[14] / matrix.mat4[15];
13321328
screenPosition = this.createVector(screenPosition.x, screenPosition.y, z);
13331329
}
13341330

13351331
const matrixInverse = matrix.invert(matrix);
1336-
return matrixInverse.multiplyAndNormalizePoint(screenPosition);
1337-
};
13381332

1333+
const worldPosition = matrixInverse
1334+
.multiplyAndNormalizePoint(screenPosition);
1335+
return worldPosition;
1336+
};
13391337

13401338
/**
13411339
* A `Number` variable that stores the width of the canvas in pixels.

0 commit comments

Comments
 (0)