| Crates.io | subsphere |
| lib.rs | subsphere |
| version | 0.7.1 |
| created_at | 2025-04-04 00:04:12.859611+00 |
| updated_at | 2025-05-29 02:05:28.292707+00 |
| description | Sphere tessellation toolkit |
| homepage | |
| repository | https://github.com/dzamkov/subsphere |
| max_upload_size | |
| id | 1619191 |
| size | 204,536 |
subsphereSphere tessellation toolkit
This crate provides a general, easy-to-use API for working with tessellated spheres, i.e. spheres whose surface is partitioned into polygonal cells. It includes implementations for a variety of such tessellations.

Implicit Representation: Instead of storing geometry data directly, the
tessellations, and the elements within them, are represented implicitly. They are compact
zero-allocation Copy types that can be used to generate geometry on the fly. This lets you work
with massive tessellations using very little memory.
Versatility: This crate allows you to explore a huge variety of tessellations, all sharing a common API. There's a bunch of adjustable parameters and you're free to mix-and-match topologies and projections to tune the tessellation to your needs.
Spherical Geometry: In the world of subsphere, there is only one geometric space: the
sphere. All objects follow the contours of the sphere, and all calculations correctly account for
this.
let sphere = subsphere::icosphere()
.subdivide_edge(NonZero::new(3).unwrap())
.with_projector(subsphere::proj::Fuller)
.truncate();
let sphere = subsphere::HexSphere::from_kis(
subsphere::TriSphere::new(
subsphere::BaseTriSphere::Icosa,
subsphere::proj::Fuller,
NonZero::new(9).unwrap(),
0,
)
).unwrap();
let mut obj = String::new();
for vert in sphere.vertices() {
let pos = vert.pos();
obj.push_str(&format!("v {} {} {}\n", pos[0], pos[1], pos[2]));
}
for face in sphere.faces() {
let indices = face
.vertices()
.map(|vert| format!("{}", vert.index() + 1)) // OBJ indices are 1-based
.collect::<Vec<_>>();
obj.push_str(&format!("f {}\n", indices.join(" ")));
}
std::fs::write("sphere.obj", &obj).expect("failed to write to file");
// Setup
let mut is_active = vec![false; sphere.num_faces()];
// For each click
let click_face = sphere.face_at(click_point);
for side in click_face.sides() {
let neighbor_index = side.twin().inside().index();
is_active[neighbor_index] = !is_active[neighbor_index];
}