@kuncat/avoidant 0.2.3 → 0.3.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.
Files changed (325) hide show
  1. package/README.md +29 -18
  2. package/dist/components/AvoidantGame.svelte +743 -458
  3. package/dist/components/AvoidantGame.svelte.d.ts +2 -1
  4. package/dist/components/GameHistory.svelte +103 -0
  5. package/dist/components/GameHistory.svelte.d.ts +8 -0
  6. package/dist/components/MapControls.svelte +1 -1
  7. package/dist/components/MapIcon.svelte +40 -0
  8. package/dist/components/MapIcon.svelte.d.ts +7 -0
  9. package/dist/components/MatchResults.svelte +29 -0
  10. package/dist/components/MatchResults.svelte.d.ts +8 -0
  11. package/dist/components/MultiplayerGame.svelte +504 -0
  12. package/dist/components/MultiplayerGame.svelte.d.ts +11 -0
  13. package/dist/components/OptionHelp.svelte +96 -0
  14. package/dist/components/OptionHelp.svelte.d.ts +7 -0
  15. package/dist/components/ScoreSummary.svelte +43 -0
  16. package/dist/components/ScoreSummary.svelte.d.ts +8 -0
  17. package/dist/components/board.svelte +61 -39
  18. package/dist/components/board.svelte.d.ts +4 -2
  19. package/dist/components/fragment.glsl +34 -0
  20. package/dist/components/label-connectors.d.ts +5 -2
  21. package/dist/components/label-connectors.js +47 -37
  22. package/dist/components/map-camera.js +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/multiplayer/client.d.ts +21 -0
  25. package/dist/multiplayer/client.js +111 -0
  26. package/dist/multiplayer/duration.d.ts +1 -0
  27. package/dist/multiplayer/duration.js +6 -0
  28. package/dist/multiplayer/local-identity.d.ts +1 -0
  29. package/dist/multiplayer/local-identity.js +13 -0
  30. package/dist/multiplayer/maps.json +275 -0
  31. package/dist/multiplayer/reveal.d.ts +11 -0
  32. package/dist/multiplayer/reveal.js +16 -0
  33. package/dist/multiplayer/types.d.ts +80 -0
  34. package/dist/multiplayer/types.js +10 -0
  35. package/dist/paraglide/messages/_index.d.ts +111 -8
  36. package/dist/paraglide/messages/_index.js +111 -8
  37. package/dist/paraglide/messages/action_back.js +2 -2
  38. package/dist/paraglide/messages/action_copied.d.ts +16 -0
  39. package/dist/paraglide/messages/action_copied.js +29 -0
  40. package/dist/paraglide/messages/action_copy.js +2 -2
  41. package/dist/paraglide/messages/action_copy_invitation.d.ts +16 -0
  42. package/dist/paraglide/messages/action_copy_invitation.js +29 -0
  43. package/dist/paraglide/messages/action_download_replay.d.ts +16 -0
  44. package/dist/paraglide/messages/action_download_replay.js +29 -0
  45. package/dist/paraglide/messages/action_exit.js +2 -2
  46. package/dist/paraglide/messages/action_game_history.d.ts +16 -0
  47. package/dist/paraglide/messages/action_game_history.js +29 -0
  48. package/dist/paraglide/messages/action_invite.js +2 -2
  49. package/dist/paraglide/messages/action_join.js +2 -2
  50. package/dist/paraglide/messages/action_join_game.js +2 -2
  51. package/dist/paraglide/messages/action_load_more.d.ts +16 -0
  52. package/dist/paraglide/messages/action_load_more.js +29 -0
  53. package/dist/paraglide/messages/action_login.d.ts +16 -0
  54. package/dist/paraglide/messages/action_login.js +29 -0
  55. package/dist/paraglide/messages/action_login_again.d.ts +16 -0
  56. package/dist/paraglide/messages/action_login_again.js +29 -0
  57. package/dist/paraglide/messages/action_logout.d.ts +16 -0
  58. package/dist/paraglide/messages/action_logout.js +29 -0
  59. package/dist/paraglide/messages/action_new_game.js +2 -2
  60. package/dist/paraglide/messages/action_pass.d.ts +16 -0
  61. package/dist/paraglide/messages/action_pass.js +29 -0
  62. package/dist/paraglide/messages/action_random.js +2 -2
  63. package/dist/paraglide/messages/action_reconnect.d.ts +16 -0
  64. package/dist/paraglide/messages/action_reconnect.js +29 -0
  65. package/dist/paraglide/messages/action_register.d.ts +16 -0
  66. package/dist/paraglide/messages/action_register.js +29 -0
  67. package/dist/paraglide/messages/action_save_name.d.ts +16 -0
  68. package/dist/paraglide/messages/action_save_name.js +29 -0
  69. package/dist/paraglide/messages/action_start.js +2 -2
  70. package/dist/paraglide/messages/action_start_match.d.ts +16 -0
  71. package/dist/paraglide/messages/action_start_match.js +29 -0
  72. package/dist/paraglide/messages/aria_close_invitation.js +2 -2
  73. package/dist/paraglide/messages/aria_score_summary.js +2 -2
  74. package/dist/paraglide/messages/cells_count.js +2 -2
  75. package/dist/paraglide/messages/cells_per_face.js +2 -2
  76. package/dist/paraglide/messages/default_player_name.js +2 -2
  77. package/dist/paraglide/messages/error_connection_failed.d.ts +16 -0
  78. package/dist/paraglide/messages/error_connection_failed.js +29 -0
  79. package/dist/paraglide/messages/error_connection_interrupted.d.ts +16 -0
  80. package/dist/paraglide/messages/error_connection_interrupted.js +29 -0
  81. package/dist/paraglide/messages/error_history.d.ts +16 -0
  82. package/dist/paraglide/messages/error_history.js +29 -0
  83. package/dist/paraglide/messages/error_invitation_invalid.d.ts +16 -0
  84. package/dist/paraglide/messages/error_invitation_invalid.js +29 -0
  85. package/dist/paraglide/messages/error_join_connect_failed.js +2 -2
  86. package/dist/paraglide/messages/error_join_failed.js +2 -2
  87. package/dist/paraglide/messages/error_join_ticket_invalid.js +2 -2
  88. package/dist/paraglide/messages/error_join_ticket_required.js +2 -2
  89. package/dist/paraglide/messages/error_login_to_join.d.ts +16 -0
  90. package/dist/paraglide/messages/error_login_to_join.js +29 -0
  91. package/dist/paraglide/messages/error_map_version.d.ts +16 -0
  92. package/dist/paraglide/messages/error_map_version.js +29 -0
  93. package/dist/paraglide/messages/error_match_join.d.ts +16 -0
  94. package/dist/paraglide/messages/error_match_join.js +29 -0
  95. package/dist/paraglide/messages/error_match_version.d.ts +16 -0
  96. package/dist/paraglide/messages/error_match_version.js +29 -0
  97. package/dist/paraglide/messages/error_name_not_saved.d.ts +16 -0
  98. package/dist/paraglide/messages/error_name_not_saved.js +29 -0
  99. package/dist/paraglide/messages/error_name_server_update.d.ts +16 -0
  100. package/dist/paraglide/messages/error_name_server_update.js +29 -0
  101. package/dist/paraglide/messages/error_player_name.d.ts +16 -0
  102. package/dist/paraglide/messages/error_player_name.js +29 -0
  103. package/dist/paraglide/messages/error_reconnect_to_play.d.ts +16 -0
  104. package/dist/paraglide/messages/error_reconnect_to_play.js +29 -0
  105. package/dist/paraglide/messages/error_replay.d.ts +16 -0
  106. package/dist/paraglide/messages/error_replay.js +29 -0
  107. package/dist/paraglide/messages/error_unsupported_map.d.ts +16 -0
  108. package/dist/paraglide/messages/error_unsupported_map.js +29 -0
  109. package/dist/paraglide/messages/faces_count.js +2 -2
  110. package/dist/paraglide/messages/field_bordering.d.ts +16 -0
  111. package/dist/paraglide/messages/field_bordering.js +29 -0
  112. package/dist/paraglide/messages/field_cell_density.js +2 -2
  113. package/dist/paraglide/messages/field_duration_unit.d.ts +16 -0
  114. package/dist/paraglide/messages/field_duration_unit.js +29 -0
  115. package/dist/paraglide/messages/field_finite_flood.d.ts +16 -0
  116. package/dist/paraglide/messages/field_finite_flood.js +29 -0
  117. package/dist/paraglide/messages/field_flood_cells.d.ts +16 -0
  118. package/dist/paraglide/messages/field_flood_cells.js +29 -0
  119. package/dist/paraglide/messages/field_flood_limit.d.ts +16 -0
  120. package/dist/paraglide/messages/field_flood_limit.js +29 -0
  121. package/dist/paraglide/messages/field_infinite_flood.d.ts +16 -0
  122. package/dist/paraglide/messages/field_infinite_flood.js +29 -0
  123. package/dist/paraglide/messages/field_invitation_link.d.ts +16 -0
  124. package/dist/paraglide/messages/field_invitation_link.js +29 -0
  125. package/dist/paraglide/messages/field_invitation_url.js +2 -2
  126. package/dist/paraglide/messages/field_language.d.ts +16 -0
  127. package/dist/paraglide/messages/field_language.js +29 -0
  128. package/dist/paraglide/messages/field_map.d.ts +16 -0
  129. package/dist/paraglide/messages/field_map.js +29 -0
  130. package/dist/paraglide/messages/field_map_shape.js +2 -2
  131. package/dist/paraglide/messages/field_map_size.d.ts +1 -1
  132. package/dist/paraglide/messages/field_map_size.js +5 -5
  133. package/dist/paraglide/messages/field_match_duration.d.ts +16 -0
  134. package/dist/paraglide/messages/field_match_duration.js +29 -0
  135. package/dist/paraglide/messages/field_match_minutes.d.ts +16 -0
  136. package/dist/paraglide/messages/field_match_minutes.js +29 -0
  137. package/dist/paraglide/messages/field_play_mode.d.ts +16 -0
  138. package/dist/paraglide/messages/field_play_mode.js +29 -0
  139. package/dist/paraglide/messages/field_player_name.js +2 -2
  140. package/dist/paraglide/messages/field_radius.js +2 -2
  141. package/dist/paraglide/messages/field_radius_x.js +2 -2
  142. package/dist/paraglide/messages/field_radius_y.js +2 -2
  143. package/dist/paraglide/messages/field_radius_z.js +2 -2
  144. package/dist/paraglide/messages/field_relay_servers.js +2 -2
  145. package/dist/paraglide/messages/field_seed.js +2 -2
  146. package/dist/paraglide/messages/field_size.d.ts +1 -1
  147. package/dist/paraglide/messages/field_size.js +5 -5
  148. package/dist/paraglide/messages/field_spikiness.js +2 -2
  149. package/dist/paraglide/messages/field_subdivisions.js +2 -2
  150. package/dist/paraglide/messages/field_surface_detail.js +2 -2
  151. package/dist/paraglide/messages/field_ticket_or_invitation_url.js +2 -2
  152. package/dist/paraglide/messages/field_turn_based.d.ts +16 -0
  153. package/dist/paraglide/messages/field_turn_based.js +29 -0
  154. package/dist/paraglide/messages/field_turn_duration.d.ts +16 -0
  155. package/dist/paraglide/messages/field_turn_duration.js +29 -0
  156. package/dist/paraglide/messages/field_turn_duration_unit.d.ts +16 -0
  157. package/dist/paraglide/messages/field_turn_duration_unit.js +29 -0
  158. package/dist/paraglide/messages/field_turn_timer.d.ts +16 -0
  159. package/dist/paraglide/messages/field_turn_timer.js +29 -0
  160. package/dist/paraglide/messages/field_tutorial_mode.js +2 -2
  161. package/dist/paraglide/messages/field_void_fraction.js +2 -2
  162. package/dist/paraglide/messages/help_bordering.d.ts +16 -0
  163. package/dist/paraglide/messages/help_bordering.js +29 -0
  164. package/dist/paraglide/messages/help_flood_limit.d.ts +16 -0
  165. package/dist/paraglide/messages/help_flood_limit.js +29 -0
  166. package/dist/paraglide/messages/help_map.d.ts +16 -0
  167. package/dist/paraglide/messages/help_map.js +29 -0
  168. package/dist/paraglide/messages/help_map_size.d.ts +16 -0
  169. package/dist/paraglide/messages/help_map_size.js +29 -0
  170. package/dist/paraglide/messages/help_match_duration.d.ts +16 -0
  171. package/dist/paraglide/messages/help_match_duration.js +29 -0
  172. package/dist/paraglide/messages/help_participation_time.d.ts +16 -0
  173. package/dist/paraglide/messages/help_participation_time.js +29 -0
  174. package/dist/paraglide/messages/help_play_mode.d.ts +16 -0
  175. package/dist/paraglide/messages/help_play_mode.js +29 -0
  176. package/dist/paraglide/messages/help_player_name.d.ts +16 -0
  177. package/dist/paraglide/messages/help_player_name.js +29 -0
  178. package/dist/paraglide/messages/help_seed.d.ts +16 -0
  179. package/dist/paraglide/messages/help_seed.js +29 -0
  180. package/dist/paraglide/messages/help_size.d.ts +16 -0
  181. package/dist/paraglide/messages/help_size.js +29 -0
  182. package/dist/paraglide/messages/help_spikiness.d.ts +16 -0
  183. package/dist/paraglide/messages/help_spikiness.js +29 -0
  184. package/dist/paraglide/messages/help_turn_based.d.ts +16 -0
  185. package/dist/paraglide/messages/help_turn_based.js +29 -0
  186. package/dist/paraglide/messages/help_turn_duration.d.ts +16 -0
  187. package/dist/paraglide/messages/help_turn_duration.js +29 -0
  188. package/dist/paraglide/messages/help_turn_time.d.ts +16 -0
  189. package/dist/paraglide/messages/help_turn_time.js +29 -0
  190. package/dist/paraglide/messages/help_turn_timer.d.ts +16 -0
  191. package/dist/paraglide/messages/help_turn_timer.js +29 -0
  192. package/dist/paraglide/messages/help_tutorial_mode.d.ts +16 -0
  193. package/dist/paraglide/messages/help_tutorial_mode.js +29 -0
  194. package/dist/paraglide/messages/help_void_fraction.d.ts +16 -0
  195. package/dist/paraglide/messages/help_void_fraction.js +29 -0
  196. package/dist/paraglide/messages/history_empty.d.ts +16 -0
  197. package/dist/paraglide/messages/history_empty.js +29 -0
  198. package/dist/paraglide/messages/label_advanced_settings.js +2 -2
  199. package/dist/paraglide/messages/label_claims.d.ts +18 -0
  200. package/dist/paraglide/messages/label_claims.js +29 -0
  201. package/dist/paraglide/messages/label_cumulative_time.d.ts +16 -0
  202. package/dist/paraglide/messages/label_cumulative_time.js +29 -0
  203. package/dist/paraglide/messages/label_custom_map_options.d.ts +16 -0
  204. package/dist/paraglide/messages/label_custom_map_options.js +29 -0
  205. package/dist/paraglide/messages/label_gameplay_options.d.ts +16 -0
  206. package/dist/paraglide/messages/label_gameplay_options.js +29 -0
  207. package/dist/paraglide/messages/label_map_options.d.ts +16 -0
  208. package/dist/paraglide/messages/label_map_options.js +29 -0
  209. package/dist/paraglide/messages/label_match_ends.d.ts +18 -0
  210. package/dist/paraglide/messages/label_match_ends.js +29 -0
  211. package/dist/paraglide/messages/label_match_id.d.ts +18 -0
  212. package/dist/paraglide/messages/label_match_id.js +29 -0
  213. package/dist/paraglide/messages/label_player_number.d.ts +18 -0
  214. package/dist/paraglide/messages/label_player_number.js +29 -0
  215. package/dist/paraglide/messages/label_players.js +2 -2
  216. package/dist/paraglide/messages/label_points.d.ts +18 -0
  217. package/dist/paraglide/messages/label_points.js +29 -0
  218. package/dist/paraglide/messages/label_revealed_count.d.ts +18 -0
  219. package/dist/paraglide/messages/label_revealed_count.js +29 -0
  220. package/dist/paraglide/messages/label_safe_cells_explored.js +2 -2
  221. package/dist/paraglide/messages/label_safe_cells_remaining.js +2 -2
  222. package/dist/paraglide/messages/label_score.js +2 -2
  223. package/dist/paraglide/messages/label_streak.js +2 -2
  224. package/dist/paraglide/messages/label_team_score.d.ts +18 -0
  225. package/dist/paraglide/messages/label_team_score.js +29 -0
  226. package/dist/paraglide/messages/label_turn_remaining.d.ts +18 -0
  227. package/dist/paraglide/messages/label_turn_remaining.js +29 -0
  228. package/dist/paraglide/messages/label_voids_discovered.js +2 -2
  229. package/dist/paraglide/messages/label_you.d.ts +16 -0
  230. package/dist/paraglide/messages/label_you.js +29 -0
  231. package/dist/paraglide/messages/mode_collaborative.d.ts +16 -0
  232. package/dist/paraglide/messages/mode_collaborative.js +29 -0
  233. package/dist/paraglide/messages/mode_collaborative_hint.d.ts +16 -0
  234. package/dist/paraglide/messages/mode_collaborative_hint.js +29 -0
  235. package/dist/paraglide/messages/mode_solo.d.ts +16 -0
  236. package/dist/paraglide/messages/mode_solo.js +29 -0
  237. package/dist/paraglide/messages/mode_solo_hint.d.ts +16 -0
  238. package/dist/paraglide/messages/mode_solo_hint.js +29 -0
  239. package/dist/paraglide/messages/mode_territory.d.ts +16 -0
  240. package/dist/paraglide/messages/mode_territory.js +29 -0
  241. package/dist/paraglide/messages/mode_territory_hint.d.ts +16 -0
  242. package/dist/paraglide/messages/mode_territory_hint.js +29 -0
  243. package/dist/paraglide/messages/multiplayer_title.d.ts +16 -0
  244. package/dist/paraglide/messages/multiplayer_title.js +29 -0
  245. package/dist/paraglide/messages/option_help.d.ts +18 -0
  246. package/dist/paraglide/messages/option_help.js +29 -0
  247. package/dist/paraglide/messages/package.json +4 -0
  248. package/dist/paraglide/messages/preset_custom.js +2 -2
  249. package/dist/paraglide/messages/preset_large.js +2 -2
  250. package/dist/paraglide/messages/preset_medium.js +2 -2
  251. package/dist/paraglide/messages/preset_small.js +2 -2
  252. package/dist/paraglide/messages/shape_label.d.ts +5 -5
  253. package/dist/paraglide/messages/shape_label.js +17 -17
  254. package/dist/paraglide/messages/status_connecting.d.ts +16 -0
  255. package/dist/paraglide/messages/status_connecting.js +29 -0
  256. package/dist/paraglide/messages/status_draw.d.ts +16 -0
  257. package/dist/paraglide/messages/status_draw.js +29 -0
  258. package/dist/paraglide/messages/status_generating_map.js +2 -2
  259. package/dist/paraglide/messages/status_initialization_failed.js +2 -2
  260. package/dist/paraglide/messages/status_joining_game.js +2 -2
  261. package/dist/paraglide/messages/status_loading.js +2 -2
  262. package/dist/paraglide/messages/status_match_complete.d.ts +16 -0
  263. package/dist/paraglide/messages/status_match_complete.js +29 -0
  264. package/dist/paraglide/messages/status_match_expired.d.ts +16 -0
  265. package/dist/paraglide/messages/status_match_expired.js +29 -0
  266. package/dist/paraglide/messages/status_name_saved.d.ts +16 -0
  267. package/dist/paraglide/messages/status_name_saved.js +29 -0
  268. package/dist/paraglide/messages/status_named_turn.d.ts +18 -0
  269. package/dist/paraglide/messages/status_named_turn.js +29 -0
  270. package/dist/paraglide/messages/status_named_winner.d.ts +18 -0
  271. package/dist/paraglide/messages/status_named_winner.js +29 -0
  272. package/dist/paraglide/messages/status_player_turn.d.ts +18 -0
  273. package/dist/paraglide/messages/status_player_turn.js +29 -0
  274. package/dist/paraglide/messages/status_preparing.js +2 -2
  275. package/dist/paraglide/messages/status_realtime_claims.d.ts +16 -0
  276. package/dist/paraglide/messages/status_realtime_claims.js +29 -0
  277. package/dist/paraglide/messages/status_reconnecting.d.ts +16 -0
  278. package/dist/paraglide/messages/status_reconnecting.js +29 -0
  279. package/dist/paraglide/messages/status_session_complete.d.ts +16 -0
  280. package/dist/paraglide/messages/status_session_complete.js +29 -0
  281. package/dist/paraglide/messages/status_winner.d.ts +18 -0
  282. package/dist/paraglide/messages/status_winner.js +29 -0
  283. package/dist/paraglide/messages/text_account_multiplayer.d.ts +16 -0
  284. package/dist/paraglide/messages/text_account_multiplayer.js +29 -0
  285. package/dist/paraglide/messages/text_avoided.js +2 -2
  286. package/dist/paraglide/messages/text_density_summary.js +2 -2
  287. package/dist/paraglide/messages/text_invite_after_opening.js +2 -2
  288. package/dist/paraglide/messages/text_multiplayer_login.d.ts +16 -0
  289. package/dist/paraglide/messages/text_multiplayer_login.js +29 -0
  290. package/dist/paraglide/messages/text_relay_servers_hint.js +2 -2
  291. package/dist/paraglide/messages/text_waiting_lobby.d.ts +16 -0
  292. package/dist/paraglide/messages/text_waiting_lobby.js +29 -0
  293. package/dist/paraglide/messages/tutorial_action_dismiss.js +2 -2
  294. package/dist/paraglide/messages/tutorial_action_next.js +2 -2
  295. package/dist/paraglide/messages/tutorial_after_safe_deducible.js +2 -2
  296. package/dist/paraglide/messages/tutorial_after_safe_guess.js +2 -2
  297. package/dist/paraglide/messages/tutorial_after_void.js +2 -2
  298. package/dist/paraglide/messages/tutorial_awaiting_first_click.js +2 -2
  299. package/dist/paraglide/messages/tutorial_intro.d.ts +1 -1
  300. package/dist/paraglide/messages/tutorial_intro.js +5 -5
  301. package/dist/paraglide/messages/tutorial_won.js +2 -2
  302. package/dist/paraglide/messages/unit_hours.d.ts +16 -0
  303. package/dist/paraglide/messages/unit_hours.js +29 -0
  304. package/dist/paraglide/messages/unit_hours_selected.d.ts +19 -0
  305. package/dist/paraglide/messages/unit_hours_selected.js +35 -0
  306. package/dist/paraglide/messages/unit_minutes.d.ts +16 -0
  307. package/dist/paraglide/messages/unit_minutes.js +29 -0
  308. package/dist/paraglide/messages/unit_minutes_selected.d.ts +19 -0
  309. package/dist/paraglide/messages/unit_minutes_selected.js +35 -0
  310. package/dist/paraglide/messages/unit_seconds.d.ts +16 -0
  311. package/dist/paraglide/messages/unit_seconds.js +29 -0
  312. package/dist/paraglide/messages/unit_seconds_selected.d.ts +19 -0
  313. package/dist/paraglide/messages/unit_seconds_selected.js +35 -0
  314. package/dist/paraglide/registry.d.ts +13 -0
  315. package/dist/paraglide/registry.js +15 -0
  316. package/dist/paraglide/runtime.d.ts +90 -26
  317. package/dist/paraglide/runtime.js +597 -109
  318. package/dist/paraglide/server.d.ts +1 -1
  319. package/dist/paraglide/server.js +27 -10
  320. package/dist/styles/global.css +12 -51
  321. package/dist/wasm/avoidant_wasm.d.ts +56 -11
  322. package/dist/wasm/avoidant_wasm.js +188 -52
  323. package/dist/wasm/avoidant_wasm_bg.wasm +0 -0
  324. package/dist/wasm/avoidant_wasm_bg.wasm.d.ts +25 -11
  325. package/package.json +34 -32
@@ -49,12 +49,13 @@
49
49
  </script>
50
50
 
51
51
  <script lang="ts">
52
- import { labelSurfacePoints } from "./label-connectors";
52
+ import { cellLabelPlacements } from "./label-connectors";
53
53
  import IdleBillboard from "./IdleBillboard.svelte";
54
54
  import { TerrainDepthSort } from "./terrain-depth-sort";
55
55
  import { SvelteMap, SvelteSet } from "svelte/reactivity";
56
56
  import { Pulse } from "../wasm/avoidant_wasm";
57
- import type { GameState } from "../wasm/avoidant_wasm";
57
+ import type { BoardState } from "../multiplayer/types";
58
+ import { PLAYER_COLORS } from "../multiplayer/types";
58
59
  import { T, useTask, useThrelte } from "@threlte/core";
59
60
  import { interactivity, Text } from "@threlte/extras";
60
61
  import {
@@ -77,7 +78,9 @@
77
78
  const { invalidate } = useThrelte();
78
79
 
79
80
  interface Props {
80
- gameState: GameState;
81
+ gameState: BoardState;
82
+ owners?: (number | null)[];
83
+ showZeroCounts?: boolean;
81
84
  terrain?:
82
85
  | { positions: number[]; normals: number[]; cellIndices: number[]; heights: number[] }
83
86
  | undefined;
@@ -96,6 +99,8 @@
96
99
  interactive = true,
97
100
  highlightedCellIndex = undefined,
98
101
  onCellClicked = undefined,
102
+ owners = [],
103
+ showZeroCounts = false,
99
104
  }: Props = $props();
100
105
  let cells = $derived(gameState?.cells);
101
106
  let cellMetadata = $derived(gameState?.cellMetadata);
@@ -395,6 +400,43 @@
395
400
  };
396
401
  });
397
402
 
403
+ const ownershipTexture = $derived.by(() => {
404
+ const texture = new DataTexture(
405
+ new Uint8Array(cellMeta.width * 4),
406
+ cellMeta.width,
407
+ 1,
408
+ RGBAFormat,
409
+ UnsignedByteType,
410
+ );
411
+ texture.minFilter = NearestFilter;
412
+ texture.magFilter = NearestFilter;
413
+ return texture;
414
+ });
415
+ $effect(() => {
416
+ const texture = ownershipTexture;
417
+ const data = texture.image.data as Uint8Array;
418
+ data.fill(0);
419
+ owners.forEach((owner, index) => {
420
+ if (owner === null || index >= $cells.length) return;
421
+ const color = new Color(PLAYER_COLORS[owner]);
422
+ data.set(
423
+ [
424
+ Math.round(color.r * 255),
425
+ Math.round(color.g * 255),
426
+ Math.round(color.b * 255),
427
+ owner + 1,
428
+ ],
429
+ index * 4,
430
+ );
431
+ });
432
+ texture.needsUpdate = true;
433
+ invalidate();
434
+ });
435
+ $effect(() => {
436
+ const texture = ownershipTexture;
437
+ return () => texture.dispose();
438
+ });
439
+
398
440
  let terrainMaterial = $derived(
399
441
  new ShaderMaterial({
400
442
  vertexShader,
@@ -409,6 +451,7 @@
409
451
  elevationMin: { value: gameState.elevationMin },
410
452
  elevationMax: { value: gameState.elevationMax },
411
453
  uCellMeta: { value: cellMeta.texture },
454
+ uOwnership: { value: ownershipTexture },
412
455
  uCellMetaSize: { value: cellMeta.width },
413
456
  pulseCount: { value: 0 },
414
457
  pulseTimers: { value: new Array(MAX_PULSES).fill(0) },
@@ -462,41 +505,14 @@
462
505
  });
463
506
 
464
507
  const LABEL_LIFT_FACTOR = 0.4;
465
- /// Maximum per-vertex elevation displacement (raw scalar from the noise field) seen inside each cell, used to lift labels above the noisiest part of the terrain.
466
- const terrainCellMaxHeights = $derived.by(() => {
467
- const result: number[] = new Array($cells.length).fill(0);
468
- if (!terrain) return result;
469
- const heights = terrain.heights;
470
- const cellIndices = terrain.cellIndices;
471
- for (let i = 0; i < cellIndices.length; i++) {
472
- const ci = cellIndices[i];
473
- const h = heights[i];
474
- if (h > result[ci]) result[ci] = h;
475
- }
476
- return result;
477
- });
478
- const cellLabelAnchors = $derived(
479
- $cells.map((cell, idx) => {
480
- const [cxv, cyv, czv] = cell.centroid;
481
- const [nx, ny, nz] = cell.normal;
482
- const lift = (terrainCellMaxHeights[idx] ?? 0) + cellRadius * LABEL_LIFT_FACTOR;
483
- return {
484
- x: cxv + nx * lift,
485
- y: cyv + ny * lift,
486
- z: czv + nz * lift,
487
- };
488
- }),
489
- );
490
-
491
- // Intersect the elevated, inset terrain rather than extending to the base
492
- // centroid below it. Compute these once per map, not on every cell reveal.
493
- const cellLabelSurfacePoints = $derived(
494
- labelSurfacePoints(
508
+ const labelPlacements = $derived(
509
+ cellLabelPlacements(
495
510
  terrainGeometry,
496
- cellLabelAnchors.map((anchor) => new Vector3(anchor.x, anchor.y, anchor.z)),
497
- $cells.map((cell) => new Vector3(...cell.centroid)),
511
+ $cells.map((cell) => new Vector3(...cell.normal)),
512
+ cellRadius * LABEL_LIFT_FACTOR,
498
513
  ),
499
514
  );
515
+ const cellLabelAnchors = $derived(labelPlacements.map((placement) => placement?.anchor));
500
516
 
501
517
  // Keep connectors in world space: only the text should turn to face the camera.
502
518
  // Batch all visible labels into one draw call, with depth testing so lines on
@@ -507,8 +523,14 @@
507
523
  for (let i = 0; i < $cellMetadata.length; i++) {
508
524
  const entry = $cellMetadata[i];
509
525
  const anchor = cellLabelAnchors[i];
510
- const surface = cellLabelSurfacePoints[i];
511
- if (!entry.isExplored || entry.isVoid || entry.voidNeighborCount <= 0 || !anchor || !surface)
526
+ const surface = labelPlacements[i]?.surface;
527
+ if (
528
+ !entry.isExplored ||
529
+ entry.isVoid ||
530
+ (!showZeroCounts && entry.voidNeighborCount <= 0) ||
531
+ !anchor ||
532
+ !surface
533
+ )
512
534
  continue;
513
535
  points.push(surface, new Vector3(anchor.x, anchor.y, anchor.z));
514
536
  const color = new Color(
@@ -526,7 +548,7 @@
526
548
  });
527
549
 
528
550
  const LABEL_COLORS = [
529
- undefined,
551
+ "#0f172a",
530
552
  "#1d4ed8",
531
553
  "#15803d",
532
554
  "#b91c1c",
@@ -633,7 +655,7 @@
633
655
  </T.LineSegments>
634
656
 
635
657
  {#each $cellMetadata as entry, i (i)}
636
- {#if entry.isExplored && !entry.isVoid && entry.voidNeighborCount > 0}
658
+ {#if entry.isExplored && !entry.isVoid && (showZeroCounts || entry.voidNeighborCount > 0)}
637
659
  {@const anchor = cellLabelAnchors[i]}
638
660
  {#if anchor}
639
661
  <IdleBillboard position={[anchor.x, anchor.y, anchor.z]}>
@@ -18,9 +18,11 @@ export declare const CellMetaChannel: {
18
18
  export declare const cellMetaDefines: string;
19
19
  export declare const vertexShader: string;
20
20
  export declare const fragmentShader: string;
21
- import type { GameState } from "../wasm/avoidant_wasm";
21
+ import type { BoardState } from "../multiplayer/types";
22
22
  interface Props {
23
- gameState: GameState;
23
+ gameState: BoardState;
24
+ owners?: (number | null)[];
25
+ showZeroCounts?: boolean;
24
26
  terrain?: {
25
27
  positions: number[];
26
28
  normals: number[];
@@ -9,6 +9,7 @@ uniform bool uTransparentPass;
9
9
  uniform float elevationMin;
10
10
  uniform float elevationMax;
11
11
  uniform sampler2D uCellMeta;
12
+ uniform sampler2D uOwnership;
12
13
  uniform float uCellMetaSize;
13
14
  uniform int pulseCount;
14
15
  uniform float pulseTimers[MAX_PULSES];
@@ -24,6 +25,32 @@ float remapClamped(float value, float inMin, float inMax, float outMin, float ou
24
25
  return mix(outMin, outMax, t);
25
26
  }
26
27
 
28
+ // Screen-space patterns stay legible at any zoom, use the existing ownership
29
+ // texture, and add no meshes, draw calls, or per-frame texture uploads.
30
+ float stripe(float x) {
31
+ float d = abs(fract(x) - 0.5);
32
+ return 1.0 - smoothstep(0.1, 0.1 + max(fwidth(x), 0.025), d);
33
+ }
34
+ float territoryPattern(float owner, vec2 p) {
35
+ // Each slot uses a different motif, not merely a rotated version of a rival's.
36
+ if (owner < 1.5) return stripe(p.x + p.y); // Diagonal hatching.
37
+ if (owner < 2.5) {
38
+ // Dots.
39
+ float d = length(fract(p) - 0.5);
40
+ return 1.0 - smoothstep(0.14, 0.23, d);
41
+ }
42
+ if (owner < 3.5) return max(stripe(p.x + p.y), stripe(p.x - p.y)); // Cross-hatching.
43
+ if (owner < 4.5) return stripe(p.y) * step(0.35, fract(p.x * 0.5)); // Dashes.
44
+ if (owner < 5.5) return stripe(p.y + abs(fract(p.x * 0.5) - 0.5) * 2.0); // Zigzags.
45
+ if (owner < 6.5) return max(stripe(p.x), stripe(p.y)); // Square grid.
46
+ if (owner < 7.5) {
47
+ // Rings.
48
+ float d = abs(length(fract(p) - 0.5) - 0.3);
49
+ return 1.0 - smoothstep(0.035, 0.11, d);
50
+ }
51
+ return stripe(p.y + sin(p.x * 3.14159) * 0.3); // Waves.
52
+ }
53
+
27
54
  void main() {
28
55
  vec2 metaUv = vec2((vCellIndex + 0.5) / uCellMetaSize, 0.5);
29
56
  vec4 meta = texture2D(uCellMeta, metaUv);
@@ -87,6 +114,13 @@ void main() {
87
114
  vec3 lowColor = mix(unexploredLow, exploredLow, colorFactor);
88
115
  vec3 highColor = mix(unexploredHigh, exploredHigh, colorFactor);
89
116
  vec3 terrainColor = mix(lowColor, highColor, elevation);
117
+ vec4 ownership = texture2D(uOwnership, metaUv);
118
+ float owner = floor(ownership.a * 255.0 + 0.5);
119
+ if (owner > 0.5) {
120
+ terrainColor = mix(terrainColor, ownership.rgb, 0.7);
121
+ float pattern = territoryPattern(owner, gl_FragCoord.xy / 12.0);
122
+ terrainColor = mix(terrainColor, terrainColor * 0.45, pattern * 0.65);
123
+ }
90
124
 
91
125
  // Uniform illumination keeps every face readable regardless of its
92
126
  // orientation, with a subdued level that avoids near-white revealed cells.
@@ -1,3 +1,6 @@
1
1
  import { BufferGeometry, Vector3 } from "three";
2
- /** Find actual terrain endpoints, keeping edge labels attached to their own cell. */
3
- export declare function labelSurfacePoints(geometry: BufferGeometry, anchors: Vector3[], centers: Vector3[]): (Vector3 | undefined)[];
2
+ /** Center each label on its cell's exposed mesh, aligned with the base face normal. */
3
+ export declare function cellLabelPlacements(geometry: BufferGeometry, normals: Vector3[], clearance: number): ({
4
+ surface: Vector3;
5
+ anchor: Vector3;
6
+ } | undefined)[];
@@ -1,6 +1,6 @@
1
1
  import { BufferGeometry, Ray, Triangle, Vector3 } from "three";
2
- /** Find actual terrain endpoints, keeping edge labels attached to their own cell. */
3
- export function labelSurfacePoints(geometry, anchors, centers) {
2
+ /** Center each label on its cell's exposed mesh, aligned with the base face normal. */
3
+ export function cellLabelPlacements(geometry, normals, clearance) {
4
4
  const positions = geometry.getAttribute("position");
5
5
  const cellIndices = geometry.getAttribute("aCellIndex");
6
6
  const triangles = new Map();
@@ -17,47 +17,57 @@ export function labelSurfacePoints(geometry, anchors, centers) {
17
17
  else
18
18
  triangles.set(cell, [triangle]);
19
19
  }
20
- return anchors.map((anchor, cell) => {
21
- const surface = triangles.get(cell);
22
- const center = centers[cell];
23
- if (!surface || !center)
20
+ return normals.map((faceNormal, cell) => {
21
+ const mesh = triangles.get(cell);
22
+ if (!mesh || !faceNormal.lengthSq())
24
23
  return undefined;
25
- const ray = new Ray(anchor, center.clone().sub(anchor).normalize());
24
+ const normal = faceNormal.clone().normalize();
25
+ const centroid = new Vector3();
26
+ const midpoint = new Vector3();
27
+ let area = 0;
28
+ let top = -Infinity;
29
+ for (const triangle of mesh) {
30
+ const weight = triangle.getArea();
31
+ centroid.addScaledVector(triangle.getMidpoint(midpoint), weight);
32
+ area += weight;
33
+ top = Math.max(top, triangle.a.dot(normal), triangle.b.dot(normal), triangle.c.dot(normal));
34
+ }
35
+ if (!area)
36
+ return undefined;
37
+ centroid.divideScalar(area);
38
+ // A curved mesh's area centroid may lie inside the terrain. Project outward
39
+ // along the face normal, then intersect back onto the exposed surface.
40
+ const gap = Math.max(clearance, 1e-6);
41
+ const anchor = centroid.clone().addScaledVector(normal, top + gap - centroid.dot(normal));
42
+ const ray = new Ray(anchor, normal.clone().negate());
26
43
  const hit = new Vector3();
27
- function firstHit() {
28
- let nearest;
29
- let distance = Infinity;
30
- for (const triangle of surface) {
31
- if (!ray.intersectTriangle(triangle.a, triangle.b, triangle.c, false, hit))
32
- continue;
33
- const candidateDistance = anchor.distanceToSquared(hit);
34
- if (candidateDistance < distance) {
35
- distance = candidateDistance;
36
- nearest = hit.clone();
37
- }
44
+ let surface;
45
+ let nearest = Infinity;
46
+ for (const triangle of mesh) {
47
+ if (!ray.intersectTriangle(triangle.a, triangle.b, triangle.c, false, hit))
48
+ continue;
49
+ const distance = anchor.distanceToSquared(hit);
50
+ if (distance < nearest) {
51
+ nearest = distance;
52
+ surface = hit.clone();
38
53
  }
39
- return nearest;
40
54
  }
41
- // A polyhedron edge's base centroid can lie above the inset triangles.
42
- // Do not stop the search at that centroid.
43
- const direct = firstHit();
44
- if (direct)
45
- return direct;
46
- // If the ray falls in an inset gap, attach to the nearest point on this
47
- // cell's surface instead of dropping the connector or hitting a neighbor.
48
- let closest;
49
- let distance = Infinity;
50
- for (const triangle of surface) {
51
- triangle.closestPointToPoint(center, hit);
52
- const candidateDistance = center.distanceToSquared(hit);
53
- if (candidateDistance < distance) {
54
- distance = candidateDistance;
55
- closest = hit.clone();
55
+ if (!surface) {
56
+ // For a non-convex cell or inset gap, use its nearest surface point and
57
+ // move the label with it so the connector never tilts away from the normal.
58
+ nearest = Infinity;
59
+ for (const triangle of mesh) {
60
+ triangle.closestPointToPoint(centroid, hit);
61
+ const distance = centroid.distanceToSquared(hit);
62
+ if (distance < nearest) {
63
+ nearest = distance;
64
+ surface = hit.clone();
65
+ }
56
66
  }
57
67
  }
58
- if (!closest)
68
+ if (!surface)
59
69
  return undefined;
60
- ray.direction.copy(closest).sub(anchor).normalize();
61
- return firstHit() ?? closest;
70
+ anchor.copy(surface).addScaledVector(normal, top + gap - surface.dot(normal));
71
+ return { surface, anchor };
62
72
  });
63
73
  }
@@ -55,7 +55,7 @@ export function orbitRadiansPerPixel(camera, radius, viewportHeight, flat = fals
55
55
  const surfaceDistance = Math.max(mapRadius * 0.01, camera.position.length() - (flat ? 0 : mapRadius));
56
56
  const visibleHeight = 2 * Math.tan((camera.getEffectiveFOV() * Math.PI) / 360) * surfaceDistance;
57
57
  // The vertical FOV includes the aspect-ratio adjustment on narrow screens.
58
- return 2 * Math.min(Math.PI * 2, visibleHeight / mapRadius) / Math.max(1, viewportHeight);
58
+ return (2 * Math.min(Math.PI * 2, visibleHeight / mapRadius)) / Math.max(1, viewportHeight);
59
59
  }
60
60
  /** Move the grabbed surface point with the pointer without changing the orbit center. */
61
61
  export function panMap(camera, from, to, anchor) {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as favicon } from "./assets/favicon.svg";
2
2
  export { default as AvoidantGame } from "./components/AvoidantGame.svelte";
3
+ export type { CompetitiveConfig } from "./multiplayer/types";
@@ -0,0 +1,21 @@
1
+ import type { CompetitiveConfig, MatchSnapshot } from "./types";
2
+ /** One pending action at a time; retries reuse the sequence after reconnection. */
3
+ export declare class MatchClient {
4
+ private config;
5
+ readonly id: string;
6
+ private actor;
7
+ private receive;
8
+ private report;
9
+ private playerName;
10
+ private socket?;
11
+ private pending?;
12
+ private stopped;
13
+ private retry?;
14
+ private retryCount;
15
+ constructor(config: CompetitiveConfig, id: string, actor: string, receive: (s: MatchSnapshot, map: string, neighbors: number[][]) => void, report: (s: string, reconnect?: boolean) => void, playerName: () => string);
16
+ connect(): Promise<void>;
17
+ start(): void;
18
+ move(sequence: number, action: unknown): void;
19
+ private send;
20
+ close(): void;
21
+ }
@@ -0,0 +1,111 @@
1
+ import { m } from "../paraglide/messages";
2
+ /** One pending action at a time; retries reuse the sequence after reconnection. */
3
+ export class MatchClient {
4
+ config;
5
+ id;
6
+ actor;
7
+ receive;
8
+ report;
9
+ playerName;
10
+ socket;
11
+ pending;
12
+ stopped = false;
13
+ retry;
14
+ retryCount = 0;
15
+ constructor(config, id, actor, receive, report, playerName) {
16
+ this.config = config;
17
+ this.id = id;
18
+ this.actor = actor;
19
+ this.receive = receive;
20
+ this.report = report;
21
+ this.playerName = playerName;
22
+ }
23
+ async connect() {
24
+ clearTimeout(this.retry);
25
+ if (this.socket) {
26
+ this.socket.onclose = null;
27
+ this.socket.close();
28
+ }
29
+ try {
30
+ const response = await fetch(`${this.config.serverUrl}/matches/${this.id}/connect`, {
31
+ method: "POST",
32
+ headers: {
33
+ Authorization: `Bearer ${await this.config.account.token()}`,
34
+ "Content-Type": "application/json",
35
+ },
36
+ body: JSON.stringify({ name: this.playerName().trim() }),
37
+ });
38
+ const data = await response.json();
39
+ if (!response.ok)
40
+ throw new Error(data.error === "Invalid player name"
41
+ ? m.error_player_name()
42
+ : (data.error ?? m.error_match_join()));
43
+ if (this.stopped)
44
+ return;
45
+ const url = new URL(`${this.config.serverUrl}/matches/${this.id}/socket`);
46
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
47
+ url.searchParams.set("ticket", data.ticket);
48
+ this.socket = new WebSocket(url);
49
+ this.socket.onmessage = (event) => {
50
+ const message = JSON.parse(event.data);
51
+ if (message.type === "error") {
52
+ this.pending = undefined;
53
+ if (message.error !== "Cell unavailable")
54
+ this.report(message.error);
55
+ return;
56
+ }
57
+ if (message.type !== "snapshot")
58
+ return;
59
+ const s = message.snapshot;
60
+ if (s.version !== 1) {
61
+ this.report(m.error_match_version());
62
+ this.close();
63
+ return;
64
+ }
65
+ const player = s.players.find((p) => p.id === this.actor);
66
+ if (this.pending && player && player.sequence >= this.pending.sequence)
67
+ this.pending = undefined;
68
+ this.retryCount = 0;
69
+ this.receive(s, message.map, message.neighbors);
70
+ if (this.pending)
71
+ this.socket?.send(JSON.stringify(this.pending));
72
+ };
73
+ this.socket.onclose = (event) => {
74
+ if (this.stopped)
75
+ return;
76
+ if (event.code === 1000) {
77
+ this.report(m.status_match_expired());
78
+ return;
79
+ }
80
+ this.report(m.status_reconnecting(), true);
81
+ this.retry = setTimeout(() => void this.connect(), Math.min(1000 * 2 ** this.retryCount++, 15000));
82
+ };
83
+ this.socket.onerror = () => this.report(m.error_connection_interrupted(), true);
84
+ }
85
+ catch (error) {
86
+ this.report(error instanceof Error ? error.message : m.error_connection_failed(), true);
87
+ }
88
+ }
89
+ start() {
90
+ this.send({ kind: "start" });
91
+ }
92
+ move(sequence, action) {
93
+ if (this.pending)
94
+ return;
95
+ if (this.socket?.readyState !== WebSocket.OPEN) {
96
+ this.report(m.error_reconnect_to_play(), true);
97
+ return;
98
+ }
99
+ this.pending = { kind: "move", sequence, action };
100
+ this.send(this.pending);
101
+ }
102
+ send(value) {
103
+ if (this.socket?.readyState === WebSocket.OPEN)
104
+ this.socket.send(JSON.stringify(value));
105
+ }
106
+ close() {
107
+ this.stopped = true;
108
+ clearTimeout(this.retry);
109
+ this.socket?.close();
110
+ }
111
+ }
@@ -0,0 +1 @@
1
+ export declare function formatDuration(milliseconds: number, locale: string): string;
@@ -0,0 +1,6 @@
1
+ export function formatDuration(milliseconds, locale) {
2
+ const seconds = Math.floor(Math.max(0, milliseconds) / 1000);
3
+ return [Math.floor(seconds / 3600), Math.floor(seconds / 60) % 60, seconds % 60]
4
+ .map((value) => value.toLocaleString(locale, { minimumIntegerDigits: 2, useGrouping: false }))
5
+ .join(":");
6
+ }
@@ -0,0 +1 @@
1
+ export declare function localActorId(actor: string): string;
@@ -0,0 +1,13 @@
1
+ // Stable, non-secret UUIDs for the explicit local multiplayer harness only.
2
+ // This also works on LAN HTTP origins where SubtleCrypto is unavailable.
3
+ export function localActorId(actor) {
4
+ const hex = [0, 1, 2, 3]
5
+ .map((salt) => {
6
+ let hash = 2166136261 ^ salt;
7
+ for (const character of actor)
8
+ hash = Math.imul(hash ^ character.codePointAt(0), 16777619);
9
+ return (hash >>> 0).toString(16).padStart(8, "0");
10
+ })
11
+ .join("");
12
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-8${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
13
+ }