@aura3d/core

中文文档
4.7.0发布于 2026/10/31MITTypeScriptES Module零依赖

Engine lifecycle, scheduling, deterministic time stepping, diagnostics, events, logging, task queues, and disposable resource scopes for Aura3D.

原始使用文档
文档目录3 节
  1. Public API
  2. Lifecycle Contract
  3. Verification

@aura3d/core

@aura3d/core owns the engine lifecycle, scheduling spine, deterministic time stepping, diagnostics, events, logging, task queues, and disposable resource scopes. It is the root runtime package and does not depend on scene, rendering, physics, animation, assets, input, audio, scripting, editor, or browser-only APIs.

Public API

  • Engine: lifecycle owner for plugin initialization, scheduler execution, manual stepping, start/stop control, events, diagnostics, task queues, and resource disposal.
  • EngineConfig, resolveEngineConfig, ResolvedEngineConfig: validated runtime configuration for fixed-step timing, max frame delta, time scale, and optional auto-start behavior.
  • EngineLoop, FrameContext: deterministic frame loop used by Engine for manual and requestAnimationFrame-backed execution.
  • FixedStepAccumulator: fixed-step accumulator with max-step clamping for deterministic simulation phases.
  • Scheduler, SystemPhase: explicit ordered phase scheduler with dependency validation, duplicate rejection, cycle detection, and cross-phase dependency rejection.
  • TaskQueue: async-safe queue flushed in the engine task phase.
  • EventBus: typed event emitter used by engine lifecycle, frame, and error signals.
  • Diagnostics: structured metric/counter snapshot support.
  • Logger: scoped runtime logging abstraction.
  • DisposableStack, ResourceScope: deterministic LIFO cleanup primitives.
  • VersionedSchema, MigrationRegistry, SaveSlot: browser-independent schema validation, save-data migration, and save-slot metadata/data snapshots.
  • ValidationError, LifecycleError: typed error classes for invalid configuration, graph, and lifecycle operations.

Lifecycle Contract

An Engine starts in created. Plugins may only be registered in this state. Calling init() transitions through initializing into initialized, invoking plugin init handlers in registration order. If any plugin initialization fails, already initialized plugin disposers run in reverse order and the engine transitions to failed.

Calling start() is valid only from initialized or stopped; it starts the configured loop and transitions to running. Calling stop() from running stops the loop and transitions to stopped. Calling step(delta) from created initializes the engine first, then executes one deterministic frame from initialized, running, or stopped.

Each frame executes phases in this order:

  1. Platform
  2. Tasks
  3. queued TaskQueue work
  4. Fixed, once per accumulated fixed step
  5. Update
  6. Scene
  7. Render
  8. Present
  9. Cleanup

Calling dispose() is idempotent. If the engine is running it stops first, then disposes plugin resources and engine-owned ResourceScope entries, clears events, and transitions to disposed. Disposal errors are reported as an AggregateError.

Verification

Lifecycle, scheduler, fixed-step, plugin rollback, deterministic manual stepping, and frame diagnostics are covered by:

  • tests/unit/core/scheduler-engine.test.ts
  • tests/unit/core/config-time.test.ts
  • tests/unit/core/events-disposal-diagnostics.test.ts
  • tests/unit/core/versioned-serialization.test.ts
  • tests/integration/engine-loop.test.ts
  • tests/browser/core-raf-loop.spec.ts

Public export and import boundaries are covered by pnpm verify:exports, pnpm verify:imports, and pnpm verify:boundaries.

版本与发布记录

@aura3d/core 共发布 48 个版本,首次发布于 2026/06/06;过去 12 个月发布了 48 个版本。

版本发布日期距今
4.7.0latest2026/10/313 天前
4.6.22026/10/304 天前
4.6.12026/10/304 天前
4.6.02026/10/304 天前
4.5.02026/10/295 天前
4.3.72026/10/286 天前

关于 @aura3d/core 的常见问题

@aura3d/core 是什么?

Aura3D的引擎生命周期、调度、确定性时间步进、诊断、事件、日志、任务队列和一次性资源范围。

如何安装 @aura3d/core?

在项目目录运行 npm install @aura3d/core,或使用 pnpm add / yarn add / bun add。

@aura3d/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aura3d/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aura3d/core 可以商用吗?

@aura3d/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aura3d/core 还在维护吗?

最新版本 4.7.0 发布于 2026/10/31(3 天前);至今共发布 48 个版本,其中过去 12 个月发布了 48 个;首次发布于 2026/06/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。