@felbrasil/dreamy 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,7 @@ Import `styles.css` in your root layout.
50
50
  | `@felbrasil/dreamy/viewport` | `createViewport({ evaluator })`: the Three.js renderer and interaction |
51
51
  | `@felbrasil/dreamy/evaluator` | `createEvaluator()`: the WASM mesher in a Worker (TypeScript fallback) |
52
52
  | `@felbrasil/dreamy/api` | Types: the model, commands, events and ports |
53
+ | `@felbrasil/dreamy/bake` | `createSpriteBaker()`: pixel-art sprites of creations as palette roles, with no studio UI |
53
54
 
54
55
  ```ts
55
56
  import { createCreationApi } from "@felbrasil/dreamy/core";
@@ -61,6 +62,26 @@ const viewport = createViewport({ evaluator: createEvaluator() });
61
62
  viewport.mount(hostElement, callbacks);
62
63
  ```
63
64
 
65
+ ## Bake sprites
66
+
67
+ ```ts
68
+ import { createCreationApi } from "@felbrasil/dreamy/core";
69
+ import { createSpriteBaker, spriteColors } from "@felbrasil/dreamy/bake";
70
+
71
+ const api = createCreationApi({ ids, clock, log });
72
+ api.dispatch({ type: "GenerateCreature", payload: { seed: 42, chimera: false, variety: 0.7, target } });
73
+
74
+ const baker = createSpriteBaker();
75
+ const [front, back] = await baker.bake(api.creation(), [
76
+ { view: { yaw: 15, pitch: 15 }, size: 256 }, // degrees around the creature's front
77
+ { view: { yaw: 180, pitch: 30 }, size: 256 }, // its back, from above
78
+ ]);
79
+ // front.roles: one palette role per pixel (0 transparent, 1 ink, 2–28 slot × tone); front.colors draws them,
80
+ // spriteColors(otherPalette) recolors them. front.anchor: the feet row and the silhouette's centre.
81
+ ```
82
+
83
+ The baker needs no React. It renders off-screen and also works in a hidden page or a headless browser with WebGL 2.
84
+
64
85
  ## Requirements
65
86
 
66
87
  A browser with WebGL 2, Web Workers and WebAssembly. Client-side only (no server rendering of the studio).
package/dist/bake.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./types/dreamy/src/bake.js";
package/dist/bake.js ADDED
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import {
3
+ createSpriteBaker
4
+ } from "./chunks/chunk-6TE546ZS.js";
5
+ import {
6
+ ROLE_INK,
7
+ ROLE_TRANSPARENT,
8
+ SPRITE_ROLE_COUNT,
9
+ SPRITE_SLOTS,
10
+ roleSlot,
11
+ spriteColors,
12
+ spriteRole
13
+ } from "./chunks/chunk-5KZP6X65.js";
14
+ import "./chunks/chunk-72DMUKP3.js";
15
+ export {
16
+ ROLE_INK,
17
+ ROLE_TRANSPARENT,
18
+ SPRITE_ROLE_COUNT,
19
+ SPRITE_SLOTS,
20
+ createSpriteBaker,
21
+ roleSlot,
22
+ spriteColors,
23
+ spriteRole
24
+ };
25
+ //# sourceMappingURL=bake.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }