@fungi.computer/sprite-zdog 0.0.0-stage → 0.0.1

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -2
  3. package/dist/agent-proof/moth.d.ts +50 -0
  4. package/dist/agent-proof/moth.js +52 -0
  5. package/dist/author.d.ts +217 -0
  6. package/dist/author.js +372 -0
  7. package/dist/avatar.d.ts +69 -0
  8. package/dist/avatar.js +40 -0
  9. package/dist/builtins/base-face.d.ts +290 -0
  10. package/dist/builtins/base-face.js +615 -0
  11. package/dist/builtins/base.d.ts +331 -0
  12. package/dist/builtins/base.js +579 -0
  13. package/dist/builtins/burger-input.d.ts +310 -0
  14. package/dist/builtins/burger-input.js +517 -0
  15. package/dist/builtins/burger.d.ts +305 -0
  16. package/dist/builtins/burger.js +4 -0
  17. package/dist/builtins/cat-input.d.ts +316 -0
  18. package/dist/builtins/cat-input.js +255 -0
  19. package/dist/builtins/cat.d.ts +311 -0
  20. package/dist/builtins/cat.js +4 -0
  21. package/dist/builtins/index.d.ts +4 -0
  22. package/dist/builtins/index.js +4 -0
  23. package/dist/builtins/mushroom-input.d.ts +314 -0
  24. package/dist/builtins/mushroom-input.js +94 -0
  25. package/dist/builtins/mushroom.d.ts +310 -0
  26. package/dist/builtins/mushroom.js +4 -0
  27. package/dist/burger.d.ts +9 -0
  28. package/dist/burger.js +15 -0
  29. package/dist/cat.d.ts +9 -0
  30. package/dist/cat.js +15 -0
  31. package/dist/catalog.d.ts +3 -0
  32. package/dist/catalog.js +63 -0
  33. package/dist/document.d.ts +444 -0
  34. package/dist/document.js +204 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.js +10 -0
  37. package/dist/internal.d.ts +41 -0
  38. package/dist/internal.js +21 -0
  39. package/dist/mushroom.character.json +1930 -0
  40. package/dist/mushroom.d.ts +4 -0
  41. package/dist/mushroom.js +9 -0
  42. package/dist/palette.d.ts +3 -0
  43. package/dist/palette.js +5 -0
  44. package/dist/portable.d.ts +4 -0
  45. package/dist/portable.js +61 -0
  46. package/dist/renderer.d.ts +4 -0
  47. package/dist/renderer.js +106 -0
  48. package/dist/zdog-runtime.d.ts +21 -0
  49. package/dist/zdog-runtime.js +622 -0
  50. package/package.json +112 -3
@@ -0,0 +1,255 @@
1
+ import { baseActivities, baseExpressions, buildBaseFace } from "./base-face.js";
2
+ const requiredNode = (nodes, name) => {
3
+ const node = nodes[name];
4
+ if (!node)
5
+ throw new Error(`Missing cat face node: ${name}`);
6
+ return node;
7
+ };
8
+ const sceneNodeMap = (nodes) => nodes;
9
+ /**
10
+ * The cat's authoring input, kept apart from its `defineSprite` call so
11
+ * the avatar catalog can import it without building the scene at module
12
+ * evaluation (a Worker cold-start cost). `./cat.js` is the definition.
13
+ */
14
+ export const catInput = {
15
+ apiVersion: 1,
16
+ name: "cat",
17
+ palette: {
18
+ body: "#ffe6c6",
19
+ eye: "#28282e",
20
+ mouth: "#28282e",
21
+ blush: "#feaae4",
22
+ dead: "#6c5671",
23
+ deadTongue: "#d9c8bf",
24
+ tongue: "#f98284",
25
+ stripes: "#dea38b",
26
+ sweat: "#accce4",
27
+ white: "#ffffff",
28
+ },
29
+ build({ scene, color }) {
30
+ const root = scene.group({ name: "root" });
31
+ const body = scene.group({ parent: root, name: "body", updateSort: true });
32
+ scene.path({
33
+ parent: body,
34
+ name: "body.sphere",
35
+ path: [{ x: 0, y: 0 }],
36
+ color: color("body"),
37
+ stroke: 32,
38
+ });
39
+ for (const side of [-1, 1]) {
40
+ scene.path({
41
+ parent: body,
42
+ name: `ear.${side < 0 ? "left" : "right"}`,
43
+ color: color("body"),
44
+ fill: true,
45
+ path: [
46
+ { x: -6, y: 0 },
47
+ { x: 6, y: 0 },
48
+ { x: 0, y: -10 },
49
+ ],
50
+ rotate: { z: 0.6 * side },
51
+ stroke: 3,
52
+ translate: { x: 9 * side, y: -10 },
53
+ });
54
+ }
55
+ const face = scene.group({
56
+ parent: body,
57
+ name: "face",
58
+ translate: { z: 20 },
59
+ });
60
+ const base = buildBaseFace(scene, color, face, { hideMouth: true });
61
+ const mouthGroup = scene.group({
62
+ parent: face,
63
+ name: "cat.mouth",
64
+ translate: { y: 6, z: 2 },
65
+ });
66
+ const line = (name, path, stroke) => scene.path({
67
+ parent: mouthGroup,
68
+ name: `cat.mouth.${name}`,
69
+ closed: false,
70
+ color: color("mouth"),
71
+ path,
72
+ stroke,
73
+ });
74
+ const mouths = sceneNodeMap({
75
+ normal: line("normal", [
76
+ { x: -2, y: -1 },
77
+ { x: 0, y: 0 },
78
+ { x: 2, y: -1 },
79
+ ], 1.5),
80
+ sad: line("sad", [
81
+ { x: -2.5, y: 2 },
82
+ {
83
+ bezier: [
84
+ { x: 0, y: 0 },
85
+ { x: 2.5, y: 2 },
86
+ { x: 2.5, y: 2 },
87
+ ],
88
+ },
89
+ ], 1.5),
90
+ angry: line("angry", [
91
+ { x: -3, y: 1 },
92
+ { x: 3, y: 1 },
93
+ ], 2),
94
+ small: line("small", [
95
+ { x: -1.5, y: 0 },
96
+ { x: 1.5, y: 0 },
97
+ ], 1),
98
+ worried: line("worried", [
99
+ { x: -2, y: 1 },
100
+ {
101
+ bezier: [
102
+ { x: -0.5, y: 0.5 },
103
+ { x: 0.5, y: 0.5 },
104
+ { x: 2, y: 1 },
105
+ ],
106
+ },
107
+ ], 1),
108
+ });
109
+ const happy = scene.group({
110
+ parent: mouthGroup,
111
+ name: "cat.mouth.happy",
112
+ translate: { y: 1 },
113
+ });
114
+ scene.path({
115
+ parent: happy,
116
+ closed: false,
117
+ color: color("mouth"),
118
+ path: [
119
+ { x: -2.5, y: 1 },
120
+ {
121
+ bezier: [
122
+ { x: 0, y: 3 },
123
+ { x: 2.5, y: 1 },
124
+ { x: 2.5, y: 1 },
125
+ ],
126
+ },
127
+ ],
128
+ stroke: 1.5,
129
+ });
130
+ scene.ellipse({
131
+ parent: happy,
132
+ width: 2,
133
+ height: 1.5,
134
+ stroke: 0,
135
+ fill: true,
136
+ color: color("tongue"),
137
+ translate: { y: 2 },
138
+ });
139
+ mouths.happy = happy;
140
+ mouths.surprised = scene.ellipse({
141
+ parent: mouthGroup,
142
+ name: "cat.mouth.surprised",
143
+ width: 2.5,
144
+ height: 3,
145
+ stroke: 1.5,
146
+ fill: true,
147
+ color: color("mouth"),
148
+ translate: { y: 1 },
149
+ });
150
+ const dead = scene.group({
151
+ parent: mouthGroup,
152
+ name: "cat.mouth.dead",
153
+ translate: { y: 3 },
154
+ });
155
+ scene.ellipse({
156
+ parent: dead,
157
+ width: 2.5,
158
+ height: 1.5,
159
+ stroke: 1.5,
160
+ fill: true,
161
+ color: color("dead"),
162
+ });
163
+ scene.ellipse({
164
+ parent: dead,
165
+ width: 1.2,
166
+ height: 0.8,
167
+ stroke: 0,
168
+ fill: true,
169
+ color: color("deadTongue"),
170
+ translate: { y: 0.5 },
171
+ });
172
+ mouths.dead = dead;
173
+ mouths.pout = scene.ellipse({
174
+ parent: mouthGroup,
175
+ name: "cat.mouth.pout",
176
+ width: 2,
177
+ height: 2.5,
178
+ stroke: 1.5,
179
+ fill: true,
180
+ color: color("mouth"),
181
+ translate: { y: 1 },
182
+ });
183
+ mouths.open = scene.ellipse({
184
+ parent: mouthGroup,
185
+ name: "cat.mouth.open",
186
+ width: 4,
187
+ height: 5,
188
+ stroke: 1.5,
189
+ fill: true,
190
+ color: color("mouth"),
191
+ translate: { y: 1 },
192
+ });
193
+ const whiskers = scene.group({
194
+ parent: face,
195
+ name: "whiskers",
196
+ translate: { y: 5, z: 2 },
197
+ });
198
+ for (const side of [-1, 1]) {
199
+ const xOffset = side * 12;
200
+ for (const [index, yOffset] of [-2, 0, 2].entries()) {
201
+ scene.path({
202
+ parent: whiskers,
203
+ name: `whisker.${side < 0 ? "left" : "right"}.${String(index)}`,
204
+ closed: false,
205
+ color: color("eye"),
206
+ path: [
207
+ { x: 0, y: yOffset },
208
+ { x: side * 8, y: yOffset + (index - 1) * 1.5 },
209
+ ],
210
+ stroke: 0.8,
211
+ translate: { x: xOffset, y: yOffset * 0.5 },
212
+ });
213
+ }
214
+ }
215
+ const orderedMouths = {
216
+ normal: requiredNode(mouths, "normal"),
217
+ happy: mouths.happy,
218
+ sad: requiredNode(mouths, "sad"),
219
+ angry: requiredNode(mouths, "angry"),
220
+ surprised: mouths.surprised,
221
+ dead: mouths.dead,
222
+ small: requiredNode(mouths, "small"),
223
+ worried: requiredNode(mouths, "worried"),
224
+ pout: mouths.pout,
225
+ open: mouths.open,
226
+ };
227
+ return {
228
+ root,
229
+ variants: { eyes: base.eyes, mouth: orderedMouths, blush: base.blush },
230
+ };
231
+ },
232
+ expressions: baseExpressions,
233
+ activities: {
234
+ ...baseActivities,
235
+ listening: {
236
+ motion: {
237
+ target: "root",
238
+ rotate: { x: -0.2 },
239
+ durationMs: 300,
240
+ repeat: "yoyo",
241
+ },
242
+ mouseInfluence: 0.3,
243
+ },
244
+ thinking: {
245
+ motion: {
246
+ target: "root",
247
+ rotate: { z: 0.1 },
248
+ durationMs: 800,
249
+ repeat: "yoyo",
250
+ },
251
+ mouseInfluence: 0,
252
+ },
253
+ },
254
+ defaultPresentation: { activity: "idle", expression: "normal" },
255
+ };
@@ -0,0 +1,311 @@
1
+ declare const cat: Readonly<{
2
+ apiVersion: 1;
3
+ name: string;
4
+ palette: {
5
+ body: string;
6
+ eye: string;
7
+ mouth: string;
8
+ blush: string;
9
+ dead: string;
10
+ deadTongue: string;
11
+ tongue: string;
12
+ stripes: string;
13
+ sweat: string;
14
+ white: string;
15
+ };
16
+ build({ scene, color }: import("../author.js").AuthorContext): {
17
+ root: import("../author.js").SceneNode;
18
+ variants: {
19
+ eyes: Record<string, import("../author.js").SceneNode>;
20
+ mouth: {
21
+ normal: import("../author.js").SceneNode;
22
+ happy: import("../author.js").SceneNode;
23
+ sad: import("../author.js").SceneNode;
24
+ angry: import("../author.js").SceneNode;
25
+ surprised: import("../author.js").SceneNode;
26
+ dead: import("../author.js").SceneNode;
27
+ small: import("../author.js").SceneNode;
28
+ worried: import("../author.js").SceneNode;
29
+ pout: import("../author.js").SceneNode;
30
+ open: import("../author.js").SceneNode;
31
+ };
32
+ blush: Record<string, import("../author.js").SceneNode>;
33
+ };
34
+ };
35
+ expressions: {
36
+ readonly angry: {
37
+ readonly variants: {
38
+ readonly eyes: "angry";
39
+ readonly mouth: "angry";
40
+ readonly blush: "off";
41
+ };
42
+ readonly motion: {
43
+ readonly target: "root";
44
+ readonly translate: {
45
+ readonly x: 1;
46
+ readonly y: 0;
47
+ };
48
+ readonly durationMs: 150;
49
+ readonly repeat: "none";
50
+ };
51
+ };
52
+ readonly confused: {
53
+ readonly variants: {
54
+ readonly eyes: "confused";
55
+ readonly mouth: "normal";
56
+ readonly blush: "off";
57
+ };
58
+ readonly motion: {
59
+ readonly target: "root";
60
+ readonly translate: {
61
+ readonly x: 0;
62
+ readonly y: 0.5;
63
+ };
64
+ readonly durationMs: 150;
65
+ readonly repeat: "none";
66
+ };
67
+ };
68
+ readonly cute: {
69
+ readonly variants: {
70
+ readonly eyes: "cute";
71
+ readonly mouth: "happy";
72
+ readonly blush: "big";
73
+ };
74
+ readonly motion: {
75
+ readonly target: "root";
76
+ readonly translate: {
77
+ readonly x: 0;
78
+ readonly y: -2.5;
79
+ };
80
+ readonly durationMs: 150;
81
+ readonly repeat: "none";
82
+ };
83
+ };
84
+ readonly dead: {
85
+ readonly variants: {
86
+ readonly eyes: "dead";
87
+ readonly mouth: "dead";
88
+ readonly blush: "off";
89
+ };
90
+ };
91
+ readonly happy: {
92
+ readonly variants: {
93
+ readonly eyes: "happy";
94
+ readonly mouth: "happy";
95
+ readonly blush: "medium";
96
+ };
97
+ readonly motion: {
98
+ readonly target: "root";
99
+ readonly translate: {
100
+ readonly x: 0;
101
+ readonly y: -2;
102
+ };
103
+ readonly durationMs: 150;
104
+ readonly repeat: "none";
105
+ };
106
+ };
107
+ readonly nervous: {
108
+ readonly variants: {
109
+ readonly eyes: "nervous";
110
+ readonly mouth: "worried";
111
+ readonly blush: "off";
112
+ };
113
+ readonly motion: {
114
+ readonly target: "root";
115
+ readonly translate: {
116
+ readonly x: -0.5;
117
+ readonly y: -1;
118
+ };
119
+ readonly durationMs: 150;
120
+ readonly repeat: "none";
121
+ };
122
+ };
123
+ readonly normal: {
124
+ readonly variants: {
125
+ readonly eyes: "normal";
126
+ readonly mouth: "normal";
127
+ readonly blush: "off";
128
+ };
129
+ readonly motion: {
130
+ readonly target: "root";
131
+ readonly translate: {
132
+ readonly x: 0;
133
+ readonly y: 1;
134
+ };
135
+ readonly durationMs: 150;
136
+ readonly repeat: "none";
137
+ };
138
+ };
139
+ readonly pleading: {
140
+ readonly variants: {
141
+ readonly eyes: "cute";
142
+ readonly mouth: "pout";
143
+ readonly blush: "medium";
144
+ };
145
+ readonly motion: {
146
+ readonly target: "root";
147
+ readonly translate: {
148
+ readonly x: 0;
149
+ readonly y: -1;
150
+ };
151
+ readonly durationMs: 150;
152
+ readonly repeat: "none";
153
+ };
154
+ };
155
+ readonly sad: {
156
+ readonly variants: {
157
+ readonly eyes: "sad";
158
+ readonly mouth: "sad";
159
+ readonly blush: "off";
160
+ };
161
+ readonly motion: {
162
+ readonly target: "root";
163
+ readonly translate: {
164
+ readonly x: 0;
165
+ readonly y: 2;
166
+ };
167
+ readonly durationMs: 150;
168
+ readonly repeat: "none";
169
+ };
170
+ };
171
+ readonly shy: {
172
+ readonly variants: {
173
+ readonly eyes: "shy";
174
+ readonly mouth: "small";
175
+ readonly blush: "small";
176
+ };
177
+ readonly motion: {
178
+ readonly target: "root";
179
+ readonly translate: {
180
+ readonly x: 0;
181
+ readonly y: 1.5;
182
+ };
183
+ readonly durationMs: 150;
184
+ readonly repeat: "none";
185
+ };
186
+ };
187
+ readonly sleepy: {
188
+ readonly variants: {
189
+ readonly eyes: "sleepy";
190
+ readonly mouth: "small";
191
+ readonly blush: "off";
192
+ };
193
+ readonly motion: {
194
+ readonly target: "root";
195
+ readonly translate: {
196
+ readonly x: 0;
197
+ readonly y: 2;
198
+ };
199
+ readonly durationMs: 150;
200
+ readonly repeat: "none";
201
+ };
202
+ };
203
+ readonly surprised: {
204
+ readonly variants: {
205
+ readonly eyes: "surprised";
206
+ readonly mouth: "surprised";
207
+ readonly blush: "off";
208
+ };
209
+ readonly motion: {
210
+ readonly target: "root";
211
+ readonly translate: {
212
+ readonly x: 0;
213
+ readonly y: -3;
214
+ };
215
+ readonly durationMs: 150;
216
+ readonly repeat: "none";
217
+ };
218
+ };
219
+ readonly wink: {
220
+ readonly variants: {
221
+ readonly mouth: "happy";
222
+ readonly blush: "small";
223
+ };
224
+ readonly variantChoices: {
225
+ readonly eyes: readonly ["wink.left", "wink.right"];
226
+ };
227
+ readonly motion: {
228
+ readonly target: "root";
229
+ readonly translate: {
230
+ readonly x: 0;
231
+ readonly y: -1.5;
232
+ };
233
+ readonly durationMs: 150;
234
+ readonly repeat: "none";
235
+ };
236
+ };
237
+ };
238
+ activities: {
239
+ listening: {
240
+ motion: {
241
+ target: string;
242
+ rotate: {
243
+ x: number;
244
+ };
245
+ durationMs: number;
246
+ repeat: "yoyo";
247
+ };
248
+ mouseInfluence: number;
249
+ };
250
+ thinking: {
251
+ motion: {
252
+ target: string;
253
+ rotate: {
254
+ z: number;
255
+ };
256
+ durationMs: number;
257
+ repeat: "yoyo";
258
+ };
259
+ mouseInfluence: number;
260
+ };
261
+ idle: {
262
+ readonly motion: {
263
+ readonly target: "root";
264
+ readonly translate: {
265
+ readonly y: 0.5;
266
+ };
267
+ readonly durationMs: 2000;
268
+ readonly repeat: "yoyo";
269
+ };
270
+ readonly mouseInfluence: 1;
271
+ };
272
+ processing: {
273
+ readonly mouseInfluence: 0.2;
274
+ };
275
+ speaking: {
276
+ readonly motion: {
277
+ readonly target: "root";
278
+ readonly translate: {
279
+ readonly y: 0.5;
280
+ };
281
+ readonly durationMs: 1500;
282
+ readonly repeat: "yoyo";
283
+ };
284
+ readonly mouseInfluence: 0;
285
+ readonly mouthCycle: readonly [{
286
+ readonly durationMs: 100;
287
+ readonly mouth: "open";
288
+ }, {
289
+ readonly durationMs: 150;
290
+ readonly mouth: "base";
291
+ }, {
292
+ readonly durationMs: 100;
293
+ readonly mouth: "open";
294
+ }, {
295
+ readonly durationMs: 200;
296
+ readonly mouth: "base";
297
+ }];
298
+ };
299
+ error: {
300
+ readonly geometry: {
301
+ readonly expression: "dead";
302
+ };
303
+ readonly mouseInfluence: 0.1;
304
+ };
305
+ };
306
+ defaultPresentation: {
307
+ activity: string;
308
+ expression: string;
309
+ };
310
+ }>;
311
+ export default cat;
@@ -0,0 +1,4 @@
1
+ import { defineSprite } from "../author.js";
2
+ import { catInput } from "./cat-input.js";
3
+ const cat = defineSprite(catInput);
4
+ export default cat;
@@ -0,0 +1,4 @@
1
+ export { default as base } from "./base.js";
2
+ export { default as mushroom } from "./mushroom.js";
3
+ export { default as cat } from "./cat.js";
4
+ export { default as burger } from "./burger.js";
@@ -0,0 +1,4 @@
1
+ export { default as base } from "./base.js";
2
+ export { default as mushroom } from "./mushroom.js";
3
+ export { default as cat } from "./cat.js";
4
+ export { default as burger } from "./burger.js";