File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- /*
1+ /**
22 * @name Geometries
33 * @description p5's
44 * <a href="https://p5js.org/reference/#/p5/WEBGL" target="_blank">WEBGL</a>
@@ -38,54 +38,42 @@ function draw() {
3838 // Plane
3939 push ( ) ;
4040 translate ( - 250 , - 100 , 0 ) ;
41- rotateZ ( frameCount ) ;
42- rotateX ( frameCount ) ;
43- rotateY ( frameCount ) ;
41+ rotateWithFrameCount ( ) ;
4442 plane ( 70 ) ;
4543 pop ( ) ;
4644
4745 // Box
4846 push ( ) ;
4947 translate ( - 75 , - 100 , 0 ) ;
50- rotateZ ( frameCount ) ;
51- rotateX ( frameCount ) ;
52- rotateY ( frameCount ) ;
48+ rotateWithFrameCount ( ) ;
5349 box ( 70 , 70 , 70 ) ;
5450 pop ( ) ;
5551
5652 // Cylinder
5753 push ( ) ;
5854 translate ( 100 , - 100 , 0 ) ;
59- rotateZ ( frameCount ) ;
60- rotateX ( frameCount ) ;
61- rotateY ( frameCount ) ;
55+ rotateWithFrameCount ( ) ;
6256 cylinder ( 70 , 70 ) ;
6357 pop ( ) ;
6458
6559 // Cone
6660 push ( ) ;
6761 translate ( 275 , - 100 , 0 ) ;
68- rotateZ ( frameCount ) ;
69- rotateX ( frameCount ) ;
70- rotateY ( frameCount ) ;
62+ rotateWithFrameCount ( ) ;
7163 cone ( 50 , 70 ) ;
7264 pop ( ) ;
7365
7466 // Torus
7567 push ( ) ;
7668 translate ( - 250 , 100 , 0 ) ;
77- rotateZ ( frameCount ) ;
78- rotateX ( frameCount ) ;
79- rotateY ( frameCount ) ;
69+ rotateWithFrameCount ( ) ;
8070 torus ( 50 , 20 ) ;
8171 pop ( ) ;
8272
8373 // Sphere
8474 push ( ) ;
8575 translate ( - 75 , 100 , 0 ) ;
86- rotateZ ( frameCount ) ;
87- rotateX ( frameCount ) ;
88- rotateY ( frameCount ) ;
76+ rotateWithFrameCount ( ) ;
8977
9078 // Show black stroke to help visualize movement
9179 stroke ( 0 ) ;
@@ -95,19 +83,24 @@ function draw() {
9583 // Ellipsoid
9684 push ( ) ;
9785 translate ( 100 , 100 , 0 ) ;
98- rotateZ ( frameCount ) ;
99- rotateX ( frameCount ) ;
100- rotateY ( frameCount ) ;
86+ rotateWithFrameCount ( ) ;
10187 ellipsoid ( 20 , 40 , 40 ) ;
10288 pop ( ) ;
10389
10490 // Astronaut
10591 push ( ) ;
10692 translate ( 275 , 100 , 0 ) ;
93+ rotateWithFrameCount ( ) ;
94+
95+ // Extra rotation to start model in upright position
10796 rotateZ ( 180 ) ;
97+ model ( astronaut ) ;
98+ pop ( ) ;
99+ }
100+
101+ // Rotate 1 degree per frame along all three axes
102+ function rotateWithFrameCount ( ) {
108103 rotateZ ( frameCount ) ;
109104 rotateX ( frameCount ) ;
110105 rotateY ( frameCount ) ;
111- model ( astronaut ) ;
112- pop ( ) ;
113106}
You can’t perform that action at this time.
0 commit comments