Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved the issue with Pan y-axis inverted in frameBuffer. #6545

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

perminder-17
Copy link
Contributor

@perminder-17 perminder-17 commented Nov 9, 2023

@perminder-17
Copy link
Contributor Author

I am not entirely sure if this was supposed to be done here. @davepagurek

@davepagurek
Copy link
Contributor

I believe now it's inverted if you aren't using a framebuffer:

let layer;
function setup() {
  createCanvas(400, 400, WEBGL);
  layer = createFramebuffer();
}

function draw() {
  // layer.begin();
  orbitControl();
  background(220);
  sphere(150);
  // layer.end();
  // image(layer,-width/2,-height/2)
}

I think rather than multiplying by -1, we should be multiplying by the yScale property of the active camera, which will be -1 for framebuffers but 1 for the main canvas camera.

@@ -229,7 +229,7 @@ p5.prototype.orbitControl = function(
deltaPhi = sensitivityY * this.movedY / scaleFactor;
} else if (this.mouseButton === this.RIGHT) {
moveDeltaX = this.movedX;
moveDeltaY = (this.movedY * -1);
moveDeltaY = (this.movedY * (cam.projMatrix.mat4[5] < 0 ? 1 : -1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for accessing the projection matrix rather than using cam.yScale?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i just confused with the y-scale. now i have done the changes. it's working fine as you told

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess both have the same sign?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think the yScale value is used in creating the projection matrices. In the end I think they should be equivalent, but it's maybe just more readable to see a value like yScale than an index into a matrix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Got it now. Thanks

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works, although we probably could remove the brackets for legibility. Just to confirm, is your sketch updated with the latest version of the code? The sketch seems to work well

@perminder-17
Copy link
Contributor Author

I think this works, although we probably could remove the brackets for legibility. Just to confirm, is your sketch updated with the latest version of the code? The sketch seems to work well

yes..my code is up to date

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good then, thanks!

@perminder-17
Copy link
Contributor Author

Thank you for catching mistakes. I decided to use a projection matrix because it was working, and I just thought if yscaling cause any issues further.

@davepagurek davepagurek merged commit 8e97213 into processing:main Nov 9, 2023
2 checks passed
@perminder-17 perminder-17 deleted the mousebug branch November 9, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pan y-axis inverted in frameBuffer
2 participants