Open kretes opened 5 months ago
Hi @kretes !
K3D is consistent here. Please look at https://k3d-jupyter.org/reference/factory.voxels_group.html
By default, the voxels are a grid inscribed in the -0.5 < x, y, z < 0.5 cube regardless of the passed voxel array shape, like aspect ratio.
That is true for k3d.voxel, k3d.surface k3d.marching_cubes etc. So it is consistent. Object with "sampling" by default are in world-space cube -0.5 to 0.5. To keep aspect ratio we can pass bounds
/ model_matrix
. So from my point of view your case is more related to chunky3d. @tgandor can you look at it? To be specific - at implementation of https://github.com/K3D-tools/chunky3d/blob/d902a5f1338e0b3b612b8be6fef91310a4520fb2/chunky3d/chunky.py#L1177
@tgandor get_k3d_obj by default use get_voxels_bounds
instead of get_bounds
. That confused @kretes i think.
And I agree that helper (get_k3d_obj
) didnt provide any control over it.
Description
Currently k3d is rendering Sparse volume as voxels that are centered around the center of the voxel coordinate. This should at least be up to the user to display Sparse with voxel being aligned to a corner.
Here is what I get for a dummy data that I intend to be plotted as the same volume:
plot with:
and I get:
This comes from the
get_voxel_bounds
method from Sparse: https://github.com/K3D-tools/chunky3d/blob/d902a5f1338e0b3b612b8be6fef91310a4520fb2/chunky3d/chunky.py#L1177If I implement a method that aligns voxel corner with the origin:
And use it when plotting:
I get what I intend to:
So the issue is about the ability to pick the way data should be interpreted - I think that this should be achievable by configuring k3d to do so, without modification of the k3d codebase.