Skip to content

Commit 4bfdfc1

Browse files
committed
Discard w texture coordinate if encountered.
1 parent bc7caed commit 4bfdfc1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/obj.jl

+9-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ function loadOBJ(path::String)
6565
elseif command == "vn"
6666
push!( temp_normals, parse.(Float32,lines) )
6767
elseif command == "vt"
68-
push!( temp_texturecoords, parse.(Float32,lines) )
68+
uvw = parse.(Float32, lines)
69+
# HACK strip the w coordinate if encountered. TODO save appropriate uvw type texture coordinate.
70+
if length(uvw) > 2
71+
push!( temp_texturecoords, TextureCoordinate(uvw[1], uvw[2]) )
72+
else
73+
push!( temp_texturecoords, uvw )
74+
end
6975
# Handle faces
70-
elseif command == "f"
76+
elseif command == "f"
7177
# Handle missing texture coordinate indices case, ie.
7278
# f v1//vn1 v2//vn2 v3//vn3 ...
7379
if any( x->occursin("//", x), lines )
@@ -85,7 +91,7 @@ function loadOBJ(path::String)
8591
append!( normalFaces[end], normalIndices )
8692
# Handle full indices case, ie.
8793
# f v1/vt1/vn1 v2/vt2/vn2 v3/vt2/vn3 ...
88-
elseif any(x->occursin("/", x), lines)
94+
elseif any(x->occursin("/", x), lines)
8995
indexes = split.(lines, "/")
9096

9197
vertIndices = UInt32[]

0 commit comments

Comments
 (0)