@felbrasil/dreamy

中文文档
0.15.0发布于 2026/11/13MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2555

Dreamy: a voxel creature sculpting studio for React (WASM mesher, Three.js viewport, git-backed saves).

原始使用文档
文档目录7 节
  1. Install
  2. Use the whole studio
  3. Props
  4. Use the pieces
  5. Bake sprites
  6. Requirements
  7. License

Dreamy

A voxel creature sculpting studio for React: stamp and smear sculpts, paint them, rig them with premade skeletons and decals, and render them as normal 3D or pixel art. Meshing runs in Rust/WASM inside a Web Worker; the 3D view is Three.js. Creations save in the browser (IndexedDB) and can sync to a GitHub or GitLab repository.

Live demo: https://dreamy-poc-c89175.gitlab.io

Install

npm install @felbrasil/dreamy react react-dom three

react, react-dom (19) and three are peer dependencies. There is nothing else to configure: the Worker and its WASM are inlined in the package, so Vite, Next.js (webpack or Turbopack) and other bundlers work as they are.

Use the whole studio

import { DreamyStudio } from "@felbrasil/dreamy";
import "@felbrasil/dreamy/styles.css";

export function App() {
  return <DreamyStudio onReady={() => console.log("studio ready")} />;
}

The studio fills the page (fixed, full viewport), so render one per page. styles.css also loads the studio's icons (Font Awesome) and font (Nunito) from their CDNs.

In Next.js you can render it straight from a server component: the package entry is a client module. Import styles.css in your root layout.

Props

PropDefault
databasethis browser's IndexedDBWhere the library of creations lives (LibraryDatabase: list / read / write / delete / current).
storagelocalStorageKey-value storage for view preferences and git settings.
gitSynctrueOffer Scenes → Git: sync the library with one GitHub or GitLab repository (token kept in storage).
onReadyCalled once the mesher is loaded, the creation is open and the studio has painted.

Use the pieces

ImportWhat
@felbrasil/dreamyDreamyStudio, the IndexedDB library, persistence, git sync, preferences
@felbrasil/dreamy/corecreateCreationApi: the event-sourced creation model, commands, undo, premades
@felbrasil/dreamy/viewportcreateViewport({ evaluator }): the Three.js renderer and interaction
@felbrasil/dreamy/evaluatorcreateEvaluator(): the WASM mesher in a Worker (TypeScript fallback)
@felbrasil/dreamy/apiTypes: the model, commands, events and ports
@felbrasil/dreamy/bakecreateSpriteBaker(): pixel-art sprites of creations as palette roles, with no studio UI
import { createCreationApi } from "@felbrasil/dreamy/core";
import { createEvaluator } from "@felbrasil/dreamy/evaluator";
import { createViewport } from "@felbrasil/dreamy/viewport";

const api = createCreationApi({ ids, clock, log });
const viewport = createViewport({ evaluator: createEvaluator() });
viewport.mount(hostElement, callbacks);

Bake sprites

import { createCreationApi } from "@felbrasil/dreamy/core";
import { createSpriteBaker, spriteColors } from "@felbrasil/dreamy/bake";

const api = createCreationApi({ ids, clock, log });
api.dispatch({ type: "GenerateCreature", payload: { seed: 42, chimera: false, variety: 0.7, target } });

const baker = createSpriteBaker();
const [front, back] = await baker.bake(api.creation(), [
  { view: { yaw: 15, pitch: 15 }, size: 256 },   // degrees around the creature's front
  { view: { yaw: 180, pitch: 30 }, size: 256 },  // its back, from above
  { view: { yaw: 15, pitch: 15 }, size: 64, dither: 0.2, normalStrength: 0.5 }, // less tone dither, flatter relief
]);
// front.roles: one palette role per pixel (0 transparent, 1 ink, 2–28 slot × tone); front.colors draws them,
// spriteColors(otherPalette) recolors them. front.anchor: the feet row and the silhouette's centre.
// front.bones: the skeleton (parent index, world position, sprite x / y, depth) for a bone or x-ray view.

Games that only draw baked sprites import the light @felbrasil/dreamy/sprite entry (no WebGL, mesher or React):

import { decodeSpritePng, encodeSpritePng, spriteColors, spriteRgba } from "@felbrasil/dreamy/sprite";

const png = await encodeSpritePng(front);              // 8-bit indexed PNG: pixel = role, PNG palette = role colors
const { width, height, roles } = await decodeSpritePng(png);
const pixels = spriteRgba(roles, spriteColors(palette)); // ImageData pixels in any creature's colors

GenerateCreature takes a stage ("chibi", "young" or "adult"): the same seed is the same creature as a big-headed baby, in between, or grown up.

The baker needs no React. It renders off-screen and also works in a hidden page or a headless browser with WebGL 2.

Requirements

A browser with WebGL 2, Web Workers and WebAssembly. Client-side only (no server rendering of the studio).

License

MIT

版本与发布记录

@felbrasil/dreamy 共发布 20 个版本,首次发布于 2026/10/20;过去 12 个月发布了 20 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.15.0latest2026/11/131 天前
0.14.02026/11/131 天前
0.13.02026/11/121 天前
0.12.02026/11/122 天前
0.11.02026/11/095 天前
0.10.02026/11/059 天前

关于 @felbrasil/dreamy 的常见问题

@felbrasil/dreamy 是什么?

Dreamy: a voxel creature sculpting studio for React (WASM mesher, Three.js viewport, git-backed saves).

如何安装 @felbrasil/dreamy?

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

@felbrasil/dreamy 支持 TypeScript 吗?

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

@felbrasil/dreamy 支持 ESM 还是 CommonJS?

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

@felbrasil/dreamy 可以商用吗?

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

@felbrasil/dreamy 的下载量有多少?

根据 npm 官方下载统计,@felbrasil/dreamy 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,555 次,日均约 85 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@felbrasil/dreamy 还在维护吗?

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