Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BunnyNabbit/celaria-formats/llms.txt

Use this file to discover all available pages before exploring further.

CelariaUvMap reads .cuvdata binary files and returns an array of UV texture coordinate entries. Each entry describes the texture region applied to a specific face of a specific block. This class is parse-only — there is no serialization method.
CelariaUvMap only supports reading .cuvdata files. Writing UV data back to the binary format is not supported.

Static properties

fileSignature

CelariaUvMap.fileSignature // "cuvdata"
The 7-character ASCII string that every .cuvdata file begins with. parse checks this value and throws if the buffer does not begin with it.

Static methods

parse(buffer)

Parses a .cuvdata binary buffer and returns an array of UvData objects.
buffer
Buffer
required
A Node.js Buffer containing the raw bytes of a .cuvdata file.
Returns: UvData[] The returned array contains one entry per face entry stored in the file. The file header contains a block count and a face count; the returned array length equals the face count.
Throws Error("Magic mismatch.") if the first 7 bytes of the buffer do not equal "cuvdata".Throws Error("Unsupported version ${version}.") if the version byte in the file header is not 0. Only version 0 is currently supported.
import fs from "node:fs"
import { CelariaUvMap } from "celaria-formats"

const buffer = fs.readFileSync("./myMap.cuvdata")
const uvData = CelariaUvMap.parse(buffer)

console.log(uvData.length)    // number of UV face entries
console.log(uvData[0])
// {
//   blockId: 0,
//   faceId: 2,
//   startX: 0.25,
//   startY: 0,
//   endX: 0.5,
//   endY: 0.25
// }

UvData type

Each element returned by parse is a UvData object with the following fields:
blockId
number
required
The index of the block this UV entry applies to, corresponding to a block’s position in the map’s instance list.
faceId
number
required
The face of the block this UV entry applies to. Face indices are specific to the block geometry used by Celaria.
startX
number
required
The left edge of the UV region in normalized texture coordinates (0.0–1.0).
startY
number
required
The top edge of the UV region in normalized texture coordinates (0.0–1.0).
endX
number
required
The right edge of the UV region in normalized texture coordinates (0.0–1.0).
endY
number
required
The bottom edge of the UV region in normalized texture coordinates (0.0–1.0).
All four coordinate fields (startX, startY, endX, endY) are stored as 32-bit floats in the binary format.

Full example

import fs from "node:fs"
import { CelariaUvMap, CelariaMap } from "celaria-formats"

// Parse both the map and its UV data
const map = CelariaMap.parse(fs.readFileSync("./myMap.cmap"))
const uvData = CelariaUvMap.parse(fs.readFileSync("./myMap.cuvdata"))

// Group UV entries by block index
const byBlock = {}
for (const entry of uvData) {
  if (!byBlock[entry.blockId]) byBlock[entry.blockId] = []
  byBlock[entry.blockId].push(entry)
}

// Print UV regions for the first block
const block0Uvs = byBlock[0] ?? []
for (const uv of block0Uvs) {
  console.log(`Face ${uv.faceId}: (${uv.startX}, ${uv.startY}) → (${uv.endX}, ${uv.endY})`)
}

UV maps guide

How to read and work with .cuvdata UV texture data.

CelariaMap

The finalized map format that UV data corresponds to.

Types

Type definitions including UvData.

Block

Block instances that UV entries reference by index.

Build docs developers (and LLMs) love