Metadata

Overview

Properties and user data are two different ways of storing metadata in a model. Properties are key value pairs. User data is arbitrary binary data. Each NodeId can be associated with multiple properties and user data. For example, you can use properties to associate a NodeId with a manufacturing ID and a revision date, or user data to associate a NodeId with an image.

While we do not cover adding user data in this guide, user data can be added when the model is authored, or inferred when the model is converted.

Retrieving properties

To retrieve a node’s properties, you can use the Model.getNodeProperties() function. This will return a list of key value pairs associated with the given NodeId.

        const properties = await viewer.model.getNodeProperties(nodeId);
        for (const propertyKey in properties) {
            const propertyValue = properties[propertyKey];
        }

Retrieving user data

To retrieve a node’s user data, you can use the Model.getNodeUserDataIndices() function. This will return a list of user data indices. The list of indices can be used to iterate and retrieve the data with the Model.getNodeUserData() function, which returns a Uint8Array containing the data.