Voxels
A Swift library for storage, manipulation, export, and 3D rendering of Voxel data.
import Voxels
Module information
- Declarations
- 224
- Symbols
- 492
Overview
The library supports storing and manipulating voxels, with convenience functions to convert the data stored within a collection of voxels into surfaces by generating 3D meshes. The general term of art for this process is isosurface extraction, originating from medical image technologies. The library includes implementations of several renderers:
simple block mesh, rendering voxels as a cube when they’re determined to be opaque.
Marching Cubes, which does simple linear smoothing to represent angles.
Surface Net, which treats voxel data as a signed distance field (SDF), to render smooth surfaces.
The library also includes a converter to generate a collection of voxels from a 2D height map (using the Heightmap library) to a collection of voxels.
Voxel Storage
struct VoxelHash<T>
A collection of voxels backed by a hash table.
struct VoxelArray<T>
A collection of voxels backed by an array.
protocol VoxelAccessible<Element>
A type that holds a collection of voxels.
protocol VoxelWritable<Element>
A type that holds an updatable collection of voxels.
Voxel Updates
struct VoxelUpdate<T>
A type that represents an update to a single voxel from a collection.
Renderers
class BlockMeshRenderer
A renderer for creating block 3D meshes of opaque voxels.
protocol VoxelBlockRenderable
A type that can be rendered as opaque blocks.
class MarchingCubesRenderer
A renderer that implements the marching cubes algorithm to create a 3D mesh from voxel data.
class SurfaceNetRenderer
A renderer for creating smooth 3D meshes of the surface of signed distance value (SDF) data.
protocol VoxelSurfaceRenderable
A type that can be rendered as a surface.
Converters
enum HeightmapConverter
Utility functions for converting height maps into collections of voxels.
enum SDF
A collection of signed distance functions
struct SDFSampleable<T>
A wrapper for a signed distance function.
protocol VoxelSampleable
A type that can be sampled at regular locations.
Supporting Types
struct VoxelBounds
The coordinate bounds of a set of voxels.
struct VoxelIndex
The coordinates of a voxel location.
protocol StrideIndexable
A type that can be accessed with a single, linear location within an array.
struct VoxelScale<T>
A scale that provides a mapping between Voxel coordinates and 3D points.
struct MeshBuffer
A buffer of vertex indices, positions and normals that make up a generated 3D mesh.
typealias Vector
A compact representation of a 3 dimensional vector.
let CUBE_CORNERS: [VoxelIndex]
The collection of voxel index offsets for the corners of a voxel.
enum CubeFace
The set of cube faces and relevant directions and coordinates of those faces.
Errors
Sample Data
enum SampleMeshData
Example voxel collections.
Code Examples
Code Examples
Code examples
Read More