<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLVoxelArray/setVoxelAtIndex(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLVoxelArray(im)setVoxelAtIndex:"
  },
  "title" : "setVoxelAtIndex(_:)"
}
-->

# setVoxelAtIndex(_:)

Sets voxel characteristics at the specified index in the array.

```
func setVoxelAtIndex(_ index: MDLVoxelIndex)
```

## Parameters

`index`

A voxel index to update in the array.

## Discussion

A [`MDLVoxelIndex`](/documentation/ModelIO/MDLVoxelIndex) value describes both a location in the voxel array and the characteristics of the volume at that location. To set characteristics at a location, pass a [`MDLVoxelIndex`](/documentation/ModelIO/MDLVoxelIndex) value whose first three components are the x, y, and z coordinates of that location and whose w coordinate specifies the *shell level* at that location.

Shell level describes the relationship of that location’s volume to the object modeled by the voxel array: 0 for a voxel on the object’s surface, a positive value for voxels outside of the object’s volume, and a negative value for voxels inside the object’s volume. For voxels inside or outside the object, the magnitude of shell level indicates the number of voxels between the index and a voxel on the surface of the object.

---

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)