diff --git a/Gruntfile.js b/Gruntfile.js index 03399b29d3..eb28ec39f3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -157,6 +157,7 @@ module.exports = function(grunt) { browserify: { p5: { options: { + transform: ['brfs'], browserifyOptions: { standalone: 'p5' }, diff --git a/examples/3d/center_origin/index.html b/examples/3d/center_origin/index.html new file mode 100644 index 0000000000..92e08b1696 --- /dev/null +++ b/examples/3d/center_origin/index.html @@ -0,0 +1,21 @@ + + +
+ + +[0, 0, 0] is in the center of the screen by default
+ + + + diff --git a/examples/3d/center_origin/sketch.js b/examples/3d/center_origin/sketch.js new file mode 100644 index 0000000000..d88e202574 --- /dev/null +++ b/examples/3d/center_origin/sketch.js @@ -0,0 +1,29 @@ +function setup(){ + createCanvas(windowWidth, windowHeight, 'webgl'); +} + +function draw(){ + + background(255); + + translate(0, 0, -800); + rotateY(frameCount * 0.01); + + var gap = 200; + var w = 100; + var h = 100; + + for(var i = -2; i < 3; i++){ + for(var j = -2; j < 3; j++){ + fill( (i+2) * 40, (j+2) * 40, 0); + quad( + i * gap, j * gap, 0, + i * gap + w, j * gap, 0, + i * gap, j * gap + h, 0, + i * gap + w, j * gap + h/2 * (sin(frameCount * 0.1 + i + j) + 1), 0 + ); + } + } + + +} \ No newline at end of file diff --git a/examples/3d/geometry/sketch.js b/examples/3d/geometry/sketch.js index e139eb64da..7807337f3a 100644 --- a/examples/3d/geometry/sketch.js +++ b/examples/3d/geometry/sketch.js @@ -7,47 +7,48 @@ var theta = 0; function draw(){ background(255, 255, 255, 255); - translate(-120, 0, -170); + translate(-width/2, 0, -800); + normalMaterial(); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - plane(100, 100); + plane(80, 80); pop(); - translate(50, 0, 0); + translate(250, 0, 0); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - box(100, 100, 100); + box(80, 80, 80); pop(); - translate(50, 0, 0); + translate(250, 0, 0); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - cylinder(100, 100); + cylinder(80, 80); pop(); - translate(50, 0, 0); + translate(250, 0, 0); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - cone(100, 100); + cone(80, 80); pop(); - translate(50, 0, 0); + translate(250, 0, 0); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - torus(100, 20); + torus(80, 20); pop(); - translate(50, 0, 0); + translate(250, 0, 0); push(); rotateZ(theta * mouseX * 0.001); rotateX(theta * mouseX * 0.001); rotateY(theta * mouseX * 0.001); - sphere(100, 100); + sphere(80, 80); pop(); theta += 0.05; } \ No newline at end of file diff --git a/examples/3d/light/index.html b/examples/3d/immediateMode/index.html similarity index 100% rename from examples/3d/light/index.html rename to examples/3d/immediateMode/index.html diff --git a/examples/3d/immediateMode/sketch.js b/examples/3d/immediateMode/sketch.js new file mode 100644 index 0000000000..f9844523db --- /dev/null +++ b/examples/3d/immediateMode/sketch.js @@ -0,0 +1,58 @@ +var theta = 0; + +function setup(){ + createCanvas(windowWidth, windowHeight, 'webgl'); +} + +function draw(){ + + background('white'); + colorMode(HSB); + + translate(0, 0, -1000); + + rotateY(frameCount * 0.01); + + //point + stroke(0, 200, 200); + point(0, 0, 0); + + //lines + translate(100, 0, 0); + push(); + rotateX(frameCount * 0.01); + for(var i = 0 ; i < 12; i++){ + var offset = i * PI / 6; + fill(i * 20, 100, 100); + line(0, 0, 0, 200 * sin(offset + frameCount*0.01), 200 * cos(offset + frameCount*0.01), 0); + } + pop(); + + + //triangles + translate(400, 0, 0); + push(); + for(var i = 0; i < 3; i++){ + fill(i * 30 + 200, 100, 100); + translate(100, 50, 0); + triangle( + 100, 0, 0, + 60 * sin(frameCount * 0.1 + i), 0, 0, + 0, 100, 0); + } + pop(); + + + //triangle strip + translate(200, 0, 0); + for(var i = 0; i < 30; i++){ + fill(i * 10, 120, 120); + translate(100, -50, 0); + beginShape('TRIANGLE_STRIP') + vertex(0, 0, (cos(frameCount * 0.1 + i) + 1) * 100); + vertex(0, 200, 100); + vertex(100, 100, 100); + vertex(100, 0, (sin(frameCount * 0.1 + i) + 1) * 100); + endShape(); + } +} \ No newline at end of file diff --git a/examples/3d/interaction/index.html b/examples/3d/interaction/index.html index 24ec82a07c..49e0c98ad6 100644 --- a/examples/3d/interaction/index.html +++ b/examples/3d/interaction/index.html @@ -12,10 +12,10 @@ -Press Mouse To Toggle The World
+Press Mouse To Toggle The World
-