createHeart method

  1. @override
Mesh createHeart({
  1. required int color,
})
override

Creates and returns a heart-shaped mesh.

Implementation

@override
Mesh createHeart({required int color}) {
  final Shape shape = Shape();
  shape.moveTo(25, 25);
  shape.bezierCurveTo(25, 25, 20, 0, 0, 0);
  shape.bezierCurveTo(-30, 0, -30, 35, -30, 35);
  shape.bezierCurveTo(-30, 55, -10, 77, 25, 95);
  shape.bezierCurveTo(60, 77, 80, 55, 80, 35);
  shape.bezierCurveTo(80, 35, 80, 0, 50, 0);
  shape.bezierCurveTo(35, 0, 25, 25, 25, 25);

  final Map<String, dynamic> extrudeSettings = {
    "depth": 8,
    "bevelEnabled": true,
    "bevelSegments": 2,
    "steps": 2,
    "bevelSize": 1,
    "bevelThickness": 1
  };

  final MeshBasicMaterial material =
      MeshBasicMaterial(jsify({'color': color}));

  final Map<String, dynamic> options = {
    'scale': {'x': 0.01, 'y': 0.01, 'z': 0.01}
  };

  final ExtrudeGeometry geometry =
      ExtrudeGeometry(shape, jsify(extrudeSettings));

  return createObject(geometry, [material], options);
}