404 image not found

Here is my code

var canvas;
let dirtImg;

function preload() {
  dirtImg = loadImage('assets/blocks/dirt.png');
}

function setup() {
  // put setup code here
  canvas = createCanvas(window.innerWidth, window.innerHeight, WEBGL);
}

function draw() {
  // put drawing code here
  background(100);

  strokeWeight(1); 
  //fill(50);
  push();
  translate(100, 100);
  //rotateY(1.25);
  //rotateX(-0.9);
  texture(dirtImg);
  box(100);
  pop();
}

window.onresize = function() {
  var w = window.innerWidth;
  var h = window.innerHeight;  
  canvas.size(w,h);
  width = w;
  height = h;
};

Im using Google’s Firebase as the sever however the image “assets/blocks/dirt.png” is not being loaded on to the cube / box . How do I fix it?

1 Like

Hello,

This is all I can offer…

If I have dirt.png in the local sketch folder assets/blocks/ it works.

I found a URL that worked:
dirtImg = loadImage(“https://farm3.staticflickr.com/2849/11011320426_c8ce1bff32_q.jpg”);

Some links did not work!

dirt

:slight_smile:

References:
https://codepen.io/ajspadial/pen/QjdWxJ
https://p5js.org/reference/#/p5/loadImage