<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ImagePresentationComponent/Spatial3DImage/generate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation26ImagePresentationComponentV14Spatial3DImageC8generateyyYaKF"
  },
  "title" : "generate()"
}
-->

# generate()

Creates a 3D representation of the image if one does not already exist.

```
@abi(final func generateNonisolatedNonsendingFinal() async throws) nonisolated(nonsending) final func generate() async throws
```

## Discussion

This method checks for cancellation of an enclosing `Task` during generation,
and cancels its own async generation early (by throwing an error) if task cancellation is detected.

> Throws: Throws an error if the underlying monoscopic image does not contain
> valid data to generate a spatial 3D representation;
> or if a spatial 3D representation has already been generated.

Also throws an error if the image size does not meet the following requirements:

- At least 320 pixels on its shortest side
- At most 16,384 pixels on its largest side
- Aspect ratio between 1:3 and 3:1

---

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)