Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
How to layer 3d objects in p5.js using WEBGL

I have 2 3D objects, a torus and a cylinder. I want the cylinder to go on top of the torus, rather than below.

function setup() {
  createCanvas(400, 400, WEBGL);
}

function draw() {
  angleMode(DEGREES)
  background(220);
  noStroke();
  rotateX(30)
  // The torus
  // The color(Torus)
  fill(241, 177, 102);
  // Drawing the Torus
  torus(100, 40);
  // The Cylinder
  // The color
  fill(138, 78, 27);
  // Drawing the cylinder
  push();
  rotateX(90);
  cylinder(130, 10);
  pop();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>

In this drawing, the cylinder will appear more obvious, since it's on its side this time rather than laying flat as if it's a circle. This is simply to make it easier to see and understand what I mean.

function setup() {
  createCanvas(400, 400, WEBGL);
}

function draw() {
  angleMode(DEGREES)
  background(220);
  noStroke();
  // rotateX(30)
  // The torus
  // The color(Torus)
  fill(241, 177, 102);
  // Drawing the Torus
  torus(100, 40);
  // The Cylinder
  // The color
  fill(138, 78, 27);
  // Drawing the cylinder
  // push();
  // rotateX(90);
  cylinder(130, 10);
  // pop();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>

So far, I have tried to rotate the cylinder on the Z axis, but that did not work, and I also tried drawing the cylinder before the torus, but that also did not work.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda