Hi recently I came across the topic of running sketches in p5js in an instance mode. I had been able to draw shapes and do basic visualization using the instance mode. However I am quite confused when it comes in dealing with classes and instance mode. For example I am trying to simulate particles , using instance mode. How is the syntax usually with classes when dealing with the instance mode? For example the particle system is defined in particle.js
as follows.
class Particle {
constructor() {
this.pos = p5.createVector(0,0,0);
this.vel = p5.Vector.random3D().normalize().mult(random(4,6));
}
update() {
this.p.pos.add(this.vel);
}
draw(){
push();
noStroke();
fill(255);
translate(this.pos.x,this.pos.y,this.pos.z);
box(10,10,10);
pop()
}
}