@fabi-play/engine 0.2.0 → 0.5.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/dist/index.d.ts CHANGED
@@ -56,7 +56,9 @@ export type Backdrop = "video" | "none";
56
56
  * image is cropped to fill the screen), with any backdrop, so avatars and hands are where the children stand (a
57
57
  * "virtual mirror"). The screen decides it: with 'video', where the video is drawn (cover or contain); with 'none',
58
58
  * the whole image contained at 92% of the viewport's height, bottom-aligned. Games don't compute it: they just use
59
- * it. Body points are in player space (0–1 of the camera image, already mirrored like the video), so a point p is on
59
+ * it. It is not fixed: with automatic framing (the default, see GameManifest.framing) the screen zooms in on children
60
+ * standing far away, up to 1.8×, so the image may reach past every edge; it changes only at calibration and in breaks
61
+ * (pause, level, turn), never during play, and arrives in a backdrop message. Body points are in player space (0–1 of the camera image, already mirrored like the video), so a point p is on
60
62
  * screen at (x + p.x·w, y + p.y·h): see toScreen.
61
63
  */
62
64
  export interface BackdropView {
@@ -1874,21 +1876,21 @@ export interface Palette {
1874
1876
  hair?: string;
1875
1877
  }
1876
1878
  /** The head's outline. */
1877
- export type HeadShape = "round" | "wide" | "tall" | "square" | "bulb" | "bucket";
1879
+ export type HeadShape = "round" | "wide" | "tall" | "square" | "bulb" | "bucket" | "snout-long";
1878
1880
  /** The ears (or what is in their place: horns, antennae, a fin). */
1879
- export type EarKind = "none" | "pointy" | "round" | "big-round" | "long" | "side" | "tufts" | "antenna" | "antennae" | "horns" | "unicorn" | "floppy" | "droopy" | "fin" | "human";
1881
+ export type EarKind = "none" | "pointy" | "round" | "big-round" | "long" | "side" | "tufts" | "antenna" | "antennae" | "horns" | "unicorn" | "floppy" | "droopy" | "fin" | "human" | "pixie";
1880
1882
  /** How the eyes are drawn. */
1881
1883
  export type EyeKind = "dot" | "big" | "mask" | "screen" | "almond" | "visor" | "calm" | "slit" | "goggle" | "bead";
1882
1884
  /** How the mouth (or beak) is drawn. */
1883
- export type MouthKind = "none" | "smile" | "open" | "cat" | "beak" | "teeth" | "grill" | "tiny" | "smirk" | "bill" | "hook" | "jaws";
1885
+ export type MouthKind = "none" | "smile" | "open" | "cat" | "beak" | "teeth" | "grill" | "tiny" | "smirk" | "bill" | "hook" | "jaws" | "toothy";
1884
1886
  /** The patch around the nose and mouth. */
1885
1887
  export type MuzzleKind = "none" | "oval" | "heart" | "monkey" | "disc" | "cheeks" | "band";
1886
1888
  /** The tail, behind the body. */
1887
- export type TailKind = "none" | "fluffy" | "brush" | "pom" | "long" | "curl" | "tuft" | "striped" | "spiky" | "arrow" | "fish" | "plume";
1889
+ export type TailKind = "none" | "fluffy" | "brush" | "pom" | "long" | "curl" | "tuft" | "striped" | "spiky" | "arrow" | "fish" | "plume" | "thick";
1888
1890
  /** Things on the head. */
1889
- export type HeadExtra = "mane" | "rainbow-mane" | "stripes" | "spikes" | "spots" | "curl" | "helmet" | "bolts" | "whiskers" | "tuft" | "brows" | "eggshell" | "wool" | "eye-spot" | "crest" | "forehead" | "gills" | "ruff" | "hair" | "curls" | "locks" | "ninja-hood" | "cap" | "safari-hat" | "wizard-hat" | "plume" | "stripe" | "bandana" | "eye-patch" | "dive-mask" | "domino";
1891
+ export type HeadExtra = "mane" | "rainbow-mane" | "stripes" | "spikes" | "spots" | "curl" | "helmet" | "bolts" | "whiskers" | "tuft" | "brows" | "eggshell" | "wool" | "eye-spot" | "crest" | "forehead" | "gills" | "ruff" | "hair" | "curls" | "locks" | "ninja-hood" | "cap" | "safari-hat" | "wizard-hat" | "plume" | "stripe" | "bandana" | "eye-patch" | "dive-mask" | "domino" | "bun" | "flower-crown";
1890
1892
  /** Things on the body. */
1891
- export type BodyExtra = "wings" | "backpack" | "sheet" | "tentacles" | "panel" | "badge" | "joints" | "feathers" | "flippers" | "boots" | "scarf" | "spots" | "wool" | "robe" | "cape" | "fins" | "tank" | "straps" | "belt" | "stripes" | "pauldrons" | "emblem" | "pocket" | "racing-stripe" | "star";
1893
+ export type BodyExtra = "wings" | "backpack" | "sheet" | "tentacles" | "panel" | "badge" | "joints" | "feathers" | "flippers" | "boots" | "scarf" | "spots" | "wool" | "robe" | "cape" | "fins" | "tank" | "straps" | "belt" | "stripes" | "pauldrons" | "emblem" | "pocket" | "racing-stripe" | "star" | "tiny-arms" | "strong-legs" | "wings-fairy" | "wand" | "petals";
1892
1894
  /** An avatar's face. */
1893
1895
  export interface FaceDef {
1894
1896
  /** How the eyes are drawn. */
@@ -1910,7 +1912,7 @@ export interface FaceDef {
1910
1912
  /** Eyebrows of this colour (people): a little attitude. */
1911
1913
  brows?: string;
1912
1914
  }
1913
- /** The age band an avatar is for, or 'all': offered in every band (Fabi the fox, the app's mascot). */
1915
+ /** The age band an avatar is for, or 'all': of no band (Fabi the fox, the app's mascot: the host, in no picker). */
1914
1916
  export type AvatarBand = AgeRange | "all";
1915
1917
  /** An avatar, as data: one renderer draws any definition. */
1916
1918
  export interface AvatarDef {
@@ -1922,11 +1924,17 @@ export interface AvatarDef {
1922
1924
  it: string;
1923
1925
  };
1924
1926
  /**
1925
- * The age band the avatar is for: its style and its body proportions (see BAND_BODY in rig.ts). 'all': in every
1926
- * band's list, drawn with the 6–8 proportions.
1927
+ * The age band the avatar is for, its home: its style and its body proportions (see BAND_BODY in rig.ts). 'all': in
1928
+ * no band's list (the mascot), drawn with the 6–8 proportions. See alsoIn for an avatar offered in other bands too.
1927
1929
  */
1928
1930
  band: AvatarBand;
1929
- /** A special avatar (the mascot): first in every band's list; pickers may mark it. */
1931
+ /**
1932
+ * Other age bands the avatar is also offered in (listed in their AVATAR_BANDS too), besides its own band. Shown in
1933
+ * one of them, it is drawn with that band's proportions (bodyBand(def, band)); its band stays its home: its style
1934
+ * (outline), bandOf, and its proportions when the band shown is not known. Not for 'all' (the mascot).
1935
+ */
1936
+ alsoIn?: readonly AgeRange[];
1937
+ /** A special avatar (the mascot): the host, not a player; in no band's list (AVATAR_BANDS). */
1930
1938
  special?: boolean;
1931
1939
  /** Its colours. */
1932
1940
  palette: Palette;
@@ -28,6 +28,7 @@ var DEFAULT_AVATARS_BY_AGE = {
28
28
  };
29
29
  var DEFAULT_AVATARS = DEFAULT_AVATARS_BY_AGE["6-8"];
30
30
  var toScreen = (view, p) => view ? { x: view.x + p.x * view.w, y: view.y + p.y * view.h } : { x: p.x, y: p.y };
31
+ var COVER_ASPECT = 16 / 9;
31
32
  var POSE_HEADER = 12;
32
33
  var POSE_BODY_BYTES = LANDMARKS * 4;
33
34
  var poseBytes = (bodies) => POSE_HEADER + bodies * POSE_BODY_BYTES;
@@ -5176,6 +5177,10 @@ async function createEngine(opts = {}) {
5176
5177
  };
5177
5178
  unlisten.push(
5178
5179
  play.on("start", (m) => lateHint(m?.device)),
5180
+ // The simple API knows muted only from the start (its getter is false before): read it again then.
5181
+ play.on("start", (m) => {
5182
+ if (typeof m?.muted === "boolean") sound.muted = m.muted;
5183
+ }),
5179
5184
  play.on("frame", (m) => setPlayers(m?.players)),
5180
5185
  play.on("players", (m) => setPlayers(m?.players)),
5181
5186
  play.on("backdrop", (m) => setBackdrop(m?.backdrop, m?.view)),