Model Manager

Model

A 3D Model is a collection of data, resources, and assets that describe a virtual object. In the ViewAR System, models are created externally by 3D designers and uploaded to ViewAR 3D CMS, making them available to apps built using ViewAR SDK.

Model Manager provides access to all Models used in a ViewAR App and can request additional ones from repository.

Tip

The Model Manager offers a convenient method downloadAll\(\) that downloads and caches all models and their assets used by an application. This way, the program may be fully usable offline.

Fetching a Model from the Catalogue

In order to be able to insert a Model into a Scene, you may retrieve it from the 3D Catalogue. The findModel method does not download the actual model files, but only the Model description. This means that, in order to actually insert it in your scene, you'll need an addditional command ([sceneManager.insertModel]). The Model download happens when inserting.

To retrieve a Model from the Catalogue, use either its Model ID or Foreign Key.

const model = modelManager.findModelById(20); // by Model ID
const model = modelManager.findModelByForeignKey('sheep'); // by Foreign Key
Tip

Keep in mind that every Model ID is unique in the scale of the whole ViewAR CMS, whereas the same Foreign Key may be assigned to multiple Models. The Foreign Key may be defined in the Model Editor. ViewAR Developer Portal > My Content > All Items > Model Editor > Foreign Key

Accessing Categories

Every Model visible in a ViewAR App must be assigned to a Category. ViewAR Developer Portal > My Content > All Items > Model Editor > Category_

To access the Model's Root Category use:

modelManager.rootCategory;

To access the Category's children (they can be models or other Categories), use:

modelManager.rootCategory.children;
Tip

You can go a multiple levels deep:

modelManager.rootCategory.children[0].children;

Download all App Models

In order to fetch all Models (and their assets) used by the Application, so that the program would be fully usable offline, go for:

await modelManager.downloadAll()

ViewAR API Quickstart - Instances - representations of the 3D Models inserted in the Scene ViewAR API References - Complete list of the ViewAR API References ViewAR JavaScript API Playground - ViewAR API interactive tutorial