← Back to Documentation Index

Babylon.js NOA Engine Integration

This document describes the experimental noa-engine adapter for Nova64's Babylon.js voxel backend.

Sponsor

Overview

Nova64 includes an optional, guarded integration with noa-engine, an experimental voxel game engine built on Babylon.js. The adapter is opt-in and must not replace Nova64's shared voxel API: existing carts should continue to call the normal voxel functions whether NOA is active or unavailable.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        Cart (game code)                         │
│              uses nova64.voxel API (api-voxel.js)               │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                      runtime/api-voxel.js                       │
│            Shared voxel API - backend agnostic                  │
│   (terrain gen, physics, entities, lighting, persistence)       │
└─────────────────────────────────────────────────────────────────┘
                                │
                ┌───────────────┼───────────────┐
                ▼               ▼               ▼
┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
│   Three.js GPU   │  │  Babylon.js GPU  │  │  Babylon.js GPU  │
│   (gpu-three.js) │  │  (voxel.js)      │  │  + NOA Adapter   │
│                  │  │                  │  │  (noa-adapter.js)│
└──────────────────┘  └──────────────────┘  └──────────────────┘
        │                       │                    │
        ▼                       ▼                    ▼
┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
│   Three.js       │  │   Babylon.js     │  │   noa-engine     │
│   WebGL Renderer │  │   WebGL Engine   │  │   (optional)     │
└──────────────────┘  └──────────────────┘  └──────────────────┘

Dependency

noa-engine is an optional dependency pinned to the latest published 0.33.x line. In the Nova64 repo, install through the normal WSL workflow:

pnpm install

If a package manager skips optional dependencies, the adapter reports a graceful inactive status and Babylon continues to use Nova64's built-in voxel renderer.

Usage

Checking NOA Availability

// Check if NOA adapter is available (Babylon.js backend only)
const status = getVoxelNoaAdapterStatus();
console.log(status);
// { initialized: false, active: false, version: '0.1.0', ... }

Enabling NOA Adapter

// Enable NOA adapter (async; Babylon.js backend only)
const result = await enableVoxelNoaAdapter({
  debug: false,
  chunkSize: 16,
  renderDistance: 4,
});

if (result.active) {
  console.log('NOA adapter is now active!');
  console.log('Features:', result.features);
  // { physics: true, entities: true, terrain: true, meshing: true }
}

Checking NOA Status

// Check if NOA is currently active
if (isVoxelNoaActive()) {
  console.log('Using NOA-enhanced voxel backend');
} else {
  console.log('Using standard voxel backend');
}

Disabling NOA Adapter

// Disable NOA and return to standard backend
disableVoxelNoaAdapter();

Backwards Compatibility

Existing cart-facing voxel APIs must keep working whether NOA is active or not:

NOA-Specific Features

When NOA is active, backend-level diagnostics can access additional NOA state:

// These only work when isVoxelNoaActive() returns true
const engine = gpu.noaEngine; // advanced backend diagnostics only

Configuration Options

When enabling the NOA adapter:

await enableVoxelNoaAdapter({
  // Debug mode - shows FPS, chunk boundaries, etc.
  debug: false,

  // Chunk size (must match Nova64's CHUNK_SIZE)
  chunkSize: 16,

  // Render distance in chunks
  renderDistance: 4,

  // Advanced NOA configuration (optional)
  noaConfig: {
    playerHeight: 1.8,
    playerWidth: 0.6,
    tickRate: 30,
    // ... see noa-engine docs for full options
  },
});

URL Parameters

You can enable NOA probing via URL parameters:

?noaVoxel=probe     Enable NOA feature detection
?noaVoxel=true      Enable NOA adapter if available
?noaVoxel=false     Disable NOA adapter

LocalStorage

NOA preference can also be stored:

localStorage.setItem('nova64:noaVoxel', 'probe');

Files

File Description
runtime/api-voxel.js Cart-facing voxel API (shared between backends)
runtime/backends/babylon/voxel.js Standard Babylon.js voxel backend
runtime/backends/babylon/noa-adapter.js NOA engine adapter for Babylon.js
runtime/backends/babylon/noa-prototype.js NOA feature detection and probing

Testing

Run the voxel examples to test NOA integration:

# Test minecraft-demo with Babylon.js backend
pnpm dev
# Navigate to: http://localhost:5173/babylon_console.html?demo=minecraft-demo

# Test with NOA probing enabled
# Navigate to: http://localhost:5173/babylon_console.html?demo=minecraft-demo&noaVoxel=probe

Troubleshooting

"NOA adapter not available"

"noa-engine does not export Engine class"

Performance issues

Babylon peer dependency warning

noa-engine@0.33.0 currently declares an older Babylon peer range than Nova64 uses. Treat pnpm's peer warning as part of the experiment, keep the adapter opt-in, and validate Babylon voxel carts before expanding NOA ownership.

References