<!--
{
  "availability" : [
    "Reality Composer Pro: -",
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ComputeGraph",
  "identifier" : "/documentation/ComputeGraph/ComputeGraphSimulation/spawn(elements:in:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Compute Graph",
      "ComputeGraph"
    ],
    "preciseIdentifier" : "s:12ComputeGraph0aB10SimulationC5spawn8elements2in5usingySayAA22ElementSpawnParametersVG_SiSgSo24MTLComputeCommandEncoder_ptF"
  },
  "title" : "spawn(elements:in:using:)"
}
-->

# spawn(elements:in:using:)

Spawns new elements into the simulation with the given initial parameters.

```
final func spawn(elements: borrowing [ElementSpawnParameters], in systemID: Int?, using encoder: any MTLComputeCommandEncoder)
```

## Parameters

`elements`

The initial state for each element to spawn.

`systemID`

The index of the particle simulation stage to spawn into,
or `nil` to spawn into all simulations.

`encoder`

The compute command encoder to encode the spawn operation with.

## Discussion

Each entry in `elements` produces one new element. The initialization
stage of the simulation graph runs on the newly spawned elements before
they participate in subsequent simulation steps, and may read or overwrite
the values supplied here.

---

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)