Skip to content

Commit

Permalink
Document the voxel data interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrimpyCat committed Aug 19, 2020
1 parent 087f486 commit 98de480
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/vox/data.ex
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
defprotocol Vox.Data do
@moduledoc """
Generic interface for voxel data.
"""
@type no_impl :: nil

@type face :: :left | :right | :bottom | :top | :front | :back
@type origin :: { face, face, face }

@doc """
Gets the orientation of the coordinate system the voxel data uses.
"""
@spec origin(t) :: origin
def origin(data)

@doc """
Gets all the models represented by the voxel data
"""
@spec models(t) :: [Vox.Model.t]
def models(data)

@doc """
Get the implementation for any optional functions.
"""
@spec impl(t, :model) :: ((t, Vox.Model.id) -> Vox.Model.t | nil) | no_impl
@spec impl(t, :model_count) :: (t -> non_neg_integer) | no_impl
@spec impl(t, :voxel) :: ((t, Vox.Model.id, Vox.Model.axis, Vox.Model.axis, Vox.Model.axis) -> { :ok, Vox.Voxel.t | nil } | Vox.Model.error(Vox.Model.bounds_error | Vox.Model.unknown_error)) | no_impl
Expand Down

0 comments on commit 98de480

Please sign in to comment.