Spinning Sphere in 3D with p5.js

Channel:
Subscribers:
738
Published on ● Video Link: https://www.youtube.com/watch?v=aXwWWbWE40w



Duration: 0:00
23 views
2


This p5.js sketch creates a 3D canvas and displays a rotating sphere. In setup(), it sets up a 400×400 pixel canvas using the WEBGL renderer. The draw() function is called continuously to update the frame. It clears the background with background(220), enables mouse control with orbitControl(), rotates the sphere around the Y-axis with rotateY(angle), and draws the sphere using sphere(80, 16, 10). The angle is slightly increased each frame (angle += 0.01) to make the sphere rotate smoothly over time.