createObject function

Object createObject({
  1. required SelectedType type,
  2. Vector3? position,
  3. Vector3? rotation,
  4. Vector3? scale,
  5. required Size size,
  6. required String name,
  7. required int layer,
  8. required int imageLocation,
  9. Color? color,
  10. List<Offset>? textcoords,
  11. Rect? textureRect,
})

Implementation

Object createObject({
  required SelectedType type,
  Vector3? position,
  Vector3? rotation,
  Vector3? scale,
  required Size size,
  required String name,
  required int layer,
  required int imageLocation,
  Color? color,
  List<Offset>? textcoords,
  Rect? textureRect,
}){
  color ??= Colors.red;
  return (type != SelectedType.atlas && type != SelectedType.image )?Object(
    position: position,
    rotation: rotation,
    scale: scale,
    mesh: [Mesh(
      vertices: [
        Vector3(0,0,0),
        Vector3(size.width,0,0),
        Vector3(size.width,size.height,0),
        Vector3(0,size.height,0),
      ],
      hasTexture: textcoords == null?false:true,
      texcoords: textcoords,
      indices: [
        Triangle([0,1,2], null, textcoords != null?[0,1,2]:null),
        Triangle([2,3,0], null, textcoords != null?[2,3,0]:null),
      ],
      textureRect: textureRect
    )],
    size: size,
    name: name,
    layer: layer,
    imageLocation: imageLocation,
    type: type,
    color: color
  ):Object(
    position: position,
    rotation: rotation,
    scale: scale,
    mesh: [Mesh(
      vertices: [
        Vector3(0,0,0),
        Vector3(size.width,0,0),
        Vector3(size.width,size.height,0),
        Vector3(0,size.height,0),
      ],
      hasTexture: textcoords == null?false:true,
      texcoords: textcoords,
      indices: [
        Triangle([0,1,2], null, textcoords != null?[0,1,2]:null),
        Triangle([2,3,0], null, textcoords != null?[2,3,0]:null),
      ],
      textureRect: textureRect
    )],
    size: size,
    name: name,
    layer: layer,
    imageLocation: imageLocation,
    type: type,
    color: color
  );
}