Geometry
Geometry is the shape half of a Mesh. Flutter Scene ships a set of primitive shapes, lets you build your own from raw vertex data, and provides line and swept shapes for strokes and profiles.
Built-in primitives
Section titled “Built-in primitives”Each primitive is a Geometry you pair with a material to make a Mesh. They are centered on the origin and carry the normals and texture coordinates the materials need.
final cube = Mesh(CuboidGeometry(vm.Vector3(1, 1, 1)), material);final ball = Mesh(SphereGeometry(radius: 0.6), material);final cone = Mesh( // A cone is a cylinder with a zero-radius top. CylinderGeometry(bottomRadius: 0.6, topRadius: 0.0, height: 1.2), material,);The full set is CuboidGeometry, SphereGeometry, IcosphereGeometry, CylinderGeometry, CapsuleGeometry, TorusGeometry, WedgeGeometry, PlaneGeometry, DiscGeometry, and RingGeometry. Most take named dimensions and tessellation counts with sensible defaults.
Custom geometry
Section titled “Custom geometry”To build a shape that is not a primitive, use GeometryBuilder. It assembles a mesh one vertex and triangle at a time, and its normal, texCoord, and color setters are sticky, applying to every vertex added after them.
final geometry = (GeometryBuilder() ..color(vm.Vector4(1, 0, 0, 1)) ..addVertex(vm.Vector3(0, 0, 0)) ..addVertex(vm.Vector3(1, 0, 0)) ..addVertex(vm.Vector3(0, 1, 0)) ..addTriangle(0, 1, 2)) .build();If a vertex has no authored normal, the builder generates one. When you already have packed attribute arrays, MeshGeometry.fromArrays takes them directly, which is the fast path for procedural meshes.
A geometry can also carry named per-vertex data beyond the standard attributes, supplied with setCustomAttribute and read by name in a custom material’s vertex stage. See Custom materials.
Lines and swept shapes
Section titled “Lines and swept shapes”For strokes and profile-based shapes there are dedicated geometries.
PolylineGeometrydraws a screen-stable line along a path, with caps, dashes, and width modes.TubeGeometrysweeps a circle along a path to make a tube.RibbonGeometrysweeps a flat strip along a path.ExtrudeGeometryextrudes a 2D profile into a solid.
Skinned and unskinned
Section titled “Skinned and unskinned”The primitives and builder produce UnskinnedGeometry. Geometry imported from a rigged glTF arrives as SkinnedGeometry, which carries joint weights so it deforms with an animation. See Assets and loading.
Key API
Section titled “Key API”Geometry, MeshGeometry, GeometryBuilder, and the primitive classes such as CuboidGeometry and SphereGeometry.