Configurator API - Client-side
The client-side configurator API contains functions for retrieving and setting the product attribute values and can be accessed from the player API, which in turn is the result of the promise returned when embedding the player.
Functions
configurator.getAttributes() ⇒ Array of Attribute Objects
Returns an array of attribute objects. This object contains defaultValue, id, name, type and an array of values for that attribute.
configurator.getConfiguration() ⇒ Configuration Object
Returns the current configuration for the product as an object containing Attribute/Value pairs.
configurator.setConfiguration({ AttributeName: AttributeValue, .... })
Sets product configuration using a Configuration Object as parameter. Can assign one or multiple attributes within the same call.
Threekit's Configurator API is initialized by calling player.getConfigurator()
This can be initialized at anytime but typically it's initialized with the player and stored somewhere for later use.
configurator.getMetadata() ⇒ Metadata Object
Returns the metadata for the product as an object containing Key/Value pairs.
Attribute Types
It's worth mentioning the difference between primitive values & part reference values. Primitive values (e.g. String, Number, etc) are straightforward.
Primitive Values
However, reference attributes (e.g. materials, parts, etc.) receive the id of the Threekit Item/Asset. For example, to set the Wheels attribute in this example, we need to pass the id of the Wheel Item as the value.
Part References
Setting Values
Let's begin with an example that takes values from an external form and sets the player's configuration.