<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GroupActivities",
  "identifier" : "/documentation/GroupActivities/SpatialTemplateElementDirection",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Group Activities"
    ],
    "preciseIdentifier" : "s:15GroupActivities31SpatialTemplateElementDirectionV"
  },
  "title" : "SpatialTemplateElementDirection"
}
-->

# SpatialTemplateElementDirection

The initial direction a participant faces when an activity starts.

```
struct SpatialTemplateElementDirection
```

## Overview

A `SpatialTemplateElementDirection` type indicates where a participant
faces at the start of an activity. You might configure participants to
face your app’s content, another participant, or an arbitrary point in
the shared coordinate system. You can also modify an existing direction
value by adding an arbitrary amount of additional rotation. When a
participant joins an activity, the system sets the initial orientation
of their spatial Persona to the direction assigned to their seat position.
If you don’t specify an initial direction for a seat, the participant
faces your app’s content.

The following example creates a spatial template for a table tennis game
with four participants and a spectator. The template places the red and
blue teams at opposite ends of the table along the z-axis, and each person
faces the app’s content along that axis. The final participant sits to
the side of the table to watch the game.

```
struct TableTennis: SpatialTemplate {
    enum Role: String, SpatialTemplateRole {
        case blueTeam
        case redTeam
    }

    var elements: [any SpatialTemplateElement] = [
        .seat(position: .app.offsetBy(x: -1, z: -3), direction: .alignedWith(appAxis: .z), role: Role.blueTeam),
        .seat(position: .app.offsetBy(x: -1, z:  3), direction: .alignedWith(appAxis: .z), role: Role.redTeam),

        .seat(position: .app.offsetBy(x:  1, z: -3), direction: .alignedWith(appAxis: .z), role: Role.blueTeam),
        .seat(position: .app.offsetBy(x:  1, z:  3), direction: .alignedWith(appAxis: .z), role: Role.redTeam),

        .seat(position: .app.offsetBy(x: -2, z:  0))
    ]
}
```

## Topics

### Looking at a specific location

[`static func lookingAt(any SpatialTemplateElement) -> SpatialTemplateElementDirection`](/documentation/GroupActivities/SpatialTemplateElementDirection/lookingAt(_:)-70j0i)

Creates a direction that orients the participant to face
another template element.

[`static func lookingAt(SpatialTemplateElementPosition) -> SpatialTemplateElementDirection`](/documentation/GroupActivities/SpatialTemplateElementDirection/lookingAt(_:)-1d7ak)

Creates a direction that orients the participant to face the
specified point in the shared coordinate space.

### Looking along an axis

[`static func alignedWith(appAxis: SpatialTemplateElementAxis) -> SpatialTemplateElementDirection`](/documentation/GroupActivities/SpatialTemplateElementDirection/alignedWith(appAxis:))

Creates a direction that orients the participant to look along
the specified axis in the direction of the app’s content.

[`struct SpatialTemplateElementAxis`](/documentation/GroupActivities/SpatialTemplateElementAxis)

An axis to use when aligning elements in a spatial template.

### Rotating the element

[`func rotatedBy(Angle2D) -> SpatialTemplateElementDirection`](/documentation/GroupActivities/SpatialTemplateElementDirection/rotatedBy(_:))

Returns a new direction structure that adds the specified rotation
angle to the current direction’s value.

### Operators

[`static func + (SpatialTemplateElementDirection, Angle2D) -> SpatialTemplateElementDirection`](/documentation/GroupActivities/SpatialTemplateElementDirection/+(_:_:))

Adds the y-axis rotations for the specified values together and returns
a new structure with the result.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)