---
title: ModelComponent
framework: realitykit
role: symbol
role_heading: Structure
path: realitykit/modelcomponent
---

# ModelComponent

A component that contains a mesh and materials for the visual appearance of an entity.

## Declaration

```swift
struct ModelComponent
```

## Mentioned in

Automatically animating RealityKit entities Creating a plane with low-level mesh

## Overview

Overview This component is a foundational component for all visual content in RealityKit. Use ModelComponent to render 3D models by attaching it to any Entity in your RealityKit scene. To create a ModelComponent, you need a mesh and the number of materials that mesh expects, which is typically one. For example, here’s how to create a simple blue, metallic box using generateBox(size:cornerRadius:), and SimpleMaterial: let mesh = MeshResource.generateBox(size: 1, cornerRadius: 0.05) let material = SimpleMaterial(color: .blue, isMetallic: true)

let modelComponent = ModelComponent(mesh: mesh, materials: [material])

let entity = Entity() entity.components.set(modelComponent)

Make different primitive shapes, like spheres with generateSphere(radius:), or cylinders with generateCylinder(height:radius:), or create custom shapes with MeshDescriptor. For more information about materials, see Applying realistic material and lighting effects to entities tip: To load a USDZ or reality file to your app, use an entity initializer such as init(named:in:) or init(contentsOf:withName:). Use other components like CollisionComponent, PhysicsBodyComponent, PhysicsMotionComponent, and InputTargetComponent to make entities interactive and dynamic.

## Topics

### Creating a model component

- [init(mesh:materials:)](realitykit/modelcomponent/init(mesh:materials:).md)

### Configuring a mesh

- [mesh](realitykit/modelcomponent/mesh.md)

### Configuring the materials

- [materials](realitykit/modelcomponent/materials.md)

### Modifying the bounding box for rendering

- [boundsMargin](realitykit/modelcomponent/boundsmargin.md)

## Relationships

### Conforms To

- [Component](realitykit/component.md)
- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)

## See Also

### Model display

- [Creating 3D entities with RealityKit](visionos/creating-3d-entities-with-realitykit.md)
- [Creating 3D models as movable windows](visionos/creating-a-volumetric-window-in-visionos.md)
- [Creating a 3D painting space](visionos/creating-a-painting-space-in-visionos.md)
- [Tracking and visualizing hand movement](visionos/tracking-and-visualizing-hand-movement.md)
- [Applying mesh to real-world surroundings](visionos/applying-mesh-to-real-world-surroundings.md)
- [Obscuring virtual items in a scene behind real-world items](visionos/obscuring-virtual-items-in-a-scene-behind-real-world-items.md)
- [Manipulating models with RealityKit](realitykit/manipulating-models-with-realitykit.md)
- [MeshResource](realitykit/meshresource.md)
- [ModelEntity](realitykit/modelentity.md)
