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

130
Vistas
Animación de galería de imágenes P5

Estoy tratando de cargar dinámicamente un conjunto de imágenes y traducirlas en la dirección Z a una velocidad constante mientras tengo valores aleatorios para X e Y

Estoy trabajando con el siguiente código y no sé cómo usar la propiedad de texture de imagen.

Obtengo un lienzo negro en blanco al renderizar el siguiente código con el que trabajé. Cualquier ayuda será apreciada.

 let imgs = []; let imgs_arr = []; let num = 15; function preload() { for (let i = 0; i < num; i++) { imgs[i] = loadImage("https://picsum.photos/400/400/?image=" + i * 10); } } function setup() { createCanvas(windowWidth, windowHeight, WEBGL); colorMode(HSB, 360, 100, 100, 100); for (let i = 0; i < num; i++) { let x = random(-width / 2, width / 2); let y = random(-height / 2, height / 2); let z = random(-width*5, width/2); let texture = new Type(imgs[i], x, y, z) imgs_arr.push(texture); } } function draw() { background(0,0,0); orbitControl(); for (let i = 0; i < num; i++) { imgs_arr[i].update(); imgs_arr[i].display(); } } class Type { constructor(_img, _x, _y, _z) { this.img = _img; this.x = _x; this.y = _y; this.z = _z; } update() { this.z += 10; if(this.z > width/2){ this.z = -width*5; } } display() { push(); translate(this.x, this.y, this.z); texture(this.img) pop(); } }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Con solo leer los documentos , parece que te falta un componente clave. Digamos que desea dibujar la imagen en un cuadro, debe agregar lo siguiente después de su textura:

 box(width / 2);

Aquí está el ejemplo en ejecución:

 let imgs = []; let imgs_arr = []; let num = 15; function preload() { for (let i = 0; i < num; i++) { imgs[i] = loadImage("https://picsum.photos/400/400/?image=" + i * 10); } } function setup() { createCanvas(windowWidth, windowHeight, WEBGL); colorMode(HSB, 360, 100, 100, 100); for (let i = 0; i < num; i++) { let x = random(-width / 2, width / 2); let y = random(-height / 2, height / 2); let z = random(-width*5, width/2); let texture = new Type(imgs[i], x, y, z) imgs_arr.push(texture); } } function draw() { background(0,0,0); orbitControl(); for (let i = 0; i < num; i++) { imgs_arr[i].update(); imgs_arr[i].display(); } } class Type { constructor(_img, _x, _y, _z) { this.img = _img; this.x = _x; this.y = _y; this.z = _z; } update() { this.z += 10; if(this.z > width/2){ this.z = -width*5; } } display() { push(); translate(this.x, this.y, this.z); texture(this.img) box(width / 2); pop(); } }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js" integrity="sha512-N4kV7GkNv7QR7RX9YF/olywyIgIwNvfEe2nZtfyj73HdjCUkAfOBDbcuJ/cTaN04JKRnw1YG1wnUyNKMsNgg3g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

about 4 years ago · Juan Pablo Isaza Denunciar
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