@johnmorrisdotca/kyogijo-stadiums 0.4.0 → 0.6.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 (361) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/NOTICE.md +182 -2
  3. package/README.md +106 -19
  4. package/dist/annotate.js +1 -1
  5. package/dist/arenas-entry.d.ts +4 -0
  6. package/dist/arenas-entry.js +3 -0
  7. package/dist/arenas.d.ts +125 -0
  8. package/dist/arenas.data.d.ts +2 -0
  9. package/dist/arenas.data.js +3763 -0
  10. package/dist/arenas.js +72 -0
  11. package/dist/athletics/describe.d.ts +8 -0
  12. package/dist/athletics/describe.js +41 -0
  13. package/dist/athletics/events.d.ts +17 -0
  14. package/dist/athletics/events.js +48 -0
  15. package/dist/athletics/facilities.d.ts +80 -0
  16. package/dist/athletics/facilities.js +176 -0
  17. package/dist/athletics/infield.d.ts +79 -0
  18. package/dist/athletics/infield.js +166 -0
  19. package/dist/athletics/layout.d.ts +13 -0
  20. package/dist/athletics/layout.js +98 -0
  21. package/dist/athletics/oval.d.ts +57 -0
  22. package/dist/athletics/oval.js +116 -0
  23. package/dist/athletics/plan.d.ts +97 -0
  24. package/dist/athletics/plan.js +355 -0
  25. package/dist/athletics/races.d.ts +102 -0
  26. package/dist/athletics/races.js +355 -0
  27. package/dist/athletics/steeplechase.d.ts +72 -0
  28. package/dist/athletics/steeplechase.js +196 -0
  29. package/dist/athletics/stencil.d.ts +13 -0
  30. package/dist/athletics/stencil.js +85 -0
  31. package/dist/athletics/track.d.ts +54 -0
  32. package/dist/athletics/track.js +105 -0
  33. package/dist/athletics/types.d.ts +77 -0
  34. package/dist/athletics/types.js +1 -0
  35. package/dist/athletics-entry.d.ts +17 -0
  36. package/dist/athletics-entry.js +11 -0
  37. package/dist/athletics.style.d.ts +16 -0
  38. package/dist/athletics.style.js +51 -0
  39. package/dist/atlas-entry.d.ts +6 -2
  40. package/dist/atlas-entry.js +4 -2
  41. package/dist/atlas.d.ts +117 -23
  42. package/dist/atlas.js +197 -12
  43. package/dist/background.js +2 -1
  44. package/dist/budo/describe.d.ts +13 -0
  45. package/dist/budo/describe.js +120 -0
  46. package/dist/budo/dojo.api.d.ts +64 -0
  47. package/dist/budo/dojo.api.js +46 -0
  48. package/dist/budo/dojo.d.ts +72 -0
  49. package/dist/budo/dojo.js +300 -0
  50. package/dist/budo/judo.d.ts +61 -0
  51. package/dist/budo/judo.js +109 -0
  52. package/dist/budo/karate.d.ts +29 -0
  53. package/dist/budo/karate.js +80 -0
  54. package/dist/budo/kendo.d.ts +18 -0
  55. package/dist/budo/kendo.js +44 -0
  56. package/dist/budo/kimarite.d.ts +19 -0
  57. package/dist/budo/kimarite.js +33 -0
  58. package/dist/budo/kit.d.ts +16 -0
  59. package/dist/budo/kit.js +24 -0
  60. package/dist/budo/kyudo.d.ts +28 -0
  61. package/dist/budo/kyudo.js +66 -0
  62. package/dist/budo/looks.d.ts +28 -0
  63. package/dist/budo/looks.js +58 -0
  64. package/dist/budo/parts.d.ts +32 -0
  65. package/dist/budo/parts.js +10 -0
  66. package/dist/budo/plan.d.ts +64 -0
  67. package/dist/budo/plan.js +139 -0
  68. package/dist/budo/room.d.ts +133 -0
  69. package/dist/budo/room.js +111 -0
  70. package/dist/budo/sumo.d.ts +31 -0
  71. package/dist/budo/sumo.js +71 -0
  72. package/dist/budo/tatami.d.ts +55 -0
  73. package/dist/budo/tatami.js +156 -0
  74. package/dist/budo/types.d.ts +192 -0
  75. package/dist/budo/types.js +2 -0
  76. package/dist/budo-entry.d.ts +22 -0
  77. package/dist/budo-entry.js +13 -0
  78. package/dist/budo.board.d.ts +28 -0
  79. package/dist/budo.board.js +81 -0
  80. package/dist/budo.score.d.ts +18 -0
  81. package/dist/budo.score.js +52 -0
  82. package/dist/budo.style.d.ts +6 -0
  83. package/dist/budo.style.js +67 -0
  84. package/dist/charts-entry.d.ts +6 -1
  85. package/dist/charts-entry.js +3 -0
  86. package/dist/charts.athletics.d.ts +183 -0
  87. package/dist/charts.athletics.js +455 -0
  88. package/dist/charts.baseball.js +1 -1
  89. package/dist/charts.curling.heat.d.ts +24 -0
  90. package/dist/charts.curling.heat.js +116 -0
  91. package/dist/charts.curling.js +14 -3
  92. package/dist/charts.js +4 -4
  93. package/dist/charts.pool.d.ts +67 -0
  94. package/dist/charts.pool.js +76 -0
  95. package/dist/charts.skating.d.ts +204 -0
  96. package/dist/charts.skating.js +426 -0
  97. package/dist/charts.soccer.js +3 -3
  98. package/dist/charts.types.d.ts +63 -1
  99. package/dist/colour.d.ts +4 -4
  100. package/dist/colour.js +4 -4
  101. package/dist/court.d.ts +85 -2
  102. package/dist/court.js +102 -7
  103. package/dist/court.more.d.ts +46 -0
  104. package/dist/court.more.js +219 -0
  105. package/dist/courts.style.d.ts +14 -2
  106. package/dist/courts.style.js +51 -4
  107. package/dist/crowd.d.ts +164 -0
  108. package/dist/crowd.draw.d.ts +17 -0
  109. package/dist/crowd.draw.js +204 -0
  110. package/dist/crowd.js +480 -0
  111. package/dist/crowd.park.d.ts +19 -0
  112. package/dist/crowd.park.js +153 -0
  113. package/dist/curling.stats.d.ts +271 -0
  114. package/dist/curling.stats.js +301 -0
  115. package/dist/draw.d.ts +16 -0
  116. package/dist/draw.js +462 -54
  117. package/dist/element-entry.d.ts +3 -1
  118. package/dist/element-entry.js +2 -1
  119. package/dist/element.d.ts +13 -2
  120. package/dist/element.js +79 -4
  121. package/dist/emblems-source.d.ts +50 -0
  122. package/dist/emblems-source.js +56 -0
  123. package/dist/eras.d.ts +3 -1
  124. package/dist/eras.js +8 -3
  125. package/dist/features.js +204 -0
  126. package/dist/field.data.d.ts +16 -0
  127. package/dist/field.data.js +50 -0
  128. package/dist/fields.kit.d.ts +2 -2
  129. package/dist/fields.types.d.ts +24 -4
  130. package/dist/formations.js +18 -7
  131. package/dist/formations.sports.d.ts +8 -0
  132. package/dist/formations.sports.js +251 -0
  133. package/dist/frames.providers.js +71 -8
  134. package/dist/geojson.js +3 -0
  135. package/dist/geometry-entry.d.ts +2 -1
  136. package/dist/geometry-entry.js +2 -1
  137. package/dist/geometry.d.ts +20 -0
  138. package/dist/geometry.js +78 -1
  139. package/dist/grounds.d.ts +4 -0
  140. package/dist/grounds.data.js +12 -0
  141. package/dist/halls.d.ts +65 -0
  142. package/dist/halls.js +122 -0
  143. package/dist/hardwood.d.ts +31 -0
  144. package/dist/hardwood.js +157 -0
  145. package/dist/heat.js +21 -13
  146. package/dist/heat.types.d.ts +5 -0
  147. package/dist/heat.zones.d.ts +4 -2
  148. package/dist/heat.zones.js +207 -7
  149. package/dist/homeside.js +24 -0
  150. package/dist/index.d.ts +30 -4
  151. package/dist/index.js +18 -2
  152. package/dist/layers-entry.d.ts +2 -1
  153. package/dist/layers-entry.js +1 -0
  154. package/dist/layers.d.ts +2 -1
  155. package/dist/layers.env.d.ts +12 -1
  156. package/dist/layers.env.js +36 -4
  157. package/dist/layers.js +32 -13
  158. package/dist/layers.types.d.ts +9 -2
  159. package/dist/leagues/athletics.d.ts +63 -0
  160. package/dist/leagues/athletics.js +87 -0
  161. package/dist/leagues/budo.d.ts +196 -0
  162. package/dist/leagues/budo.js +105 -0
  163. package/dist/leagues/courts.d.ts +269 -4
  164. package/dist/leagues/courts.js +155 -1
  165. package/dist/leagues/hockey.js +41 -19
  166. package/dist/leagues/skating.d.ts +145 -0
  167. package/dist/leagues/skating.js +73 -0
  168. package/dist/leagues/sources.js +41 -0
  169. package/dist/leagues/types.d.ts +1 -1
  170. package/dist/leagues-entry.d.ts +4 -2
  171. package/dist/leagues-entry.js +2 -1
  172. package/dist/leagues.d.ts +17 -4
  173. package/dist/leagues.js +246 -5
  174. package/dist/lineup.codes.d.ts +23 -0
  175. package/dist/lineup.codes.js +122 -0
  176. package/dist/logo.d.ts +25 -0
  177. package/dist/logo.js +47 -0
  178. package/dist/look.d.ts +3 -3
  179. package/dist/look.js +39 -6
  180. package/dist/outline.d.ts +1 -1
  181. package/dist/outline.js +46 -4
  182. package/dist/pageant.d.ts +120 -0
  183. package/dist/pageant.draw.d.ts +21 -0
  184. package/dist/pageant.draw.js +171 -0
  185. package/dist/pageant.js +211 -0
  186. package/dist/pageant.style.d.ts +8 -0
  187. package/dist/pageant.style.js +42 -0
  188. package/dist/png.d.ts +8 -1
  189. package/dist/png.js +21 -1
  190. package/dist/pointer-entry.d.ts +2 -0
  191. package/dist/pointer-entry.js +2 -0
  192. package/dist/pointer.d.ts +113 -0
  193. package/dist/pointer.js +151 -0
  194. package/dist/pool.d.ts +176 -0
  195. package/dist/pool.figures.d.ts +306 -0
  196. package/dist/pool.figures.js +148 -0
  197. package/dist/pool.js +304 -0
  198. package/dist/pool.kit.d.ts +48 -0
  199. package/dist/pool.kit.js +141 -0
  200. package/dist/pool.labels.d.ts +20 -0
  201. package/dist/pool.labels.js +258 -0
  202. package/dist/pool.race.d.ts +65 -0
  203. package/dist/pool.race.js +140 -0
  204. package/dist/pool.replay.d.ts +46 -0
  205. package/dist/pool.replay.js +127 -0
  206. package/dist/pool.section.d.ts +13 -0
  207. package/dist/pool.section.js +83 -0
  208. package/dist/pool.style.d.ts +20 -0
  209. package/dist/pool.style.js +169 -0
  210. package/dist/pool.types.d.ts +145 -0
  211. package/dist/pool.types.js +3 -0
  212. package/dist/pool.words.d.ts +13 -0
  213. package/dist/pool.words.js +101 -0
  214. package/dist/ranges.names.js +53 -3
  215. package/dist/replay-entry.d.ts +3 -0
  216. package/dist/replay-entry.js +2 -0
  217. package/dist/restyle.js +1 -1
  218. package/dist/road.draw.js +3 -2
  219. package/dist/road.js +2 -1
  220. package/dist/road.types.d.ts +3 -0
  221. package/dist/rules.d.ts +138 -0
  222. package/dist/rules.js +511 -0
  223. package/dist/rules.types.d.ts +4 -0
  224. package/dist/rules.types.js +64 -0
  225. package/dist/score.d.ts +3 -0
  226. package/dist/score.js +93 -6
  227. package/dist/sheet.d.ts +3 -0
  228. package/dist/sheet.js +7 -3
  229. package/dist/situation.d.ts +135 -0
  230. package/dist/situation.draw.d.ts +34 -0
  231. package/dist/situation.draw.js +202 -0
  232. package/dist/situation.js +337 -0
  233. package/dist/situation.style.d.ts +2 -0
  234. package/dist/situation.style.js +45 -0
  235. package/dist/situation.types.d.ts +77 -0
  236. package/dist/situation.types.js +3 -0
  237. package/dist/situation.widgets.d.ts +39 -0
  238. package/dist/situation.widgets.js +129 -0
  239. package/dist/skating/describe.d.ts +7 -0
  240. package/dist/skating/describe.js +44 -0
  241. package/dist/skating/events.d.ts +24 -0
  242. package/dist/skating/events.js +47 -0
  243. package/dist/skating/figure.d.ts +24 -0
  244. package/dist/skating/figure.js +37 -0
  245. package/dist/skating/long.d.ts +54 -0
  246. package/dist/skating/long.js +111 -0
  247. package/dist/skating/parts.d.ts +43 -0
  248. package/dist/skating/parts.js +40 -0
  249. package/dist/skating/plan.d.ts +55 -0
  250. package/dist/skating/plan.js +197 -0
  251. package/dist/skating/short.d.ts +47 -0
  252. package/dist/skating/short.js +89 -0
  253. package/dist/skating/track.d.ts +66 -0
  254. package/dist/skating/track.js +94 -0
  255. package/dist/skating/types.d.ts +57 -0
  256. package/dist/skating/types.js +3 -0
  257. package/dist/skating-entry.d.ts +17 -0
  258. package/dist/skating-entry.js +11 -0
  259. package/dist/skating.style.d.ts +4 -0
  260. package/dist/skating.style.js +24 -0
  261. package/dist/strings.d.ts +470 -0
  262. package/dist/strings.js +674 -13
  263. package/dist/style.d.ts +2 -0
  264. package/dist/style.js +19 -2
  265. package/dist/surfaces/artistic.d.ts +9 -0
  266. package/dist/surfaces/artistic.js +94 -0
  267. package/dist/surfaces/athletics.d.ts +16 -0
  268. package/dist/surfaces/athletics.js +132 -0
  269. package/dist/surfaces/baseball.js +17 -0
  270. package/dist/surfaces/basketball.floor.d.ts +27 -0
  271. package/dist/surfaces/basketball.floor.js +83 -0
  272. package/dist/surfaces/basketball.gear.d.ts +27 -0
  273. package/dist/surfaces/basketball.gear.js +90 -0
  274. package/dist/surfaces/basketball.js +44 -22
  275. package/dist/surfaces/budo.d.ts +6 -0
  276. package/dist/surfaces/budo.js +104 -0
  277. package/dist/surfaces/curling.d.ts +16 -0
  278. package/dist/surfaces/curling.fold.d.ts +67 -0
  279. package/dist/surfaces/curling.fold.js +107 -0
  280. package/dist/surfaces/curling.js +37 -3
  281. package/dist/surfaces/dive.d.ts +9 -0
  282. package/dist/surfaces/dive.js +128 -0
  283. package/dist/surfaces/field.d.ts +7 -2
  284. package/dist/surfaces/field.js +15 -9
  285. package/dist/surfaces/football.js +7 -0
  286. package/dist/surfaces/hockey.js +4 -2
  287. package/dist/surfaces/net.d.ts +2 -1
  288. package/dist/surfaces/net.js +160 -15
  289. package/dist/surfaces/polo.d.ts +12 -0
  290. package/dist/surfaces/polo.js +159 -0
  291. package/dist/surfaces/pool.d.ts +27 -0
  292. package/dist/surfaces/pool.js +198 -0
  293. package/dist/surfaces/skating.d.ts +6 -0
  294. package/dist/surfaces/skating.js +62 -0
  295. package/dist/surfaces/soccer.js +2 -1
  296. package/dist/surfaces/surface.d.ts +76 -0
  297. package/dist/surfaces/venue.d.ts +15 -0
  298. package/dist/surfaces/venue.js +95 -0
  299. package/dist/target-entry.d.ts +2 -0
  300. package/dist/target-entry.js +2 -0
  301. package/dist/target.d.ts +200 -0
  302. package/dist/target.js +525 -0
  303. package/dist/team.common.d.ts +1 -1
  304. package/dist/team.common.js +3 -3
  305. package/dist/team.formation.d.ts +3 -1
  306. package/dist/team.formation.js +3 -3
  307. package/dist/team.layers.d.ts +2 -2
  308. package/dist/team.layers.js +4 -1
  309. package/dist/team.lineup.d.ts +27 -0
  310. package/dist/team.lineup.js +207 -0
  311. package/dist/team.network.js +6 -5
  312. package/dist/team.shape.js +5 -5
  313. package/dist/team.types.d.ts +40 -1
  314. package/dist/tenants.d.ts +77 -0
  315. package/dist/tenants.data.d.ts +8 -0
  316. package/dist/tenants.data.js +1793 -0
  317. package/dist/tenants.js +46 -0
  318. package/dist/turn-entry.d.ts +12 -0
  319. package/dist/turn-entry.js +7 -0
  320. package/dist/turn.camera.d.ts +116 -0
  321. package/dist/turn.camera.js +184 -0
  322. package/dist/turn.dom.d.ts +40 -0
  323. package/dist/turn.dom.js +353 -0
  324. package/dist/turn.kit.d.ts +86 -0
  325. package/dist/turn.kit.js +110 -0
  326. package/dist/turn.markup.d.ts +48 -0
  327. package/dist/turn.markup.js +108 -0
  328. package/dist/turn.model.d.ts +78 -0
  329. package/dist/turn.model.js +91 -0
  330. package/dist/turn.style.d.ts +5 -0
  331. package/dist/turn.style.js +56 -0
  332. package/dist/types.d.ts +221 -20
  333. package/dist/units.d.ts +1 -1
  334. package/dist/units.js +22 -1
  335. package/dist/uprights.board.d.ts +17 -0
  336. package/dist/uprights.board.js +59 -0
  337. package/dist/uprights.budo.d.ts +17 -0
  338. package/dist/uprights.budo.js +87 -0
  339. package/dist/uprights.d.ts +37 -0
  340. package/dist/uprights.fields.d.ts +32 -0
  341. package/dist/uprights.fields.js +172 -0
  342. package/dist/uprights.goal.d.ts +49 -0
  343. package/dist/uprights.goal.js +69 -0
  344. package/dist/uprights.js +169 -0
  345. package/dist/uprights.more.d.ts +7 -0
  346. package/dist/uprights.more.js +183 -0
  347. package/dist/uprights.net.d.ts +12 -0
  348. package/dist/uprights.net.js +109 -0
  349. package/dist/uprights.netkit.d.ts +28 -0
  350. package/dist/uprights.netkit.js +67 -0
  351. package/dist/uprights.pools.d.ts +8 -0
  352. package/dist/uprights.pools.js +190 -0
  353. package/dist/uprights.rinks.d.ts +27 -0
  354. package/dist/uprights.rinks.js +106 -0
  355. package/dist/uprights.track.d.ts +50 -0
  356. package/dist/uprights.track.js +246 -0
  357. package/dist/version.d.ts +1 -1
  358. package/dist/version.js +1 -1
  359. package/dist/zones-entry.d.ts +2 -0
  360. package/dist/zones-entry.js +2 -0
  361. package/package.json +56 -3
@@ -0,0 +1,46 @@
1
+ import { TENANT_ARTICLES, TENANT_DATA, TENANT_NAMES_JA, TENANT_NO_SURFACE } from "./tenants.data.js";
2
+ const toTenant = (placeId, data) => {
3
+ const article = TENANT_ARTICLES[placeId];
4
+ const source = {
5
+ ...(data.statements === undefined ? {} : { wikidata: data.statements }),
6
+ ...(data.listed === true && article !== undefined ? { wikipedia: article } : {}),
7
+ ...(data.years === undefined ? {} : { years: data.years }),
8
+ };
9
+ return {
10
+ club: data.club,
11
+ ...(data.clubJa === undefined ? {} : { clubJa: data.clubJa }),
12
+ ...(data.aliasesJa === undefined ? {} : { aliasesJa: data.aliasesJa }),
13
+ league: data.league,
14
+ sport: data.sport,
15
+ ...(data.from === undefined ? {} : { from: data.from }),
16
+ ...(data.to === undefined ? {} : { to: data.to }),
17
+ wikidata: data.wikidata,
18
+ source,
19
+ };
20
+ };
21
+ /** The tenants of every place that has any, by the place's key: the current ones first, by the year they came, then those that have left, the latest to leave first. */
22
+ export const TENANTS = Object.freeze(Object.fromEntries(Object.entries(TENANT_DATA).map(([id, list]) => [id, Object.freeze(list.map((data) => toTenant(id, data)))])));
23
+ /** The leagues of a list of tenants, each once, in the order they first come. */
24
+ export const leaguesOf = (tenants) => [...new Set(tenants.map((tenant) => tenant.league))];
25
+ /** True when a tenant played there in `year`; a year the data does not give for a bound does not shut it out. */
26
+ export const playedIn = (tenant, year) => (tenant.from === undefined || tenant.from <= year) && (tenant.to === undefined || year <= tenant.to);
27
+ /** The draw sport a tenant's sport is drawn as, and any league of its rulebook: the field of play a club's sport asks for. `undefined` where the package draws none. */
28
+ export const SURFACE_OF_SPORT = Object.freeze({
29
+ baseball: { sport: "mlb" },
30
+ soccer: { sport: "soccer" },
31
+ "american-football": { sport: "nfl" },
32
+ "canadian-football": { sport: "cfl" },
33
+ basketball: { sport: "nba" },
34
+ "ice-hockey": { sport: "nhl" },
35
+ "rugby-union": { sport: "rugby" },
36
+ "rugby-league": { sport: "rugby", league: "nrl" },
37
+ "australian-football": { sport: "afl" },
38
+ lacrosse: undefined,
39
+ cricket: { sport: "cricket" },
40
+ });
41
+ /** True when the package draws a surface for the tenant's sport and league. */
42
+ export const hasSurface = (tenant) => SURFACE_OF_SPORT[tenant.sport] !== undefined && !TENANT_NO_SURFACE.includes(tenant.league);
43
+ /** The clubs whose name in Japanese is the everyday form and not Wikidata's label, by Wikidata item, with why and the source of each: `nameJaOf(tenant)` finds a tenant's. */
44
+ export const TENANT_JAPANESE_NAMES = TENANT_NAMES_JA;
45
+ /** The note on a tenant's name in Japanese, if its everyday form is a curated one. */
46
+ export const nameJaOf = (tenant) => TENANT_NAMES_JA[tenant.wikidata];
@@ -0,0 +1,12 @@
1
+ export { mountKyogijoTurn, turnSupported } from "./turn.dom.ts";
2
+ export type { KyogijoTurn } from "./turn.dom.ts";
3
+ export { buildTurn, floorOptions, openingView } from "./turn.model.ts";
4
+ export type { TurnModel, TurnSettings } from "./turn.model.ts";
5
+ export { layoutOf, planeMarkup, planeMatrix, turnMarkup, turnMarkupOf } from "./turn.markup.ts";
6
+ export type { Layout } from "./turn.markup.ts";
7
+ export { KYOGIJO_TURN_STYLE } from "./turn.style.ts";
8
+ export { CURLING_PRESETS, LONG_PRESETS, NET_PRESETS, PITCH_MAX, STEP, TURN_DEFAULT, TURN_PRESETS, TURN_PRESET_NAMES, ZOOM_MAX, ZOOM_MIN, cameraMatrix, clampView, depthOf, drag, eyeDistance, fit, matrix3d, multiply, nudge, presetOf, presetView, presetsFor, project, step } from "./turn.camera.ts";
9
+ export type { Box3, Mat4, Placement, TurnPreset, TurnToward, TurnView } from "./turn.camera.ts";
10
+ export { describeUprights, heightUnit, planesOf, uprightsFor } from "./uprights.ts";
11
+ export type { UprightOptions, Uprights } from "./uprights.ts";
12
+ export type { Plane, PartKind, Upright, UprightKind, V3 } from "./turn.kit.ts";
@@ -0,0 +1,7 @@
1
+ // The 3D view: a surface as a floor that turns, with a net, a basket, a goal or a pair of posts standing on it.
2
+ export { mountKyogijoTurn, turnSupported } from "./turn.dom.js";
3
+ export { buildTurn, floorOptions, openingView } from "./turn.model.js";
4
+ export { layoutOf, planeMarkup, planeMatrix, turnMarkup, turnMarkupOf } from "./turn.markup.js";
5
+ export { KYOGIJO_TURN_STYLE } from "./turn.style.js";
6
+ export { CURLING_PRESETS, LONG_PRESETS, NET_PRESETS, PITCH_MAX, STEP, TURN_DEFAULT, TURN_PRESETS, TURN_PRESET_NAMES, ZOOM_MAX, ZOOM_MIN, cameraMatrix, clampView, depthOf, drag, eyeDistance, fit, matrix3d, multiply, nudge, presetOf, presetView, presetsFor, project, step } from "./turn.camera.js";
7
+ export { describeUprights, heightUnit, planesOf, uprightsFor } from "./uprights.js";
@@ -0,0 +1,116 @@
1
+ /** How the scene is looked at: turned about the vertical (degrees, clockwise as the eye sees the floor), tipped back from straight overhead (degrees), and magnified. */
2
+ export interface TurnView {
3
+ yaw: number;
4
+ pitch: number;
5
+ zoom: number;
6
+ }
7
+ /** The named viewpoints. */
8
+ export type TurnPreset = "overhead" | "broadcast" | "end" | "corner";
9
+ /** The viewpoints, in the order the controls and the number keys list them. */
10
+ export declare const TURN_PRESET_NAMES: readonly TurnPreset[];
11
+ /**
12
+ * The four viewpoints. `overhead` looks straight down; `broadcast` is the main camera, high on one side line and turned a little towards the near end so that the boards, the nets and the goals show their faces; `end` stands behind an end line, along the
13
+ * surface, which is where a net, a goal or a basket is best seen; `corner` is low, from a corner, with the nearest net or goal in front.
14
+ */
15
+ export declare const TURN_PRESETS: Readonly<Record<TurnPreset, TurnView>>;
16
+ /** The same four for a long, narrow surface (a football field, a hockey rink): turned less, because a diagonal view would shrink it in the box. */
17
+ export declare const LONG_PRESETS: Readonly<Record<TurnPreset, TurnView>>;
18
+ /**
19
+ * The same four for the net sports, whose net runs across the court: seen from the side line it is a stick, so the broadcast view stands high behind an end line, as a
20
+ * television camera does, and the end-on view is lower behind it. The corner view is the same.
21
+ */
22
+ export declare const NET_PRESETS: Readonly<Record<TurnPreset, TurnView>>;
23
+ /**
24
+ * The same four for a curling sheet, which is ten times as long as it is wide: from the side it is a strip across the box, so the broadcast and the corner views
25
+ * stay nearly square on to it, and the end view looks along it.
26
+ */
27
+ export declare const CURLING_PRESETS: Readonly<Record<TurnPreset, TurnView>>;
28
+ /** The four viewpoints of a sport. */
29
+ export declare const presetsFor: (sport?: string) => Readonly<Record<TurnPreset, TurnView>>;
30
+ /** The view a mount opens on. */
31
+ export declare const TURN_DEFAULT: TurnPreset;
32
+ export declare const PITCH_MAX = 84;
33
+ export declare const ZOOM_MIN = 0.5;
34
+ export declare const ZOOM_MAX = 4;
35
+ /** An angle in degrees brought to the range -180 to 180. */
36
+ export declare const wrap: (angle: number) => number;
37
+ /** A view held to what the controls allow: the pitch from overhead to 84 degrees, the zoom from half to four times. A number that is not one is left as it was. */
38
+ export declare function clampView(view: TurnView, fallback?: TurnView): TurnView;
39
+ /** The angle equal to `to` that is nearest to `from`, so that a change of view turns the short way round. */
40
+ export declare const nearest: (from: number, to: number) => number;
41
+ /** The view a viewpoint name stands for in a sport, or `undefined` for a name that is not one. */
42
+ export declare const presetView: (name: string | undefined, sport?: string) => TurnView | undefined;
43
+ /** The name of the viewpoint a view is in a sport, or `undefined` when it is none of them (it has been turned by hand). */
44
+ export declare function presetOf(view: TurnView, sport?: string): TurnPreset | undefined;
45
+ /** The steps of the keys and the buttons, in degrees, and the factor of a zoom step. A held Shift takes the larger. */
46
+ export declare const STEP: {
47
+ readonly yaw: 6;
48
+ readonly yawBig: 24;
49
+ readonly pitch: 4;
50
+ readonly pitchBig: 12;
51
+ readonly zoom: 1.2;
52
+ };
53
+ /** The view after a step of a key or a button. */
54
+ export declare function step(view: TurnView, change: {
55
+ yaw?: number;
56
+ pitch?: number;
57
+ zoom?: number;
58
+ }): TurnView;
59
+ /** A side a key, a button or a drag takes the surface toward. */
60
+ export type TurnToward = "left" | "right" | "up" | "down";
61
+ /**
62
+ * The view after a step of `amount` degrees toward a side, the way a drag toward that side takes the view: left and right carry the near side to the left and to the right (the yaw rises and
63
+ * falls), up tips the surface as a drag up does and down as a drag down does (the pitch rises and falls). The arrow keys and the four turn buttons are this, so that a drag, a key and a button
64
+ * toward one side all move the surface the same way.
65
+ */
66
+ export declare function nudge(view: TurnView, toward: TurnToward, amount: number): TurnView;
67
+ /**
68
+ * The view after a drag of the pointer by (dx, dy) pixels, `degreesPerPixel` apart: the surface is taken hold of, so a drag to the right carries the side nearest the eye to the right (the
69
+ * yaw falls) and a drag down tips the top toward the eye (the pitch falls).
70
+ */
71
+ export declare function drag(view: TurnView, dx: number, dy: number, tilt?: boolean, degreesPerPixel?: number): TurnView;
72
+ /** A box in the scene, in pixels from the scene's middle, the floor at `z0` and the highest thing at `z1`. */
73
+ export interface Box3 {
74
+ x0: number;
75
+ y0: number;
76
+ x1: number;
77
+ y1: number;
78
+ z0: number;
79
+ z1: number;
80
+ }
81
+ /** How a view is placed in a container: the scale (at a zoom of 1) that fits the scene, and where the middle of what is seen falls. */
82
+ export interface Placement {
83
+ k: number;
84
+ tx: number;
85
+ ty: number;
86
+ }
87
+ /** Where a point of the scene falls on the screen, in pixels from the middle of the container, when the scene is placed as given and the eye is `distance` pixels away. */
88
+ export declare function project(point: readonly [number, number, number], view: TurnView, at: Placement, distance: number): [number, number, number];
89
+ /** The rectangle on the screen that a box covers. */
90
+ export declare function covered(b: Box3, view: TurnView, at: Placement, distance: number): {
91
+ x0: number;
92
+ y0: number;
93
+ x1: number;
94
+ y1: number;
95
+ };
96
+ /**
97
+ * The placement that fits the scene in a container of width `w` and height `h` pixels, centred, with `pad` of its width and height left round it. The
98
+ * perspective bends the sum, so it is found by a few rounds of scaling and re-centring; six is plenty.
99
+ */
100
+ export declare function fit(b: Box3, view: TurnView, w: number, h: number, distance: number, pad?: number): Placement;
101
+ /** A 4 by 4 matrix, as CSS writes it in `matrix3d`: sixteen numbers, a column after a column. */
102
+ export type Mat4 = readonly number[];
103
+ /** Two matrices as one: `b` first, then `a`. */
104
+ export declare function multiply(a: Mat4, b: Mat4): number[];
105
+ /**
106
+ * The matrix that puts a point of the scene on the screen for a view in a placement: the scene (whose middle is the origin) is scaled, turned about the vertical,
107
+ * tipped back, shifted to where the fit puts it, and seen with a perspective `distance` pixels deep. This is `project`'s arithmetic as one matrix, so that an
108
+ * element can be given its whole place in one `matrix3d` and need no 3D context of the browser's: a browser that draws nested 3D layers flat still draws it right.
109
+ */
110
+ export declare function cameraMatrix(view: TurnView, at: Placement, distance: number): number[];
111
+ /** A matrix as the CSS `transform` that applies it. */
112
+ export declare const matrix3d: (m: Mat4) => string;
113
+ /** How far a point is from the eye's plane after the scene is turned and tipped, in pixels towards the eye: bigger is nearer. Planes are drawn far first. */
114
+ export declare function depthOf(point: readonly [number, number, number], view: TurnView, at: Placement): number;
115
+ /** How far the eye is from the screen, in pixels, for a container: a long lens, so that the floor keeps its shape and the heights lean a little. */
116
+ export declare const eyeDistance: (w: number, h: number, lens?: number) => number;
@@ -0,0 +1,184 @@
1
+ // The eye of the 3D view: where it looks from, and what that does to the scene. The scene is turned by `rotateZ(yaw)` about the vertical through its middle
2
+ // and then tipped back by `rotateX(pitch)`; a perspective on the container does the rest. Everything here is arithmetic on numbers, so the same view can be
3
+ // worked out in Node, tested, and handed to a stylesheet as one `transform`.
4
+ //
5
+ // CSS has x to the right, y down and z towards the eye, and the scene is built that way: the floor lies in the x-y plane facing the eye, heights are z.
6
+ /** The viewpoints, in the order the controls and the number keys list them. */
7
+ export const TURN_PRESET_NAMES = ["overhead", "broadcast", "end", "corner"];
8
+ /**
9
+ * The four viewpoints. `overhead` looks straight down; `broadcast` is the main camera, high on one side line and turned a little towards the near end so that the boards, the nets and the goals show their faces; `end` stands behind an end line, along the
10
+ * surface, which is where a net, a goal or a basket is best seen; `corner` is low, from a corner, with the nearest net or goal in front.
11
+ */
12
+ export const TURN_PRESETS = {
13
+ overhead: { yaw: 0, pitch: 0, zoom: 1 },
14
+ broadcast: { yaw: -20, pitch: 62, zoom: 1 },
15
+ end: { yaw: -90, pitch: 68, zoom: 1 },
16
+ corner: { yaw: -38, pitch: 70, zoom: 1 },
17
+ };
18
+ /** The same four for a long, narrow surface (a football field, a hockey rink): turned less, because a diagonal view would shrink it in the box. */
19
+ export const LONG_PRESETS = { ...TURN_PRESETS, broadcast: { yaw: -9, pitch: 62, zoom: 1 } };
20
+ /** The sports with surfaces more than twice as long as they are wide, whose viewpoints are `LONG_PRESETS`. */
21
+ const LONG_SPORTS = ["nfl", "cfl", "ifaf", "nhl"];
22
+ /**
23
+ * The same four for the net sports, whose net runs across the court: seen from the side line it is a stick, so the broadcast view stands high behind an end line, as a
24
+ * television camera does, and the end-on view is lower behind it. The corner view is the same.
25
+ */
26
+ export const NET_PRESETS = {
27
+ overhead: TURN_PRESETS.overhead,
28
+ broadcast: { yaw: -90, pitch: 54, zoom: 1 },
29
+ end: { yaw: -90, pitch: 74, zoom: 1 },
30
+ corner: TURN_PRESETS.corner,
31
+ };
32
+ /**
33
+ * The same four for a curling sheet, which is ten times as long as it is wide: from the side it is a strip across the box, so the broadcast and the corner views
34
+ * stay nearly square on to it, and the end view looks along it.
35
+ */
36
+ export const CURLING_PRESETS = {
37
+ overhead: TURN_PRESETS.overhead,
38
+ broadcast: { yaw: 0, pitch: 62, zoom: 1 },
39
+ end: { yaw: -90, pitch: 70, zoom: 1 },
40
+ corner: { yaw: -24, pitch: 62, zoom: 1 },
41
+ };
42
+ /** The sports whose net runs across the court and whose viewpoints are `NET_PRESETS`. */
43
+ const NET_SPORTS = ["tennis", "volleyball", "badminton", "pickleball", "tabletennis", "padel", "sepaktakraw", "teqball"];
44
+ /** The four viewpoints of a sport. */
45
+ export const presetsFor = (sport) => (sport === "curling" ? CURLING_PRESETS : sport !== undefined && NET_SPORTS.includes(sport) ? NET_PRESETS : sport !== undefined && LONG_SPORTS.includes(sport) ? LONG_PRESETS : TURN_PRESETS);
46
+ /** The view a mount opens on. */
47
+ export const TURN_DEFAULT = "corner";
48
+ export const PITCH_MAX = 84;
49
+ export const ZOOM_MIN = 0.5;
50
+ export const ZOOM_MAX = 4;
51
+ const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
52
+ /** An angle in degrees brought to the range -180 to 180. */
53
+ export const wrap = (angle) => ((((angle + 180) % 360) + 360) % 360) - 180;
54
+ /** A view held to what the controls allow: the pitch from overhead to 84 degrees, the zoom from half to four times. A number that is not one is left as it was. */
55
+ export function clampView(view, fallback = TURN_PRESETS[TURN_DEFAULT]) {
56
+ const finite = (value, otherwise) => (Number.isFinite(value) ? value : otherwise);
57
+ return {
58
+ yaw: wrap(finite(view.yaw, fallback.yaw)),
59
+ pitch: clamp(finite(view.pitch, fallback.pitch), 0, PITCH_MAX),
60
+ zoom: clamp(finite(view.zoom, fallback.zoom), ZOOM_MIN, ZOOM_MAX),
61
+ };
62
+ }
63
+ /** The angle equal to `to` that is nearest to `from`, so that a change of view turns the short way round. */
64
+ export const nearest = (from, to) => from + wrap(to - from);
65
+ /** The view a viewpoint name stands for in a sport, or `undefined` for a name that is not one. */
66
+ export const presetView = (name, sport) => (name !== undefined && TURN_PRESET_NAMES.includes(name) ? { ...presetsFor(sport)[name] } : undefined);
67
+ /** The name of the viewpoint a view is in a sport, or `undefined` when it is none of them (it has been turned by hand). */
68
+ export function presetOf(view, sport) {
69
+ return TURN_PRESET_NAMES.find((name) => {
70
+ const p = presetsFor(sport)[name];
71
+ return Math.abs(wrap(view.yaw - p.yaw)) < 0.5 && Math.abs(view.pitch - p.pitch) < 0.5 && Math.abs(view.zoom - p.zoom) < 0.01;
72
+ });
73
+ }
74
+ /** The steps of the keys and the buttons, in degrees, and the factor of a zoom step. A held Shift takes the larger. */
75
+ export const STEP = { yaw: 6, yawBig: 24, pitch: 4, pitchBig: 12, zoom: 1.2 };
76
+ /** The view after a step of a key or a button. */
77
+ export function step(view, change) {
78
+ return clampView({ yaw: view.yaw + (change.yaw ?? 0), pitch: view.pitch + (change.pitch ?? 0), zoom: view.zoom * (change.zoom ?? 1) });
79
+ }
80
+ /**
81
+ * The view after a step of `amount` degrees toward a side, the way a drag toward that side takes the view: left and right carry the near side to the left and to the right (the yaw rises and
82
+ * falls), up tips the surface as a drag up does and down as a drag down does (the pitch rises and falls). The arrow keys and the four turn buttons are this, so that a drag, a key and a button
83
+ * toward one side all move the surface the same way.
84
+ */
85
+ export function nudge(view, toward, amount) {
86
+ switch (toward) {
87
+ case "left": return step(view, { yaw: amount });
88
+ case "right": return step(view, { yaw: -amount });
89
+ case "up": return step(view, { pitch: amount });
90
+ default: return step(view, { pitch: -amount });
91
+ }
92
+ }
93
+ /**
94
+ * The view after a drag of the pointer by (dx, dy) pixels, `degreesPerPixel` apart: the surface is taken hold of, so a drag to the right carries the side nearest the eye to the right (the
95
+ * yaw falls) and a drag down tips the top toward the eye (the pitch falls).
96
+ */
97
+ export function drag(view, dx, dy, tilt = true, degreesPerPixel = 0.4) {
98
+ return clampView({ ...view, yaw: view.yaw - dx * degreesPerPixel, pitch: tilt ? view.pitch - dy * degreesPerPixel * 0.75 : view.pitch });
99
+ }
100
+ const RAD = Math.PI / 180;
101
+ /** Where a point of the scene falls on the screen, in pixels from the middle of the container, when the scene is placed as given and the eye is `distance` pixels away. */
102
+ export function project(point, view, at, distance) {
103
+ const k = at.k * view.zoom;
104
+ const [x, y, z] = [point[0] * k, point[1] * k, point[2] * k];
105
+ const yaw = view.yaw * RAD;
106
+ const pitch = view.pitch * RAD;
107
+ const x2 = x * Math.cos(yaw) - y * Math.sin(yaw);
108
+ const y2 = x * Math.sin(yaw) + y * Math.cos(yaw);
109
+ const y3 = y2 * Math.cos(pitch) - z * Math.sin(pitch);
110
+ const z3 = y2 * Math.sin(pitch) + z * Math.cos(pitch);
111
+ const X = x2 + at.tx;
112
+ const Y = y3 + at.ty;
113
+ // A point at or behind the eye cannot be seen: it is pushed to the edge of the world instead of flipping.
114
+ const f = distance / Math.max(distance - z3, distance * 0.05);
115
+ return [X * f, Y * f, f];
116
+ }
117
+ /** The corners of a box. */
118
+ const corners = (b) => [b.x0, b.x1].flatMap((x) => [b.y0, b.y1].flatMap((y) => [b.z0, b.z1].map((z) => [x, y, z])));
119
+ /** The rectangle on the screen that a box covers. */
120
+ export function covered(b, view, at, distance) {
121
+ const shown = corners(b).map((c) => project(c, view, at, distance));
122
+ return { x0: Math.min(...shown.map((p) => p[0])), x1: Math.max(...shown.map((p) => p[0])), y0: Math.min(...shown.map((p) => p[1])), y1: Math.max(...shown.map((p) => p[1])) };
123
+ }
124
+ /**
125
+ * The placement that fits the scene in a container of width `w` and height `h` pixels, centred, with `pad` of its width and height left round it. The
126
+ * perspective bends the sum, so it is found by a few rounds of scaling and re-centring; six is plenty.
127
+ */
128
+ export function fit(b, view, w, h, distance, pad = 0.03) {
129
+ const at = { k: 0.5, tx: 0, ty: 0 };
130
+ const flat = { ...view, zoom: 1 };
131
+ for (let i = 0; i < 8; i += 1) {
132
+ const r = covered(b, flat, at, distance);
133
+ const cw = r.x1 - r.x0;
134
+ const ch = r.y1 - r.y0;
135
+ if (cw <= 0 || ch <= 0)
136
+ break;
137
+ at.k *= Math.min((w * (1 - 2 * pad)) / cw, (h * (1 - 2 * pad)) / ch);
138
+ const c = covered(b, flat, at, distance);
139
+ at.tx -= (c.x0 + c.x1) / 2;
140
+ at.ty -= (c.y0 + c.y1) / 2;
141
+ }
142
+ return at;
143
+ }
144
+ /** Two matrices as one: `b` first, then `a`. */
145
+ export function multiply(a, b) {
146
+ const out = new Array(16).fill(0);
147
+ for (let col = 0; col < 4; col += 1)
148
+ for (let row = 0; row < 4; row += 1)
149
+ for (let k = 0; k < 4; k += 1)
150
+ out[col * 4 + row] += a[k * 4 + row] * b[col * 4 + k];
151
+ return out;
152
+ }
153
+ const translation = (x, y, z) => [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1];
154
+ /**
155
+ * The matrix that puts a point of the scene on the screen for a view in a placement: the scene (whose middle is the origin) is scaled, turned about the vertical,
156
+ * tipped back, shifted to where the fit puts it, and seen with a perspective `distance` pixels deep. This is `project`'s arithmetic as one matrix, so that an
157
+ * element can be given its whole place in one `matrix3d` and need no 3D context of the browser's: a browser that draws nested 3D layers flat still draws it right.
158
+ */
159
+ export function cameraMatrix(view, at, distance) {
160
+ const k = at.k * view.zoom;
161
+ const [yaw, pitch] = [view.yaw * RAD, view.pitch * RAD];
162
+ const [cy, sy, cp, sp] = [Math.cos(yaw), Math.sin(yaw), Math.cos(pitch), Math.sin(pitch)];
163
+ const scale = [k, 0, 0, 0, 0, k, 0, 0, 0, 0, k, 0, 0, 0, 0, 1];
164
+ const rotateZ = [cy, sy, 0, 0, -sy, cy, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
165
+ const rotateX = [1, 0, 0, 0, 0, cp, sp, 0, 0, -sp, cp, 0, 0, 0, 0, 1];
166
+ const eye = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1 / distance, 0, 0, 0, 1];
167
+ let m = multiply(eye, translation(at.tx, at.ty, 0));
168
+ m = multiply(m, rotateX);
169
+ m = multiply(m, rotateZ);
170
+ return multiply(m, scale);
171
+ }
172
+ const num = (value) => String(Math.round(value * 10000) / 10000);
173
+ /** A matrix as the CSS `transform` that applies it. */
174
+ export const matrix3d = (m) => `matrix3d(${m.map(num).join(",")})`;
175
+ /** How far a point is from the eye's plane after the scene is turned and tipped, in pixels towards the eye: bigger is nearer. Planes are drawn far first. */
176
+ export function depthOf(point, view, at) {
177
+ const k = at.k * view.zoom;
178
+ const [x, y, z] = [point[0] * k, point[1] * k, point[2] * k];
179
+ const yaw = view.yaw * RAD;
180
+ const y2 = x * Math.sin(yaw) + y * Math.cos(yaw);
181
+ return y2 * Math.sin(view.pitch * RAD) + z * Math.cos(view.pitch * RAD);
182
+ }
183
+ /** How far the eye is from the screen, in pixels, for a container: a long lens, so that the floor keeps its shape and the heights lean a little. */
184
+ export const eyeDistance = (w, h, lens = 1.7) => lens * Math.max(w, h);
@@ -0,0 +1,40 @@
1
+ import { type TurnPreset, type TurnView } from "./turn.camera.ts";
2
+ import { type TurnSettings } from "./turn.model.ts";
3
+ import type { ScoreOptions, SurfaceOptions } from "./types.ts";
4
+ /** What `mountKyogijoTurn` gives back. */
5
+ export interface KyogijoTurn {
6
+ /** `3d`, or `flat` where the browser cannot draw the 3D view (or there is nothing to turn): the flat drawing is shown and the rest of this does nothing. */
7
+ readonly mode: "3d" | "flat";
8
+ /** The view now: where it is going if it is gliding. */
9
+ view(): TurnView;
10
+ /** Turn to a view (the parts of it given): it glides there unless `glide` is false or the reader prefers reduced motion. */
11
+ set(view: Partial<TurnView>, glide?: boolean): void;
12
+ /** Go to one of the four viewpoints: `overhead`, `broadcast`, `end` or `corner`. */
13
+ preset(name: TurnPreset): void;
14
+ /** Back to the opening view. */
15
+ reset(): void;
16
+ /** Draw again with new options (a score that moved, a look that changed), keeping the view. */
17
+ update(options: SurfaceOptions | ScoreOptions): void;
18
+ /** The flat drawing that is the floor, or `null` after `destroy`. */
19
+ svg(): SVGSVGElement | null;
20
+ /** Stop listening and empty the container. */
21
+ destroy(): void;
22
+ }
23
+ /** True where the page can draw a plane in 3D by one `matrix3d`: that is, nearly everywhere with a stylesheet. */
24
+ export declare function turnSupported(win?: {
25
+ CSS?: {
26
+ supports?: (property: string, value: string) => boolean;
27
+ } | null;
28
+ } | undefined): boolean;
29
+ /**
30
+ * Mount a surface as a 3D view in a container, over the static drawing it would otherwise hold: the drawing is the floor, tilted and turned by the pointer, the
31
+ * touch, the wheel and the keys, with what stands on the surface (a net and its posts, a basket, a goal, the posts of a football field) standing on it.
32
+ * @example
33
+ * ```ts no-run
34
+ * import { mountKyogijoTurn } from "@johnmorrisdotca/kyogijo-stadiums/turn";
35
+ * const view = mountKyogijoTurn(document.querySelector("#court")!, { sport: "volleyball", home: { name: "Harbour City Gulls", score: 3 }, away: { name: "Prairie Ridge Bison", score: 2 } }, { preset: "end" });
36
+ * view.preset("corner");
37
+ * view.set({ yaw: 60, pitch: 40 });
38
+ * ```
39
+ */
40
+ export declare function mountKyogijoTurn(host: HTMLElement, options: SurfaceOptions | ScoreOptions, settings?: TurnSettings): KyogijoTurn;