Hello forum
I’ve run into an unexpected exception while trying to rotate a PShape in the Z axis, even though it works fine in the X and Y axis. Has anyone else gotten this problem? It only started happening after installing 3.5 (3.5.1 and 3.5.2)
I believe this code used to work fine
PShape shape;
void setup(){
size(500,500,P3D);
shape = createShape(SPHERE,50);
}
void draw(){
background(100);
fill(255);
noStroke();
shape.rotateX(.2);
println("success X");
shape.rotateY(.2);
println("success Y");
shape.rotateZ(.2);
println("success Z");
translate(width/2.0,height/2.0);
shape(shape);
}
the exception:
ClassCastException: processing.core.PMatrix3D cannot be cast to processing.core.PMatrix2D
2 Likes
Oddly enough, I ran another sketch and used rotateZ by itself and it works fine, the behavior seems to be limited to PShape’s rotateZ function…
Seems like a nasty bug that should be reported to github!
2 Likes
glv
June 18, 2019, 4:21pm
4
I ran into this issue as well with some old code (see last post):
PShape rotations and translations…
Workaround for P3D:
// s2.rotate(heading); // Generates error in Processing 3.5.3
s2.rotate(heading, 0, 0, 1); // Workaround for P3D
I also tried P2D and some rotations were not correct for PShapes.
Workaround for P2D:
s2.translate(-10, -10);
s2.rotate(heading);
shape(s2, v1.x, v1.y);
// s2.resetMatrix(); // Shapes no longer rotating correctly!
s2.rotate(-heading); // Workaround for P2D Rotated back...
s2.translate(10, 10); // Workaround for P2D Translated back..
Also box() in P2D did not display with console message “box() is not available with this renderer.”
Fix:
// box(20, 20, 0); // Does not display in P2D with console message
rect(-10, -10, 20, 20); // Works in P2D!
1 Like