WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics API based on OpenGL ES
var object3d;
function setup() {
createCanvas(710, 400, WEBGL);
}
function preload(){
object3d= loadModel('cubeRed.obj')
}
function draw() {
background(100);
noStroke();
fill(50);
push();
translate(-275, 175);
rotateY(1.25);
rotateX(-0.9);
model(object3d);
pop();
}
There are also 3D objects predefined, for insert them we just write the name and, into the parentheses, the size.
function setup() {
createCanvas(710, 400, WEBGL);
}
function draw() {
background(100);
noStroke();
fill(50);
push();
translate(-275, 175);
rotateY(1.25);
rotateX(-0.9);
box(100);
pop();
noFill();
stroke(255);
push();
translate(500, height*0.35, -200);
sphere(300);
pop();
}