Skip to content

menloresearch/voxel

Repository files navigation

Voxel API Documentation

This document describes the available API endpoints for managing voxels in the system.

Base URL

All API endpoints are relative to: /api/voxel

Endpoints

POST /api/voxel

Add or remove voxels. Supports both single voxel operations and batch operations.

Single Voxel Operation

{
  "x": 0,
  "y": 0,
  "z": 0,
  "action": "add"  // or "remove"
}

Batch Operation

[
  {
    "x": 0,
    "y": 0,
    "z": 0,
    "action": "add"
  },
  {
    "x": 1,
    "y": 0,
    "z": 0,
    "action": "add"
  },
  {
    "x": 0,
    "y": 1,
    "z": 0,
    "action": "remove"
  }
]

Parameters

  • x (number, required): X coordinate (0-99)
  • y (number, required): Y coordinate (0-99)
  • z (number, required): Z coordinate (0-24)
  • action (string, required): Either "add" or "remove"

Response

{
  "success": true,
  "activeVoxels": ["0,0,0", "1,0,0"]  // Array of active voxel coordinates
}

Error Response

{
  "error": "Error message here",
  "status": 400  // or other appropriate status code
}

GET /api/voxel

Retrieve all active voxels.

Response

{
  "activeVoxels": ["0,0,0", "1,0,0", "0,1,0"]  // Array of active voxel coordinates
}

DELETE /api/voxel

Remove all voxels from the system.

Response

{
  "success": true,
  "activeVoxels": []  // Empty array as all voxels are removed
}

Error Codes

  • 400: Invalid input (coordinates out of range or invalid action)
  • 500: Internal server error

Coordinate System

  • X range: 0-99
  • Y range: 0-99
  • Z range: 0-24

Examples

Adding a Single Voxel

fetch('/api/voxel', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    x: 0,
    y: 0,
    z: 0,
    action: 'add'
  })
});

Adding Multiple Voxels

fetch('/api/voxel', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify([
    { x: 0, y: 0, z: 0, action: 'add' },
    { x: 1, y: 0, z: 0, action: 'add' },
    { x: 0, y: 1, z: 0, action: 'add' }
  ])
});

Getting All Active Voxels

fetch('/api/voxel')
  .then(res => res.json())
  .then(data => console.log(data.activeVoxels));

Removing All Voxels

fetch('/api/voxel', {
  method: 'DELETE'
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published