DatumHuePlatform v0.0.24datumhue.com
Contents

handle18 methods, 8 fields

Voxel

An editable voxel volume returned by datumhue.voxel.new. Cells are 0-based (x, y, z) integer coordinates; each cell holds a 0-based palette index, where 0 is air (empty).

Obtained from
datumhue.physics.raycast, datumhue.physics.raycast_all, datumhue.physics.point_query, datumhue.physics.shapecast, datumhue.voxel.new, SceneNode:on_collision_start (in its callback), SceneNode:on_collision_end (in its callback), PhysicsWorld:raycast and 5 more
Accepted by
datumhue.physics.add_joint, datumhue.physics.raycast, datumhue.physics.raycast_all, datumhue.physics.point_query, datumhue.physics.shapecast, PhysicsWorld:raycast, PhysicsWorld:raycast_all, PhysicsWorld:point_query and 1 more

The examples on this page start from:

lua
local scene = datumhue.scene.new({ width = 320, height = 240 })
scene:mount({ width = 320, height = 240 })
local volume = datumhue.voxel.new(scene, {
    width = 16,
    height = 8,
    depth = 16,
    pos = datumhue.math.vec3(-8, 0, -8),
})

Fields 8

FieldTypeAccessDescription
posVec3read/writeWorld-space position of the volume's minimum corner.
rotationQuatread/writeRotation quaternion about the minimum corner.
scaleVec3read/writePer-axis scale on top of the cell size.
widthintegerread-onlyCells along x.
heightintegerread-onlyCells along y.
depthintegerread-onlyCells along z.
cell_sizenumberread-onlyWorld units per cell.
physicsbooleanread/writeWhether the volume carries a static physics body whose collider matches its cells, following every edit; collisions and physics queries name that body as this handle. Assign a boolean to toggle.

Methods 18

Voxel:set

method
Voxel:set(x: integer, y: integer, z: integer, material: integer)

Set the material index at a cell.

Example
volume:palette(1, { color = datumhue.color("#e69875") })
-- 0-based cells: x and z run 0..15 here, y 0..7.
volume:set(0, 0, 0, 1)
volume:set(15, 7, 15, 1)

Voxel:get

method
Voxel:get(x: integer, y: integer, z: integer) -> integer

Read the material index at a cell.

Example
volume:set(3, 0, 3, 1)
-- A palette index; 0 is air.
print(volume:get(3, 0, 3), volume:get(3, 1, 3)) --> 1 0

Voxel:raycast

method
Voxel:raycast(ray: Ray) -> voxel.RaycastHit?

Raycast through the volume with a scene-space ray (the volume's position, rotation, and cell size are accounted for). Returns the hit cell, or nil.

Example
volume:fill(0, 0, 0, 15, 0, 15, 1)
-- A scene-space ray down onto cell (0, 0, 0), whose top is at y = 1.
local from = datumhue.math.vec3(-7.5, 5, -7.5)
local ray = datumhue.math.ray(from, datumhue.math.vec3(0, -1, 0))
local hit = volume:raycast(ray)
print(hit.x, hit.y, hit.z, hit.material) --> 0 0 0 1
print(hit.distance, hit.normal) --> 4.0 vec3(0.0, 1.0, 0.0)

returns voxel.RaycastHit record 6 keys

KeyTypeDescription
xintegerVoxel x coordinate of the hit cell.
yintegerVoxel y coordinate of the hit cell.
zintegerVoxel z coordinate of the hit cell.
materialintegerPalette material index of the hit cell.
distancenumberDistance from the ray origin to the hit, in scene units.
normalVec3Face normal at the hit cell, in cell axes.

Voxel:fill

method
Voxel:fill(x0: integer, y0: integer, z0: integer, x1: integer, y1: integer, z1: integer, material: integer)

Fill an axis-aligned box of cells.

Example
volume:palette(1, { color = datumhue.color("#a7c080") })
-- Both corners are included: a floor of 16 x 1 x 16 cells.
volume:fill(0, 0, 0, 15, 0, 15, 1)
print(volume:count(1)) --> 256

Voxel:palette

method
Voxel:palette(index: integer, opts: voxel.PaletteOptions)

Define a palette material: color, render class, and — with an atlas bound — static per-face or animated block textures.

Example
-- Index 0 is air; define 1..255. light is a level 0..15.
local color = datumhue.color
volume:palette(1, { color = color("#d3c6aa") })
volume:palette(2, { color = color("#dbbc7f"), light = 12 })
volume:palette(3, { color = color("#7fbbb3"), transparent = true })
volume:fill(0, 0, 0, 15, 0, 15, 1)
volume:set(8, 1, 8, 2)
volume:fill(4, 1, 4, 6, 3, 6, 3)

opts voxel.PaletteOptions options 7 keys

KeyTypeDefaultDescription
colorColordatumhue.color(1, 1, 1)Base color; tints the tile when textured.
emissiveColorthe entry renders litEmissive color: entries with one render unlit at this color (channel values above 1 feed bloom).
transparentbooleanfalseTransparent entries render alpha-blended and don't occlude neighboring faces.
lightinteger0Block-light emission level 0..15: cells of this entry glow and light their surroundings, falling off one level per cell.
textureinteger | voxel.TextureFacesthe faces show frames, or the color aloneAtlas tile for every face, or a tile per face. Needs an atlas bound via voxel:atlas. At most one of texture / frames.
framesinteger[]the faces show texture, or the color aloneAnimated tile sequence shown on every face, advancing at fps.
fpsnumberthe tiles advance 4 times per secondAnimation frames per second for frames.

Voxel:atlas

method
Voxel:atlas(atlas: Atlas)

Bind a tile atlas to the volume; palette entries then pick tiles with texture / frames. The atlas image must carry readable pixel data. Binding replaces any previous atlas; a material set with set_material takes precedence over block textures.

Voxel:clear

method
Voxel:clear()

Reset every cell to air.

Voxel:count

method
Voxel:count(material?: integer) -> integer

Count cells holding material, or every non-air cell when omitted.

Example
volume:fill(0, 0, 0, 3, 0, 3, 1)
volume:set(0, 1, 0, 2)
-- Every solid cell, or the cells of one palette index.
print(volume:count(), volume:count(2)) --> 17 1

Voxel:set_material

method
Voxel:set_material(material: Material | Shader)

Set the material for the volume's solid surfaces: a standard Material, or a Shader, whose color the surfaces show unlit. Transparent and emissive faces keep their built-in rendering.

Example
-- A Material or a Shader for every solid face.
local stone = datumhue.material.standard({
    color = datumhue.color("#859289"),
    roughness = 0.9,
})
volume:set_material(stone)
volume:fill(0, 0, 0, 15, 1, 15, 1)

Voxel:capture

method
Voxel:capture() -> integer

Snapshot the current cells as an animation frame; returns the frame's 1-based index for play.

Voxel:play

method
Voxel:play(opts: voxel.PlayOptions)

Play captured frames as a flip-book, swapping the volume's cells on the fps clock; the first frame applies immediately. Cell edits made while playing are overwritten at the next swap.

Example
volume:set(8, 0, 8, 1)
local lit = volume:capture()
volume:set(8, 0, 8, 0)
local dark = volume:capture()
-- Frames are the 1-based indices capture returned.
volume:play({ frames = { lit, dark }, fps = 2 })
print(lit, dark) --> 1 2

opts voxel.PlayOptions options 3 keys

KeyTypeDefaultDescription
framesinteger[]every captured frame, in capture orderCaptured frame indices to play, in order.
fpsnumber8Frame swaps per second.
loopingbooleantrueWrap back to the first frame after the last; with it off, playback stops on the last frame.

Voxel:stop

method
Voxel:stop()

Stop playback, leaving the currently shown frame's cells in place.

Voxel:drop_frames

method
Voxel:drop_frames()

Discard every captured frame (and stop any playback), freeing their memory; the current cells stay.

Voxel:remove

method
Voxel:remove()

Remove the volume from its scene.

Voxel:fill_noise

method
Voxel:fill_noise(opts: voxel.FillNoiseOptions)

Set material wherever 3D noise meets the threshold over the region in one call, with no per-cell calls. Cells below the threshold are untouched.

Example
-- Solid wherever the noise at a cell is 0.2 or more.
volume:fill_noise({
    sampler = datumhue.noise.simplex({ seed = 7, frequency = 0.15 }),
    material = 1,
    threshold = 0.2,
})

opts voxel.FillNoiseOptions options 6 keys

KeyTypeDefaultDescription
sampler requiredNoiseSamplerno default3D-sampled noise source.
material requiredintegerno defaultPalette index written where the sample meets the threshold.
thresholdnumber0Minimum sample value (noise output is -1..1).
regionvoxel.Regionthe whole volumeCell region to fill.
scalenumber1Cell → noise-space coordinate scale.
offsetVec3datumhue.math.vec3(0, 0, 0)Noise-space offset, for scrolling or layering.

Voxel:heightmap

method
Voxel:heightmap(opts: voxel.HeightmapOptions)

Fill each (x, z) column with material up to the height the source yields — terrain from noise, a grid, or a heightmap image in one call.

Example
-- Each column rises up to 6 cells where the noise reaches 1.
volume:heightmap({
    source = datumhue.noise.perlin({ seed = 3, frequency = 0.1 }),
    material = 1,
    max_height = 6,
})

opts voxel.HeightmapOptions options 6 keys

KeyTypeDefaultDescription
source requiredNoiseSampler | Grid | Imageno defaultHeight source: 2D-sampled noise (remapped 0..1), a grid (cell value = height in cells), or an image (luminance, stretched over the region).
material requiredintegerno defaultPalette index columns fill with.
max_heightintegerthe region's full heightHeight in cells a full-strength source value reaches, above the region floor.
regionvoxel.Regionthe whole volumeCell region.
scalenumber1Cell → noise-space scale for noise sources.
offsetVec2datumhue.math.vec2(0, 0)Noise-space offset for noise sources.

Voxel:stamp_grid

method
Voxel:stamp_grid(opts: voxel.StampGridOptions)

Write a 2D grid into one slice of the volume — dungeon layouts, automata output, or path maps become geometry in one pass.

Example
local plan = datumhue.grid.new(16, 16)
plan:fill_rect(2, 2, 12, 12, 1)
plan:fill_rect(4, 4, 8, 8, 2)
-- A floor plan at height 0: grid value 1 becomes palette index 1.
volume:stamp_grid({
    grid = plan,
    plane = "xz",
    at = 0,
    materials = { [1] = 1, [2] = 2 },
})

opts voxel.StampGridOptions options 4 keys

KeyTypeDefaultDescription
grid requiredGridno default2D source; its (x, y) maps onto the plane's axes.
plane required"xz" | "xy" | "zy"no defaultSlice orientation: xz is a floor plan at height at, xy a wall at depth at, zy a wall at column at.
at requiredintegerno defaultThe fixed coordinate of the slice.
materialstablepositive grid values write directly as palette indicesMap of grid value → palette index; unmapped values leave cells untouched.

Voxel:stamp_image

method
Voxel:stamp_image(opts: voxel.StampImageOptions)

Write image pixels into one slice by nearest-palette-color match; pixels with alpha below 0.5 write air. The image reads upright on wall planes.

Example
volume:palette(1, { color = datumhue.color("#e67e80") })
local art = datumhue.image.new({ width = 16, height = 8 })
local red = datumhue.color("#e67e80")
art:apply(datumhue.image.picture():rectfill(2, 2, 13, 5, red))
-- A wall at z = 0; each pixel takes the nearest palette color.
volume:stamp_image({ image = art, plane = "xy", at = 0 })

opts voxel.StampImageOptions options 3 keys

KeyTypeDefaultDescription
image requiredImageno defaultPixel source; must carry readable pixel data.
plane required"xz" | "xy" | "zy"no defaultSlice orientation (see stamp_grid).
at requiredintegerno defaultThe fixed coordinate of the slice.

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page