frame.setResizable(true); in combination with peasycam
in
Contributed Library Questions
•
1 year ago
If you set the frame to resizeable in combination with peasycam then on a frame size change things snap to the left corner. This get's away as soon as you drag the mouse, but this is very ugly.
Also the perspective is very strange after a resize.
Does someone know how it can be fixed. I tried some things and the thing down here is the closest.
- import peasy.*;
- PeasyCam cam;
- void setup() {
- size(200, 200, P3D);
- cam = new PeasyCam(this, 100);
- cam.setMinimumDistance(50);
- cam.setMaximumDistance(500);
- frame.setResizable(true);
- registerPre(this);
- }
- void pre() {
- if (width != frame.getWidth() || height != frame.getHeight()-22) {
- float[] rot = cam.getRotations();
- size(frame.getWidth(), frame.getHeight()-22, P3D);
- cam.reset();
- cam.rotateX(-rot[0]);
- cam.rotateY(-rot[1]);
- cam.rotateZ(-rot[2]);
- }
- }
- void draw() {
- rotateX(-.5);
- rotateY(-.5);
- background(0);
- fill(255, 0, 0);
- box(30);
- pushMatrix();
- translate(0, 0, 20);
- fill(0, 0, 255);
- box(5);
- popMatrix();
- }
1