A small Flutter demo that renders a rotating 3D point cloud and morphs it between multiple shapes (sphere, cube, heart, donut). The morph progress is driven by a PageView, so you can scrub transitions by swiping anywhere on the page.
- Swipe anywhere to morph between shapes.
- The shape continuously rotates around the Y axis.
- Point cloud: Each shape is represented as a
List<Vec3>with a fixed number of points. - Stable correspondence: A deterministic list of 2D seeds (
Seed2) is generated once and reused, so each point index maps consistently across shapes. This makes morphing as simple asVec3.lerp(from[i], to[i], t). - Rendering:
DotMorphPainterapplies a small X tilt, rotates the points around Y, projects them into 2D with a basic perspective transform, then draws each point as a circle with depth-based size/opacity.
lib/three_dot_animation_switcher_page.dart— UI, shape generation, and morph/rotation wiring.lib/dot_morph_painter.dart— 3D → 2D projection and dot rendering.lib/utils/utility_functions.dart— point generators for sphere/cube/heart/donut.lib/utils/morph_spec.dart— maps page position to morph indices and progress (t).
Prerequisites: Flutter (Dart SDK) installed. This demo can run on any platform Flutter supports (mobile, desktop, and web).
flutter pub get
flutter run- Point density: tweak
_pointCountinlib/three_dot_animation_switcher_page.dart. - Add a new shape: generate a new
List<Vec3>of the same length and append it to_shapes. - Look & feel: adjust perspective/tilt/dot sizing in
lib/dot_morph_painter.dart.
Licensed under The Unlicense — do whatever you want with this code. See LICENSE.