CodingTrain / CodingTrain/Suggestion-Box

P5.js texture() error - Uncaught TypeError: Cannot read property 'width' of undefined

Open
#862 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

Hi!

I have come across with a problem while practising the following lesson.
https://www.youtube.com/watch?v=O1mYw-3Wl_Q

texture(); function doesn't work for me. I have attached the console log error as well.
https://imgur.com/a/pc41X

```javascript
let visual;

function preLoad(){
visual = loadImage('http://i55.tinypic.com/16axyx0.jpg');
}

function setup(){
createCanvas(windowWidth,windowHeight,WEBGL);
}
function draw(){

ambientLight(0,0,255);

background(51);
noStroke();
//normalMaterial();
//ambientMaterial(255);
rotateX(frameCount*0.01);
rotateY(frameCount*0.01);
rotateZ(frameCount*0.01);
//ellipsoid(width/6);
texture(visual);
box(200,200,200);
}
function windowResized(){
resizeCanvas(windowWidth,windowHeight,WEBGL);
}
```

Thanks in advance.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied JavaScript sketch with p5.js in WEBGL mode and inspect the console around texture(visual). Read the texture() and image-loading documentation, then verify that the sketch renders the textured box without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.