<!--
{
  "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",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLVoxelArray"
  },
  "title" : "MDLVoxelArray"
}
-->

# MDLVoxelArray

A model of a 3D object’s solid volume as a collection of *voxels*, or cubic units.

```
class MDLVoxelArray
```

## Overview

Unlike a mesh, which models only surface topology, a voxel array models the solid volume of a 3D object. Voxels are useful for modeling volumetric phenomena (such as clouds and fire), performing solid geometry operations (such as intersection and union), and preparing a 3D design for real-world physical production.

## Topics

### Creating a Voxel Array

[`-  initWithAsset:divisions:interiorShells:exteriorShells:patchRadius:`](/documentation/ModelIO/MDLVoxelArray/init(asset:divisions:interiorShells:exteriorShells:patchRadius:))

Initializes a voxel array that models the volume of 3D objects in the specified asset and creates the specified number of voxel shells.

[`-  initWithAsset:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:`](/documentation/ModelIO/MDLVoxelArray/init(asset:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:))

Initializes a voxel array that models the volume of 3D objects in the specified asset, creating voxel shells for the specified distances from the object’s surface.

[`-  initWithData:boundingBox:voxelExtent:`](/documentation/ModelIO/MDLVoxelArray/init(data:boundingBox:voxelExtent:))

Initializes a voxel array with the specified voxel data.

### Examining Voxels

[`count`](/documentation/ModelIO/MDLVoxelArray/count)

The number of voxels in the array.

[`voxelIndexExtent`](/documentation/ModelIO/MDLVoxelArray/voxelIndexExtent)

The indexes that define the corners of the three-dimensional voxel grid.

[`-  voxelExistsAtIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:`](/documentation/ModelIO/MDLVoxelArray/voxelExists(atIndex:allowAnyX:allowAnyY:allowAnyZ:allowAnyShell:))

Returns a Boolean value indicating whether the voxel array contains voxel data for the specified index.

[`-  voxelsWithinExtent:`](/documentation/ModelIO/MDLVoxelArray/voxels(within:))

Returns a data object containing all voxels within the specified volume.

[`-  voxelIndices`](/documentation/ModelIO/MDLVoxelArray/voxelIndices())

Returns a data object containing all voxels within the voxel array.

### Modifying Voxels

[`-  setVoxelAtIndex:`](/documentation/ModelIO/MDLVoxelArray/setVoxelAtIndex(_:))

Sets voxel characteristics at the specified index in the array.

[`-  setVoxelsForMesh:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:`](/documentation/ModelIO/MDLVoxelArray/setVoxelsFor(_:divisions:interiorNBWidth:exteriorNBWidth:patchRadius:))

Sets voxel values in the array to model the volume of the specified mesh and creates voxel shells for the specified distances from the object’s surface.

[`-  setVoxelsForMesh:divisions:interiorShells:exteriorShells:patchRadius:`](/documentation/ModelIO/MDLVoxelArray/setVoxelsFor(_:divisions:interiorShells:exteriorShells:patchRadius:))

Sets voxel values in the array to model the volume of the specified mesh and creates the specified number of voxel shells.

### Performing Constructive Solid Geometry Operations

[`-  unionWithVoxels:`](/documentation/ModelIO/MDLVoxelArray/union(with:))

Extends the voxel array to also cover the volume of the specified voxel array.

[`-  intersectWithVoxels:`](/documentation/ModelIO/MDLVoxelArray/intersect(with:))

Reduces the voxel array to cover only the volume within both it and another voxel array.

[`-  differenceWithVoxels:`](/documentation/ModelIO/MDLVoxelArray/difference(with:))

Reduces the voxel array to cover only the portion of its volume not covered by another voxel array.

### Relating Voxels to Scene Space

[`boundingBox`](/documentation/ModelIO/MDLVoxelArray/boundingBox)

The extent of the voxel array’s volume in world coordinate space.

[`-  indexOfSpatialLocation:`](/documentation/ModelIO/MDLVoxelArray/index(ofSpatialLocation:))

Returns voxel information corresponding to the specified point in the world coordinate space of the asset from which the voxel array was created.

[`-  spatialLocationOfIndex:`](/documentation/ModelIO/MDLVoxelArray/spatialLocation(ofIndex:))

Returns the location of the specified voxel in world coordinate space.

[`-  voxelBoundingBoxAtIndex:`](/documentation/ModelIO/MDLVoxelArray/voxelBoundingBox(atIndex:))

Returns the extent of the specified voxel’s volume in the world coordinate space of the asset from which the voxel array was created.

### Creating a Mesh from Voxels

[`-  meshUsingAllocator:`](/documentation/ModelIO/MDLVoxelArray/mesh(using:))

Generates a closed polygon mesh around the volume of space the voxel array describes.

### Constants

[`MDLVoxelIndex`](/documentation/ModelIO/MDLVoxelIndex)

A 4-component vector encoding the location of a voxel in a voxel array and describing its relation to an object’s volume.

[`MDLVoxelIndexExtent`](/documentation/ModelIO/MDLVoxelIndexExtent)

The corner voxel indices defining a solid rectangular volume of voxels. Used by the [`voxelIndexExtent`](/documentation/ModelIO/MDLVoxelArray/voxelIndexExtent) property and [`voxels(within:)`](/documentation/ModelIO/MDLVoxelArray/voxels(within:)) method.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

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

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

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

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

[`MDLNamed`](/documentation/ModelIO/MDLNamed)

### Inherits From

[`MDLObject`](/documentation/ModelIO/MDLObject)

---

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)