Protocol

Component

A representation of a geometry or a behavior that you apply to an entity.

Declaration

protocol Component

Overview

You assemble a particular combination of behavior and appearance for an entity by adding components to the components set of an Entity instance. Each component, represented by a type that conforms to the Component protocol, defines a single aspect of the entity. For example, one might define a position in space, while another provides a visual appearance. You can add at most one component of a given type to an entity.

Diagram showing the components present in different kinds of entities.

RealityKit has a variety of predefined component types that you can use to add commonly needed characteristics. For example, the ModelComponent specifies visual appearance with a mesh and materials. The CollisionComponent contains a shape and other information used to decide if one entity collides with another.

You can also define custom component types. When you do, register that type with the system by calling the new component’s registerComponent() method—a default implementation of which is provided by the Component protocol. Call this method once before using the component type. You don’t need to make this call for component types that RealityKit provides.

Topics

Registering a Component Type

static func registerComponent()

Registers a new component type.

See Also

The Entity Component System

class Scene

A container that holds the collection of entities rendered by an AR view.

class Entity

An element of a RealityKit scene to which you attach components that provide appearance and behavior characteristics for the entity.

protocol Resource

A shared resource you use to configure a component, like a material, mesh, or texture.