Use the glTF 2.0 Display component to assign materials defined with the glTF 2.0 Material component to geometry. The component takes two inputs: the geometry to display, and the material definition that is returned by the glTF 2.0 material. The material input is used as default material for all the input geometry, except when material attributes are defined (see below section).

Applying several materials with a single component

It is possible to use a tree of geometry along with a list of materials, in order to apply different materials to each branch of the input geometry tree . See this article for more information about this method: .

However, the glTF 2.0 Display component also offers a more flexible and intuitive way to apply separate materials to each piece of geometry, and that without having to use any complex data structure.

Each geometry object can be assigned a material attribute individually, using the Construct Attributes and Inject Attributes components. Construct an Attributes object with the reserved name “material” and use a glTF 2.0 material as the value, and then inject this attribute in the geometry:

When using this method, it is not necessary to connect any material to the Material input of the Display component. However, if a material is connected, it will be used as the default for all geometry which does not contain a material attribute. In the example below, the sphere gets a material attribute (blue material) while the cube does not get any attribute. Therefore the sphere is displayed with its assigned attribute while the cube is displayed using the fallback red material used as input of the display component.

Read more about the Attributes system here.

Attaching transformations

If the same geometry element is reused multiple times in the final display, it is more efficient to store the element only once and attach transformations to the element. That way the online viewer only needs to receive the element once and read the attached transformations to display the other instances of the same object. Attach transformations using the Attach Transformations component before sending geometry to the glTF 2.0 display component and the viewport will preview all instances of the object. Read more about attaching transformations here.