Skip to content

Commit e973b84

Browse files
authored
Modify screenToWorld to handle argument count
1 parent 763bde2 commit e973b84

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/core/environment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,14 +1316,14 @@ function environment(p5, fn, lifecycles){
13161316
fn.screenToWorld = function(screenPosition) {
13171317
// remember how many components the caller actually provided to createVector
13181318
const origDimension = this.dimension;
1319-
1319+
const screenToWorldArgs = arguments.length;
13201320
if (typeof screenPosition === 'number') {
13211321
// We got passed numbers, convert to vector
13221322
screenPosition = this.createVector(...arguments);
13231323
}
1324-
1324+
13251325
const matrix = this._renderer.getWorldToScreenMatrix();
1326-
if (origDimension === 2) {
1326+
if (origDimension === 2 || screenToWorldArgs === 2) {
13271327
// Calculate a sensible Z value for the current camera projection that
13281328
// will result in 0 once converted to world coordinates
13291329
let z = matrix.mat4[14] / matrix.mat4[15];

0 commit comments

Comments
 (0)