(p5.dom is now part of p5js, no need to enable if using v0.10+). p5.dom library lets you use video, audio, webcam, input, and text.
Examples: Dom - Video
“3DCube Random Walker” by dhemerae
https://openprocessing.org/sketch/1093274
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
mouse
CC Attribution ShareAlike
3DCube Random Walker
xxxxxxxxxx
// rotate around the look-at point (it will feel like the object is moving)
// mouse: left-click and drag
// touch: one-finger drag
// pan the scene
// mouse: middle-click and drag
// touch: two-finger drag
// zoom out/in
// mouse: right-click drag down/up
// touch: pinch/spread
// reset to the starting state
// mouse: double-click
// touch: double-tap
var boxes = [];
var walker;
var stepCnt = 5 //amount of movement in x,y,z and also size of box
var cChangeRate = 0 // rate that color cycles through HSB spectrum
let slider1
let slider2
function setup() {
document.oncontextmenu = () => false; //removes right click functionality
createCanvas(windowWidth, windowHeight, WEBGL);
colorMode(HSB);
createEasyCam(); //using easycam library on OpenProcessing
walker = new RndWalker(0, 0, 0, stepCnt);
boxes.push(createVector(0, 0, 0));
slider1 = createSlider(0.1,3,1,0.1) //affects cChangeRate
slider1.position(10,10)
slider2 = createSlider(0.1,1,0.1,0) //affects cChangeRate
slider2.position(150,10)
}
function draw() {
background(100);
//lights();
frameRate(10);
walker.move();
let pos = walker.getPos();
boxes.push(createVector(pos.x, pos.y, pos.z));
let c = 0
boxes.forEach((nbox) => {
push();
//stroke(255)
noStroke();
fill(c,100,100,slider2.value());
strokeWeight(1)
translate(nbox.x, nbox.y, nbox.z);
box(stepCnt, stepCnt, stepCnt);
//xoff += .01
pop();
cChangeRate = slider1.value();
c += cChangeRate
if (c >= 360){
c = 0
}
});
}
class RndWalker {
constructor(x, y, z, stepCnt) {
this.pos = createVector(x, y, z)
this.stepCnt = stepCnt
this.dir = [
createVector(stepCnt, 0, 0), // positive x
createVector(-stepCnt, 0, 0), // negative x
createVector(0, stepCnt, 0), //positive y
createVector(0, -stepCnt, 0), // negative y
createVector(0, 0, stepCnt), // positive z
createVector(0, 0, -stepCnt) // negative z
];
}
getPos() {
return this.pos;
}
move() {
let step = random(this.dir);
this.pos.add(step);
}
}
Examples: Play - Synthesis - Microphone
p5.dom library lets you use video, audio, webcam, input, and text.
Examples: Dom - Video
See More Shortcuts
Please verify your email to comment
Verify Email