Model Manager provides all models available in the app and can request additional models from the repository. Additionally, it has a convenient method downloadAll() which downloads and caches the entirety of models and their assets used in the application, making the app fully usable when offline.
Find models in the catalog
By models in the catalogue, we mean models uploaded to the user account on which the app was created. It may be done through the My Content section on the Developer Portal. In order to be visible for the application, a model needs to be in a proper category and its mode should be set to Active.
To get a model from the catalog you can either retrieve it by using its foreign key which can be defined in the model section at the Developer Portal:
const model = modelManager.findModelByForeignKey('sheep');
or you can access a model by its model id:
const model = modelManager.findModelById('20');
Fetching model from the repository
By models in the repository, we mean all models uploaded to the ViewAR database. Those models do not need to be included in your app exclusively. This way you can also access models from different apps.
With the following line you are able to fetch any model from the repository by passing its model id as an argument. Please note that the getModelFromRepository method does not download the actual model files, but only the model description. The download happens when inserting the model.
const model = await modelManager.getModelFromRepository('20');
To access the root category, use:
to access its children, which can be models or other categories, use:
to go further you need to access the children by index:
Downloading all app models
to fetch all models of the entire app you can use the following command: