Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda