Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/primitives/rectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,17 @@ function coordinates(rect::Rect3)
end

function texturecoordinates(rect::Rect3)
return coordinates(Rect3(0, 0, 0, 1, 1, 1))
# compatible with a texture ordered:
# [+x +y +z; -x -y -z]
uvs = map(v -> v ./ (3, 2), Vec{2, Float32}[
(2, 0), (2, 1), (3, 1), (3, 0),
(1, 0), (1, 1), (2, 1), (2, 0),
(0, 0), (0, 1), (1, 1), (1, 0),
(2, 1), (2, 2), (3, 2), (3, 1),
(0, 1), (0, 2), (1, 2), (1, 1),
(1, 1), (1, 2), (2, 2), (2, 1),
])
return uvs
end

function faces(rect::Rect3)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ end
r2 = Rect2(0.0, 0.0, 1.0, 1.0)
@test collect(texturecoordinates(r2)) == [(0.0, 1.0), (1.0, 1.0), (0.0, 0.0), (1.0, 0.0)]
r3 = Rect3(0.0, 0.0, 1.0, 1.0, 2.0, 2.0)
@test first(texturecoordinates(r3)) == Vec3(0, 0, 0)
@test collect(texturecoordinates(r3)) ≈ [[0.6666667, 0.0], [0.6666667, 0.5], [1.0, 0.5], [1.0, 0.0], [0.33333334, 0.0], [0.33333334, 0.5], [0.6666667, 0.5], [0.6666667, 0.0], [0.0, 0.0], [0.0, 0.5], [0.33333334, 0.5], [0.33333334, 0.0], [0.6666667, 0.5], [0.6666667, 1.0], [1.0, 1.0], [1.0, 0.5], [0.0, 0.5], [0.0, 1.0], [0.33333334, 1.0], [0.33333334, 0.5], [0.33333334, 0.5], [0.33333334, 1.0], [0.6666667, 1.0], [0.6666667, 0.5]]
uv = decompose_uv(m)
@test Rect(Point.(uv)) == Rect(0, 0, 1, 1)

Expand Down