pub static sphere: SphereInternalTypeExpand description
Draw a sphere with given radius.
DetailX and detailY determines the number of subdivisions in the x-dimension and the y-dimension of a sphere. More subdivisions make the sphere seem smoother. The recommended maximum values are both 24. Using a value greater than 24 may cause a warning or slow down the browser.
Examples
// draw a sphere with radius 40
function setup() {
createCanvas(100, 100, WEBGL);
}
function draw() {
background(205, 102, 94);
sphere(40);
}let detailX;
// slide to see how detailX works
function setup() {
createCanvas(100, 100, WEBGL);
detailX = createSlider(3, 24, 3);
detailX.position(10, height + 5);
detailX.style('width', '80px');
}
function draw() {
background(205, 105, 94);
rotateY(millis() / 1000);
sphere(40, detailX.value(), 16);
}let detailY;
// slide to see how detailY works
function setup() {
createCanvas(100, 100, WEBGL);
detailY = createSlider(3, 16, 3);
detailY.position(10, height + 5);
detailY.style('width', '80px');
}
function draw() {
background(205, 105, 94);
rotateY(millis() / 1000);
sphere(40, 16, detailY.value());
}Parameters
radius? radius of circle
detailX? optional number of subdivisions in x-dimension
detailY? optional number of subdivisions in y-dimension