npm.io
0.2.0 • Published 5d ago

@aperture-engine/app

Licence
MIT
Version
0.2.0
Deps
10
Size
2.7 MB
Vulns
0
Weekly
59

@aperture-engine/app

The aperture metaframework app facade: config helpers, worker-safe system authoring, and the browser/headless run loop.

Install

pnpm add @aperture-engine/app

This package is part of the aperture WebGPU game engine and is normally used together with the other @aperture-engine/* packages (render, runtime, simulation, physics, audio, webgpu, vite-plugin).

What it does

@aperture-engine/app is the top layer most apps author against. It turns an ApertureConfig (mode, assets, signals, input bindings, render defaults) plus a set of ECS systems into a running app — either driving a WebGPU canvas in the browser or stepping deterministically in a headless extraction loop. Systems are authored by extending createSystem(...), which gives each system typed queries, config signals, and worker-safe access facades (spawn, assets, physics, spatial queries, cameras, hierarchy, materials, interaction, diagnostics) without importing the renderer or DOM directly.

Usage

Author a system, then run it headlessly:

import { defineApertureConfig } from "@aperture-engine/app/config";
import { createSystem, mesh } from "@aperture-engine/app/systems";
import { createApertureHeadlessRunner } from "@aperture-engine/app/headless";

class SceneSystem extends createSystem({ priority: 0 }) {
  override init(): void {
    this.spawn.camera({
      key: "camera.main",
      transform: { translation: [0, 0, 4], lookAt: [0, 0, 0] },
    });
    this.spawn.mesh({
      key: "ground",
      mesh: mesh.plane({ size: [2, 1] }),
    });
  }
}

const runner = await createApertureHeadlessRunner({
  config: defineApertureConfig({ mode: "headless", systems: [] }),
  systems: [{ default: SceneSystem }],
});

const { snapshot } = runner.step(1 / 60, 0);
console.log(snapshot.meshDraws.length);

The same createSystem authoring and defineApertureConfig config work for browser apps, which are wired up by the aperture Vite plugin (re-exported from @aperture-engine/app/vite) and startGeneratedBrowserApp from @aperture-engine/app/browser.

Entry points

The package exposes these subpath exports:

  • @aperture-engine/app — aggregate root (config, advanced app, headless, entity lookup, commands, diagnostics, physics, controllers).
  • @aperture-engine/app/configdefineApertureConfig, asset/signal/input helpers, config types.
  • @aperture-engine/app/systemscreateSystem, spawn/material/shader/mesh helpers, ECS components, system access types.
  • @aperture-engine/app/advancedcreateApertureApp and the low-level app/step/extract API.
  • @aperture-engine/app/headlesscreateApertureHeadlessRunner and headless status/step reports.
  • @aperture-engine/app/entity-lookup — entity lookup and snapshot helpers.
  • @aperture-engine/app/commands — devtools/command message protocol helpers.
  • @aperture-engine/app/diagnostics — diagnostic normalization and status helpers.
  • @aperture-engine/app/vite — the aperture Vite plugin (re-exported from @aperture-engine/vite-plugin).
  • @aperture-engine/app/browserstartGeneratedBrowserApp, render-settings and input helpers for the browser run loop.
  • @aperture-engine/app/workerstartGeneratedSimulationWorker for running the simulation in a Web Worker.

Part of the aperture monorepo. MIT licensed.

Keywords