Skip to content

Commit

Permalink
Merge pull request #5017 from myselfhimself/patch-1
Browse files Browse the repository at this point in the history
#4866 V texture coordinate inversion on OBJ loadModel
  • Loading branch information
stalgiag authored Jan 29, 2021
2 parents 23db9e6 + 2b6302d commit c2c8992
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 c2c8992

Please sign in to comment.