Docs
Art Engine
Custom Plugins
Renderers
Interface

Renderers Interface

All input renderer in the Art Engine implement the RendererInterface<RendererDataType> interface. This interface defines the basic structure that an renderer plugin should follow.

interface RendererInterface<RendererDataType> {
  init: (props: RendererInitPropsInterface) => Promise<void>;
  render: () => Promise<ItemsRenders<RendererDataType>>;
}
  • RendererInterface<RendererDataType>: This interface outlines the structure that renderer plugins should follow. It's parameterized with a generic type RendererDataType which represents the type of data that the renderer plugin will produce.
  • init(props: RendererInitPropsInterface) => Promise<void>: This method initializes the renderer plugin. It takes an object of type RendererInitPropsInterface as an argument, containing the necessary initialization properties. The method returns a promise that resolves when the initialization is complete.
  • render() => Promise<ItemsRenders<RendererDataType>>: This method is responsible for performing the rendering process. It returns a promise that resolves to an object of type ItemsRenders<RendererDataType>, which is the rendered data produced by the plugin.
interface ItemsRenders<RenderDataType> {
  [itemUid: string]: ItemPropertiesInterface<RenderDataType>[];
}

ItemsRenders<RenderDataType>: This is a data structure that represents the renders produced by a renderer plugin. It's an object where the keys are item UIDs (unique identifiers) and the values are arrays of render data of type RenderDataType. This structure allows you to store multiple render data sets associated with different items.

interface RendererInitPropsInterface {
  seed: string;
  cachePath: string;
  attributesGetter: ItemsDataManager["getAttributes"];
}

RendererInitPropsInterface: This interface defines the properties required to initialize a renderer plugin. It includes the following properties:

  • seed: A string value that serves as a seed for deterministic behavior. Similar to the input plugins, this can be used to ensure consistent results when rendering.
  • cachePath: A string representing the path where the renderer plugin can store temporary cache data. This can be used to store any intermediate files or data that the exporter might need to use.
  • attributesGetter: A reference to a function called getAttributes from the ItemsDataManager. This function is used to access the attributes data generated by the generators.