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.

Sphere is a collectible object — a red sphere placed in the level that players can pick up. It is one of the simpler map objects: it carries no properties beyond the position it inherits from Instance. Sphere has an instanceId of 1.

Constructor

new Sphere()
The constructor takes no arguments and initializes position to [0, 0, 0] via the Instance base class.

Properties

position
[number, number, number]
World-space position of the sphere, inherited from Instance. Defaults to [0, 0, 0]. Z is the gravity axis.

Getters

instanceId
1
Always returns 1. Used during binary serialization to identify this object as a Sphere.

Example

Placing collectible spheres in a map

import { Sphere, EditableCelariaMap } from "celaria-formats"

const map = new EditableCelariaMap()
map.name = "Sphere Course"

// Place three spheres along a path
const positions = [
  [0, 5, 2],
  [0, 15, 4],
  [0, 25, 6],
]

for (const pos of positions) {
  const sphere = new Sphere()
  sphere.position = pos
  map.instances.push(sphere)
}

Reading sphere positions from a parsed map

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

const buffer = fs.readFileSync("./myMap.cmap")
const map = CelariaMap.parse(buffer)

const spheres = map.instances.filter(instance => instance instanceof Sphere)

console.log(`Found ${spheres.length} sphere(s):`)
for (const sphere of spheres) {
  const [x, y, z] = sphere.position
  console.log(`  x=${x}, y=${y}, z=${z}`)
}

Instance

Abstract base class that Sphere extends.

Map objects guide

Overview of all map object types and how to use them.

Block

Rectangular geometry block with multiple surface types.

Types reference

Vector3 and other type definitions.

Build docs developers (and LLMs) love