@@ -33,6 +33,8 @@ function faces(primitive, nvertices=nothing)
33
33
return nothing
34
34
end
35
35
36
+ texturecoordinates (primitive, nvertices= nothing ) = nothing
37
+
36
38
"""
37
39
Tesselation(primitive, nvertices)
38
40
For abstract geometries, when we generate
@@ -123,16 +125,25 @@ function decompose(NT::Normal{T}, primitive) where T
123
125
end
124
126
125
127
function decompose (UVT:: Union{UV{T}, UVW{T}} , primitive) where T
128
+ # This is the fallback for texture coordinates if a primitive doesn't overload them
129
+ # We just take the positions and normalize them
126
130
uv = texturecoordinates (primitive)
127
131
if uv === nothing
128
- return decompose (UVT, texturecoordinates (coordinates (primitive)))
132
+ # If the primitive doesn't even have coordinates, we're out of options and return
133
+ # nothing, indicating that texturecoordinates aren't implemented
134
+ positions = decompose (Point, primitive)
135
+ positions === nothing && return nothing
136
+ # Let this overlord do the work
137
+ return decompose (UVT, positions)
129
138
end
130
139
return collect_with_eltype (T, uv)
131
140
end
132
141
133
- function texturecoordinates (positions:: AbstractVector{<:VecTypes} )
134
- bb = Rect (positions)
135
- return map (positions) do p
142
+ function decompose (UVT:: Union{UV{T}, UVW{T}} , positions:: AbstractVector{<:VecTypes} ) where T
143
+ N = length (T)
144
+ positions_nd = decompose (Point{N, eltype (T)}, positions)
145
+ bb = Rect (positions_nd) # Make sure we get this as points
146
+ return map (positions_nd) do p
136
147
return (p .- minimum (bb)) ./ widths (bb)
137
148
end
138
149
end
0 commit comments