@@ -563,22 +563,33 @@ end
563563
564564# #
565565# Rect3 decomposition
566- function coordinates (rect:: Rect3 )
566+ function coordinates (rect:: Rect3{T} ) where T
567567 # TODO use n
568568 w = widths (rect)
569569 o = origin (rect)
570- points = Point{3 ,Int}[(0 , 0 , 0 ), (0 , 0 , 1 ), (0 , 1 , 1 ), (0 , 1 , 0 ), (0 , 0 , 0 ), (1 , 0 , 0 ),
571- (1 , 0 , 1 ), (0 , 0 , 1 ), (0 , 0 , 0 ), (0 , 1 , 0 ), (1 , 1 , 0 ), (1 , 0 , 0 ),
572- (1 , 1 , 1 ), (0 , 1 , 1 ), (0 , 0 , 1 ), (1 , 0 , 1 ), (1 , 1 , 1 ), (1 , 0 , 1 ),
573- (1 , 0 , 0 ), (1 , 1 , 0 ), (1 , 1 , 1 ), (1 , 1 , 0 ), (0 , 1 , 0 ), (0 , 1 , 1 )]
574- return ((x .* w .+ o) for x in points)
570+ # points = Point{3,Int}[(0, 0, 0), (0, 0, 1), (0, 1, 1), (0, 1, 0), (0, 0, 0), (1, 0, 0),
571+ # (1, 0, 1), (0, 0, 1), (0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0),
572+ # (1, 1, 1), (0, 1, 1), (0, 0, 1), (1, 0, 1), (1, 1, 1), (1, 0, 1),
573+ # (1, 0, 0), (1, 1, 0), (1, 1, 1), (1, 1, 0), (0, 1, 0), (0, 1, 1)]
574+ # return ((x .* w .+ o) for x in points)
575+ return Point{3 , T}[o + (x, y, z) .* w for x in (0 , 1 ) for y in (0 , 1 ) for z in (0 , 1 )]
576+ end
577+
578+ function normals (:: Rect3 )
579+ return Vec3f[(- 1 ,0 ,0 ), (1 ,0 ,0 ), (0 ,- 1 ,0 ), (0 ,1 ,0 ), (0 ,0 ,- 1 ), (0 ,0 ,1 )]
575580end
576581
577582function texturecoordinates (rect:: Rect3 )
578583 return coordinates (Rect3 (0 , 0 , 0 , 1 , 1 , 1 ))
579584end
580585
581- function faces (rect:: Rect3 )
582- return QuadFace{Int}[(1 , 2 , 3 , 4 ), (5 , 6 , 7 , 8 ), (9 , 10 , 11 , 12 ), (13 , 14 , 15 , 16 ),
583- (17 , 18 , 19 , 20 ), (21 , 22 , 23 , 24 ),]
586+ function faces (:: Rect3 )
587+ return NormalUVFace {QuadFace} .([
588+ ((1 , 2 , 3 , 4 ), 1 , (1 , 2 , 3 , 4 )), # -x
589+ ((5 , 6 , 7 , 8 ), 2 , (5 , 6 , 7 , 8 )), # +x
590+ ((1 , 2 , 5 , 6 ), 3 , (1 , 2 , 5 , 6 )), # -y
591+ ((3 , 4 , 7 , 8 ), 4 , (3 , 4 , 7 , 8 )), # +y
592+ ((1 , 3 , 5 , 7 ), 5 , (1 , 3 , 5 , 7 )), # -z
593+ ((2 , 4 , 6 , 8 ), 6 , (2 , 4 , 6 , 8 )), # +z
594+ ])
584595end
0 commit comments