shapes_3d

The 3-D shapes, in two families.

Curved shapes – Sphere, Cylinder, Cone, Torus, and Dot3D / Line3D / Arrow3D built from them – are Surface subclasses. They carry an analytic coordinate function and a normal function, and are tessellated per frame to whatever the camera needs, so they stay smooth as you move in.

Faceted shapes – Polyhedron and everything built on it: Prism, Cube, the Platonic solids, ConvexHull3D – are defined by explicit vertices and flat polygon faces. Their faces are already planar, so they are triangulated once at construction and never refined.

The revolved solids share one vocabulary: radius, u_range / v_range and closed, with direction defaulting to UP on both Cone and Cylinder. Manim’s spellings of those (base_radius, show_base, show_ends, u_min, checkerboard_colors) raise here, naming the Algan one; they are correct under algan.manim, where Manim’s classes live. resolution is the one Manim name kept, counting patches rather than vertices as Manim does, and u_range / v_range keep Manim’s names but take Algan’s degrees.

Unlike 2-D shapes, these respond to light. See Your First 3-D Scene.

Classes

Arrow3D

An arrow: a Cylinder shaft with a Cone tip, grouped.

Cone

A circular cone, tessellated from a Surface.

ConvexHull3D

The convex hull of a point cloud, as a flat-faced Polyhedron.

Cube

A cube -- a Prism with three equal sides.

Cylinder

A cylinder, tessellated from a Surface.

Dodecahedron

The twelve-faced Platonic solid, built from flat pentagonal faces.

Dot3D

A small Sphere, for marking a point in a 3-D scene.

Icosahedron

The twenty-faced Platonic solid, built from flat triangular faces.

Line3D

A thin capped Cylinder spanning two points.

Octahedron

The eight-faced Platonic solid, built from flat triangular faces.

Polyhedron

A solid built from explicit vertices and indexed polygon faces.

Prism

A right rectangular prism -- a box -- built from six flat faces.

Sphere

A 3-D sphere, tessellated from a Surface.

Tetrahedron

The four-faced Platonic solid, built from flat triangular faces.

Torus

A torus, tessellated from a Surface.

Functions

orient_faces_outward(vertex_coords, faces_list)[source]

Rewind a closed polyhedron’s faces so every one of them faces outward.

Returns a new face list, or the input unchanged when the mesh is not a closed orientable manifold and the question therefore has no answer.

Two steps, both standard. First make the winding CONSISTENT: two faces that agree on their orientation traverse their shared edge in opposite directions, so a flood fill over the shared-edge graph flips whichever neighbour disagrees. Then fix the global sign, which consistency alone cannot: the signed volume of the closed shell (the divergence theorem, one tetrahedron per triangle of the fan) is positive exactly when the faces point outward, so a negative total flips all of them.

It bails out, leaving the input alone, on anything that is not a closed orientable manifold – an undirected edge used by other than two faces (an open mesh, a T-junction, a non-manifold fin), a flood fill that reaches a face two ways with contradicting orientations (a Moebius-like shell), a shell in more than one connected piece, or a degenerate zero volume. A Polyhedron is public API and takes arbitrary user geometry, so the pass has to be a no-op wherever “outward” is not defined rather than guess.

Why this exists: the projected winding sign IS the renderer’s backface bit (raster_taichi._AA_BACKFACE_BIT), which is what separates the near and far sheets of a closed mesh for the analytic-AA run rule. The face lists Algan ships for the Platonic solids are Manim’s, and they are not consistently oriented – 12 of an Icosahedron’s 20 faces, 2 of 4 on a Tetrahedron, 2 of 8 on an Octahedron, 3 of 12 on a Dodecahedron, 0 of 6 on a Cube. See rendering/raytracing/DESIGN_mesh_identity.md ss6.5.