<!--
{
  "availability" : [
    "iOS: 26.4.0 -",
    "iPadOS: 26.4.0 -",
    "macCatalyst: 26.4.0 -",
    "macOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ImmersiveMediaSupport",
  "identifier" : "/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Immersive Media Support"
    ],
    "preciseIdentifier" : "s:21ImmersiveMediaSupport22FadeEnvironmentCommandV"
  },
  "title" : "FadeEnvironmentCommand"
}
-->

# FadeEnvironmentCommand

A command type for opacity fading environment backdrops during immersive media playback.

```
struct FadeEnvironmentCommand
```

## Overview

Opacity fade is used to apply requested opacity to the AIV environment backdrops. Fade environment commands can be absolute time based or offset based. If fade commands are absolute time based, then property time dictates the time it needs to start executing and keep fading until the duration property value. On the other hand if they are offset based, then offset property dictates the fade percentage from the start time of the fade command till the duration of the fade. If the fade has to start at time 0.0 second of the playback for duration of 1.0 seconds and if the media FPS is 90, then first frame should be accompanied with presentation metadata with fade command which has 0.011 as offset. Second frame should have fade command with offset 0.022 and so on. For the 90th frame, we should receive offset 1.0.

## Topics

### Initializers

[`init(from: any Decoder) throws`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/init(from:))

Creates a `FadeEnvironmentCommand` instance from the specified decoder.

### Instance Properties

[`var direction: FadeEnvironmentCommand.FadeDirection`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/direction)

Fade direction for this command instance.

[`var duration: CMTime`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/duration)

The duration of the command - this can be .zero if the command has no duration

[`var id: Int`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/id)

A unique command ID for the immersive media file.

[`var offset: CMTime?`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/offset)

The offset from the start time of this command.

[`var opacity: Float`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/opacity)

The fade opacity value between `0.0` to `1.0`.
This value represents the target opacity of the environment backdrops during playback after fading completes.

[`var time: CMTime`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/time)

The time this command starts during playback.

### Instance Methods

[`func encode(to: any Encoder) throws`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/encode(to:))

Encodes an instance of fade environment command.

### Enumerations

[`enum FadeDirection`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/FadeDirection)

A value that represents the direction of the fade environment command.

### Initializers

[`init(id: Int, time: CMTime, duration: CMTime, direction: FadeEnvironmentCommand.FadeDirection, opacity: Float, offset: CMTime?)`](/documentation/ImmersiveMediaSupport/FadeEnvironmentCommand/init(id:time:duration:direction:opacity:offset:))

Creates a fade environment command instance.

## Relationships

### Conforms To

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

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

---

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)