@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,517 @@
1
+ import { baseActivities, baseExpressions, buildBaseFace } from "./base-face.js";
2
+ const pathMap = (paths) => paths;
3
+ const requiredPath = (paths, name) => {
4
+ const path = paths[name];
5
+ if (!path)
6
+ throw new Error(`Missing burger path: ${name}`);
7
+ return path;
8
+ };
9
+ /**
10
+ * The burger'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). `./burger.js` is the definition.
13
+ */
14
+ export const burgerInput = {
15
+ apiVersion: 1,
16
+ name: "burger",
17
+ palette: {
18
+ bottomBun: "#e9c46a",
19
+ bunSpot: "#d4a373",
20
+ cheese: "#f4d03f",
21
+ dead: "#636e72",
22
+ deadTongue: "#b2bec3",
23
+ eye: "#2d3436",
24
+ lettuce: "#7cb342",
25
+ mouth: "#2d3436",
26
+ patty: "#5d4037",
27
+ tomato: "#e74c3c",
28
+ topBun: "#f4a261",
29
+ blush: "#feaae4",
30
+ tongue: "#f98284",
31
+ sweat: "#accce4",
32
+ white: "#ffffff",
33
+ },
34
+ build({ scene, color }) {
35
+ const root = scene.group({ name: "root" });
36
+ const body = scene.group({ parent: root, name: "body", updateSort: true });
37
+ scene.cylinder({
38
+ parent: body,
39
+ name: "bottom-bun",
40
+ backface: color("bottomBun"),
41
+ color: color("bottomBun"),
42
+ diameter: 34,
43
+ frontFace: color("bunSpot"),
44
+ length: 6,
45
+ rotate: { x: Math.PI / 2 },
46
+ stroke: false,
47
+ translate: { y: 8 },
48
+ });
49
+ scene.cylinder({
50
+ parent: body,
51
+ name: "patty",
52
+ color: color("patty"),
53
+ diameter: 36,
54
+ frontFace: color("patty"),
55
+ length: 4,
56
+ rotate: { x: Math.PI / 2 },
57
+ stroke: false,
58
+ translate: { y: 3 },
59
+ });
60
+ scene.cylinder({
61
+ parent: body,
62
+ name: "tomato",
63
+ color: color("tomato"),
64
+ diameter: 34,
65
+ frontFace: color("tomato"),
66
+ length: 2,
67
+ rotate: { x: Math.PI / 2 },
68
+ stroke: false,
69
+ translate: { y: -2 },
70
+ });
71
+ const topBun = scene.hemisphere({
72
+ parent: body,
73
+ name: "top-bun",
74
+ backface: color("bunSpot"),
75
+ color: color("topBun"),
76
+ diameter: 38,
77
+ rotate: { x: Math.PI / 2 },
78
+ stroke: false,
79
+ translate: { y: -3 },
80
+ });
81
+ const seeds = [
82
+ { x: -8, y: -6, z: 14 },
83
+ { x: 6, y: -8, z: 13 },
84
+ { x: 0, y: -10, z: 12 },
85
+ { x: 10, y: -4, z: 13 },
86
+ { x: -5, y: -2, z: 15 },
87
+ { x: 4, y: -12, z: 11 },
88
+ ];
89
+ for (const [index, position] of seeds.entries())
90
+ scene.path({
91
+ parent: topBun,
92
+ name: `seed.${String(index + 1)}`,
93
+ path: [{ x: 0, y: 0 }],
94
+ color: color("bunSpot"),
95
+ stroke: 1.2,
96
+ translate: position,
97
+ });
98
+ const face = scene.group({
99
+ parent: body,
100
+ name: "face",
101
+ translate: { y: -5, z: 16 },
102
+ });
103
+ const base = buildBaseFace(scene, color, face, {
104
+ blushMode: "medium-alias",
105
+ hideMouth: true,
106
+ });
107
+ const mouthGroup = scene.group({
108
+ parent: body,
109
+ name: "burger.mouth",
110
+ translate: { y: 1, z: 10 },
111
+ });
112
+ const cheesePaths = pathMap({
113
+ angry: [
114
+ { x: -13, y: 2 },
115
+ { x: 13, y: 2 },
116
+ { x: 13, y: 5 },
117
+ {
118
+ bezier: [
119
+ { x: 7, y: 4 },
120
+ { x: 0, y: 5 },
121
+ { x: -7, y: 4 },
122
+ ],
123
+ },
124
+ { x: -13, y: 5 },
125
+ ],
126
+ happy: [
127
+ { x: -12, y: 0 },
128
+ {
129
+ bezier: [
130
+ { x: -6, y: 3 },
131
+ { x: 0, y: 5 },
132
+ { x: 6, y: 3 },
133
+ ],
134
+ },
135
+ { x: 12, y: 0 },
136
+ { x: 13, y: 2 },
137
+ {
138
+ bezier: [
139
+ { x: 7, y: 5 },
140
+ { x: 0, y: 7 },
141
+ { x: -7, y: 5 },
142
+ ],
143
+ },
144
+ { x: -13, y: 2 },
145
+ ],
146
+ open: [
147
+ { x: -10, y: 0 },
148
+ {
149
+ bezier: [
150
+ { x: -10, y: 5 },
151
+ { x: -5, y: 8 },
152
+ { x: 0, y: 8 },
153
+ ],
154
+ },
155
+ {
156
+ bezier: [
157
+ { x: 5, y: 8 },
158
+ { x: 10, y: 5 },
159
+ { x: 10, y: 0 },
160
+ ],
161
+ },
162
+ { x: 10, y: 1 },
163
+ {
164
+ bezier: [
165
+ { x: 5, y: 6 },
166
+ { x: -5, y: 6 },
167
+ { x: -10, y: 1 },
168
+ ],
169
+ },
170
+ ],
171
+ pout: [
172
+ { x: -8, y: 2 },
173
+ {
174
+ bezier: [
175
+ { x: 0, y: 5 },
176
+ { x: 8, y: 2 },
177
+ { x: 8, y: 4 },
178
+ ],
179
+ },
180
+ { x: 0, y: 6 },
181
+ { x: -8, y: 4 },
182
+ ],
183
+ sad: [
184
+ { x: -12, y: 3 },
185
+ {
186
+ bezier: [
187
+ { x: -6, y: 0 },
188
+ { x: 0, y: -1 },
189
+ { x: 6, y: 0 },
190
+ ],
191
+ },
192
+ { x: 12, y: 3 },
193
+ { x: 13, y: 5 },
194
+ {
195
+ bezier: [
196
+ { x: 7, y: 2 },
197
+ { x: 0, y: 1 },
198
+ { x: -7, y: 2 },
199
+ ],
200
+ },
201
+ { x: -13, y: 5 },
202
+ ],
203
+ small: [
204
+ { x: -6, y: 1 },
205
+ { x: 6, y: 1 },
206
+ { x: 7, y: 3 },
207
+ { x: 0, y: 2 },
208
+ { x: -7, y: 3 },
209
+ ],
210
+ surprised: [],
211
+ worried: [
212
+ { x: -11, y: 1 },
213
+ {
214
+ bezier: [
215
+ { x: -6, y: 3 },
216
+ { x: -3, y: 1 },
217
+ { x: 0, y: 2 },
218
+ ],
219
+ },
220
+ {
221
+ bezier: [
222
+ { x: 3, y: 1 },
223
+ { x: 6, y: 3 },
224
+ { x: 11, y: 1 },
225
+ ],
226
+ },
227
+ { x: 12, y: 3 },
228
+ { x: 0, y: 4 },
229
+ { x: -12, y: 3 },
230
+ ],
231
+ dead: [
232
+ { x: -12, y: 1 },
233
+ { x: 12, y: 1 },
234
+ { x: 13, y: 4 },
235
+ {
236
+ bezier: [
237
+ { x: 7, y: 3 },
238
+ { x: 0, y: 4 },
239
+ { x: -7, y: 3 },
240
+ ],
241
+ },
242
+ { x: -13, y: 4 },
243
+ ],
244
+ normal: [
245
+ { x: -12, y: 1 },
246
+ { x: 12, y: 1 },
247
+ { x: 13, y: 4 },
248
+ {
249
+ bezier: [
250
+ { x: 7, y: 3 },
251
+ { x: 0, y: 4 },
252
+ { x: -7, y: 3 },
253
+ ],
254
+ },
255
+ { x: -13, y: 4 },
256
+ ],
257
+ });
258
+ const lettucePaths = pathMap({
259
+ angry: [
260
+ { x: -13, y: 0 },
261
+ { x: 13, y: 0 },
262
+ { x: 13, y: 2 },
263
+ {
264
+ bezier: [
265
+ { x: 7, y: 1 },
266
+ { x: 0, y: 2 },
267
+ { x: -7, y: 1 },
268
+ ],
269
+ },
270
+ { x: -13, y: 2 },
271
+ ],
272
+ happy: [
273
+ { x: -12, y: 2 },
274
+ {
275
+ bezier: [
276
+ { x: -6, y: 0 },
277
+ { x: 0, y: -1 },
278
+ { x: 6, y: 0 },
279
+ ],
280
+ },
281
+ { x: 12, y: 2 },
282
+ { x: 13, y: 3 },
283
+ {
284
+ bezier: [
285
+ { x: 7, y: 1 },
286
+ { x: 0, y: 0 },
287
+ { x: -7, y: 1 },
288
+ ],
289
+ },
290
+ { x: -13, y: 3 },
291
+ ],
292
+ open: [
293
+ { x: -10, y: 2 },
294
+ {
295
+ bezier: [
296
+ { x: -10, y: -3 },
297
+ { x: -5, y: -6 },
298
+ { x: 0, y: -6 },
299
+ ],
300
+ },
301
+ {
302
+ bezier: [
303
+ { x: 5, y: -6 },
304
+ { x: 10, y: -3 },
305
+ { x: 10, y: 2 },
306
+ ],
307
+ },
308
+ { x: 10, y: 1 },
309
+ {
310
+ bezier: [
311
+ { x: 5, y: -4 },
312
+ { x: -5, y: -4 },
313
+ { x: -10, y: 1 },
314
+ ],
315
+ },
316
+ ],
317
+ pout: [
318
+ { x: -8, y: 0 },
319
+ {
320
+ bezier: [
321
+ { x: -4, y: -1 },
322
+ { x: 0, y: 0 },
323
+ { x: 4, y: -1 },
324
+ ],
325
+ },
326
+ { x: 8, y: 0 },
327
+ { x: 9, y: 1 },
328
+ { x: 0, y: 1 },
329
+ { x: -9, y: 1 },
330
+ ],
331
+ sad: [
332
+ { x: -12, y: 0 },
333
+ {
334
+ bezier: [
335
+ { x: -6, y: 2 },
336
+ { x: 0, y: 3 },
337
+ { x: 6, y: 2 },
338
+ ],
339
+ },
340
+ { x: 12, y: 0 },
341
+ { x: 13, y: 1 },
342
+ {
343
+ bezier: [
344
+ { x: 7, y: 3 },
345
+ { x: 0, y: 4 },
346
+ { x: -7, y: 3 },
347
+ ],
348
+ },
349
+ { x: -13, y: 1 },
350
+ ],
351
+ small: [
352
+ { x: -6, y: 0 },
353
+ {
354
+ bezier: [
355
+ { x: -3, y: 1 },
356
+ { x: 0, y: 0 },
357
+ { x: 3, y: 1 },
358
+ ],
359
+ },
360
+ { x: 6, y: 0 },
361
+ { x: 7, y: 1 },
362
+ { x: 0, y: 1 },
363
+ { x: -7, y: 1 },
364
+ ],
365
+ surprised: [
366
+ { x: -13, y: 2 },
367
+ {
368
+ bezier: [
369
+ { x: -7, y: -2 },
370
+ { x: 0, y: -3 },
371
+ { x: 7, y: -2 },
372
+ ],
373
+ },
374
+ { x: 13, y: 2 },
375
+ { x: 14, y: 3 },
376
+ {
377
+ bezier: [
378
+ { x: 8, y: 0 },
379
+ { x: 0, y: -1 },
380
+ { x: -8, y: 0 },
381
+ ],
382
+ },
383
+ { x: -14, y: 3 },
384
+ ],
385
+ worried: [
386
+ { x: -11, y: 1 },
387
+ {
388
+ bezier: [
389
+ { x: -6, y: 0 },
390
+ { x: -3, y: 1 },
391
+ { x: 0, y: 0 },
392
+ ],
393
+ },
394
+ {
395
+ bezier: [
396
+ { x: 3, y: 2 },
397
+ { x: 6, y: 0 },
398
+ { x: 11, y: 1 },
399
+ ],
400
+ },
401
+ { x: 12, y: 2 },
402
+ {
403
+ bezier: [
404
+ { x: 7, y: 1 },
405
+ { x: 0, y: 1 },
406
+ { x: -7, y: 1 },
407
+ ],
408
+ },
409
+ { x: -12, y: 2 },
410
+ ],
411
+ dead: [
412
+ { x: -12, y: 1 },
413
+ {
414
+ bezier: [
415
+ { x: -6, y: 0 },
416
+ { x: 0, y: -0.5 },
417
+ { x: 6, y: 0 },
418
+ ],
419
+ },
420
+ { x: 12, y: 1 },
421
+ { x: 13, y: 2 },
422
+ {
423
+ bezier: [
424
+ { x: 7, y: 1 },
425
+ { x: 0, y: 0.5 },
426
+ { x: -7, y: 1 },
427
+ ],
428
+ },
429
+ { x: -13, y: 2 },
430
+ ],
431
+ normal: [
432
+ { x: -12, y: 1 },
433
+ {
434
+ bezier: [
435
+ { x: -6, y: 0 },
436
+ { x: 0, y: -0.5 },
437
+ { x: 6, y: 0 },
438
+ ],
439
+ },
440
+ { x: 12, y: 1 },
441
+ { x: 13, y: 2 },
442
+ {
443
+ bezier: [
444
+ { x: 7, y: 1 },
445
+ { x: 0, y: 0.5 },
446
+ { x: -7, y: 1 },
447
+ ],
448
+ },
449
+ { x: -13, y: 2 },
450
+ ],
451
+ });
452
+ const mouths = {};
453
+ for (const name of [
454
+ "normal",
455
+ "happy",
456
+ "sad",
457
+ "angry",
458
+ "surprised",
459
+ "dead",
460
+ "small",
461
+ "worried",
462
+ "pout",
463
+ "open",
464
+ ]) {
465
+ const variant = scene.group({
466
+ parent: mouthGroup,
467
+ name: `burger.mouth.${name}`,
468
+ });
469
+ const cheeseTranslate = {
470
+ y: name === "open" ? 2 : name === "small" ? 0.5 : 1.5,
471
+ z: name === "pout" ? 1 : 0,
472
+ };
473
+ if (name === "surprised")
474
+ scene.ellipse({
475
+ parent: variant,
476
+ name: `cheese.${name}`,
477
+ color: color("cheese"),
478
+ fill: true,
479
+ height: 8,
480
+ stroke: 2,
481
+ translate: { y: 2, z: 0 },
482
+ width: 6,
483
+ });
484
+ else
485
+ scene.path({
486
+ parent: variant,
487
+ name: `cheese.${name}`,
488
+ color: color("cheese"),
489
+ fill: true,
490
+ path: requiredPath(cheesePaths, name),
491
+ stroke: 2,
492
+ translate: cheeseTranslate,
493
+ });
494
+ const lettuceTranslate = {
495
+ y: name === "open" ? 1 : name === "surprised" ? -1 : -0.5,
496
+ z: name === "pout" ? 2 : 1,
497
+ };
498
+ scene.path({
499
+ parent: variant,
500
+ name: `lettuce.${name}`,
501
+ color: color("lettuce"),
502
+ fill: true,
503
+ path: requiredPath(lettucePaths, name),
504
+ stroke: 1.5,
505
+ translate: lettuceTranslate,
506
+ });
507
+ mouths[name] = variant;
508
+ }
509
+ return {
510
+ root,
511
+ variants: { eyes: base.eyes, mouth: mouths, blush: base.blush },
512
+ };
513
+ },
514
+ expressions: baseExpressions,
515
+ activities: baseActivities,
516
+ defaultPresentation: { activity: "idle", expression: "normal" },
517
+ };