Asset Providers
Resource providers are necessary for implementing the HostAdaptor. They provide necessary means to access the available garments, avatars and scenes.
The asset providers need to be implemented per dressing room mode (“2D_Parallax” recommended, “3D”, “2D” deprecated).
Depending on the type of asset the provider is providing, it needs to implement additional interfaces on top of the following base interface.
/**
* Provides the available ids as well as the asset bundles for a specific resource type.
*/
interface AssetProvider {
/**
* Returns a list of ids for the available resources for this provider.
*/
getIds(): Awaitable<Array<string>>;
/**
* Returns the asset bundle for a specific resource
* @param id Unique ID if the garment as used in your systems
*/
getById(id: string): Awaitable<Core.AssetInfo | undefined>;
}
The method getIds
provides the modal dressing room with a list of ids of the available assets that should be shown. For example the garments that are available in the Try-On section of the modal dressing room, or the scenes that can be selected in the Scene section of the modal dressing room.
The method getById
should return an asset information object that can be used to access the necessary PICTOFiT resources to handle this asset. Mostly a representation of the Web Result from the Content Service. This method can also be able to resolve assets that are not in the list returned by the getIds
method. This might be necessary to open a shared look from a link.
Garment Provider
/**
* Provides information about the garments in the dressing room
*/
export interface GarmentProvider extends AssetProvider {
/**
* Return the display name of a garment as string. This will be shown for example below
* the garment tile and in the details drawer.
* @param id Unique ID if the garment as used in your systems
*/
getName(id: string): Awaitable<string | undefined>;
/**
* Returns an url to the thumbnail image of a garment. This will be shown for example below
* the garment tile and in the details drawer.
*/
getThumbnail(id: string): Awaitable<string | undefined>;
/**
* Removes the given garment from the dressing room.
* Is called when someone clicks "Remove from dressing room" on a garment tile.
* @param id Unique ID if the garment as used in your systems
*/
removeById(id: string): Awaitable<void>;
/**
* Callback to add a garments from a shared look into the current dressing room / garment provider.
* @param id Unique ID if the garment as used in your systems
* */
addById?: (id: string) => void;
}
The garment provider, which is an asset provider specifically for garments should implement the above interface as well. It should resolve metadata per asset to be displayed in the modal dressing room, as well as methods that can be used from the modal dressing room perspective to change the list of currently selected garments.
Scene Provider
The scene provider has to implement the following interface in addition to the base interface. Similar to the the garment provider to serve additional information on assets to be shown in the modal dressing room component.
/**
* Provides information & assest for the scenes available in the dressing room.
*/
export interface SceneProvider extends AssetProvider {
/**
* Returns the display name of the scene as string. This will be shown in the scene selection drawer.
* @param id Unique ID of the scene
*/
getName(id: string): Awaitable<string | undefined>;
/**
* Returns an url to the thumbail image for the scene. This will be shown in the scene selection drawer.
* Thumbnails should ideally be square.
* @param id
*/
getThumbnail(id: string): Awaitable<string | undefined>;
}
Avatar Provider
The avatar provider has to implement the following interface in addition to the base interface. Similar to the the garment provider to serve additional information on assets to be shown in the modal dressing room component.
/**
* Provides information & assets for the avatars available in the dressing room.
*/
export interface AvatarProvider extends AssetProvider {
/**
* Returns the display name of the avatar as string. This will be shown in the avatar selection drawer.
* @param id Unique ID of the avatar
*/
getName(id: string): Awaitable<string | undefined>;
/**
* Returns an url to the thumbail image of the avatar. This will be shown in the avater selection drawer.
* Thumbnails should ideally be square.
* @param id Unique ID of the avatar
*/
getThumbnail(id: string): Awaitable<string | undefined>;
/**
* Returns the gender of an avatar as enum.
* @param id Unique ID of the avatar
*/
getGender(id: string): Awaitable<Core.Gender | undefined>;
}