Skip to content

Commit

Permalink
#4866 V texture coordinate inversion on OBJ loadModel
Browse files Browse the repository at this point in the history
Testing this as WebGL requires a flipped/inverted V texture coordinate
  • Loading branch information
myselfhimself authored Jan 28, 2021
1 parent 23db9e6 commit 2b6302d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/webgl/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ function parseObj(model, lines) {
loadedVerts[tokens[0]].push(vertex);
} else if (tokens[0] === 'vt') {
// Check if this line describes a texture coordinate.
// It will have two numeric parameters.
const texVertex = [parseFloat(tokens[1]), parseFloat(tokens[2])];
// It will have two numeric parameters U and V (W is omitted).
// Because of WebGL texture coordinates rendering behaviour, the V
// coordinate is inversed.
const texVertex = [parseFloat(tokens[1]), 1 - parseFloat(tokens[2])];
loadedVerts[tokens[0]].push(texVertex);
} else if (tokens[0] === 'f') {
// Check if this line describes a face.
Expand Down

0 comments on commit 2b6302d

Please sign in to comment.