3D draw layering #907
-
|
Encountering a strange issue with 3D coordinates and layering -- could not find a related issue on the GitHub. You will notice that the "debug line" below appears on top of the cube's faces in the first call of the Perhaps the strangest part is that the the 'inner' edges of the cuboid manage to stay on top of fills? I believe this might have to be because they are 'closest' to the viewing "camera" and thus not conflicting with the filled sides? #import "@preview/cetz:0.4.0": *
#set page(width: auto, height: auto, margin: 0.6pt)
#let cube_block(
pos: (0, 0, 0),
dimensions: (1, 1, 1),
..style
) = {
import draw: *
set-origin((0, 0))
let (x, y, z) = pos
let (x_dim, y_dim, z_dim) = dimensions
let vertices = ( // Cuboid vertices
(x + x_dim, y, z),
(x + x_dim, y + y_dim, z),
(x, y + y_dim, z),
(x, y + y_dim, z + z_dim),
(x, y, z + z_dim),
(x + x_dim, y, z + z_dim),
)
let outer_most_point = (x + x_dim, y + y_dim, z + z_dim)
ortho({
group({
// Coloured faces
line(vertices.at(0), vertices.at(1), outer_most_point, vertices.at(5), ..style, close: true, stroke: none)
line(vertices.at(1), vertices.at(2), vertices.at(3), outer_most_point, ..style, close: true, stroke: none)
line(vertices.at(3), vertices.at(4), vertices.at(5), outer_most_point, ..style, close: true, stroke: none)
// DEBUG Line
line((rel: (1, 0, 0.), to: vertices.at(2)), (rel: (0, 0, z_dim + 2)), ..style, stroke: 4pt)
// Wireframe
line(..vertices, ..style, close: true, fill: none)
line(vertices.at(5), outer_most_point, ..style)
line(vertices.at(1), outer_most_point, vertices.at(3), ..style, fill: none)
})
})
}
#canvas({
import draw: *
// Block of cubes -- arbitrary positions
cube_block(pos: (-1, 0, 0), dimensions: (3, 3, 4), fill: red)
cube_block(pos: (8, 4, 0), dimensions: (4, 3, 4), fill: red)})For context I want to create a cuboid with lines together to give the effect of many cubes, however these inner 'grid' lines were being obscured in precisely the way seen above: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can pass |
Beta Was this translation helpful? Give feedback.


You can pass
sorted: falsetoorthoto disable its very naive element sorting.I will create an issue about that.