学習日
8月5日 火曜日
名前
中村 結
✅ 練習問題 4-5-1
function setup() {
createCanvas(600, 400, WEBGL);
}
function draw() {
background(200);
normalMaterial()
push();
translate(0, 0);
rotateX(frameCount * 0.01);
rotateY(frameCount * 0.01);
box(100);
pop();
push();
translate(160, 0,);
rotateX(-frameCount * 0.04);
rotateY(frameCount * 0.04);
box(100);
pop();
}📷 実行結果
立方体が二つになって右は早く回って、二つとも違う方向に回るようになった。
まとめ
push()とpop()は特殊なことをするときに使われる
rotateX()、trotateY()は3Dの立方体を回すときに使うことができる。