@johnmorrisdotca/kyogijo-stadiums 0.12.1 → 0.13.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ All notable changes to this project are written here. The format follows
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.13.0] - 2026-10-20
11
+
12
+ ### Added
13
+
14
+ - **Tournament layouts in 3D** (`mountMultiTurn`, `multiTurnMarkup`, `buildMultiTurn` and `multiPresets` of `@johnmorrisdotca/kyogijo-stadiums/multi`). A layout can be turned like any surface: the same four viewpoints (overhead, broadcast, end-on and low corner), turn, tilt, zoom, reset and auto-turn, the same drag, keys and pinch, and the steady camera of 0.12.2 (a fixed scale for the whole turn, ten-decimal matrices, the lens of 8), with the whole floor fitted at every angle. It is the 3D view and not a second renderer: the layout is built as a `TurnModel`, so the camera, the controls and the tests are the ones every surface has (`mountKyogijoTurn` is now `mountTurn` over `buildTurn`, and `mountMultiTurn` is `mountTurn` over `buildMultiTurn`; `TurnModel` has `presets` and `flat` for a model with viewpoints and a flat drawing of its own). Each surface stands as it does on its own page and in its own cell (`uprightsFor`, moved and turned with the cell, and with the hall when the hall turns the layout): the nets and posts of every net sport and a table tennis table as a top 76 cm over the floor on its skirt and legs, with the table's own drawing on it and a soft shadow on the floor, each table's parts drawn in the right order from every side. What only a layout has is stood up from the figures the flat drawing draws: a surround of 75 cm round each area (the ITTF Handbook, 3.2.3.3), in pieces of at most 3 m, that gives way a little only to an eye low on its side (`Plane.fadeAt`); an umpire's chair and a score table as solid blocks; the scoreboard hung over the middle of the floor and facing the eye, and one at each surface where the layout has them. With `stadium` the stands of the hall are raised on the floor's ground (`standsVenueOf`, the same planes `standsVenue` makes for one surface), with a roof on request. The viewpoints are turned to the layout: a net sport's end-on view looks along its surfaces, and a floor taller than it is wide is turned a quarter so that its long way runs across the screen. The heights of the chairs, the tables and the scoreboard are ours (no rule gives them); the table's, the net's and the surround's are the rulebook's.
15
+ - **`halls.html` has the 3D view.** A View choice (`2D` or `3D`, `view=3d` in the address), the viewpoint in the address (`viewpoint=`), the roof of the stadium (`roof=1`) and the 3D view's own controls under the floor; a layout chosen in 3D opens on the viewpoint chosen. Try it: <https://johnmorrisdotca.github.io/kyogijo-stadiums/halls.html?preset=tabletennis-4&view=3d>.
16
+ - **Docs and README.** A section "In 3D" on [the layouts page](./docs/multi.md#in-3d) with a picture of a layout in 3D (four table tennis areas, light and dark); the same picture in the README's layouts section.
17
+ - **Japanese**, two phrases for the parts named in a layout's 3D description: `競技エリアのフェンス` (the competition area's fence) and `審判席と記録台` (the umpires' chairs and the score tables).
18
+
19
+ ### Changed
20
+
21
+ - `multiDrawing(options, raise)` (internal to `multi.draw.ts`) is the drawing of a layout with what was worked out to make it; `drawMulti` is its string. A layout made as the floor of a 3D view leaves out what the 3D view stands up. The drawn picture is unchanged.
22
+
23
+ ### Tests
24
+
25
+ - The size-steadiness test (`src/turn.size.test.ts`) and the camera-fit test (`src/turn.camera.test.ts`) now run on every tournament layout, alone and in a stadium, in place of four layouts used as a plain floor; the depth-order and whole-floor tests of 0.12.2 (`src/turn.raised.test.ts`) run on the tables of the table tennis layouts and on the floor and stands of five layouts at every turn and tip, desk and phone; `src/multi.turn.test.ts` holds each surface to its cell (also in a hall that turns the layout), the surrounds, chairs, scoreboards and stands, the viewpoints and the markup; `e2e/halls.demo.mjs` plays the layouts page in 3D in a real browser (the controls, the address, a full turn's size, the legs under each table's top, the stadium and its roof, Japanese, a phone).
26
+
27
+ ## [0.12.2] - 2026-10-20
28
+
29
+ ### Added
30
+
31
+ - **The demo leads to the tournament layouts.** A "Tournament layouts" link in the demo's header; under the surface of a sport that has layouts (table tennis, pickleball, curling, judo, karate, badminton, tennis) a "See it as a tournament floor" link to `halls.html` with that sport's first layout chosen (and the page's language and theme); and a link back to the demo from `halls.html`. `halls.html` also takes `theme=light|dark` in its address.
32
+
33
+ ### Fixed
34
+
35
+ - **A dohyō in the 3D view is a solid block, not a hollow tray, and the floor round it is not cut off.** The whole floor was lifted to the mound's height and always drawn under the mound's four walls, so the walls on the far side showed over the clay and the clay looked sunk in a tray, with the grey hall floor raised level with it. Now the floor lies on the hall's floor, the mound is four sides (a tone darker than the top) and a flat top (the drawing's own clay and straw bales, cropped to the mound's square and lifted to its height), and the sides on the far side are drawn before the top and the ones on the near side after it at every turn. The view is fitted to the whole floor, so no part of it is cut off at any angle, and the stands of a crowd stand on the hall's floor.
36
+ - **A table tennis table's far legs no longer show through its top, and its legs stand on something.** The raised floor (the table's top) was always drawn under every plane, so the legs and skirt on the far side were drawn over it. A raised floor now takes its turn among the planes by its middle, like any other, and a soft shadow under the table on the hall's floor seats the legs.
37
+ - **The 3D view no longer swells and shrinks as it turns.** A surface going round, by hand or by the auto-turn, grew and shrank rhythmically, and in steps, instead of turning smoothly. There were two causes, both in the camera. The matrix written to each plane (`matrix3d`) rounded every number to four decimals, but its perspective terms are a few ten-thousandths and are multiplied by the pixels of a whole floor, so the rounding bent the perspective by tens of percent and by jumps as the angle changed (a floor's area on the screen jumped by up to a quarter between two views a few degrees apart); the numbers are now written to ten decimals. And the lens was short (1.7 times the box's longer side), so the nearer end of the floor swelled as it swung toward the eye (about a tenth of the area over a turn); the default is now 8 (`lens` still takes any value, and a smaller one brings the swelling back). The scale and the centre were already one for the whole turn (0.10.0); now the floor's area on the screen varies by about one percent over a turn, smoothly, for every sport and a tournament layout used as a floor, light and dark, desk and phone. New tests (`src/turn.size.test.ts`, and one in `e2e/turn.demo.mjs` in a real browser) sample the floor's area over a full turn, as the browser draws the written matrix, and fail on the old camera.
38
+
10
39
  ## [0.12.1] - 2026-10-19
11
40
 
12
41
  The npm page shows the tournament layouts. No change to the package's code.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <h1 align="center">Kyogijo Stadiums <sub>競技場</sub></h1>
2
2
 
3
3
  <p align="center"><strong>Sports surfaces as SVG, drawn to scale, with the score on them.</strong><br>
4
- The NFL, CFL and IFAF football fields, the NHL rink, the NBA court, the soccer pitch and futsal court, the baseball field of every MLB ballpark, current and past, and every NPB home park, the rink and court of 167 NHL, NBA, WNBA and PWHL arenas, and the surfaces of curling, athletics, speed, short track and figure skating, swimming, water polo, diving, artistic swimming, tennis, volleyball (indoor, beach and sitting), badminton, pickleball, table tennis, padel, squash, racquetball, sepak takraw, teqball, roundnet, netball, lacrosse, rugby, Australian football, Gaelic games, cricket, field hockey, handball, judo, karate, kendo, sumo, kyūdō and a dojo of tatami, thirty-nine sports in all, each drawn from its rulebook or its published distances, with each team's name and logo on its side and the score in the middle, a lineup and the situation of the game on them, with stands and a crowd, a pageant of flags and a 3D view. Wide or tall, light or dark, a compact badge for a list, a helper for React, a custom element and a frame for a page that runs no script. One function, no dependencies.</p>
4
+ The NFL, CFL and IFAF football fields, the NHL rink, the NBA court, the soccer pitch and futsal court, the baseball field of every MLB ballpark, current and past, and every NPB home park, the rink and court of 167 NHL, NBA, WNBA and PWHL arenas, and the surfaces of curling, athletics, speed, short track and figure skating, swimming, water polo, diving, artistic swimming, tennis, volleyball (indoor, beach and sitting), badminton, pickleball, table tennis, padel, squash, racquetball, sepak takraw, teqball, roundnet, netball, lacrosse, rugby, Australian football, Gaelic games, cricket, field hockey, handball, judo, karate, kendo, sumo, kyūdō and a dojo of tatami, thirty-nine sports in all, each drawn from its rulebook or its published distances, with each team's name and logo on its side and the score in the middle, a lineup and the situation of the game on them, with stands and a crowd, a pageant of flags and a 3D view. Wide or tall, light or dark, a badge for a list, a helper for React, a custom element and a frame for a page that runs no script. One function, no dependencies.</p>
5
5
 
6
6
  <p align="center">
7
7
  <a href="https://github.com/johnmorrisdotca/kyogijo-stadiums/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/johnmorrisdotca/kyogijo-stadiums/actions/workflows/ci.yml/badge.svg"></a>
@@ -72,10 +72,10 @@ console.log(svg.startsWith("<svg"), svg.includes("USA 3, Canada 2"));
72
72
 
73
73
  ## Features
74
74
 
75
- - **Thirty-nine surfaces, to scale.** The NFL, CFL and IFAF fields, the NHL rink, the NBA court, the soccer pitch and futsal court, the baseball field, the curling sheet, the courts of tennis, volleyball (beach and sitting), badminton, pickleball, table tennis, padel, squash, racquetball, sepak takraw, teqball, roundnet and netball, the pools, the athletics stadium, the skating rinks, the fields of lacrosse, rugby, Australian football, Gaelic games, cricket, field hockey and handball, and the budō, with the lines, circles, keys, boxes and goals of each. Every figure is cited in [sources](./docs/sources.md). [The surfaces](./docs/surfaces.md).
75
+ - **Thirty-nine surfaces, to scale.** The NFL, CFL and IFAF fields, the NHL rink, the NBA court, the soccer pitch and futsal court, the baseball field, the curling sheet, the courts of tennis, volleyball (beach and sitting), badminton, pickleball, table tennis, padel, squash, racquetball, sepak takraw, teqball, roundnet and netball, the pools, the athletics stadium, the skating rinks, the fields of lacrosse, rugby, Australian football, Gaelic games, cricket, field hockey and handball, and the budō. Every figure is cited in [sources](./docs/sources.md). [The surfaces](./docs/surfaces.md).
76
76
  - **Each league's rulebook.** `league: "fiba"` draws a court as FIBA marks it: 48 variants, from the WNBA, the NCAA and the IIHF to Little League, PONY, softball, Curling Canada, FIVB's beach volleyball, rugby league and the NLL's box lacrosse, each cited. [League variants](./docs/variants.md).
77
77
  - **A realistic basketball floor.** `court: { hardwood: true }` draws maple boards that run the length of the court with staggered ends, grain and tone, stained keys, circle and border, a strip behind each baseline in the team's colour, the baskets and stanchions with soft shadows from above, a coaching box and benches, and a satin sheen, in every league and every renderer, with the detail dropping at small sizes. The clean floor stays the default. [Hardwood](./docs/hardwood.md).
78
- - **The stands and the crowd.** `crowd: true` draws the seating round any surface that has spectators: a bowl, two sides, a horseshoe, an arena's courtside rows, or a ballpark's grandstands and bleachers laid behind the park's own fence, with the people as a seeded pattern of heads and shoulders in the home colours, the visitors at an end, the empty seats showing (`density`, or `attendance` over `capacity`), a card display on request, and a soccer pitch inside a gridiron stadium's footprint, to scale. A few kB of patterns, blocks at small sizes, every renderer, and the stands' rings, heights and rake as data. [The crowd](./docs/crowd.md).
78
+ - **The stands and the crowd.** `crowd: true` draws the seating round any surface that has spectators: a bowl, two sides, a horseshoe, an arena's courtside rows, or a ballpark's grandstands and bleachers, with the people as seeded heads and shoulders in the home colours, the visitors at an end, the empty seats showing (`density`, or `attendance` over `capacity`), and a soccer pitch inside a gridiron stadium's footprint, to scale. Blocks at small sizes; the stands as data. [The crowd](./docs/crowd.md).
79
79
  - **Curling, from the rule books.** A sheet from World Curling's and Curling Canada's rules, tall by default, with the board and the hammer in a score, `curlingStones` for the stones of an end, scored by the rules, `show: "folded"` for the whole sheet with both houses enlarged beside it in a square, and a heat map and statistics (free guards, hammer, steals, shots) for many ends. [Curling](./docs/curling.md).
80
80
  - **Net, racket and court sports, from their rulebooks.** The ITF's court, the FIVB's indoor and beach courts, World ParaVolley's sitting volleyball court, the BWF's, USA Pickleball's, the ITTF's table, the FIP's padel court, World Squash's courts (with the front wall laid flat beside the floor), the IRF's racquetball court, the ISTAF's sepak takraw court, the FITEQ's teqball court and table, the Roundnet Federation's court and World Netball's court, each in its look (hard court, clay, grass, wood, sand), with a board of sets and games and a ball beside the server. [Net, racket and court sports](./docs/courts.md).
81
81
  - **Swimming, water polo, diving and artistic swimming, from World Aquatics' regulations.** The competition pool of 50 or 25 m with its lanes, ropes, blocks, touch panels and flags; the water polo field; the diving well with its springboards and platforms; the artistic swimming area; several pools in a natatorium. The lanes of a race carry names, flags, places, times and splits, with a race replay by lane (`raceTimeline`) and a `splitsChart`. [Pools](./docs/pools.md).
@@ -85,7 +85,7 @@ console.log(svg.startsWith("<svg"), svg.includes("USA 3, Canada 2"));
85
85
  - **The budō, from the federations' rules.** The IJF's and the All Japan Judo Federation's judo areas, the WKF's karate areas, the kendo shiai-jo, the sumo dohyō, the kyūdōjō, and **a dojo builder**: a floor of tatami laid as real units (no four corners meet), in jō or metres, with the walls, doors, windows, shrine and kamiza. Five famous halls are on the atlas, each with only what a source gives, and the scores are judo's ippon, waza-ari and shido, karate's points, kendo's points and sumo's kimarite. [The budō](./docs/budo.md).
86
86
  - **Soccer, to the Laws.** A pitch from Law 1 of the IFAB Laws of the Game of any size, with presets (international, UEFA, MLS, NCAA, the FA's 9-, 7- and 5-a-side, FIFA's futsal), half pitches, five mowing patterns, four goal styles, penalties and extra time in a score. [Soccer](./docs/soccer.md).
87
87
  - **Every ballpark.** The 30 current MLB parks and 44 that MLB clubs have left (the Polo Grounds, Ebbets Field, the Astrodome and more), and the 12 home parks of Nippon Professional Baseball with eight other NPB grounds, each with its fence drawn from the distances published for it; a past park whose fence moved is drawn as it stood in a season. [Ballparks](./docs/ballparks.md).
88
- - **Soccer grounds, arenas and an atlas.** 64 soccer grounds, each pitch at its published size, and 167 NHL, NBA, WNBA and PWHL arenas (`drawKyogijo({ sport: "nhl", arena: "boston-garden" })`), a rink or a court at the arena's own size where an article gives one, and every park, ground, arena and budō hall (330 places) on a map, by sport, league, country and year, each found by any name it has in English, Japanese or its own language (`Koshien Stadium` is also `甲子園`, `San Siro` is `サン・シーロ`). [The grounds](./docs/grounds.md), [the arenas](./docs/arenas.md), [the atlas](./docs/atlas.md), [names](./docs/ballparks.md#names).
88
+ - **Soccer grounds, arenas and an atlas.** 64 soccer grounds, each pitch at its published size, and 167 NHL, NBA, WNBA and PWHL arenas (`drawKyogijo({ sport: "nhl", arena: "boston-garden" })`), a rink or court at the arena's own size where known, and every park, ground, arena and budō hall (330 places) on a map, by sport, league, country and year, each found by any of its names. [The grounds](./docs/grounds.md), [the arenas](./docs/arenas.md), [the atlas](./docs/atlas.md), [names](./docs/ballparks.md#names).
89
89
  - **Walls and quirks.** How high the fence stands, stretch by stretch and season by season (the Green Monster at 37 feet 2 inches, the Crawford Boxes, the Baggie), drawn as a band outside the fence whose width and shade say the height, with a key (`walls`); and Tal's Hill, Wrigley Field's ivy and basket, overhangs, poles, bullpens, the backstop and the dugouts (`quirks`), each from the park's article, none guessed: [ballparks](./docs/ballparks.md).
90
90
  - **Special games.** A surface set inside another, to scale: an NHL rink on a ballpark's infield or a football stadium's field (the Winter Classic, the Stadium Series, the Heritage Classic), a college basketball court on the deck of a carrier, a baseball field laid over a London stadium's pitch. 18 games, each with its day, its venue and its sources, and the place of the rink cited where a source gives it and marked as a convention where none does. [Special games](./docs/special-games.md).
91
91
  - **Surfaces through the years.** `year: 1975` draws a surface as its league's rules marked it that season, each change cited. [Surfaces through the years](./docs/eras.md).
@@ -103,7 +103,7 @@ console.log(svg.startsWith("<svg"), svg.includes("USA 3, Canada 2"));
103
103
  - **Small multiples and backgrounds.** `drawGrid` puts many drawings in one SVG, under a title and a subtitle, over a credit line, with a key they share, in a size for a social card, a square post or a phone; `background` lays a quiet pattern (felt, grass, wood, ice, paper, a grid, dots) or a photograph behind a drawing or a grid. [Layouts and backgrounds](./docs/layouts.md).
104
104
  - **Tournament layouts.** Several surfaces laid out together for one large event, to scale, on one floor, as one SVG: thirteen presets from table tennis, pickleball, curling, judo, karate, badminton and tennis, each with its rule and sources, whether it fits a hall, and a real stadium round it. [Tournament layouts](./docs/multi.md).
105
105
  - **Replay.** Tracking data played on any surface: the players with their numbers, the ball and its trail, and the passes, shots and goals as they happen, with controls, the keyboard and a live region, steps for a reader who prefers reduced motion, and a pause when the page is hidden. [Replay](./docs/replay.md).
106
- - **A 3D view.** Any surface as a floor that turns by mouse, touch, wheel or keys, with four viewpoints (overhead, broadcast, end-on, low corner), and what the rulebook stands on it at its height: nets, antennae, baskets, rink boards and glass, goals, posts, stumps, a ballpark's fence, the walls of padel and squash, a pool's blocks, a diving well's platforms, a jump's bar, hurdles; and the venue round it (the raked stands with the people on them, roofs on request, a dojo's walls and gallery). Plain DOM and CSS over the same SVG. [The 3D view](./docs/turn.md).
106
+ - **A 3D view.** Any surface as a floor that turns by mouse, touch, wheel or keys, with four viewpoints (overhead, broadcast, end-on, low corner), and what the rulebook stands on it at its height: nets, antennae, baskets, rink boards and glass, goals, posts, stumps, a ballpark's fence, the walls of padel and squash, a pool's blocks, hurdles; and the venue round it (raked stands, roofs on request, a dojo's walls and gallery). Plain DOM and CSS over the same SVG. [The 3D view](./docs/turn.md).
107
107
  - **Renderers.** The same drawing as plain data (a scene), on a canvas (a browser's or a Node canvas), in a d3 selection, as a mark of an Observable Plot, as GeoJSON and as a PNG in Node, each an entry of its own that imports nothing from outside the package. [Renderers](./docs/renderers.md).
108
108
  - **Units and frames.** Each surface in its rulebook's unit and any other, and 48 coordinate frames (ten soccer providers, the NHL API, HockeyTech, NBA stats, NFL tracking, MLBAM, Retrosheet, a curling stone's place from the button, a place from the net in each net sport (from the centre of the court in squash, racquetball, roundnet and netball), the centre of each field sport's surface, the middle of the water of each pool, the middle of the athletics stadium and of each skating rink) to move a provider's points onto a surface. [Units](./docs/units.md), [coordinate frames](./docs/frames.md).
109
109
  - **A compact badge and a compact card.** One strip for a list, or the surface with that strip under it.
@@ -494,7 +494,7 @@ console.log(svg.includes('viewBox="0 0 1200 675"'), svg.includes("Three ballpark
494
494
 
495
495
  ### Several surfaces on one floor
496
496
 
497
- For a large event that runs many contests at once: `drawMulti` lays the package's own surfaces out together, to scale, on one floor, with the officials' chairs, the boards along the edges and empty places for the event's own words and marks ([tournament layouts](./docs/multi.md)). Thirteen presets, each with its rule and sources, from table tennis to judo and karate; `multiFit` says whether a layout fits a hall, and `stadium: true` sets it inside real stands.
497
+ `drawMulti` lays the package's own surfaces out together for one large event, to scale, on one floor, with the officials' chairs, the boards and empty places for the event's words and marks ([tournament layouts](./docs/multi.md)). Thirteen presets with their rules and sources; `multiFit` says whether a layout fits a hall, `stadium: true` sets it inside real stands, and `mountMultiTurn` turns the floor in 3D.
498
498
 
499
499
  ```ts
500
500
  import { drawMulti, multiLayout } from "@johnmorrisdotca/kyogijo-stadiums/multi";
@@ -523,7 +523,15 @@ console.log(layout.needs.length, layout.needs.width);
523
523
  <br><em>Four table tennis areas under one scoreboard.</em>
524
524
  </p>
525
525
 
526
- Each surface is the one `drawKyogijo` draws, so nothing is drawn a second way; the [demo](https://johnmorrisdotca.github.io/kyogijo-stadiums/halls.html) picks a preset, sets it in a hall and switches the stadium on and off.
526
+ <p align="center">
527
+ <picture>
528
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/kyogijo-stadiums/main/docs/images/multi-tabletennis-3d-desk-dark.webp">
529
+ <img src="https://raw.githubusercontent.com/johnmorrisdotca/kyogijo-stadiums/main/docs/images/multi-tabletennis-3d-desk-light.webp" alt="Four table tennis areas in 3D from a low corner: tables on legs, a surround round each, a hung scoreboard, and the 3D view's controls." width="640">
530
+ </picture>
531
+ <br><em>The same four in 3D.</em>
532
+ </p>
533
+
534
+ The [demo](https://johnmorrisdotca.github.io/kyogijo-stadiums/halls.html) picks a preset, sets it in a hall, switches the stadium on and off, and turns it in 3D.
527
535
 
528
536
  ### The element in a page
529
537
 
@@ -1,4 +1,5 @@
1
1
  export { drawMulti, multiSetting, multiTable } from "./multi.draw.ts";
2
+ export { SURROUND_HEIGHT, buildMultiTurn, mountMultiTurn, multiPresets, multiTurnMarkup } from "./multi.turn.ts";
2
3
  export { MULTI_MAX, fitSentence, multiFit, multiLayout, needsSentence, specOf, venueOf } from "./multi.ts";
3
4
  export { MULTI_PRESETS, MULTI_PRESET_IDS, MULTI_SOURCES, MULTI_VENUES, multiPreset, multiSource, multiVenueById } from "./multi.data.ts";
4
5
  export { KYOGIJO_MULTI_STYLE } from "./multi.style.ts";
@@ -2,6 +2,7 @@
2
2
  // officials' chairs, a scoreboard hung over the middle, the boards and the empty places for the event's own words and marks; the real configurations of events as presets, each with its rule; the halls whose
3
3
  // floors are published, and whether a layout fits one; and a real stadium round the floor at the same scale. `multiTable` is the text alternative.
4
4
  export { drawMulti, multiSetting, multiTable } from "./multi.draw.js";
5
+ export { SURROUND_HEIGHT, buildMultiTurn, mountMultiTurn, multiPresets, multiTurnMarkup } from "./multi.turn.js";
5
6
  export { MULTI_MAX, fitSentence, multiFit, multiLayout, needsSentence, specOf, venueOf } from "./multi.js";
6
7
  export { MULTI_PRESETS, MULTI_PRESET_IDS, MULTI_SOURCES, MULTI_VENUES, multiPreset, multiSource, multiVenueById } from "./multi.data.js";
7
8
  export { KYOGIJO_MULTI_STYLE } from "./multi.style.js";
@@ -1,4 +1,5 @@
1
- import type { MultiFit, MultiLayout, MultiOptions, MultiVenue } from "./multi.types.ts";
1
+ import { type Crowd, type CrowdStands } from "./crowd.ts";
2
+ import type { MultiCell, MultiFit, MultiLayout, MultiOptions, MultiVenue } from "./multi.types.ts";
2
3
  /**
3
4
  * A tournament layout as one SVG string: several of the package's surfaces laid out together for one large event, to scale, on one floor. `preset` is one of `MULTI_PRESETS` (`tabletennis-4`, `pickleball-2x4`,
4
5
  * `curling-1x4`, `judo-1x3`, `karate-2x3`, `badminton-1x4`, ...), or `layout` is your own; `rows`, `columns` and `stagger` change the grid. The empty places for the event's words and marks are drawn dashed and hold nothing.
@@ -13,6 +14,61 @@ import type { MultiFit, MultiLayout, MultiOptions, MultiVenue } from "./multi.ty
13
14
  * ```
14
15
  */
15
16
  export declare function drawMulti(options?: MultiOptions): string;
17
+ /** Where the layout stands in the picture, so that something else can be put in the same frame (the 3D view's planes): the hall's size, where the layout is set in it, and the map from the layout's own frame to the picture's. */
18
+ export interface MultiFrame {
19
+ layout: MultiLayout;
20
+ /** The hall's size and the layout's size as set in it (turned a quarter when the hall asks), in feet; the layout's top left corner is at (`ox`, `oy`). */
21
+ hall: {
22
+ w: number;
23
+ h: number;
24
+ };
25
+ lw: number;
26
+ lh: number;
27
+ ox: number;
28
+ oy: number;
29
+ turned: boolean;
30
+ /** A point of the layout's own frame (feet from the top left of its floor) in the picture's frame. */
31
+ to(x: number, y: number): [number, number];
32
+ }
33
+ /** A layout's drawing, and what was worked out to make it. */
34
+ export interface MultiDrawing {
35
+ svg: string;
36
+ frame: MultiFrame;
37
+ fit: MultiFit | undefined;
38
+ /** The stands of the stadium round the hall, when it is on (in the picture's frame), and the crowd they are of. */
39
+ stands?: {
40
+ stands: CrowdStands;
41
+ crowd: Crowd;
42
+ standsLike: string;
43
+ };
44
+ /** For a drawing made to be raised (`raise`): the surfaces that stand over the floor (a table tennis table), each with its cell and its own drawing, which the floor does not carry. */
45
+ lifted: {
46
+ cell: MultiCell;
47
+ body: string;
48
+ box: {
49
+ x: number;
50
+ y: number;
51
+ w: number;
52
+ h: number;
53
+ };
54
+ lift: number;
55
+ }[];
56
+ /** The width and height of the picture and where it starts, in feet (its viewBox). */
57
+ view: {
58
+ x: number;
59
+ y: number;
60
+ w: number;
61
+ h: number;
62
+ };
63
+ title: string;
64
+ description: string;
65
+ }
66
+ /**
67
+ * The drawing of a layout, with what it was worked out from. `raise` makes the floor of a 3D view instead of the flat picture: the barriers, the officials' chairs, the scoreboard and the stands are left out (the 3D
68
+ * view stands them up), and a surface that stands over the floor (a table tennis table) is left off it too, with a soft shadow in its place. Everything else is the same string. With `uprights` false the 3D view stands
69
+ * nothing but the stands up, so the barriers and the rest stay on the floor.
70
+ */
71
+ export declare function multiDrawing(options: MultiOptions, raise: boolean, uprights?: boolean): MultiDrawing;
16
72
  /**
17
73
  * The same thing as the picture, as a table: each playing surface with its row, column, place and size in metres, and each empty place for the event's words and marks, under a caption that gives
18
74
  * what the layout needs. For a reader who cannot see the drawing, and for a page that wants the figures.
@@ -14,6 +14,7 @@ import { MULTI_WORDS } from "./multi.words.js";
14
14
  import { outlineOf } from "./outline.js";
15
15
  import { fill } from "./strings.js";
16
16
  import { textWidth } from "./text.js";
17
+ import { uprightsFor } from "./uprights.js";
17
18
  import { VERSION } from "./version.js";
18
19
  const metres = (ft) => ft / FEET_PER_METRE;
19
20
  const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
@@ -46,6 +47,14 @@ const floorClass = (layout) => (layout.spec.kind === "budo" ? "ky-bud-t2" : "ky-
46
47
  * ```
47
48
  */
48
49
  export function drawMulti(options = {}) {
50
+ return multiDrawing(options, false).svg;
51
+ }
52
+ /**
53
+ * The drawing of a layout, with what it was worked out from. `raise` makes the floor of a 3D view instead of the flat picture: the barriers, the officials' chairs, the scoreboard and the stands are left out (the 3D
54
+ * view stands them up), and a surface that stands over the floor (a table tennis table) is left off it too, with a soft shadow in its place. Everything else is the same string. With `uprights` false the 3D view stands
55
+ * nothing but the stands up, so the barriers and the rest stay on the floor.
56
+ */
57
+ export function multiDrawing(options, raise, uprights = true) {
49
58
  const o = options;
50
59
  const language = o.language === "ja" ? "ja" : "en";
51
60
  const words = MULTI_WORDS[language];
@@ -80,8 +89,13 @@ export function drawMulti(options = {}) {
80
89
  let style = "";
81
90
  let look;
82
91
  let cellsMarkup = "";
92
+ const lifted = [];
83
93
  const surfaceBox = outlineOf(spec.surface).box;
84
94
  const common = { ...spec.surface, margin: 0, language };
95
+ // A surface that stands over the floor (a table tennis table's top, 76 cm up) is raised by the 3D view as a plane of its own.
96
+ const up = raise && uprights;
97
+ const lift = up && spec.kind === "cells" ? uprightsFor(common).lift : 0;
98
+ const raised = lift > 0;
85
99
  if (spec.kind === "budo") {
86
100
  const drawn = inner(drawKyogijo({ ...common, id: `${gid}-s`, ...(o.style === "none" ? { style: "none" } : {}) }));
87
101
  style = drawn.style;
@@ -97,6 +111,13 @@ export function drawMulti(options = {}) {
97
111
  style = drawn.style;
98
112
  look = drawn.look;
99
113
  }
114
+ if (raised) {
115
+ // The floor has its shadow, soft and a little larger; the top is a plane of the 3D view.
116
+ const grow = 0.8;
117
+ cellsMarkup += el("rect", { class: "ky-mu-shadow", x: num(cell.x - grow / 2), y: num(cell.y - grow / 2), width: num(cell.w + grow), height: num(cell.h + grow), rx: num(grow) });
118
+ lifted.push({ cell, body: drawn.body, box: { x: surfaceBox.x, y: surfaceBox.y, w: surfaceBox.w, h: surfaceBox.h }, lift });
119
+ return;
120
+ }
100
121
  // A surface turned a quarter stands across the layout: the drawing's own top left goes to the cell's top right, and the drawing is turned.
101
122
  const place = cell.turn ? `translate(${num(cell.x + cell.w)} ${num(cell.y)}) rotate(90) translate(${num(-surfaceBox.x)} ${num(-surfaceBox.y)})` : `translate(${num(cell.x - surfaceBox.x)} ${num(cell.y - surfaceBox.y)})`;
102
123
  cellsMarkup += el("g", { class: "ky-mu-cell", "data-cell": cell.n, transform: place }, drawn.body);
@@ -106,10 +127,10 @@ export function drawMulti(options = {}) {
106
127
  let floorMarkup = "";
107
128
  floorMarkup += el("rect", { class: floorClass(layout), x: 0, y: 0, width: num(layout.floor.w), height: num(layout.floor.h) });
108
129
  let over = "";
109
- if (spec.parts.barriers === true)
130
+ if (!up && spec.parts.barriers === true)
110
131
  for (const c of layout.cells)
111
132
  over += el("rect", { class: "ky-mu-barrier", x: num(c.bay.x + 0.5), y: num(c.bay.y + 0.5), width: num(c.bay.w - 1), height: num(c.bay.h - 1), rx: 0.4 });
112
- if (spec.parts.officials === true) {
133
+ if (!up && spec.parts.officials === true) {
113
134
  for (const c of layout.cells) {
114
135
  if (c.turn) {
115
136
  // Beside the net, on the right of a surface that stands across the layout.
@@ -123,10 +144,10 @@ export function drawMulti(options = {}) {
123
144
  over += el("rect", { class: "ky-mu-desk", x: num(cx - 5), y: num(c.y - 3.1), width: 3.6, height: 1.1, rx: 0.2 });
124
145
  }
125
146
  }
126
- if (spec.parts.scoreboard === "each")
147
+ if (!up && spec.parts.scoreboard === "each")
127
148
  for (const c of layout.cells)
128
149
  over += el("rect", { class: "ky-mu-sb", x: num(c.x + c.w / 2 - 2), y: num(c.y + c.h + 1.2), width: 4, height: 1.4, rx: 0.2 });
129
- const sb = layout.shared;
150
+ const sb = up ? undefined : layout.shared;
130
151
  if (sb !== undefined) {
131
152
  over += el("rect", { class: "ky-mu-sb", x: num(sb.x), y: num(sb.y), width: num(sb.w), height: num(sb.h), rx: 0.5 });
132
153
  // One scoreboard for all: a quarter of it for each of four areas, or one panel for each when they are fewer or more.
@@ -186,6 +207,7 @@ export function drawMulti(options = {}) {
186
207
  let reach = { left: 0, right: 0, top: 0, bottom: 0 };
187
208
  let defs = "";
188
209
  let crowdStyle = "";
210
+ let standing;
189
211
  const wide = { x: 0, y: 0, w: hall.w, h: hall.h };
190
212
  const boards = layout.slots.filter((s) => s.kind === "board");
191
213
  const boardsMargin = withSlots && boards.length > 0 ? 5 : 0;
@@ -202,13 +224,18 @@ export function drawMulti(options = {}) {
202
224
  const standsLike = venue?.standsLike ?? spec.sport;
203
225
  const crowd = resolveCrowd({ gaps: false, awayEnd: "none", roof: stadium.roof, shape: stadium.shape, density: stadium.density, detail: stadium.detail === "plain" ? "plain" : "fine" });
204
226
  const stands = layoutOf({ sport: standsLike, box: wide, crowd, awaySide: "right", arena: venue?.shape === "octagon" });
205
- const density = stadium.crowd === false ? 0 : densityOf(crowd, stands.seats, undefined);
206
- const drawn = drawCrowd(stands, { id: `${gid}-cr`, crowd, density, fine: crowd.detail !== "plain", ground: "ky-mu-apron" });
207
- defs += drawn.defs;
208
227
  const wall = venue?.shape === "octagon" ? el("path", { class: "ky-mu-wall", d: octagonD(hall.w / 2, hall.w / 2, hall.w / 2) }) : el("rect", { class: "ky-mu-wall", x: 0, y: 0, width: num(hall.w), height: num(hall.h), rx: 0.5 });
209
- hallMarkup = drawn.markup + hallMarkup + wall;
228
+ if (raise)
229
+ hallMarkup += wall;
230
+ else {
231
+ const density = stadium.crowd === false ? 0 : densityOf(crowd, stands.seats, undefined);
232
+ const drawn = drawCrowd(stands, { id: `${gid}-cr`, crowd, density, fine: crowd.detail !== "plain", ground: "ky-mu-apron" });
233
+ defs += drawn.defs;
234
+ hallMarkup = drawn.markup + hallMarkup + wall;
235
+ crowdStyle = KYOGIJO_CROWD_STYLE;
236
+ }
210
237
  reach = stands.reach;
211
- crowdStyle = KYOGIJO_CROWD_STYLE;
238
+ standing = { stands, crowd, standsLike };
212
239
  }
213
240
  else if (venue !== undefined) {
214
241
  hallMarkup += el("rect", { class: "ky-mu-hall", x: 0, y: 0, width: num(hall.w), height: num(hall.h) });
@@ -267,7 +294,8 @@ export function drawMulti(options = {}) {
267
294
  "data-theme": o.theme === "light" || o.theme === "dark" ? o.theme : undefined,
268
295
  "data-version": VERSION,
269
296
  }, `<title id="${titleId}">${esc(title)}</title><desc id="${descId}">${esc(description)}</desc>` + css + (defs === "" ? "" : `<defs>${defs}</defs>`) + el("rect", { class: "ky-mu-apron", x: num(view.x), y: num(view.y), width: num(vw), height: num(vh) }) + hallLayer + group + overhang + slotTexts + labelsMarkup);
270
- return root;
297
+ const frame = { layout, hall, lw, lh, ox, oy, turned, to };
298
+ return { svg: root, frame, fit, ...(standing === undefined ? {} : { stands: standing }), lifted, view: { x: view.x, y: view.y, w: vw, h: vh }, title, description };
271
299
  }
272
300
  /** Where an empty place is, in words: the surface it belongs to, the side or end it is at, and whether it is on the mats. */
273
301
  function slotWhere(slot, layout, words) {
@@ -6,8 +6,8 @@ const FLOORS = {
6
6
  red: { light: ["#b3362b", "#fdf3f1"], dark: ["#7a241d", "#f3d8d4"] },
7
7
  ice: { light: ["#e4eef5", "#1d2b36"], dark: ["#a9bccb", "#10181f"] },
8
8
  };
9
- const COMMON_LIGHT = "--ky-mu-neutral:#bdb9ad;--ky-mu-barrier:#161a1f;--ky-mu-board:#1d2430;--ky-mu-board-ink:#f4f1ea;--ky-mu-chair:#ece7da;--ky-mu-chair-edge:#4a4f56;--ky-mu-sb:#10151b;--ky-mu-sb-ink:#f6f6f6;--ky-mu-wall:#3a4048;--ky-mu-hall:#d9d5c8;--ky-mu-over:#c0392b";
10
- const COMMON_DARK = "--ky-mu-neutral:#2b2f2c;--ky-mu-barrier:#05070a;--ky-mu-board:#0d1218;--ky-mu-board-ink:#e8e4da;--ky-mu-chair:#b9b4a6;--ky-mu-chair-edge:#050607;--ky-mu-sb:#05080b;--ky-mu-sb-ink:#e9e9e9;--ky-mu-wall:#0a0c0f;--ky-mu-hall:#1b1f1c;--ky-mu-over:#e0614f";
9
+ const COMMON_LIGHT = "--ky-mu-neutral:#bdb9ad;--ky-mu-barrier:#161a1f;--ky-mu-board:#1d2430;--ky-mu-board-ink:#f4f1ea;--ky-mu-chair:#ece7da;--ky-mu-chair-edge:#4a4f56;--ky-mu-sb:#10151b;--ky-mu-sb-ink:#f6f6f6;--ky-mu-wall:#3a4048;--ky-mu-hall:#d9d5c8;--ky-mu-over:#c0392b;--ky-mu-shadow:rgba(0,0,0,.2)";
10
+ const COMMON_DARK = "--ky-mu-neutral:#2b2f2c;--ky-mu-barrier:#05070a;--ky-mu-board:#0d1218;--ky-mu-board-ink:#e8e4da;--ky-mu-chair:#b9b4a6;--ky-mu-chair-edge:#050607;--ky-mu-sb:#05080b;--ky-mu-sb-ink:#e9e9e9;--ky-mu-wall:#0a0c0f;--ky-mu-hall:#1b1f1c;--ky-mu-over:#e0614f;--ky-mu-shadow:rgba(0,0,0,.45)";
11
11
  const hallVars = (which) => Object.entries(FLOORS).map(([name, f]) => `--ky-mu-f-${name}:${f[which][0]}`).join(";");
12
12
  const looks = (which) => Object.entries(FLOORS).map(([name, f]) => `.kyogijo.ky-multi[data-floor=${name}]{--ky-mu-floor:${f[which][0]};--ky-mu-slot:${f[which][1]}}`).join("");
13
13
  /**
@@ -27,6 +27,7 @@ ${Object.entries(FLOORS).map(([name, f]) => `html[data-theme=dark] .kyogijo.ky-m
27
27
  .kyogijo .ky-mu-hallfloor{fill:var(--ky-mu-neutral);stroke:var(--ky-mu-wall);stroke-width:.8}
28
28
  ${Object.keys(FLOORS).map((name) => `.kyogijo .ky-mu-hf-${name}{fill:var(--ky-mu-f-${name})}`).join("\n")}
29
29
  .kyogijo .ky-mu-wall{fill:none;stroke:var(--ky-mu-wall);stroke-width:2.2;stroke-linejoin:round}
30
+ .kyogijo .ky-mu-shadow{fill:var(--ky-mu-shadow)}
30
31
  .kyogijo .ky-mu-over{fill:none;stroke:var(--ky-mu-over);stroke-width:1.4;stroke-dasharray:5 3}
31
32
  .kyogijo .ky-mu-barrier{fill:none;stroke:var(--ky-mu-barrier);stroke-width:1;stroke-opacity:.9}
32
33
  .kyogijo .ky-mu-board{fill:var(--ky-mu-board)}
@@ -0,0 +1,32 @@
1
+ import type { MultiOptions } from "./multi.types.ts";
2
+ import { type PresetTable } from "./turn.camera.ts";
3
+ import { type KyogijoTurn } from "./turn.dom.ts";
4
+ import { type TurnModel, type TurnSettings } from "./turn.model.ts";
5
+ import type { Sport } from "./types.ts";
6
+ /** How high a surround stands: the ITTF's "about 75 cm" (Handbook 3.2.3.3). A layout of another sport with surrounds has the same (ours: no other rulebook is read for it). */
7
+ export declare const SURROUND_HEIGHT: number;
8
+ /**
9
+ * The viewpoints of a layout. Overhead, broadcast and the low corner are a single surface's (`TURN_PRESETS`); the end-on view of a net sport looks along its surfaces' length, where the nets are seen whole, as `NET_PRESETS` does. All are turned a quarter where
10
+ * the floor or the surfaces stand across the picture, so that the long way of the floor runs across the screen. `floor` is the picture's frame (the hall's, turned if the hall asks) and `lengthAlongX` says whether the surfaces' length runs along its x.
11
+ */
12
+ export declare function multiPresets(sport: Sport, floor: {
13
+ w: number;
14
+ h: number;
15
+ }, lengthAlongX: boolean): PresetTable;
16
+ /**
17
+ * A tournament layout as a 3D model: the floor is the layout's flat drawing, and on it stand each surface as it stands on its own page, the surrounds, the umpires' chairs and score tables, the scoreboards and, with `stadium`, the stands
18
+ * of the hall. A `TurnModel` like any other: `turnMarkupOf` and `mountMultiTurn` make a view of it.
19
+ */
20
+ export declare function buildMultiTurn(options: MultiOptions, settings?: TurnSettings): TurnModel;
21
+ /**
22
+ * Mount a tournament layout as a 3D view in a container: the same view as `mountKyogijoTurn`'s, with the controls, the pointer, the keys and the auto-turn of every 3D view, over the layout's floor with each surface standing on it.
23
+ * @example
24
+ * ```ts no-run
25
+ * import { mountMultiTurn } from "@johnmorrisdotca/kyogijo-stadiums/multi";
26
+ * const view = mountMultiTurn(document.querySelector("#hall")!, { preset: "tabletennis-4", stadium: true }, { preset: "broadcast" });
27
+ * view.set({ yaw: 40 });
28
+ * ```
29
+ */
30
+ export declare function mountMultiTurn(host: HTMLElement, options: MultiOptions, settings?: TurnSettings): KyogijoTurn<MultiOptions>;
31
+ /** A tournament layout as the markup of a 3D view, still until a page's script makes it turn: pure, so a server can make it. */
32
+ export declare function multiTurnMarkup(options: MultiOptions, settings?: TurnSettings): string;