castle-web-cli 0.4.232 → 0.4.233

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 (355) hide show
  1. package/dist/agent-failures.d.ts +8 -0
  2. package/dist/agent-failures.js +19 -2
  3. package/dist/agent-prompts.d.ts +1 -1
  4. package/dist/agent-prompts.js +10 -3
  5. package/dist/agent.d.ts +64 -3
  6. package/dist/agent.js +170 -81
  7. package/dist/castle-host/host.d.ts +1 -0
  8. package/dist/castle-host/host.js +51 -3
  9. package/dist/castleJson.d.ts +4 -2
  10. package/dist/castleJson.js +2 -0
  11. package/dist/check.d.ts +3 -1
  12. package/dist/check.js +11 -1
  13. package/dist/devSessionStorage.js +47 -1
  14. package/dist/importPinMismatch.d.ts +22 -0
  15. package/dist/importPinMismatch.js +77 -0
  16. package/dist/importRegression.js +3 -15
  17. package/dist/imports.d.ts +10 -3
  18. package/dist/imports.js +88 -20
  19. package/dist/index.js +5 -4
  20. package/dist/init.js +1 -1
  21. package/dist/platformDoc.js +22 -0
  22. package/dist/routerFences.d.ts +5 -0
  23. package/dist/routerFences.js +12 -2
  24. package/dist/save-deck.d.ts +5 -0
  25. package/dist/save-deck.js +37 -4
  26. package/dist/serve.js +3 -0
  27. package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
  28. package/dist/shell/assets/index-MVLfNYd9.css +1 -0
  29. package/dist/shell/index.html +2 -2
  30. package/dist/taskSteer.d.ts +13 -0
  31. package/dist/taskSteer.js +22 -2
  32. package/kits/base/castle.json +1 -1
  33. package/kits/base/package-lock.json +1 -1
  34. package/kits/base/sdk/README.md +79 -2
  35. package/kits/base/sdk/avatar.d.ts +6 -2
  36. package/kits/base/sdk/avatar.js +12 -4
  37. package/kits/base/sdk/castle.d.ts +1 -1
  38. package/kits/base/sdk/commands.d.ts +14 -0
  39. package/kits/base/sdk/hub.d.ts +6 -2
  40. package/kits/base/sdk/hub.js +13 -0
  41. package/kits/base/sdk/multiplayer.js +17 -1
  42. package/kits/base/sdk/save.js +2 -1
  43. package/kits/base/sdk/server/hub.d.ts +87 -0
  44. package/kits/base/sdk/server/hub.js +70 -0
  45. package/kits/base/sdk/server/platformHandle.d.ts +31 -1
  46. package/kits/base/sdk/server/storage.d.ts +13 -0
  47. package/kits/base/sdk/server/storage.js +46 -0
  48. package/kits/base/sdk/server/wrapper.d.ts +36 -5
  49. package/kits/base/sdk/server/wrapper.js +83 -8
  50. package/kits/hub-game/CLAUDE.md +329 -11
  51. package/kits/hub-game/blueprints/avatar-10.scene +28 -0
  52. package/kits/hub-game/blueprints/avatar-11.scene +28 -0
  53. package/kits/hub-game/blueprints/avatar-12.scene +28 -0
  54. package/kits/hub-game/blueprints/avatar-13.scene +28 -0
  55. package/kits/hub-game/blueprints/avatar-14.scene +28 -0
  56. package/kits/hub-game/blueprints/avatar-15.scene +28 -0
  57. package/kits/hub-game/blueprints/avatar-4.scene +28 -0
  58. package/kits/hub-game/blueprints/avatar-5.scene +28 -0
  59. package/kits/hub-game/blueprints/avatar-6.scene +28 -0
  60. package/kits/hub-game/blueprints/avatar-7.scene +28 -0
  61. package/kits/hub-game/blueprints/avatar-8.scene +28 -0
  62. package/kits/hub-game/blueprints/avatar-9.scene +28 -0
  63. package/kits/hub-game/code/client/actorBudget.js +47 -0
  64. package/kits/hub-game/code/client/attention.js +11 -2
  65. package/kits/hub-game/code/client/avatar.js +309 -35
  66. package/kits/hub-game/code/client/avatarCap.js +228 -0
  67. package/kits/hub-game/code/client/avatarColors.js +70 -0
  68. package/kits/hub-game/code/client/avatarFaces.js +21 -0
  69. package/kits/hub-game/code/client/avatarShare.js +251 -0
  70. package/kits/hub-game/code/client/ballot.js +467 -0
  71. package/kits/hub-game/code/client/build.js +22 -0
  72. package/kits/hub-game/code/client/chrome.js +1144 -50
  73. package/kits/hub-game/code/client/companion.js +716 -0
  74. package/kits/hub-game/code/client/companionDress.js +99 -0
  75. package/kits/hub-game/code/client/decor.js +509 -0
  76. package/kits/hub-game/code/client/earned.js +131 -0
  77. package/kits/hub-game/code/client/emoteBubble.js +75 -0
  78. package/kits/hub-game/code/client/grab.js +339 -20
  79. package/kits/hub-game/code/client/hookLayer.js +299 -13
  80. package/kits/hub-game/code/client/idle.js +163 -22
  81. package/kits/hub-game/code/client/interestCap.js +81 -0
  82. package/kits/hub-game/code/client/keys.js +36 -0
  83. package/kits/hub-game/code/client/labelsNear.js +205 -0
  84. package/kits/hub-game/code/client/menuIcons.js +34 -0
  85. package/kits/hub-game/code/client/pack.js +6 -2
  86. package/kits/hub-game/code/client/packFormat.js +3 -3
  87. package/kits/hub-game/code/client/rehello.js +167 -0
  88. package/kits/hub-game/code/client/shot.js +92 -0
  89. package/kits/hub-game/code/client/sound.js +63 -8
  90. package/kits/hub-game/code/client/soundscape.js +1151 -0
  91. package/kits/hub-game/code/client/soundscapeActions.js +99 -0
  92. package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
  93. package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
  94. package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
  95. package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
  96. package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
  97. package/kits/hub-game/code/client/soundscapeCues.js +362 -0
  98. package/kits/hub-game/code/client/soundscapeMap.js +181 -0
  99. package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
  100. package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
  101. package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
  102. package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
  103. package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
  104. package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
  105. package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
  106. package/kits/hub-game/code/client/soundscapeUi.js +211 -0
  107. package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
  108. package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
  109. package/kits/hub-game/code/client/spin.js +101 -0
  110. package/kits/hub-game/code/client/state.js +109 -1
  111. package/kits/hub-game/code/client/stuck.js +259 -0
  112. package/kits/hub-game/code/client/talk.js +538 -47
  113. package/kits/hub-game/code/client/tiers.js +516 -27
  114. package/kits/hub-game/code/client/toastBand.js +37 -0
  115. package/kits/hub-game/code/client/together.js +32 -0
  116. package/kits/hub-game/code/client/visibility.js +43 -0
  117. package/kits/hub-game/code/client/wear.js +461 -170
  118. package/kits/hub-game/code/client/yours.js +199 -0
  119. package/kits/hub-game/code/companionSpec.js +45 -0
  120. package/kits/hub-game/code/privateText.js +7 -0
  121. package/kits/hub-game/code/server/actions.js +133 -0
  122. package/kits/hub-game/code/server/actors.js +9 -1
  123. package/kits/hub-game/code/server/ask.js +155 -0
  124. package/kits/hub-game/code/server/ballot.js +539 -0
  125. package/kits/hub-game/code/server/cells.js +100 -0
  126. package/kits/hub-game/code/server/companion.js +82 -0
  127. package/kits/hub-game/code/server/cues.js +70 -0
  128. package/kits/hub-game/code/server/decor.js +269 -0
  129. package/kits/hub-game/code/server/earned.js +461 -0
  130. package/kits/hub-game/code/server/friendBests.js +166 -0
  131. package/kits/hub-game/code/server/friendsAmong.js +232 -0
  132. package/kits/hub-game/code/server/history.js +5 -0
  133. package/kits/hub-game/code/server/hub.js +1254 -50
  134. package/kits/hub-game/code/server/idle.js +30 -11
  135. package/kits/hub-game/code/server/index.js +2 -2
  136. package/kits/hub-game/code/server/labels.js +28 -2
  137. package/kits/hub-game/code/server/manifest.js +378 -7
  138. package/kits/hub-game/code/server/menu.js +133 -0
  139. package/kits/hub-game/code/server/npcs.js +830 -80
  140. package/kits/hub-game/code/server/party.js +2 -2
  141. package/kits/hub-game/code/server/players.js +22 -0
  142. package/kits/hub-game/code/server/shot.js +110 -0
  143. package/kits/hub-game/code/server/standing.js +124 -0
  144. package/kits/hub-game/code/server/vis.js +113 -0
  145. package/kits/hub-game/code/server/wear.js +12 -0
  146. package/kits/hub-game/code/server/yours.js +59 -0
  147. package/kits/hub-game/code/shared/cues.js +9 -0
  148. package/kits/hub-game/code/shared/decor.js +41 -0
  149. package/kits/hub-game/code/shared/shot.js +19 -0
  150. package/kits/hub-game/code/shared/spin.js +57 -0
  151. package/kits/hub-game/code/systems/hub.js +845 -95
  152. package/kits/hub-game/docs/content-pack.md +1 -1
  153. package/kits/hub-game/docs/contract.md +2244 -61
  154. package/kits/hub-game/docs/home-pieces.md +64 -0
  155. package/kits/hub-game/models/avatar-10.pxmodel +28 -0
  156. package/kits/hub-game/models/avatar-11.pxmodel +28 -0
  157. package/kits/hub-game/models/avatar-12.pxmodel +27 -0
  158. package/kits/hub-game/models/avatar-13.pxmodel +24 -0
  159. package/kits/hub-game/models/avatar-14.pxmodel +29 -0
  160. package/kits/hub-game/models/avatar-15.pxmodel +24 -0
  161. package/kits/hub-game/models/avatar-4.pxmodel +29 -0
  162. package/kits/hub-game/models/avatar-5.pxmodel +27 -0
  163. package/kits/hub-game/models/avatar-6.pxmodel +26 -0
  164. package/kits/hub-game/models/avatar-7.pxmodel +25 -0
  165. package/kits/hub-game/models/avatar-8.pxmodel +24 -0
  166. package/kits/hub-game/models/avatar-9.pxmodel +30 -0
  167. package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
  168. package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
  169. package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
  170. package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
  171. package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
  172. package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
  173. package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
  174. package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
  175. package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
  176. package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
  177. package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
  178. package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
  179. package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
  180. package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
  181. package/kits/hub-game/models/hats/cap.pxmodel +162 -0
  182. package/kits/hub-game/models/hats/captain.pxmodel +178 -0
  183. package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
  184. package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
  185. package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
  186. package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
  187. package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
  188. package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
  189. package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
  190. package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
  191. package/kits/hub-game/models/hats/straw.pxmodel +139 -0
  192. package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
  193. package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
  194. package/kits/hub-game/models/hats/witch.pxmodel +147 -0
  195. package/kits/hub-game/package-lock.json +2 -0
  196. package/kits/hub-game/package.json +2 -1
  197. package/kits/hub-game/scripts/check.mjs +78 -11
  198. package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
  199. package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
  200. package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
  201. package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
  202. package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
  203. package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
  204. package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
  205. package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
  206. package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
  207. package/kits/hub-game/scripts/gen-earned.mjs +285 -0
  208. package/kits/hub-game/scripts/gen-hats.mjs +827 -0
  209. package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
  210. package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
  211. package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
  212. package/kits/hub-game/scripts/test-actions.mjs +298 -0
  213. package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
  214. package/kits/hub-game/scripts/test-actors.mjs +19 -17
  215. package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
  216. package/kits/hub-game/scripts/test-ask.mjs +269 -0
  217. package/kits/hub-game/scripts/test-attention.mjs +10 -1
  218. package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
  219. package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
  220. package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
  221. package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
  222. package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
  223. package/kits/hub-game/scripts/test-avatar.mjs +540 -7
  224. package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
  225. package/kits/hub-game/scripts/test-build.mjs +31 -0
  226. package/kits/hub-game/scripts/test-cells.mjs +71 -0
  227. package/kits/hub-game/scripts/test-chat.mjs +662 -0
  228. package/kits/hub-game/scripts/test-classic.mjs +2 -0
  229. package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
  230. package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
  231. package/kits/hub-game/scripts/test-companion.mjs +259 -0
  232. package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
  233. package/kits/hub-game/scripts/test-decor.mjs +457 -0
  234. package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
  235. package/kits/hub-game/scripts/test-earned.mjs +1194 -0
  236. package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
  237. package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
  238. package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
  239. package/kits/hub-game/scripts/test-grab.mjs +7 -0
  240. package/kits/hub-game/scripts/test-hats.mjs +422 -168
  241. package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
  242. package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
  243. package/kits/hub-game/scripts/test-hub-trip.mjs +716 -2
  244. package/kits/hub-game/scripts/test-hud-clear.mjs +328 -4
  245. package/kits/hub-game/scripts/test-idle.mjs +361 -1
  246. package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
  247. package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
  248. package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
  249. package/kits/hub-game/scripts/test-keys.mjs +46 -1
  250. package/kits/hub-game/scripts/test-labels.mjs +596 -0
  251. package/kits/hub-game/scripts/test-manifest.mjs +207 -0
  252. package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
  253. package/kits/hub-game/scripts/test-menu.mjs +296 -0
  254. package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
  255. package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
  256. package/kits/hub-game/scripts/test-pack.mjs +7 -0
  257. package/kits/hub-game/scripts/test-picker.mjs +314 -0
  258. package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
  259. package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
  260. package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
  261. package/kits/hub-game/scripts/test-shot.mjs +756 -0
  262. package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
  263. package/kits/hub-game/scripts/test-spin.mjs +314 -0
  264. package/kits/hub-game/scripts/test-standing.mjs +416 -0
  265. package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
  266. package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
  267. package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
  268. package/kits/hub-game/scripts/test-tiers.mjs +477 -2
  269. package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
  270. package/kits/hub-game/scripts/test-try-on.mjs +22 -22
  271. package/kits/hub-game/scripts/test-vis.mjs +343 -0
  272. package/kits/hub-game/scripts/test-visibility.mjs +134 -0
  273. package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
  274. package/kits/hub-game/scripts/test-yours.mjs +372 -0
  275. package/kits/multiplayer-3d/CLAUDE.md +50 -0
  276. package/kits/multiplayer-3d/castle.json +5 -5
  277. package/kits/multiplayer-3d/code/client/avatars.js +7 -0
  278. package/kits/multiplayer-3d/code/client/gait.js +65 -0
  279. package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
  280. package/kits/multiplayer-3d/code/options.js +5 -0
  281. package/kits/multiplayer-3d/code/server/ownership.js +10 -2
  282. package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
  283. package/kits/multiplayer-3d/code/server/world.js +7 -0
  284. package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
  285. package/kits/multiplayer-3d/package.json +2 -1
  286. package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
  287. package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
  288. package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
  289. package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
  290. package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
  291. package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
  292. package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
  293. package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
  294. package/kits/physics-2d/CLAUDE.md +9 -0
  295. package/kits/physics-2d/castle.json +2 -2
  296. package/kits/physics-2d/engine/scene.js +253 -1
  297. package/kits/physics-2d/engine/skyKey.js +129 -0
  298. package/kits/physics-2d/engine/stillClock.js +106 -0
  299. package/kits/physics-2d/engine/updateBudget.js +21 -0
  300. package/kits/physics-2d/scripts/test-skip-unchanged.mjs +326 -1
  301. package/kits/physics-3d/CLAUDE.md +1169 -30
  302. package/kits/physics-3d/behaviors/Player.jsx +629 -72
  303. package/kits/physics-3d/castle.json +3 -3
  304. package/kits/physics-3d/docs/pxmodel-format.md +8 -0
  305. package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +69 -13
  306. package/kits/physics-3d/engine3d/actornode.js +86 -0
  307. package/kits/physics-3d/engine3d/animationBudget.js +23 -0
  308. package/kits/physics-3d/engine3d/editorWorld.js +6 -0
  309. package/kits/physics-3d/engine3d/emptynodes.js +232 -0
  310. package/kits/physics-3d/engine3d/framecap.js +96 -0
  311. package/kits/physics-3d/engine3d/gait.js +118 -0
  312. package/kits/physics-3d/engine3d/kithooks.js +47 -0
  313. package/kits/physics-3d/engine3d/look.js +507 -48
  314. package/kits/physics-3d/engine3d/lookbake.js +208 -0
  315. package/kits/physics-3d/engine3d/materialpresets.js +2 -0
  316. package/kits/physics-3d/engine3d/motion.js +39 -10
  317. package/kits/physics-3d/engine3d/nearshadows.js +37 -19
  318. package/kits/physics-3d/engine3d/optimize.js +9 -5
  319. package/kits/physics-3d/engine3d/orbitinput.js +487 -9
  320. package/kits/physics-3d/engine3d/orbitlens.js +48 -0
  321. package/kits/physics-3d/engine3d/ownmodel.js +213 -0
  322. package/kits/physics-3d/engine3d/pxmodel.js +42 -11
  323. package/kits/physics-3d/engine3d/shadowfade.js +882 -0
  324. package/kits/physics-3d/engine3d/sky.js +547 -0
  325. package/kits/physics-3d/engine3d/skylife.js +306 -0
  326. package/kits/physics-3d/engine3d/unchanged.js +11 -0
  327. package/kits/physics-3d/engine3d/viewrange.js +52 -0
  328. package/kits/physics-3d/engine3d/world3d.js +796 -69
  329. package/kits/physics-3d/main.jsx +5 -0
  330. package/kits/physics-3d/package.json +1 -1
  331. package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
  332. package/kits/physics-3d/scripts/test-camera-orbit.mjs +2563 -80
  333. package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +1 -1
  334. package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
  335. package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
  336. package/kits/physics-3d/scripts/test-gait.mjs +387 -0
  337. package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
  338. package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
  339. package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
  340. package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
  341. package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
  342. package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
  343. package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
  344. package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
  345. package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
  346. package/kits/physics-3d/scripts/test-static-actors.mjs +8 -1
  347. package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
  348. package/kits/physics-3d/scripts/test-steady-hover.mjs +2 -0
  349. package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
  350. package/kits/physics-3d/systems/physics3d.js +383 -6
  351. package/kits/real-time/castle.json +2 -2
  352. package/kits/real-time/code/server/gameHooks.js +7 -0
  353. package/kits/real-time/code/server/session.js +97 -19
  354. package/package.json +2 -2
  355. package/dist/shell/assets/index-Cf61cNfT.css +0 -1
@@ -1,8 +1,12 @@
1
- // Writes the kit's four player avatars, `models/avatar-0.pxmodel` to
2
- // `avatar-3.pxmodel`: the Castle mascot, Petal, Beat and Star, in the hub's
3
- // toon style. Run from the kit: `node scripts/gen-avatars.mjs` (or with a
4
- // directory to write into instead of `models/`). The model files are this
5
- // script's output; change a character here and run it again.
1
+ // Writes the kit's sixteen player avatars, `models/avatar-0.pxmodel` to
2
+ // `avatar-15.pxmodel`, in the hub's toon style: the Castle mascot, Petal, Beat
3
+ // and Star, then (v1.51) Biscuit, Mochi, Hop, Pip, Ribbit, Ember, Bolt, Gloop,
4
+ // Cap, Toast, Scoop and Zest. It also writes `code/client/avatarFaces.js`, each
5
+ // character's name and the small face the picker shows for it. Run from the
6
+ // kit: `node scripts/gen-avatars.mjs` (or with a directory to write everything
7
+ // into instead). The model files and the faces are this script's output;
8
+ // change a character here and run it again (scripts/test-avatar.mjs holds the
9
+ // files to it).
6
10
  //
7
11
  // What every avatar keeps, because the kit and the phone budget depend on it:
8
12
  // - part ids `torso`, `head`, `legL`, `legR`, `armL`, `armR` (the walk moves
@@ -11,7 +15,13 @@
11
15
  // batches (torso, head, two legs, two arms) plus an outline on the torso and
12
16
  // the head only. The limbs are ink-coloured and unoutlined, since an outline
13
17
  // on each would be four more draw calls;
14
- // - flat colours: no textures and no glow.
18
+ // - flat colours: no textures and no glow;
19
+ // - a crown a hat can sit on: rounded or flat, with ears, horns, stalks and
20
+ // leaves beside or behind it. Each avatar's height and hat fit, measured on
21
+ // its model, are in `code/client/avatar.js` (`TOPS`, `HAT_FITS`);
22
+ // - no part under 3.5 cm in radius on the torso or the head (the engine
23
+ // outlines those apart, a draw call more), and no part called `tail`,
24
+ // `wingL` or `wingR` (the engine moves those by name, each in its own batch).
15
25
 
16
26
  import fs from 'node:fs';
17
27
  import path from 'node:path';
@@ -19,6 +29,10 @@ import { fileURLToPath } from 'node:url';
19
29
 
20
30
  const KIT_DIR = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
21
31
  const OUT_DIR = process.argv[2] ? path.resolve(process.argv[2]) : path.join(KIT_DIR, 'models');
32
+ const FACES_FILE = path.join(
33
+ process.argv[2] ? OUT_DIR : path.join(KIT_DIR, 'code', 'client'),
34
+ 'avatarFaces.js',
35
+ );
22
36
 
23
37
  const INK = '#241a2e';
24
38
  const WHITE = '#ffffff';
@@ -156,7 +170,7 @@ function onHead({ radius, scale }, x, y, lift = 0) {
156
170
  // A round patch lying on the face, +z before `at` turns it: an eye, a glint,
157
171
  // a cheek. A squashed sphere, not a disc: a disc's outline hull shows as a
158
172
  // ring round it, while a sphere's only thickens its edge.
159
- function patch(id, at, { r, wide = 1, tall = 1, segments = 6, mirror = true }, color) {
173
+ function patch(id, at, { r, wide = 1, tall = 1, deep = 0.3, segments = 6, mirror = true }, color) {
160
174
  const part = {
161
175
  id,
162
176
  parent: 'head',
@@ -164,7 +178,7 @@ function patch(id, at, { r, wide = 1, tall = 1, segments = 6, mirror = true }, c
164
178
  radius: r,
165
179
  position: at.position,
166
180
  rotation: at.rotation,
167
- scale: [wide, tall, 0.3],
181
+ scale: [wide, tall, deep],
168
182
  segments,
169
183
  };
170
184
  if (mirror) {
@@ -175,12 +189,12 @@ function patch(id, at, { r, wide = 1, tall = 1, segments = 6, mirror = true }, c
175
189
 
176
190
  // Two ink ovals with a white glint each. `at(x, y, lift)` places a point on
177
191
  // the face.
178
- function eyes(at, { x, y, r, wide = 1, tall = 1, glint = 0.036 }) {
192
+ function eyes(at, { x, y, r, wide = 1, tall = 1, glint = 0.036, lift = 0 }) {
179
193
  return [
180
- patch('eye', at(x, y, 0), { r, wide, tall, segments: 8 }, INK),
194
+ patch('eye', at(x, y, lift), { r, wide, tall, segments: 8 }, INK),
181
195
  patch(
182
196
  'glint',
183
- at(x + r * wide * 0.3, y + r * tall * 0.4, r * 0.3),
197
+ at(x + r * wide * 0.3, y + r * tall * 0.4, lift + r * 0.3),
184
198
  { r: glint, segments: 4 },
185
199
  WHITE,
186
200
  ),
@@ -199,6 +213,19 @@ function starOutline(count, outer, inner) {
199
213
  return points;
200
214
  }
201
215
 
216
+ // A character's face for the picker: the inside of a 24 x 24 SVG, drawn in
217
+ // the character's own colours with the ink line (`write` adds the rest).
218
+ // Two ink dots for eyes, unless a face draws its own.
219
+ function dots(y, x = 2.6, r = 1.5) {
220
+ return `<g fill="${INK}" stroke="none"><circle cx="${12 - x}" cy="${y}" r="${r}"/><circle cx="${12 + x}" cy="${y}" r="${r}"/></g>`;
221
+ }
222
+ const disc = (cx, cy, r, fill, more = '') =>
223
+ `<circle cx="${cx}" cy="${cy}" r="${r}" fill="${fill}"${more}/>`;
224
+ const oval = (cx, cy, rx, ry, fill) =>
225
+ `<ellipse cx="${cx}" cy="${cy}" rx="${rx}" ry="${ry}" fill="${fill}"/>`;
226
+ const shape = (d, fill, more = '') => `<path d="${d}" fill="${fill}"${more}/>`;
227
+ const BARE = ' stroke="none"';
228
+
202
229
  //
203
230
  // 0: the Castle mascot. One black body rounded on top, one almond eye, and
204
231
  // the logo's white sheen down its side.
@@ -316,7 +343,13 @@ function mascot() {
316
343
  patch('pupil', flatOn(0, 0, -0.01), { r: 0.108, segments: 10, mirror: false }, INK),
317
344
  patch('glint', flatOn(0.042, 0.046, 0.016), { r: 0.038, mirror: false }, WHITE),
318
345
  );
319
- return { name: 'Castle', look: { ...LOOK, outlineColor: MASCOT_LINE }, parts };
346
+ const icon = [
347
+ shape('M5 22V10a7 7 0 0 1 14 0v12z', '#4a4556'),
348
+ shape('M7.2 19.5V10a4.8 4.8 0 0 1 1.6-3.6', 'none', ` stroke="${WHITE}"`),
349
+ shape('M7.6 13.4q4.4-4.6 8.8 0q-4.4 4.6-8.8 0z', WHITE),
350
+ disc(12, 13.4, 1.8, INK, BARE),
351
+ ];
352
+ return { name: 'Castle', look: { ...LOOK, outlineColor: MASCOT_LINE }, parts, icon };
320
353
  }
321
354
 
322
355
  //
@@ -412,7 +445,11 @@ function petal() {
412
445
  ),
413
446
  );
414
447
  parts.find((part) => part.id === 'mouth').rotation[2] = 180;
415
- return { name: 'Petal', parts };
448
+ const icon = [0, 60, 120, 180, 240, 300].map((turn) =>
449
+ disc(round(12 + 6.6 * Math.sin(rad(turn))), round(12 - 6.6 * Math.cos(rad(turn))), 4, pink),
450
+ );
451
+ icon.push(disc(12, 12, 6.4, '#fff1cf'), dots(12));
452
+ return { name: 'Petal', parts, icon };
416
453
  }
417
454
 
418
455
  //
@@ -512,7 +549,14 @@ function beat() {
512
549
  ),
513
550
  patch('tongue', at(0, -0.118, 0.012), { r: 0.045, tall: 0.5, mirror: false }, '#ff5fa2'),
514
551
  );
515
- return { name: 'Beat', parts };
552
+ const icon = [
553
+ shape('M4 13a8 8 0 0 1 16 0', 'none', ' stroke-width="2.2"'),
554
+ disc(12, 14, 7.5, '#38b6ff'),
555
+ oval(3.6, 14.5, 2, 3.4, orange),
556
+ oval(20.4, 14.5, 2, 3.4, orange),
557
+ dots(13.5),
558
+ ];
559
+ return { name: 'Beat', parts, icon };
516
560
  }
517
561
 
518
562
  //
@@ -572,7 +616,847 @@ function star() {
572
616
  orange,
573
617
  ),
574
618
  );
575
- return { name: 'Star', parts };
619
+ const icon = [
620
+ shape(
621
+ 'M12 1.5l3 6.6 7.2.8-5.4 4.9 1.5 7.1L12 17.3l-6.3 3.6 1.5-7.1L1.8 8.9l7.2-.8z',
622
+ '#ffd21f',
623
+ ),
624
+ dots(11.5, 2.2, 1.3),
625
+ ];
626
+ return { name: 'Star', parts, icon };
627
+ }
628
+
629
+ //
630
+ // Shared by the twelve after Star.
631
+ //
632
+
633
+ // The usual body: a rounded lathe from the hips to the neck.
634
+ const BODY = [
635
+ [0, -0.07],
636
+ [0.19, -0.02],
637
+ [0.24, 0.12],
638
+ [0.2, 0.28],
639
+ [0.12, 0.39],
640
+ [0, 0.42],
641
+ ];
642
+
643
+ // A part hung on another, coloured.
644
+ function on(parent, id, kind, color, fields) {
645
+ return mat({ id, parent, kind, ...fields }, color);
646
+ }
647
+
648
+ function ball(parent, id, color, radius, position, { scale, rotation, segments = 6, mirror } = {}) {
649
+ const part = { id, parent, kind: 'sphere', radius, position: position.map(round), segments };
650
+ if (scale) {
651
+ part.scale = scale;
652
+ }
653
+ if (rotation) {
654
+ part.rotation = rotation;
655
+ }
656
+ if (mirror) {
657
+ part.mirror = 'x';
658
+ }
659
+ return mat(part, color);
660
+ }
661
+
662
+ function cone(
663
+ parent,
664
+ id,
665
+ color,
666
+ radius,
667
+ height,
668
+ position,
669
+ rotation,
670
+ { segments = 5, scale, mirror } = {},
671
+ ) {
672
+ const part = {
673
+ id,
674
+ parent,
675
+ kind: 'cone',
676
+ radius,
677
+ height,
678
+ position: position.map(round),
679
+ rotation,
680
+ segments,
681
+ };
682
+ if (scale) {
683
+ part.scale = scale;
684
+ }
685
+ if (mirror) {
686
+ part.mirror = 'x';
687
+ }
688
+ return mat(part, color);
689
+ }
690
+
691
+ function roundHead(spec, y, color, segments = 10) {
692
+ return mat(
693
+ { id: 'head', parent: 'torso', kind: 'sphere', position: [0, y, 0], ...spec, segments },
694
+ color,
695
+ );
696
+ }
697
+
698
+ // `onHead` for a ball that is not at the head's pivot: a face mask, a snout.
699
+ function onBall(center, spec) {
700
+ return (x, y, lift) => {
701
+ const at = onHead(spec, x - center[0], y - center[1], lift);
702
+ return { position: at.position.map((v, k) => round(v + center[k])), rotation: at.rotation };
703
+ };
704
+ }
705
+
706
+ // `onHead` for a head that is a lathe: the point of its surface in front of
707
+ // [x, y] (behind it with `back`), pushed `lift` along the normal.
708
+ function onLathe(profile) {
709
+ return (x, y, lift = 0, back = false) => {
710
+ let k = 0;
711
+ while (k < profile.length - 2 && profile[k + 1][1] < y) {
712
+ k += 1;
713
+ }
714
+ const [r0, y0] = profile[k];
715
+ const [r1, y1] = profile[k + 1];
716
+ const r = r0 + ((r1 - r0) * (y - y0)) / (y1 - y0);
717
+ const side = back ? -1 : 1;
718
+ const z = side * Math.sqrt(Math.max(0, r * r - x * x));
719
+ // Outward, and up where the profile narrows upward.
720
+ const slope = Math.atan2(r0 - r1, y1 - y0);
721
+ const normal = [(Math.cos(slope) * x) / r, Math.sin(slope), (Math.cos(slope) * z) / r];
722
+ return {
723
+ position: [
724
+ round(x + normal[0] * lift),
725
+ round(y + normal[1] * lift),
726
+ round(z + normal[2] * lift),
727
+ ],
728
+ rotation: [
729
+ round(-deg(Math.asin(normal[1])) * side),
730
+ round(deg(Math.atan2(normal[0], normal[2]))),
731
+ 0,
732
+ ],
733
+ };
734
+ };
735
+ }
736
+
737
+ // A smile: half a thin ring, lying on the face at `at`.
738
+ function smile(at, radius = 0.045, tube = 0.016) {
739
+ const part = mat(
740
+ { id: 'mouth', parent: 'head', kind: 'torus', radius, tube, arc: 180, ...at, segments: 6 },
741
+ INK,
742
+ );
743
+ part.rotation[2] = 180;
744
+ return part;
745
+ }
746
+
747
+ function cheeks(at, color, r = 0.046) {
748
+ return patch('cheek', at, { r, tall: 0.7, segments: 5 }, color);
749
+ }
750
+
751
+ //
752
+ // 4: Biscuit, a puppy.
753
+ //
754
+
755
+ function biscuit() {
756
+ const tan = '#c79a68';
757
+ const brown = '#6b3d20';
758
+ const cream = '#ffe6bf';
759
+ const head = { radius: 0.3, scale: [1.05, 0.95, 1] };
760
+ const at = (x, y, lift) => onHead(head, x, y, lift);
761
+ const muzzle = [0, -0.09, 0.2];
762
+ const parts = limbs({ shoe: brown });
763
+ parts.push(
764
+ torso(BODY, tan),
765
+ roundHead(head, 0.68, tan),
766
+ // The patch round one eye: a ball inside the head that breaks its surface.
767
+ // A patch round one eye; that eye stands on it.
768
+ patch('eyePatch', at(0.13, 0.05, -0.012), { r: 0.135, tall: 1.1, mirror: false }, brown),
769
+ patch('eyeL', at(0.115, 0.04, 0.03), { r: 0.07, tall: 1.15, segments: 8, mirror: false }, INK),
770
+ patch('glintL', at(0.136, 0.072, 0.052), { r: 0.036, segments: 4, mirror: false }, WHITE),
771
+ patch('eyeR', at(-0.115, 0.04, 0), { r: 0.07, tall: 1.15, segments: 8, mirror: false }, INK),
772
+ patch('glintR', at(-0.094, 0.072, 0.022), { r: 0.036, segments: 4, mirror: false }, WHITE),
773
+ ball('head', 'muzzle', cream, 0.135, muzzle, { scale: [1.25, 0.85, 0.9] }),
774
+ ball('head', 'nose', INK, 0.05, [0, -0.045, 0.325], { scale: [1.25, 0.85, 0.8] }),
775
+ ball('head', 'tongue', '#ff5f8f', 0.045, [0, -0.175, 0.285], {
776
+ scale: [0.9, 1.1, 0.5],
777
+ segments: 4,
778
+ }),
779
+ // Floppy ears hang down the sides, clear of the crown.
780
+ ball('head', 'ear', brown, 0.13, [0.305, -0.03, -0.02], {
781
+ scale: [0.5, 1.45, 0.85],
782
+ rotation: [0, 0, 10],
783
+ mirror: true,
784
+ }),
785
+ on('torso', 'collar', 'cylinder', '#e8463c', {
786
+ radius: 0.15,
787
+ height: 0.055,
788
+ position: [0, 0.385, 0],
789
+ segments: 8,
790
+ }),
791
+ cone('torso', 'tailA', tan, 0.06, 0.24, [0, 0.13, -0.27], [-48, 0, 0]),
792
+ );
793
+ const icon = [
794
+ disc(12, 13, 8, tan),
795
+ oval(4.3, 13.5, 2.4, 5.4, brown),
796
+ oval(19.7, 13.5, 2.4, 5.4, brown),
797
+ disc(14.8, 11.6, 3.1, brown, BARE),
798
+ dots(11.6),
799
+ oval(12, 15.6, 1.9, 1.3, INK),
800
+ ];
801
+ return { name: 'Biscuit', parts, icon };
802
+ }
803
+
804
+ //
805
+ // 5: Mochi, a cat.
806
+ //
807
+
808
+ function mochi() {
809
+ const fur = '#686c7d';
810
+ const white = '#fffaf2';
811
+ const pink = '#ff7fae';
812
+ const head = { radius: 0.3, scale: [1.08, 0.92, 1] };
813
+ const at = (x, y, lift) => onHead(head, x, y, lift);
814
+ const parts = limbs({ shoe: pink });
815
+ parts.push(
816
+ torso(BODY, fur),
817
+ roundHead(head, 0.68, fur),
818
+ // Ears stand at the sides of the crown, so a hat sits between them.
819
+ cone('head', 'ear', fur, 0.115, 0.21, [0.215, 0.27, -0.02], [0, 0, -24], {
820
+ segments: 4,
821
+ mirror: true,
822
+ }),
823
+ cone('head', 'earIn', pink, 0.07, 0.14, [0.212, 0.262, 0.028], [0, 0, -24], {
824
+ segments: 4,
825
+ mirror: true,
826
+ }),
827
+ ...eyes(at, { x: 0.12, y: 0.035, r: 0.075, wide: 0.9, tall: 1.2 }),
828
+ ball('head', 'muzzle', white, 0.115, [0, -0.095, 0.2], { scale: [1.3, 0.8, 0.9] }),
829
+ ball('head', 'nose', pink, 0.04, [0, -0.06, 0.3], { scale: [1.2, 0.8, 0.7], segments: 4 }),
830
+ on('head', 'whiskerA', 'cylinder', INK, {
831
+ radius: 0.011,
832
+ height: 0.17,
833
+ position: [0.25, -0.075, 0.2],
834
+ rotation: [0, 20, 80],
835
+ segments: 3,
836
+ mirror: 'x',
837
+ }),
838
+ on('head', 'whiskerB', 'cylinder', INK, {
839
+ radius: 0.011,
840
+ height: 0.17,
841
+ position: [0.25, -0.125, 0.2],
842
+ rotation: [0, 20, 100],
843
+ segments: 3,
844
+ mirror: 'x',
845
+ }),
846
+ // The tail curls up behind.
847
+ on('torso', 'tailA', 'torus', fur, {
848
+ radius: 0.12,
849
+ tube: 0.042,
850
+ arc: 230,
851
+ position: [0, 0.2, -0.3],
852
+ rotation: [0, 90, 205],
853
+ segments: 6,
854
+ }),
855
+ );
856
+ const icon = [
857
+ shape('M4.6 11 5.4 3l5.4 3.6zM19.4 11 18.6 3l-5.4 3.6z', fur),
858
+ disc(12, 14, 8, fur),
859
+ shape('M1.5 14.5h4M18.5 14.5h4', 'none'),
860
+ dots(13),
861
+ oval(12, 16.2, 1.3, 0.9, pink),
862
+ ];
863
+ return { name: 'Mochi', parts, icon };
864
+ }
865
+
866
+ //
867
+ // 6: Hop, a bunny.
868
+ //
869
+
870
+ function hop() {
871
+ const white = '#fbf6ee';
872
+ const pink = '#ff8fb3';
873
+ const head = { radius: 0.29, scale: [1.04, 0.97, 1] };
874
+ const at = (x, y, lift) => onHead(head, x, y, lift);
875
+ const parts = limbs({ shoe: pink });
876
+ parts.push(
877
+ torso(BODY, white),
878
+ roundHead(head, 0.68, white),
879
+ // Two tall ears rise from the back of the crown, behind where a hat sits.
880
+ ball('head', 'ear', white, 0.1, [0.12, 0.37, -0.23], {
881
+ scale: [0.6, 2, 0.42],
882
+ rotation: [-8, 0, -8],
883
+ mirror: true,
884
+ }),
885
+ ball('head', 'earIn', pink, 0.07, [0.12, 0.37, -0.2], {
886
+ scale: [0.5, 2.1, 0.3],
887
+ rotation: [-8, 0, -8],
888
+ segments: 5,
889
+ mirror: true,
890
+ }),
891
+ ...eyes(at, { x: 0.11, y: 0.035, r: 0.072, wide: 0.9, tall: 1.2 }),
892
+ ball('head', 'nose', pink, 0.04, at(0, -0.05, 0.002).position, {
893
+ scale: [1.2, 0.8, 0.6],
894
+ segments: 4,
895
+ }),
896
+ on('head', 'teeth', 'box', '#ffffff', {
897
+ size: [0.075, 0.06, 0.04],
898
+ position: at(0, -0.125, 0).position,
899
+ rotation: at(0, -0.125, 0).rotation,
900
+ }),
901
+ cheeks(at(0.2, -0.08, 0), pink),
902
+ ball('torso', 'tailA', white, 0.095, [0, 0.07, -0.23]),
903
+ );
904
+ const icon = [
905
+ oval(8.6, 6.4, 2.2, 5.4, white),
906
+ oval(15.4, 6.4, 2.2, 5.4, white),
907
+ shape('M8.6 3.5v5M15.4 3.5v5', 'none', ` stroke="${pink}" stroke-width="1.5"`),
908
+ disc(12, 15.5, 7, white),
909
+ dots(14.5),
910
+ oval(12, 17.4, 1.2, 0.9, pink),
911
+ ];
912
+ return { name: 'Hop', parts, icon };
913
+ }
914
+
915
+ //
916
+ // 7: Pip, a penguin.
917
+ //
918
+
919
+ function pip() {
920
+ const navy = '#27356e';
921
+ const white = '#ffffff';
922
+ const orange = '#ff9326';
923
+ const head = { radius: 0.28, scale: [1.05, 0.96, 1] };
924
+ const mask = { radius: 0.225, scale: [1.04, 0.95, 1] };
925
+ const maskAt = [0, -0.035, 0.125];
926
+ const at = onBall(maskAt, mask);
927
+ const parts = limbs({ shoe: orange, mitt: navy });
928
+ parts.push(
929
+ torso(
930
+ [
931
+ [0, -0.07],
932
+ [0.22, -0.03],
933
+ [0.28, 0.12],
934
+ [0.24, 0.29],
935
+ [0.14, 0.4],
936
+ [0, 0.43],
937
+ ],
938
+ navy,
939
+ ),
940
+ ball('torso', 'belly', white, 0.21, [0, 0.14, 0.15], { scale: [1, 1.12, 0.75] }),
941
+ roundHead(head, 0.68, navy),
942
+ ball('head', 'mask', white, mask.radius, maskAt, { scale: mask.scale, segments: 10 }),
943
+ ...eyes(at, { x: 0.1, y: 0.03, r: 0.062, tall: 1.15 }),
944
+ cone('head', 'beak', orange, 0.075, 0.14, [0, -0.075, 0.37], [90, 0, 0], {
945
+ scale: [1.25, 1, 0.7],
946
+ }),
947
+ cheeks(at(0.17, -0.07, 0), '#ff8fb3', 0.04),
948
+ cone('torso', 'tailA', navy, 0.07, 0.16, [0, 0.03, -0.27], [-70, 0, 0]),
949
+ );
950
+ const icon = [
951
+ disc(12, 12.5, 9, navy),
952
+ oval(12, 14, 6.4, 5.8, white),
953
+ dots(12.6),
954
+ shape('M10.3 15h3.4L12 17.8z', orange),
955
+ ];
956
+ return { name: 'Pip', parts, icon };
957
+ }
958
+
959
+ //
960
+ // 8: Ribbit, a frog.
961
+ //
962
+
963
+ function ribbit() {
964
+ const green = '#4fbf3f';
965
+ const cream = '#fff3b8';
966
+ const head = { radius: 0.3, scale: [1.28, 0.74, 1] };
967
+ const at = (x, y, lift) => onHead(head, x, y, lift);
968
+ const bump = [0.235, 0.15, 0.05];
969
+ const bumpR = 0.108;
970
+ const eyeAt = (x, y, lift) => ({
971
+ position: [round(bump[0] + x), round(bump[1] + y), round(bump[2] + bumpR + lift)],
972
+ rotation: [0, 0, 0],
973
+ });
974
+ const parts = limbs({ shoe: green, mitt: cream });
975
+ parts.push(
976
+ torso(BODY, green),
977
+ ball('torso', 'belly', cream, 0.17, [0, 0.13, 0.14], { scale: [1, 1.1, 0.75], segments: 8 }),
978
+ roundHead(head, 0.64, green),
979
+ // The eyes stand on two bumps at the sides of the crown.
980
+ ball('head', 'bump', green, bumpR, bump, { mirror: true }),
981
+ patch('eye', eyeAt(0, 0.005, -0.012), { r: 0.066, segments: 8 }, INK),
982
+ patch('glint', eyeAt(0.02, 0.03, 0.006), { r: 0.036, segments: 4 }, WHITE),
983
+ // A wide mouth: an arc of a ring standing in the face.
984
+ on('head', 'mouth', 'torus', INK, {
985
+ radius: 0.16,
986
+ tube: 0.016,
987
+ arc: 120,
988
+ position: [0, 0.1, 0.283],
989
+ rotation: [0, 0, 210],
990
+ segments: 8,
991
+ }),
992
+ cheeks(at(0.25, -0.03, 0), '#ff8fb3'),
993
+ );
994
+ const icon = [
995
+ disc(6.8, 8, 3.6, green),
996
+ disc(17.2, 8, 3.6, green),
997
+ oval(12, 14.5, 10, 7, green),
998
+ dots(8, 5.2, 1.6),
999
+ shape('M7 15.5q5 4 10 0', 'none'),
1000
+ ];
1001
+ return { name: 'Ribbit', parts, icon };
1002
+ }
1003
+
1004
+ //
1005
+ // 9: Ember, a little dragon.
1006
+ //
1007
+
1008
+ function ember() {
1009
+ const purple = '#7a3fd0';
1010
+ const lilac = '#c9adf8';
1011
+ const flame = '#ff9a2e';
1012
+ const horn = '#ffe9a8';
1013
+ const head = { radius: 0.29, scale: [1.02, 0.95, 1] };
1014
+ const at = (x, y, lift) => onHead(head, x, y, lift);
1015
+ // The muzzle: a paler bump low on the face, nostrils on top, a mouth below.
1016
+ const muzzle = { radius: 0.135, scale: [1.15, 0.8, 1.1] };
1017
+ const muzzleAt = [0, -0.105, 0.2];
1018
+ const onMuzzle = onBall(muzzleAt, muzzle);
1019
+ const parts = limbs({ shoe: purple });
1020
+ parts.push(
1021
+ torso(BODY, purple),
1022
+ ball('torso', 'belly', flame, 0.17, [0, 0.13, 0.14], { scale: [0.95, 1.1, 0.75] }),
1023
+ roundHead(head, 0.68, purple),
1024
+ ball('head', 'muzzle', lilac, muzzle.radius, muzzleAt, { scale: muzzle.scale }),
1025
+ patch('nostril', onMuzzle(0.048, -0.045, -0.004), { r: 0.036, wide: 0.55, segments: 4 }, INK),
1026
+ smile(onMuzzle(0, -0.125, 0.002), 0.05, 0.014),
1027
+ ...eyes(at, { x: 0.12, y: 0.085, r: 0.07, tall: 1.15 }),
1028
+ // Horns at the sides of the crown, leaning out and back.
1029
+ cone('head', 'horn', horn, 0.058, 0.19, [0.215, 0.27, -0.07], [-18, 0, -30], { mirror: true }),
1030
+ cone('head', 'spikeA', flame, 0.07, 0.16, [0, 0.13, -0.3], [-75, 0, 0]),
1031
+ cone('torso', 'spikeB', flame, 0.07, 0.15, [0, 0.3, -0.21], [-80, 0, 0]),
1032
+ cone('torso', 'tailA', purple, 0.1, 0.42, [0, 0.03, -0.33], [-105, 0, 0], { segments: 6 }),
1033
+ cone('torso', 'tailTip', flame, 0.085, 0.16, [0, -0.045, -0.6], [-105, 0, 0], {
1034
+ scale: [1, 1, 0.5],
1035
+ }),
1036
+ on('torso', 'wing', 'extrude', '#5a2aa8', {
1037
+ outline: [
1038
+ [0, 0],
1039
+ [0.2, 0.17],
1040
+ [0.21, 0.02],
1041
+ [0.13, 0.04],
1042
+ [0.11, -0.07],
1043
+ ],
1044
+ depth: 0.035,
1045
+ flat: false,
1046
+ position: [0.1, 0.22, -0.2],
1047
+ rotation: [0, -40, 0],
1048
+ mirror: 'x',
1049
+ }),
1050
+ );
1051
+ const icon = [
1052
+ shape('M5.2 9.5 3.6 2.6l5.6 3.6zM18.8 9.5l1.6-6.9-5.6 3.6z', horn),
1053
+ shape('M12 1.8l2.2 4h-4.4z', flame),
1054
+ disc(12, 13.5, 8, purple),
1055
+ dots(11.4),
1056
+ oval(12, 17, 4, 2.9, lilac),
1057
+ dots(16, 1.3, 0.6),
1058
+ shape('M10.6 18.2q1.4 1 2.8 0', 'none', ' stroke-width="1"'),
1059
+ ];
1060
+ return { name: 'Ember', parts, icon };
1061
+ }
1062
+
1063
+ //
1064
+ // 10: Bolt, a robot.
1065
+ //
1066
+
1067
+ function bolt() {
1068
+ const steel = '#b5c1cf';
1069
+ const dark = '#3a4558';
1070
+ const yellow = '#ffc531';
1071
+ const cyan = '#35e0ff';
1072
+ const front = 0.22;
1073
+ const parts = limbs({ shoe: dark, mitt: yellow });
1074
+ parts.push(
1075
+ mat(
1076
+ {
1077
+ id: 'torso',
1078
+ kind: 'box',
1079
+ position: [0, HIP, 0],
1080
+ offset: [0, 0.17, 0],
1081
+ size: [0.38, 0.42, 0.28],
1082
+ round: 0.05,
1083
+ roundSegments: 1,
1084
+ },
1085
+ steel,
1086
+ ),
1087
+ on('torso', 'panel', 'box', dark, { size: [0.22, 0.15, 0.03], position: [0, 0.2, 0.135] }),
1088
+ ball('torso', 'light', '#ff4d4d', 0.04, [-0.05, 0.215, 0.15], {
1089
+ scale: [1, 1, 0.5],
1090
+ segments: 4,
1091
+ }),
1092
+ on('torso', 'dial', 'box', yellow, {
1093
+ size: [0.07, 0.035, 0.03],
1094
+ position: [0.05, 0.215, 0.143],
1095
+ }),
1096
+ on('torso', 'neck', 'cylinder', dark, {
1097
+ radius: 0.075,
1098
+ height: 0.1,
1099
+ position: [0, 0.43, 0],
1100
+ segments: 6,
1101
+ }),
1102
+ mat(
1103
+ {
1104
+ id: 'head',
1105
+ parent: 'torso',
1106
+ kind: 'box',
1107
+ position: [0, 0.69, 0],
1108
+ size: [0.56, 0.44, 0.44],
1109
+ round: 0.07,
1110
+ roundSegments: 1,
1111
+ },
1112
+ steel,
1113
+ ),
1114
+ // One visor strip, with two lights in it for eyes.
1115
+ on('head', 'visor', 'box', INK, {
1116
+ size: [0.46, 0.15, 0.04],
1117
+ position: [0, 0.035, front - 0.004],
1118
+ }),
1119
+ ball('head', 'eye', cyan, 0.05, [0.11, 0.035, front + 0.012], {
1120
+ scale: [1, 1.1, 0.4],
1121
+ mirror: true,
1122
+ }),
1123
+ on('head', 'mouth', 'box', INK, {
1124
+ size: [0.18, 0.035, 0.03],
1125
+ position: [0, -0.12, front - 0.006],
1126
+ }),
1127
+ on('head', 'ear', 'cylinder', yellow, {
1128
+ radius: 0.085,
1129
+ height: 0.07,
1130
+ position: [0.3, 0, 0],
1131
+ rotation: [0, 0, 90],
1132
+ segments: 8,
1133
+ mirror: 'x',
1134
+ }),
1135
+ // The antenna stands on one ear, beside the head: the crown stays flat.
1136
+ on('head', 'mast', 'cylinder', INK, {
1137
+ radius: 0.016,
1138
+ height: 0.24,
1139
+ position: [0.33, 0.17, 0],
1140
+ segments: 4,
1141
+ }),
1142
+ ball('head', 'bulb', '#ff4d4d', 0.05, [0.33, 0.3, 0]),
1143
+ );
1144
+ const icon = [
1145
+ shape('M20.5 10V4', 'none'),
1146
+ disc(20.5, 3.4, 1.7, '#ff4d4d'),
1147
+ `<rect x="3.5" y="6.5" width="16" height="14" rx="2.6" fill="${steel}"/>`,
1148
+ `<rect x="5.6" y="9.4" width="11.8" height="5" rx="1.2" fill="${INK}"/>`,
1149
+ `<g fill="${cyan}" stroke="none"><circle cx="9" cy="11.9" r="1.4"/><circle cx="14" cy="11.9" r="1.4"/></g>`,
1150
+ shape('M9 17.6h5', 'none'),
1151
+ ];
1152
+ return { name: 'Bolt', parts, icon };
1153
+ }
1154
+
1155
+ //
1156
+ // 11: Gloop, an alien.
1157
+ //
1158
+
1159
+ function gloop() {
1160
+ const teal = '#14bfae';
1161
+ const deep = '#0b7f86';
1162
+ const berry = '#ff4fa3';
1163
+ // A drop: wide and round below, narrowing to a small rounded crown.
1164
+ const profile = [
1165
+ [0, -0.27],
1166
+ [0.17, -0.24],
1167
+ [0.29, -0.14],
1168
+ [0.33, 0],
1169
+ [0.29, 0.13],
1170
+ [0.2, 0.25],
1171
+ [0.11, 0.335],
1172
+ [0, 0.37],
1173
+ ];
1174
+ const at = onLathe(profile);
1175
+ const parts = limbs({ shoe: berry });
1176
+ parts.push(
1177
+ torso(BODY, deep),
1178
+ mat(
1179
+ { id: 'head', parent: 'torso', kind: 'lathe', position: [0, 0.66, 0], profile, segments: 10 },
1180
+ teal,
1181
+ ),
1182
+ // Three eyes: one over two.
1183
+ patch('eyeTop', at(0, 0.14, 0), { r: 0.07, tall: 1.1, segments: 8, mirror: false }, INK),
1184
+ patch('glintTop', at(0.022, 0.172, 0.022), { r: 0.036, segments: 4, mirror: false }, WHITE),
1185
+ patch('eye', at(0.14, -0.005, 0), { r: 0.066, tall: 1.1, segments: 8 }, INK),
1186
+ patch('glint', at(0.16, 0.025, 0.032), { r: 0.036, segments: 4 }, WHITE),
1187
+ smile(at(0, -0.13, 0.004)),
1188
+ // The stalk grows from the back of the crown and leans back.
1189
+ on('head', 'stalk', 'cylinder', deep, {
1190
+ radius: 0.02,
1191
+ height: 0.2,
1192
+ position: [0, 0.36, -0.2],
1193
+ rotation: [-32, 0, 0],
1194
+ segments: 4,
1195
+ }),
1196
+ ball('head', 'bobble', berry, 0.055, [0, 0.45, -0.255]),
1197
+ patch('spotA', at(0.12, 0.1, -0.004, true), { r: 0.07, segments: 4, mirror: false }, deep),
1198
+ patch('spotB', at(-0.11, -0.05, -0.004, true), { r: 0.05, segments: 4, mirror: false }, deep),
1199
+ patch('spotC', at(-0.05, 0.2, -0.004, true), { r: 0.04, segments: 4, mirror: false }, deep),
1200
+ );
1201
+ const icon = [
1202
+ shape('M13 6l3-3.4', 'none'),
1203
+ disc(16.6, 2.4, 1.6, berry),
1204
+ shape('M12 4.5c5 1.6 8 6.5 8 10.5a8 7 0 0 1-16 0c0-4 3-8.9 8-10.5z', teal),
1205
+ disc(12, 11, 1.8, INK, BARE),
1206
+ dots(15.6, 3.6),
1207
+ ];
1208
+ return { name: 'Gloop', parts, icon };
1209
+ }
1210
+
1211
+ //
1212
+ // 12: Cap, a mushroom.
1213
+ //
1214
+
1215
+ function cap() {
1216
+ const plum = '#a8479a';
1217
+ const cream = '#fff3d6';
1218
+ const stemColor = '#ffdfa6';
1219
+ const moss = '#7d9a3c';
1220
+ // The stem is the face: an egg standing tall under the cap, so the cap's
1221
+ // rim clears the eyes from a camera that looks down on it.
1222
+ const stem = { radius: 0.25, scale: [1, 1.14, 1] };
1223
+ const at = (x, y, lift) => onHead(stem, x, y, lift);
1224
+ const dome = [
1225
+ [0.18, 0.21],
1226
+ [0.32, 0.19],
1227
+ [0.36, 0.25],
1228
+ [0.325, 0.35],
1229
+ [0.24, 0.43],
1230
+ [0.12, 0.48],
1231
+ [0, 0.495],
1232
+ ];
1233
+ const onDome = onLathe(dome);
1234
+ // A few spots of different sizes, none of them placed like another.
1235
+ const spot = (id, x, y, r, back = false) =>
1236
+ patch(id, onDome(x, y, -0.004, back), { r, segments: 5, mirror: false }, cream);
1237
+ const parts = limbs({ shoe: '#7a4a2a', mitt: stemColor });
1238
+ parts.push(
1239
+ torso(BODY, moss),
1240
+ roundHead(stem, 0.6, stemColor, 8),
1241
+ mat({ id: 'cap', parent: 'head', kind: 'lathe', profile: dome, segments: 10 }, plum),
1242
+ spot('spotA', -0.09, 0.355, 0.085),
1243
+ spot('spotB', 0.19, 0.31, 0.048),
1244
+ spot('spotC', 0.05, 0.34, 0.09, true),
1245
+ spot('spotD', -0.21, 0.3, 0.05, true),
1246
+ ...eyes(at, { x: 0.1, y: -0.035, r: 0.072, tall: 1.15 }),
1247
+ smile(at(0, -0.15, 0.004), 0.045),
1248
+ cheeks(at(0.18, -0.115, 0), '#ff8f6b', 0.042),
1249
+ );
1250
+ const icon = [
1251
+ oval(12, 16.5, 5.4, 6, stemColor),
1252
+ shape('M2.6 10.6a9.4 8.4 0 0 1 18.8 0q-9.4 2.6-18.8 0z', plum),
1253
+ `<g fill="${cream}" stroke="none"><circle cx="9.4" cy="6.2" r="2.3"/><circle cx="15.6" cy="7.6" r="1.2"/><circle cx="5.4" cy="9.4" r=".9"/></g>`,
1254
+ dots(16, 2.2, 1.3),
1255
+ shape('M10.4 19.2q1.6 1.3 3.2 0', 'none', ' stroke-width="1"'),
1256
+ ];
1257
+ return { name: 'Cap', parts, icon };
1258
+ }
1259
+
1260
+ //
1261
+ // 13: Toast, a slice of toast.
1262
+ //
1263
+
1264
+ function toast() {
1265
+ const crust = '#a8612a';
1266
+ const crumb = '#fff2c4';
1267
+ const jam = '#b5305e';
1268
+ const slice = [
1269
+ [-0.2, -0.28],
1270
+ [0.2, -0.28],
1271
+ [0.26, -0.22],
1272
+ [0.25, 0.08],
1273
+ [0.3, 0.17],
1274
+ [0.28, 0.26],
1275
+ [0.17, 0.31],
1276
+ [-0.17, 0.31],
1277
+ [-0.28, 0.26],
1278
+ [-0.3, 0.17],
1279
+ [-0.25, 0.08],
1280
+ [-0.26, -0.22],
1281
+ ];
1282
+ const depth = 0.14;
1283
+ const bevel = 0.03;
1284
+ const face = depth / 2 + bevel + 0.012;
1285
+ const at = (x, y, lift) => ({
1286
+ position: [round(x), round(y), round(face + lift)],
1287
+ rotation: [0, 0, 0],
1288
+ });
1289
+ const parts = limbs({ shoe: crust });
1290
+ parts.push(
1291
+ torso(BODY, jam),
1292
+ mat(
1293
+ {
1294
+ id: 'head',
1295
+ parent: 'torso',
1296
+ kind: 'extrude',
1297
+ outline: slice,
1298
+ depth,
1299
+ bevel,
1300
+ flat: false,
1301
+ position: [0, 0.7, 0],
1302
+ },
1303
+ crust,
1304
+ ),
1305
+ // The crumb stands a little proud of the crust on both faces.
1306
+ on('head', 'crumb', 'extrude', crumb, {
1307
+ outline: slice.map(([x, y]) => [round(x * 0.86), round(y * 0.86)]),
1308
+ depth: face * 2,
1309
+ flat: false,
1310
+ }),
1311
+ ...eyes(at, { x: 0.1, y: -0.02, r: 0.07, tall: 1.15 }),
1312
+ smile(at(0, -0.12, 0.004)),
1313
+ cheeks(at(0.17, -0.1, 0), '#ff8f6b'),
1314
+ on('head', 'butter', 'box', '#fff27a', {
1315
+ size: [0.14, 0.13, 0.04],
1316
+ position: [0.1, 0.16, face + 0.012],
1317
+ rotation: [0, 0, 12],
1318
+ }),
1319
+ );
1320
+ const icon = [
1321
+ shape('M5 22V11.5Q2 9.5 4 6t8-3t8 3t-1 5.5V22z', crust),
1322
+ shape('M7.2 19.8V10.6Q5 9 6.6 7t5.4-1.8T17.4 7t-.6 3.6v9.2z', crumb, BARE),
1323
+ `<rect x="12.6" y="7.3" width="4" height="3.3" rx=".6" fill="#ffe24a" stroke-width=".8"/>`,
1324
+ dots(14.4, 2.3, 1.3),
1325
+ ];
1326
+ return { name: 'Toast', parts, icon };
1327
+ }
1328
+
1329
+ //
1330
+ // 14: Scoop, an ice cream.
1331
+ //
1332
+
1333
+ function scoop() {
1334
+ const berry = '#ff93a6';
1335
+ const fudge = '#6a3a1f';
1336
+ const waffle = '#e3a550';
1337
+ const head = { radius: 0.3, scale: [1, 0.97, 1] };
1338
+ const at = (x, y, lift) => onHead(head, x, y, lift);
1339
+ // The sauce: a cap over the top of the scoop, with a rounded drip every quarter
1340
+ // of the way round its edge, the same on both sides.
1341
+ const sauceR = 0.322;
1342
+ const sauceEdge = 34;
1343
+ const sauce = [sauceEdge, 58].map((e) => [
1344
+ round(sauceR * Math.cos(rad(e))),
1345
+ round(sauceR * 0.97 * Math.sin(rad(e))),
1346
+ ]);
1347
+ sauce.push([0, round(sauceR * 0.97)]);
1348
+ const edgeR = 0.3 * Math.cos(rad(sauceEdge));
1349
+ const edgeY = 0.3 * 0.97 * Math.sin(rad(sauceEdge));
1350
+ const drip = (turn, long) =>
1351
+ ball(
1352
+ 'head',
1353
+ `drip${turn}`,
1354
+ fudge,
1355
+ 0.095,
1356
+ [edgeR * Math.sin(rad(turn)), edgeY + 0.04 - long * 0.045, edgeR * Math.cos(rad(turn))],
1357
+ { scale: [0.95, long, 0.5], rotation: [30, turn, 0] },
1358
+ );
1359
+ const onSauce = onLathe(sauce);
1360
+ // A sprinkle lying on the sauce, `turn` degrees round and `tilt` in its plane.
1361
+ const sprinkle = (id, color, x, y, tilt) => {
1362
+ const lie = onSauce(x, y, 0.012);
1363
+ return on('head', id, 'box', color, {
1364
+ size: [0.085, 0.03, 0.03],
1365
+ position: lie.position,
1366
+ rotation: [lie.rotation[0], lie.rotation[1], tilt],
1367
+ });
1368
+ };
1369
+ const parts = limbs({ shoe: fudge });
1370
+ parts.push(
1371
+ // The body is the cone.
1372
+ torso(
1373
+ [
1374
+ [0, -0.08],
1375
+ [0.11, -0.06],
1376
+ [0.215, 0.36],
1377
+ [0.225, 0.41],
1378
+ [0, 0.41],
1379
+ ],
1380
+ waffle,
1381
+ ),
1382
+ roundHead(head, 0.71, berry, 9),
1383
+ // The scoop's foot, pressed out over the cone's rim.
1384
+ on('head', 'foot', 'cylinder', berry, {
1385
+ radius: 0.27,
1386
+ radiusTop: 0.24,
1387
+ height: 0.07,
1388
+ position: [0, -0.265, 0],
1389
+ segments: 8,
1390
+ }),
1391
+ mat({ id: 'sauce', parent: 'head', kind: 'lathe', profile: sauce, segments: 10 }, fudge),
1392
+ drip(45, 1.25),
1393
+ drip(135, 1.05),
1394
+ drip(225, 1.05),
1395
+ drip(315, 1.25),
1396
+ sprinkle('sprinkleA', '#fff27a', -0.09, 0.262, 35),
1397
+ sprinkle('sprinkleB', '#7ae0ff', 0.1, 0.25, -50),
1398
+ ...eyes(at, { x: 0.11, y: -0.03, r: 0.07, tall: 1.15 }),
1399
+ smile(at(0, -0.135, 0.004)),
1400
+ );
1401
+ const icon = [
1402
+ shape('M7 15.5h10l-5 7.5z', waffle),
1403
+ disc(12, 10.5, 7.5, berry),
1404
+ shape(
1405
+ 'M4.6 9.4a7.5 7.5 0 0 1 14.8 0q-.2 1.5-1.3 1.5t-1.2-1.4q-.1 2.6-1.3 2.6t-1.2-2.6q-.1 1.4-1.2 1.4t-1.2-1.4q-.1 2.6-1.3 2.6T8.3 9.5q-.1 1.4-1.2 1.4T4.6 9.4z',
1406
+ fudge,
1407
+ ),
1408
+ shape('M9 6.3l2.2-1.2', 'none', ' stroke="#fff27a" stroke-width="1.2"'),
1409
+ shape('M13.2 5.2l1.6 1.8', 'none', ' stroke="#7ae0ff" stroke-width="1.2"'),
1410
+ dots(13.6, 2.4, 1.2),
1411
+ ];
1412
+ return { name: 'Scoop', parts, icon };
1413
+ }
1414
+
1415
+ //
1416
+ // 15: Zest, an orange.
1417
+ //
1418
+
1419
+ function zest() {
1420
+ const orange = '#ff8a14';
1421
+ const leaf = '#4fc04a';
1422
+ const head = { radius: 0.31, scale: [1.06, 0.94, 1.04] };
1423
+ const at = (x, y, lift) => onHead(head, x, y, lift);
1424
+ const parts = limbs({ shoe: orange });
1425
+ parts.push(
1426
+ torso(BODY, '#2f9e55'),
1427
+ roundHead(head, 0.68, orange, 12),
1428
+ ...eyes(at, { x: 0.12, y: 0.03, r: 0.075, tall: 1.15 }),
1429
+ smile(at(0, -0.085, 0.004), 0.06, 0.017),
1430
+ cheeks(at(0.215, -0.07, 0), '#ff5a3c'),
1431
+ // A short stem at the back of the crown, and a leaf lying off to one side.
1432
+ on('head', 'stem', 'cylinder', '#6b3d20', {
1433
+ radius: 0.03,
1434
+ height: 0.09,
1435
+ position: [0, 0.3, -0.07],
1436
+ segments: 5,
1437
+ }),
1438
+ on('head', 'leaf', 'extrude', leaf, {
1439
+ outline: [
1440
+ [0, 0],
1441
+ [0.09, 0.1],
1442
+ [0.06, 0.21],
1443
+ [0, 0.27],
1444
+ [-0.06, 0.21],
1445
+ [-0.09, 0.1],
1446
+ ],
1447
+ depth: 0.035,
1448
+ flat: false,
1449
+ position: [0.02, 0.265, -0.08],
1450
+ rotation: [-65, 0, -75],
1451
+ }),
1452
+ );
1453
+ const icon = [
1454
+ disc(12, 14, 8.5, orange),
1455
+ shape('M12 5.8q3.5-6 8.5-3.2q-3 5.4-8.5 3.2z', leaf),
1456
+ dots(13.2),
1457
+ shape('M9.2 16.4q2.8 2.4 5.6 0', 'none'),
1458
+ ];
1459
+ return { name: 'Zest', parts, icon };
576
1460
  }
577
1461
 
578
1462
  //
@@ -617,5 +1501,38 @@ function write(index, { name, look = LOOK, parts }) {
617
1501
  fs.writeFileSync(path.join(OUT_DIR, `avatar-${index}.pxmodel`), lines.join('\n'));
618
1502
  }
619
1503
 
1504
+ // `code/client/avatarFaces.js`: per avatar index, its name and its face.
1505
+ function writeFaces(characters) {
1506
+ const lines = [
1507
+ '// Generated by scripts/gen-avatars.mjs; do not edit. Each avatar index: the',
1508
+ "// character's name, and its face for the picker (`chrome.js`), the inside of a",
1509
+ '// 24 x 24 SVG.',
1510
+ 'export const AVATAR_FACES = [',
1511
+ ...characters.map(({ name, icon }) => ` ['${name}', '${icon.join('')}'],`),
1512
+ '];',
1513
+ '',
1514
+ ];
1515
+ fs.writeFileSync(FACES_FILE, lines.join('\n'));
1516
+ }
1517
+
620
1518
  fs.mkdirSync(OUT_DIR, { recursive: true });
621
- [mascot, petal, beat, star].forEach((make, index) => write(index, make()));
1519
+ const characters = [
1520
+ mascot,
1521
+ petal,
1522
+ beat,
1523
+ star,
1524
+ biscuit,
1525
+ mochi,
1526
+ hop,
1527
+ pip,
1528
+ ribbit,
1529
+ ember,
1530
+ bolt,
1531
+ gloop,
1532
+ cap,
1533
+ toast,
1534
+ scoop,
1535
+ zest,
1536
+ ].map((make) => make());
1537
+ characters.forEach((character, index) => write(index, character));
1538
+ writeFaces(characters);