Object constructor

Object({
  1. List<Mesh>? mesh,
  2. Vector3? position,
  3. Vector3? rotation,
  4. Vector3? scale,
  5. Size? size,
  6. String name = 'Object',
  7. bool visible = true,
  8. int imageLocation = 0,
  9. SelectedType type = SelectedType.image,
  10. Color color = Colors.red,
  11. int layer = 1,
  12. bool scaleAllowed = true,
})

Implementation

Object({
  List<Mesh>? mesh,
  Vector3? position,
  Vector3? rotation,
  Vector3? scale,
  Size? size,
  this.name = 'Object',
  this.visible = true,
  this.imageLocation = 0,
  this.type = SelectedType.image,
  this.color = Colors.red,
  this.layer = 1,
  this.scaleAllowed = true,
}){
  if (position != null) position.copyInto(this.position);
  if (rotation != null) rotation.copyInto(this.rotation);
  if (scale != null) scale.copyInto(this.scale);
  updateTransform();
  this.size = size ?? const Size(50,50);
  if(type == SelectedType.collision){layer = 4;}
  else if(type == SelectedType.rect){layer = 2;}
  this.mesh = mesh??[Mesh(
    vertices: [
      Vector3(0,0,0),
      Vector3(this.size.width,0,0),
      Vector3(this.size.width,this.size.height,0),
      Vector3(0,this.size.height,0)
    ],
    indices: [Triangle([0,1,2], null, null),Triangle([2,3,0], null, null)],
    colors: [color,color]
  )];
}