mirror of
				https://github.com/KevinMidboe/cubewaves.git
				synced 2025-10-29 17:40:17 +00:00 
			
		
		
		
	Moving ortho plane of cubes.
This commit is contained in:
		| @@ -1,31 +1,33 @@ | |||||||
| let angle = 0; | let angle = 0; | ||||||
| let w = 24; | let w = 24; | ||||||
|  | let ma; | ||||||
|  |  | ||||||
| function setup() { | function setup() { | ||||||
|    createCanvas(400, 400, WEBGL); |    createCanvas(400, 400, WEBGL); | ||||||
|  |    ma = atan(1 / sqrt(2)) | ||||||
| } | } | ||||||
|  |  | ||||||
| function draw() { | function draw() { | ||||||
|    background(175); |    background(100); | ||||||
|    ortho(); |    ortho(-300, 300, 300, -300, 0, 600); | ||||||
|    directionalLight(255, 255, 255, 0, -1, 0); |  | ||||||
|  |  | ||||||
|    translate(0, 50, -50); |  | ||||||
|    rotateX(PI / 8); |  | ||||||
|  |  | ||||||
|    rectMode(CENTER); |    rotateX(-QUARTER_PI); | ||||||
|  |    rotateY(ma); | ||||||
|  |  | ||||||
|    let offset = 0; |    let offset = 0; | ||||||
|    for (let x = 0; x < width; x += w) { |    for (let z = 0; z < height; z += w) { | ||||||
|       push(); |       for (let x = 0; x < width; x += w) { | ||||||
|       let a = angle + offset; |          push(); | ||||||
|       let h = map(sin(a), -1, 1, 0, 100); |          let a = angle + offset; | ||||||
|       translate(x - width / 2, 0, 0); |          let h = map(sin(a), -1, 1, 0, 100); | ||||||
|       ambientMaterial(255); |          translate(x - width / 2, 0, z - height / 2); | ||||||
|       box(w, h, w); |          normalMaterial(); | ||||||
|       //rect(x - width / 2 + w / 2, 0, w - 2, h); |          box(w - 2, h, w - 2); | ||||||
|  |          //rect(x - width / 2 + w / 2, 0, w - 2, h); | ||||||
|  |          pop(); | ||||||
|  |       } | ||||||
|       offset += 0.1; |       offset += 0.1; | ||||||
|       pop(); |  | ||||||
|    } |    } | ||||||
|  |  | ||||||
|    angle += 0.1; |    angle += 0.1; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user