@aura3d/react

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

React components and helpers for mounting Aura3D scenes with typed assets, cameras, lights, effects, and product-viewer scene builders.

原始使用文档
文档目录4 节
  1. Public API
  2. Status: experimental
  3. R3F migration note
  4. Package Boundary

@aura3d/react

@aura3d/react owns React components and helpers for mounting Aura3D scenes with typed assets, cameras, lights, effects, and product-viewer scene builders.

Public API

  • AuraCanvas: React canvas component that mounts createAuraApp, forwards diagnostics/options, and disposes the app on unmount.
  • Scene: declarative scene wrapper for background, camera, timeline, and diagnostics options.
  • Model: typed model node declaration using an AuraAssetRef<"model">.
  • Camera: orbit, dolly, follow, or perspective camera declaration.
  • Lights: studio, ambient, directional, and point light declaration.
  • Effect: fog, bloom, and rain effect declaration.
  • buildSceneFromChildren: converts supported React children into an AuraSceneBuilder.
  • productViewerScene: convenience builder for a typed-asset product viewer scene.
  • useAuraApp / AuraAppContext: the mounted AuraApp (undefined until mount). Detect "outside a canvas" with useAuraApp() !== undefined.
  • useAuraFrame(callback, priority?): the game loop — priority-ordered fan-out over one shared app.onFrame subscription, cleaned up on unmount.
  • AuraCanvas event props (onPointerDown/Move/Up, onHover): canvas-level DOM listeners with unmount cleanup. Pair with eventInteractionNodes(target) so the F4 picking stack is engaged — a DOM handler alone is not picking.
  • createAuraAssetResource / useAuraAsset / resourceForDescriptors: Suspense-compatible asset boundary with preloadAll semantics (per-record ok/failed evidence; failures throw to an error boundary). <Model suspendOnLoad fallback> suspends on typed-asset preload.
  • drei-pattern recipes (tested fragments, not deps, not parity): cameraControlsRecipe, environmentPresetRecipe, transformGizmoRecipe.
  • R3F_TO_AURA_MIGRATION_TABLE: the R3F → AuraCanvas mapping for importers.

Status: experimental

Audited in the beat-three.js PRD (WP-K.6). What is tested: scene building from children, the frame scheduler, asset resources, recipes and the migration table (tests/unit/react-adapter/), and the render tree of AuraCanvas (one canvas; children render inside the app provider; declarative nodes add no DOM). Fixed in that audit: children used to be read for the scene but never rendered, so useAuraFrame, useAuraApp and <Model suspendOnLoad> inside an AuraCanvas never ran; and the app was disposed and recreated whenever the parent re-rendered with inline children, handlers or an inline onReady. AuraCanvas now remounts only when the built scene, diagnostics, pixelRatio, autoStart or resize change.

Not yet proven, so the package stays experimental: mount, dispose and listener cleanup in a real browser (needs a remote Playwright receipt), React StrictMode double-mount, and server rendering of a mounted scene.

R3F migration note

R3F_TO_AURA_MIGRATION_TABLE maps idiomatic R3F to the covered AuraCanvas surface (Canvas, mesh/model, lights, camera, effects, useFrame, useThree, useLoader/Suspense, mesh events, drei OrbitControls/Environment/ TransformControls). It is a mapping, not an R3F-parity claim (R3F_MIGRATION_NOT_PARITY). The three-compat migration lab detects @react-three/fiber / @react-three/drei source and points here, and documents the manual CSS2D/CSS3D mapping (CSS2D_CSS3D_MANUAL_MAP).

Package Boundary

This package wraps the root @aura3d/engine public API for React apps. It does not replace the typed asset pipeline: model props should use generated assets.name references, not raw GLB URLs or guessed asset IDs.

版本与发布记录

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

版本发布日期距今
4.7.0latest2026/10/312 天前
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/react 的常见问题

@aura3d/react 是什么?

用于安装带有类型资产、相机、灯光、效果和产品查看器场景构建器的Aura3D场景的React组件和帮助器。

如何安装 @aura3d/react?

在项目目录运行 npm install @aura3d/react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0 || ^18.0.0)、@aura3d/engine(^4.7.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aura3d/react 支持 TypeScript 吗?

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

@aura3d/react 支持 ESM 还是 CommonJS?

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

@aura3d/react 可以商用吗?

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

@aura3d/react 还在维护吗?

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