Skip to content

Commit b488e12

Browse files
committed
added sphere and reset, edited text
1 parent 151d745 commit b488e12

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/data/examples/en/20_3D/12_simple_feedback.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,32 @@ let pg, swap;
99
function setup() {
1010
createCanvas(710, 400);
1111

12-
// this will hold our main graphic
13-
pg = createGraphics(710, 400, WEBGL);
1412
// this will hold the previous frame
13+
pg = createGraphics(710, 400, WEBGL);
14+
// this will hold our main graphic
1515
swap = createGraphics(710, 400, WEBGL);
1616

1717
describe(
18-
'a WebGL example that achieves a simple feedback effect, displaying a slowly moving, radiating white circle.'
18+
'a WebGL example that achieves a simple feedback effect, displaying a slowly moving, radiating white sphere.'
1919
);
2020
}
2121

2222
function draw() {
2323
// draw the previous frame
2424
pg.texture(swap);
25-
pg.noStroke();
25+
pg.noStroke();
2626
pg.plane(width, height);
2727

28-
// draw our circle graphic on top
28+
// p5.Graphics sometimes requires us to use reset() before drawing
29+
pg.reset();
30+
31+
// draw our sphere on top
32+
pg.push();
33+
// slowly move the sphere in a circle
34+
pg.translate(sin(millis() / 200) * 5, cos(millis() / 200) * 5, 0);
2935
pg.fill(255);
30-
pg.ellipse(Math.sin(millis()/200)*5, Math.cos(millis()/200)*5, 150, 150);
36+
pg.sphere(90);
37+
pg.pop();
3138

3239
// draw a slightly scaled up copy of the texture
3340
swap.push();

0 commit comments

Comments
 (0)