@korial29/tiny-fps 0.113.0 → 0.115.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.
@@ -25,12 +25,14 @@ export interface Piece {
25
25
  /** The stump's cut face on the body (soldier() keeps it there), and seconds since the cut. */
26
26
  at: Vec3;
27
27
  age: number;
28
+ /** The BUILD of the body it came off (rig.ts). */
29
+ b?: number;
28
30
  }
29
31
  /**
30
32
  * The limb `limb` of `p` coming off the body posed as `s`: thrown with the body's speed, a little
31
33
  * outward (and back) from the hips and up, tumbling outward.
32
34
  */
33
- export declare const sever: (limb: number, s: ReturnType<typeof solve>, p: PlayerState) => Piece;
35
+ export declare const sever: (limb: number, s: ReturnType<typeof solve>, p: PlayerState, build?: number) => Piece;
34
36
  /**
35
37
  * One step of dt seconds of a piece's fall: gravity and spin, then the floor under it, which it
36
38
  * bounces off, rubs along and lies down on (its long axis toppling to the level).
@@ -45,6 +47,7 @@ export declare const track: (r: {
45
47
  p: PlayerState;
46
48
  gait: Pick<Gait, "pose">;
47
49
  cut?: Piece;
50
+ build?: number;
48
51
  }, dt: number, floor: Ground, fresh: boolean, tracer?: Pick<Tracer, "shock" | "spit">) => void;
49
52
  /** Appends the piece at level of detail `lod`, in `colors` (see palette()), sunk by `sink` metres with the body. */
50
53
  export declare const piece: (out: number[], c: Piece, colors: number[][], lod: number, sink: number, face?: ArrayLike<number>) => void;
@@ -43,7 +43,9 @@ export declare const PAD: {
43
43
  h: number;
44
44
  cut: number;
45
45
  };
46
- /** Appends both shoulder pads at level of detail `lod` on the arm joints (`arms`: the left's and the right's place and turn), in `plate` (white when absent). */
47
- export declare const shoulders: (out: number[], arms: [Vec3, Quat][], lod: number, plate?: number[]) => void;
46
+ /** The woman's shoulder pads and cup, scaled about their joints: her shoulders' caps are smaller, the cup flatter. */
47
+ export declare const PAD_F: number, CUP_F: Vec3;
48
+ /** Appends both shoulder pads at level of detail `lod` on the arm joints (`arms`: the left's and the right's place and turn), in `plate` (white when absent), `scale`d about the joints. */
49
+ export declare const shoulders: (out: number[], arms: [Vec3, Quat][], lod: number, plate?: number[], scale?: number) => void;
48
50
  /** Appends the crotch cup at level of detail `lod` on the pelvis joint at `at` turned by `q`, in `plate` (white when absent). */
49
- export declare const crotch: (out: number[], at: Vec3, q: Quat, lod: number, plate?: number[]) => void;
51
+ export declare const crotch: (out: number[], at: Vec3, q: Quat, lod: number, plate?: number[], scale?: number | Vec3) => void;
@@ -134,6 +134,8 @@ export interface Renderer {
134
134
  muzzle(id: number): Vec3 | undefined;
135
135
  /** The runners of the players `ids` grin for a moment: their team has captured. */
136
136
  cheer(ids: number[]): void;
137
+ /** The body of each player (PlayerInfo.body, BODY), from the roster: the man's for one not in it. */
138
+ wear(builds: ReadonlyMap<number, number>): void;
137
139
  destroy(): void;
138
140
  }
139
141
  /** 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. */
@@ -33,6 +33,13 @@ export declare const JOINTS: number;
33
33
  export declare const PARENT: number[];
34
34
  /** Each joint's offset from its parent in the rest pose, metres; the pelvis's from the feet origin. */
35
35
  export declare const REST: Vec3[];
36
+ /** The builds a runner can have (PlayerInfo.body): today's man, and the woman. */
37
+ export declare const BUILD: {
38
+ readonly MALE: 0;
39
+ readonly FEMALE: 1;
40
+ };
41
+ /** Each build's rest offsets (BUILD). */
42
+ export declare const RESTS: Vec3[][];
36
43
  /** A pose: where the runner stands, how it faces, and each joint's rotation from its rest. */
37
44
  export interface Pose {
38
45
  /** The feet origin in the world (the player's position). */
@@ -42,10 +49,12 @@ export interface Pose {
42
49
  hips: Vec3;
43
50
  /** Local rotation of each joint, relative to its rest, in its parent's frame. */
44
51
  rot: Quat[];
52
+ /** The rest offsets of its build (RESTS), the man's when absent. Copies of a pose keep it. */
53
+ rest?: Vec3[];
45
54
  }
46
55
  export declare const IDENTITY: Quat;
47
56
  /** The rest pose at `at`, facing `yaw`. */
48
- export declare const rest: (at?: Vec3, yaw?: number) => Pose;
57
+ export declare const rest: (at?: Vec3, yaw?: number, build?: number) => Pose;
49
58
  /** a then b: the rotation b applied in a's frame. */
50
59
  export declare const mul: ([ax, ay, az, aw]: Quat, [bx, by, bz, bw]: Quat) => Quat;
51
60
  /** The rotation of `angle` radians about the unit `axis`. */
@@ -2,6 +2,8 @@ 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
+ /** The hair colour of the woman `id`: as hairOf(), never the shaved head's (her hair is a style of hair.ts). */
6
+ export declare const tressOf: (id: number) => number[];
5
7
  /** How dark the shaved beard of the runner `id` is, 0 (none) to 1. */
6
8
  export declare const beardOf: (id: number) => number;
7
9
  /** Whether the runner `id` has a shaved head (the last of HAIRS): no hair to give a length to. */
@@ -13,12 +15,21 @@ export declare const eyesOf: (id: number) => number[];
13
15
  * With `suit` (the moon's, the user 2026-11-10), a dark grey space suit under white armour: the
14
16
  * team's colour only in a stripe down each side, black gloves, boots and belt. Then the pupils,
15
17
  * 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.
18
+ * the shaved beard is on it, 0 to 1. `fem` (the woman's): redder lips, darker lashes.
17
19
  */
18
- export declare const palette: (jacket: number[], hair?: number[], eyes?: number[], suit?: boolean, tone?: number[], beard?: number) => number[][];
20
+ export declare const palette: (jacket: number[], hair?: number[], eyes?: number[], suit?: boolean, tone?: number[], beard?: number, fem?: boolean) => number[][];
19
21
  /** 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). */
20
22
  export declare const CUFF: number[];
21
23
  export declare const CUFF_SIDES: number;
24
+ /**
25
+ * A point of the man's skull at rest, `a` radians round it from the front (+ toward +x) at height
26
+ * `y`, `off` metres out of it along its normal: what hair.ts lays a woman's hair on.
27
+ */
28
+ export declare const scalp: (a: number, y: number, off?: number) => Vec3;
29
+ /** The crown of the man's head at rest, metres. */
30
+ export declare const TOP = 1.803;
31
+ /** The woman's: a higher, rounder forehead, no sideburn, clear of the ear, a higher nape. hair.ts lays her styles down to it. */
32
+ export declare const HAIRLINE_F: number[][];
22
33
  /** The rest mesh: per vertex a position and a normal, two joints and the weight of the second. */
23
34
  export interface Skin {
24
35
  v: Float32Array;
@@ -36,6 +47,9 @@ export interface Skin {
36
47
  cm: Float32Array;
37
48
  /** Per vertex the KIND of part it is (features.ts). */
38
49
  g: Uint8Array;
50
+ /** The BUILD it is (rig.ts), the man's when absent; and, for another, the man's rest mesh it was made from, as `v`: the armour's regions are written on him. */
51
+ b?: number;
52
+ u?: Float32Array;
39
53
  /**
40
54
  * Per channel (CH in features.ts) the vertices it moves and, six floats each, how far at full
41
55
  * weight: the position's shift, then the normal's. skin() adds them to the rest mesh.
@@ -57,24 +71,28 @@ export interface Skin {
57
71
  t: Uint32Array;
58
72
  };
59
73
  }
74
+ /** How far out the woman's bust stands at its fullest, on the man's rest mesh, metres. */
75
+ export declare const BUST = 0.022;
60
76
  /**
61
77
  * The skin at a level of detail: 0 far, 1 near (see DETAIL in mesh.ts), 2 near, headless and
62
78
  * handless, for the eye, 3 close (CLOSE in render.ts), twice the rings and half more sides, the
63
79
  * face carved finest. Built once.
64
80
  */
65
- export declare const body: (lod: number) => Skin;
81
+ export declare const body: (lod: number, build?: number) => Skin;
66
82
  /**
67
83
  * The skin at a level of detail without the LIMB `limb`, then the limb alone, each closed by a
68
84
  * glowing cut face whose middle is the last vertex of the last triangle. Built once.
69
85
  */
70
- export declare const cut: (lod: number, limb: number) => Skin[];
86
+ export declare const cut: (lod: number, limb: number, build?: number) => Skin[];
87
+ /** A build's joints at rest (solve() of its rest pose), for what is placed on its body. */
88
+ export declare const bindOf: (build?: number) => Vec3[];
71
89
  /**
72
90
  * The turn of the shoulder plate of shoulder joint `j`: on the collarbone, it goes with a share of
73
91
  * the upper arm's swing, all of it as the arm comes up over the shoulder, and with none of its
74
92
  * turn about itself, as a plate strapped to the trunk does (the user, 2026-11-10: it rode a
75
93
  * reaching arm round to the front of the chest).
76
94
  */
77
- export declare const capped: (rot: Quat[], j: number) => Quat;
95
+ export declare const capped: (rot: Quat[], j: number, build?: number) => Quat;
78
96
  /**
79
97
  * Appends the skin in the pose `solved` (see solve()) to `out` as triangles in the renderer's
80
98
  * vertex format, each in its palette colour: a vertex goes where the two joints it hangs on would
@@ -28,6 +28,8 @@ export interface Runner {
28
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. */
29
29
  hurt: number;
30
30
  grin: number;
31
+ /** How far out the fist of a punch is, 0 to 1, eased. */
32
+ jab: number;
31
33
  /** 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
34
  face: Face;
33
35
  dt: number;
@@ -35,6 +37,8 @@ export interface Runner {
35
37
  seat?: Seat;
36
38
  /** The muzzle of the long gun in his hands as last drawn, from his feet: where its shots are seen to leave (combat.ts). */
37
39
  tip?: Vec3;
40
+ /** The BUILD of the body (rig.ts, PlayerInfo.body): the man's when absent. */
41
+ build?: number;
38
42
  }
39
43
  /**
40
44
  * The seat of a player who rides: the rover whose `driver` or `rider` he is. Nothing for one on
@@ -43,14 +47,19 @@ export interface Runner {
43
47
  export declare const seatOf: (p: PlayerState, rovers?: Rover[]) => Seat | undefined;
44
48
  /** Seconds a hit's wince lasts, and the grin of a capture or of a foe put down. */
45
49
  export declare const HURT: number, GRIN: number;
50
+ /**
51
+ * A woman's traits on the face of her id: never the heavy brow ridge, the wide jaw or the long
52
+ * lower face of the draw, fuller lips, and the scalp's hair flat under her style (hair.ts).
53
+ */
54
+ export declare const femme: (w: Float32Array) => void;
46
55
  /** A runner as first seen: in the pose its state asks for, no ease. */
47
- export declare const createRunner: (p: PlayerState, seat?: Seat) => Runner;
56
+ export declare const createRunner: (p: PlayerState, seat?: Seat, build?: number) => Runner;
48
57
  /**
49
58
  * Moves each runner of `book` to its player in `others` after dt seconds: a new player gets a
50
59
  * runner already in pose, one that left loses it. With a `world` the feet stand on the brushes
51
60
  * under them. The `tracer` gets the sparks of a limb cut off.
52
61
  */
53
- export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World, tracer?: Pick<Tracer, "shock" | "spit">, rovers?: Rover[]) => void;
62
+ export declare const animate: (book: Map<number, Runner>, others: PlayerState[], dt: number, world?: World, tracer?: Pick<Tracer, "shock" | "spit">, rovers?: Rover[], builds?: ReadonlyMap<number, number>) => void;
54
63
  /**
55
64
  * A long gun's butt plate in the hollow of the right shoulder: from the shoulder joint, in the
56
65
  * chest's frame (to its right, up, back). The gun goes from there along the look, so it is
@@ -26,7 +26,10 @@ export declare const swingOf: (p: Pick<PlayerState, "cut" | "heavy">) => {
26
26
  * the arc round his look (the foe's own angular radius counts: his edge in the arc is a hit), with
27
27
  * the heights of the two bodies overlapping and no brush between the chests.
28
28
  */
29
- export declare const strike: (w: World, p: PlayerState, foes: PlayerState[]) => PlayerState[];
29
+ export declare const strike: (w: World, p: PlayerState, foes: PlayerState[], { reach, arc }?: {
30
+ reach: number;
31
+ arc: number;
32
+ }) => PlayerState[];
30
33
  /**
31
34
  * Whether the cut of `p`, striking now, meets the cut of the foe `f` (where `p` drew him) and the
32
35
  * two lock blades: `f` swings the katana and strikes within LOCK_WINDOW ticks of now, before or
@@ -167,6 +167,23 @@ export declare const FLAG_H = 2.2;
167
167
  export declare const FLAG_RETURN = 10;
168
168
  /** Health of a player; a hit takes 1, so HP_MAX hits put him down. */
169
169
  export declare const HP_MAX = 5;
170
+ /**
171
+ * A punch (the user, 2026-11-11): FIRE with no weapon at all. A swing of `ticks` that strikes at
172
+ * `strike` whoever is within `reach` of his centre less PLAYER_R, inside `arc` round his look (the
173
+ * katana's strike test, blade.ts). It takes half a point of health: every PUNCH_HITS punches a
174
+ * player takes cost him 1 hp (the host counts; the wire's health is whole). The PUNCH_STUN-th he
175
+ * takes within PUNCH_MEMORY ticks of the one before stuns him: a stumble as a tackle's, thrown the
176
+ * way the puncher faces, and he drops the flag he carries.
177
+ */
178
+ export declare const PUNCH: {
179
+ ticks: number;
180
+ strike: number;
181
+ reach: number;
182
+ arc: number;
183
+ hp: number;
184
+ hold: number;
185
+ };
186
+ export declare const PUNCH_HITS: number, PUNCH_STUN: number, PUNCH_MEMORY: number;
170
187
  /** Shots the rack loads. */
171
188
  export declare const AMMO_MAX = 60;
172
189
  /**
@@ -1,8 +1,9 @@
1
1
  import type { Input, PlayerInfo, Snapshot } from './types';
2
- /** join: the first frame of a peer. map: the host picks the map of the next match (MAPS key). */
2
+ /** join: the first frame of a peer, `body` the character he picked (BODY, the man without it). map: the host picks the map of the next match (MAPS key). */
3
3
  export type ClientText = {
4
4
  t: 'join';
5
5
  name: string;
6
+ body?: number;
6
7
  } | {
7
8
  t: 'map';
8
9
  map: string;
@@ -107,6 +107,14 @@ export declare class Room {
107
107
  * crosses where `p` drew him (`limbOf`).
108
108
  */
109
109
  private cut;
110
+ /**
111
+ * A punch of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him (the
112
+ * strike test, with PUNCH's reach and arc) takes half a point, 1 hp every PUNCH_HITS punches; the
113
+ * `hits` count goes up once. The PUNCH_STUN-th he takes with no more than PUNCH_MEMORY ticks
114
+ * between two stuns him as a tackle does: a stumble thrown the way `p` faces, the flag dropped,
115
+ * `by` the puncher.
116
+ */
117
+ private punch;
110
118
  /**
111
119
  * The rail gun's bolt of `p` at the view tick `view`: the first enemy it enters as `p` drew him is
112
120
  * drained for RAIL_TICKS more (`slow`). A first touch, when he was not drained, takes 1 hp at once
@@ -16,7 +16,14 @@ export interface PlayerInfo {
16
16
  team: number;
17
17
  /** CSS colour: the team's (TEAM_COLOR). */
18
18
  color: string;
19
+ /** BODY: the character he plays. Absent for the man, as before there was a choice. */
20
+ body?: number;
19
21
  }
22
+ /** The characters a player can be (PlayerInfo.body, the join's `body`): the look only, the game is the same for both. */
23
+ export declare const BODY: {
24
+ readonly MALE: 0;
25
+ readonly FEMALE: 1;
26
+ };
20
27
  /** Bits of Input.keys. Keys are read by KeyboardEvent.code, so WASD is ZQSD on AZERTY. */
21
28
  export declare const KEY: {
22
29
  readonly FORWARD: 1;
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.113.0",
5
+ "version": "0.115.0",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"