@korial29/tiny-fps 0.109.1 → 0.111.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.
@@ -0,0 +1,55 @@
1
+ import type { PlayerState } from '../shared/types';
2
+ /** What a face answers to, each 0 to 1 but the gaze. */
3
+ export interface Mood {
4
+ /** Down: a grimace, the eyes shut. */
5
+ down: boolean;
6
+ /** Just hit: a wince, 1 at the hit. */
7
+ hurt: number;
8
+ /** Sprinting, climbing, hanging, on a wall. */
9
+ effort: number;
10
+ /** Aiming. */
11
+ focus: number;
12
+ /** Cutting with the katana, dashing. */
13
+ shout: number;
14
+ /** A capture, a foe put down. */
15
+ grin: number;
16
+ /** Where he aims from where his head points: radians to his right, and up. */
17
+ gx: number;
18
+ gy: number;
19
+ }
20
+ export declare const CALM: Mood;
21
+ /** The expressions, each the weights of the channels it moves. */
22
+ export declare const POSE: {
23
+ /** At rest: a soldier's face, the brows a touch low, the mouth set. */
24
+ NEUTRAL: number[][];
25
+ EFFORT: number[][];
26
+ FOCUS: number[][];
27
+ GRIN: number[][];
28
+ SHOUT: number[][];
29
+ WINCE: number[][];
30
+ DOWN: number[][];
31
+ };
32
+ /** How far the eyes turn in their sockets, radians, for the full travel of the iris. */
33
+ export declare const REACH_X: number, REACH_Y: number;
34
+ export declare const BLINK: number;
35
+ /** How shut a blink `t` seconds old is. */
36
+ export declare const blink: (t: number) => number;
37
+ /** The face's channels for an expression alone, on the face of `id` (or on the plain one). */
38
+ export declare const expression: (pose: number[][], id?: number) => Float32Array;
39
+ export interface Face {
40
+ /** The channels' weights now (CH): what skin() takes. */
41
+ w: Float32Array;
42
+ /** How far each expression of LAYERS is in, 0 to 1, in their order. */
43
+ k: number[];
44
+ update(dt: number, mood: Mood): void;
45
+ }
46
+ export declare const createFace: (id: number) => Face;
47
+ /** Whether the player is in the burst of a dash. */
48
+ export declare const dashing: (p: PlayerState) => boolean;
49
+ /** How hard the player is working, 0 to 1: a sprint, a climb, a hang, a run along a wall, a stumble. */
50
+ export declare const strain: (p: PlayerState) => number;
51
+ /**
52
+ * Whether `p` just put a foe down: his hit counter went on from `was` in the frame one of the
53
+ * `others` went down (the snapshot says no more).
54
+ */
55
+ export declare const felled: (was: Pick<PlayerState, "hits">, p: PlayerState, before: (id: number) => Pick<PlayerState, "down"> | undefined, others: PlayerState[]) => boolean;
@@ -10,9 +10,14 @@ export declare const EXPR: {
10
10
  OUCH: number;
11
11
  GRIN: number;
12
12
  RAGE: number;
13
+ EFFORT: number;
14
+ FOCUS: number;
15
+ SHOUT: number;
13
16
  };
14
- /** The frames past the 40 of the wound levels: the flag carrier's glow, and dead. */
15
- export declare const GLOW: number, DEAD: number, FRAMES: number;
17
+ /** The frames past the 40 of the wound levels: the flag carrier's glow, and dead; then the 15 of effort, focus and the shout. */
18
+ export declare const GLOW: number, DEAD: number, MORE: number, FRAMES: number;
19
+ /** The frame of expression `e` at wound level `level`. */
20
+ export declare const frame: (level: number, e: number) => number;
16
21
  /** The colours of the palette, RGBA as one number each (little-endian ABGR for ImageData). */
17
22
  export declare const PALETTE: number[];
18
23
  /** Frame `n`'s pixels, FW by FH palette indices, row by row; built once. */
@@ -31,11 +36,18 @@ export interface Feel {
31
36
  got: boolean;
32
37
  /** Seconds the trigger has been held, firing. */
33
38
  firing: number;
39
+ /** What the runners' faces answer to as well (Mood in expression.ts): a sprint or a climb, aiming, a cut or a dash, a capture or a foe put down. */
40
+ effort?: boolean;
41
+ focus?: boolean;
42
+ shout?: boolean;
43
+ grin?: boolean;
34
44
  }
35
45
  /**
36
46
  * The face's mind (after DOOM's, not its code): the frame for this moment. A hit turns the face
37
47
  * toward its side, or grimaces straight on when it comes from ahead or from nowhere; a heavy hit (2
38
48
  * health or more) is an ouch; a new weapon a grin; the trigger held for 2 s a rage; and otherwise it
39
- * glances left and right every half second or so. Each reaction holds a second.
49
+ * glances left and right every half second or so. Each reaction holds a second. As the runners'
50
+ * faces do, it shouts in a cut or a dash, grins at a capture or a foe put down, is set while aiming
51
+ * and strains in a sprint or a climb.
40
52
  */
41
53
  export declare const mood: (rand?: () => number) => (dt: number, f: Feel) => number;
@@ -0,0 +1,102 @@
1
+ /** What a vertex of the skin is part of: the fields move each kind its own way. */
2
+ export declare const KIND: {
3
+ readonly BODY: 0;
4
+ readonly HEAD: 1;
5
+ readonly WHITE: 2;
6
+ readonly IRIS: 3;
7
+ readonly LID_U: 4;
8
+ readonly LID_L: 5;
9
+ readonly EAR: 6;
10
+ /** Far, where the face is not carved: the marks that stand for the eyes, the brows and the mouth, and the nose. */
11
+ readonly MARK: 7;
12
+ };
13
+ /** The channels: expressions first, then (from `TRAITS` on) a runner's own traits. */
14
+ export declare const CH: {
15
+ /** The upper lids down onto the lower ones; BLINK_MID keeps them on the ball half way (see lids()). */
16
+ readonly BLINK: 0;
17
+ readonly BLINK_MID: 1;
18
+ /** The upper lids up off the irises. */
19
+ readonly WIDE: 2;
20
+ /** The lower lids and the cheeks up. */
21
+ readonly SQUINT: 3;
22
+ /** The irises to the runner's right, and up: 1 is the end of their travel. */
23
+ readonly LOOK_X: 4;
24
+ readonly LOOK_Y: 5;
25
+ /** The brows up; their inner ends down and in (anger, effort); their inner ends up (pain, worry). */
26
+ readonly BROW_UP: 6;
27
+ readonly BROW_DOWN: 7;
28
+ readonly BROW_PAIN: 8;
29
+ /** The jaw turned down about its hinge. */
30
+ readonly JAW: 9;
31
+ /** The mouth's corners up and out with the cheeks; down; the lips drawn apart off the teeth; pursed. */
32
+ readonly SMILE: 10;
33
+ readonly FROWN: 11;
34
+ readonly GRIT: 12;
35
+ readonly PUCKER: 13;
36
+ /** The irises back with the ball's curve as they leave its middle: lookIn() is its weight. */
37
+ readonly LOOK_IN: 14;
38
+ /** A wider head, a longer lower face, a wider jaw, fuller cheeks. */
39
+ readonly WIDTH: 15;
40
+ readonly CHIN: 16;
41
+ readonly JOWL: 17;
42
+ readonly CHEEK: 18;
43
+ /** A wider nose, a longer one, a heavier brow ridge, fuller lips, ears standing out. */
44
+ readonly NOSE_W: 19;
45
+ readonly NOSE_L: 20;
46
+ readonly RIDGE: 21;
47
+ readonly LIPS: 22;
48
+ readonly EARS: 23;
49
+ /** Longer hair (0 to 1), heavier lids, and what is not the same on both sides of a face. */
50
+ readonly HAIR: 24;
51
+ readonly LIDS: 25;
52
+ readonly ASYM: 26;
53
+ };
54
+ export declare const TRAITS: number, CHANNELS: number;
55
+ /** The middle of the right eye (x, y); the left is its mirror. */
56
+ export declare const EYE: number[];
57
+ /** The iris' radius, the pupil's, and how far the iris travels sideways and up or down. */
58
+ export declare const IRIS_R: number, PUPIL_R: number, GAZE_X: number, GAZE_Y: number;
59
+ /** The mouth: the height of the line between the lips at the middle, how it falls to the corners (per m2), and the corners. */
60
+ export declare const MOUTH_Y: number, MOUTH_K: number, MOUTH_X: number;
61
+ /** The line between the lips at `ax` across. */
62
+ export declare const lipLine: (ax: number) => number;
63
+ /** The front of the eye's ball at `ax` across (a right eye's), height y: its rim's plane outside it. */
64
+ export declare const ball: (ax: number, y: number) => number;
65
+ /**
66
+ * A lid's edge at t, `c` of the way to the other lid's open edge: an upper lid at 1 is shut, under
67
+ * 0 lifted.
68
+ */
69
+ export declare const lidEdge: (upper: boolean, t: number, c?: number) => number;
70
+ /**
71
+ * A point of a lid: t along the eye, s from its root in the face (0, just under the skin `surf`)
72
+ * to its edge (1), the edge `c` of the way to the other lid (lidEdge()). It lies on the ball.
73
+ */
74
+ export declare const lid: (upper: boolean, t: number, s: number, c: number, surf: (x: number, y: number) => number) => number[];
75
+ /** A point of the iris' disc, r from its middle (in radii) at angle a, the gaze (gx, gy) of its travel: on the ball. */
76
+ export declare const iris: (r: number, a: number, gx?: number, gy?: number, k?: number) => number[];
77
+ /** The weight of CH.LOOK_IN for a gaze (gx, gy) of the irises' travel: how far back the ball's curve takes them, in millimetres. */
78
+ export declare const lookIn: (gx: number, gy: number) => number;
79
+ /** A point of the white: the ball r from its middle (1 its rim), and past 1 its sides going back into the head. */
80
+ export declare const white: (r: number, a: number) => number[];
81
+ /** Whether (ax, y) is in the opening between the lids' roots, 1 inside, 0 outside, soft at its edge: the socket's floor is set back behind the ball there. */
82
+ export declare const socket: (ax: number, y: number) => number;
83
+ /** What a field knows of a vertex beyond its place: a lid's (t, s), a head's (jaw, hair, how far over the hairline). */
84
+ export type Uv = number[] | undefined;
85
+ /**
86
+ * How far channel `ch` at full weight moves the rest vertex at (x, y, z), of kind `kind`: metres,
87
+ * or nothing. `n` is its normal, `surf` the skin's depth at a point of the face (for the lids'
88
+ * roots).
89
+ */
90
+ export declare const shift: (ch: number, [x, y, z]: number[], kind: number, uv: Uv, n: number[], surf: (x: number, y: number) => number) => number[] | undefined;
91
+ /** A draw in [0, 1) for the runner `id`, one per `salt`: the same for everyone who sees him. */
92
+ export declare const hash: (id: number, salt: number) => number;
93
+ /** Skin tones, one per runner (toneOf()): fair, light (the old one), olive, tan, brown, dark. */
94
+ export declare const TONES: number[][];
95
+ /** A skin tone for the runner `id`, the same for everyone who sees him. */
96
+ export declare const toneOf: (id: number) => number[];
97
+ /**
98
+ * The face of the runner `id`: the weights of the trait channels (the expressions' are 0), the
99
+ * same for everyone who sees him. Each trait is the mean of two draws, so most faces are near the
100
+ * middle and a few are not.
101
+ */
102
+ export declare const lookOf: (id: number) => Float32Array;
@@ -47,4 +47,4 @@ export declare const track: (r: {
47
47
  cut?: Piece;
48
48
  }, dt: number, floor: Ground, fresh: boolean, tracer?: Pick<Tracer, "shock" | "spit">) => void;
49
49
  /** Appends the piece at level of detail `lod`, in `colors` (see palette()), sunk by `sink` metres with the body. */
50
- export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number) => void;
50
+ export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number, face?: ArrayLike<number>) => void;
@@ -132,6 +132,8 @@ export interface Renderer {
132
132
  steps(id: number): number | undefined;
133
133
  /** The muzzle of the long gun of the player `id`'s runner as last drawn, from his feet (Runner.tip). */
134
134
  muzzle(id: number): Vec3 | undefined;
135
+ /** The runners of the players `ids` grin for a moment: their team has captured. */
136
+ cheer(ids: number[]): void;
135
137
  destroy(): void;
136
138
  }
137
139
  /** Pixels drawn at most (1080p): every one is lit per light and shadow map, so a 4K screen at a pixel ratio of 2 would pay for 8 million. */
@@ -2,14 +2,20 @@ import type { Quat } from './rig';
2
2
  import type { Vec3 } from './mesh';
3
3
  /** A hair colour for the runner `id`, picked at random from HAIRS but the same for everyone who sees him. */
4
4
  export declare const hairOf: (id: number) => number[];
5
+ /** How dark the shaved beard of the runner `id` is, 0 (none) to 1. */
6
+ export declare const beardOf: (id: number) => number;
7
+ /** Whether the runner `id` has a shaved head (the last of HAIRS): no hair to give a length to. */
8
+ export declare const shaved: (id: number) => boolean;
5
9
  /** An iris colour for the runner `id`, as hairOf(). */
6
10
  export declare const eyesOf: (id: number) => number[];
7
11
  /** Jacket, its darker trim, trousers (the suit's legs, darker), skin, hair, boots, sole, gloves, the whites of the eyes and their irises, the lips, the skin in its folds (nostrils, the mouth, the ears' hollows), the brows, between the hair and the skin, the shaved beard's shadow and its edge, the line between the lips (as the folds), the side stripe on the jacket and on the trousers and the belt (the jacket's and the trousers' own colours but on a space suit), the light caught in the eyes, which glows, and the cut's cauterized face, which glows too. */
8
12
  /**
9
13
  * With `suit` (the moon's, the user 2026-11-10), a dark grey space suit under white armour: the
10
- * team's colour only in a stripe down each side, black gloves, boots and belt.
14
+ * team's colour only in a stripe down each side, black gloves, boots and belt. Then the pupils,
15
+ * the lashes, the cheeks' flush and the teeth. `tone` is the skin's (toneOf()), `beard` how dark
16
+ * the shaved beard is on it, 0 to 1.
11
17
  */
12
- export declare const palette: (jacket: number[], hair?: number[], iris?: number[], suit?: boolean) => number[][];
18
+ export declare const palette: (jacket: number[], hair?: number[], eyes?: number[], suit?: boolean, tone?: number[], beard?: number) => number[][];
13
19
  /** The ring where the eye's sleeve ends in the glove, which body.ts starts the palm on, and its sides: the close ones (the eye's body is close). A thin wrist (3.2 cm until the user, 2026-11-09). */
14
20
  export declare const CUFF: number[];
15
21
  export declare const CUFF_SIDES: number;
@@ -25,8 +31,19 @@ export interface Skin {
25
31
  o: Float32Array;
26
32
  /** Per triangle the LIMB it comes off with, NONE for the trunk's. */
27
33
  l?: Uint8Array;
28
- /** Per vertex how far it turns with the jaw when the mouth opens (radians, see skin()). */
29
- d: Float32Array;
34
+ /** Per corner a second palette colour and how much of it is blended into the first. */
35
+ c2: Uint8Array;
36
+ cm: Float32Array;
37
+ /** Per vertex the KIND of part it is (features.ts). */
38
+ g: Uint8Array;
39
+ /**
40
+ * Per channel (CH in features.ts) the vertices it moves and, six floats each, how far at full
41
+ * weight: the position's shift, then the normal's. skin() adds them to the rest mesh.
42
+ */
43
+ m: {
44
+ i: Uint16Array;
45
+ d: Float32Array;
46
+ }[];
30
47
  /**
31
48
  * The eye's own body only: the vertices round its shoulders that skin() relaxes once posed, how
32
49
  * much (0 to 1), and per each (offsets into the lists) its neighbours and its triangles.
@@ -67,4 +84,4 @@ export declare const capped: (rot: Quat[], j: number) => Quat;
67
84
  export declare const skin: (out: number[], s: Skin, { pos, rot }: {
68
85
  pos: Vec3[];
69
86
  rot: Quat[];
70
- }, colors: number[][], shut?: number, open?: number) => void;
87
+ }, colors: number[][], face?: ArrayLike<number>) => void;
@@ -5,6 +5,7 @@ import type { Tracer } from './beams';
5
5
  import type { Piece } from './limbs';
6
6
  import type { Vec3 } from './mesh';
7
7
  import type { Pose, Quat } from './rig';
8
+ import type { Face } from './expression';
8
9
  import type { Trail } from './trail';
9
10
  /** What a runner keeps between frames. */
10
11
  export interface Runner {
@@ -24,8 +25,12 @@ export interface Runner {
24
25
  t: number;
25
26
  /** The limb a katana's cut took off, while he is down (see limbs.ts). */
26
27
  cut?: Piece;
27
- /** Seconds left of the grimace a hit puts on his face. */
28
+ /** Seconds left of the grimace a hit puts on his face, and of the grin of a capture or of a foe put down. */
28
29
  hurt: number;
30
+ grin: number;
31
+ /** His face (expression.ts), and the seconds it has yet to live through: soldier() moves it once drawn, where the head's turn is known. */
32
+ face: Face;
33
+ dt: number;
29
34
  /** The seat he rides in, when he does and his rover is known. */
30
35
  seat?: Seat;
31
36
  /** The muzzle of the long gun in his hands as last drawn, from his feet: where its shots are seen to leave (combat.ts). */
@@ -36,6 +41,8 @@ export interface Runner {
36
41
  * foot, or whose rover is not among `rovers`.
37
42
  */
38
43
  export declare const seatOf: (p: PlayerState, rovers?: Rover[]) => Seat | undefined;
44
+ /** Seconds a hit's wince lasts, and the grin of a capture or of a foe put down. */
45
+ export declare const HURT: number, GRIN: number;
39
46
  /** A runner as first seen: in the pose its state asks for, no ease. */
40
47
  export declare const createRunner: (p: PlayerState, seat?: Seat) => Runner;
41
48
  /**
@@ -47,13 +47,24 @@ export declare const rockOf: (s: number, R: number, H: number) => {
47
47
  reach: (u: V3) => number;
48
48
  tops: number[][];
49
49
  };
50
+ /** A pit: PIT_R in radius, cut in a square of half side PIT_S of its crater's terrace, its floor at PIT_FLOOR, 7 m over the kill floor; a flight of PIT_STEPS steps up its east wall. */
51
+ export declare const PIT_R: number, PIT_S: number, PIT_FLOOR: number, PIT_STEPS: number;
50
52
  export declare const LAYOUT: {
51
53
  /** Outside the arena: the boulders (x, z, radius), the dishes, the ramps (the middle of the lip and the unit way up it), the wreck. */
52
54
  rocks: number[][];
53
55
  dishes: number[][];
54
56
  ramps: number[][];
55
57
  wreck: number[];
58
+ /** The pits, both sides: the middle, the terrace's level and the rows (z0, z1, the void's reach west and east). */
59
+ pits: {
60
+ x: number;
61
+ z: number;
62
+ level: number;
63
+ rows: number[][];
64
+ }[];
56
65
  /** Red's boulders along its walls and the field's stones; blue's are their mirrors, drawn by the scenery's flip. */
66
+ /** The craters of the relief, both sides: x, z, radius, depth as a share of it. */
67
+ bowls: number[][];
57
68
  boulders: number[][];
58
69
  /** Red's rocks, in the arena and in the boulder field: blue's are their mirrors. */
59
70
  crags: {
@@ -28,6 +28,8 @@ export interface Relief {
28
28
  /** The definition's pits and the box round them all (none: an empty box). */
29
29
  pits: Quad[];
30
30
  box: Quad;
31
+ /** 1 for each lattice square a pit touches or is next to, by its low node. */
32
+ pitted: Uint8Array;
31
33
  bound: Quad;
32
34
  /** The highest node: a ray above it meets no ground. */
33
35
  top: number;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@korial29/tiny-fps",
3
3
  "description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.109.1",
5
+ "version": "0.111.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"