xxxxxxxxxx
//box横断歩道
function setup() {
createCanvas(600, 600,WEBGL);
camera(0,-300,(height/2.0)/
tan(PI*30.0/180.0),0,0,0,0,1,0);
ortho(-width/2,width/2,-height/2,height/2,1,1200);
}
function draw() {
background(255);
rotateY(radians(45)); //回転させる
push();
//座標の記憶
translate(0,71,0);
//原点の移動継続
rotateY(radians(90)); //回転させる
rotateX(radians(90));
noStroke();
fill(128);
plane(400,2000);
translate(0,0,1);
for (var i=0;i<7;i++)
//()内の命令が繰り返し・変数iが使える
// var使い方 ↓
//var i=0(0から開始)、i<=100(100まで終了)
//i=i+10 (10ずつ増える変化)
{
push(); //移動、回転する前の座標状態の
translate(0,-600-(frameCount%200)+i*200,0);
//原点の移動・継続的に維持・図形をまとめて移動できる
fill(255);
plane(410,40);
pop(); //座標の復元・直前の座標の状態に戻す
//z票の変な移動が起きないようにpush,popではさむ◎
}
pop();
push();
stroke(255);
fill(192);
strokeWeight(4);
push();
translate(-20,0,-50);
rotateZ(-frameCount/75);
box(100,100,100,);
pop();
push();
translate(-300,0,80);
rotateZ(radians(45)-frameCount/75);
box(100,100,100);
pop();
push();
translate(250,0,10);
rotateZ(radians(45)-frameCount/75);
box(100,100,100);
pop();
}
p5.RendererGL: enabled webgl context